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 Workspace
Commits
87faa4a6
Verified
Commit
87faa4a6
authored
Jan 18, 2022
by
Fushan Wen
Browse files
klipper: Add named role types to HistoryModel
This makes the expressions more clear.
parent
c1e5628f
Changes
2
Hide whitespace changes
Inline
Side-by-side
klipper/historymodel.cpp
View file @
87faa4a6
...
...
@@ -70,15 +70,15 @@ QVariant HistoryModel::data(const QModelIndex &index, int role) const
return
item
->
text
();
case
Qt
::
DecorationRole
:
return
item
->
image
();
case
Qt
::
Use
rRole
:
case
HistoryItemConstPt
rRole
:
return
QVariant
::
fromValue
<
HistoryItemConstPtr
>
(
qSharedPointerConstCast
<
const
HistoryItem
>
(
item
));
case
Qt
::
UserRole
+
1
:
case
UuidRole
:
return
item
->
uuid
();
case
Qt
::
UserRole
+
2
:
case
TypeRole
:
return
QVariant
::
fromValue
<
HistoryItemType
>
(
type
);
case
Qt
::
UserRole
+
3
:
case
Base64UuidRole
:
return
item
->
uuid
().
toBase64
();
case
Qt
::
UserRole
+
4
:
case
TypeIntRole
:
return
int
(
type
);
}
return
QVariant
();
...
...
@@ -200,7 +200,7 @@ QHash<int, QByteArray> HistoryModel::roleNames() const
QHash
<
int
,
QByteArray
>
hash
;
hash
.
insert
(
Qt
::
DisplayRole
,
QByteArrayLiteral
(
"DisplayRole"
));
hash
.
insert
(
Qt
::
DecorationRole
,
QByteArrayLiteral
(
"DecorationRole"
));
hash
.
insert
(
Qt
::
UserRole
+
3
,
QByteArrayLiteral
(
"UuidRole"
));
hash
.
insert
(
Qt
::
UserRole
+
4
,
QByteArrayLiteral
(
"TypeRole"
));
hash
.
insert
(
Base64UuidRole
,
QByteArrayLiteral
(
"UuidRole"
));
hash
.
insert
(
TypeIntRole
,
QByteArrayLiteral
(
"TypeRole"
));
return
hash
;
}
klipper/historymodel.h
View file @
87faa4a6
...
...
@@ -20,6 +20,15 @@ class HistoryModel : public QAbstractListModel
{
Q_OBJECT
public:
enum
RoleType
{
HistoryItemConstPtrRole
=
Qt
::
UserRole
,
UuidRole
,
TypeRole
,
Base64UuidRole
,
TypeIntRole
,
};
Q_ENUM
(
RoleType
)
explicit
HistoryModel
(
QObject
*
parent
=
nullptr
);
~
HistoryModel
()
override
;
QVariant
data
(
const
QModelIndex
&
index
,
int
role
=
Qt
::
DisplayRole
)
const
override
;
...
...
Fushan Wen
@fusionfuture
mentioned in commit
1e3deb1d
·
Jan 18, 2022
mentioned in commit
1e3deb1d
mentioned in commit 1e3deb1dbf2b1347446762dc6fe8e95395e450a6
Toggle commit list
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