CCheckableComboBox.h
Go to the documentation of this file.
1 #ifndef iwidgets_CCheckableComboBox_included
2 #define iwidgets_CCheckableComboBox_included
3 
4 
5 // Qt includes
6 #include <QtCore/QtGlobal>
7 #if QT_VERSION >= 0x050000
8 #include <QtWidgets/QComboBox>
9 #include <QtWidgets/QItemDelegate>
10 #else
11 #include <QtGui/QComboBox>
12 #include <QtGui/QItemDelegate>
13 #endif
14 
15 
16 // ACF includes
17 #include <istd/TDelPtr.h>
18 #include <iwidgets/iwidgets.h>
19 
20 
21 namespace iwidgets
22 {
23 
24 
25 class CCheckableComboBox: public QComboBox
26 {
27  Q_OBJECT
28 
29 public:
30  typedef QComboBox BaseClass;
31 
32  explicit CCheckableComboBox(QWidget* parentPtr = NULL);
33 
34  void SetItemsChecked(const QStringList& items, bool isChecked = true);
35 
36 protected:
37  virtual void UpdateDisplayText();
38 
39  // reimplemented (QWidget)
40  virtual void paintEvent(QPaintEvent* eventPtr);
41 
42  // reimplemented (QObject)
43  virtual bool eventFilter(QObject* object, QEvent* eventPtr);
44 
45 Q_SIGNALS:
49  void EmitActivatedItems(const QStringList& items);
50 
51 private:
52  class CCheckBoxDelegate: public QItemDelegate
53  {
54  public:
55  typedef QItemDelegate BaseClass;
56 
57  explicit CCheckBoxDelegate(CCheckableComboBox& parent);
58 
59  protected:
60  // reimplemented (QItemDelegate)
61  virtual void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const;
62  virtual QWidget *createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const;
63  virtual void setEditorData(QWidget* editor, const QModelIndex &index) const;
64  virtual void setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const;
65 
66  private:
67  CCheckableComboBox& m_parent;
68  };
69 
70  QString m_displayText;
71 };
72 
73 
74 } // namespace iwidgets
75 
76 
77 #endif // !iwidgets_CCheckableComboBox_included
78 
79 
void SetItemsChecked(const QStringList &items, bool isChecked=true)
virtual void paintEvent(QPaintEvent *eventPtr)
void EmitActivatedItems(const QStringList &items)
Emit the list of items, they have checked state.
virtual void UpdateDisplayText()
virtual bool eventFilter(QObject *object, QEvent *eventPtr)
#define NULL
Definition: istd.h:64
CCheckableComboBox(QWidget *parentPtr=NULL)

© 2007-2017 Witold Gantzke and Kirill Lepskiy