OpenMS
FilterableList.h
Go to the documentation of this file.
1 // Copyright (c) 2002-present, The OpenMS Team -- EKU Tuebingen, ETH Zurich, and FU Berlin
2 // SPDX-License-Identifier: BSD-3-Clause
3 //
4 // --------------------------------------------------------------------------
5 // $Maintainer: Chris Bielow $
6 // $Authors: Chris Bielow $
7 // --------------------------------------------------------------------------
8 
9 #pragma once
10 
11 #include <OpenMS/VISUAL/OpenMS_GUIConfig.h>
12 
13 #include <QSet>
14 #include <QWidget>
15 
16 namespace Ui
17 {
18  class FilterableList;
19 }
20 
21 class QListWidgetItem;
22 
23 namespace OpenMS
24 {
25  namespace Internal
26  {
42  class FilterableList : public QWidget
43  {
44  Q_OBJECT
45 
46  public:
48  explicit FilterableList(QWidget* parent);
50 
52  QStringList getSelectedItems() const;
53 
55  QStringList getAllVisibleItems() const;
56 
57  public slots:
61  void setItems(const QStringList& items);
62 
65  void setBlacklistItems(const QStringList& blacklist_items);
66 
69  void addBlackListItems(const QStringList& additional_blacklist_items);
70 
73  void removeBlackListItems(const QStringList& outdated_blacklist_items);
74 
75 
76  signals:
78  void filterChanged(const QString& filter_text);
79 
81  void itemDoubleClicked(QListWidgetItem* item);
82 
83  private slots:
86  void filterEdited_(const QString& filter_text);
87 
91 
94 
95  private:
97  QStringList items_;
98  // this needs to be a Set, otherwise items might be blacklisted twice, which will lead to an Exception (because it cannot find the item on the second round)
99  QSet<QString> blacklist_;
100  QStringList items_wo_bl_;
101  };
102  } // ns Internal
103 } // ns OpenMS
104 
105 // this is required to allow parent widgets (auto UIC'd from .ui) to have a FilterableList member
OpenMS::Internal::FilterableList FilterableList
Definition: FilterableList.h:106
A widget which shows a list of text items, which can be filtered.
Definition: FilterableList.h:43
void updateVisibleList_()
update shown items, based on current items_wo_bl_ and current filter
void setItems(const QStringList &items)
QStringList getSelectedItems() const
get the currently selected items of all visible items, i.e. must pass the filter and be selected
void addBlackListItems(const QStringList &additional_blacklist_items)
void filterEdited_(const QString &filter_text)
FilterableList(QWidget *parent)
C'tor.
void itemDoubleClicked(QListWidgetItem *item)
emitted when this item was double clicked
QStringList getAllVisibleItems() const
get all items which are visible (i.e. excludes the ones which are hidden by the filter)
void setBlacklistItems(const QStringList &blacklist_items)
QStringList items_
full list of items to show; when filtered only a subset is shown
Definition: FilterableList.h:97
Ui::FilterableList * ui_
Definition: FilterableList.h:96
QSet< QString > blacklist_
blacklisted items, which are never shown, even if in items_;
Definition: FilterableList.h:99
void filterChanged(const QString &filter_text)
emitted when the user has edited the filter
void removeBlackListItems(const QStringList &outdated_blacklist_items)
QStringList items_wo_bl_
items from item_ with blacklisted items removed
Definition: FilterableList.h:100
Main OpenMS namespace.
Definition: openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19
Definition: FLASHDeconvWizardBase.h:37