Clean (and reduce the size) the class QETDiagramEditor, mostly by replacing the connection syntax "signal -> slot" by "signal -> lambda".

git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@5401 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
blacksun
2018-06-20 18:03:39 +00:00
parent 98531b0f3f
commit 8386002ef3
4 changed files with 453 additions and 598 deletions

View File

@@ -797,45 +797,6 @@ void DiagramView::applyReadOnly() {
setAcceptDrops(is_writable); setAcceptDrops(is_writable);
} }
/**
* @brief DiagramView::editSelectionProperties
* Edit the properties of the selected items
*/
void DiagramView::editSelectionProperties()
{
// get selection
DiagramContent selection(m_diagram);
// if selection contains nothing return
int selected_items_count = selection.count(DiagramContent::All | DiagramContent::SelectedOnly);
if (!selected_items_count) return;
// if selection contains one item and this item can be editable, edit this item with an appropriate dialog
if (selected_items_count == 1 && selection.items(DiagramContent::Elements |
DiagramContent::AnyConductor |
DiagramContent::SelectedOnly).size()) {
// edit conductor
if (selection.conductors(DiagramContent::AnyConductor | DiagramContent::SelectedOnly).size())
selection.conductors().first()->editProperty();
// edit element
else if (selection.m_elements.size())
selection.m_elements.first() -> editProperty();
}
else {
QET::QetMessageBox::information(
this,
tr("Propriétés de la sélection"),
QString(
tr(
"La sélection contient %1.",
"%1 is a sentence listing the selected objects"
)
).arg(selection.sentence(DiagramContent::All | DiagramContent::SelectedOnly))
);
}
}
/** /**
* @brief DiagramView::editSelectedConductorColor * @brief DiagramView::editSelectedConductorColor
* Edit the color of the selected conductor; does nothing if multiple conductors are selected * Edit the color of the selected conductor; does nothing if multiple conductors are selected
@@ -1063,7 +1024,7 @@ void DiagramView::contextMenuEvent(QContextMenuEvent *e) {
m_paste_here -> setEnabled(Diagram::clipboardMayContainDiagram()); m_paste_here -> setEnabled(Diagram::clipboardMayContainDiagram());
m_context_menu -> addAction(m_paste_here); m_context_menu -> addAction(m_paste_here);
m_context_menu -> addSeparator(); m_context_menu -> addSeparator();
m_context_menu -> addAction(qde -> infos_diagram); m_context_menu -> addAction(qde -> m_edit_diagram_properties);
m_context_menu -> addActions(qde -> m_row_column_actions_group.actions()); m_context_menu -> addActions(qde -> m_row_column_actions_group.actions());
} else { } else {
m_context_menu -> addAction(qde -> m_cut); m_context_menu -> addAction(qde -> m_cut);
@@ -1073,6 +1034,8 @@ void DiagramView::contextMenuEvent(QContextMenuEvent *e) {
m_context_menu -> addAction(qde -> m_conductor_reset); m_context_menu -> addAction(qde -> m_conductor_reset);
m_context_menu -> addSeparator(); m_context_menu -> addSeparator();
m_context_menu -> addActions(qde -> m_selection_actions_group.actions()); m_context_menu -> addActions(qde -> m_selection_actions_group.actions());
m_context_menu -> addSeparator();
m_context_menu -> addActions(qde->m_depth_action_group->actions());
} }
//Remove from the context menu the actions which are disabled. //Remove from the context menu the actions which are disabled.

View File

@@ -125,7 +125,6 @@ class DiagramView : public QGraphicsView
void pasteHere(); void pasteHere();
void adjustSceneRect(); void adjustSceneRect();
void updateWindowTitle(); void updateWindowTitle();
void editSelectionProperties();
void editSelectedConductorColor(); void editSelectedConductorColor();
void editConductorColor(Conductor *); void editConductorColor(Conductor *);
void resetConductors(); void resetConductors();

File diff suppressed because it is too large Load Diff

View File

@@ -17,9 +17,16 @@
*/ */
#ifndef QET_DIAGRAM_EDITOR_H #ifndef QET_DIAGRAM_EDITOR_H
#define QET_DIAGRAM_EDITOR_H #define QET_DIAGRAM_EDITOR_H
#include <QtWidgets>
#include <QActionGroup>
#include <QMdiArea>
#include <QSignalMapper>
#include <QDir>
#include <QUndoGroup>
#include "qetmainwindow.h" #include "qetmainwindow.h"
class QMdiSubWindow;
class QETProject; class QETProject;
class QETResult; class QETResult;
class ProjectView; class ProjectView;
@@ -38,28 +45,17 @@ class AutoNumberingDockWidget;
This class represents the main window of the QElectroTech diagram editor and, This class represents the main window of the QElectroTech diagram editor and,
ipso facto, the most important part of the QElectroTech user interface. ipso facto, the most important part of the QElectroTech user interface.
*/ */
class QETDiagramEditor : public QETMainWindow { class QETDiagramEditor : public QETMainWindow
{
Q_OBJECT Q_OBJECT
// constructors, destructor
public: public:
QETDiagramEditor(const QStringList & = QStringList(), QWidget * = nullptr); QETDiagramEditor(const QStringList & = QStringList(), QWidget * = nullptr);
~QETDiagramEditor() override; ~QETDiagramEditor() override;
private: private:
QETDiagramEditor(const QETDiagramEditor &); QETDiagramEditor(const QETDiagramEditor &);
private:
void setUpElementsPanel ();
void setUpElementsCollectionWidget();
void setUpUndoStack ();
void setUpSelectionPropertiesEditor();
void setUpAutonumberingWidget();
void setUpActions ();
void setUpToolBar ();
void setUpMenu ();
// methods
public: public:
void closeEvent (QCloseEvent *) override; void closeEvent (QCloseEvent *) override;
QList<ProjectView *> openedProjects () const; QList<ProjectView *> openedProjects () const;
@@ -70,25 +66,32 @@ class QETDiagramEditor : public QETMainWindow {
ProjectView *acessCurrentProject (); ProjectView *acessCurrentProject ();
DiagramView *acessCurrentDiagramView (); DiagramView *acessCurrentDiagramView ();
bool drawGrid() const; bool drawGrid() const;
protected: protected:
bool event(QEvent *) override; bool event(QEvent *) override;
private: private:
bool addProject(QETProject *, bool = true); void setUpElementsPanel ();
ProjectView *currentProjectView() const; void setUpElementsCollectionWidget();
DiagramView *currentDiagramView() const; void setUpUndoStack ();
Element *currentElement() const; void setUpSelectionPropertiesEditor();
CustomElement * currentCustomElement() const; void setUpAutonumberingWidget();
ProjectView *findProject(DiagramView *) const; void setUpActions ();
ProjectView *findProject(Diagram *) const; void setUpToolBar ();
ProjectView *findProject(QETProject *) const; void setUpMenu ();
ProjectView *findProject(const QString &) const;
QMdiSubWindow *subWindowForWidget(QWidget *) const; bool addProject(QETProject *, bool = true);
ProjectView *currentProjectView() const;
DiagramView *currentDiagramView() const;
Element *currentElement() const;
CustomElement * currentCustomElement() const;
ProjectView *findProject(DiagramView *) const;
ProjectView *findProject(Diagram *) const;
ProjectView *findProject(QETProject *) const;
ProjectView *findProject(const QString &) const;
QMdiSubWindow *subWindowForWidget(QWidget *) const;
public slots: public slots:
void printDialog();
void exportDialog();
void save(); void save();
void saveAs(); void saveAs();
bool newProject(); bool newProject();
@@ -96,17 +99,11 @@ class QETDiagramEditor : public QETMainWindow {
bool openRecentFile(const QString &); bool openRecentFile(const QString &);
bool closeProject(ProjectView *); bool closeProject(ProjectView *);
bool closeProject(QETProject *); bool closeProject(QETProject *);
bool closeCurrentProject();
void slot_cut();
void slot_copy();
void slot_paste();
void zoomGroupTriggered (QAction *action); void zoomGroupTriggered (QAction *action);
void selectGroupTriggered (QAction *action); void selectGroupTriggered (QAction *action);
void addItemGroupTriggered (QAction *action); void addItemGroupTriggered (QAction *action);
void selectionGroupTriggered (QAction *action); void selectionGroupTriggered (QAction *action);
void rowColumnGroupTriggered (QAction *action); void rowColumnGroupTriggered (QAction *action);
void slot_setSelectionMode();
void slot_setVisualisationMode();
void slot_updateActions(); void slot_updateActions();
void slot_updateUndoStack(); void slot_updateUndoStack();
void slot_updateModeActions(); void slot_updateModeActions();
@@ -114,10 +111,7 @@ class QETDiagramEditor : public QETMainWindow {
void slot_updatePasteAction(); void slot_updatePasteAction();
void slot_updateWindowsMenu(); void slot_updateWindowsMenu();
void slot_updateAutoNumDock(); void slot_updateAutoNumDock();
void editSelectionProperties(); void generateTerminalBlock();
void slot_resetConductors();
void slot_autoConductor(bool ac);
void slot_generateTerminalBlock();
void setWindowedMode(); void setWindowedMode();
void setTabbedMode(); void setTabbedMode();
void readSettings(); void readSettings();
@@ -127,14 +121,10 @@ class QETDiagramEditor : public QETMainWindow {
void activateProject(ProjectView *); void activateProject(ProjectView *);
void activateWidget(QWidget *); void activateWidget(QWidget *);
void projectWasClosed(ProjectView *); void projectWasClosed(ProjectView *);
void editCurrentProjectProperties();
void editProjectProperties(ProjectView *); void editProjectProperties(ProjectView *);
void editProjectProperties(QETProject *); void editProjectProperties(QETProject *);
void editCurrentDiagramProperties();
void editDiagramProperties(DiagramView *); void editDiagramProperties(DiagramView *);
void editDiagramProperties(Diagram *); void editDiagramProperties(Diagram *);
void addDiagramToProject();
void addDiagramFolioListToProject();
void addDiagramToProject(QETProject *); void addDiagramToProject(QETProject *);
void removeDiagram(Diagram *); void removeDiagram(Diagram *);
void removeDiagramFromProject(); void removeDiagramFromProject();
@@ -143,9 +133,7 @@ class QETDiagramEditor : public QETMainWindow {
void moveDiagramUpTop(Diagram *); void moveDiagramUpTop(Diagram *);
void moveDiagramUpx10(Diagram *); void moveDiagramUpx10(Diagram *);
void moveDiagramDownx10(Diagram *); void moveDiagramDownx10(Diagram *);
void cleanCurrentProject();
void reloadOldElementPanel(); void reloadOldElementPanel();
void nomenclatureProject();
void diagramWasAdded(DiagramView *); void diagramWasAdded(DiagramView *);
void findElementInPanel(const ElementsLocation &); void findElementInPanel(const ElementsLocation &);
void editElementInEditor(const ElementsLocation &); void editElementInEditor(const ElementsLocation &);
@@ -157,77 +145,68 @@ class QETDiagramEditor : public QETMainWindow {
private slots: private slots:
void selectionChanged(); void selectionChanged();
// attributes
private:
// Actions reachable through menus within QElectroTech
QActionGroup *grp_visu_sel; ///< Action group for visualisation vs edition mode
QActionGroup *grp_view_mode; ///< Action group for project
QAction *tabbed_view_mode; ///< Display projects as tabs
QAction *windowed_view_mode; ///< Display projects as windows
QAction *mode_selection; ///< Set edition mode
QAction *mode_visualise; ///< Set visualisation mode
QAction *export_diagram; ///< Export diagrams of the current project as imagess
QAction *print; ///< Print diagrams of the current project
QAction *quit_editor; ///< Quit the diagram editor
QAction *undo; ///< Cancel the latest action
QAction *redo; ///< Redo the latest cancelled operation
public: public:
QAction *infos_diagram; ///< Show a dialog to edit diagram properties QAction *m_edit_diagram_properties; ///< Show a dialog to edit diagram properties
QAction *m_conductor_reset; ///< Reset paths of selected conductors QAction *m_conductor_reset; ///< Reset paths of selected conductors
QAction *m_cut; ///< Cut selection to clipboard QAction *m_cut; ///< Cut selection to clipboard
QAction *m_copy; ///< Copy selection to clipboard QAction *m_copy; ///< Copy selection to clipboard
QActionGroup m_row_column_actions_group; /// Action related to add/remove rows/column in diagram
QActionGroup m_selection_actions_group; ///Action related to edit a selected item
QActionGroup *m_depth_action_group = nullptr;
private: private:
QAction *paste; ///< Paste clipboard content on the current diagram QActionGroup *grp_visu_sel; ///< Action group for visualisation vs edition mode
QActionGroup *m_group_view_mode; ///< Action group for project
QActionGroup m_add_item_actions_group; ///Action related to adding (add text image shape...)
QActionGroup m_zoom_actions_group; ///Action related to zoom for diagram
QActionGroup m_select_actions_group; ///Action related to global selections
QActionGroup m_file_actions_group; ///Actions related to file (open, close, save...)
QAction *m_tabbed_view_mode; ///< Display projects as tabs
QAction *m_windowed_view_mode; ///< Display projects as windows
QAction *m_mode_selection; ///< Set edition mode
QAction *m_mode_visualise; ///< Set visualisation mode
QAction *m_export_diagram; ///< Export diagrams of the current project as imagess
QAction *m_print; ///< Print diagrams of the current project
QAction *m_quit_editor; ///< Quit the diagram editor
QAction *undo; ///< Cancel the latest action
QAction *redo; ///< Redo the latest cancelled operation
QAction *m_paste; ///< Paste clipboard content on the current diagram
QAction *m_auto_conductor; ///< Enable/Disable the use of auto conductor QAction *m_auto_conductor; ///< Enable/Disable the use of auto conductor
QAction *conductor_default; ///< Show a dialog to edit default conductor properties QAction *conductor_default; ///< Show a dialog to edit default conductor properties
QAction *m_grey_background; ///< Switch the background color in white or grey QAction *m_grey_background; ///< Switch the background color in white or grey
QAction *m_draw_grid; ///< Switch the background grid display or not QAction *m_draw_grid; ///< Switch the background grid display or not
QAction *prj_edit_prop; ///< Edit the properties of the current project. QAction *m_project_edit_properties; ///< Edit the properties of the current project.
QAction *prj_add_diagram; ///< Add a diagram to the current project. QAction *m_project_add_diagram; ///< Add a diagram to the current project.
QAction *prj_del_diagram; ///< Delete a diagram from the current project QAction *m_remove_diagram_from_project; ///< Delete a diagram from the current project
QAction *prj_clean; ///< Clean the content of the curent project by removing useless items QAction *m_clean_project; ///< Clean the content of the curent project by removing useless items
QAction *prj_diagramList; ///< Sommaire des schemas QAction *m_project_folio_list; ///< Sommaire des schemas
QAction *prj_nomenclature; ///< generate nomenclature QAction *m_project_nomenclature; ///< generate nomenclature
QAction *prj_terminalBloc; ///< generate terminal block QAction *m_project_terminalBloc; ///< generate terminal block
QAction *tile_window; ///< Show MDI subwindows as tile QAction *m_tile_window; ///< Show MDI subwindows as tile
QAction *cascade_window; ///< Show MDI subwindows as cascade QAction *m_cascade_window; ///< Show MDI subwindows as cascade
QAction *prev_window; ///< Switch to the previous document QAction *m_previous_window; ///< Switch to the previous document
QAction *next_window; ///< Switch to the next document QAction *m_next_window; ///< Switch to the next document
QAction *m_edit_selection; ///< To edit selected item QAction *m_edit_selection; ///< To edit selected item
QActionGroup m_add_item_actions_group; ///Action related to adding (add text image shape...)
QActionGroup m_zoom_actions_group; ///Action related to zoom for diagram
QList <QAction *> m_zoom_action_toolBar; ///Only zoom action must displayed in the toolbar QList <QAction *> m_zoom_action_toolBar; ///Only zoom action must displayed in the toolbar
QActionGroup m_select_actions_group; ///Action related to global selections
public:
QActionGroup m_row_column_actions_group; /// Action related to add/remove rows/column in diagram
QActionGroup m_selection_actions_group; ///Action related to edit a selected item
QActionGroup *m_depth_action_group = nullptr;
private:
QAction *m_delete_selection; ///< Delete selection QAction *m_delete_selection; ///< Delete selection
QAction *m_rotate_selection; ///< Rotate selected elements and text items by 90 degrees QAction *m_rotate_selection; ///< Rotate selected elements and text items by 90 degrees
QAction *m_rotate_texts; ///< Direct selected text items to a specific angle QAction *m_rotate_texts; ///< Direct selected text items to a specific angle
QAction *m_find_element; ///< Find the selected element in the panel QAction *m_find_element; ///< Find the selected element in the panel
QAction *m_group_selected_texts = nullptr; QAction *m_group_selected_texts = nullptr;
QActionGroup m_file_actions_group; ///Actions related to file (open, close, save...)
QAction *m_close_file; ///< Close current project file QAction *m_close_file; ///< Close current project file
QAction *save_file; ///< Save current project QAction *m_save_file; ///< Save current project
QAction *save_file_as; ///< Save current project as a specific file QAction *m_save_file_as; ///< Save current project as a specific file
QMdiArea workspace; QMdiArea m_workspace;
QSignalMapper windowMapper; QSignalMapper windowMapper;
/// Directory to use for file dialogs such as File > save QDir open_dialog_dir; /// Directory to use for file dialogs such as File > save
QDir open_dialog_dir; QDockWidget *qdw_pa; /// Dock for the elements panel
/// Dock for the elements panel
QDockWidget *qdw_pa;
QDockWidget *m_qdw_elmt_collection; QDockWidget *m_qdw_elmt_collection;
QDockWidget *qdw_undo; /// Dock for the undo list
ElementsCollectionWidget *m_element_collection_widget; ElementsCollectionWidget *m_element_collection_widget;
/// Dock for the undo list
QDockWidget *qdw_undo;
DiagramPropertiesEditorDockWidget *m_selection_properties_editor; DiagramPropertiesEditorDockWidget *m_selection_properties_editor;
/// Elements panel /// Elements panel
ElementsPanelWidget *pa; ElementsPanelWidget *pa;
@@ -240,7 +219,6 @@ class QETDiagramEditor : public QETMainWindow {
*m_depth_tool_bar = nullptr; *m_depth_tool_bar = nullptr;
QUndoGroup undo_group; QUndoGroup undo_group;
// AutoNumbering Selection Dock
AutoNumberingDockWidget *m_autonumbering_dock; AutoNumberingDockWidget *m_autonumbering_dock;
int activeSubWindowIndex; int activeSubWindowIndex;
bool m_first_show = true; bool m_first_show = true;