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
a88cbb68
Commit
a88cbb68
authored
7 months ago
by
Wuttke, Joachim
Browse files
Options
Downloads
Patches
Plain Diff
mv members
parent
a0c05d51
No related branches found
No related tags found
1 merge request
!2696
PolyItem -> PolyPtr, with BaseItem as separate template parameter
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
GUI/Model/Descriptor/PolyPtr.h
+11
-12
11 additions, 12 deletions
GUI/Model/Descriptor/PolyPtr.h
with
11 additions
and
12 deletions
GUI/Model/Descriptor/PolyPtr.h
+
11
−
12
View file @
a88cbb68
...
...
@@ -17,17 +17,23 @@
#include
"GUI/Model/Util/UtilXML.h"
//! Holds a polymorphous item. Possible types of the item are specified by a Catalog.
class
PolyBase
{
public:
virtual
QString
piLabel
()
const
=
0
;
virtual
QString
piTooltip
()
const
=
0
;
virtual
QStringList
menuEntries
()
const
=
0
;
QString
piLabel
()
const
{
return
m_label
;
}
QString
piTooltip
()
const
{
return
m_tooltip
;
}
QStringList
menuEntries
()
const
{
return
m_menu_entries
;
}
virtual
void
setCurrentIndex
(
int
index
)
=
0
;
virtual
int
currentIndex
()
const
=
0
;
protected
:
QString
m_label
;
//!< A label text (short, no trailing colon)
QString
m_tooltip
;
//!< Tooltip text
QStringList
m_menu_entries
;
//!< List of options, usually presented as combo entries
};
//! Holds a polymorphous item. Possible types of the item are specified by a Catalog.
template
<
typename
Catalog
>
class
PolyPtr
:
public
PolyBase
{
public:
using
BaseItem
=
typename
Catalog
::
BaseItem
;
...
...
@@ -52,19 +58,12 @@ public:
m_item
.
reset
(
XML
::
readItemFrom
<
Catalog
>
(
r
,
args
...));
}
QString
piLabel
()
const
override
{
return
m_label
;
}
QString
piTooltip
()
const
override
{
return
m_tooltip
;
}
QStringList
menuEntries
()
const
override
{
return
m_menu_entries
;
}
void
setCurrentIndex
(
int
index
)
override
{
m_item
.
reset
(
Catalog
::
create
(
m_types
[
index
]));
}
int
currentIndex
()
const
override
{
return
m_types
.
indexOf
(
Catalog
::
type
(
m_item
.
get
()));
}
private
:
std
::
unique_ptr
<
BaseItem
>
m_item
;
//!< Current selection
QString
m_label
;
//!< A label text (short, no trailing colon)
QString
m_tooltip
;
//!< Tooltip text
QStringList
m_menu_entries
;
//!< List of options, usually presented as combo entries
QVector
<
typename
Catalog
::
Type
>
m_types
=
Catalog
::
types
();
};
...
...
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