[qet] [3524] clean some code about undo stack |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/qet Archives
]
Revision: 3524
Author: blacksun
Date: 2014-11-27 19:46:30 +0100 (Thu, 27 Nov 2014)
Log Message:
-----------
clean some code about undo stack
Modified Paths:
--------------
trunk/sources/qetdiagrameditor.cpp
trunk/sources/qetdiagrameditor.h
Modified: trunk/sources/qetdiagrameditor.cpp
===================================================================
--- trunk/sources/qetdiagrameditor.cpp 2014-11-27 17:57:10 UTC (rev 3523)
+++ trunk/sources/qetdiagrameditor.cpp 2014-11-27 18:46:30 UTC (rev 3524)
@@ -57,8 +57,7 @@
m_selection_actions_group (this),
m_row_column_actions_group (this),
m_file_actions_group (this),
- open_dialog_dir (QDesktopServices::storageLocation(QDesktopServices::DesktopLocation)),
- can_update_actions (true)
+ open_dialog_dir (QDesktopServices::storageLocation(QDesktopServices::DesktopLocation))
{
// mise en place de l'interface MDI au centre de l'application
setCentralWidget(&workspace);
@@ -883,6 +882,8 @@
// cree un ProjectView pour visualiser le projet
ProjectView *project_view = new ProjectView(project);
addProjectView(project_view);
+
+ undo_group.addStack(project -> undoStack());
// met a jour le panel d'elements
if (update_panel) {
@@ -1200,7 +1201,7 @@
*/
void QETDiagramEditor::slot_updateUndoStack() {
ProjectView *pv = currentProject();
- if (pv && can_update_actions) {
+ if (pv) {
undo_group.setActiveStack(pv->project()->undoStack());
undo -> setEnabled (undo_group.canUndo());
redo -> setEnabled (undo_group.canRedo());
@@ -1339,7 +1340,6 @@
// gere l'ajout et le retrait de schema du projet
connect(project_view, SIGNAL(diagramAdded(DiagramView *)), this, SLOT(diagramWasAdded(DiagramView *)));
connect(project_view, SIGNAL(diagramAdded(DiagramView *)), this, SLOT(slot_updateActions()));
- connect(project_view, SIGNAL(diagramRemoved(DiagramView *)), this, SLOT(diagramWasRemoved(DiagramView *)));
connect(project_view, SIGNAL(diagramRemoved(DiagramView *)), this, SLOT(slot_updateActions()));
if (QETProject *project = project_view -> project()) {
// on met aussi les menus a jour quand un projet passe en lecture seule ou non
@@ -1690,6 +1690,7 @@
QETProject *project = project_view -> project();
if (project) {
pa -> elementsPanel().projectWasClosed(project);
+ undo_group.removeStack(project -> undoStack());
QETApp::unregisterProject(project);
}
project_view -> deleteLater();
@@ -1841,7 +1842,6 @@
void QETDiagramEditor::removeDiagramFromProject() {
if (ProjectView *current_project = currentProject()) {
if (DiagramView *current_diagram = current_project -> currentDiagram()) {
- can_update_actions = false;
bool isFolioList = false;
// if diagram to remove is a "folio list sheet", then set a flag.
@@ -1878,23 +1878,12 @@
*/
void QETDiagramEditor::diagramWasAdded(DiagramView *dv) {
// quand on change qqc a l'interieur d'un schema, on met a jour les menus
- undo_group.addStack(&(dv -> diagram() -> undoStack()));
connect(dv, SIGNAL(selectionChanged()), this, SLOT(slot_updateComplexActions()));
connect(dv, SIGNAL(modeChanged()), this, SLOT(slot_updateModeActions()));
connect(dv, SIGNAL(itemAdded()), this, SLOT(addItemFinish()));
}
/**
- Gere le retrait d'un schema dans un projet apres que le retrait soit effectif
- @param dv DiagramView concerne
-*/
-void QETDiagramEditor::diagramWasRemoved(DiagramView *dv) {
- Q_UNUSED(dv);
- can_update_actions = true;
- slot_updateUndoStack();
-}
-
-/**
@param location Emplacement de l'element a retrouver dans le panel
d'elements.
*/
Modified: trunk/sources/qetdiagrameditor.h
===================================================================
--- trunk/sources/qetdiagrameditor.h 2014-11-27 17:57:10 UTC (rev 3523)
+++ trunk/sources/qetdiagrameditor.h 2014-11-27 18:46:30 UTC (rev 3524)
@@ -149,7 +149,6 @@
void cleanCurrentProject();
void nomenclatureProject();
void diagramWasAdded(DiagramView *);
- void diagramWasRemoved(DiagramView *);
void findElementInPanel(const ElementsLocation &);
void findSelectedElementInPanel();
void editElementInEditor(const ElementsLocation &);
@@ -229,6 +228,5 @@
QToolBar *diagram_bar;
QToolBar *m_add_item_toolBar;
QUndoGroup undo_group;
- bool can_update_actions;
};
#endif