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();

View File

@@ -64,22 +64,22 @@
*/ */
QETDiagramEditor::QETDiagramEditor(const QStringList &files, QWidget *parent) : QETDiagramEditor::QETDiagramEditor(const QStringList &files, QWidget *parent) :
QETMainWindow(parent), QETMainWindow(parent),
m_row_column_actions_group (this),
m_selection_actions_group (this),
m_add_item_actions_group (this), m_add_item_actions_group (this),
m_zoom_actions_group (this), m_zoom_actions_group (this),
m_select_actions_group (this), m_select_actions_group (this),
m_row_column_actions_group (this),
m_selection_actions_group (this),
m_file_actions_group (this), m_file_actions_group (this),
open_dialog_dir (QStandardPaths::writableLocation(QStandardPaths::DesktopLocation)) open_dialog_dir (QStandardPaths::writableLocation(QStandardPaths::DesktopLocation))
{ {
activeSubWindowIndex = 0; activeSubWindowIndex = 0;
//Setup the mdi area at center of application //Setup the mdi area at center of application
setCentralWidget(&workspace); setCentralWidget(&m_workspace);
//Set object name to be retrieved by the stylesheets //Set object name to be retrieved by the stylesheets
workspace.setBackground(QBrush(Qt::NoBrush)); m_workspace.setBackground(QBrush(Qt::NoBrush));
workspace.setObjectName("mdiarea"); m_workspace.setObjectName("mdiarea");
workspace.setTabsClosable(true); m_workspace.setTabsClosable(true);
//Set the signal mapper //Set the signal mapper
connect(&windowMapper, SIGNAL(mapped(QWidget *)), this, SLOT(activateWidget(QWidget *))); connect(&windowMapper, SIGNAL(mapped(QWidget *)), this, SLOT(activateWidget(QWidget *)));
@@ -104,7 +104,7 @@ QETDiagramEditor::QETDiagramEditor(const QStringList &files, QWidget *parent) :
setMinimumSize(QSize(500, 350)); setMinimumSize(QSize(500, 350));
setWindowState(Qt::WindowMaximized); setWindowState(Qt::WindowMaximized);
connect (&workspace, SIGNAL(subWindowActivated(QMdiSubWindow *)), this, SLOT(subWindowActivated(QMdiSubWindow*))); connect (&m_workspace, SIGNAL(subWindowActivated(QMdiSubWindow *)), this, SLOT(subWindowActivated(QMdiSubWindow*)));
connect (QApplication::clipboard(), SIGNAL(dataChanged()), this, SLOT(slot_updatePasteAction())); connect (QApplication::clipboard(), SIGNAL(dataChanged()), this, SLOT(slot_updatePasteAction()));
readSettings(); readSettings();
@@ -230,48 +230,90 @@ void QETDiagramEditor::setUpAutonumberingWidget()
*/ */
void QETDiagramEditor::setUpActions() void QETDiagramEditor::setUpActions()
{ {
export_diagram = new QAction(QET::Icons::DocumentExport, tr("E&xporter"), this); //Export to another file type (jpeg, dxf etc...)
print = new QAction(QET::Icons::DocumentPrint, tr("Imprimer"), this); m_export_diagram = new QAction(QET::Icons::DocumentExport, tr("E&xporter"), this);
quit_editor = new QAction(QET::Icons::ApplicationExit, tr("&Quitter"), this); m_export_diagram->setShortcut(QKeySequence(tr("Ctrl+Shift+X")));
m_export_diagram->setStatusTip(tr("Exporte le folio courant dans un autre format", "status bar tip"));
connect(m_export_diagram, &QAction::triggered, [this]() {
ProjectView *current_project = currentProjectView();
if (current_project) {
current_project -> exportProject();
}
});
//Undo redo //Print
m_print = new QAction(QET::Icons::DocumentPrint, tr("Imprimer"), this);
m_print->setShortcut(QKeySequence(QKeySequence::Print));
m_print->setStatusTip(tr("Imprime un ou plusieurs folios du projet courant", "status bar tip"));
connect(m_print, &QAction::triggered, [this]() {
ProjectView *current_project = currentProjectView();
if (current_project) {
current_project -> printProject();
}
});
//Quit editor
m_quit_editor = new QAction(QET::Icons::ApplicationExit, tr("&Quitter"), this);
m_quit_editor->setShortcut(QKeySequence(tr("Ctrl+Q")));
m_quit_editor->setStatusTip(tr("Ferme l'application QElectroTech", "status bar tip"));
connect(m_quit_editor, &QAction::triggered, this, &QETDiagramEditor::close);
//Undo
undo = undo_group.createUndoAction(this, tr("Annuler")); undo = undo_group.createUndoAction(this, tr("Annuler"));
redo = undo_group.createRedoAction(this, tr("Refaire"));
undo->setIcon(QET::Icons::EditUndo); undo->setIcon(QET::Icons::EditUndo);
redo -> setIcon(QET::Icons::EditRedo);
undo->setShortcut(QKeySequence::Undo); undo->setShortcut(QKeySequence::Undo);
redo -> setShortcut(QKeySequence::Redo);
undo->setStatusTip(tr("Annule l'action précédente", "status bar tip")); undo->setStatusTip(tr("Annule l'action précédente", "status bar tip"));
//Redo
redo = undo_group.createRedoAction(this, tr("Refaire"));
redo->setIcon(QET::Icons::EditRedo);
redo->setShortcut(QKeySequence::Redo);
redo->setStatusTip(tr("Restaure l'action annulée", "status bar tip")); redo->setStatusTip(tr("Restaure l'action annulée", "status bar tip"));
//cut copy past action //cut copy past
m_cut = new QAction(QET::Icons::EditCut, tr("Co&uper"), this); m_cut = new QAction(QET::Icons::EditCut, tr("Co&uper"), this);
m_copy = new QAction(QET::Icons::EditCopy, tr("Cop&ier"), this); m_copy = new QAction(QET::Icons::EditCopy, tr("Cop&ier"), this);
paste = new QAction(QET::Icons::EditPaste, tr("C&oller"), this); m_paste = new QAction(QET::Icons::EditPaste, tr("C&oller"), this);
m_cut -> setShortcut(QKeySequence::Cut); m_cut -> setShortcut(QKeySequence::Cut);
m_copy -> setShortcut(QKeySequence::Copy); m_copy -> setShortcut(QKeySequence::Copy);
paste -> setShortcut(QKeySequence::Paste); m_paste -> setShortcut(QKeySequence::Paste);
m_cut -> setStatusTip(tr("Transfère les éléments sélectionnés dans le presse-papier", "status bar tip")); m_cut -> setStatusTip(tr("Transfère les éléments sélectionnés dans le presse-papier", "status bar tip"));
m_copy -> setStatusTip(tr("Copie les éléments sélectionnés dans le presse-papier", "status bar tip")); m_copy -> setStatusTip(tr("Copie les éléments sélectionnés dans le presse-papier", "status bar tip"));
paste -> setStatusTip(tr("Place les éléments du presse-papier sur le folio", "status bar tip")); m_paste -> setStatusTip(tr("Place les éléments du presse-papier sur le folio", "status bar tip"));
connect(m_cut, SIGNAL(triggered()), this, SLOT(slot_cut())); connect(m_cut, &QAction::triggered, [this]() {
connect(m_copy, SIGNAL(triggered()), this, SLOT(slot_copy())); if (currentDiagramView())
connect(paste, SIGNAL(triggered()), this, SLOT(slot_paste())); currentDiagramView()->cut();
});
connect(m_copy, &QAction::triggered, [this]() {
if (currentDiagramView())
currentDiagramView()->copy();
});
connect(m_paste, &QAction::triggered, [this]() {
if(currentDiagramView())
currentDiagramView()->paste();
});
//Reset conductor path
m_conductor_reset = new QAction(QET::Icons::ConductorSettings, tr("Réinitialiser les conducteurs"), this); m_conductor_reset = new QAction(QET::Icons::ConductorSettings, tr("Réinitialiser les conducteurs"), this);
m_conductor_reset->setShortcut( QKeySequence( tr("Ctrl+K") ) ); m_conductor_reset->setShortcut( QKeySequence( tr("Ctrl+K") ) );
m_conductor_reset->setStatusTip(tr("Recalcule les chemins des conducteurs sans tenir compte des modifications", "status bar tip"));
connect(m_conductor_reset, &QAction::triggered, [this]() {
if (DiagramView *dv = currentDiagramView())
dv->resetConductors();
});
//AutoConductor
m_auto_conductor = new QAction (QET::Icons::Autoconnect, tr("Création automatique de conducteur(s)","Tool tip of auto conductor"), this); m_auto_conductor = new QAction (QET::Icons::Autoconnect, tr("Création automatique de conducteur(s)","Tool tip of auto conductor"), this);
m_auto_conductor->setStatusTip (tr("Utiliser la création automatique de conducteur(s) quand cela est possible", "Status tip of auto conductor")); m_auto_conductor->setStatusTip (tr("Utiliser la création automatique de conducteur(s) quand cela est possible", "Status tip of auto conductor"));
m_auto_conductor->setCheckable (true); m_auto_conductor->setCheckable (true);
connect(m_auto_conductor, SIGNAL(triggered(bool)), this, SLOT(slot_autoConductor(bool))); connect(m_auto_conductor, &QAction::triggered, [this](bool ac) {
if (ProjectView *pv = currentProjectView())
pv->project()->setAutoConductor(ac);
});
//Switch background color
m_grey_background = new QAction (QET::Icons::DiagramBg, tr("Couleur de fond blanc/gris","Tool tip of white/grey background button"), this); m_grey_background = new QAction (QET::Icons::DiagramBg, tr("Couleur de fond blanc/gris","Tool tip of white/grey background button"), this);
m_grey_background -> setStatusTip (tr("Affiche la couleur de fond du folio en blanc ou en gris", "Status tip of white/grey background button")); m_grey_background -> setStatusTip (tr("Affiche la couleur de fond du folio en blanc ou en gris", "Status tip of white/grey background button"));
m_grey_background -> setCheckable (true); m_grey_background -> setCheckable (true);
@@ -281,6 +323,7 @@ void QETDiagramEditor::setUpActions()
this->currentDiagramView()->diagram()->update(); this->currentDiagramView()->diagram()->update();
}); });
//Draw or not the background grid
m_draw_grid = new QAction ( QET::Icons::Grid, tr("Afficher la grille"), this); m_draw_grid = new QAction ( QET::Icons::Grid, tr("Afficher la grille"), this);
m_draw_grid->setStatusTip(tr("Affiche ou masque la grille des folios")); m_draw_grid->setStatusTip(tr("Affiche ou masque la grille des folios"));
m_draw_grid->setCheckable(true); m_draw_grid->setCheckable(true);
@@ -293,49 +336,159 @@ void QETDiagramEditor::setUpActions()
} }
}); });
infos_diagram = new QAction(QET::Icons::DialogInformation, tr("Propriétés du folio"), this); //Edit current diagram properties
infos_diagram -> setShortcut( QKeySequence( tr("Ctrl+L") ) ); m_edit_diagram_properties = new QAction(QET::Icons::DialogInformation, tr("Propriétés du folio"), this);
prj_edit_prop = new QAction(QET::Icons::ProjectProperties, tr("Propriétés du projet"), this); m_edit_diagram_properties->setShortcut( QKeySequence( tr("Ctrl+L")));
prj_add_diagram = new QAction(QET::Icons::DiagramAdd, tr("Ajouter un folio"), this); m_edit_diagram_properties -> setStatusTip(tr("Édite les propriétés du folio (dimensions, informations du cartouche, propriétés des conducteurs...)", "status bar tip"));
prj_del_diagram = new QAction(QET::Icons::DiagramDelete, tr("Supprimer le folio"), this); connect(m_edit_diagram_properties, &QAction::triggered, [this]() {
prj_clean = new QAction(QET::Icons::EditClear, tr("Nettoyer le projet"), this); if (ProjectView *project_view = currentProjectView())
prj_diagramList = new QAction(QET::Icons::TableOfContent, tr("Ajouter un sommaire"), this); {
prj_nomenclature = new QAction(QET::Icons::DocumentSpreadsheet, tr("Exporter une nomenclature"), this); activateProject(project_view);
prj_terminalBloc = new QAction(QET::Icons::TerminalStrip, tr("Lancer le plugin de creation de bornier"), this); project_view->editCurrentDiagramProperties();
tabbed_view_mode = new QAction( tr("en utilisant des onglets"), this); }
windowed_view_mode= new QAction( tr("en utilisant des fenêtres"), this); });
mode_selection = new QAction(QET::Icons::PartSelect, tr("Mode Selection"), this);
mode_visualise = new QAction(QET::Icons::ViewMove, tr("Mode Visualisation"), this); //Edit current project properties
tile_window = new QAction( tr("&Mosaïque"), this); m_project_edit_properties = new QAction(QET::Icons::ProjectProperties, tr("Propriétés du projet"), this);
cascade_window = new QAction( tr("&Cascade"), this); connect(m_project_edit_properties, &QAction::triggered, [this]() {
next_window = new QAction( tr("Projet suivant"), this); editProjectProperties(currentProjectView());
prev_window = new QAction( tr("Projet précédent"), this); });
//Add new folio to current project
m_project_add_diagram = new QAction(QET::Icons::DiagramAdd, tr("Ajouter un folio"), this);
m_project_add_diagram->setShortcut(QKeySequence(tr("Ctrl+T")));
connect(m_project_add_diagram, &QAction::triggered, [this]() {
if (ProjectView *current_project = currentProjectView()) {
current_project->addNewDiagram();
}
});
//Remove current folio from current project
m_remove_diagram_from_project = new QAction(QET::Icons::DiagramDelete, tr("Supprimer le folio"), this);
connect(m_remove_diagram_from_project, &QAction::triggered, this, &QETDiagramEditor::removeDiagramFromProject);
//Clean the current project
m_clean_project = new QAction(QET::Icons::EditClear, tr("Nettoyer le projet"), this);
connect(m_clean_project, &QAction::triggered, [this]() {
if (ProjectView *current_project = currentProjectView()) {
if (current_project->cleanProject()) {
pa -> reloadAndFilter();
}
}
});
//Add folio list to current project
m_project_folio_list = new QAction(QET::Icons::TableOfContent, tr("Ajouter un sommaire"), this);
connect(m_project_folio_list, &QAction::triggered, [this]() {
if (ProjectView *current_project = currentProjectView()) {
current_project->addNewDiagramFolioList();
}
});
//Export nomenclature to CSV
m_project_nomenclature = new QAction(QET::Icons::DocumentSpreadsheet, tr("Exporter une nomenclature"), this);
connect(m_project_nomenclature, &QAction::triggered, [this]() {
nomenclature nomencl(currentProjectView()->project(), this);
nomencl.saveToCSVFile();
});
//Lauch the plugin of terminal generator
m_project_terminalBloc = new QAction(QET::Icons::TerminalStrip, tr("Lancer le plugin de creation de bornier"), this);
connect(m_project_terminalBloc, &QAction::triggered, this, &QETDiagramEditor::generateTerminalBlock);
//MDI view style
m_tabbed_view_mode = new QAction(tr("en utilisant des onglets"), this);
m_tabbed_view_mode->setStatusTip(tr("Présente les différents projets ouverts des onglets", "status bar tip"));
m_tabbed_view_mode->setCheckable(true);
connect(m_tabbed_view_mode, &QAction::triggered, this, &QETDiagramEditor::setTabbedMode);
m_windowed_view_mode = new QAction(tr("en utilisant des fenêtres"), this);
m_windowed_view_mode->setStatusTip(tr("Présente les différents projets ouverts dans des sous-fenêtres", "status bar tip"));
m_windowed_view_mode->setCheckable(true);
connect(m_windowed_view_mode, &QAction::triggered, this, &QETDiagramEditor::setWindowedMode);
m_group_view_mode = new QActionGroup(this);
m_group_view_mode -> addAction(m_windowed_view_mode);
m_group_view_mode -> addAction(m_tabbed_view_mode);
m_group_view_mode -> setExclusive(true);
m_tile_window = new QAction(tr("&Mosaïque"), this);
m_tile_window->setStatusTip(tr("Dispose les fenêtres en mosaïque", "status bar tip"));
connect(m_tile_window, &QAction::triggered, &m_workspace, &QMdiArea::tileSubWindows);
m_cascade_window = new QAction(tr("&Cascade"), this);
m_cascade_window->setStatusTip(tr("Dispose les fenêtres en cascade", "status bar tip"));
connect(m_cascade_window, &QAction::triggered, &m_workspace, &QMdiArea::cascadeSubWindows);
//Switch selection/view mode
m_mode_selection = new QAction(QET::Icons::PartSelect, tr("Mode Selection"), this);
m_mode_selection->setStatusTip(tr("Permet de sélectionner les éléments", "status bar tip"));
m_mode_selection->setCheckable(true);
m_mode_selection->setChecked(true);
connect(m_mode_selection, &QAction::triggered, [this]() {
if (ProjectView *pv = currentProjectView()) {
for (DiagramView *dv : pv->diagram_views()) {
dv->setSelectionMode();
}
}
});
m_mode_visualise = new QAction(QET::Icons::ViewMove, tr("Mode Visualisation"), this);
m_mode_visualise->setStatusTip(tr("Permet de visualiser le folio sans pouvoir le modifier", "status bar tip"));
m_mode_visualise->setCheckable(true);
connect(m_mode_visualise, &QAction::triggered, [this]() {
if (ProjectView *pv = currentProjectView()) {
for(DiagramView *dv : pv->diagram_views()) {
dv->setVisualisationMode();
}
}
});
grp_visu_sel = new QActionGroup(this);
grp_visu_sel->addAction(m_mode_selection);
grp_visu_sel->addAction(m_mode_visualise);
grp_visu_sel->setExclusive(true);
//Navigate next/previous project
m_next_window = new QAction(tr("Projet suivant"), this);
m_next_window->setShortcut(QKeySequence::NextChild);
m_next_window->setStatusTip(tr("Active le projet suivant", "status bar tip"));
connect(m_next_window, &QAction::triggered, &m_workspace, &QMdiArea::activateNextSubWindow);
m_previous_window = new QAction(tr("Projet précédent"), this);
m_previous_window->setShortcut(QKeySequence::PreviousChild);
m_previous_window->setStatusTip(tr("Active le projet précédent", "status bar tip"));
connect(m_previous_window, &QAction::triggered, &m_workspace, &QMdiArea::activatePreviousSubWindow);
//Files action //Files action
QAction *new_file = m_file_actions_group.addAction(QET::Icons::ProjectNew, tr("&Nouveau")); QAction *new_file = m_file_actions_group.addAction(QET::Icons::ProjectNew, tr("&Nouveau"));
QAction *open_file = m_file_actions_group.addAction(QET::Icons::DocumentOpen, tr("&Ouvrir")); QAction *open_file = m_file_actions_group.addAction(QET::Icons::DocumentOpen, tr("&Ouvrir"));
save_file = m_file_actions_group.addAction( QET::Icons::DocumentSave, tr("&Enregistrer") ); m_save_file = m_file_actions_group.addAction(QET::Icons::DocumentSave, tr("&Enregistrer"));
save_file_as = m_file_actions_group.addAction( QET::Icons::DocumentSaveAs, tr("Enregistrer sous") ); m_save_file_as = m_file_actions_group.addAction(QET::Icons::DocumentSaveAs, tr("Enregistrer sous"));
m_close_file = m_file_actions_group.addAction(QET::Icons::ProjectClose, tr("&Fermer")); m_close_file = m_file_actions_group.addAction(QET::Icons::ProjectClose, tr("&Fermer"));
new_file ->setShortcut(QKeySequence::New); new_file ->setShortcut(QKeySequence::New);
open_file ->setShortcut(QKeySequence::Open); open_file ->setShortcut(QKeySequence::Open);
m_close_file ->setShortcut(QKeySequence::Close); m_close_file ->setShortcut(QKeySequence::Close);
save_file -> setShortcut( QKeySequence::Save ); m_save_file ->setShortcut(QKeySequence::Save);
new_file ->setStatusTip( tr("Crée un nouveau projet", "status bar tip") ); new_file ->setStatusTip( tr("Crée un nouveau projet", "status bar tip") );
open_file ->setStatusTip( tr("Ouvre un projet existant", "status bar tip") ); open_file ->setStatusTip( tr("Ouvre un projet existant", "status bar tip") );
m_close_file ->setStatusTip( tr("Ferme le projet courant", "status bar tip") ); m_close_file ->setStatusTip( tr("Ferme le projet courant", "status bar tip") );
save_file -> setStatusTip( tr("Enregistre le projet courant et tous ses folios", "status bar tip") ); m_save_file ->setStatusTip( tr("Enregistre le projet courant et tous ses folios", "status bar tip") );
save_file_as -> setStatusTip( tr("Enregistre le projet courant avec un autre nom de fichier", "status bar tip") ); m_save_file_as ->setStatusTip( tr("Enregistre le projet courant avec un autre nom de fichier", "status bar tip") );
connect(save_file_as, SIGNAL( triggered() ), this, SLOT( saveAs() ) ); connect(m_save_file_as, &QAction::triggered, this, &QETDiagramEditor::saveAs);
connect(save_file, SIGNAL( triggered() ), this, SLOT( save() ) ); connect(m_save_file, &QAction::triggered, this, &QETDiagramEditor::save);
connect(new_file, SIGNAL( triggered() ), this, SLOT( newProject() ) ); connect(new_file, &QAction::triggered, this, &QETDiagramEditor::newProject);
connect(open_file, SIGNAL( triggered() ), this, SLOT( openProject() ) ); connect(open_file, &QAction::triggered, this, &QETDiagramEditor::openProject);
connect(m_close_file, SIGNAL( triggered() ), this, SLOT( closeCurrentProject() ) ); connect(m_close_file, &QAction::triggered, [this]() {
if (ProjectView *project_view = currentProjectView()) {
closeProject(project_view);
}
});
//Row and Column actions //Rows and Columns
QAction *add_column = m_row_column_actions_group.addAction( QET::Icons::EditTableInsertColumnRight, tr("Ajouter une colonne") ); QAction *add_column = m_row_column_actions_group.addAction( QET::Icons::EditTableInsertColumnRight, tr("Ajouter une colonne") );
QAction *remove_column = m_row_column_actions_group.addAction( QET::Icons::EditTableDeleteColumn, tr("Enlever une colonne") ); QAction *remove_column = m_row_column_actions_group.addAction( QET::Icons::EditTableDeleteColumn, tr("Enlever une colonne") );
QAction *add_row = m_row_column_actions_group.addAction( QET::Icons::EditTableInsertRowUnder, tr("Ajouter une ligne", "Add row") ); QAction *add_row = m_row_column_actions_group.addAction( QET::Icons::EditTableInsertRowUnder, tr("Ajouter une ligne", "Add row") );
@@ -442,95 +595,13 @@ void QETDiagramEditor::setUpActions()
add_ellipse ->setData("ellipse"); add_ellipse ->setData("ellipse");
add_polyline ->setData("polyline"); add_polyline ->setData("polyline");
foreach (QAction *action, m_add_item_actions_group.actions()) action->setCheckable(true); for(QAction *action : m_add_item_actions_group.actions()) {
action->setCheckable(true);
}
connect(&m_add_item_actions_group, &QActionGroup::triggered, this, &QETDiagramEditor::addItemGroupTriggered); connect(&m_add_item_actions_group, &QActionGroup::triggered, this, &QETDiagramEditor::addItemGroupTriggered);
//Keyboard shortcut
export_diagram -> setShortcut(QKeySequence(tr("Ctrl+Shift+X")));
print -> setShortcut(QKeySequence(QKeySequence::Print));
quit_editor -> setShortcut(QKeySequence(tr("Ctrl+Q")));
prj_add_diagram -> setShortcut(QKeySequence(tr("Ctrl+T")));
next_window -> setShortcut(QKeySequence::NextChild);
prev_window -> setShortcut(QKeySequence::PreviousChild);
// affichage dans la barre de statut
export_diagram -> setStatusTip(tr("Exporte le folio courant dans un autre format", "status bar tip"));
print -> setStatusTip(tr("Imprime un ou plusieurs folios du projet courant", "status bar tip"));
quit_editor -> setStatusTip(tr("Ferme l'application QElectroTech", "status bar tip"));
m_conductor_reset -> setStatusTip(tr("Recalcule les chemins des conducteurs sans tenir compte des modifications", "status bar tip"));
infos_diagram -> setStatusTip(tr("Édite les propriétés du folio (dimensions, informations du cartouche, propriétés des conducteurs...)", "status bar tip"));
windowed_view_mode -> setStatusTip(tr("Présente les différents projets ouverts dans des sous-fenêtres", "status bar tip"));
tabbed_view_mode -> setStatusTip(tr("Présente les différents projets ouverts des onglets", "status bar tip"));
mode_selection -> setStatusTip(tr("Permet de sélectionner les éléments", "status bar tip"));
mode_visualise -> setStatusTip(tr("Permet de visualiser le folio sans pouvoir le modifier", "status bar tip"));
tile_window -> setStatusTip(tr("Dispose les fenêtres en mosaïque", "status bar tip"));
cascade_window -> setStatusTip(tr("Dispose les fenêtres en cascade", "status bar tip"));
next_window -> setStatusTip(tr("Active le projet suivant", "status bar tip"));
prev_window -> setStatusTip(tr("Active le projet précédent", "status bar tip"));
//mode_visualise -> setShortcut( QKeySequence( tr("Ctrl+Shift") ) );
// traitements speciaux
windowed_view_mode -> setCheckable(true);
tabbed_view_mode -> setCheckable(true);
mode_selection -> setCheckable(true);
mode_visualise -> setCheckable(true);
mode_selection -> setChecked(true);
grp_visu_sel = new QActionGroup(this);
grp_visu_sel -> addAction(mode_selection);
grp_visu_sel -> addAction(mode_visualise);
grp_visu_sel -> setExclusive(true);
grp_view_mode = new QActionGroup(this);
grp_view_mode -> addAction(windowed_view_mode);
grp_view_mode -> addAction(tabbed_view_mode);
grp_view_mode -> setExclusive(true);
// connexion a des slots
connect(quit_editor, SIGNAL(triggered()), this, SLOT(close()) );
connect(windowed_view_mode, SIGNAL(triggered()), this, SLOT(setWindowedMode()) );
connect(tabbed_view_mode, SIGNAL(triggered()), this, SLOT(setTabbedMode()) );
connect(mode_selection, SIGNAL(triggered()), this, SLOT(slot_setSelectionMode()) );
connect(mode_visualise, SIGNAL(triggered()), this, SLOT(slot_setVisualisationMode()) );
connect(prj_edit_prop, SIGNAL(triggered()), this, SLOT(editCurrentProjectProperties()));
connect(prj_add_diagram, SIGNAL(triggered()), this, SLOT(addDiagramToProject()) );
connect(prj_del_diagram, SIGNAL(triggered()), this, SLOT(removeDiagramFromProject()) );
connect(prj_clean, SIGNAL(triggered()), this, SLOT(cleanCurrentProject()) );
connect(prj_diagramList, SIGNAL(triggered()), this, SLOT(addDiagramFolioListToProject()));
connect(prj_nomenclature, SIGNAL(triggered()), this, SLOT(nomenclatureProject()) );
connect(prj_terminalBloc, SIGNAL(triggered()), this, SLOT(slot_generateTerminalBlock()));
connect(print, SIGNAL(triggered()), this, SLOT(printDialog()) );
connect(export_diagram, SIGNAL(triggered()), this, SLOT(exportDialog()) );
connect(tile_window, SIGNAL(triggered()), &workspace, SLOT(tileSubWindows()) );
connect(cascade_window, SIGNAL(triggered()), &workspace, SLOT(cascadeSubWindows()) );
connect(next_window, SIGNAL(triggered()), &workspace, SLOT(activateNextSubWindow()) );
connect(prev_window, SIGNAL(triggered()), &workspace, SLOT(activatePreviousSubWindow()) );
connect(m_conductor_reset, SIGNAL(triggered()), this, SLOT(slot_resetConductors()) );
connect(infos_diagram, SIGNAL(triggered()), this, SLOT(editCurrentDiagramProperties()));
//Depth action //Depth action
m_depth_action_group = new QActionGroup(this); m_depth_action_group = QET::depthActionGroup(this);
QAction *edit_forward = new QAction(QET::Icons::BringForward, tr("Amener au premier plan"), m_depth_action_group);
QAction *edit_raise = new QAction(QET::Icons::Raise, tr("Rapprocher"), m_depth_action_group);
QAction *edit_lower = new QAction(QET::Icons::Lower, tr("Éloigner"), m_depth_action_group);
QAction *edit_backward = new QAction(QET::Icons::SendBackward, tr("Envoyer au fond"), m_depth_action_group);
edit_raise ->setShortcut(QKeySequence(tr("Ctrl+Shift+Up")));
edit_lower ->setShortcut(QKeySequence(tr("Ctrl+Shift+Down")));
edit_backward->setShortcut(QKeySequence(tr("Ctrl+Shift+End")));
edit_forward ->setShortcut(QKeySequence(tr("Ctrl+Shift+Home")));
edit_forward ->setData(QET::BringForward);
edit_raise ->setData(QET::Raise);
edit_lower ->setData(QET::Lower);
edit_backward->setData(QET::SendBackward);
m_depth_action_group->setDisabled(true); m_depth_action_group->setDisabled(true);
connect(m_depth_action_group, &QActionGroup::triggered, [this](QAction *action) { connect(m_depth_action_group, &QActionGroup::triggered, [this](QAction *action) {
@@ -553,28 +624,28 @@ void QETDiagramEditor::setUpToolBar()
diagram_tool_bar -> setObjectName("diagram"); diagram_tool_bar -> setObjectName("diagram");
main_tool_bar -> addActions(m_file_actions_group.actions()); main_tool_bar -> addActions(m_file_actions_group.actions());
main_tool_bar -> addAction(print); main_tool_bar -> addAction(m_print);
main_tool_bar -> addSeparator(); main_tool_bar -> addSeparator();
main_tool_bar -> addAction(undo); main_tool_bar -> addAction(undo);
main_tool_bar -> addAction(redo); main_tool_bar -> addAction(redo);
main_tool_bar -> addSeparator(); main_tool_bar -> addSeparator();
main_tool_bar -> addAction(m_cut); main_tool_bar -> addAction(m_cut);
main_tool_bar -> addAction(m_copy); main_tool_bar -> addAction(m_copy);
main_tool_bar -> addAction(paste); main_tool_bar -> addAction(m_paste);
main_tool_bar -> addSeparator(); main_tool_bar -> addSeparator();
main_tool_bar -> addAction(m_delete_selection); main_tool_bar -> addAction(m_delete_selection);
main_tool_bar -> addAction(m_rotate_selection); main_tool_bar -> addAction(m_rotate_selection);
// Modes selection / visualisation et zoom // Modes selection / visualisation et zoom
view_tool_bar -> addAction(mode_selection); view_tool_bar -> addAction(m_mode_selection);
view_tool_bar -> addAction(mode_visualise); view_tool_bar -> addAction(m_mode_visualise);
view_tool_bar -> addSeparator(); view_tool_bar -> addSeparator();
view_tool_bar -> addAction(m_draw_grid); view_tool_bar -> addAction(m_draw_grid);
view_tool_bar -> addAction (m_grey_background); view_tool_bar -> addAction (m_grey_background);
view_tool_bar -> addSeparator(); view_tool_bar -> addSeparator();
view_tool_bar -> addActions(m_zoom_action_toolBar); view_tool_bar -> addActions(m_zoom_action_toolBar);
diagram_tool_bar -> addAction (infos_diagram); diagram_tool_bar -> addAction (m_edit_diagram_properties);
diagram_tool_bar -> addAction (m_conductor_reset); diagram_tool_bar -> addAction (m_conductor_reset);
diagram_tool_bar -> addAction (m_auto_conductor); diagram_tool_bar -> addAction (m_auto_conductor);
@@ -618,11 +689,11 @@ void QETDiagramEditor::setUpMenu() {
menu_fichier -> addActions(m_file_actions_group.actions()); menu_fichier -> addActions(m_file_actions_group.actions());
menu_fichier -> addSeparator(); menu_fichier -> addSeparator();
//menu_fichier -> addAction(import_diagram); //menu_fichier -> addAction(import_diagram);
menu_fichier -> addAction(export_diagram); menu_fichier -> addAction(m_export_diagram);
//menu_fichier -> addSeparator(); //menu_fichier -> addSeparator();
menu_fichier -> addAction(print); menu_fichier -> addAction(m_print);
menu_fichier -> addSeparator(); menu_fichier -> addSeparator();
menu_fichier -> addAction(quit_editor); menu_fichier -> addAction(m_quit_editor);
// menu Edition // menu Edition
menu_edition -> addAction(undo); menu_edition -> addAction(undo);
@@ -630,7 +701,7 @@ void QETDiagramEditor::setUpMenu() {
menu_edition -> addSeparator(); menu_edition -> addSeparator();
menu_edition -> addAction(m_cut); menu_edition -> addAction(m_cut);
menu_edition -> addAction(m_copy); menu_edition -> addAction(m_copy);
menu_edition -> addAction(paste); menu_edition -> addAction(m_paste);
menu_edition -> addSeparator(); menu_edition -> addSeparator();
menu_edition -> addActions(m_select_actions_group.actions()); menu_edition -> addActions(m_select_actions_group.actions());
menu_edition -> addSeparator(); menu_edition -> addSeparator();
@@ -638,20 +709,20 @@ void QETDiagramEditor::setUpMenu() {
menu_edition -> addSeparator(); menu_edition -> addSeparator();
menu_edition -> addAction(m_conductor_reset); menu_edition -> addAction(m_conductor_reset);
menu_edition -> addSeparator(); menu_edition -> addSeparator();
menu_edition -> addAction(infos_diagram); menu_edition -> addAction(m_edit_diagram_properties);
menu_edition -> addActions(m_row_column_actions_group.actions()); menu_edition -> addActions(m_row_column_actions_group.actions());
menu_edition -> addSeparator(); menu_edition -> addSeparator();
menu_edition -> addActions(m_depth_action_group->actions()); menu_edition -> addActions(m_depth_action_group->actions());
// menu Projet // menu Projet
menu_project -> addAction(prj_edit_prop); menu_project -> addAction(m_project_edit_properties);
menu_project -> addAction(prj_add_diagram); menu_project -> addAction(m_project_add_diagram);
menu_project -> addAction(prj_del_diagram); menu_project -> addAction(m_remove_diagram_from_project);
menu_project -> addAction(prj_clean); menu_project -> addAction(m_clean_project);
menu_project -> addSeparator(); menu_project -> addSeparator();
menu_project -> addAction(prj_diagramList); menu_project -> addAction(m_project_folio_list);
menu_project -> addAction(prj_nomenclature); menu_project -> addAction(m_project_nomenclature);
menu_project -> addAction(prj_terminalBloc); menu_project -> addAction(m_project_terminalBloc);
main_tool_bar -> toggleViewAction() -> setStatusTip(tr("Affiche ou non la barre d'outils principale")); main_tool_bar -> toggleViewAction() -> setStatusTip(tr("Affiche ou non la barre d'outils principale"));
view_tool_bar -> toggleViewAction() -> setStatusTip(tr("Affiche ou non la barre d'outils Affichage")); view_tool_bar -> toggleViewAction() -> setStatusTip(tr("Affiche ou non la barre d'outils Affichage"));
@@ -663,12 +734,12 @@ void QETDiagramEditor::setUpMenu() {
// menu Affichage // menu Affichage
QMenu *projects_view_mode = menu_affichage -> addMenu(QET::Icons::ConfigureToolbars, tr("Afficher les projets")); QMenu *projects_view_mode = menu_affichage -> addMenu(QET::Icons::ConfigureToolbars, tr("Afficher les projets"));
projects_view_mode -> setTearOffEnabled(true); projects_view_mode -> setTearOffEnabled(true);
projects_view_mode -> addAction(windowed_view_mode); projects_view_mode -> addAction(m_windowed_view_mode);
projects_view_mode -> addAction(tabbed_view_mode); projects_view_mode -> addAction(m_tabbed_view_mode);
menu_affichage -> addSeparator(); menu_affichage -> addSeparator();
menu_affichage -> addAction(mode_selection); menu_affichage -> addAction(m_mode_selection);
menu_affichage -> addAction(mode_visualise); menu_affichage -> addAction(m_mode_visualise);
menu_affichage -> addSeparator(); menu_affichage -> addSeparator();
menu_affichage -> addAction(m_draw_grid); menu_affichage -> addAction(m_draw_grid);
menu_affichage -> addAction(m_grey_background); menu_affichage -> addAction(m_grey_background);
@@ -725,24 +796,6 @@ bool QETDiagramEditor::event(QEvent *e)
return(QETMainWindow::event(e)); return(QETMainWindow::event(e));
} }
/**
Imprime le schema courant
*/
void QETDiagramEditor::printDialog() {
ProjectView *current_project = currentProjectView();
if (!current_project) return;
current_project -> printProject();
}
/**
Gere l'export de schema sous forme d'image
*/
void QETDiagramEditor::exportDialog() {
ProjectView *current_project = currentProjectView();
if (!current_project) return;
current_project -> exportProject();
}
/** /**
* @brief QETDiagramEditor::save * @brief QETDiagramEditor::save
* Ask the current active project to save * Ask the current active project to save
@@ -875,18 +928,6 @@ bool QETDiagramEditor::closeProject(QETProject *project) {
return(true); return(true);
} }
/**
Ferme le projet courant
@return true si la fermeture du fichier a reussi, false sinon
Note : cette methode renvoie true s'il n'y a pas de projet courant
*/
bool QETDiagramEditor::closeCurrentProject() {
if (ProjectView *project_view = currentProjectView()) {
return(closeProject(project_view));
}
return(true);
}
/** /**
Ouvre un projet depuis un fichier et l'ajoute a cet editeur Ouvre un projet depuis un fichier et l'ajoute a cet editeur
@param filepath Chemin du projet a ouvrir @param filepath Chemin du projet a ouvrir
@@ -1029,7 +1070,7 @@ bool QETDiagramEditor::addProject(QETProject *project, bool update_panel) {
*/ */
QList<ProjectView *> QETDiagramEditor::openedProjects() const { QList<ProjectView *> QETDiagramEditor::openedProjects() const {
QList<ProjectView *> result; QList<ProjectView *> result;
QList<QMdiSubWindow *> window_list(workspace.subWindowList()); QList<QMdiSubWindow *> window_list(m_workspace.subWindowList());
foreach(QMdiSubWindow *window, window_list) { foreach(QMdiSubWindow *window, window_list) {
if (ProjectView *project_view = qobject_cast<ProjectView *>(window -> widget())) { if (ProjectView *project_view = qobject_cast<ProjectView *>(window -> widget())) {
result << project_view; result << project_view;
@@ -1043,7 +1084,7 @@ QList<ProjectView *> QETDiagramEditor::openedProjects() const {
MDI) ou 0 s'il n'y en a pas MDI) ou 0 s'il n'y en a pas
*/ */
ProjectView *QETDiagramEditor::currentProjectView() const { ProjectView *QETDiagramEditor::currentProjectView() const {
QMdiSubWindow *current_window = workspace.activeSubWindow(); QMdiSubWindow *current_window = m_workspace.activeSubWindow();
if (!current_window) return(nullptr); if (!current_window) return(nullptr);
QWidget *current_widget = current_window -> widget(); QWidget *current_widget = current_window -> widget();
@@ -1161,7 +1202,7 @@ ProjectView *QETDiagramEditor::findProject(const QString &filepath) const {
celui-ci n'a pas ete trouve. celui-ci n'a pas ete trouve.
*/ */
QMdiSubWindow *QETDiagramEditor::subWindowForWidget(QWidget *widget) const { QMdiSubWindow *QETDiagramEditor::subWindowForWidget(QWidget *widget) const {
foreach(QMdiSubWindow *sub_window, workspace.subWindowList()) { foreach(QMdiSubWindow *sub_window, m_workspace.subWindowList()) {
if (sub_window -> widget() == widget) { if (sub_window -> widget() == widget) {
return(sub_window); return(sub_window);
} }
@@ -1175,31 +1216,10 @@ QMdiSubWindow *QETDiagramEditor::subWindowForWidget(QWidget *widget) const {
void QETDiagramEditor::activateWidget(QWidget *widget) { void QETDiagramEditor::activateWidget(QWidget *widget) {
QMdiSubWindow *sub_window = subWindowForWidget(widget); QMdiSubWindow *sub_window = subWindowForWidget(widget);
if (sub_window) { if (sub_window) {
workspace.setActiveSubWindow(sub_window); m_workspace.setActiveSubWindow(sub_window);
} }
} }
/**
Effectue l'action "couper" sur le schema en cours
*/
void QETDiagramEditor::slot_cut() {
if(currentDiagramView()) currentDiagramView() -> cut();
}
/**
Effectue l'action "copier" sur le diagram en cours
*/
void QETDiagramEditor::slot_copy() {
if(currentDiagramView()) currentDiagramView() -> copy();
}
/**
Effectue l'action "coller" sur le schema en cours
*/
void QETDiagramEditor::slot_paste() {
if(currentDiagramView()) currentDiagramView() -> paste();
}
void QETDiagramEditor::zoomGroupTriggered(QAction *action) void QETDiagramEditor::zoomGroupTriggered(QAction *action)
{ {
QString value = action->data().toString(); QString value = action->data().toString();
@@ -1349,28 +1369,6 @@ void QETDiagramEditor::rowColumnGroupTriggered(QAction *action)
d->undoStack().push(new ChangeBorderCommand(d, old_bp, new_bp)); d->undoStack().push(new ChangeBorderCommand(d, old_bp, new_bp));
} }
/**
* @brief QETDiagramEditor::slot_setSelectionMode
* Set all diagram view of the current project to selection mode
*/
void QETDiagramEditor::slot_setSelectionMode()
{
if (ProjectView *pv = currentProjectView())
foreach(DiagramView *dv, pv -> diagram_views())
dv -> setSelectionMode();
}
/**
* @brief QETDiagramEditor::slot_setVisualisationMode
* Set all diagram view of the current project to visualisation mode
*/
void QETDiagramEditor::slot_setVisualisationMode()
{
if (ProjectView *pv = currentProjectView())
foreach(DiagramView *dv, pv -> diagram_views())
dv -> setVisualisationMode();
}
/** /**
* @brief QETDiagramEditor::slot_updateActions * @brief QETDiagramEditor::slot_updateActions
* Manage actions * Manage actions
@@ -1385,19 +1383,19 @@ void QETDiagramEditor::slot_updateActions()
bool editable_project = (pv && !pv -> project() -> isReadOnly()); bool editable_project = (pv && !pv -> project() -> isReadOnly());
m_close_file -> setEnabled(opened_project); m_close_file -> setEnabled(opened_project);
save_file -> setEnabled(opened_project); m_save_file -> setEnabled(opened_project);
save_file_as -> setEnabled(opened_project); m_save_file_as -> setEnabled(opened_project);
prj_edit_prop -> setEnabled(opened_project); m_project_edit_properties -> setEnabled(opened_project);
//prj_terminalBloc -> setEnabled(opened_project); //prj_terminalBloc -> setEnabled(opened_project);
prj_add_diagram -> setEnabled(editable_project); m_project_add_diagram -> setEnabled(editable_project);
prj_del_diagram -> setEnabled(editable_project); m_remove_diagram_from_project -> setEnabled(editable_project);
prj_clean -> setEnabled(editable_project); m_clean_project -> setEnabled(editable_project);
prj_diagramList -> setEnabled(opened_project); m_project_folio_list -> setEnabled(opened_project);
prj_nomenclature -> setEnabled(editable_project); m_project_nomenclature -> setEnabled(editable_project);
export_diagram -> setEnabled(opened_diagram); m_export_diagram -> setEnabled(opened_diagram);
print -> setEnabled(opened_diagram); m_print -> setEnabled(opened_diagram);
infos_diagram -> setEnabled(opened_diagram); m_edit_diagram_properties -> setEnabled(opened_diagram);
prj_nomenclature -> setEnabled(editable_project); m_project_nomenclature -> setEnabled(editable_project);
m_zoom_actions_group. setEnabled(opened_diagram); m_zoom_actions_group. setEnabled(opened_diagram);
m_select_actions_group. setEnabled(opened_diagram); m_select_actions_group. setEnabled(opened_diagram);
m_add_item_actions_group. setEnabled(editable_project); m_add_item_actions_group. setEnabled(editable_project);
@@ -1417,8 +1415,8 @@ void QETDiagramEditor::slot_updateActions()
* Update Auto Num Dock Widget when changing Project * Update Auto Num Dock Widget when changing Project
*/ */
void QETDiagramEditor::slot_updateAutoNumDock() { void QETDiagramEditor::slot_updateAutoNumDock() {
if ( workspace.subWindowList().indexOf(workspace.activeSubWindow()) != activeSubWindowIndex) { if ( m_workspace.subWindowList().indexOf(m_workspace.activeSubWindow()) != activeSubWindowIndex) {
activeSubWindowIndex = workspace.subWindowList().indexOf(workspace.activeSubWindow()); activeSubWindowIndex = m_workspace.subWindowList().indexOf(m_workspace.activeSubWindow());
if (currentProjectView() != nullptr && currentDiagramView() != nullptr) { if (currentProjectView() != nullptr && currentDiagramView() != nullptr) {
m_autonumbering_dock->setProject(currentProjectView()->project(),currentProjectView()); m_autonumbering_dock->setProject(currentProjectView()->project(),currentProjectView());
} }
@@ -1571,11 +1569,11 @@ void QETDiagramEditor::slot_updateModeActions()
break; break;
case QGraphicsView::ScrollHandDrag: case QGraphicsView::ScrollHandDrag:
grp_visu_sel -> setEnabled(true); grp_visu_sel -> setEnabled(true);
mode_visualise -> setChecked(true); m_mode_visualise -> setChecked(true);
break; break;
case QGraphicsView::RubberBandDrag: case QGraphicsView::RubberBandDrag:
grp_visu_sel -> setEnabled(true); grp_visu_sel -> setEnabled(true);
mode_selection -> setChecked(true); m_mode_selection -> setChecked(true);
break; break;
} }
} }
@@ -1597,7 +1595,7 @@ void QETDiagramEditor::slot_updatePasteAction() {
bool editable_diagram = (dv && !dv -> diagram() -> isReadOnly()); bool editable_diagram = (dv && !dv -> diagram() -> isReadOnly());
// pour coller, il faut un schema ouvert et un schema dans le presse-papier // pour coller, il faut un schema ouvert et un schema dans le presse-papier
paste -> setEnabled(editable_diagram && Diagram::clipboardMayContainDiagram()); m_paste -> setEnabled(editable_diagram && Diagram::clipboardMayContainDiagram());
} }
/** /**
@@ -1629,11 +1627,11 @@ void QETDiagramEditor::addProjectView(ProjectView *project_view)
connect(project_view, SIGNAL(errorEncountered(QString)), this, SLOT(showError(const QString &))); connect(project_view, SIGNAL(errorEncountered(QString)), this, SLOT(showError(const QString &)));
//We maximise the new window if the current window is inexistent or maximized //We maximise the new window if the current window is inexistent or maximized
QWidget *current_window = workspace.activeSubWindow(); QWidget *current_window = m_workspace.activeSubWindow();
bool maximise = ((!current_window) || (current_window -> windowState() & Qt::WindowMaximized)); bool maximise = ((!current_window) || (current_window -> windowState() & Qt::WindowMaximized));
//Add the new window //Add the new window
QMdiSubWindow *sub_window = workspace.addSubWindow(project_view); QMdiSubWindow *sub_window = m_workspace.addSubWindow(project_view);
sub_window -> setWindowIcon(project_view -> windowIcon()); sub_window -> setWindowIcon(project_view -> windowIcon());
sub_window -> systemMenu() -> clear(); sub_window -> systemMenu() -> clear();
@@ -1693,7 +1691,7 @@ ProjectView *QETDiagramEditor::viewForFile(const QString &filepath) const {
* Retrieve current Project open in diagram editor * Retrieve current Project open in diagram editor
*/ */
ProjectView *QETDiagramEditor::acessCurrentProject (){ ProjectView *QETDiagramEditor::acessCurrentProject (){
QMdiSubWindow *current_window = workspace.activeSubWindow(); QMdiSubWindow *current_window = m_workspace.activeSubWindow();
if (!current_window) return(nullptr); if (!current_window) return(nullptr);
QWidget *current_widget = current_window -> widget(); QWidget *current_widget = current_window -> widget();
@@ -1737,21 +1735,21 @@ void QETDiagramEditor::slot_updateWindowsMenu() {
// actions de reorganisation des fenetres // actions de reorganisation des fenetres
windows_menu -> addSeparator(); windows_menu -> addSeparator();
windows_menu -> addAction(tile_window); windows_menu -> addAction(m_tile_window);
windows_menu -> addAction(cascade_window); windows_menu -> addAction(m_cascade_window);
// actions de deplacement entre les fenetres // actions de deplacement entre les fenetres
windows_menu -> addSeparator(); windows_menu -> addSeparator();
windows_menu -> addAction(next_window); windows_menu -> addAction(m_next_window);
windows_menu -> addAction(prev_window); windows_menu -> addAction(m_previous_window);
// liste des fenetres // liste des fenetres
QList<ProjectView *> windows = openedProjects(); QList<ProjectView *> windows = openedProjects();
tile_window -> setEnabled(!windows.isEmpty() && workspace.viewMode() == QMdiArea::SubWindowView); m_tile_window -> setEnabled(!windows.isEmpty() && m_workspace.viewMode() == QMdiArea::SubWindowView);
cascade_window -> setEnabled(!windows.isEmpty() && workspace.viewMode() == QMdiArea::SubWindowView); m_cascade_window -> setEnabled(!windows.isEmpty() && m_workspace.viewMode() == QMdiArea::SubWindowView);
next_window -> setEnabled(windows.count() > 1); m_next_window -> setEnabled(windows.count() > 1);
prev_window -> setEnabled(windows.count() > 1); m_previous_window -> setEnabled(windows.count() > 1);
if (!windows.isEmpty()) windows_menu -> addSeparator(); if (!windows.isEmpty()) windows_menu -> addSeparator();
QActionGroup *windows_actions = new QActionGroup(this); QActionGroup *windows_actions = new QActionGroup(this);
@@ -1767,16 +1765,6 @@ void QETDiagramEditor::slot_updateWindowsMenu() {
} }
} }
/**
Edite les informations du schema en cours
*/
void QETDiagramEditor::editCurrentDiagramProperties() {
if (ProjectView *project_view = currentProjectView()) {
activateProject(project_view);
project_view -> editCurrentDiagramProperties();
}
}
/** /**
Edite les proprietes du schema diagram Edite les proprietes du schema diagram
@param diagram_view schema dont il faut editer les proprietes @param diagram_view schema dont il faut editer les proprietes
@@ -1799,41 +1787,12 @@ void QETDiagramEditor::editDiagramProperties(Diagram *diagram) {
} }
} }
/**
Edite les proprietes des objets selectionnes
*/
void QETDiagramEditor::editSelectionProperties() {
if (DiagramView *dv = currentDiagramView()) {
dv -> editSelectionProperties();
}
}
/**
Reinitialise les conducteurs selectionnes
*/
void QETDiagramEditor::slot_resetConductors() {
if (DiagramView *dv = currentDiagramView()) {
dv -> resetConductors();
}
}
/**
* @brief QETDiagramEditor::slot_autoConductor
* @param ac
* Update the auto conductor status of current project;
*/
void QETDiagramEditor::slot_autoConductor(bool ac)
{
if (ProjectView *pv = currentProjectView())
pv -> project() -> setAutoConductor(ac);
}
/** /**
Affiche les projets dans des fenetres. Affiche les projets dans des fenetres.
*/ */
void QETDiagramEditor::setWindowedMode() { void QETDiagramEditor::setWindowedMode() {
workspace.setViewMode(QMdiArea::SubWindowView); m_workspace.setViewMode(QMdiArea::SubWindowView);
windowed_view_mode -> setChecked(true); m_windowed_view_mode -> setChecked(true);
slot_updateWindowsMenu(); slot_updateWindowsMenu();
} }
@@ -1841,8 +1800,8 @@ void QETDiagramEditor::setWindowedMode() {
Affiche les projets dans des onglets. Affiche les projets dans des onglets.
*/ */
void QETDiagramEditor::setTabbedMode() { void QETDiagramEditor::setTabbedMode() {
workspace.setViewMode(QMdiArea::TabbedView); m_workspace.setViewMode(QMdiArea::TabbedView);
tabbed_view_mode -> setChecked(true); m_tabbed_view_mode -> setChecked(true);
slot_updateWindowsMenu(); slot_updateWindowsMenu();
} }
@@ -1930,13 +1889,6 @@ void QETDiagramEditor::projectWasClosed(ProjectView *project_view) {
project -> deleteLater(); project -> deleteLater();
} }
/**
Edite les proprietes du projet courant.
*/
void QETDiagramEditor::editCurrentProjectProperties() {
editProjectProperties(currentProjectView());
}
/** /**
Edite les proprietes du projet project_view. Edite les proprietes du projet project_view.
@param project_view Vue sur le projet dont il faut editer les proprietes @param project_view Vue sur le projet dont il faut editer les proprietes
@@ -1955,24 +1907,6 @@ void QETDiagramEditor::editProjectProperties(QETProject *project) {
editProjectProperties(findProject(project)); editProjectProperties(findProject(project));
} }
/**
Ajoute un nouveau schema au projet courant
*/
void QETDiagramEditor::addDiagramToProject() {
if (ProjectView *current_project = currentProjectView()) {
current_project -> addNewDiagram();
}
}
/**
* @brief QETDiagramEditor::addDiagramFolioListToProject
* Add new folio list to project
*/
void QETDiagramEditor::addDiagramFolioListToProject() {
if (ProjectView *current_project = currentProjectView())
current_project -> addNewDiagramFolioList();
}
/** /**
Ajoute un nouveau schema a un projet Ajoute un nouveau schema a un projet
@param project Projet auquel il faut ajouter un schema @param project Projet auquel il faut ajouter un schema
@@ -2108,30 +2042,10 @@ void QETDiagramEditor::moveDiagramDownx10(Diagram *diagram) {
} }
} }
/**
Nettoie le projet courant
*/
void QETDiagramEditor::cleanCurrentProject() {
if (ProjectView *current_project = currentProjectView()) {
int clean_count = current_project -> cleanProject();
if (clean_count) pa -> reloadAndFilter();
}
}
void QETDiagramEditor::reloadOldElementPanel() { void QETDiagramEditor::reloadOldElementPanel() {
pa->reloadAndFilter(); pa->reloadAndFilter();
} }
/**
* @brief export nomemclature of schema
*/
void QETDiagramEditor::nomenclatureProject() {
//TODO: Test nomenclature CYRIL F.
nomenclature nomencl(currentProjectView()->project() ,this);
nomencl.saveToCSVFile();
}
/** /**
Supprime le schema courant du projet courant Supprime le schema courant du projet courant
*/ */
@@ -2251,9 +2165,10 @@ void QETDiagramEditor::selectionChanged()
/** /**
* @brief QETDiagramEditor::slot_generateTerminalBlock * @brief QETDiagramEditor::generateTerminalBlock
*/ */
void QETDiagramEditor::slot_generateTerminalBlock() { void QETDiagramEditor::generateTerminalBlock()
{
bool success; bool success;
QProcess *process = new QProcess(qApp); QProcess *process = new QProcess(qApp);

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,10 +45,10 @@ 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;
@@ -49,17 +56,6 @@ class QETDiagramEditor : public QETMainWindow {
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;
@@ -75,6 +71,15 @@ class QETDiagramEditor : public QETMainWindow {
bool event(QEvent *) override; bool event(QEvent *) override;
private: private:
void setUpElementsPanel ();
void setUpElementsCollectionWidget();
void setUpUndoStack ();
void setUpSelectionPropertiesEditor();
void setUpAutonumberingWidget();
void setUpActions ();
void setUpToolBar ();
void setUpMenu ();
bool addProject(QETProject *, bool = true); bool addProject(QETProject *, bool = true);
ProjectView *currentProjectView() const; ProjectView *currentProjectView() const;
DiagramView *currentDiagramView() const; DiagramView *currentDiagramView() const;
@@ -87,8 +92,6 @@ class QETDiagramEditor : public QETMainWindow {
QMdiSubWindow *subWindowForWidget(QWidget *) 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;