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

applets/dict: Add `loading` in DictionariesModel

loading: true if the engine is downloading dict list from
the Internet, false otherwise.
parent 63936137
......@@ -22,6 +22,7 @@ DictionariesModel::DictionariesModel(QObject *parent)
endResetModel();
});
connect(this, &QAbstractItemModel::modelReset, this, &DictionariesModel::countChanged);
connect(&engine, &DictEngine::dictLoadingChanged, this, &DictionariesModel::slotDictLoadingChanged);
engine.requestDicts();
}
......@@ -57,3 +58,15 @@ int DictionariesModel::count() const
{
return rowCount();
}
bool DictionariesModel::loading() const
{
return m_loading;
}
void DictionariesModel::slotDictLoadingChanged(bool loading)
{
m_loading = loading;
Q_EMIT loadingChanged();
}
......@@ -19,6 +19,12 @@ class DictionariesModel : public QAbstractListModel
*/
Q_PROPERTY(int count READ count NOTIFY countChanged)
/**
* @return @c true if the engine is downloading dict list from
* the Internet, @c false otherwise.
*/
Q_PROPERTY(bool loading READ loading NOTIFY loadingChanged)
public:
explicit DictionariesModel(QObject *parent = nullptr);
......@@ -27,9 +33,11 @@ public:
QHash<int, QByteArray> roleNames() const override;
int count() const;
bool loading() const;
Q_SIGNALS:
void countChanged();
void loadingChanged();
private:
void setAvailableDicts(const QVariantMap &data);
......@@ -39,6 +47,8 @@ private:
QString description;
};
std::vector<AvailableDict> m_availableDicts;
bool m_loading = false;
};
#endif
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