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
0ae683ae
Commit
0ae683ae
authored
1 year ago
by
Wuttke, Joachim
Browse files
Options
Downloads
Patches
Plain Diff
follow-up InstrumentsTreeModel
parent
9f334634
No related branches found
No related tags found
1 merge request
!2136
rm single-instrument and single-sample mode; no need to disable some instrument tyes
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
GUI/View/Instrument/InstrumentsTreeModel.cpp
+14
-25
14 additions, 25 deletions
GUI/View/Instrument/InstrumentsTreeModel.cpp
GUI/View/Instrument/InstrumentsTreeModel.h
+0
-2
0 additions, 2 deletions
GUI/View/Instrument/InstrumentsTreeModel.h
with
14 additions
and
27 deletions
GUI/View/Instrument/InstrumentsTreeModel.cpp
+
14
−
25
View file @
0ae683ae
...
...
@@ -19,10 +19,17 @@
#include
<QApplication>
#include
<QtGui>
namespace
{
using
IType
=
InstrumentsTreeModel
::
InstrumentType
;
const
auto
types
=
{
IType
::
Gisas
,
IType
::
Offspec
,
IType
::
Specular
,
IType
::
Depthprobe
};
}
// namespace
InstrumentsTreeModel
::
InstrumentsTreeModel
(
QObject
*
parent
,
InstrumentModel
*
model
)
:
QAbstractItemModel
(
parent
)
,
m_model
(
model
)
,
m_visibleTypes
(
All
)
,
m_namesAreEditable
(
false
)
,
m_enableEmptyHeadlines
(
true
)
{
...
...
@@ -43,24 +50,6 @@ void InstrumentsTreeModel::clear()
endResetModel
();
}
QList
<
InstrumentsTreeModel
::
InstrumentType
>
InstrumentsTreeModel
::
visibleTypes
()
const
{
QList
<
InstrumentsTreeModel
::
InstrumentType
>
result
;
const
auto
forType
=
[
&
](
InstrumentType
type
)
{
if
(
m_visibleTypes
.
testFlag
(
type
)
&&
(
m_enableEmptyHeadlines
||
!
instrumentItemsOfType
(
type
).
isEmpty
()))
result
<<
type
;
};
forType
(
Gisas
);
forType
(
Offspec
);
forType
(
Specular
);
forType
(
Depthprobe
);
return
result
;
}
QVector
<
InstrumentItem
*>
InstrumentsTreeModel
::
instrumentItemsOfType
(
InstrumentType
type
)
const
{
switch
(
type
)
{
...
...
@@ -88,7 +77,7 @@ QVector<InstrumentItem*> InstrumentsTreeModel::instrumentItemsOfType(InstrumentT
QModelIndex
InstrumentsTreeModel
::
indexOfHeadline
(
InstrumentType
type
)
const
{
int
row
=
0
;
for
(
auto
t
:
visibleT
ypes
()
)
{
for
(
auto
t
:
::
t
ypes
)
{
if
(
t
==
type
)
return
createIndex
(
row
,
0
,
nullptr
);
row
++
;
...
...
@@ -105,7 +94,7 @@ QModelIndex InstrumentsTreeModel::index(int row, int column, const QModelIndex&
if
(
!
parent
.
isValid
())
return
createIndex
(
row
,
column
,
nullptr
);
for
(
auto
type
:
visibleT
ypes
()
)
for
(
auto
type
:
::
t
ypes
)
if
(
parent
==
indexOfHeadline
(
type
))
return
createIndex
(
row
,
column
,
instrumentItemsOfType
(
type
)[
row
]);
...
...
@@ -121,7 +110,7 @@ QModelIndex InstrumentsTreeModel::parent(const QModelIndex& index) const
return
QModelIndex
();
auto
*
item
=
itemForIndex
(
index
);
for
(
auto
type
:
visibleT
ypes
()
)
for
(
auto
type
:
::
t
ypes
)
if
(
instrumentItemsOfType
(
type
).
contains
(
item
))
return
indexOfHeadline
(
type
);
...
...
@@ -136,10 +125,10 @@ int InstrumentsTreeModel::columnCount(const QModelIndex& /*parent*/) const
int
InstrumentsTreeModel
::
rowCount
(
const
QModelIndex
&
parent
)
const
{
if
(
!
parent
.
isValid
())
return
visibleT
ypes
()
.
size
();
return
::
t
ypes
.
size
();
// parent is a headline
for
(
auto
type
:
visibleT
ypes
()
)
for
(
auto
type
:
::
t
ypes
)
if
(
parent
==
indexOfHeadline
(
type
))
return
instrumentItemsOfType
(
type
).
size
();
...
...
@@ -270,7 +259,7 @@ QModelIndex InstrumentsTreeModel::indexForItem(InstrumentItem* item) const
if
(
item
==
nullptr
)
return
QModelIndex
();
for
(
auto
type
:
visibleT
ypes
()
)
for
(
auto
type
:
::
t
ypes
)
if
(
auto
row
=
instrumentItemsOfType
(
type
).
indexOf
(
item
);
row
>=
0
)
return
createIndex
(
row
,
0
,
item
);
...
...
This diff is collapsed.
Click to expand it.
GUI/View/Instrument/InstrumentsTreeModel.h
+
0
−
2
View file @
0ae683ae
...
...
@@ -60,12 +60,10 @@ public:
private
:
void
clear
();
QList
<
InstrumentType
>
visibleTypes
()
const
;
QVector
<
InstrumentItem
*>
instrumentItemsOfType
(
InstrumentType
type
)
const
;
private
:
InstrumentModel
*
m_model
=
nullptr
;
VisibleInstrumentTypes
m_visibleTypes
;
bool
m_namesAreEditable
;
bool
m_enableEmptyHeadlines
;
};
...
...
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