Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Discover
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
3
Merge Requests
3
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Plasma
Discover
Commits
535575f3
Commit
535575f3
authored
Jan 10, 2018
by
Aleix Pol Gonzalez
🐧
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make sense of the ActionsModel
parent
a4c06f0f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
6 deletions
+9
-6
libdiscover/ActionsModel.cpp
libdiscover/ActionsModel.cpp
+9
-6
No files found.
libdiscover/ActionsModel.cpp
View file @
535575f3
...
...
@@ -22,6 +22,7 @@
#include "resources/ResourcesModel.h"
#include "utils.h"
#include <QAction>
#include <QDebug>
ActionsModel
::
ActionsModel
(
QObject
*
parent
)
:
QAbstractListModel
(
parent
)
...
...
@@ -39,19 +40,20 @@ QVariant ActionsModel::data(const QModelIndex& index, int role) const
{
if
(
!
index
.
isValid
()
||
role
!=
Qt
::
UserRole
)
return
QVariant
();
return
QVariant
::
fromValue
<
QObject
*>
(
m_
a
ctions
[
index
.
row
()]);
return
QVariant
::
fromValue
<
QObject
*>
(
m_
filteredA
ctions
[
index
.
row
()]);
}
int
ActionsModel
::
rowCount
(
const
QModelIndex
&
parent
)
const
{
return
parent
.
isValid
()
?
0
:
m_
a
ctions
.
count
();
return
parent
.
isValid
()
?
0
:
m_
filteredA
ctions
.
count
();
}
void
ActionsModel
::
setActions
(
const
QList
<
QAction
*>&
actions
)
void
ActionsModel
::
setActions
(
const
QList
<
QAction
*>&
actions
)
{
if
(
m_actions
==
actions
)
{
return
;
}
m_actions
=
actions
;
reload
();
Q_EMIT
actionsChanged
(
m_actions
);
...
...
@@ -59,16 +61,17 @@ void ActionsModel::setActions(const QList<QAction *>& actions)
void
ActionsModel
::
reload
()
{
auto
actions
=
m_filteredA
ctions
;
QList
<
QAction
*>
actions
=
m_a
ctions
;
if
(
m_priority
>=
0
)
{
actions
=
kFilter
<
QList
<
QAction
*>>
(
actions
,
[
this
](
QAction
*
action
){
return
action
->
priority
()
==
m_priority
;
});
}
actions
=
kFilter
<
QList
<
QAction
*>>
(
actions
,
[](
QAction
*
action
){
return
action
->
isVisible
();
});
if
(
actions
==
m_
a
ctions
)
if
(
actions
==
m_
filteredA
ctions
)
return
;
beginResetModel
();
m_
a
ctions
=
actions
;
m_
filteredA
ctions
=
actions
;
endResetModel
();
for
(
auto
a
:
qAsConst
(
m_filteredActions
))
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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