From 67680f59a9d17ab25c31d321d1b02fa6ed466297 Mon Sep 17 00:00:00 2001 From: blacksun Date: Thu, 27 Nov 2014 18:46:30 +0000 Subject: [PATCH] clean some code about undo stack git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3524 bfdf4180-ca20-0410-9c96-a3a8aa849046 --- sources/qetdiagrameditor.cpp | 21 +++++---------------- sources/qetdiagrameditor.h | 2 -- 2 files changed, 5 insertions(+), 18 deletions(-) diff --git a/sources/qetdiagrameditor.cpp b/sources/qetdiagrameditor.cpp index 3ef5f12eb..5008a9509 100644 --- a/sources/qetdiagrameditor.cpp +++ b/sources/qetdiagrameditor.cpp @@ -57,8 +57,7 @@ QETDiagramEditor::QETDiagramEditor(const QStringList &files, QWidget *parent) : 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 @@ bool QETDiagramEditor::addProject(QETProject *project, bool update_panel) { // 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_updateActions() { */ 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 @@ void QETDiagramEditor::addProjectView(ProjectView *project_view) { // 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 @@ void QETDiagramEditor::projectWasClosed(ProjectView *project_view) { 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::nomenclatureProject() { 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,22 +1878,11 @@ void QETDiagramEditor::removeDiagramFromProject() { */ 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. diff --git a/sources/qetdiagrameditor.h b/sources/qetdiagrameditor.h index 34146bef7..cb3dd964d 100644 --- a/sources/qetdiagrameditor.h +++ b/sources/qetdiagrameditor.h @@ -149,7 +149,6 @@ class QETDiagramEditor : public QETMainWindow { void cleanCurrentProject(); void nomenclatureProject(); void diagramWasAdded(DiagramView *); - void diagramWasRemoved(DiagramView *); void findElementInPanel(const ElementsLocation &); void findSelectedElementInPanel(); void editElementInEditor(const ElementsLocation &); @@ -229,6 +228,5 @@ class QETDiagramEditor : public QETMainWindow { QToolBar *diagram_bar; QToolBar *m_add_item_toolBar; QUndoGroup undo_group; - bool can_update_actions; }; #endif