OpenMS  2.7.0
FilterableList.h
Go to the documentation of this file.
1 // --------------------------------------------------------------------------
2 // OpenMS -- Open-Source Mass Spectrometry
3 // --------------------------------------------------------------------------
4 // Copyright The OpenMS Team -- Eberhard Karls University Tuebingen,
5 // ETH Zurich, and Freie Universitaet Berlin 2002-2021.
6 //
7 // This software is released under a three-clause BSD license:
8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above copyright
11 // notice, this list of conditions and the following disclaimer in the
12 // documentation and/or other materials provided with the distribution.
13 // * Neither the name of any author or any participating institution
14 // may be used to endorse or promote products derived from this software
15 // without specific prior written permission.
16 // For a full list of authors, refer to the file AUTHORS.
17 // --------------------------------------------------------------------------
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 // ARE DISCLAIMED. IN NO EVENT SHALL ANY OF THE AUTHORS OR THE CONTRIBUTING
22 // INSTITUTIONS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
25 // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
27 // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
28 // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 //
30 // --------------------------------------------------------------------------
31 // $Maintainer: Chris Bielow $
32 // $Authors: Chris Bielow $
33 // --------------------------------------------------------------------------
34 
35 #pragma once
36 
37 #include <OpenMS/VISUAL/OpenMS_GUIConfig.h>
38 
39 #include <QSet>
40 #include <QWidget>
41 
42 namespace Ui
43 {
44  class FilterableList;
45 }
46 
47 class QListWidgetItem;
48 
49 namespace OpenMS
50 {
51  namespace Internal
52  {
68  class FilterableList : public QWidget
69  {
70  Q_OBJECT
71 
72  public:
74  explicit FilterableList(QWidget* parent);
76 
78  QStringList getSelectedItems() const;
79 
81  QStringList getAllVisibleItems() const;
82 
83  public slots:
87  void setItems(const QStringList& items);
88 
91  void setBlacklistItems(const QStringList& blacklist_items);
92 
95  void addBlackListItems(const QStringList& additional_blacklist_items);
96 
99  void removeBlackListItems(const QStringList& outdated_blacklist_items);
100 
101 
102  signals:
104  void filterChanged(const QString& filter_text);
105 
107  void itemDoubleClicked(QListWidgetItem* item);
108 
109  private slots:
112  void filterEdited_(const QString& filter_text);
113 
117 
120 
121  private:
123  QStringList items_;
124  // 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)
125  QSet<QString> blacklist_;
126  QStringList items_wo_bl_;
127  };
128  } // ns Internal
129 } // ns OpenMS
130 
131 // this is required to allow parent widgets (auto UIC'd from .ui) to have a FilterableList member
OpenMS::Internal::FilterableList FilterableList
Definition: FilterableList.h:132
A widget which shows a list of text items, which can be filtered.
Definition: FilterableList.h:69
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:123
Ui::FilterableList * ui_
Definition: FilterableList.h:122
QSet< QString > blacklist_
blacklisted items, which are never shown, even if in items_;
Definition: FilterableList.h:125
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:126
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
Definition: SwathWizardBase.h:63