1 #ifndef MODELS_CHECKLISTMODEL_H 2 #define MODELS_CHECKLISTMODEL_H 6 #include <QAbstractListModel> 9 QT_FORWARD_DECLARE_CLASS(QSettings)
19 ChecklistItem(
const QVariant &
id = QVariant(),
const QString &label = QString(), Qt::CheckState checked = Qt::Unchecked);
21 const QVariant &id()
const;
22 const QString &label()
const;
23 Qt::CheckState checkState()
const;
24 bool isChecked()
const;
29 Qt::CheckState m_checkState;
32 inline ChecklistItem::ChecklistItem(
const QVariant &
id,
const QString &label, Qt::CheckState checkState)
35 , m_checkState(checkState)
69 return m_checkState == Qt::Checked;
77 int rowCount(
const QModelIndex &parent = QModelIndex())
const;
78 Qt::ItemFlags flags(
const QModelIndex &index)
const;
79 QVariant data(
const QModelIndex &index,
int role = Qt::DisplayRole)
const;
80 QMap<int, QVariant> itemData(
const QModelIndex &index)
const;
81 bool setData(
const QModelIndex &index,
const QVariant &value,
int role = Qt::DisplayRole);
82 bool setItemData(
const QModelIndex &index,
const QMap<int, QVariant> &roles);
83 virtual QString labelForId(
const QVariant &
id)
const;
84 Qt::DropActions supportedDropActions()
const;
85 bool insertRows(
int row,
int count,
const QModelIndex &parent);
86 bool removeRows(
int row,
int count,
const QModelIndex &parent);
87 const QList<ChecklistItem> &items()
const;
88 void setItems(
const QList<ChecklistItem> &items);
89 void restore(QSettings &settings,
const QString &name);
90 void save(QSettings &settings,
const QString &name)
const;
91 static constexpr
int idRole();
94 QList<ChecklistItem> m_items;
110 return Qt::UserRole + 1;
114 #endif // MODELS_CHECKLISTMODEL_H const QVariant & id() const
Returns the ID of the item.
friend class ChecklistModel
#define QT_UTILITIES_EXPORT
Marks the symbol to be exported by the qtutilities library.
static constexpr int idRole()
Returns the role used to get or set the item ID.
Qt::CheckState checkState() const
Returns the check state.
The ChecklistItem class provides an item for use with the ChecklistModel class.
The ChecklistModel class provides a generic model for storing checkable items.
const QString & label() const
Returns the label.
bool isChecked() const
Returns whether the item is checked.
const QList< ChecklistItem > & items() const
Returns the items.