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
d95e23e2
Commit
d95e23e2
authored
3 years ago
by
Wuttke, Joachim
Browse files
Options
Downloads
Patches
Plain Diff
mv fct to local ns
parent
56ae0160
No related branches found
No related tags found
1 merge request
!583
shuffle GUI/Model subdirectories
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
GUI/Model/Data/DataProperties.cpp
+28
-1
28 additions, 1 deletion
GUI/Model/Data/DataProperties.cpp
GUI/Model/Session/ModelPath.cpp
+3
-26
3 additions, 26 deletions
GUI/Model/Session/ModelPath.cpp
GUI/Model/Session/ModelPath.h
+0
-2
0 additions, 2 deletions
GUI/Model/Session/ModelPath.h
with
31 additions
and
29 deletions
GUI/Model/Data/DataProperties.cpp
+
28
−
1
View file @
d95e23e2
...
@@ -16,6 +16,8 @@
...
@@ -16,6 +16,8 @@
#include
"GUI/Model/Data/DataItem.h"
#include
"GUI/Model/Data/DataItem.h"
#include
"GUI/Model/Session/ModelPath.h"
#include
"GUI/Model/Session/ModelPath.h"
#include
"GUI/Model/Session/SessionModel.h"
#include
"GUI/Model/Session/SessionModel.h"
#include
"GUI/Model/Instrument/InstrumentItems.h"
#include
"GUI/Model/Job/JobItem.h"
#include
"GUI/Util/ComboProperty.h"
#include
"GUI/Util/ComboProperty.h"
#include
"GUI/Util/Error.h"
#include
"GUI/Util/Error.h"
#include
<QColor>
#include
<QColor>
...
@@ -41,8 +43,33 @@ struct ColorNameComparator {
...
@@ -41,8 +43,33 @@ struct ColorNameComparator {
ComboProperty
defaultColorCombo
();
ComboProperty
defaultColorCombo
();
// TODO cover with unit tests and simplify
QModelIndex
getIndexFromPath
(
const
SessionModel
*
model
,
const
QString
&
path
)
{
if
(
!
model
)
return
{};
QStringList
parts
=
path
.
split
(
"/"
);
SessionItem
*
t
=
model
->
rootItem
();
for
(
int
i
=
0
;
i
<
parts
.
length
();
i
++
)
{
if
(
t
->
modelType
()
==
JobItem
::
M_TYPE
&&
parts
[
i
]
==
"GISASInstrument"
)
{
t
=
dynamic_cast
<
JobItem
*>
(
t
)
->
instrumentItem
();
continue
;
}
for
(
int
j
=
0
;
j
<
t
->
numberOfChildren
();
j
++
)
{
if
(
t
->
childAt
(
j
)
->
itemName
()
==
parts
[
i
])
{
t
=
t
->
childAt
(
j
);
break
;
}
}
}
return
t
->
index
();
}
}
// namespace
}
// namespace
DataProperties
::
DataProperties
(
const
QString
&
model_type
)
:
SessionItem
(
model_type
)
DataProperties
::
DataProperties
(
const
QString
&
model_type
)
:
SessionItem
(
model_type
)
{
{
addProperty
(
P_DATALINK
,
QString
());
addProperty
(
P_DATALINK
,
QString
());
...
@@ -58,7 +85,7 @@ DataItem* DataProperties::dataItem()
...
@@ -58,7 +85,7 @@ DataItem* DataProperties::dataItem()
{
{
SessionModel
*
hosting_model
=
this
->
model
();
SessionModel
*
hosting_model
=
this
->
model
();
const
QString
&
path
=
getItemValue
(
P_DATALINK
).
toString
();
const
QString
&
path
=
getItemValue
(
P_DATALINK
).
toString
();
auto
item_index
=
GUI
::
Model
::
Path
::
getIndexFromPath
(
hosting_model
,
path
);
auto
item_index
=
getIndexFromPath
(
hosting_model
,
path
);
if
(
!
item_index
.
isValid
())
{
if
(
!
item_index
.
isValid
())
{
std
::
stringstream
os
;
std
::
stringstream
os
;
os
<<
"Error in DataProperties::dataItem: index produced by path"
;
os
<<
"Error in DataProperties::dataItem: index produced by path"
;
...
...
This diff is collapsed.
Click to expand it.
GUI/Model/Session/ModelPath.cpp
+
3
−
26
View file @
d95e23e2
...
@@ -13,8 +13,9 @@
...
@@ -13,8 +13,9 @@
// ************************************************************************************************
// ************************************************************************************************
#include
"GUI/Model/Session/ModelPath.h"
#include
"GUI/Model/Session/ModelPath.h"
#include
"GUI/Model/Instrument/InstrumentItems.h"
#include
"GUI/Model/Session/SessionModel.h"
#include
"GUI/Model/Job/JobItem.h"
#include
<QModelIndex>
#include
<QStringList>
QString
GUI
::
Model
::
Path
::
getPathFromIndex
(
const
QModelIndex
&
index
)
QString
GUI
::
Model
::
Path
::
getPathFromIndex
(
const
QModelIndex
&
index
)
{
{
...
@@ -31,30 +32,6 @@ QString GUI::Model::Path::getPathFromIndex(const QModelIndex& index)
...
@@ -31,30 +32,6 @@ QString GUI::Model::Path::getPathFromIndex(const QModelIndex& index)
return
namePath
.
join
(
"/"
);
return
namePath
.
join
(
"/"
);
}
}
// TODO cover with unit tests and simplify
QModelIndex
GUI
::
Model
::
Path
::
getIndexFromPath
(
const
SessionModel
*
model
,
const
QString
&
path
)
{
if
(
!
model
)
return
{};
QStringList
parts
=
path
.
split
(
"/"
);
SessionItem
*
t
=
model
->
rootItem
();
for
(
int
i
=
0
;
i
<
parts
.
length
();
i
++
)
{
if
(
t
->
modelType
()
==
JobItem
::
M_TYPE
&&
parts
[
i
]
==
"GISASInstrument"
)
{
t
=
dynamic_cast
<
JobItem
*>
(
t
)
->
instrumentItem
();
continue
;
}
for
(
int
j
=
0
;
j
<
t
->
numberOfChildren
();
j
++
)
{
if
(
t
->
childAt
(
j
)
->
itemName
()
==
parts
[
i
])
{
t
=
t
->
childAt
(
j
);
break
;
}
}
}
return
t
->
index
();
}
//! Iterates through all the model and returns true if item is found. This is to
//! Iterates through all the model and returns true if item is found. This is to
bool
GUI
::
Model
::
Path
::
isValidItem
(
SessionModel
*
model
,
SessionItem
*
item
,
bool
GUI
::
Model
::
Path
::
isValidItem
(
SessionModel
*
model
,
SessionItem
*
item
,
...
...
This diff is collapsed.
Click to expand it.
GUI/Model/Session/ModelPath.h
+
0
−
2
View file @
d95e23e2
...
@@ -30,8 +30,6 @@ QString getPathFromIndex(const QModelIndex& index);
...
@@ -30,8 +30,6 @@ QString getPathFromIndex(const QModelIndex& index);
QString
getPathFromItem
(
SessionItem
*
item
);
QString
getPathFromItem
(
SessionItem
*
item
);
QModelIndex
getIndexFromPath
(
const
SessionModel
*
model
,
const
QString
&
path
);
bool
isValidItem
(
SessionModel
*
model
,
SessionItem
*
item
,
const
QModelIndex
&
parent
);
bool
isValidItem
(
SessionModel
*
model
,
SessionItem
*
item
,
const
QModelIndex
&
parent
);
//! Returns ancestor of given modelType for given item.
//! Returns ancestor of given modelType for given 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