diff options
| author | Christoph Berg <myon@debian.org> | 2020-11-16 21:54:50 +0100 |
|---|---|---|
| committer | Christoph Berg <myon@debian.org> | 2020-11-16 21:54:50 +0100 |
| commit | 77922fa33547ce24535f2e514c9a112dcb496f18 (patch) | |
| tree | 9f82b0ee01281b315f43a4c60d678927b4c6ca59 /widgets/CheckableItemComboBox.hpp | |
| parent | 7aa3c56b01768ba7d38fccedc17b30a4046b3fbb (diff) | |
New upstream version 2.3.0~rc2+repackupstream/2.3.0_rc2+repack
Diffstat (limited to 'widgets/CheckableItemComboBox.hpp')
| -rw-r--r-- | widgets/CheckableItemComboBox.hpp | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/widgets/CheckableItemComboBox.hpp b/widgets/CheckableItemComboBox.hpp new file mode 100644 index 00000000..21e75116 --- /dev/null +++ b/widgets/CheckableItemComboBox.hpp @@ -0,0 +1,37 @@ +#ifndef CHECKABLE_ITEM_COMBO_BOX_HPP__ +#define CHECKABLE_ITEM_COMBO_BOX_HPP__ + +#include <QScopedPointer> + +#include "LazyFillComboBox.hpp" + +class QStandardItemModel; +class QStandardItem; + +/** + * @brief QComboBox with support of checkboxes + * http://stackoverflow.com/questions/8422760/combobox-of-checkboxes + */ +class CheckableItemComboBox + : public LazyFillComboBox +{ + Q_OBJECT + +public: + explicit CheckableItemComboBox (QWidget * parent = nullptr); + QStandardItem * addCheckItem (QString const& label, QVariant const& data, Qt::CheckState checkState); + +protected: + bool eventFilter (QObject *, QEvent *) override; + +private: + void update_text(); + + Q_SLOT void model_data_changed (); + Q_SLOT void item_pressed (QModelIndex const&); + +private: + QScopedPointer<QStandardItemModel> model_; +}; + +#endif |
