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
acdad288
Commit
acdad288
authored
1 year ago
by
Wuttke, Joachim
Browse files
Options
Downloads
Patches
Plain Diff
extract method InstrumentView::setToolbarActions
parent
110efb6d
No related branches found
Branches containing commit
No related tags found
1 merge request
!2387
unify code for list views
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
GUI/View/Views/InstrumentView.cpp
+37
-26
37 additions, 26 deletions
GUI/View/Views/InstrumentView.cpp
GUI/View/Views/InstrumentView.h
+2
-0
2 additions, 0 deletions
GUI/View/Views/InstrumentView.h
with
39 additions
and
26 deletions
GUI/View/Views/InstrumentView.cpp
+
37
−
26
View file @
acdad288
...
...
@@ -46,6 +46,39 @@ InstrumentView::InstrumentView()
layout
->
addWidget
(
toolbar
);
toolbar
->
setToolButtonStyle
(
Qt
::
ToolButtonTextBesideIcon
);
setToolbarActions
(
toolbar
);
//... Everything below top toolbar
auto
*
hLayout
=
new
QHBoxLayout
;
layout
->
addLayout
(
hLayout
);
// Left margin: instrument list
hLayout
->
addWidget
(
m_qlistview
);
m_qlistview
->
setMinimumWidth
(
200
);
// Large widget: current instrument
hLayout
->
addWidget
(
m_scroll_area
);
m_scroll_area
->
setWidgetResizable
(
true
);
m_scroll_area
->
setMinimumWidth
(
1000
);
m_scroll_area
->
setWidget
(
new
QWidget
(
m_scroll_area
));
// initial state: blank widget
hLayout
->
addStretch
(
1
);
//... Finalize
connect
(
gDoc
->
instruments
(),
&
InstrumentsSet
::
setChanged
,
this
,
&
InstrumentView
::
createWidgetsForCurrentInstrument
);
updateActions
();
}
void
InstrumentView
::
setToolbarActions
(
QToolBar
*
toolbar
)
{
//... New-instrument actions
auto
new_action
=
[
this
,
toolbar
](
const
QString
&
name
,
const
QString
&
description
)
{
QAction
*
a
=
new
QAction
(
"New "
+
name
,
this
);
a
->
setIcon
(
QIcon
(
":/images/shape-square-plus.svg"
));
...
...
@@ -66,6 +99,8 @@ InstrumentView::InstrumentView()
connect
(
new_action
(
"depthprobe"
,
"depth intensity profile"
),
&
QAction
::
triggered
,
[
this
]
{
m_qlistmodel
->
pushInstrument
(
new
DepthprobeInstrumentItem
);
});
//... Copy and remove actions
m_rm_action
=
ActionFactory
::
createRemoveAction
(
"instrument"
,
this
);
toolbar
->
addAction
(
m_rm_action
);
connect
(
m_rm_action
,
&
QAction
::
triggered
,
m_qlistmodel
,
&
InstrumentsQModel
::
removeInstrument
);
...
...
@@ -74,6 +109,8 @@ InstrumentView::InstrumentView()
toolbar
->
addAction
(
m_cp_action
);
connect
(
m_cp_action
,
&
QAction
::
triggered
,
m_qlistmodel
,
&
InstrumentsQModel
::
copyInstrument
);
//... Save and load actions
m_save_action
=
new
QAction
(
"Store in library"
,
this
);
m_save_action
->
setIcon
(
QIcon
(
":/images/library.svg"
));
m_save_action
->
setToolTip
(
"Store instrument in library"
);
...
...
@@ -88,32 +125,6 @@ InstrumentView::InstrumentView()
connect
(
m_load_action
,
&
QAction
::
triggered
,
[
this
]
{
m_qlistmodel
->
pushInstrument
(
RW
::
loadComponentFromXML
<
InstrumentItem
>
(
"instrument"
));
});
//... Everything below top toolbar
auto
*
hLayout
=
new
QHBoxLayout
;
layout
->
addLayout
(
hLayout
);
// Left margin: instrument list
hLayout
->
addWidget
(
m_qlistview
);
m_qlistview
->
setMinimumWidth
(
200
);
// Large widget: current instrument
hLayout
->
addWidget
(
m_scroll_area
);
m_scroll_area
->
setWidgetResizable
(
true
);
m_scroll_area
->
setMinimumWidth
(
1000
);
m_scroll_area
->
setWidget
(
new
QWidget
(
m_scroll_area
));
// initial state: blank widget
hLayout
->
addStretch
(
1
);
//... Finalize
connect
(
gDoc
->
instruments
(),
&
InstrumentsSet
::
setChanged
,
this
,
&
InstrumentView
::
createWidgetsForCurrentInstrument
);
updateActions
();
}
void
InstrumentView
::
createWidgetsForCurrentInstrument
()
...
...
This diff is collapsed.
Click to expand it.
GUI/View/Views/InstrumentView.h
+
2
−
0
View file @
acdad288
...
...
@@ -23,6 +23,7 @@
class
InstrumentItem
;
class
InstrumentsQListView
;
class
InstrumentsQModel
;
class
QToolBar
;
class
InstrumentView
:
public
QWidget
{
Q_OBJECT
...
...
@@ -33,6 +34,7 @@ private slots:
void
updateActions
();
private:
void
setToolbarActions
(
QToolBar
*
toolbar
);
void
createWidgetsForCurrentInstrument
();
InstrumentsQModel
*
m_qlistmodel
;
...
...
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