diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2021-01-13 08:55:47 -0800 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2021-01-13 11:39:36 -0800 |
commit | e610fb248115cb70bc3ded65ad3ac6985658a4a9 (patch) | |
tree | 61359d4845599fd50fa5294a17ca15efc5ac22b9 /stats/chartlistmodel.h | |
parent | 46bb242c69c999575b4d67f262bb5676f243651f (diff) | |
download | subsurface-e610fb248115cb70bc3ded65ad3ac6985658a4a9.tar.gz |
statistics: add count property to chart list
In order to be able to correctly size the chart type popup, we'll need
access to the total count or rows as a property that signals changes to
QML.
The hack to use rowCount() as the READ function requires that rowCount()
can be called without argument, therefore the addition of a default
parent.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'stats/chartlistmodel.h')
-rw-r--r-- | stats/chartlistmodel.h | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/stats/chartlistmodel.h b/stats/chartlistmodel.h index 701dca50e..70484e0ad 100644 --- a/stats/chartlistmodel.h +++ b/stats/chartlistmodel.h @@ -24,6 +24,12 @@ public: static const constexpr int IsHeaderRole = Qt::UserRole + 2; static const constexpr int IconRole = Qt::UserRole + 3; static const constexpr int IconSizeRole = Qt::UserRole + 4; + + Q_PROPERTY(int count READ rowCount NOTIFY countChanged) + +signals: + void countChanged(); + private: struct Item { bool isHeader; @@ -45,7 +51,7 @@ private: QFont headerFont; std::vector<Item> items; QHash<int, QByteArray> roleNames() const override; - int rowCount(const QModelIndex &parent) const override; + int rowCount(const QModelIndex &parent = QModelIndex()) const override; QVariant data(const QModelIndex &index, int role) const override; Qt::ItemFlags flags(const QModelIndex &index) const override; void initIcon(ChartSubType type, const char *name, int iconSize); |