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
33c1e822
Commit
33c1e822
authored
8 months ago
by
Wuttke, Joachim
Browse files
Options
Downloads
Patches
Plain Diff
ComboProperty m_current_index instead of vector<int>; further cleanup
parent
6642e568
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!2670
ComboProperty further cleanup, and always have valid current index
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
GUI/Model/Descriptor/ComboProperty.cpp
+2
-37
2 additions, 37 deletions
GUI/Model/Descriptor/ComboProperty.cpp
GUI/Model/Descriptor/ComboProperty.h
+2
-5
2 additions, 5 deletions
GUI/Model/Descriptor/ComboProperty.h
with
4 additions
and
42 deletions
GUI/Model/Descriptor/ComboProperty.cpp
+
2
−
37
View file @
33c1e822
...
...
@@ -16,18 +16,11 @@
#include
"Base/Util/Assert.h"
#include
"GUI/Model/Util/UtilXML.h"
namespace
{
const
QString
value_separator
=
";"
;
const
QString
selection_separator
=
","
;
}
// namespace
ComboProperty
::
ComboProperty
()
=
default
;
ComboProperty
::
ComboProperty
(
const
QStringList
&
values
)
:
m_values
(
values
)
,
m_current_index
(
-
1
)
{
}
...
...
@@ -70,38 +63,10 @@ void ComboProperty::setToolTips(const QStringList& tooltips)
m_tooltips
=
tooltips
;
}
int
ComboProperty
::
currentIndex
()
const
{
return
m_selected_indices
.
empty
()
?
-
1
:
m_selected_indices
.
at
(
0
);
}
void
ComboProperty
::
setCurrentIndex
(
int
index
)
{
ASSERT
(
index
>=
0
&&
index
<
m_values
.
size
());
m_selected_indices
.
clear
();
m_selected_indices
.
push_back
(
index
);
}
//! Sets given index selection flag.
//! If false, index will be excluded from selection.
void
ComboProperty
::
setSelected
(
int
index
,
bool
value
)
{
if
(
index
<
0
||
index
>=
m_values
.
size
())
return
;
if
(
value
)
{
if
(
!
m_selected_indices
.
contains
(
index
))
m_selected_indices
.
push_back
(
index
);
}
else
{
m_selected_indices
.
removeAll
(
index
);
}
std
::
sort
(
m_selected_indices
.
begin
(),
m_selected_indices
.
end
());
}
void
ComboProperty
::
setSelected
(
const
QString
&
name
,
bool
value
)
{
setSelected
(
m_values
.
indexOf
(
name
),
value
);
m_current_index
=
index
;
}
void
ComboProperty
::
writeTo
(
QXmlStreamWriter
*
w
)
const
...
...
This diff is collapsed.
Click to expand it.
GUI/Model/Descriptor/ComboProperty.h
+
2
−
5
View file @
33c1e822
...
...
@@ -38,12 +38,9 @@ public:
void
setToolTips
(
const
QStringList
&
tooltips
);
int
currentIndex
()
const
;
int
currentIndex
()
const
{
return
m_current_index
;
}
void
setCurrentIndex
(
int
index
);
void
setSelected
(
int
index
,
bool
value
=
true
);
void
setSelected
(
const
QString
&
name
,
bool
value
=
true
);
void
writeTo
(
QXmlStreamWriter
*
w
)
const
;
void
readFrom
(
QXmlStreamReader
*
r
);
...
...
@@ -52,7 +49,7 @@ private:
QStringList
m_values
;
QStringList
m_tooltips
;
QVector
<
int
>
m_
selected_indices
;
int
m_
current_index
;
};
Q_DECLARE_METATYPE
(
ComboProperty
)
...
...
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