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
d87f5138
Commit
d87f5138
authored
7 years ago
by
Pospelov, Gennady
Browse files
Options
Downloads
Patches
Plain Diff
Standard code beautification in MaskEditorActions.
parent
95c3f1df
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
GUI/coregui/Views/MaskWidgets/MaskEditorActions.cpp
+57
-44
57 additions, 44 deletions
GUI/coregui/Views/MaskWidgets/MaskEditorActions.cpp
with
57 additions
and
44 deletions
GUI/coregui/Views/MaskWidgets/MaskEditorActions.cpp
+
57
−
44
View file @
d87f5138
...
...
@@ -21,87 +21,94 @@
#include
<QItemSelectionModel>
#include
<QMenu>
MaskEditorActions
::
MaskEditorActions
(
QWidget
*
parent
)
MaskEditorActions
::
MaskEditorActions
(
QWidget
*
parent
)
:
QObject
(
parent
)
,
m_maskModel
(
0
)
,
m_selectionModel
(
0
)
,
m_toggleMaskValueAction
(
new
QAction
(
"Toggle mask value"
,
parent
))
,
m_bringToFrontAction
(
new
QAction
(
"Rise mask up"
,
parent
))
,
m_sendToBackAction
(
new
QAction
(
"Lower mask down"
,
parent
))
,
m_deleteMaskAction
(
new
QAction
(
"Remove mask"
,
parent
))
,
m_resetViewAction
(
new
QAction
(
this
))
,
m_savePlotAction
(
new
QAction
(
this
))
,
m_togglePanelAction
(
new
QAction
(
this
))
,
m_rotateDataAction
(
new
QAction
(
this
))
,
m_maskModel
(
nullptr
)
,
m_selectionModel
(
nullptr
)
{
m_toggleMaskValueAction
=
new
QAction
(
QStringLiteral
(
"Toggle mask value"
),
parent
);
connect
(
m_toggleMaskValueAction
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
onToggleMaskValueAction
())
);
connect
(
m_toggleMaskValueAction
,
&
QAction
::
triggered
,
this
,
&
MaskEditorActions
::
onToggleMaskValueAction
);
m_bringToFrontAction
=
new
QAction
(
QStringLiteral
(
"Rise mask up"
),
parent
);
m_bringToFrontAction
->
setIcon
(
QIcon
(
":/MaskWidgets/images/maskeditor_bringtofront.svg"
));
m_bringToFrontAction
->
setToolTip
(
"Rise selected mask one level up (PgUp)"
);
m_bringToFrontAction
->
setShortcuts
(
QKeySequence
::
MoveToPreviousPage
);
connect
(
m_bringToFrontAction
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
onBringToFrontAction
()));
connect
(
m_bringToFrontAction
,
&
QAction
::
triggered
,
this
,
&
MaskEditorActions
::
onBringToFrontAction
);
m_sendToBackAction
=
new
QAction
(
QStringLiteral
(
"Lower mask down"
),
parent
);
m_sendToBackAction
->
setIcon
(
QIcon
(
":/MaskWidgets/images/maskeditor_sendtoback.svg"
));
m_sendToBackAction
->
setToolTip
(
"Lower selected mask one level down (PgDown)"
);
m_sendToBackAction
->
setShortcuts
(
QKeySequence
::
MoveToNextPage
);
connect
(
m_sendToBackAction
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
onSendToBackAction
()));
connect
(
m_sendToBackAction
,
&
QAction
::
triggered
,
this
,
&
MaskEditorActions
::
onSendToBackAction
);
m_deleteMaskAction
=
new
QAction
(
QStringLiteral
(
"Remove mask"
),
parent
);
m_deleteMaskAction
->
setToolTip
(
"Remove selected mask (Del)"
);
m_deleteMaskAction
->
setShortcuts
(
QKeySequence
::
Delete
);
parent
->
addAction
(
m_deleteMaskAction
);
connect
(
m_deleteMaskAction
,
SIGNAL
(
triggered
())
,
this
,
SLOT
(
onDeleteMaskAction
())
);
connect
(
m_deleteMaskAction
,
&
QAction
::
triggered
,
this
,
&
MaskEditorActions
::
onDeleteMaskAction
);
// Actions for top toolbar
m_resetViewAction
=
new
QAction
(
this
);
m_resetViewAction
->
setText
(
"Reset"
);
m_resetViewAction
->
setIcon
(
QIcon
(
":/images/toolbar16light_refresh.svg"
));
m_resetViewAction
->
setToolTip
(
"Reset View"
);
connect
(
m_resetViewAction
,
SIGNAL
(
triggered
())
,
this
,
SIGNAL
(
resetViewRequest
())
);
connect
(
m_resetViewAction
,
&
QAction
::
triggered
,
this
,
&
MaskEditorActions
::
resetViewRequest
);
m_savePlotAction
=
new
QAction
(
this
);
m_savePlotAction
->
setText
(
"Save"
);
m_savePlotAction
->
setIcon
(
QIcon
(
":/images/toolbar16light_save.svg"
));
m_savePlotAction
->
setToolTip
(
"Save Plot"
);
connect
(
m_savePlotAction
,
SIGNAL
(
triggered
())
,
this
,
SIGNAL
(
savePlotRequest
())
);
connect
(
m_savePlotAction
,
&
QAction
::
triggered
,
this
,
&
MaskEditorActions
::
savePlotRequest
);
m_togglePanelAction
=
new
QAction
(
this
);
m_togglePanelAction
->
setText
(
"Properties"
);
m_togglePanelAction
->
setIcon
(
QIcon
(
":/images/toolbar16light_propertypanel.svg"
));
m_togglePanelAction
->
setToolTip
(
"Toggle Property Panel"
);
connect
(
m_togglePanelAction
,
SIGNAL
(
triggered
()),
this
,
SIGNAL
(
propertyPanelRequest
()));
connect
(
m_togglePanelAction
,
&
QAction
::
triggered
,
this
,
&
MaskEditorActions
::
propertyPanelRequest
);
m_rotateDataAction
=
new
QAction
(
this
);
m_rotateDataAction
->
setText
(
"Rotate"
);
m_rotateDataAction
->
setIcon
(
QIcon
(
":/images/toolbar16light_rotate.svg"
));
m_rotateDataAction
->
setToolTip
(
"Rotate intensity data by 90 deg counterclockwise"
);
connect
(
m_rotateDataAction
,
SIGNAL
(
triggered
()),
this
,
SIGNAL
(
rotateDataRequest
()));
connect
(
m_rotateDataAction
,
&
QAction
::
triggered
,
this
,
&
MaskEditorActions
::
rotateDataRequest
);
}
void
MaskEditorActions
::
setModel
(
SessionModel
*
maskModel
,
const
QModelIndex
&
rootIndex
)
void
MaskEditorActions
::
setModel
(
SessionModel
*
maskModel
,
const
QModelIndex
&
rootIndex
)
{
m_maskModel
=
maskModel
;
m_rootIndex
=
rootIndex
;
}
void
MaskEditorActions
::
setSelectionModel
(
QItemSelectionModel
*
selectionModel
)
void
MaskEditorActions
::
setSelectionModel
(
QItemSelectionModel
*
selectionModel
)
{
m_selectionModel
=
selectionModel
;
}
QAction
*
MaskEditorActions
::
sendToBackAction
()
QAction
*
MaskEditorActions
::
sendToBackAction
()
{
return
m_sendToBackAction
;
}
QAction
*
MaskEditorActions
::
bringToFrontAction
()
QAction
*
MaskEditorActions
::
bringToFrontAction
()
{
return
m_bringToFrontAction
;
}
QList
<
QAction
*>
MaskEditorActions
::
topToolBarActions
()
QList
<
QAction
*>
MaskEditorActions
::
topToolBarActions
()
{
return
QList
<
QAction
*>
()
<<
m_resetViewAction
<<
m_savePlotAction
<<
m_togglePanelAction
<<
m_rotateDataAction
;
return
QList
<
QAction
*>
()
<<
m_resetViewAction
<<
m_savePlotAction
<<
m_togglePanelAction
<<
m_rotateDataAction
;
}
//! Constructs MaskItem context menu following the request from MaskGraphicsScene
//! or MaskEditorInfoPanel
void
MaskEditorActions
::
onItemContextMenuRequest
(
const
QPoint
&
point
)
void
MaskEditorActions
::
onItemContextMenuRequest
(
const
QPoint
&
point
)
{
QMenu
menu
;
initItemContextMenu
(
menu
);
...
...
@@ -126,8 +133,8 @@ void MaskEditorActions::onToggleMaskValueAction()
{
Q_ASSERT
(
m_maskModel
);
Q_ASSERT
(
m_selectionModel
);
foreach
(
QModelIndex
itemIndex
,
m_selectionModel
->
selectedIndexes
())
{
if
(
SessionItem
*
item
=
m_maskModel
->
itemForIndex
(
itemIndex
))
{
foreach
(
QModelIndex
itemIndex
,
m_selectionModel
->
selectedIndexes
())
{
if
(
SessionItem
*
item
=
m_maskModel
->
itemForIndex
(
itemIndex
))
{
bool
old_value
=
item
->
getItemValue
(
MaskItem
::
P_MASK_VALUE
).
toBool
();
item
->
setItemValue
(
MaskItem
::
P_MASK_VALUE
,
!
old_value
);
}
...
...
@@ -147,20 +154,23 @@ void MaskEditorActions::onSendToBackAction()
//! Lower mask one level down or rise one level up in the masks stack
void
MaskEditorActions
::
changeMaskStackingOrder
(
MaskEditorFlags
::
Stacking
value
)
{
if
(
!
m_maskModel
||
!
m_selectionModel
)
return
;
if
(
!
m_maskModel
||
!
m_selectionModel
)
return
;
int
change_in_row
(
0
);
if
(
value
==
MaskEditorFlags
::
BRING_TO_FRONT
)
change_in_row
=
-
1
;
if
(
value
==
MaskEditorFlags
::
SEND_TO_BACK
)
change_in_row
=
2
;
if
(
value
==
MaskEditorFlags
::
BRING_TO_FRONT
)
change_in_row
=
-
1
;
if
(
value
==
MaskEditorFlags
::
SEND_TO_BACK
)
change_in_row
=
2
;
QModelIndexList
indexes
=
m_selectionModel
->
selectedIndexes
();
foreach
(
QModelIndex
itemIndex
,
indexes
)
{
if
(
SessionItem
*
item
=
m_maskModel
->
itemForIndex
(
itemIndex
))
{
foreach
(
QModelIndex
itemIndex
,
indexes
)
{
if
(
SessionItem
*
item
=
m_maskModel
->
itemForIndex
(
itemIndex
))
{
int
new_row
=
itemIndex
.
row
()
+
change_in_row
;
if
(
new_row
>=
0
&&
new_row
<=
m_maskModel
->
rowCount
(
m_rootIndex
))
{
SessionItem
*
newItem
=
m_maskModel
->
moveParameterizedItem
(
item
,
m_maskModel
->
itemForIndex
(
m_rootIndex
),
new_row
);
if
(
new_row
>=
0
&&
new_row
<=
m_maskModel
->
rowCount
(
m_rootIndex
))
{
SessionItem
*
newItem
=
m_maskModel
->
moveParameterizedItem
(
item
,
m_maskModel
->
itemForIndex
(
m_rootIndex
),
new_row
);
m_selectionModel
->
select
(
m_maskModel
->
indexOfItem
(
newItem
),
QItemSelectionModel
::
Select
);
}
...
...
@@ -176,7 +186,8 @@ bool MaskEditorActions::isBringToFrontPossible() const
{
bool
result
(
false
);
QModelIndexList
indexes
=
m_selectionModel
->
selectedIndexes
();
if
(
indexes
.
size
()
==
1
&&
indexes
.
front
().
row
()
!=
0
)
result
=
true
;
if
(
indexes
.
size
()
==
1
&&
indexes
.
front
().
row
()
!=
0
)
result
=
true
;
return
result
;
}
...
...
@@ -185,9 +196,10 @@ bool MaskEditorActions::isSendToBackPossible() const
{
bool
result
(
false
);
QModelIndexList
indexes
=
m_selectionModel
->
selectedIndexes
();
if
(
indexes
.
size
()
==
1
)
{
SessionItem
*
item
=
m_maskModel
->
itemForIndex
(
indexes
.
front
());
if
(
indexes
.
front
().
row
()
!=
item
->
parent
()
->
rowCount
()
-
1
)
result
=
true
;
if
(
indexes
.
size
()
==
1
)
{
SessionItem
*
item
=
m_maskModel
->
itemForIndex
(
indexes
.
front
());
if
(
indexes
.
front
().
row
()
!=
item
->
parent
()
->
rowCount
()
-
1
)
result
=
true
;
}
return
result
;
}
...
...
@@ -202,16 +214,17 @@ void MaskEditorActions::setAllActionsEnabled(bool value)
//! Init external context menu with currently defined actions.
//! Triggered from MaskGraphicsScene of MaskEditorInfoPanel (QListView)
void
MaskEditorActions
::
initItemContextMenu
(
QMenu
&
menu
)
void
MaskEditorActions
::
initItemContextMenu
(
QMenu
&
menu
)
{
if
(
!
m_rootIndex
.
isValid
())
return
;
if
(
!
m_rootIndex
.
isValid
())
return
;
Q_ASSERT
(
m_maskModel
);
Q_ASSERT
(
m_selectionModel
);
if
(
m_selectionModel
->
selectedIndexes
().
isEmpty
())
{
if
(
m_selectionModel
->
selectedIndexes
().
isEmpty
())
setAllActionsEnabled
(
false
);
}
m_sendToBackAction
->
setEnabled
(
isSendToBackPossible
());
m_bringToFrontAction
->
setEnabled
(
isBringToFrontPossible
());
...
...
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