multicombobox.h
1 //------------------------------------------------------------------------------
2 // multicombobox.h
3 //------------------------------------------------------------------------------
4 //
5 // This library is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation; either
8 // version 2.1 of the License, or (at your option) any later version.
9 //
10 // This library is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public
16 // License along with this library; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 // 02110-1301 USA
19 //
20 //------------------------------------------------------------------------------
21 // Copyright (C) 2013 "Zalewa" <zalewapl@gmail.com>
22 //------------------------------------------------------------------------------
23 #ifndef id61914372_2F5E_42A3_9CCC3ADF106B6FF2
24 #define id61914372_2F5E_42A3_9CCC3ADF106B6FF2
25 
26 #include <QComboBox>
27 
28 class QEvent;
29 
39 class MultiComboBox : public QComboBox
40 {
41  Q_OBJECT
42 
43 public:
44  MultiComboBox(QWidget *widget = nullptr);
45  ~MultiComboBox() override;
46  QString displayText() const;
47  bool eventFilter(QObject *object, QEvent *event) override;
48  void paintEvent(QPaintEvent *) override;
49  QStringList selectedItemTexts() const;
50  void setSelectedTexts(const QStringList &texts);
51 
52 signals:
53  void valueChanged();
54 
55 private:
56  bool handleViewViewportEvent(QEvent *event);
57 };
58 
59 #endif