mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-18 13:30:34 +01:00
clean some code about undo stack
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3524 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -57,8 +57,7 @@ QETDiagramEditor::QETDiagramEditor(const QStringList &files, QWidget *parent) :
|
|||||||
m_selection_actions_group (this),
|
m_selection_actions_group (this),
|
||||||
m_row_column_actions_group (this),
|
m_row_column_actions_group (this),
|
||||||
m_file_actions_group (this),
|
m_file_actions_group (this),
|
||||||
open_dialog_dir (QDesktopServices::storageLocation(QDesktopServices::DesktopLocation)),
|
open_dialog_dir (QDesktopServices::storageLocation(QDesktopServices::DesktopLocation))
|
||||||
can_update_actions (true)
|
|
||||||
{
|
{
|
||||||
// mise en place de l'interface MDI au centre de l'application
|
// mise en place de l'interface MDI au centre de l'application
|
||||||
setCentralWidget(&workspace);
|
setCentralWidget(&workspace);
|
||||||
@@ -883,6 +882,8 @@ bool QETDiagramEditor::addProject(QETProject *project, bool update_panel) {
|
|||||||
// cree un ProjectView pour visualiser le projet
|
// cree un ProjectView pour visualiser le projet
|
||||||
ProjectView *project_view = new ProjectView(project);
|
ProjectView *project_view = new ProjectView(project);
|
||||||
addProjectView(project_view);
|
addProjectView(project_view);
|
||||||
|
|
||||||
|
undo_group.addStack(project -> undoStack());
|
||||||
|
|
||||||
// met a jour le panel d'elements
|
// met a jour le panel d'elements
|
||||||
if (update_panel) {
|
if (update_panel) {
|
||||||
@@ -1200,7 +1201,7 @@ void QETDiagramEditor::slot_updateActions() {
|
|||||||
*/
|
*/
|
||||||
void QETDiagramEditor::slot_updateUndoStack() {
|
void QETDiagramEditor::slot_updateUndoStack() {
|
||||||
ProjectView *pv = currentProject();
|
ProjectView *pv = currentProject();
|
||||||
if (pv && can_update_actions) {
|
if (pv) {
|
||||||
undo_group.setActiveStack(pv->project()->undoStack());
|
undo_group.setActiveStack(pv->project()->undoStack());
|
||||||
undo -> setEnabled (undo_group.canUndo());
|
undo -> setEnabled (undo_group.canUndo());
|
||||||
redo -> setEnabled (undo_group.canRedo());
|
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
|
// 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(diagramWasAdded(DiagramView *)));
|
||||||
connect(project_view, SIGNAL(diagramAdded(DiagramView *)), this, SLOT(slot_updateActions()));
|
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()));
|
connect(project_view, SIGNAL(diagramRemoved(DiagramView *)), this, SLOT(slot_updateActions()));
|
||||||
if (QETProject *project = project_view -> project()) {
|
if (QETProject *project = project_view -> project()) {
|
||||||
// on met aussi les menus a jour quand un projet passe en lecture seule ou non
|
// 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();
|
QETProject *project = project_view -> project();
|
||||||
if (project) {
|
if (project) {
|
||||||
pa -> elementsPanel().projectWasClosed(project);
|
pa -> elementsPanel().projectWasClosed(project);
|
||||||
|
undo_group.removeStack(project -> undoStack());
|
||||||
QETApp::unregisterProject(project);
|
QETApp::unregisterProject(project);
|
||||||
}
|
}
|
||||||
project_view -> deleteLater();
|
project_view -> deleteLater();
|
||||||
@@ -1841,7 +1842,6 @@ void QETDiagramEditor::nomenclatureProject() {
|
|||||||
void QETDiagramEditor::removeDiagramFromProject() {
|
void QETDiagramEditor::removeDiagramFromProject() {
|
||||||
if (ProjectView *current_project = currentProject()) {
|
if (ProjectView *current_project = currentProject()) {
|
||||||
if (DiagramView *current_diagram = current_project -> currentDiagram()) {
|
if (DiagramView *current_diagram = current_project -> currentDiagram()) {
|
||||||
can_update_actions = false;
|
|
||||||
bool isFolioList = false;
|
bool isFolioList = false;
|
||||||
|
|
||||||
// if diagram to remove is a "folio list sheet", then set a flag.
|
// 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) {
|
void QETDiagramEditor::diagramWasAdded(DiagramView *dv) {
|
||||||
// quand on change qqc a l'interieur d'un schema, on met a jour les menus
|
// 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(selectionChanged()), this, SLOT(slot_updateComplexActions()));
|
||||||
connect(dv, SIGNAL(modeChanged()), this, SLOT(slot_updateModeActions()));
|
connect(dv, SIGNAL(modeChanged()), this, SLOT(slot_updateModeActions()));
|
||||||
connect(dv, SIGNAL(itemAdded()), this, SLOT(addItemFinish()));
|
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
|
@param location Emplacement de l'element a retrouver dans le panel
|
||||||
d'elements.
|
d'elements.
|
||||||
|
|||||||
@@ -149,7 +149,6 @@ class QETDiagramEditor : public QETMainWindow {
|
|||||||
void cleanCurrentProject();
|
void cleanCurrentProject();
|
||||||
void nomenclatureProject();
|
void nomenclatureProject();
|
||||||
void diagramWasAdded(DiagramView *);
|
void diagramWasAdded(DiagramView *);
|
||||||
void diagramWasRemoved(DiagramView *);
|
|
||||||
void findElementInPanel(const ElementsLocation &);
|
void findElementInPanel(const ElementsLocation &);
|
||||||
void findSelectedElementInPanel();
|
void findSelectedElementInPanel();
|
||||||
void editElementInEditor(const ElementsLocation &);
|
void editElementInEditor(const ElementsLocation &);
|
||||||
@@ -229,6 +228,5 @@ class QETDiagramEditor : public QETMainWindow {
|
|||||||
QToolBar *diagram_bar;
|
QToolBar *diagram_bar;
|
||||||
QToolBar *m_add_item_toolBar;
|
QToolBar *m_add_item_toolBar;
|
||||||
QUndoGroup undo_group;
|
QUndoGroup undo_group;
|
||||||
bool can_update_actions;
|
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user