QElectroTech  0.70
qetdiagrameditor.h
Go to the documentation of this file.
1 /*
2  Copyright 2006-2019 The QElectroTech Team
3  This file is part of QElectroTech.
4 
5  QElectroTech is free software: you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation, either version 2 of the License, or
8  (at your option) any later version.
9 
10  QElectroTech is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
17 */
18 #ifndef QET_DIAGRAM_EDITOR_H
19 #define QET_DIAGRAM_EDITOR_H
20 
21 #include <QActionGroup>
22 #include <QMdiArea>
23 #include <QSignalMapper>
24 #include <QDir>
25 #include <QUndoGroup>
26 
27 #include "qetmainwindow.h"
28 #include "searchandreplacewidget.h"
29 
30 class QMdiSubWindow;
31 class QETProject;
32 class QETResult;
33 class ProjectView;
34 class CustomElement;
35 class Diagram;
36 class DiagramView;
37 class Element;
39 class ElementsLocation;
40 class RecentFiles;
44 class KAutoSaveFile;
45 
51 {
52  Q_OBJECT
53 
54  public:
55  QETDiagramEditor(const QStringList & = QStringList(), QWidget * = nullptr);
56  ~QETDiagramEditor() override;
57 
58  private:
60 
61  public:
62  void closeEvent (QCloseEvent *) override;
63  QList<ProjectView *> openedProjects () const;
64  void addProjectView (ProjectView *);
65  bool openAndAddProject (const QString &, bool = true);
66  QList<QString> editedFiles () const;
67  ProjectView *viewForFile (const QString &) const;
69  QETProject *currentProject() const;
70  bool drawGrid() const;
71  void openBackupFiles (QList<KAutoSaveFile *> backup_files);
72 
73  protected:
74  bool event(QEvent *) override;
75 
76  private:
77  void setUpElementsPanel ();
79  void setUpUndoStack ();
82  void setUpActions ();
83  void setUpToolBar ();
84  void setUpMenu ();
85 
86  bool addProject(QETProject *, bool = true);
88  Element *currentElement() const;
92  ProjectView *findProject(const QString &) const;
93  QMdiSubWindow *subWindowForWidget(QWidget *) const;
94 
95  public slots:
96  void save();
97  void saveAs();
98  bool newProject();
99  bool openProject();
100  bool openRecentFile(const QString &);
101  bool closeProject(ProjectView *);
102  bool closeProject(QETProject *);
103  void zoomGroupTriggered (QAction *action);
104  void selectGroupTriggered (QAction *action);
105  void addItemGroupTriggered (QAction *action);
106  void selectionGroupTriggered (QAction *action);
107  void rowColumnGroupTriggered (QAction *action);
108  void slot_updateActions();
109  void slot_updateUndoStack();
110  void slot_updateModeActions();
112  void slot_updatePasteAction();
113  void slot_updateWindowsMenu();
114  void slot_updateAutoNumDock();
115  void generateTerminalBlock();
116  void setWindowedMode();
117  void setTabbedMode();
118  void readSettings();
119  void writeSettings();
120  void activateDiagram(Diagram *);
121  void activateProject(QETProject *);
123  void activateWidget(QWidget *);
130  void removeDiagram(Diagram *);
132  void moveDiagramUp(Diagram *);
133  void moveDiagramDown(Diagram *);
134  void moveDiagramUpTop(Diagram *);
135  void moveDiagramUpx10(Diagram *);
136  void moveDiagramDownx10(Diagram *);
137  void reloadOldElementPanel();
139  void findElementInPanel(const ElementsLocation &);
142  void showError(const QETResult &);
143  void showError(const QString &);
144  void subWindowActivated(QMdiSubWindow *subWindows);
145 
146  private slots:
147  void selectionChanged();
148 
149  public:
151  QAction *m_conductor_reset;
152  QAction *m_cut;
153  QAction *m_copy;
154 
157  QActionGroup *m_depth_action_group = nullptr;
158 
159  private:
160  QActionGroup *grp_visu_sel;
161  QActionGroup *m_group_view_mode;
163  QActionGroup m_zoom_actions_group;
164  QActionGroup m_select_actions_group;
165  QActionGroup m_file_actions_group;
166 
169  QAction *m_mode_selection;
170  QAction *m_mode_visualise;
171  QAction *m_export_diagram;
172  QAction *m_print;
173  QAction *m_quit_editor;
174  QAction *undo;
175  QAction *redo;
176  QAction *m_paste;
177  QAction *m_auto_conductor;
178  QAction *conductor_default;
179  QAction *m_grey_background;
180  QAction *m_draw_grid;
184  QAction *m_clean_project;
188  QAction *m_tile_window;
189  QAction *m_cascade_window;
190  QAction *m_previous_window;
191  QAction *m_next_window;
192  QAction *m_edit_selection;
193  QList <QAction *> m_zoom_action_toolBar;
196  QAction *m_rotate_texts;
197  QAction *m_find_element;
198  QAction *m_group_selected_texts = nullptr;
199  QAction *m_close_file;
200  QAction *m_save_file;
201  QAction *m_save_file_as;
202  QAction *m_find = nullptr;
203 
204  QMdiArea m_workspace;
205  QSignalMapper windowMapper;
207  QDockWidget *qdw_pa;
208  QDockWidget *m_qdw_elmt_collection;
209  QDockWidget *qdw_undo;
211 
215  QMenu *windows_menu;
216 
217  QToolBar *main_tool_bar = nullptr,
218  *view_tool_bar = nullptr,
219  *diagram_tool_bar = nullptr,
221  *m_depth_tool_bar = nullptr;
222 
223  QUndoGroup undo_group;
226  bool m_first_show = true;
228 };
229 #endif
QActionGroup m_row_column_actions_group
QList< ProjectView * > openedProjects() const
DiagramPropertiesEditorDockWidget * m_selection_properties_editor
QAction * m_group_selected_texts
void setUpToolBar()
QETDiagramEditor::setUpToolBar.
QAction * m_paste
Paste clipboard content on the current diagram.
DiagramView * currentDiagramView() const
QAction * m_cut
Cut selection to clipboard.
QAction * m_export_diagram
Export diagrams of the current project as imagess.
ElementsPanelWidget * pa
Elements panel.
void slot_updateComplexActions()
QETDiagramEditor::slot_updateComplexActions Manage the actions who need some conditions to be enable ...
void editDiagramProperties(DiagramView *)
QSignalMapper windowMapper
void moveDiagramDownx10(Diagram *)
QActionGroup * grp_visu_sel
Action group for visualisation vs edition mode.
void setUpAutonumberingWidget()
QETDiagramEditor::setUpAutonumberingWidget Setup the dock for AutoNumbering Selection.
void setUpElementsCollectionWidget()
QETDiagramEditor::setUpElementsCollectionWidget Set up the dock widget of element collection...
QAction * m_print
Print diagrams of the current project.
QAction * m_edit_diagram_properties
Show a dialog to edit diagram properties.
void editElementInEditor(const ElementsLocation &)
QAction * m_grey_background
Switch the background color in white or grey.
void slot_updateActions()
QETDiagramEditor::slot_updateActions Manage actions.
bool closeProject(ProjectView *)
QDockWidget * qdw_undo
QAction * m_tabbed_view_mode
Actions related to file (open, close, save...)
QAction * m_rotate_texts
Direct selected text items to a specific angle.
void moveDiagramUpx10(Diagram *)
QAction * m_next_window
Switch to the next document.
ProjectView * viewForFile(const QString &) const
void setUpElementsPanel()
QETDiagramEditor::setUpElementsPanel Setup the element panel and element panel widget.
Element * currentElement() const
QDockWidget * m_qdw_elmt_collection
Dock for the elements panel.
QAction * conductor_default
Show a dialog to edit default conductor properties.
AutoNumberingDockWidget * m_autonumbering_dock
void showError(const QETResult &)
QToolBar * m_add_item_tool_bar
The ElementsCollectionWidget class This widget embedd a tree view that display the element collection...
void addProjectView(ProjectView *)
QETDiagramEditor::addProjectView Add a new project view to workspace and build the connection between...
QAction * m_mode_selection
Set edition mode.
QToolBar * diagram_tool_bar
QMdiSubWindow * subWindowForWidget(QWidget *) const
QETDiagramEditor(const QStringList &=QStringList(), QWidget *=nullptr)
QETDiagramEditor::QETDiagramEditor Constructor.
QActionGroup * m_group_view_mode
Action group for project.
QToolBar * view_tool_bar
QAction * m_project_terminalBloc
generate terminal block
void moveDiagramUpTop(Diagram *)
QAction * m_save_file_as
Save current project as a specific file.
QAction * m_save_file
Save current project.
void addItemGroupTriggered(QAction *action)
QETDiagramEditor::addItemGroupTriggered This slot is called when an item must be added to the curent ...
void moveDiagramDown(Diagram *)
bool openAndAddProject(const QString &, bool=true)
void setUpUndoStack()
QETDiagramEditor::setUpUndoStack Setup the undostack and undo stack widget.
QAction * m_cascade_window
Show MDI subwindows as cascade.
QDockWidget * qdw_pa
Directory to use for file dialogs such as File > save.
bool drawGrid() const
QETDiagramEditor::drawGrid.
void removeDiagram(Diagram *)
void setUpActions()
QETDiagramEditor::setUpActions Set up all Qaction.
void zoomGroupTriggered(QAction *action)
ElementsCollectionWidget * m_element_collection_widget
Dock for the undo list.
QAction * undo
Cancel the latest action.
QAction * m_project_nomenclature
generate nomenclature
QAction * m_edit_selection
To edit selected item.
QActionGroup m_zoom_actions_group
Action related to adding (add text image shape...)
void closeEvent(QCloseEvent *) override
QAction * redo
Redo the latest cancelled operation.
void writeSettings()
QETDiagramEditor::writeSettings Write the settings.
void slot_updateModeActions()
QETDiagramEditor::slot_updateModeActions Manage action who need an opened diagram or project to be up...
QAction * m_project_folio_list
Sommaire des schemas.
ProjectView * currentProjectView() const
QAction * m_quit_editor
Quit the diagram editor.
void generateTerminalBlock()
QETDiagramEditor::generateTerminalBlock.
void slot_updateAutoNumDock()
QETDiagramEditor::slot_updateAutoNumDock Update Auto Num Dock Widget when changing Project...
void setUpMenu()
QETDiagramEditor::setUpMenu.
void slot_updateUndoStack()
QETDiagramEditor::slot_updateUndoStack Update the undo stack view.
void addDiagramToProject(QETProject *)
bool newProject()
QETDiagramEditor::newProject Create an empty project.
QActionGroup m_selection_actions_group
Action related to add/remove rows/column in diagram.
QAction * m_find_element
Find the selected element in the panel.
void save()
QETDiagramEditor::save Ask the current active project to save.
void setUpSelectionPropertiesEditor()
QETDiagramEditor::setUpSelectionPropertiesEditor Setup the dock for edit the current selection...
void activateWidget(QWidget *)
void selectionGroupTriggered(QAction *action)
QETDiagramEditor::selectionGroupTriggered This slot is called when an action should be made on the cu...
~QETDiagramEditor() override
QActionGroup m_file_actions_group
Action related to global selections.
QAction * m_delete_selection
Only zoom action must displayed in the toolbar.
void projectWasClosed(ProjectView *)
SearchAndReplaceWidget m_search_and_replace_widget
QList< QString > editedFiles() const
QAction * m_clean_project
Clean the content of the curent project by removing useless items.
QToolBar * m_depth_tool_bar
QActionGroup * m_depth_action_group
Action related to edit a selected item.
void openBackupFiles(QList< KAutoSaveFile *> backup_files)
QETDiagramEditor::openBackupFiles.
void selectGroupTriggered(QAction *action)
QETDiagramEditor::selectGroupTriggered This slot is called when selection need to change...
void moveDiagramUp(Diagram *)
void saveAs()
QETDiagramEditor::saveAs Ask the current active project to save as.
QList< QAction * > m_zoom_action_toolBar
QAction * m_tile_window
Show MDI subwindows as tile.
QAction * m_mode_visualise
Set visualisation mode.
QToolBar * main_tool_bar
QActionGroup m_add_item_actions_group
QAction * m_auto_conductor
Enable/Disable the use of auto conductor.
void rowColumnGroupTriggered(QAction *action)
void diagramWasAdded(DiagramView *)
QETDiagramEditor::diagramWasAdded Manage the adding of diagram view in a project. ...
QAction * m_windowed_view_mode
Display projects as windows.
bool openRecentFile(const QString &)
void editProjectProperties(ProjectView *)
QETProject * currentProject() const
QETDiagramEditor::currentProject.
QAction * m_project_add_diagram
Add a diagram to the current project.
QAction * m_previous_window
Switch to the previous document.
bool addProject(QETProject *, bool=true)
QAction * m_copy
Copy selection to clipboard.
void readSettings()
QETDiagramEditor::readSettings Read the settings.
void activateDiagram(Diagram *)
QAction * m_remove_diagram_from_project
Delete a diagram from the current project.
QAction * m_conductor_reset
Reset paths of selected conductors.
void subWindowActivated(QMdiSubWindow *subWindows)
QETDiagramEditor::subWindowActivated Slot used to update menu and undo stack when subwindows of MDIar...
void activateProject(QETProject *)
ProjectView * findProject(DiagramView *) const
bool event(QEvent *) override
QETDiagramEditor::event Reimplemented to : -Load elements collection when WindowActivate.
QAction * m_project_edit_properties
Edit the properties of the current project.
QAction * m_rotate_selection
Rotate selected elements and text items by 90 degrees.
QAction * m_draw_grid
Switch the background grid display or not.
QAction * m_close_file
Close current project file.
void findElementInPanel(const ElementsLocation &)
QETDiagramEditor::findElementInPanel Find the item for in the element panel.
void selectionChanged()
QETDiagramEditor::selectionChanged This slot is called when a diagram selection was changed...
QActionGroup m_select_actions_group
Action related to zoom for diagram.