18 #ifndef QGSCHECKABLECOMBOBOX_H 19 #define QGSCHECKABLECOMBOBOX_H 23 #include <QStandardItemModel> 24 #include <QStyledItemDelegate> 58 Qt::ItemFlags
flags(
const QModelIndex &index )
const override;
66 QVariant
data(
const QModelIndex &index,
int role = Qt::DisplayRole )
const override;
75 bool setData(
const QModelIndex &index,
const QVariant &value,
int role = Qt::EditRole )
override;
113 void paint( QPainter *painter,
const QStyleOptionViewItem &option,
const QModelIndex &index )
const override;
127 Q_PROPERTY( QString separator READ separator WRITE setSeparator )
128 Q_PROPERTY( QString defaultText READ defaultText WRITE setDefaultText )
129 Q_PROPERTY( QStringList checkedItems READ checkedItems WRITE setCheckedItems )
142 QString separator() const;
149 void setSeparator( const QString &separator );
156 QString defaultText() const;
164 void setDefaultText( const QString &text );
170 QStringList checkedItems() const;
178 Qt::CheckState itemCheckState(
int index ) const;
187 void setItemCheckState(
int index, Qt::CheckState state );
195 void toggleItemCheckState(
int index );
201 void hidePopup() override;
206 bool eventFilter( QObject *
object, QEvent *event ) override;
213 void checkedItemsChanged( const QStringList &items );
222 void setCheckedItems( const QStringList &items );
229 void resizeEvent( QResizeEvent *event ) override;
237 void showContextMenu( QPoint pos );
242 void selectAllOptions();
247 void deselectAllOptions();
250 void updateCheckedItems();
251 void updateDisplayText();
254 QString mDefaultText;
256 bool mSkipHide = false;
258 QMenu *mContextMenu =
nullptr;
259 QAction *mSelectAllAction =
nullptr;
260 QAction *mDeselectAllAction =
nullptr;
263 #endif // QGSCHECKABLECOMBOBOX_H QgsCheckableItemModel(QObject *parent=nullptr)
Constructor for QgsCheckableItemModel.
QStyledItemDelegate subclass for QgsCheckableComboBox.
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override
Sets the role data for the item at index to value.
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
Returns the data stored under the given role for the item referred to by the index.
QComboBox subclass which allows selecting multiple items.
void itemCheckStateChanged()
Emitted whenever the items checkstate has changed.
Qt::ItemFlags flags(const QModelIndex &index) const override
Returns a combination of the item flags: items are enabled (ItemIsEnabled), selectable (ItemIsSelecta...
QStandardItemModel subclass which makes all items checkable by default.