Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Plasma
Plasma Add-ons
Commits
63936137
Verified
Commit
63936137
authored
May 05, 2022
by
Fushan Wen
Browse files
applets/dict: Add `count` in DictionariesModel
count: the number of dict items
parent
7ba8d0ec
Changes
2
Hide whitespace changes
Inline
Side-by-side
applets/dict/plugin/dictionariesmodel.cpp
View file @
63936137
...
...
@@ -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
();
}
applets/dict/plugin/dictionariesmodel.h
View file @
63936137
...
...
@@ -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
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment