OpenMS
FilterableList Class Reference

A widget which shows a list of text items, which can be filtered. More...

#include <OpenMS/VISUAL/MISC/FilterableList.h>

Inheritance diagram for FilterableList:
[legend]
Collaboration diagram for FilterableList:
[legend]

Public Slots

void setItems (const QStringList &items)
 
void setBlacklistItems (const QStringList &blacklist_items)
 
void addBlackListItems (const QStringList &additional_blacklist_items)
 
void removeBlackListItems (const QStringList &outdated_blacklist_items)
 

Signals

void filterChanged (const QString &filter_text)
 emitted when the user has edited the filter More...
 
void itemDoubleClicked (QListWidgetItem *item)
 emitted when this item was double clicked More...
 

Public Member Functions

 FilterableList (QWidget *parent)
 C'tor. More...
 
 ~FilterableList ()
 
QStringList getSelectedItems () const
 get the currently selected items of all visible items, i.e. must pass the filter and be selected More...
 
QStringList getAllVisibleItems () const
 get all items which are visible (i.e. excludes the ones which are hidden by the filter) More...
 

Private Slots

void filterEdited_ (const QString &filter_text)
 
void updateInternalList_ ()
 
void updateVisibleList_ ()
 update shown items, based on current items_wo_bl_ and current filter More...
 

Private Attributes

Ui::FilterableListui_
 
QStringList items_
 full list of items to show; when filtered only a subset is shown More...
 
QSet< QString > blacklist_
 blacklisted items, which are never shown, even if in items_; More...
 
QStringList items_wo_bl_
 items from item_ with blacklisted items removed More...
 

Detailed Description

A widget which shows a list of text items, which can be filtered.

A text field serves as filter expression (unix wildcard regEx support - see https://doc.qt.io/archives/qt-5.10/qregexp.html#wildcard-matching), which hides any items in the list which do not match the currently typed text.

You can also specify a blacklist of items which should never be shown, even though they are in the list. This is useful for only showing items which are not yet chosen elsewhere. Make sure all blacklist items are actually valid text items, which are contained in the list and can actually be blacklisted. Otherwise an exception is thrown.

To query the currently selected items, use getSelectedItems() or connect to the 'itemDoubleClicked()' signal.

Constructor & Destructor Documentation

◆ FilterableList()

FilterableList ( QWidget parent)
explicit

C'tor.

◆ ~FilterableList()

Member Function Documentation

◆ addBlackListItems

void addBlackListItems ( const QStringList &  additional_blacklist_items)
slot

adds items to a blacklist, i.e. they are not shown, even if they are in the item list

Exceptions
Exception::InvalidValueif any of additional_blacklist_items is not contained in current items

◆ filterChanged

void filterChanged ( const QString &  filter_text)
signal

emitted when the user has edited the filter

◆ filterEdited_

void filterEdited_ ( const QString &  filter_text)
privateslot

internally invoked when the filter was changed by the user emits 'filterChanged' signal and updates the current list of visible items

◆ getAllVisibleItems()

QStringList getAllVisibleItems ( ) const

get all items which are visible (i.e. excludes the ones which are hidden by the filter)

◆ getSelectedItems()

QStringList getSelectedItems ( ) const

get the currently selected items of all visible items, i.e. must pass the filter and be selected

◆ itemDoubleClicked

void itemDoubleClicked ( QListWidgetItem *  item)
signal

emitted when this item was double clicked

◆ removeBlackListItems

void removeBlackListItems ( const QStringList &  outdated_blacklist_items)
slot

removes items from blacklist, which should not be shown, even if they are in the item list

Exceptions
Exception::InvalidValueif any of outdated_blacklist_items is not contained in current blacklist

◆ setBlacklistItems

void setBlacklistItems ( const QStringList &  blacklist_items)
slot

sets items of a blacklist, i.e. they are not shown, even if they are in the item list

Exceptions
Exception::InvalidValueif any of blacklist_items is not contained in current items

◆ setItems

void setItems ( const QStringList &  items)
slot

Provide new items to the widget. Be careful if blacklisted items have already been set. If in doubt, clear blacklisted items first to avoid an exception.

Exceptions
Exception::InvalidValueif any of the internal blacklist_items_ is not contained in the given items

◆ updateInternalList_

void updateInternalList_ ( )
privateslot

recompute items_wo_bl_, whenever items_ or blacklist_ changed. and call updateVisibleList_()

◆ updateVisibleList_

void updateVisibleList_ ( )
privateslot

update shown items, based on current items_wo_bl_ and current filter

Member Data Documentation

◆ blacklist_

QSet<QString> blacklist_
private

blacklisted items, which are never shown, even if in items_;

◆ items_

QStringList items_
private

full list of items to show; when filtered only a subset is shown

◆ items_wo_bl_

QStringList items_wo_bl_
private

items from item_ with blacklisted items removed

◆ ui_

Ui::FilterableList* ui_
private