Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
BornAgain
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mlz
BornAgain
Commits
2abd17f7
Commit
2abd17f7
authored
3 years ago
by
Wuttke, Joachim
Browse files
Options
Downloads
Patches
Plain Diff
SessionModel ..
parent
f0c2a7ef
No related branches found
No related tags found
1 merge request
!457
a few more changes suggested by clang-tidy
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
GUI/Model/Session/SessionModel.cpp
+18
-24
18 additions, 24 deletions
GUI/Model/Session/SessionModel.cpp
with
18 additions
and
24 deletions
GUI/Model/Session/SessionModel.cpp
+
18
−
24
View file @
2abd17f7
...
@@ -59,21 +59,18 @@ Qt::ItemFlags SessionModel::flags(const QModelIndex& index) const
...
@@ -59,21 +59,18 @@ Qt::ItemFlags SessionModel::flags(const QModelIndex& index) const
&&
item
->
isEditable
()
&&
item
->
isEnabled
())
&&
item
->
isEditable
()
&&
item
->
isEnabled
())
result_flags
|=
Qt
::
ItemIsEditable
;
result_flags
|=
Qt
::
ItemIsEditable
;
QVector
<
QString
>
acceptable_child_items
=
acceptableDefaultItemTypes
(
index
);
QVector
<
QString
>
acceptable_child_items
=
acceptableDefaultItemTypes
(
index
);
if
(
acceptable_child_items
.
contains
(
m_dragged_item_type
))
{
if
(
acceptable_child_items
.
contains
(
m_dragged_item_type
))
result_flags
|=
Qt
::
ItemIsDropEnabled
;
result_flags
|=
Qt
::
ItemIsDropEnabled
;
}
}
else
}
else
{
result_flags
|=
Qt
::
ItemIsDropEnabled
;
result_flags
|=
Qt
::
ItemIsDropEnabled
;
}
return
result_flags
;
return
result_flags
;
}
}
QVariant
SessionModel
::
data
(
const
QModelIndex
&
index
,
int
role
)
const
QVariant
SessionModel
::
data
(
const
QModelIndex
&
index
,
int
role
)
const
{
{
if
(
!
m_root_item
||
!
index
.
isValid
()
||
index
.
column
()
<
0
if
(
!
m_root_item
||
!
index
.
isValid
()
||
index
.
column
()
<
0
||
index
.
column
()
>=
columnCount
(
QModelIndex
()))
{
||
index
.
column
()
>=
columnCount
(
QModelIndex
()))
return
QVariant
();
return
{};
}
if
(
SessionItem
*
item
=
itemForIndex
(
index
))
{
if
(
SessionItem
*
item
=
itemForIndex
(
index
))
{
if
(
role
==
Qt
::
DisplayRole
||
role
==
Qt
::
EditRole
)
{
if
(
role
==
Qt
::
DisplayRole
||
role
==
Qt
::
EditRole
)
{
if
(
index
.
column
()
==
SessionFlags
::
ITEM_VALUE
)
if
(
index
.
column
()
==
SessionFlags
::
ITEM_VALUE
)
...
@@ -86,24 +83,24 @@ QVariant SessionModel::data(const QModelIndex& index, int role) const
...
@@ -86,24 +83,24 @@ QVariant SessionModel::data(const QModelIndex& index, int role) const
return
GUI
::
Session
::
ItemUtils
::
ForegroundRole
(
*
item
);
return
GUI
::
Session
::
ItemUtils
::
ForegroundRole
(
*
item
);
}
else
if
(
role
==
Qt
::
CheckStateRole
&&
index
.
column
()
==
SessionFlags
::
ITEM_VALUE
)
{
}
else
if
(
role
==
Qt
::
CheckStateRole
&&
index
.
column
()
==
SessionFlags
::
ITEM_VALUE
)
{
return
GUI
::
Session
::
ItemUtils
::
CheckStateRole
(
*
item
);
return
GUI
::
Session
::
ItemUtils
::
CheckStateRole
(
*
item
);
}
else
{
}
else
return
item
->
roleProperty
(
role
);
return
item
->
roleProperty
(
role
);
}
}
}
return
QVariant
()
;
return
{}
;
}
}
QVariant
SessionModel
::
headerData
(
int
section
,
Qt
::
Orientation
orientation
,
int
role
)
const
QVariant
SessionModel
::
headerData
(
int
section
,
Qt
::
Orientation
orientation
,
int
role
)
const
{
{
if
(
orientation
==
Qt
::
Horizontal
&&
role
==
Qt
::
DisplayRole
)
{
if
(
orientation
!=
Qt
::
Horizontal
||
role
!=
Qt
::
DisplayRole
)
switch
(
section
)
{
return
{};
case
SessionFlags
::
ITEM_NAME
:
switch
(
section
)
{
return
"Name"
;
case
SessionFlags
::
ITEM_NAME
:
case
SessionFlags
::
ITEM_VALUE
:
return
"Name"
;
return
"Value"
;
case
SessionFlags
::
ITEM_VALUE
:
}
return
"Value"
;
default:
return
{};
}
}
return
QVariant
();
}
}
int
SessionModel
::
rowCount
(
const
QModelIndex
&
parent
)
const
int
SessionModel
::
rowCount
(
const
QModelIndex
&
parent
)
const
...
@@ -143,7 +140,6 @@ QModelIndex SessionModel::parent(const QModelIndex& child) const
...
@@ -143,7 +140,6 @@ QModelIndex SessionModel::parent(const QModelIndex& child) const
if
(
SessionItem
*
parent_item
=
child_item
->
parent
())
{
if
(
SessionItem
*
parent_item
=
child_item
->
parent
())
{
if
(
parent_item
==
m_root_item
)
if
(
parent_item
==
m_root_item
)
return
QModelIndex
();
return
QModelIndex
();
return
createIndex
(
GUI
::
Session
::
ItemUtils
::
ParentRow
(
*
parent_item
),
0
,
parent_item
);
return
createIndex
(
GUI
::
Session
::
ItemUtils
::
ParentRow
(
*
parent_item
),
0
,
parent_item
);
}
}
}
}
...
@@ -271,12 +267,10 @@ SessionItem* SessionModel::insertNewItem(QString model_type, SessionItem* parent
...
@@ -271,12 +267,10 @@ SessionItem* SessionModel::insertNewItem(QString model_type, SessionItem* parent
}
}
SessionItem
*
new_item
=
GUI
::
Model
::
ItemFactory
::
CreateItem
(
model_type
);
SessionItem
*
new_item
=
GUI
::
Model
::
ItemFactory
::
CreateItem
(
model_type
);
ASSERT
(
new_item
);
if
(
!
new_item
)
const
auto
success
=
parent_item
->
insertItem
(
row
,
new_item
,
tag
);
throw
Error
(
"SessionModel::insertNewItem() -> Wrong model type "
+
model_type
);
ASSERT
(
success
);
if
(
!
parent_item
->
insertItem
(
row
,
new_item
,
tag
))
throw
Error
(
"SessionModel::insertNewItem -> Error. Can't insert item"
);
return
new_item
;
return
new_item
;
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment