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
1f148680
Commit
1f148680
authored
3 years ago
by
Matthias Puchner
Committed by
Wuttke, Joachim
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
rectify var name
parent
9d719378
No related branches found
No related tags found
1 merge request
!565
further consequences of big refactoring
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
GUI/Model/Fit/FitParameterModel.cpp
+26
-25
26 additions, 25 deletions
GUI/Model/Fit/FitParameterModel.cpp
GUI/Model/Fit/FitParameterModel.h
+1
-1
1 addition, 1 deletion
GUI/Model/Fit/FitParameterModel.h
with
27 additions
and
26 deletions
GUI/Model/Fit/FitParameterModel.cpp
+
26
−
25
View file @
1f148680
...
...
@@ -33,7 +33,7 @@ using boost::polymorphic_downcast;
using
GUI
::
Session
::
ItemUtils
::
ParentRow
;
FitParameterModel
::
FitParameterModel
(
FitParameterContainerItem
*
fitParContainer
,
QObject
*
parent
)
:
QAbstractItemModel
(
parent
),
m_
root_item
(
fitParContainer
)
:
QAbstractItemModel
(
parent
),
m_
parameterContainer
(
fitParContainer
)
{
addColumn
(
COL_NAME
,
"Name"
,
"Name of fit parameter"
);
addColumn
(
COL_TYPE
,
"Type"
,
"Fit parameter limits type"
);
...
...
@@ -43,26 +43,26 @@ FitParameterModel::FitParameterModel(FitParameterContainerItem* fitParContainer,
connectModel
(
fitParContainer
->
model
());
m_
root_item
->
mapper
()
->
setOnItemDestroy
(
m_
parameterContainer
->
mapper
()
->
setOnItemDestroy
(
[
this
](
SessionItem
*
parentItem
)
{
if
(
parentItem
!=
m_
root_item
)
{
if
(
parentItem
!=
m_
parameterContainer
)
{
throw
Error
(
"FitParameterModel::FitParameterModel() -> Error. "
"Wrong item reported."
);
}
m_
root_item
=
nullptr
;
m_
parameterContainer
=
nullptr
;
},
this
);
}
FitParameterModel
::~
FitParameterModel
()
{
if
(
m_
root_item
)
m_
root_item
->
mapper
()
->
unsubscribe
(
this
);
if
(
m_
parameterContainer
)
m_
parameterContainer
->
mapper
()
->
unsubscribe
(
this
);
}
Qt
::
ItemFlags
FitParameterModel
::
flags
(
const
QModelIndex
&
index
)
const
{
if
(
!
m_
root_item
)
if
(
!
m_
parameterContainer
)
return
Qt
::
NoItemFlags
;
Qt
::
ItemFlags
returnVal
=
Qt
::
ItemIsEnabled
|
Qt
::
ItemIsSelectable
;
...
...
@@ -91,7 +91,7 @@ Qt::ItemFlags FitParameterModel::flags(const QModelIndex& index) const
QModelIndex
FitParameterModel
::
index
(
int
row
,
int
column
,
const
QModelIndex
&
parent
)
const
{
if
(
!
m_
root_item
||
row
<
0
||
column
<
0
||
column
>=
columnCount
(
QModelIndex
())
if
(
!
m_
parameterContainer
||
row
<
0
||
column
<
0
||
column
>=
columnCount
(
QModelIndex
())
||
(
parent
.
isValid
()
&&
parent
.
column
()
!=
COL_NAME
))
return
QModelIndex
();
...
...
@@ -138,7 +138,7 @@ QModelIndex FitParameterModel::index(int row, int column, const QModelIndex& par
QModelIndex
FitParameterModel
::
parent
(
const
QModelIndex
&
child
)
const
{
if
(
!
m_
root_item
)
if
(
!
m_
parameterContainer
)
return
QModelIndex
();
if
(
!
child
.
isValid
())
...
...
@@ -161,14 +161,14 @@ QModelIndex FitParameterModel::parent(const QModelIndex& child) const
int
FitParameterModel
::
rowCount
(
const
QModelIndex
&
parent
)
const
{
if
(
!
m_
root_item
)
if
(
!
m_
parameterContainer
)
return
0
;
if
(
parent
.
isValid
()
&&
parent
.
column
()
!=
COL_NAME
)
return
0
;
SessionItem
*
parent_item
=
itemForIndex
(
parent
);
if
(
parent_item
!=
m_
root_item
&&
!
isValidSourceItem
(
parent_item
))
if
(
parent_item
!=
m_
parameterContainer
&&
!
isValidSourceItem
(
parent_item
))
return
0
;
if
(
parent_item
->
hasModelType
<
FitParameterContainerItem
>
())
...
...
@@ -180,7 +180,7 @@ int FitParameterModel::rowCount(const QModelIndex& parent) const
int
FitParameterModel
::
columnCount
(
const
QModelIndex
&
parent
)
const
{
if
(
!
m_
root_item
)
if
(
!
m_
parameterContainer
)
return
0
;
if
(
parent
.
isValid
()
&&
parent
.
column
()
!=
COL_NAME
)
...
...
@@ -200,7 +200,7 @@ int FitParameterModel::columnCount(const QModelIndex& parent) const
QVariant
FitParameterModel
::
data
(
const
QModelIndex
&
index
,
int
role
)
const
{
if
(
!
m_
root_item
)
if
(
!
m_
parameterContainer
)
return
QVariant
();
if
(
!
index
.
isValid
()
||
index
.
column
()
<
0
||
index
.
column
()
>=
NUM_COLUMNS
)
...
...
@@ -222,7 +222,7 @@ QVariant FitParameterModel::data(const QModelIndex& index, int role) const
bool
FitParameterModel
::
setData
(
const
QModelIndex
&
index
,
const
QVariant
&
value
,
int
role
)
{
if
(
!
m_
root_item
)
if
(
!
m_
parameterContainer
)
return
false
;
if
(
!
index
.
isValid
())
...
...
@@ -251,7 +251,7 @@ QMimeData* FitParameterModel::mimeData(const QModelIndexList& indexes) const
if
(
index
.
isValid
())
{
if
(
SessionItem
*
item
=
itemForIndex
(
index
))
{
QString
path
=
item
->
value
().
toString
();
auto
*
parameterItem
=
FitParameterHelper
::
getParameterItem
(
m_
root_item
,
path
);
auto
*
parameterItem
=
FitParameterHelper
::
getParameterItem
(
m_
parameterContainer
,
path
);
QByteArray
data
;
data
.
setNum
(
reinterpret_cast
<
qlonglong
>
(
parameterItem
));
mimeData
->
setData
(
GUI
::
Session
::
XML
::
LinkMimeType
,
data
);
...
...
@@ -287,13 +287,13 @@ bool FitParameterModel::dropMimeData(const QMimeData* data, Qt::DropAction actio
ParameterItem
*
parItem
=
reinterpret_cast
<
ParameterItem
*>
(
data
->
data
(
GUI
::
Session
::
XML
::
LinkMimeType
).
toULongLong
());
ASSERT
(
parItem
);
m_
root_item
->
addToFitParameter
(
parItem
,
fitParItem
->
displayName
());
m_
parameterContainer
->
addToFitParameter
(
parItem
,
fitParItem
->
displayName
());
}
}
else
{
ParameterItem
*
parItem
=
reinterpret_cast
<
ParameterItem
*>
(
data
->
data
(
GUI
::
Session
::
XML
::
LinkMimeType
).
toULongLong
());
ASSERT
(
parItem
);
m_
root_item
->
createFitParameter
(
parItem
);
m_
parameterContainer
->
createFitParameter
(
parItem
);
}
return
true
;
}
...
...
@@ -334,7 +334,7 @@ void FitParameterModel::onSourceRowsRemoved(const QModelIndex& parent, int first
void
FitParameterModel
::
onSourceAboutToBeReset
()
{
if
(
!
m_
root_item
)
if
(
!
m_
parameterContainer
)
return
;
beginResetModel
();
endResetModel
();
...
...
@@ -369,7 +369,7 @@ void FitParameterModel::addColumn(FitParameterModel::EColumn id, const QString&
QModelIndex
FitParameterModel
::
indexOfItem
(
SessionItem
*
item
)
const
{
if
(
!
m_
root_item
)
if
(
!
m_
parameterContainer
)
return
QModelIndex
();
if
(
SessionItem
*
parent_item
=
item
->
parent
())
{
...
...
@@ -401,7 +401,7 @@ QModelIndex FitParameterModel::indexOfItem(SessionItem* item) const
SessionItem
*
FitParameterModel
::
itemForIndex
(
const
QModelIndex
&
index
)
const
{
if
(
!
m_
root_item
)
if
(
!
m_
parameterContainer
)
return
nullptr
;
if
(
index
.
isValid
())
{
...
...
@@ -412,21 +412,22 @@ SessionItem* FitParameterModel::itemForIndex(const QModelIndex& index) const
return
item
;
}
}
return
m_
root_item
;
return
m_
parameterContainer
;
}
SessionModel
*
FitParameterModel
::
sourceModel
()
const
{
ASSERT
(
m_
root_item
);
return
m_
root_item
->
model
();
ASSERT
(
m_
parameterContainer
);
return
m_
parameterContainer
->
model
();
}
//! Returns true if given item still exists in source model
bool
FitParameterModel
::
isValidSourceItem
(
SessionItem
*
item
)
const
{
if
(
item
==
m_
root_item
)
if
(
item
==
m_
parameterContainer
)
return
true
;
if
(
sourceModel
()
&&
GUI
::
Model
::
Path
::
isValidItem
(
sourceModel
(),
item
,
m_root_item
->
index
()))
if
(
sourceModel
()
&&
GUI
::
Model
::
Path
::
isValidItem
(
sourceModel
(),
item
,
m_parameterContainer
->
index
()))
return
true
;
return
false
;
}
This diff is collapsed.
Click to expand it.
GUI/Model/Fit/FitParameterModel.h
+
1
−
1
View file @
1f148680
...
...
@@ -70,7 +70,7 @@ private:
void
connectModel
(
QAbstractItemModel
*
sourceModel
,
bool
isConnect
=
true
)
const
;
void
addColumn
(
EColumn
id
,
const
QString
&
name
,
const
QString
&
tooltip
);
FitParameterContainerItem
*
m_
root_item
;
FitParameterContainerItem
*
m_
parameterContainer
;
QMap
<
int
,
QString
>
m_columnNames
;
QMap
<
int
,
QString
>
m_columnToolTips
;
};
...
...
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