Verified Commit 63936137 authored by Fushan Wen's avatar Fushan Wen
Browse files

applets/dict: Add `count` in DictionariesModel

count: the number of dict items
parent 7ba8d0ec
......@@ -21,6 +21,8 @@ DictionariesModel::DictionariesModel(QObject *parent)
}
endResetModel();
});
connect(this, &QAbstractItemModel::modelReset, this, &DictionariesModel::countChanged);
engine.requestDicts();
}
......@@ -50,3 +52,8 @@ QHash<int, QByteArray> DictionariesModel::roleNames() const
{
return {{Qt::DisplayRole, "description"}, {Qt::EditRole, "id"}};
}
int DictionariesModel::count() const
{
return rowCount();
}
......@@ -14,6 +14,11 @@ class DictionariesModel : public QAbstractListModel
{
Q_OBJECT
/**
* @return the number of dict items
*/
Q_PROPERTY(int count READ count NOTIFY countChanged)
public:
explicit DictionariesModel(QObject *parent = nullptr);
......@@ -21,6 +26,11 @@ public:
int rowCount(const QModelIndex &index = QModelIndex()) const override;
QHash<int, QByteArray> roleNames() const override;
int count() const;
Q_SIGNALS:
void countChanged();
private:
void setAvailableDicts(const QVariantMap &data);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment