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;
114 void paint( QPainter *painter,
const QStyleOptionViewItem &option,
const QModelIndex &index )
const override;
129 Q_PROPERTY( QString separator READ separator WRITE setSeparator )
130 Q_PROPERTY( QString defaultText READ defaultText WRITE setDefaultText )
131 Q_PROPERTY( QStringList checkedItems READ checkedItems WRITE setCheckedItems )
144 QString separator() const;
151 void setSeparator( const QString &separator );
158 QString defaultText() const;
166 void setDefaultText( const QString &text );
172 QStringList checkedItems() const;
180 Qt::CheckState itemCheckState(
int index ) const;
189 void setItemCheckState(
int index, Qt::CheckState state );
197 void toggleItemCheckState(
int index );
203 void hidePopup() override;
208 bool eventFilter( QObject *
object, QEvent *event ) override;
215 void checkedItemsChanged( const QStringList &items );
224 void setCheckedItems( const QStringList &items );
231 void resizeEvent( QResizeEvent *event ) override;
239 void showContextMenu( QPoint pos );
244 void selectAllOptions();
249 void deselectAllOptions();
252 void updateCheckedItems();
253 void updateDisplayText();
256 QString mDefaultText;
258 bool mSkipHide = false;
260 QMenu *mContextMenu =
nullptr;
261 QAction *mSelectAllAction =
nullptr;
262 QAction *mDeselectAllAction =
nullptr;
265 #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()
This signal is 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.