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
6a5673f0
Commit
6a5673f0
authored
12 years ago
by
Van Herck, Walter
Browse files
Options
Downloads
Patches
Plain Diff
Fixed bug with discarding of instrument changes (which triggered a selection changed event)
parent
8b291b3a
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
GUI/coregui/Views/InstrumentView.cpp
+42
-64
42 additions, 64 deletions
GUI/coregui/Views/InstrumentView.cpp
GUI/coregui/Views/InstrumentView.h
+1
-0
1 addition, 0 deletions
GUI/coregui/Views/InstrumentView.h
with
43 additions
and
64 deletions
GUI/coregui/Views/InstrumentView.cpp
+
42
−
64
View file @
6a5673f0
...
@@ -164,32 +164,8 @@ InstrumentView::InstrumentView(SimulationDataModel *p_simulation_data_model, QWi
...
@@ -164,32 +164,8 @@ InstrumentView::InstrumentView(SimulationDataModel *p_simulation_data_model, QWi
void
InstrumentView
::
onAddInstrument
()
void
InstrumentView
::
onAddInstrument
()
{
{
if
(
saveInstrumentButton
->
isEnabled
())
{
if
(
saveInstrumentButton
->
isEnabled
())
{
QMessageBox
unsaved_changes_box
;
int
ret
=
saveDiscardCancel
();
unsaved_changes_box
.
setText
(
"There are unsaved changes to the current instrument."
);
if
(
ret
==
QMessageBox
::
Cancel
)
{
unsaved_changes_box
.
setInformativeText
(
"Do you want to save your changes?"
);
unsaved_changes_box
.
setStandardButtons
(
QMessageBox
::
Save
|
QMessageBox
::
Discard
|
QMessageBox
::
Cancel
);
unsaved_changes_box
.
setDefaultButton
(
QMessageBox
::
Save
);
int
ret
=
unsaved_changes_box
.
exec
();
switch
(
ret
)
{
case
QMessageBox
::
Save
:
// Save was clicked
onSaveInstrument
();
break
;
case
QMessageBox
::
Discard
:
// Don't Save was clicked: cached changes are discarded
delete
mp_cached_instrument
;
mp_cached_instrument
=
0
;
if
(
!
mp_simulation_data_model
->
getInstrumentList
().
contains
(
m_cached_name
))
{
removeInstrumentName
(
m_cached_name
);
}
m_cached_name
.
clear
();
saveInstrumentButton
->
setEnabled
(
false
);
break
;
case
QMessageBox
::
Cancel
:
// Cancel was clicked: selection does not change
return
;
default
:
// should never be reached
return
;
return
;
}
}
}
}
...
@@ -240,38 +216,8 @@ void InstrumentView::onInstrumentSelectionChanged(int index)
...
@@ -240,38 +216,8 @@ void InstrumentView::onInstrumentSelectionChanged(int index)
(
void
)
index
;
(
void
)
index
;
if
(
instrumentBox
->
currentText
()
==
m_cached_name
)
return
;
if
(
instrumentBox
->
currentText
()
==
m_cached_name
)
return
;
if
(
saveInstrumentButton
->
isEnabled
())
{
if
(
saveInstrumentButton
->
isEnabled
())
{
QMessageBox
unsaved_changes_box
;
int
ret
=
saveDiscardCancel
();
unsaved_changes_box
.
setText
(
"There are unsaved changes to the current instrument."
);
if
(
ret
==
QMessageBox
::
Cancel
)
{
unsaved_changes_box
.
setInformativeText
(
"Do you want to save your changes?"
);
unsaved_changes_box
.
setStandardButtons
(
QMessageBox
::
Save
|
QMessageBox
::
Discard
|
QMessageBox
::
Cancel
);
unsaved_changes_box
.
setDefaultButton
(
QMessageBox
::
Save
);
int
ret
=
unsaved_changes_box
.
exec
();
switch
(
ret
)
{
case
QMessageBox
::
Save
:
// Save was clicked
onSaveInstrument
();
break
;
case
QMessageBox
::
Discard
:
// Don't Save was clicked: changes are discarded
delete
mp_cached_instrument
;
mp_cached_instrument
=
0
;
if
(
!
mp_simulation_data_model
->
getInstrumentList
().
contains
(
m_cached_name
))
{
removeInstrumentName
(
m_cached_name
);
}
m_cached_name
.
clear
();
saveInstrumentButton
->
setEnabled
(
false
);
break
;
case
QMessageBox
::
Cancel
:
// Cancel was clicked: selection does not change
if
(
m_cached_name
.
isEmpty
())
{
// this should not happen!
}
else
{
int
old_index
=
instrumentBox
->
findText
(
m_cached_name
);
instrumentBox
->
setCurrentIndex
(
old_index
);
}
return
;
default
:
// should never be reached
return
;
return
;
}
}
}
}
...
@@ -289,12 +235,7 @@ void InstrumentView::onInstrumentEntryChanged()
...
@@ -289,12 +235,7 @@ void InstrumentView::onInstrumentEntryChanged()
void
InstrumentView
::
updateEditBoxes
()
void
InstrumentView
::
updateEditBoxes
()
{
{
if
(
saveInstrumentButton
->
isEnabled
())
{
if
(
saveInstrumentButton
->
isEnabled
())
{
if
(
mp_cached_instrument
)
{
setToInstrumentData
(
mp_cached_instrument
);
setToInstrumentData
(
mp_cached_instrument
);
}
else
{
// should not occur
saveInstrumentButton
->
setEnabled
(
false
);
}
}
else
{
}
else
{
m_cached_name
=
instrumentBox
->
currentText
();
m_cached_name
=
instrumentBox
->
currentText
();
Instrument
*
p_instrument
;
Instrument
*
p_instrument
;
...
@@ -328,6 +269,7 @@ void InstrumentView::setToInstrumentData(Instrument *p_instrument)
...
@@ -328,6 +269,7 @@ void InstrumentView::setToInstrumentData(Instrument *p_instrument)
detectorAlphaStartEdit
->
setValue
(
axis2
.
getMin
()
/
Units
::
degree
);
detectorAlphaStartEdit
->
setValue
(
axis2
.
getMin
()
/
Units
::
degree
);
detectorAlphaEndEdit
->
setValue
(
axis2
.
getMax
()
/
Units
::
degree
);
detectorAlphaEndEdit
->
setValue
(
axis2
.
getMax
()
/
Units
::
degree
);
detectorAlphaValuesEdit
->
setValue
(
axis2
.
getSize
());
detectorAlphaValuesEdit
->
setValue
(
axis2
.
getSize
());
//TODO: add isgisaxs flag
}
}
// remove block
// remove block
setSignalBlock
(
false
);
setSignalBlock
(
false
);
...
@@ -358,8 +300,44 @@ void InstrumentView::removeInstrumentName(QString name)
...
@@ -358,8 +300,44 @@ void InstrumentView::removeInstrumentName(QString name)
{
{
int
index
=
instrumentBox
->
findText
(
name
);
int
index
=
instrumentBox
->
findText
(
name
);
if
(
index
!=
-
1
)
{
if
(
index
!=
-
1
)
{
instrumentBox
->
blockSignals
(
true
);
instrumentBox
->
removeItem
(
index
);
instrumentBox
->
removeItem
(
index
);
instrumentBox
->
blockSignals
(
false
);
}
}
int
InstrumentView
::
saveDiscardCancel
()
{
if
(
!
saveInstrumentButton
->
isEnabled
())
return
QMessageBox
::
NoButton
;
QMessageBox
unsaved_changes_box
;
unsaved_changes_box
.
setText
(
"There are unsaved changes to the current instrument."
);
unsaved_changes_box
.
setInformativeText
(
"Do you want to save your changes?"
);
unsaved_changes_box
.
setStandardButtons
(
QMessageBox
::
Save
|
QMessageBox
::
Discard
|
QMessageBox
::
Cancel
);
unsaved_changes_box
.
setDefaultButton
(
QMessageBox
::
Save
);
int
ret
=
unsaved_changes_box
.
exec
();
switch
(
ret
)
{
case
QMessageBox
::
Save
:
// Save was clicked
onSaveInstrument
();
break
;
case
QMessageBox
::
Discard
:
// Don't Save was clicked: cached changes are discarded
delete
mp_cached_instrument
;
mp_cached_instrument
=
0
;
if
(
!
mp_simulation_data_model
->
getInstrumentList
().
contains
(
m_cached_name
))
{
removeInstrumentName
(
m_cached_name
);
}
m_cached_name
.
clear
();
saveInstrumentButton
->
setEnabled
(
false
);
break
;
case
QMessageBox
::
Cancel
:
// Cancel was clicked: selection does not change
break
;
default
:
// should never be reached
break
;
}
}
return
ret
;
}
}
void
InstrumentView
::
setSignalBlock
(
bool
block
)
void
InstrumentView
::
setSignalBlock
(
bool
block
)
...
...
This diff is collapsed.
Click to expand it.
GUI/coregui/Views/InstrumentView.h
+
1
−
0
View file @
6a5673f0
...
@@ -29,6 +29,7 @@ private:
...
@@ -29,6 +29,7 @@ private:
void
setToInstrumentData
(
Instrument
*
p_instrument
);
void
setToInstrumentData
(
Instrument
*
p_instrument
);
void
initInstrumentFromForm
(
Instrument
*
p_instrument
);
void
initInstrumentFromForm
(
Instrument
*
p_instrument
);
void
removeInstrumentName
(
QString
name
);
void
removeInstrumentName
(
QString
name
);
int
saveDiscardCancel
();
void
setSignalBlock
(
bool
block
);
void
setSignalBlock
(
bool
block
);
SimulationDataModel
*
mp_simulation_data_model
;
SimulationDataModel
*
mp_simulation_data_model
;
Instrument
*
mp_cached_instrument
;
Instrument
*
mp_cached_instrument
;
...
...
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