18 #ifndef QGSCHECKABLECOMBOBOX_H
19 #define QGSCHECKABLECOMBOBOX_H
23 #include <QStandardItemModel>
24 #include <QStyledItemDelegate>
59 Qt::ItemFlags
flags(
const QModelIndex &index )
const override;
67 QVariant
data(
const QModelIndex &index,
int role = Qt::DisplayRole )
const override;
76 bool setData(
const QModelIndex &index,
const QVariant &value,
int role = Qt::EditRole )
override;
114 void paint( QPainter *painter,
const QStyleOptionViewItem &option,
const QModelIndex &index )
const override;
128 Q_PROPERTY( QString separator READ separator WRITE setSeparator )
129 Q_PROPERTY( QString defaultText READ defaultText WRITE setDefaultText )
130 Q_PROPERTY( QStringList checkedItems READ checkedItems WRITE setCheckedItems )
143 QString separator() const;
150 void setSeparator( const QString &separator );
157 QString defaultText() const;
165 void setDefaultText( const QString &text );
173 void addItemWithCheckState( const QString &text, Qt::CheckState state, const QVariant &userData = QVariant() );
179 QStringList checkedItems() const;
186 QVariantList checkedItemsData() const;
194 Qt::CheckState itemCheckState(
int index ) const;
203 void setItemCheckState(
int index, Qt::CheckState state );
211 void toggleItemCheckState(
int index );
224 void hidePopup()
override;
229 bool eventFilter( QObject *
object, QEvent *event )
override;
236 void checkedItemsChanged(
const QStringList &items );
245 void setCheckedItems(
const QStringList &items );
252 void resizeEvent( QResizeEvent *event )
override;
260 void showContextMenu( QPoint pos );
265 void selectAllOptions();
270 void deselectAllOptions();
276 void updateCheckedItems();
277 void updateDisplayText();
280 QString mDefaultText;
282 bool mSkipHide =
false;
284 QMenu *mContextMenu =
nullptr;
285 QAction *mSelectAllAction =
nullptr;
286 QAction *mDeselectAllAction =
nullptr;
289 #endif // QGSCHECKABLECOMBOBOX_H