mirror of
https://gitlab.com/pamhyr/pamhyr2.git
synced 2026-10-30 03:20:41 +01:00
Scenario: Add delete scenario command and use undo command.
This commit is contained in:
1 parent
064b3efa13
commit
29df56c8b4
9 files changed
+171
-34
No files matched your search
@@ -265,6 +265,9 @@ class GraphWidget(QGraphicsView):
|
||||
self.edge_items = []
|
||||
|
||||
for scenar in self._study.scenarios.lst:
|
||||
if scenar.is_deleted():
|
||||
continue
|
||||
|
||||
iscenar = ScenarioItem(scenar, self)
|
||||
self.scene().addItem(iscenar)
|
||||
self.scenarios_items[scenar] = iscenar
|
||||
@@ -294,7 +297,8 @@ class GraphWidget(QGraphicsView):
|
||||
def scenario_has_child(self, scenario):
|
||||
for scenar in self._study.scenarios.lst:
|
||||
if scenar.parent is scenario:
|
||||
return True
|
||||
if not scenar.is_deleted():
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
@@ -409,23 +413,48 @@ class GraphWidget(QGraphicsView):
|
||||
return
|
||||
|
||||
def fn():
|
||||
self._close_other_window()
|
||||
self._study.save()
|
||||
self._study.reload_from_scenario(item.scenario)
|
||||
self._undo.push(
|
||||
SelectScenariosCommand(
|
||||
self._study,
|
||||
item.scenario
|
||||
)
|
||||
)
|
||||
# self._study.reload_from_scenario(item.scenario)
|
||||
|
||||
self._close_other_window()
|
||||
self.exec_with_waiting_window(fn, "select_scenario")
|
||||
|
||||
self.changeScenario.emit(self.sender())
|
||||
|
||||
def new_scenario(self, pos):
|
||||
def fn():
|
||||
self._close_other_window()
|
||||
self._study.save()
|
||||
scenario = self._study.new_scenario_from_current()
|
||||
scenario.set_pos(pos.x(), pos.y())
|
||||
self._undo.push(
|
||||
AddScenariosCommand(
|
||||
self._study,
|
||||
pos
|
||||
)
|
||||
)
|
||||
# scenario = self._study.new_scenario_from_current()
|
||||
# scenario.set_pos(pos.x(), pos.y())
|
||||
|
||||
self._close_other_window()
|
||||
self.exec_with_waiting_window(fn, "new_scenario")
|
||||
self.changeScenario.emit(self.sender())
|
||||
|
||||
def delete_scenario(self, item):
|
||||
def fn():
|
||||
self._close_other_window()
|
||||
# self._study.save()
|
||||
self._undo.push(
|
||||
DeleteScenariosCommand(
|
||||
self._study,
|
||||
item.scenario
|
||||
)
|
||||
)
|
||||
|
||||
self.exec_with_waiting_window(fn, "delete_scenario")
|
||||
self.changeScenario.emit(self.sender())
|
||||
|
||||
def _close_other_window(self):
|
||||
|
||||
Reference in new issue
Block a user