2007-12-01 10:47:15 +00:00
/*
2017-01-20 10:55:49 +00:00
Copyright 2006 - 2017 The QElectroTech Team
2007-12-01 10:47:15 +00:00
This file is part of QElectroTech .
QElectroTech is free software : you can redistribute it and / or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation , either version 2 of the License , or
( at your option ) any later version .
QElectroTech is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
GNU General Public License for more details .
You should have received a copy of the GNU General Public License
along with QElectroTech . If not , see < http : //www.gnu.org/licenses/>.
*/
2007-09-21 12:35:28 +00:00
# include "qetdiagrameditor.h"
2007-09-21 13:22:18 +00:00
# include "qetapp.h"
2013-02-12 18:37:08 +00:00
# include "diagramcontent.h"
2007-01-29 00:41:12 +00:00
# include "diagramview.h"
2007-09-25 23:24:36 +00:00
# include "diagram.h"
2013-11-14 10:11:22 +00:00
# include "qetgraphicsitem/element.h"
2007-02-26 22:42:46 +00:00
# include "elementspanelwidget.h"
2007-10-14 10:09:46 +00:00
# include "conductorpropertieswidget.h"
2013-11-14 10:11:22 +00:00
# include "qetgraphicsitem/customelement.h"
2009-04-03 19:30:25 +00:00
# include "qetproject.h"
# include "projectview.h"
2008-07-30 11:51:27 +00:00
# include "recentfiles.h"
2009-05-01 14:41:33 +00:00
# include "qeticons.h"
2009-07-08 09:41:20 +00:00
# include "qetelementeditor.h"
2009-08-09 16:02:14 +00:00
# include "qetmessagebox.h"
2012-07-13 07:21:19 +00:00
# include "qetresult.h"
2012-02-06 21:21:43 +00:00
# include "genericpanel.h"
2013-04-11 09:35:10 +00:00
# include "nomenclature.h"
2014-02-08 18:17:10 +00:00
# include "diagramfoliolist.h"
2014-09-24 09:38:16 +00:00
# include "qetshapeitem.h"
2014-10-26 11:57:38 +00:00
# include "reportproperties.h"
2015-05-07 22:15:00 +00:00
# include "diagrampropertieseditordockwidget.h"
2015-11-07 12:28:43 +00:00
# include "diagrameventaddshape.h"
2015-11-12 17:01:08 +00:00
# include "diagrameventaddimage.h"
2015-11-12 17:29:48 +00:00
# include "diagrameventaddtext.h"
2015-12-08 16:52:10 +00:00
# include "elementscollectionwidget.h"
2016-07-13 14:57:27 +00:00
# include "autonumberingdockwidget.h"
2013-04-11 09:35:10 +00:00
2013-01-03 17:26:08 +00:00
# include <QMessageBox>
2015-03-02 20:14:56 +00:00
# include <QStandardPaths>
2013-01-03 17:26:08 +00:00
2015-12-08 16:52:10 +00:00
# include "elementscollectionmodel.h"
2014-12-26 19:41:00 +00:00
2006-10-27 15:47:22 +00:00
/**
2014-12-26 19:41:00 +00:00
* @ brief QETDiagramEditor : : QETDiagramEditor
* Constructor
* @ param files , list of files to open
* @ param parent , parent widget
2006-10-27 15:47:22 +00:00
*/
2009-04-03 19:30:25 +00:00
QETDiagramEditor : : QETDiagramEditor ( const QStringList & files , QWidget * parent ) :
2012-02-13 22:12:37 +00:00
QETMainWindow ( parent ) ,
2014-10-19 11:25:03 +00:00
m_add_item_actions_group ( this ) ,
m_zoom_actions_group ( this ) ,
m_select_actions_group ( this ) ,
m_row_column_actions_group ( this ) ,
2016-08-19 11:13:55 +00:00
m_selection_actions_group ( this ) ,
2014-10-19 11:25:03 +00:00
m_file_actions_group ( this ) ,
2015-03-02 20:14:56 +00:00
open_dialog_dir ( QStandardPaths : : writableLocation ( QStandardPaths : : DesktopLocation ) )
2009-04-03 19:30:25 +00:00
{
2016-07-13 14:57:27 +00:00
activeSubWindowIndex = 0 ;
//Setup the mdi area at center of application
2006-10-27 15:47:22 +00:00
setCentralWidget ( & workspace ) ;
2009-05-24 17:46:44 +00:00
2014-12-26 19:41:00 +00:00
//Set object name to be retrieved by the stylesheets
2009-04-03 19:30:25 +00:00
workspace . setBackground ( QBrush ( Qt : : NoBrush ) ) ;
workspace . setObjectName ( " mdiarea " ) ;
2012-07-08 13:32:38 +00:00
workspace . setTabsClosable ( true ) ;
2014-12-26 19:41:00 +00:00
//Set the signal mapper
2009-04-03 19:30:25 +00:00
connect ( & windowMapper , SIGNAL ( mapped ( QWidget * ) ) , this , SLOT ( activateWidget ( QWidget * ) ) ) ;
2006-10-27 15:47:22 +00:00
2014-12-26 19:41:00 +00:00
setWindowTitle ( tr ( " QElectroTech " , " window title " ) ) ;
2009-05-01 14:41:33 +00:00
setWindowIcon ( QET : : Icons : : QETLogo ) ;
2009-04-03 19:30:25 +00:00
statusBar ( ) - > showMessage ( tr ( " QElectroTech " , " status bar message " ) ) ;
2006-10-27 15:47:22 +00:00
2014-10-26 11:57:38 +00:00
setUpElementsPanel ( ) ;
2015-12-08 16:52:10 +00:00
setUpElementsCollectionWidget ( ) ;
2014-10-26 11:57:38 +00:00
setUpUndoStack ( ) ;
2015-05-07 22:15:00 +00:00
setUpSelectionPropertiesEditor ( ) ;
2016-07-13 14:57:27 +00:00
setUpAutonumberingWidget ( ) ;
2015-12-08 16:52:10 +00:00
2014-10-26 11:57:38 +00:00
setUpActions ( ) ;
setUpToolBar ( ) ;
setUpMenu ( ) ;
2014-11-28 18:14:33 +00:00
tabifyDockWidget ( qdw_undo , qdw_pa ) ;
2006-10-27 15:47:22 +00:00
2014-12-26 19:41:00 +00:00
//By default the windows is maximised
2007-11-12 15:21:14 +00:00
setMinimumSize ( QSize ( 500 , 350 ) ) ;
2006-10-27 15:47:22 +00:00
setWindowState ( Qt : : WindowMaximized ) ;
2014-12-26 19:41:00 +00:00
connect ( & workspace , SIGNAL ( subWindowActivated ( QMdiSubWindow * ) ) , this , SLOT ( subWindowActivated ( QMdiSubWindow * ) ) ) ;
2014-12-10 17:00:08 +00:00
connect ( QApplication : : clipboard ( ) , SIGNAL ( dataChanged ( ) ) , this , SLOT ( slot_updatePasteAction ( ) ) ) ;
2017-01-11 00:04:43 +00:00
//connect (&undo_group, SIGNAL(cleanChanged(bool)), this, SLOT(activeUndoStackCleanChanged(bool)));
2016-06-07 12:55:05 +00:00
2007-11-12 15:21:14 +00:00
readSettings ( ) ;
2007-09-22 13:27:14 +00:00
show ( ) ;
2008-08-23 12:54:16 +00:00
2014-12-26 19:41:00 +00:00
//If valid file path is given as arguments
2009-04-03 19:30:25 +00:00
uint opened_projects = 0 ;
2014-12-26 19:41:00 +00:00
if ( files . count ( ) )
{
//So we open this files
2017-02-05 16:18:50 +00:00
foreach ( QString file , files )
2014-12-26 19:41:00 +00:00
if ( openAndAddProject ( file , false ) )
2009-04-03 19:30:25 +00:00
+ + opened_projects ;
2008-08-23 12:54:16 +00:00
}
2014-10-26 11:57:38 +00:00
slot_updateActions ( ) ;
2006-10-27 15:47:22 +00:00
}
2007-04-12 03:13:13 +00:00
/**
Destructeur
*/
2007-09-21 12:35:28 +00:00
QETDiagramEditor : : ~ QETDiagramEditor ( ) {
2007-04-12 03:13:13 +00:00
}
2006-10-27 15:47:22 +00:00
/**
2014-10-26 11:57:38 +00:00
* @ brief QETDiagramEditor : : setUpElementsPanel
* Setup the element panel and element panel widget
*/
void QETDiagramEditor : : setUpElementsPanel ( ) {
//Add the element panel as a QDockWidget
2016-08-21 20:50:52 +00:00
qdw_pa = new QDockWidget ( tr ( " Projets " , " dock title " ) , this ) ;
2014-10-26 11:57:38 +00:00
2016-08-21 20:32:05 +00:00
qdw_pa - > setObjectName ( " projects panel " ) ;
2014-10-26 11:57:38 +00:00
qdw_pa - > setAllowedAreas ( Qt : : LeftDockWidgetArea | Qt : : RightDockWidgetArea ) ;
qdw_pa - > setFeatures ( QDockWidget : : AllDockWidgetFeatures ) ;
qdw_pa - > setMinimumWidth ( 160 ) ;
qdw_pa - > setWidget ( pa = new ElementsPanelWidget ( qdw_pa ) ) ;
2014-11-28 18:14:33 +00:00
addDockWidget ( Qt : : LeftDockWidgetArea , qdw_pa ) ;
2014-10-26 11:57:38 +00:00
connect ( pa , SIGNAL ( requestForProject ( QETProject * ) ) , this , SLOT ( activateProject ( QETProject * ) ) ) ;
connect ( pa , SIGNAL ( requestForProjectClosing ( QETProject * ) ) , this , SLOT ( closeProject ( QETProject * ) ) ) ;
connect ( pa , SIGNAL ( requestForProjectPropertiesEdition ( QETProject * ) ) , this , SLOT ( editProjectProperties ( QETProject * ) ) ) ;
connect ( pa , SIGNAL ( requestForNewDiagram ( QETProject * ) ) , this , SLOT ( addDiagramToProject ( QETProject * ) ) ) ;
connect ( pa , SIGNAL ( requestForDiagram ( Diagram * ) ) , this , SLOT ( activateDiagram ( Diagram * ) ) ) ;
connect ( pa , SIGNAL ( requestForDiagramPropertiesEdition ( Diagram * ) ) , this , SLOT ( editDiagramProperties ( Diagram * ) ) ) ;
connect ( pa , SIGNAL ( requestForDiagramDeletion ( Diagram * ) ) , this , SLOT ( removeDiagram ( Diagram * ) ) ) ;
connect ( pa , SIGNAL ( requestForDiagramMoveUp ( Diagram * ) ) , this , SLOT ( moveDiagramUp ( Diagram * ) ) ) ;
connect ( pa , SIGNAL ( requestForDiagramMoveDown ( Diagram * ) ) , this , SLOT ( moveDiagramDown ( Diagram * ) ) ) ;
2015-03-04 06:00:25 +00:00
connect ( pa , SIGNAL ( requestForDiagramMoveUpTop ( Diagram * ) ) , this , SLOT ( moveDiagramUpTop ( Diagram * ) ) ) ;
2014-12-14 17:01:11 +00:00
connect ( pa , SIGNAL ( requestForDiagramMoveUpx10 ( Diagram * ) ) , this , SLOT ( moveDiagramUpx10 ( Diagram * ) ) ) ;
connect ( pa , SIGNAL ( requestForDiagramMoveDownx10 ( Diagram * ) ) , this , SLOT ( moveDiagramDownx10 ( Diagram * ) ) ) ;
2006-10-27 15:47:22 +00:00
}
2015-12-08 16:52:10 +00:00
/**
* @ brief QETDiagramEditor : : setUpElementsCollectionWidget
* Set up the dock widget of element collection
*/
void QETDiagramEditor : : setUpElementsCollectionWidget ( )
{
2016-08-21 20:50:52 +00:00
m_qdw_elmt_collection = new QDockWidget ( tr ( " Collections " ) , this ) ;
2015-12-08 16:52:10 +00:00
m_qdw_elmt_collection - > setObjectName ( " elements_collection_widget " ) ;
m_qdw_elmt_collection - > setAllowedAreas ( Qt : : LeftDockWidgetArea | Qt : : RightDockWidgetArea ) ;
m_qdw_elmt_collection - > setFeatures ( QDockWidget : : AllDockWidgetFeatures ) ;
m_element_collection_widget = new ElementsCollectionWidget ( m_qdw_elmt_collection ) ;
m_qdw_elmt_collection - > setWidget ( m_element_collection_widget ) ;
m_element_collection_widget - > expandFirstItems ( ) ;
addDockWidget ( Qt : : RightDockWidgetArea , m_qdw_elmt_collection ) ;
}
2006-10-27 15:47:22 +00:00
/**
2014-10-26 11:57:38 +00:00
* @ brief QETDiagramEditor : : setUpUndoStack
* Setup the undostack and undo stack widget
*/
void QETDiagramEditor : : setUpUndoStack ( ) {
QUndoView * undo_view = new QUndoView ( & undo_group , this ) ;
undo_view - > setEmptyLabel ( tr ( " Aucune modification " ) ) ;
2015-03-02 20:14:56 +00:00
undo_view - > setStatusTip ( tr ( " Cliquez sur une action pour revenir en arrière dans l'édition de votre schéma " , " Status tip " ) ) ;
2015-06-21 15:29:09 +00:00
undo_view - > setWhatsThis ( tr ( " Ce panneau liste les différentes actions effectuées sur le folio courant. Cliquer sur une action permet de revenir à l'état du schéma juste après son application. " , " \" What's this \" tip " ) ) ;
2014-10-26 11:57:38 +00:00
qdw_undo = new QDockWidget ( tr ( " Annulations " , " dock title " ) , this ) ;
qdw_undo - > setObjectName ( " diagram_undo " ) ;
qdw_undo - > setAllowedAreas ( Qt : : LeftDockWidgetArea | Qt : : RightDockWidgetArea ) ;
qdw_undo - > setFeatures ( QDockWidget : : AllDockWidgetFeatures ) ;
qdw_undo - > setMinimumWidth ( 160 ) ;
qdw_undo - > setWidget ( undo_view ) ;
2014-11-28 18:14:33 +00:00
addDockWidget ( Qt : : LeftDockWidgetArea , qdw_undo ) ;
2014-10-26 11:57:38 +00:00
}
2015-05-07 22:15:00 +00:00
/**
* @ brief QETDiagramEditor : : setUpSelectionPropertiesEditor
* Setup the dock for edit the current selection
*/
void QETDiagramEditor : : setUpSelectionPropertiesEditor ( )
{
m_selection_properties_editor = new DiagramPropertiesEditorDockWidget ( this ) ;
m_selection_properties_editor - > setObjectName ( " diagram_properties_editor_dock_widget " ) ;
addDockWidget ( Qt : : RightDockWidgetArea , m_selection_properties_editor ) ;
}
2016-07-13 14:57:27 +00:00
/**
* @ brief QETDiagramEditor : : setUpAutonumberingWidget
* Setup the dock for AutoNumbering Selection
*/
void QETDiagramEditor : : setUpAutonumberingWidget ( )
{
m_autonumbering_dock = new AutoNumberingDockWidget ( this ) ;
m_autonumbering_dock - > setAllowedAreas ( Qt : : LeftDockWidgetArea | Qt : : RightDockWidgetArea ) ;
m_autonumbering_dock - > setFeatures ( QDockWidget : : AllDockWidgetFeatures ) ;
addDockWidget ( Qt : : RightDockWidgetArea , m_autonumbering_dock ) ;
}
2014-10-26 11:57:38 +00:00
/**
* @ brief QETDiagramEditor : : setUpActions
* Set up all Qaction
*/
2015-06-25 18:23:47 +00:00
void QETDiagramEditor : : setUpActions ( )
{
2013-10-26 11:51:46 +00:00
export_diagram = new QAction ( QET : : Icons : : DocumentExport , tr ( " E&xporter " ) , this ) ;
print = new QAction ( QET : : Icons : : DocumentPrint , tr ( " Imprimer " ) , this ) ;
quit_editor = new QAction ( QET : : Icons : : ApplicationExit , tr ( " &Quitter " ) , this ) ;
2014-10-26 11:57:38 +00:00
2015-09-19 13:27:06 +00:00
//Undo redo
2007-09-29 12:54:01 +00:00
undo = undo_group . createUndoAction ( this , tr ( " Annuler " ) ) ;
redo = undo_group . createRedoAction ( this , tr ( " Refaire " ) ) ;
2015-09-19 13:27:06 +00:00
undo - > setIcon ( QET : : Icons : : EditUndo ) ;
2013-10-26 11:51:46 +00:00
redo - > setIcon ( QET : : Icons : : EditRedo ) ;
2015-09-19 13:27:06 +00:00
undo - > setShortcut ( QKeySequence : : Undo ) ;
redo - > setShortcut ( QKeySequence : : Redo ) ;
undo - > setStatusTip ( tr ( " Annule l'action précédente " , " status bar tip " ) ) ;
redo - > setStatusTip ( tr ( " Restaure l'action annulée " , " status bar tip " ) ) ;
//cut copy past action
cut = new QAction ( QET : : Icons : : EditCut , tr ( " Co&uper " ) , this ) ;
copy = new QAction ( QET : : Icons : : EditCopy , tr ( " Cop&ier " ) , this ) ;
paste = new QAction ( QET : : Icons : : EditPaste , tr ( " C&oller " ) , this ) ;
cut - > setShortcut ( QKeySequence : : Cut ) ;
copy - > setShortcut ( QKeySequence : : Copy ) ;
paste - > setShortcut ( QKeySequence : : Paste ) ;
cut - > setStatusTip ( tr ( " Transfère les éléments sélectionnés dans le presse-papier " , " status bar tip " ) ) ;
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 " ) ) ;
connect ( cut , SIGNAL ( triggered ( ) ) , this , SLOT ( slot_cut ( ) ) ) ;
connect ( copy , SIGNAL ( triggered ( ) ) , this , SLOT ( slot_copy ( ) ) ) ;
connect ( paste , SIGNAL ( triggered ( ) ) , this , SLOT ( slot_paste ( ) ) ) ;
2015-03-10 14:47:03 +00:00
conductor_reset = new QAction ( QET : : Icons : : ConductorSettings , tr ( " Réinitialiser les conducteurs " ) , this ) ;
2015-09-19 13:27:06 +00:00
conductor_reset - > setShortcut ( QKeySequence ( tr ( " Ctrl+K " ) ) ) ;
2015-01-11 11:10:57 +00:00
2015-03-02 20:14:56 +00:00
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 " ) ) ;
2015-01-11 11:10:57 +00:00
m_auto_conductor - > setCheckable ( true ) ;
connect ( m_auto_conductor , SIGNAL ( triggered ( bool ) ) , this , SLOT ( slot_autoConductor ( bool ) ) ) ;
2015-06-21 15:29:09 +00:00
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 - > setCheckable ( true ) ;
2015-06-25 18:23:47 +00:00
connect ( m_grey_background , & QAction : : triggered , [ this ] ( bool checked ) {
Diagram : : background_color = checked ? Qt : : darkGray : Qt : : white ;
if ( this - > currentDiagram ( ) & & this - > currentDiagram ( ) - > diagram ( ) )
this - > currentDiagram ( ) - > diagram ( ) - > update ( ) ;
} ) ;
2015-06-21 11:00:08 +00:00
2016-08-19 11:33:23 +00:00
m_draw_grid = new QAction ( QET : : Icons : : Grid , tr ( " Afficher la grille " ) , this ) ;
2016-08-18 16:30:24 +00:00
m_draw_grid - > setStatusTip ( tr ( " Affiche ou masque la grille des folios " ) ) ;
m_draw_grid - > setCheckable ( true ) ;
m_draw_grid - > setChecked ( true ) ;
connect ( m_draw_grid , & QAction : : triggered , [ this ] ( bool checked ) {
2017-02-05 16:18:50 +00:00
foreach ( ProjectView * prjv , this - > openedProjects ( ) )
foreach ( Diagram * d , prjv - > project ( ) - > diagrams ( ) ) {
2016-08-18 16:30:24 +00:00
d - > setDisplayGrid ( checked ) ;
d - > update ( ) ;
}
} ) ;
2016-08-30 21:42:35 +00:00
infos_diagram = new QAction ( QET : : Icons : : DialogInformation , tr ( " Propriétés du folio " ) , this ) ;
2015-09-19 13:27:06 +00:00
infos_diagram - > setShortcut ( QKeySequence ( tr ( " Ctrl+L " ) ) ) ;
2015-03-10 14:47:03 +00:00
prj_edit_prop = new QAction ( QET : : Icons : : DialogInformation , tr ( " Propriétés du projet " ) , this ) ;
2016-08-30 21:42:35 +00:00
prj_add_diagram = new QAction ( QET : : Icons : : DiagramAdd , tr ( " Ajouter un folio " ) , this ) ;
prj_del_diagram = new QAction ( QET : : Icons : : DiagramDelete , tr ( " Supprimer le folio " ) , this ) ;
2013-10-26 11:51:46 +00:00
prj_clean = new QAction ( QET : : Icons : : EditClear , tr ( " Nettoyer le projet " ) , this ) ;
2014-02-06 23:55:02 +00:00
prj_diagramList = new QAction ( QET : : Icons : : listDrawings , tr ( " Ajouter un sommaire " ) , this ) ;
2015-03-10 14:47:03 +00:00
prj_nomenclature = new QAction ( QET : : Icons : : DocumentSpreadsheet , tr ( " Exporter une nomenclature " ) , this ) ;
2016-08-30 21:42:35 +00:00
prj_terminalBloc = new QAction ( QET : : Icons : : TerminalStrip , tr ( " Lancer le plugin de creation de bornier " ) , this ) ;
2009-05-01 14:41:33 +00:00
tabbed_view_mode = new QAction ( tr ( " en utilisant des onglets " ) , this ) ;
2015-03-10 14:47:03 +00:00
windowed_view_mode = new QAction ( tr ( " en utilisant des fenêtres " ) , this ) ;
2009-05-01 14:41:33 +00:00
mode_selection = new QAction ( QET : : Icons : : PartSelect , tr ( " Mode Selection " ) , this ) ;
mode_visualise = new QAction ( QET : : Icons : : ViewMove , tr ( " Mode Visualisation " ) , this ) ;
2015-03-10 14:47:03 +00:00
tile_window = new QAction ( tr ( " &Mosaïque " ) , this ) ;
cascade_window = new QAction ( tr ( " &Cascade " ) , this ) ;
next_window = new QAction ( tr ( " Projet suivant " ) , this ) ;
prev_window = new QAction ( tr ( " Projet précédent " ) , this ) ;
2014-10-26 11:57:38 +00:00
2015-09-19 13:27:06 +00:00
//Files action
2015-03-12 14:44:04 +00:00
QAction * new_file = m_file_actions_group . addAction ( QET : : Icons : : ProjectNew , tr ( " &Nouveau " ) ) ;
2014-06-07 21:03:49 +00:00
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 " ) ) ;
save_file_as = m_file_actions_group . addAction ( QET : : Icons : : DocumentSaveAs , tr ( " Enregistrer sous " ) ) ;
2015-03-12 14:44:04 +00:00
close_file = m_file_actions_group . addAction ( QET : : Icons : : ProjectClose , tr ( " &Fermer " ) ) ;
2014-06-07 21:03:49 +00:00
new_file - > setShortcut ( QKeySequence : : New ) ;
open_file - > setShortcut ( QKeySequence : : Open ) ;
close_file - > setShortcut ( QKeySequence : : Close ) ;
save_file - > setShortcut ( QKeySequence : : Save ) ;
2015-06-21 15:29:09 +00:00
new_file - > setStatusTip ( tr ( " Crée un nouveau projet " , " status bar tip " ) ) ;
open_file - > setStatusTip ( tr ( " Ouvre un projet existant " , " status bar tip " ) ) ;
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 " ) ) ;
save_file_as - > setStatusTip ( tr ( " Enregistre le projet courant avec un autre nom de fichier " , " status bar tip " ) ) ;
2014-06-07 21:03:49 +00:00
connect ( save_file_as , SIGNAL ( triggered ( ) ) , this , SLOT ( saveAs ( ) ) ) ;
connect ( save_file , SIGNAL ( triggered ( ) ) , this , SLOT ( save ( ) ) ) ;
connect ( new_file , SIGNAL ( triggered ( ) ) , this , SLOT ( newProject ( ) ) ) ;
connect ( open_file , SIGNAL ( triggered ( ) ) , this , SLOT ( openProject ( ) ) ) ;
connect ( close_file , SIGNAL ( triggered ( ) ) , this , SLOT ( closeCurrentProject ( ) ) ) ;
2015-09-19 13:27:06 +00:00
//Row and Column actions
2014-06-07 21:03:49 +00:00
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 " ) ) ;
2016-08-23 00:10:33 +00:00
QAction * add_row = m_row_column_actions_group . addAction ( QET : : Icons : : EditTableInsertRowUnder , tr ( " Ajouter une ligne " , " Add row " ) ) ;
QAction * remove_row = m_row_column_actions_group . addAction ( QET : : Icons : : EditTableDeleteRow , tr ( " Enlever une ligne " , " Remove row " ) ) ;
2014-06-07 21:03:49 +00:00
2015-09-19 13:27:06 +00:00
add_column - > setStatusTip ( tr ( " Ajoute une colonne au folio " , " status bar tip " ) ) ;
remove_column - > setStatusTip ( tr ( " Enlève une colonne au folio " , " status bar tip " ) ) ;
add_row - > setStatusTip ( tr ( " Agrandit le folio en hauteur " , " status bar tip " ) ) ;
remove_row - > setStatusTip ( tr ( " Rétrécit le folio en hauteur " , " status bar tip " ) ) ;
add_column - > setData ( " add_column " ) ;
remove_column - > setData ( " remove_column " ) ;
add_row - > setData ( " add_row " ) ;
remove_row - > setData ( " remove_row " ) ;
2014-06-07 21:03:49 +00:00
2015-09-19 13:27:06 +00:00
connect ( & m_row_column_actions_group , & QActionGroup : : triggered , this , & QETDiagramEditor : : rowColumnGroupTriggered ) ;
2014-06-07 21:03:49 +00:00
2015-09-19 13:27:06 +00:00
//Selections Actions (related to a selected item)
2014-06-07 21:03:49 +00:00
delete_selection = m_selection_actions_group . addAction ( QET : : Icons : : EditDelete , tr ( " Supprimer " ) ) ;
rotate_selection = m_selection_actions_group . addAction ( QET : : Icons : : ObjectRotateRight , tr ( " Pivoter " ) ) ;
rotate_texts = m_selection_actions_group . addAction ( QET : : Icons : : ObjectRotateRight , tr ( " Orienter les textes " ) ) ;
find_element = m_selection_actions_group . addAction ( tr ( " Retrouver dans le panel " ) ) ;
2015-03-02 20:14:56 +00:00
edit_selection = m_selection_actions_group . addAction ( QET : : Icons : : ElementEdit , tr ( " Éditer l'item sélectionné " ) ) ;
2014-06-07 21:03:49 +00:00
2015-09-19 13:27:06 +00:00
delete_selection - > setShortcut ( QKeySequence : : Delete ) ;
2014-06-07 21:03:49 +00:00
rotate_selection - > setShortcut ( QKeySequence ( tr ( " Space " ) ) ) ;
rotate_texts - > setShortcut ( QKeySequence ( tr ( " Ctrl+Space " ) ) ) ;
edit_selection - > setShortcut ( QKeySequence ( tr ( " Ctrl+E " ) ) ) ;
2015-09-19 13:27:06 +00:00
delete_selection - > setStatusTip ( tr ( " Enlève les éléments sélectionnés du folio " , " status bar tip " ) ) ;
rotate_selection - > setStatusTip ( tr ( " Pivote les éléments et textes sélectionnés " , " status bar tip " ) ) ;
rotate_texts - > setStatusTip ( tr ( " Pivote les textes sélectionnés à un angle précis " , " status bar tip " ) ) ;
find_element - > setStatusTip ( tr ( " Retrouve l'élément sélectionné dans le panel " , " status bar tip " ) ) ;
delete_selection - > setData ( " delete_selection " ) ;
rotate_selection - > setData ( " rotate_selection " ) ;
rotate_texts - > setData ( " rotate_selected_text " ) ;
find_element - > setData ( " find_selected_element " ) ;
edit_selection - > setData ( " edit_selected_element " ) ;
2014-06-07 21:03:49 +00:00
2015-09-19 13:27:06 +00:00
connect ( & m_selection_actions_group , & QActionGroup : : triggered , this , & QETDiagramEditor : : selectionGroupTriggered ) ;
2014-06-07 21:03:49 +00:00
2015-09-19 13:27:06 +00:00
//Select Action
2015-03-02 20:14:56 +00:00
QAction * select_all = m_select_actions_group . addAction ( QET : : Icons : : EditSelectAll , tr ( " Tout sélectionner " ) ) ;
QAction * select_nothing = m_select_actions_group . addAction ( tr ( " Désélectionner tout " ) ) ;
QAction * select_invert = m_select_actions_group . addAction ( tr ( " Inverser la sélection " ) ) ;
2014-06-07 21:03:49 +00:00
2015-09-19 13:27:06 +00:00
select_all - > setShortcut ( QKeySequence : : SelectAll ) ;
select_nothing - > setShortcut ( QKeySequence : : Deselect ) ;
select_invert - > setShortcut ( QKeySequence ( tr ( " Ctrl+I " ) ) ) ;
2014-06-07 21:03:49 +00:00
2015-06-21 15:29:09 +00:00
select_all - > setStatusTip ( tr ( " Sélectionne tous les éléments du folio " , " status bar tip " ) ) ;
select_nothing - > setStatusTip ( tr ( " Désélectionne tous les éléments du folio " , " status bar tip " ) ) ;
2015-03-02 20:14:56 +00:00
select_invert - > setStatusTip ( tr ( " Désélectionne les éléments sélectionnés et sélectionne les éléments non sélectionnés " , " status bar tip " ) ) ;
2014-06-07 21:03:49 +00:00
2015-09-19 13:27:06 +00:00
select_all - > setData ( " select_all " ) ;
select_nothing - > setData ( " deselect " ) ;
select_invert - > setData ( " invert_selection " ) ;
2014-06-07 21:03:49 +00:00
2015-09-19 13:27:06 +00:00
connect ( & m_select_actions_group , & QActionGroup : : triggered , this , & QETDiagramEditor : : selectGroupTriggered ) ;
//Zoom actions
QAction * zoom_in = m_zoom_actions_group . addAction ( QET : : Icons : : ZoomIn , tr ( " Zoom avant " ) ) ;
QAction * zoom_out = m_zoom_actions_group . addAction ( QET : : Icons : : ZoomOut , tr ( " Zoom arrière " ) ) ;
QAction * zoom_content = m_zoom_actions_group . addAction ( QET : : Icons : : ZoomDraw , tr ( " Zoom sur le contenu " ) ) ;
QAction * zoom_fit = m_zoom_actions_group . addAction ( QET : : Icons : : ZoomFitBest , tr ( " Zoom adapté " ) ) ;
QAction * zoom_reset = m_zoom_actions_group . addAction ( QET : : Icons : : ZoomOriginal , tr ( " Pas de zoom " ) ) ;
2014-06-07 21:03:49 +00:00
m_zoom_action_toolBar < < zoom_content < < zoom_fit < < zoom_reset ;
zoom_in - > setShortcut ( QKeySequence : : ZoomIn ) ;
zoom_out - > setShortcut ( QKeySequence : : ZoomOut ) ;
zoom_content - > setShortcut ( QKeySequence ( tr ( " Ctrl+8 " ) ) ) ;
zoom_fit - > setShortcut ( QKeySequence ( tr ( " Ctrl+9 " ) ) ) ;
zoom_reset - > setShortcut ( QKeySequence ( tr ( " Ctrl+0 " ) ) ) ;
2015-06-21 15:29:09 +00:00
zoom_in - > setStatusTip ( tr ( " Agrandit le folio " , " status bar tip " ) ) ;
zoom_out - > setStatusTip ( tr ( " Rétrécit le folio " , " status bar tip " ) ) ;
zoom_content - > setStatusTip ( tr ( " Adapte le zoom de façon à afficher tout le contenu du folio indépendamment du cadre " ) ) ;
zoom_fit - > setStatusTip ( tr ( " Adapte le zoom exactement sur le cadre du folio " , " status bar tip " ) ) ;
2015-03-02 20:14:56 +00:00
zoom_reset - > setStatusTip ( tr ( " Restaure le zoom par défaut " , " status bar tip " ) ) ;
2014-06-07 21:03:49 +00:00
2015-09-19 13:27:06 +00:00
zoom_in - > setData ( " zoom_in " ) ;
zoom_out - > setData ( " zoom_out " ) ;
zoom_content - > setData ( " zoom_content " ) ;
zoom_fit - > setData ( " zoom_fit " ) ;
zoom_reset - > setData ( " zoom_reset " ) ;
connect ( & m_zoom_actions_group , & QActionGroup : : triggered , this , & QETDiagramEditor : : zoomGroupTriggered ) ;
//Adding action (add text, image, shape...)
QAction * add_text = m_add_item_actions_group . addAction ( QET : : Icons : : PartTextField , tr ( " Ajouter un champ de texte " ) ) ;
QAction * add_image = m_add_item_actions_group . addAction ( QET : : Icons : : adding_image , tr ( " Ajouter une image " ) ) ;
2016-08-23 00:10:33 +00:00
QAction * add_line = m_add_item_actions_group . addAction ( QET : : Icons : : PartLine , tr ( " Ajouter une ligne " , " Draw line " ) ) ;
2015-09-19 13:27:06 +00:00
QAction * add_rectangle = m_add_item_actions_group . addAction ( QET : : Icons : : PartRectangle , tr ( " Ajouter un rectangle " ) ) ;
QAction * add_ellipse = m_add_item_actions_group . addAction ( QET : : Icons : : PartEllipse , tr ( " Ajouter une ellipse " ) ) ;
QAction * add_polyline = m_add_item_actions_group . addAction ( QET : : Icons : : PartPolygon , tr ( " Ajouter une polyligne " ) ) ;
add_text - > setData ( " text " ) ;
add_image - > setData ( " image " ) ;
add_line - > setData ( " line " ) ;
add_rectangle - > setData ( " rectangle " ) ;
add_ellipse - > setData ( " ellipse " ) ;
add_polyline - > setData ( " polyline " ) ;
2017-02-05 16:18:50 +00:00
foreach ( QAction * action , m_add_item_actions_group . actions ( ) ) action - > setCheckable ( true ) ;
2015-09-19 13:27:06 +00:00
connect ( & m_add_item_actions_group , & QActionGroup : : triggered , this , & QETDiagramEditor : : addItemGroupTriggered ) ;
//Keyboard shortcut
2007-09-29 12:54:01 +00:00
export_diagram - > setShortcut ( QKeySequence ( tr ( " Ctrl+Shift+X " ) ) ) ;
print - > setShortcut ( QKeySequence ( QKeySequence : : Print ) ) ;
quit_editor - > setShortcut ( QKeySequence ( tr ( " Ctrl+Q " ) ) ) ;
2015-09-19 13:27:06 +00:00
2014-10-26 11:57:38 +00:00
2009-04-03 19:30:25 +00:00
prj_add_diagram - > setShortcut ( QKeySequence ( tr ( " Ctrl+T " ) ) ) ;
2014-10-26 11:57:38 +00:00
2007-09-29 12:54:01 +00:00
next_window - > setShortcut ( QKeySequence : : NextChild ) ;
prev_window - > setShortcut ( QKeySequence : : PreviousChild ) ;
2014-10-26 11:57:38 +00:00
2006-10-28 11:17:14 +00:00
// affichage dans la barre de statut
2015-06-21 15:29:09 +00:00
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 " ) ) ;
2009-04-03 19:30:25 +00:00
quit_editor - > setStatusTip ( tr ( " Ferme l'application QElectroTech " , " status bar tip " ) ) ;
conductor_reset - > setStatusTip ( tr ( " Recalcule les chemins des conducteurs sans tenir compte des modifications " , " status bar tip " ) ) ;
2015-06-21 15:29:09 +00:00
infos_diagram - > setStatusTip ( tr ( " Édite les propriétés du folio (dimensions, informations du cartouche, propriétés des conducteurs...) " , " status bar tip " ) ) ;
2014-10-26 11:57:38 +00:00
2015-03-02 20:14:56 +00:00
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 " ) ) ;
2014-10-26 11:57:38 +00:00
2015-03-02 20:14:56 +00:00
mode_selection - > setStatusTip ( tr ( " Permet de sélectionner les éléments " , " status bar tip " ) ) ;
2015-06-21 15:29:09 +00:00
mode_visualise - > setStatusTip ( tr ( " Permet de visualiser le folio sans pouvoir le modifier " , " status bar tip " ) ) ;
2014-10-26 11:57:38 +00:00
2015-03-02 20:14:56 +00:00
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 " ) ) ;
2009-04-06 03:56:56 +00:00
next_window - > setStatusTip ( tr ( " Active le projet suivant " , " status bar tip " ) ) ;
2015-03-02 20:14:56 +00:00
prev_window - > setStatusTip ( tr ( " Active le projet précédent " , " status bar tip " ) ) ;
2014-10-30 15:03:58 +00:00
//mode_visualise -> setShortcut( QKeySequence( tr("Ctrl+Shift") ) );
2014-10-26 11:57:38 +00:00
2006-10-27 15:47:22 +00:00
// traitements speciaux
2009-04-03 19:30:25 +00:00
windowed_view_mode - > setCheckable ( true ) ;
tabbed_view_mode - > setCheckable ( true ) ;
mode_selection - > setCheckable ( true ) ;
mode_visualise - > setCheckable ( true ) ;
mode_selection - > setChecked ( true ) ;
2014-10-26 11:57:38 +00:00
2007-10-28 00:16:32 +00:00
grp_visu_sel = new QActionGroup ( this ) ;
2006-10-27 15:47:22 +00:00
grp_visu_sel - > addAction ( mode_selection ) ;
grp_visu_sel - > addAction ( mode_visualise ) ;
grp_visu_sel - > setExclusive ( true ) ;
2014-10-26 11:57:38 +00:00
2009-04-03 19:30:25 +00:00
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 ) ;
2014-10-26 11:57:38 +00:00
2006-10-27 15:47:22 +00:00
// connexion a des slots
2009-04-03 19:30:25 +00:00
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 ( ) ) ) ;
2014-02-07 07:54:54 +00:00
connect ( prj_diagramList , SIGNAL ( triggered ( ) ) , this , SLOT ( addDiagramFolioListToProject ( ) ) ) ;
2013-04-11 09:35:10 +00:00
connect ( prj_nomenclature , SIGNAL ( triggered ( ) ) , this , SLOT ( nomenclatureProject ( ) ) ) ;
2016-08-30 21:42:35 +00:00
connect ( prj_terminalBloc , SIGNAL ( triggered ( ) ) , this , SLOT ( slot_generateTerminalBlock ( ) ) ) ;
2009-04-03 19:30:25 +00:00
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 ( conductor_reset , SIGNAL ( triggered ( ) ) , this , SLOT ( slot_resetConductors ( ) ) ) ;
connect ( infos_diagram , SIGNAL ( triggered ( ) ) , this , SLOT ( editCurrentDiagramProperties ( ) ) ) ;
}
/**
2014-10-26 11:57:38 +00:00
* @ brief QETDiagramEditor : : setUpToolBar
*/
void QETDiagramEditor : : setUpToolBar ( ) {
main_bar = new QToolBar ( tr ( " Outils " ) , this ) ;
main_bar - > setObjectName ( " toolbar " ) ;
view_bar = new QToolBar ( tr ( " Affichage " ) , this ) ;
view_bar - > setObjectName ( " display " ) ;
2015-03-02 20:14:56 +00:00
diagram_bar = new QToolBar ( tr ( " Schéma " ) , this ) ;
2014-10-26 11:57:38 +00:00
diagram_bar - > setObjectName ( " diagram " ) ;
main_bar - > addActions ( m_file_actions_group . actions ( ) ) ;
main_bar - > addAction ( print ) ;
main_bar - > addSeparator ( ) ;
main_bar - > addAction ( undo ) ;
main_bar - > addAction ( redo ) ;
main_bar - > addSeparator ( ) ;
main_bar - > addAction ( cut ) ;
main_bar - > addAction ( copy ) ;
main_bar - > addAction ( paste ) ;
main_bar - > addSeparator ( ) ;
main_bar - > addAction ( delete_selection ) ;
main_bar - > addAction ( rotate_selection ) ;
// Modes selection / visualisation et zoom
view_bar - > addAction ( mode_selection ) ;
view_bar - > addAction ( mode_visualise ) ;
view_bar - > addSeparator ( ) ;
2016-08-18 16:30:24 +00:00
view_bar - > addAction ( m_draw_grid ) ;
2015-06-21 15:29:09 +00:00
view_bar - > addAction ( m_grey_background ) ;
view_bar - > addSeparator ( ) ;
2014-10-26 11:57:38 +00:00
view_bar - > addActions ( m_zoom_action_toolBar ) ;
2015-01-11 11:10:57 +00:00
diagram_bar - > addAction ( infos_diagram ) ;
diagram_bar - > addAction ( conductor_reset ) ;
diagram_bar - > addAction ( m_auto_conductor ) ;
2014-10-26 11:57:38 +00:00
m_add_item_toolBar = new QToolBar ( tr ( " Ajouter " ) , this ) ;
m_add_item_toolBar - > setObjectName ( " adding " ) ;
m_add_item_toolBar - > addActions ( m_add_item_actions_group . actions ( ) ) ;
// ajout de la barre d'outils a la fenetre principale
addToolBar ( Qt : : TopToolBarArea , main_bar ) ;
addToolBar ( Qt : : TopToolBarArea , view_bar ) ;
addToolBar ( Qt : : TopToolBarArea , diagram_bar ) ;
addToolBar ( Qt : : TopToolBarArea , m_add_item_toolBar ) ;
2006-10-27 15:47:22 +00:00
}
/**
2014-10-26 11:57:38 +00:00
* @ brief QETDiagramEditor : : setUpMenu
*/
void QETDiagramEditor : : setUpMenu ( ) {
2012-02-13 22:12:37 +00:00
QMenu * menu_fichier = new QMenu ( tr ( " &Fichier " ) ) ;
2015-03-02 20:14:56 +00:00
QMenu * menu_edition = new QMenu ( tr ( " &Édition " ) ) ;
2012-02-13 22:12:37 +00:00
QMenu * menu_project = new QMenu ( tr ( " &Projet " ) ) ;
QMenu * menu_affichage = new QMenu ( tr ( " Afficha&ge " ) ) ;
//QMenu *menu_outils = new QMenu(tr("O&utils"));
2015-03-02 20:14:56 +00:00
windows_menu = new QMenu ( tr ( " Fe&nêtres " ) ) ;
2014-10-26 11:57:38 +00:00
2012-02-13 22:12:37 +00:00
insertMenu ( settings_menu_ , menu_fichier ) ;
insertMenu ( settings_menu_ , menu_edition ) ;
insertMenu ( settings_menu_ , menu_project ) ;
insertMenu ( settings_menu_ , menu_affichage ) ;
insertMenu ( help_menu_ , windows_menu ) ;
2014-10-26 11:57:38 +00:00
2014-06-07 21:03:49 +00:00
// File menu
2015-03-02 20:14:56 +00:00
QMenu * recentfile = menu_fichier - > addMenu ( QET : : Icons : : DocumentOpenRecent , tr ( " &Récemment ouverts " ) ) ;
2014-05-05 17:32:10 +00:00
recentfile - > addActions ( QETApp : : projectsRecentFiles ( ) - > menu ( ) - > actions ( ) ) ;
2008-07-30 11:51:27 +00:00
connect ( QETApp : : projectsRecentFiles ( ) , SIGNAL ( fileOpeningRequested ( const QString & ) ) , this , SLOT ( openRecentFile ( const QString & ) ) ) ;
2014-06-07 21:03:49 +00:00
menu_fichier - > addActions ( m_file_actions_group . actions ( ) ) ;
2006-10-27 15:47:22 +00:00
menu_fichier - > addSeparator ( ) ;
2007-09-29 12:54:01 +00:00
//menu_fichier -> addAction(import_diagram);
menu_fichier - > addAction ( export_diagram ) ;
2007-09-22 13:27:14 +00:00
//menu_fichier -> addSeparator();
2007-09-29 12:54:01 +00:00
menu_fichier - > addAction ( print ) ;
2006-10-27 15:47:22 +00:00
menu_fichier - > addSeparator ( ) ;
2007-09-29 12:54:01 +00:00
menu_fichier - > addAction ( quit_editor ) ;
2014-10-26 11:57:38 +00:00
2006-10-27 15:47:22 +00:00
// menu Edition
2007-09-29 12:54:01 +00:00
menu_edition - > addAction ( undo ) ;
menu_edition - > addAction ( redo ) ;
2006-10-27 15:47:22 +00:00
menu_edition - > addSeparator ( ) ;
2007-09-29 12:54:01 +00:00
menu_edition - > addAction ( cut ) ;
menu_edition - > addAction ( copy ) ;
menu_edition - > addAction ( paste ) ;
2006-10-27 15:47:22 +00:00
menu_edition - > addSeparator ( ) ;
2014-06-07 21:03:49 +00:00
menu_edition - > addActions ( m_select_actions_group . actions ( ) ) ;
2006-10-27 15:47:22 +00:00
menu_edition - > addSeparator ( ) ;
2014-06-07 21:03:49 +00:00
menu_edition - > addActions ( m_selection_actions_group . actions ( ) ) ;
2006-11-19 18:40:03 +00:00
menu_edition - > addSeparator ( ) ;
2007-10-06 18:37:21 +00:00
menu_edition - > addAction ( conductor_reset ) ;
2007-10-03 13:11:47 +00:00
menu_edition - > addSeparator ( ) ;
2007-01-29 00:41:12 +00:00
menu_edition - > addAction ( infos_diagram ) ;
2014-06-07 21:03:49 +00:00
menu_edition - > addActions ( m_row_column_actions_group . actions ( ) ) ;
2014-10-26 11:57:38 +00:00
2009-04-03 19:30:25 +00:00
// menu Projet
menu_project - > addAction ( prj_edit_prop ) ;
menu_project - > addAction ( prj_add_diagram ) ;
menu_project - > addAction ( prj_del_diagram ) ;
menu_project - > addAction ( prj_clean ) ;
2013-04-11 09:35:10 +00:00
menu_project - > addSeparator ( ) ;
2014-02-06 23:55:02 +00:00
menu_project - > addAction ( prj_diagramList ) ;
2013-04-11 09:35:10 +00:00
menu_project - > addAction ( prj_nomenclature ) ;
2016-08-30 21:42:35 +00:00
menu_project - > addAction ( prj_terminalBloc ) ;
2014-10-26 11:57:38 +00:00
2016-08-30 21:42:35 +00:00
main_bar - > toggleViewAction ( ) - > setStatusTip ( tr ( " Affiche ou non la barre d'outils principale " ) ) ;
view_bar - > toggleViewAction ( ) - > setStatusTip ( tr ( " Affiche ou non la barre d'outils Affichage " ) ) ;
diagram_bar - > toggleViewAction ( ) - > setStatusTip ( tr ( " Affiche ou non la barre d'outils Schéma " ) ) ;
qdw_pa - > toggleViewAction ( ) - > setStatusTip ( tr ( " Affiche ou non le panel d'appareils " ) ) ;
qdw_undo - > toggleViewAction ( ) - > setStatusTip ( tr ( " Affiche ou non la liste des modifications " ) ) ;
2014-10-26 11:57:38 +00:00
2006-10-27 15:47:22 +00:00
// menu Affichage
2009-04-03 19:30:25 +00:00
QMenu * projects_view_mode = menu_affichage - > addMenu ( tr ( " Afficher les projets " ) ) ;
projects_view_mode - > setTearOffEnabled ( true ) ;
projects_view_mode - > addAction ( windowed_view_mode ) ;
projects_view_mode - > addAction ( tabbed_view_mode ) ;
2014-10-26 11:57:38 +00:00
2009-04-03 19:30:25 +00:00
menu_affichage - > addSeparator ( ) ;
2007-10-13 17:04:52 +00:00
menu_affichage - > addAction ( mode_selection ) ;
menu_affichage - > addAction ( mode_visualise ) ;
2006-10-27 15:47:22 +00:00
menu_affichage - > addSeparator ( ) ;
2016-08-18 16:30:24 +00:00
menu_affichage - > addAction ( m_draw_grid ) ;
2015-06-25 18:23:47 +00:00
menu_affichage - > addAction ( m_grey_background ) ;
menu_affichage - > addSeparator ( ) ;
2014-06-07 21:03:49 +00:00
menu_affichage - > addActions ( m_zoom_actions_group . actions ( ) ) ;
2013-08-24 15:18:45 +00:00
2007-01-29 00:41:12 +00:00
// menu Fenetres
2007-09-29 12:54:01 +00:00
slot_updateWindowsMenu ( ) ;
2006-10-27 15:47:22 +00:00
}
/**
2014-10-26 11:57:38 +00:00
Permet de quitter l ' application lors de la fermeture de la fenetre principale
@ param qce Le QCloseEvent correspondant a l ' evenement de fermeture
2006-10-27 15:47:22 +00:00
*/
2014-10-26 11:57:38 +00:00
void QETDiagramEditor : : closeEvent ( QCloseEvent * qce ) {
// quitte directement s'il n'y a aucun projet ouvert
bool can_quit = true ;
if ( openedProjects ( ) . count ( ) ) {
// s'assure que la fenetre soit visible s'il y a des projets a fermer
if ( ! isVisible ( ) | | isMinimized ( ) ) {
if ( isMaximized ( ) ) showMaximized ( ) ;
else showNormal ( ) ;
}
// sinon demande la permission de fermer chaque projet
2017-02-05 16:18:50 +00:00
foreach ( ProjectView * project , openedProjects ( ) ) {
2014-10-26 11:57:38 +00:00
if ( ! closeProject ( project ) ) {
can_quit = false ;
qce - > ignore ( ) ;
break ;
}
}
}
if ( can_quit ) {
writeSettings ( ) ;
setAttribute ( Qt : : WA_DeleteOnClose ) ;
qce - > accept ( ) ;
}
}
2013-03-27 21:20:53 +00:00
2014-10-26 11:57:38 +00:00
/**
2017-05-01 16:22:34 +00:00
* @ brief QETDiagramEditor : : event
* Reimplemented to :
* - avoid conflic with shortcut " Ctrl+W " ( QKeySequence : : Close )
* - Load elements collection when WindowActivate .
* @ param e
* @ return
*/
bool QETDiagramEditor : : event ( QEvent * e )
{
if ( e - > type ( ) = = QEvent : : ShortcutOverride )
{
2014-10-26 11:57:38 +00:00
QKeyEvent * shortcut_event = static_cast < QKeyEvent * > ( e ) ;
2017-05-01 16:22:34 +00:00
if ( shortcut_event & & shortcut_event - > matches ( QKeySequence : : Close ) )
{
2014-10-26 11:57:38 +00:00
close_file - > trigger ( ) ;
e - > accept ( ) ;
return ( true ) ;
}
}
2017-05-01 16:22:34 +00:00
if ( m_first_show & & e - > type ( ) = = QEvent : : WindowActivate )
{
m_first_show = false ;
QTimer : : singleShot ( 250 , m_element_collection_widget , SLOT ( reload ( ) ) ) ;
}
2014-10-26 11:57:38 +00:00
return ( QETMainWindow : : event ( e ) ) ;
2006-10-27 15:47:22 +00:00
}
/**
2007-02-01 01:07:26 +00:00
Imprime le schema courant
2006-10-27 15:47:22 +00:00
*/
2007-09-29 12:54:01 +00:00
void QETDiagramEditor : : printDialog ( ) {
2009-04-03 19:30:25 +00:00
ProjectView * current_project = currentProject ( ) ;
if ( ! current_project ) return ;
current_project - > printProject ( ) ;
2006-10-27 15:47:22 +00:00
}
2006-11-11 13:56:40 +00:00
/**
2007-02-01 01:07:26 +00:00
Gere l ' export de schema sous forme d ' image
2006-11-11 13:56:40 +00:00
*/
2007-09-29 12:54:01 +00:00
void QETDiagramEditor : : exportDialog ( ) {
2009-04-03 19:30:25 +00:00
ProjectView * current_project = currentProject ( ) ;
if ( ! current_project ) return ;
current_project - > exportProject ( ) ;
2006-10-27 15:47:22 +00:00
}
/**
2014-12-12 13:27:13 +00:00
* @ brief QETDiagramEditor : : save
* Ask the current active project to save
*/
2012-07-13 07:21:19 +00:00
void QETDiagramEditor : : save ( ) {
2009-04-03 19:30:25 +00:00
if ( ProjectView * project_view = currentProject ( ) ) {
2014-10-26 11:57:38 +00:00
QETResult saved = project_view - > save ( ) ;
2014-12-12 13:27:13 +00:00
2014-10-26 11:57:38 +00:00
if ( saved . isOk ( ) ) {
2017-01-10 14:56:34 +00:00
//save_file -> setDisabled(true);
2009-04-03 19:30:25 +00:00
QETApp : : projectsRecentFiles ( ) - > fileWasOpened ( project_view - > project ( ) - > filePath ( ) ) ;
2014-12-12 13:27:13 +00:00
2014-11-24 02:51:08 +00:00
QString title = ( project_view - > project ( ) - > title ( ) ) ;
if ( title . isEmpty ( ) ) title = " QElectroTech " ;
QString filePath = ( project_view - > project ( ) - > filePath ( ) ) ;
2015-03-02 20:14:56 +00:00
statusBar ( ) - > showMessage ( tr ( " Projet %1 enregistré dans le repertoire: %2. " ) . arg ( title ) . arg ( filePath ) , 2000 ) ;
2016-06-30 09:12:25 +00:00
m_element_collection_widget - > highlightUnusedElement ( ) ;
2014-12-12 13:27:13 +00:00
}
else {
2014-10-26 11:57:38 +00:00
showError ( saved ) ;
2009-04-03 19:30:25 +00:00
}
}
2006-10-27 15:47:22 +00:00
}
/**
2014-12-12 13:27:13 +00:00
* @ brief QETDiagramEditor : : saveAs
* Ask the current active project to save as
*/
2012-07-13 07:21:19 +00:00
void QETDiagramEditor : : saveAs ( ) {
2009-04-03 19:30:25 +00:00
if ( ProjectView * project_view = currentProject ( ) ) {
2012-07-13 07:21:19 +00:00
QETResult save_file = project_view - > saveAs ( ) ;
if ( save_file . isOk ( ) ) {
2009-04-03 19:30:25 +00:00
QETApp : : projectsRecentFiles ( ) - > fileWasOpened ( project_view - > project ( ) - > filePath ( ) ) ;
2014-12-12 13:27:13 +00:00
2014-11-24 02:51:08 +00:00
QString title = ( project_view - > project ( ) - > title ( ) ) ;
if ( title . isEmpty ( ) ) title = " QElectroTech " ;
QString filePath = ( project_view - > project ( ) - > filePath ( ) ) ;
2015-03-02 20:14:56 +00:00
statusBar ( ) - > showMessage ( tr ( " Projet %1 enregistré dans le repertoire: %2. " ) . arg ( title ) . arg ( filePath ) , 2000 ) ;
2016-06-30 09:12:25 +00:00
m_element_collection_widget - > highlightUnusedElement ( ) ;
2014-12-12 13:27:13 +00:00
}
else {
2012-07-13 07:21:19 +00:00
showError ( save_file ) ;
2008-08-23 18:17:00 +00:00
}
}
2006-10-27 15:47:22 +00:00
}
2009-04-03 19:30:25 +00:00
/**
2014-04-11 09:51:21 +00:00
* @ brief QETDiagramEditor : : newProject
* Create an empty project
* @ return
*/
2009-04-03 19:30:25 +00:00
bool QETDiagramEditor : : newProject ( ) {
2014-04-11 09:51:21 +00:00
// create new project without diagram
2009-04-03 19:30:25 +00:00
QETProject * new_project = new QETProject ( 0 ) ;
2014-04-11 09:51:21 +00:00
// Set default properties for new diagram
2014-10-26 11:57:38 +00:00
new_project - > setDefaultBorderProperties ( BorderProperties : : defaultProperties ( ) ) ;
new_project - > setDefaultConductorProperties ( ConductorProperties : : defaultProperties ( ) ) ;
new_project - > setDefaultTitleBlockProperties ( TitleBlockProperties : : defaultProperties ( ) ) ;
new_project - > setDefaultReportProperties ( ReportProperties : : defaultProperties ( ) ) ;
new_project - > setDefaultXRefProperties ( XRefProperties : : defaultProperties ( ) ) ;
2009-04-03 19:30:25 +00:00
2014-02-11 05:10:16 +00:00
// add new diagram
2014-02-08 23:54:15 +00:00
new_project - > addNewDiagram ( ) ;
2009-04-03 19:30:25 +00:00
return ( addProject ( new_project ) ) ;
2006-10-27 15:47:22 +00:00
}
2008-07-30 11:51:27 +00:00
/**
Slot utilise pour ouvrir un fichier recent .
Transfere filepath au slot openAndAddDiagram seulement si cet editeur est
actif
@ param filepath Fichier a ouvrir
@ see openAndAddDiagram
*/
bool QETDiagramEditor : : openRecentFile ( const QString & filepath ) {
2013-01-03 21:53:26 +00:00
// small hack to prevent all diagram editors from trying to topen the required
// recent file at the same time
2008-07-30 11:51:27 +00:00
if ( qApp - > activeWindow ( ) ! = this ) return ( false ) ;
2009-04-03 19:30:25 +00:00
return ( openAndAddProject ( filepath ) ) ;
2008-07-30 11:51:27 +00:00
}
2006-10-27 15:47:22 +00:00
/**
Cette fonction demande un nom de fichier a ouvrir a l ' utilisateur
@ return true si l ' ouverture a reussi , false sinon
*/
2009-04-03 19:30:25 +00:00
bool QETDiagramEditor : : openProject ( ) {
// demande un chemin de fichier a ouvrir a l'utilisateur
QString filepath = QFileDialog : : getOpenFileName (
2006-10-27 15:47:22 +00:00
this ,
tr ( " Ouvrir un fichier " ) ,
2007-10-21 12:53:57 +00:00
open_dialog_dir . absolutePath ( ) ,
2015-06-21 15:29:09 +00:00
tr ( " Projets QElectroTech (*.qet);;Fichiers XML (*.xml);;Tous les fichiers (*) " )
2006-10-27 15:47:22 +00:00
) ;
2009-04-03 19:30:25 +00:00
if ( filepath . isEmpty ( ) ) return ( false ) ;
// retient le dossier contenant le dernier projet ouvert
open_dialog_dir = QDir ( filepath ) ;
2008-07-17 19:25:57 +00:00
2009-04-03 19:30:25 +00:00
// ouvre le fichier
return ( openAndAddProject ( filepath ) ) ;
}
/**
Ferme un projet
@ param project_view Projet a fermer
@ return true si la fermeture du projet a reussi , false sinon
Note : cette methode renvoie true si project est nul
*/
bool QETDiagramEditor : : closeProject ( ProjectView * project_view ) {
if ( project_view ) {
activateProject ( project_view ) ;
2015-05-07 22:15:00 +00:00
if ( QMdiSubWindow * sub_window = subWindowForWidget ( project_view ) ) {
2009-04-03 19:30:25 +00:00
return ( sub_window - > close ( ) ) ;
}
}
return ( true ) ;
}
/**
Ferme un projet
@ param project projet a fermer
@ return true si la fermeture du fichier a reussi , false sinon
Note : cette methode renvoie true si project est nul
*/
bool QETDiagramEditor : : closeProject ( QETProject * project ) {
if ( ProjectView * project_view = findProject ( project ) ) {
return ( closeProject ( project_view ) ) ;
}
return ( true ) ;
2008-07-17 19:25:57 +00:00
}
/**
2009-04-03 19:30:25 +00:00
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 = currentProject ( ) ) {
return ( closeProject ( project_view ) ) ;
}
return ( true ) ;
}
/**
Ouvre un projet depuis un fichier et l ' ajoute a cet editeur
@ param filepath Chemin du projet a ouvrir
@ param interactive true pour afficher des messages a l ' utilisateur , false sinon
2011-03-15 20:06:40 +00:00
@ param update_panel Whether the elements panel should be warned this
project has been added . Defaults to true .
2008-07-17 19:25:57 +00:00
@ return true si l ' ouverture a reussi , false sinon
*/
2011-03-15 20:06:40 +00:00
bool QETDiagramEditor : : openAndAddProject ( const QString & filepath , bool interactive , bool update_panel ) {
2009-04-03 19:30:25 +00:00
if ( filepath . isEmpty ( ) ) return ( false ) ;
2006-10-27 15:47:22 +00:00
2009-04-03 19:30:25 +00:00
QFileInfo filepath_info ( filepath ) ;
// verifie que le projet n'est pas deja ouvert dans un editeur
QString my_filepath = filepath_info . canonicalFilePath ( ) ;
if ( QETDiagramEditor * diagram_editor = QETApp : : diagramEditorForFile ( filepath ) ) {
2008-07-20 11:37:31 +00:00
if ( diagram_editor = = this ) {
2009-04-03 19:30:25 +00:00
if ( ProjectView * project_view = viewForFile ( filepath ) ) {
activateWidget ( project_view ) ;
2008-07-20 11:37:31 +00:00
show ( ) ;
activateWindow ( ) ;
}
2006-10-27 15:47:22 +00:00
return ( false ) ;
2008-07-20 11:37:31 +00:00
} else {
// demande a l'autre editeur d'afficher le fichier
2009-04-03 19:30:25 +00:00
return ( diagram_editor - > openAndAddProject ( filepath ) ) ;
2006-10-27 15:47:22 +00:00
}
}
2013-01-03 21:53:26 +00:00
// check the file exists
if ( ! filepath_info . exists ( ) ) {
if ( interactive ) {
2015-03-02 20:14:56 +00:00
QET : : QetMessageBox : : critical (
2013-01-03 21:53:26 +00:00
this ,
tr ( " Impossible d'ouvrir le fichier " , " message box title " ) ,
QString (
tr ( " Il semblerait que le fichier %1 que vous essayez d'ouvrir "
" n'existe pas ou plus. " )
) . arg ( filepath )
) ;
}
2013-01-04 14:11:03 +00:00
return ( false ) ;
2013-01-03 21:53:26 +00:00
}
2009-04-03 19:30:25 +00:00
// verifie que le fichier est accessible en lecture
if ( ! filepath_info . isReadable ( ) ) {
if ( interactive ) {
2015-03-02 20:14:56 +00:00
QET : : QetMessageBox : : critical (
2009-04-03 19:30:25 +00:00
this ,
2013-01-03 21:53:26 +00:00
tr ( " Impossible d'ouvrir le fichier " , " message box title " ) ,
2009-04-03 19:30:25 +00:00
tr ( " Il semblerait que le fichier que vous essayez d'ouvrir ne "
" soit pas accessible en lecture. Il est donc impossible de "
2015-03-02 20:14:56 +00:00
" l'ouvrir. Veuillez vérifier les permissions du fichier. " )
2009-04-03 19:30:25 +00:00
) ;
}
return ( false ) ;
}
// gere le fait que le fichier puisse etre en lecture seule
if ( ! filepath_info . isWritable ( ) ) {
if ( interactive ) {
2015-03-02 20:14:56 +00:00
QET : : QetMessageBox : : warning (
2009-04-03 19:30:25 +00:00
this ,
2013-01-03 21:53:26 +00:00
tr ( " Ouverture du projet en lecture seule " , " message box title " ) ,
2009-04-03 19:30:25 +00:00
tr ( " Il semblerait que le projet que vous essayez d'ouvrir ne "
2015-03-02 20:14:56 +00:00
" soit pas accessible en écriture. Il sera donc ouvert en "
2009-04-03 19:30:25 +00:00
" lecture seule. " )
) ;
}
}
// cree le projet a partir du fichier
QETProject * project = new QETProject ( filepath ) ;
if ( project - > state ( ) ! = QETProject : : Ok ) {
2011-08-26 19:06:35 +00:00
if ( interactive & & project - > state ( ) ! = QETProject : : FileOpenDiscard ) {
2015-03-02 20:14:56 +00:00
QET : : QetMessageBox : : warning (
2009-04-03 19:30:25 +00:00
this ,
2015-03-02 20:14:56 +00:00
tr ( " Échec de l'ouverture du projet " , " message box title " ) ,
2009-04-03 19:30:25 +00:00
QString (
tr (
" Il semblerait que le fichier %1 ne soit pas un fichier "
2015-03-02 20:14:56 +00:00
" projet QElectroTech. Il ne peut donc être ouvert. " ,
2009-04-03 19:30:25 +00:00
" message box content "
)
) . arg ( filepath )
) ;
2006-10-27 15:47:22 +00:00
}
2011-08-26 19:06:35 +00:00
delete project ;
2006-10-27 15:47:22 +00:00
return ( false ) ;
}
2013-04-11 09:35:10 +00:00
2009-04-03 19:30:25 +00:00
// a ce stade, l'ouverture du fichier a reussi
// on l'ajoute a la liste des fichiers recents
QETApp : : projectsRecentFiles ( ) - > fileWasOpened ( filepath ) ;
// ... et on l'ajoute dans l'application
2011-03-15 20:06:40 +00:00
// Note: we require the panel not to be updated when the project is added
// because it will update itself as soon as it becomes visible
return ( addProject ( project ) , update_panel ) ;
2006-10-27 15:47:22 +00:00
}
/**
2014-02-08 23:54:15 +00:00
Ajoute un projetmoveDiagramUp (
2009-04-03 19:30:25 +00:00
@ param project projet a ajouter
2011-03-15 20:06:40 +00:00
@ param update_panel Whether the elements panel should be warned this
project has been added . Defaults to true .
2006-10-27 15:47:22 +00:00
*/
2011-03-15 20:06:40 +00:00
bool QETDiagramEditor : : addProject ( QETProject * project , bool update_panel ) {
2009-04-03 19:30:25 +00:00
// enregistre le projet
QETApp : : registerProject ( project ) ;
// cree un ProjectView pour visualiser le projet
ProjectView * project_view = new ProjectView ( project ) ;
addProjectView ( project_view ) ;
2014-11-27 18:46:30 +00:00
undo_group . addStack ( project - > undoStack ( ) ) ;
2015-12-16 17:16:15 +00:00
m_element_collection_widget - > addProject ( project ) ;
2009-04-03 19:30:25 +00:00
// met a jour le panel d'elements
2011-03-15 20:06:40 +00:00
if ( update_panel ) {
pa - > elementsPanel ( ) . projectWasOpened ( project ) ;
2016-07-26 18:52:49 +00:00
if ( currentDiagram ( ) ! = NULL )
2016-07-13 14:57:27 +00:00
m_autonumbering_dock - > setProject ( project , project_view ) ;
2011-03-15 20:06:40 +00:00
}
2009-04-03 19:30:25 +00:00
return ( true ) ;
}
/**
@ return la liste des projets ouverts dans cette fenetre
*/
QList < ProjectView * > QETDiagramEditor : : openedProjects ( ) const {
QList < ProjectView * > result ;
QList < QMdiSubWindow * > window_list ( workspace . subWindowList ( ) ) ;
2017-02-05 16:18:50 +00:00
foreach ( QMdiSubWindow * window , window_list ) {
2009-04-03 19:30:25 +00:00
if ( ProjectView * project_view = qobject_cast < ProjectView * > ( window - > widget ( ) ) ) {
result < < project_view ;
}
}
return ( result ) ;
}
/**
@ return Le projet actuellement edite ( = qui a le focus dans l ' interface
MDI ) ou 0 s ' il n ' y en a pas
*/
ProjectView * QETDiagramEditor : : currentProject ( ) const {
QMdiSubWindow * current_window = workspace . activeSubWindow ( ) ;
if ( ! current_window ) return ( 0 ) ;
QWidget * current_widget = current_window - > widget ( ) ;
if ( ! current_widget ) return ( 0 ) ;
if ( ProjectView * project_view = qobject_cast < ProjectView * > ( current_widget ) ) {
return ( project_view ) ;
}
return ( 0 ) ;
2006-10-27 15:47:22 +00:00
}
/**
2009-04-03 19:30:25 +00:00
@ return Le schema actuellement edite ( = l ' onglet ouvert dans le projet
courant ) ou 0 s ' il n ' y en a pas
2006-10-27 15:47:22 +00:00
*/
2007-09-25 23:24:36 +00:00
DiagramView * QETDiagramEditor : : currentDiagram ( ) const {
2009-04-03 19:30:25 +00:00
if ( ProjectView * project_view = currentProject ( ) ) {
return ( project_view - > currentDiagram ( ) ) ;
}
return ( 0 ) ;
}
2013-02-12 18:37:08 +00:00
/**
@ return the selected element in the current diagram view , or 0 if :
* no diagram is being viewed in this editor .
* no element is selected
* more than one element is selected
*/
Element * QETDiagramEditor : : currentElement ( ) const {
DiagramView * dv = currentDiagram ( ) ;
if ( ! dv ) return ( 0 ) ;
QList < Element * > selected_elements = dv - > diagram ( ) - > selectedContent ( ) . elements . toList ( ) ;
if ( selected_elements . count ( ) ! = 1 ) return ( 0 ) ;
return ( selected_elements . first ( ) ) ;
}
/**
@ return the selected element in the current diagram view , or 0 if :
* no diagram is being viewed in this editor .
* no element is selected
* more than one element is selected
* the selected element is not a custom element
*/
CustomElement * QETDiagramEditor : : currentCustomElement ( ) const {
return ( dynamic_cast < CustomElement * > ( currentElement ( ) ) ) ;
}
2009-04-03 19:30:25 +00:00
/**
Cette methode permet de retrouver le projet contenant un schema donne .
@ param diagram_view Schema dont il faut retrouver
@ return la vue sur le projet contenant ce schema ou 0 s ' il n ' y en a pas
*/
ProjectView * QETDiagramEditor : : findProject ( DiagramView * diagram_view ) const {
2017-02-05 16:18:50 +00:00
foreach ( ProjectView * project_view , openedProjects ( ) ) {
2017-02-18 13:30:38 +00:00
if ( project_view - > diagram_views ( ) . contains ( diagram_view ) ) {
2009-04-03 19:30:25 +00:00
return ( project_view ) ;
}
}
return ( 0 ) ;
}
/**
Cette methode permet de retrouver le projet contenant un schema donne .
@ param diagram Schema dont il faut retrouver
@ return la vue sur le projet contenant ce schema ou 0 s ' il n ' y en a pas
*/
ProjectView * QETDiagramEditor : : findProject ( Diagram * diagram ) const {
2017-02-05 16:18:50 +00:00
foreach ( ProjectView * project_view , openedProjects ( ) ) {
2017-02-18 13:30:38 +00:00
foreach ( DiagramView * diagram_view , project_view - > diagram_views ( ) ) {
2009-04-03 19:30:25 +00:00
if ( diagram_view - > diagram ( ) = = diagram ) {
return ( project_view ) ;
}
}
}
return ( 0 ) ;
}
/**
@ param project Projet dont il faut trouver la vue
@ return la vue du projet passe en parametre
*/
ProjectView * QETDiagramEditor : : findProject ( QETProject * project ) const {
2017-02-05 16:18:50 +00:00
foreach ( ProjectView * opened_project , openedProjects ( ) ) {
2009-04-03 19:30:25 +00:00
if ( opened_project - > project ( ) = = project ) {
return ( opened_project ) ;
}
}
return ( 0 ) ;
}
/**
@ param filepath Chemin de fichier d ' un projet
@ return le ProjectView correspondant au chemin passe en parametre , ou 0 si
celui - ci n ' a pas ete trouve
*/
ProjectView * QETDiagramEditor : : findProject ( const QString & filepath ) const {
2017-02-05 16:18:50 +00:00
foreach ( ProjectView * opened_project , openedProjects ( ) ) {
2009-04-03 19:30:25 +00:00
if ( QETProject * project = opened_project - > project ( ) ) {
if ( project - > filePath ( ) = = filepath ) {
return ( opened_project ) ;
}
}
}
return ( 0 ) ;
}
/**
@ param widget Widget a rechercher dans la zone MDI
@ return La sous - fenetre accueillant le widget passe en parametre , ou 0 si
celui - ci n ' a pas ete trouve .
*/
QMdiSubWindow * QETDiagramEditor : : subWindowForWidget ( QWidget * widget ) const {
2017-02-05 16:18:50 +00:00
foreach ( QMdiSubWindow * sub_window , workspace . subWindowList ( ) ) {
2009-04-03 19:30:25 +00:00
if ( sub_window - > widget ( ) = = widget ) {
return ( sub_window ) ;
}
}
return ( 0 ) ;
}
/**
@ param widget Widget a activer
*/
void QETDiagramEditor : : activateWidget ( QWidget * widget ) {
QMdiSubWindow * sub_window = subWindowForWidget ( widget ) ;
if ( sub_window ) {
workspace . setActiveSubWindow ( sub_window ) ;
}
}
2006-11-11 13:56:40 +00:00
/**
Effectue l ' action " couper " sur le schema en cours
*/
2007-09-29 12:54:01 +00:00
void QETDiagramEditor : : slot_cut ( ) {
if ( currentDiagram ( ) ) currentDiagram ( ) - > cut ( ) ;
2006-10-27 15:47:22 +00:00
}
2006-11-11 13:56:40 +00:00
/**
2007-01-29 00:41:12 +00:00
Effectue l ' action " copier " sur le diagram en cours
2006-11-11 13:56:40 +00:00
*/
2007-09-29 12:54:01 +00:00
void QETDiagramEditor : : slot_copy ( ) {
if ( currentDiagram ( ) ) currentDiagram ( ) - > copy ( ) ;
2006-10-27 15:47:22 +00:00
}
2006-11-11 13:56:40 +00:00
/**
Effectue l ' action " coller " sur le schema en cours
*/
2007-09-29 12:54:01 +00:00
void QETDiagramEditor : : slot_paste ( ) {
if ( currentDiagram ( ) ) currentDiagram ( ) - > paste ( ) ;
2006-10-27 15:47:22 +00:00
}
2015-09-19 13:27:06 +00:00
void QETDiagramEditor : : zoomGroupTriggered ( QAction * action )
{
QString value = action - > data ( ) . toString ( ) ;
DiagramView * dv = currentDiagram ( ) ;
2006-10-27 15:47:22 +00:00
2015-09-19 13:27:06 +00:00
if ( ! dv | | value . isEmpty ( ) ) return ;
2006-10-27 15:47:22 +00:00
2015-09-19 13:27:06 +00:00
if ( value = = " zoom_in " )
2015-11-18 09:51:53 +00:00
dv - > zoom ( 1.15 ) ;
2015-09-19 13:27:06 +00:00
else if ( value = = " zoom_out " )
2015-11-18 09:51:53 +00:00
dv - > zoom ( 0.85 ) ;
2015-09-19 13:27:06 +00:00
else if ( value = = " zoom_content " )
dv - > zoomContent ( ) ;
else if ( value = = " zoom_fit " )
dv - > zoomFit ( ) ;
else if ( value = = " zoom_reset " )
dv - > zoomReset ( ) ;
2006-10-27 15:47:22 +00:00
}
2012-08-12 11:46:42 +00:00
/**
2015-09-19 13:27:06 +00:00
* @ brief QETDiagramEditor : : selectGroupTriggered
* This slot is called when selection need to change .
* @ param action : Action that describes what to do .
*/
void QETDiagramEditor : : selectGroupTriggered ( QAction * action )
{
QString value = action - > data ( ) . toString ( ) ;
DiagramView * dv = currentDiagram ( ) ;
2012-08-12 11:46:42 +00:00
2015-09-19 13:27:06 +00:00
if ( ! dv | | value . isEmpty ( ) ) return ;
2006-10-27 15:47:22 +00:00
2015-09-19 13:27:06 +00:00
if ( value = = " select_all " )
dv - > selectAll ( ) ;
else if ( value = = " deselect " )
dv - > selectNothing ( ) ;
else if ( value = = " invert_selection " )
dv - > selectInvert ( ) ;
2006-10-27 15:47:22 +00:00
}
2006-11-11 13:56:40 +00:00
/**
2015-09-19 13:27:06 +00:00
* @ brief QETDiagramEditor : : addItemGroupTriggered
* This slot is called when an item must be added to the curent diagram ,
* this slot use the DVEventInterface to add item
* @ param action : Action that describe the item to add .
*/
void QETDiagramEditor : : addItemGroupTriggered ( QAction * action )
{
QString value = action - > data ( ) . toString ( ) ;
2015-11-07 12:28:43 +00:00
2015-11-12 17:29:48 +00:00
if ( Q_UNLIKELY ( ! currentDiagram ( ) | | ! currentDiagram ( ) - > diagram ( ) | | value . isEmpty ( ) ) ) return ;
2015-11-07 12:28:43 +00:00
2015-11-12 17:29:48 +00:00
Diagram * d = currentDiagram ( ) - > diagram ( ) ;
2015-11-07 12:28:43 +00:00
DiagramEventInterface * diagram_event = nullptr ;
if ( value = = " line " )
diagram_event = new DiagramEventAddShape ( d , QetShapeItem : : Line ) ;
else if ( value = = " rectangle " )
diagram_event = new DiagramEventAddShape ( d , QetShapeItem : : Rectangle ) ;
else if ( value = = " ellipse " )
diagram_event = new DiagramEventAddShape ( d , QetShapeItem : : Ellipse ) ;
else if ( value = = " polyline " )
diagram_event = new DiagramEventAddShape ( d , QetShapeItem : : Polygon ) ;
2015-11-12 17:01:08 +00:00
else if ( value = = " image " )
{
DiagramEventAddImage * deai = new DiagramEventAddImage ( d ) ;
if ( deai - > isNull ( ) )
{
delete deai ;
action - > setChecked ( false ) ;
return ;
}
else
diagram_event = deai ;
}
2015-11-12 17:29:48 +00:00
else if ( value = = " text " )
diagram_event = new DiagramEventAddText ( d ) ;
2015-11-07 12:28:43 +00:00
if ( diagram_event )
{
d - > setEventInterface ( diagram_event ) ;
connect ( diagram_event , & DiagramEventInterface : : finish , [ action ] ( ) { action - > setChecked ( false ) ; } ) ;
2015-09-19 13:27:06 +00:00
}
2006-10-27 15:47:22 +00:00
}
2006-11-11 13:56:40 +00:00
/**
2015-09-19 13:27:06 +00:00
* @ brief QETDiagramEditor : : selectionGroupTriggered
* This slot is called when an action should be made on the current selection
* @ param action : Action that describe the action to do .
*/
void QETDiagramEditor : : selectionGroupTriggered ( QAction * action )
{
QString value = action - > data ( ) . toString ( ) ;
DiagramView * dv = currentDiagram ( ) ;
if ( ! dv | | value . isEmpty ( ) ) return ;
if ( value = = " delete_selection " )
dv - > deleteSelection ( ) ;
else if ( value = = " rotate_selection " )
dv - > rotateSelection ( ) ;
else if ( value = = " rotate_selected_text " )
dv - > rotateTexts ( ) ;
else if ( value = = " find_selected_element " & & currentCustomElement ( ) )
findElementInPanel ( currentCustomElement ( ) - > location ( ) ) ;
else if ( value = = " edit_selected_element " )
dv - > editSelection ( ) ;
2006-10-27 15:47:22 +00:00
}
2015-09-19 13:27:06 +00:00
void QETDiagramEditor : : rowColumnGroupTriggered ( QAction * action )
{
QString value = action - > data ( ) . toString ( ) ;
DiagramView * dv = currentDiagram ( ) ;
if ( ! dv | | value . isEmpty ( ) ) return ;
if ( value = = " add_column " )
dv - > addColumn ( ) ;
else if ( value = = " remove_column " )
dv - > removeColumn ( ) ;
else if ( value = = " add_row " )
dv - > addRow ( ) ;
else if ( value = = " remove_row " )
dv - > removeRow ( ) ;
2010-02-11 23:35:04 +00:00
}
2006-11-11 13:56:40 +00:00
/**
2015-01-11 08:50:36 +00:00
* @ brief QETDiagramEditor : : slot_setSelectionMode
* Set all diagram view of the current project to selection mode
*/
void QETDiagramEditor : : slot_setSelectionMode ( )
{
if ( ProjectView * pv = currentProject ( ) )
2017-02-18 13:30:38 +00:00
foreach ( DiagramView * dv , pv - > diagram_views ( ) )
2015-01-11 08:50:36 +00:00
dv - > setSelectionMode ( ) ;
2006-10-27 15:47:22 +00:00
}
2006-11-11 13:56:40 +00:00
/**
2015-01-11 08:50:36 +00:00
* @ brief QETDiagramEditor : : slot_setVisualisationMode
* Set all diagram view of the current project to visualisation mode
*/
void QETDiagramEditor : : slot_setVisualisationMode ( )
{
if ( ProjectView * pv = currentProject ( ) )
2017-02-18 13:30:38 +00:00
foreach ( DiagramView * dv , pv - > diagram_views ( ) )
2015-01-11 08:50:36 +00:00
dv - > setVisualisationMode ( ) ;
2006-10-27 15:47:22 +00:00
}
/**
2014-12-26 19:41:00 +00:00
* @ brief QETDiagramEditor : : slot_updateActions
* Manage actions
*/
void QETDiagramEditor : : slot_updateActions ( )
{
2009-04-03 19:30:25 +00:00
DiagramView * dv = currentDiagram ( ) ;
ProjectView * pv = currentProject ( ) ;
2014-10-26 11:57:38 +00:00
2009-04-03 19:30:25 +00:00
bool opened_project = pv ;
bool opened_diagram = dv ;
bool editable_project = ( pv & & ! pv - > project ( ) - > isReadOnly ( ) ) ;
2014-02-08 18:51:06 +00:00
2014-12-26 19:41:00 +00:00
close_file - > setEnabled ( opened_project ) ;
2017-01-11 00:04:43 +00:00
save_file - > setEnabled ( opened_project ) ;
2014-12-26 19:41:00 +00:00
save_file_as - > setEnabled ( opened_project ) ;
prj_edit_prop - > setEnabled ( opened_project ) ;
prj_add_diagram - > setEnabled ( editable_project ) ;
prj_del_diagram - > setEnabled ( editable_project ) ;
prj_clean - > setEnabled ( editable_project ) ;
prj_diagramList - > setEnabled ( opened_project ) ;
prj_nomenclature - > setEnabled ( editable_project ) ;
export_diagram - > setEnabled ( opened_diagram ) ;
print - > setEnabled ( opened_diagram ) ;
infos_diagram - > setEnabled ( opened_diagram ) ;
prj_nomenclature - > setEnabled ( editable_project ) ;
m_zoom_actions_group . setEnabled ( opened_diagram ) ;
m_select_actions_group . setEnabled ( opened_diagram ) ;
m_add_item_actions_group . setEnabled ( editable_project ) ;
m_row_column_actions_group . setEnabled ( editable_project ) ;
2015-06-25 18:23:47 +00:00
m_grey_background - > setEnabled ( opened_diagram ) ;
2014-12-26 19:41:00 +00:00
2015-01-11 11:10:57 +00:00
2014-12-26 19:41:00 +00:00
slot_updateUndoStack ( ) ;
2007-10-28 00:16:32 +00:00
slot_updateModeActions ( ) ;
slot_updatePasteAction ( ) ;
slot_updateComplexActions ( ) ;
2016-07-13 14:57:27 +00:00
slot_updateAutoNumDock ( ) ;
}
/**
* @ brief QETDiagramEditor : : slot_updateAutoNumDock
* Update Auto Num Dock Widget when changing Project
*/
void QETDiagramEditor : : slot_updateAutoNumDock ( ) {
if ( workspace . subWindowList ( ) . indexOf ( workspace . activeSubWindow ( ) ) ! = activeSubWindowIndex ) {
activeSubWindowIndex = workspace . subWindowList ( ) . indexOf ( workspace . activeSubWindow ( ) ) ;
2016-07-26 18:52:49 +00:00
if ( currentProject ( ) ! = NULL & & currentDiagram ( ) ! = NULL ) {
2016-07-13 14:57:27 +00:00
m_autonumbering_dock - > setProject ( currentProject ( ) - > project ( ) , currentProject ( ) ) ;
}
}
2007-10-28 00:16:32 +00:00
}
2014-01-05 15:00:46 +00:00
/**
* @ brief QETDiagramEditor : : slot_updateUndoStack
* Update the undo stack view
*/
2014-12-26 19:41:00 +00:00
void QETDiagramEditor : : slot_updateUndoStack ( )
{
2014-01-05 15:00:46 +00:00
ProjectView * pv = currentProject ( ) ;
2014-12-26 19:41:00 +00:00
if ( pv )
{
2014-01-05 15:00:46 +00:00
undo_group . setActiveStack ( pv - > project ( ) - > undoStack ( ) ) ;
2017-01-10 14:56:34 +00:00
// save_file -> setEnabled (undo_group.activeStack() -> count() && !pv -> project() -> isReadOnly());
// }
// else
// {
// //save_file -> setDisabled(true);
2014-01-05 15:00:46 +00:00
}
}
2007-10-28 00:16:32 +00:00
/**
2015-02-20 18:44:44 +00:00
* @ brief QETDiagramEditor : : slot_updateComplexActions
* Manage the actions who need some conditions to be enable or not .
* This method does nothing if there is no project opened
*/
2007-10-28 00:16:32 +00:00
void QETDiagramEditor : : slot_updateComplexActions ( ) {
DiagramView * dv = currentDiagram ( ) ;
2009-04-03 19:30:25 +00:00
bool editable_diagram = ( dv & & ! dv - > diagram ( ) - > isReadOnly ( ) ) ;
2015-05-07 22:15:00 +00:00
2015-02-20 18:44:44 +00:00
//Number of selected conductors
2009-04-03 19:30:25 +00:00
int selected_conductors_count = dv ? dv - > diagram ( ) - > selectedConductors ( ) . count ( ) : 0 ;
conductor_reset - > setEnabled ( editable_diagram & & selected_conductors_count ) ;
2007-10-28 00:16:32 +00:00
2015-02-20 18:44:44 +00:00
// number of selected elements
2013-02-12 18:37:08 +00:00
int selected_elements_count = dv ? dv - > diagram ( ) - > selectedContent ( ) . count ( DiagramContent : : Elements ) : 0 ;
find_element - > setEnabled ( selected_elements_count = = 1 ) ;
2015-02-20 18:44:44 +00:00
//Action that need items (elements, conductors, texts...) selected, to be enabled
2010-04-24 22:37:45 +00:00
bool copiable_items = dv ? ( dv - > hasCopiableItems ( ) ) : false ;
bool deletable_items = dv ? ( dv - > hasDeletableItems ( ) ) : false ;
2013-08-25 10:38:26 +00:00
cut - > setEnabled ( editable_diagram & & copiable_items ) ;
copy - > setEnabled ( copiable_items ) ;
2010-04-24 22:37:45 +00:00
delete_selection - > setEnabled ( editable_diagram & & deletable_items ) ;
rotate_selection - > setEnabled ( editable_diagram & & dv - > diagram ( ) - > canRotateSelection ( ) ) ;
2014-02-06 23:55:02 +00:00
2015-02-20 18:44:44 +00:00
//Action that need selected texts
2013-05-28 16:50:35 +00:00
int selected_texts = dv ? ( dv - > diagram ( ) - > selectedTexts ( ) . count ( ) ) : 0 ;
int selected_conductor_texts = dv ? ( dv - > diagram ( ) - > selectedConductorTexts ( ) . count ( ) ) : 0 ;
2014-12-23 01:51:17 +00:00
int selected_element_texts = dv ? ( dv - > diagram ( ) - > selectedElementTexts ( ) . count ( ) ) : 0 ;
2010-04-24 22:37:45 +00:00
rotate_texts - > setEnabled ( editable_diagram & & selected_texts ) ;
2013-09-10 14:44:25 +00:00
2015-02-20 18:44:44 +00:00
// actions need only one editable item
2013-09-10 14:44:25 +00:00
int selected_image = dv ? dv - > diagram ( ) - > selectedContent ( ) . count ( DiagramContent : : Images ) : 0 ;
2014-03-06 14:04:19 +00:00
int selected_shape = dv ? dv - > diagram ( ) - > selectedContent ( ) . count ( DiagramContent : : Shapes ) : 0 ;
2015-02-20 18:44:44 +00:00
int selected_editable = selected_elements_count +
( selected_texts - selected_conductor_texts - selected_element_texts ) +
selected_image +
selected_shape +
selected_conductors_count ;
2013-09-10 14:44:25 +00:00
2015-02-20 18:44:44 +00:00
if ( selected_editable = = 1 )
{
2013-09-10 14:44:25 +00:00
edit_selection - > setEnabled ( true ) ;
2015-02-20 18:44:44 +00:00
//edit element
if ( selected_elements_count )
{
2015-03-02 20:14:56 +00:00
edit_selection - > setText ( tr ( " Éditer l'élement " , " edit element " ) ) ;
2013-09-10 14:44:25 +00:00
edit_selection - > setIcon ( QET : : Icons : : ElementEdit ) ;
}
2015-02-20 18:44:44 +00:00
//edit text field
else if ( selected_texts )
{
2015-03-02 20:14:56 +00:00
edit_selection - > setText ( tr ( " Éditer le champ de texte " , " edit text field " ) ) ;
2013-09-10 14:44:25 +00:00
edit_selection - > setIcon ( QET : : Icons : : EditText ) ;
}
2015-02-20 18:44:44 +00:00
//edit image
else if ( selected_image )
{
2015-03-02 20:14:56 +00:00
edit_selection - > setText ( tr ( " Éditer l'image " , " edit image " ) ) ;
2013-09-11 15:30:49 +00:00
edit_selection - > setIcon ( QET : : Icons : : resize_image ) ;
2013-09-10 14:44:25 +00:00
}
2015-02-20 18:44:44 +00:00
//edit conductor
else if ( selected_conductors_count )
{
2015-03-02 20:14:56 +00:00
edit_selection - > setText ( tr ( " Éditer le conducteur " , " edit conductor " ) ) ;
2015-02-20 18:44:44 +00:00
edit_selection - > setIcon ( QET : : Icons : : ElementEdit ) ;
}
2013-09-10 14:44:25 +00:00
}
2015-02-20 18:44:44 +00:00
//not an editable item
else
{
2015-03-02 20:14:56 +00:00
edit_selection - > setText ( tr ( " Éditer l'objet sélectionné " , " edit selected item " ) ) ;
2013-09-10 14:44:25 +00:00
edit_selection - > setIcon ( QET : : Icons : : ElementEdit ) ;
edit_selection - > setEnabled ( false ) ;
}
2009-04-03 19:30:25 +00:00
}
2007-10-28 00:16:32 +00:00
/**
2015-01-11 11:10:57 +00:00
* @ brief QETDiagramEditor : : slot_updateModeActions
* Manage action who need an opened diagram or project to be updated
*/
2015-06-25 18:23:47 +00:00
void QETDiagramEditor : : slot_updateModeActions ( )
{
2007-10-28 00:16:32 +00:00
DiagramView * dv = currentDiagram ( ) ;
2006-10-27 15:47:22 +00:00
2015-01-11 11:10:57 +00:00
if ( ! dv )
2007-10-28 00:16:32 +00:00
grp_visu_sel - > setEnabled ( false ) ;
2015-01-11 11:10:57 +00:00
else
{
2015-06-21 15:29:09 +00:00
switch ( ( int ) ( dv - > dragMode ( ) ) )
2015-01-11 11:10:57 +00:00
{
2006-10-27 15:47:22 +00:00
case QGraphicsView : : NoDrag :
2007-10-28 00:16:32 +00:00
grp_visu_sel - > setEnabled ( false ) ;
2006-10-27 15:47:22 +00:00
break ;
case QGraphicsView : : ScrollHandDrag :
2007-10-28 00:16:32 +00:00
grp_visu_sel - > setEnabled ( true ) ;
2006-10-27 15:47:22 +00:00
mode_visualise - > setChecked ( true ) ;
break ;
case QGraphicsView : : RubberBandDrag :
2007-10-28 00:16:32 +00:00
grp_visu_sel - > setEnabled ( true ) ;
2006-10-27 15:47:22 +00:00
mode_selection - > setChecked ( true ) ;
break ;
}
}
2015-01-11 11:10:57 +00:00
if ( ProjectView * pv = currentProject ( ) )
{
m_auto_conductor - > setEnabled ( true ) ;
m_auto_conductor - > setChecked ( pv - > project ( ) - > autoConductor ( ) ) ;
}
else
m_auto_conductor - > setDisabled ( true ) ;
2007-10-28 00:16:32 +00:00
}
/**
Gere les actions ayant besoin du presse - papier
*/
void QETDiagramEditor : : slot_updatePasteAction ( ) {
2009-04-03 19:30:25 +00:00
DiagramView * dv = currentDiagram ( ) ;
bool editable_diagram = ( dv & & ! dv - > diagram ( ) - > isReadOnly ( ) ) ;
2007-11-03 20:20:34 +00:00
// pour coller, il faut un schema ouvert et un schema dans le presse-papier
2009-04-03 19:30:25 +00:00
paste - > setEnabled ( editable_diagram & & Diagram : : clipboardMayContainDiagram ( ) ) ;
2006-10-27 15:47:22 +00:00
}
2006-11-11 13:56:40 +00:00
/**
2014-12-26 19:41:00 +00:00
* @ brief QETDiagramEditor : : addProjectView
* Add a new project view to workspace and
* build the connection between the projectview / project and this QETDiagramEditor .
* @ param project_view , project view to add
*/
void QETDiagramEditor : : addProjectView ( ProjectView * project_view )
{
2009-04-03 19:30:25 +00:00
if ( ! project_view ) return ;
2014-10-26 11:57:38 +00:00
2017-02-18 13:30:38 +00:00
foreach ( DiagramView * dv , project_view - > diagram_views ( ) )
2009-04-03 19:30:25 +00:00
diagramWasAdded ( dv ) ;
2007-01-29 00:41:12 +00:00
2014-12-26 19:41:00 +00:00
//Manage the close event of project
2009-04-03 19:30:25 +00:00
connect ( project_view , SIGNAL ( projectClosed ( ProjectView * ) ) , this , SLOT ( projectWasClosed ( ProjectView * ) ) ) ;
2014-12-26 19:41:00 +00:00
//Manage the adding of diagram
connect ( project_view , SIGNAL ( diagramAdded ( DiagramView * ) ) , this , SLOT ( diagramWasAdded ( DiagramView * ) ) ) ;
if ( QETProject * project = project_view - > project ( ) )
2009-04-03 19:30:25 +00:00
connect ( project , SIGNAL ( readOnlyChanged ( QETProject * , bool ) ) , this , SLOT ( slot_updateActions ( ) ) ) ;
2014-12-26 19:41:00 +00:00
//Manage request for edit or find element and titleblock
2017-05-01 11:42:55 +00:00
connect ( project_view , & ProjectView : : findElementRequired , this , & QETDiagramEditor : : findElementInPanel ) ;
connect ( project_view , & ProjectView : : editElementRequired , this , & QETDiagramEditor : : editElementInEditor ) ;
2012-01-25 07:29:50 +00:00
2014-12-26 19:41:00 +00:00
// display error messages sent by the project view
2012-07-13 07:21:19 +00:00
connect ( project_view , SIGNAL ( errorEncountered ( QString ) ) , this , SLOT ( showError ( const QString & ) ) ) ;
2014-01-18 19:04:39 +00:00
2014-12-26 19:41:00 +00:00
//We maximise the new window if the current window is inexistent or maximized
QWidget * current_window = workspace . activeSubWindow ( ) ;
bool maximise = ( ( ! current_window ) | | ( current_window - > windowState ( ) & Qt : : WindowMaximized ) ) ;
//Add the new window
QMdiSubWindow * sub_window = workspace . addSubWindow ( project_view ) ;
sub_window - > setWindowIcon ( project_view - > windowIcon ( ) ) ;
sub_window - > systemMenu ( ) - > clear ( ) ;
//Display the new window
if ( maximise ) project_view - > showMaximized ( ) ;
else project_view - > show ( ) ;
2008-07-20 11:37:31 +00:00
}
/**
@ return la liste des fichiers edites par cet editeur de schemas
*/
QList < QString > QETDiagramEditor : : editedFiles ( ) const {
QList < QString > edited_files_list ;
2017-02-05 16:18:50 +00:00
foreach ( ProjectView * project_view , openedProjects ( ) ) {
2009-04-03 19:30:25 +00:00
QString diagram_file ( project_view - > project ( ) - > filePath ( ) ) ;
2008-07-20 11:37:31 +00:00
if ( ! diagram_file . isEmpty ( ) ) {
edited_files_list < < QFileInfo ( diagram_file ) . canonicalFilePath ( ) ;
}
}
return ( edited_files_list ) ;
}
/**
@ param filepath Un chemin de fichier
Note : si filepath est une chaine vide , cette methode retourne 0.
2009-04-03 19:30:25 +00:00
@ return le ProjectView editant le fichier filepath , ou 0 si ce fichier n ' est
2008-07-20 11:37:31 +00:00
pas edite par cet editeur de schemas .
*/
2009-04-03 19:30:25 +00:00
ProjectView * QETDiagramEditor : : viewForFile ( const QString & filepath ) const {
2008-07-20 11:37:31 +00:00
if ( filepath . isEmpty ( ) ) return ( 0 ) ;
QString searched_can_file_path = QFileInfo ( filepath ) . canonicalFilePath ( ) ;
2013-01-04 14:11:03 +00:00
if ( searched_can_file_path . isEmpty ( ) ) {
// QFileInfo returns an empty path for non-existent files
return ( 0 ) ;
}
2017-02-05 16:18:50 +00:00
foreach ( ProjectView * project_view , openedProjects ( ) ) {
2009-04-03 19:30:25 +00:00
QString project_can_file_path = QFileInfo ( project_view - > project ( ) - > filePath ( ) ) . canonicalFilePath ( ) ;
if ( project_can_file_path = = searched_can_file_path ) {
return ( project_view ) ;
2008-07-20 11:37:31 +00:00
}
}
return ( 0 ) ;
}
2016-05-13 15:00:22 +00:00
/**
* @ brief QETDiagramEditor : : acessCurrentProject
* Retrieve current Project open in diagram editor
*/
ProjectView * QETDiagramEditor : : acessCurrentProject ( ) {
QMdiSubWindow * current_window = workspace . activeSubWindow ( ) ;
if ( ! current_window ) return ( 0 ) ;
QWidget * current_widget = current_window - > widget ( ) ;
if ( ! current_widget ) return ( 0 ) ;
if ( ProjectView * project_view = qobject_cast < ProjectView * > ( current_widget ) ) {
return ( project_view ) ;
}
return ( 0 ) ;
}
2016-08-18 16:30:24 +00:00
/**
* @ brief QETDiagramEditor : : drawGrid
* @ return true if the grid of folio must be displayed
*/
bool QETDiagramEditor : : drawGrid ( ) const {
return m_draw_grid - > isChecked ( ) ;
}
2016-05-13 15:00:22 +00:00
/**
* @ brief QETDiagramEditor : : acessCurrentDiagramView
* Retrieve current DiagramView used in diagram editor
*/
DiagramView * QETDiagramEditor : : acessCurrentDiagramView ( ) {
if ( ProjectView * project_view = currentProject ( ) ) {
return ( project_view - > currentDiagram ( ) ) ;
}
return ( 0 ) ;
}
2006-11-11 13:56:40 +00:00
/**
met a jour le menu " Fenetres "
*/
2007-09-29 12:54:01 +00:00
void QETDiagramEditor : : slot_updateWindowsMenu ( ) {
2006-10-27 15:47:22 +00:00
// nettoyage du menu
2017-02-05 16:18:50 +00:00
foreach ( QAction * a , windows_menu - > actions ( ) ) windows_menu - > removeAction ( a ) ;
2006-10-27 15:47:22 +00:00
// actions de fermeture
2007-09-29 12:54:01 +00:00
windows_menu - > addAction ( close_file ) ;
//windows_menu -> addAction(closeAllAct);
2006-10-27 15:47:22 +00:00
// actions de reorganisation des fenetres
2007-09-29 12:54:01 +00:00
windows_menu - > addSeparator ( ) ;
windows_menu - > addAction ( tile_window ) ;
windows_menu - > addAction ( cascade_window ) ;
2006-10-27 15:47:22 +00:00
2007-10-28 00:16:32 +00:00
// actions de deplacement entre les fenetres
2007-09-29 12:54:01 +00:00
windows_menu - > addSeparator ( ) ;
windows_menu - > addAction ( next_window ) ;
windows_menu - > addAction ( prev_window ) ;
2006-10-27 15:47:22 +00:00
// liste des fenetres
2009-04-03 19:30:25 +00:00
QList < ProjectView * > windows = openedProjects ( ) ;
2007-09-29 12:54:01 +00:00
2009-04-03 19:30:25 +00:00
tile_window - > setEnabled ( ! windows . isEmpty ( ) & & workspace . viewMode ( ) = = QMdiArea : : SubWindowView ) ;
cascade_window - > setEnabled ( ! windows . isEmpty ( ) & & workspace . viewMode ( ) = = QMdiArea : : SubWindowView ) ;
2007-10-28 00:16:32 +00:00
next_window - > setEnabled ( windows . count ( ) > 1 ) ;
prev_window - > setEnabled ( windows . count ( ) > 1 ) ;
2007-09-29 12:54:01 +00:00
if ( ! windows . isEmpty ( ) ) windows_menu - > addSeparator ( ) ;
2007-11-01 23:56:19 +00:00
QActionGroup * windows_actions = new QActionGroup ( this ) ;
2017-02-05 16:18:50 +00:00
foreach ( ProjectView * project_view , windows ) {
2009-04-03 19:30:25 +00:00
QString pv_title = project_view - > windowTitle ( ) ;
QAction * action = windows_menu - > addAction ( pv_title ) ;
2007-11-01 23:56:19 +00:00
windows_actions - > addAction ( action ) ;
2015-03-02 20:14:56 +00:00
action - > setStatusTip ( QString ( tr ( " Active le projet « %1 » " ) ) . arg ( pv_title ) ) ;
2006-10-27 15:47:22 +00:00
action - > setCheckable ( true ) ;
2009-04-03 19:30:25 +00:00
action - > setChecked ( project_view = = currentProject ( ) ) ;
2006-10-27 15:47:22 +00:00
connect ( action , SIGNAL ( triggered ( ) ) , & windowMapper , SLOT ( map ( ) ) ) ;
2009-04-03 19:30:25 +00:00
windowMapper . setMapping ( action , project_view ) ;
2006-10-27 15:47:22 +00:00
}
}
2006-10-28 19:39:43 +00:00
2007-02-01 01:07:26 +00:00
/**
Edite les informations du schema en cours
*/
2009-04-03 19:30:25 +00:00
void QETDiagramEditor : : editCurrentDiagramProperties ( ) {
if ( ProjectView * project_view = currentProject ( ) ) {
activateProject ( project_view ) ;
project_view - > editCurrentDiagramProperties ( ) ;
}
}
/**
Edite les proprietes du schema diagram
@ param diagram_view schema dont il faut editer les proprietes
*/
void QETDiagramEditor : : editDiagramProperties ( DiagramView * diagram_view ) {
if ( ProjectView * project_view = findProject ( diagram_view ) ) {
activateProject ( project_view ) ;
project_view - > editDiagramProperties ( diagram_view ) ;
}
}
/**
Edite les proprietes du schema diagram
@ param diagram schema dont il faut editer les proprietes
*/
void QETDiagramEditor : : editDiagramProperties ( Diagram * diagram ) {
if ( ProjectView * project_view = findProject ( diagram ) ) {
activateProject ( project_view ) ;
project_view - > editDiagramProperties ( diagram ) ;
2008-08-10 15:07:59 +00:00
}
2006-11-19 18:40:03 +00:00
}
2007-01-28 00:53:17 +00:00
2009-05-17 02:13:40 +00:00
/**
Edite les proprietes des objets selectionnes
*/
void QETDiagramEditor : : editSelectionProperties ( ) {
if ( DiagramView * dv = currentDiagram ( ) ) {
dv - > editSelectionProperties ( ) ;
}
}
2007-10-06 18:37:21 +00:00
/**
Reinitialise les conducteurs selectionnes
*/
void QETDiagramEditor : : slot_resetConductors ( ) {
if ( DiagramView * dv = currentDiagram ( ) ) {
dv - > resetConductors ( ) ;
}
}
2007-10-14 15:16:37 +00:00
2015-01-11 11:10:57 +00:00
/**
* @ brief QETDiagramEditor : : slot_autoConductor
* @ param ac
* Update the auto conductor status of current project ;
*/
void QETDiagramEditor : : slot_autoConductor ( bool ac )
{
if ( ProjectView * pv = currentProject ( ) )
pv - > project ( ) - > setAutoConductor ( ac ) ;
}
2009-04-03 19:30:25 +00:00
/**
Affiche les projets dans des fenetres .
*/
void QETDiagramEditor : : setWindowedMode ( ) {
workspace . setViewMode ( QMdiArea : : SubWindowView ) ;
windowed_view_mode - > setChecked ( true ) ;
slot_updateWindowsMenu ( ) ;
}
/**
Affiche les projets dans des onglets .
*/
void QETDiagramEditor : : setTabbedMode ( ) {
workspace . setViewMode ( QMdiArea : : TabbedView ) ;
tabbed_view_mode - > setChecked ( true ) ;
slot_updateWindowsMenu ( ) ;
}
2015-09-16 15:11:13 +00:00
/**
* @ brief QETDiagramEditor : : readSettings
* Read the settings
*/
void QETDiagramEditor : : readSettings ( )
{
QSettings settings ;
2007-11-12 15:21:14 +00:00
// dimensions et position de la fenetre
QVariant geometry = settings . value ( " diagrameditor/geometry " ) ;
if ( geometry . isValid ( ) ) restoreGeometry ( geometry . toByteArray ( ) ) ;
// etat de la fenetre (barres d'outils, docks...)
QVariant state = settings . value ( " diagrameditor/state " ) ;
if ( state . isValid ( ) ) restoreState ( state . toByteArray ( ) ) ;
2009-04-03 19:30:25 +00:00
// gestion des projets (onglets ou fenetres)
2009-04-05 12:33:20 +00:00
bool tabbed = settings . value ( " diagrameditor/viewmode " , " tabbed " ) = = " tabbed " ;
2009-04-03 19:30:25 +00:00
if ( tabbed ) {
setTabbedMode ( ) ;
} else {
setWindowedMode ( ) ;
}
2007-11-12 15:21:14 +00:00
}
2015-09-16 15:11:13 +00:00
/**
* @ brief QETDiagramEditor : : writeSettings
* Write the settings
*/
void QETDiagramEditor : : writeSettings ( )
{
QSettings settings ;
2007-11-12 15:21:14 +00:00
settings . setValue ( " diagrameditor/geometry " , saveGeometry ( ) ) ;
settings . setValue ( " diagrameditor/state " , saveState ( ) ) ;
}
2007-11-18 00:22:19 +00:00
2009-04-03 19:30:25 +00:00
/**
Active le schema passe en parametre
@ param diagram Schema a activer
*/
void QETDiagramEditor : : activateDiagram ( Diagram * diagram ) {
if ( QETProject * project = diagram - > project ( ) ) {
if ( ProjectView * project_view = findProject ( project ) ) {
activateWidget ( project_view ) ;
project_view - > showDiagram ( diagram ) ;
}
} else {
/// @todo gerer ce cas
}
}
/**
Active le projet passe en parametre
@ param project Projet a activer
*/
void QETDiagramEditor : : activateProject ( QETProject * project ) {
activateProject ( findProject ( project ) ) ;
}
/**
Active le projet passe en parametre
@ param project_view Projet a activer
*/
void QETDiagramEditor : : activateProject ( ProjectView * project_view ) {
if ( ! project_view ) return ;
activateWidget ( project_view ) ;
}
/**
Gere la fermeture d ' une ProjectView
@ param project_view ProjectView fermee
*/
void QETDiagramEditor : : projectWasClosed ( ProjectView * project_view ) {
QETProject * project = project_view - > project ( ) ;
if ( project ) {
pa - > elementsPanel ( ) . projectWasClosed ( project ) ;
2015-12-16 17:16:15 +00:00
m_element_collection_widget - > removeProject ( project ) ;
2014-11-27 18:46:30 +00:00
undo_group . removeStack ( project - > undoStack ( ) ) ;
2009-04-03 19:30:25 +00:00
QETApp : : unregisterProject ( project ) ;
}
project_view - > deleteLater ( ) ;
project - > deleteLater ( ) ;
}
/**
Edite les proprietes du projet courant .
*/
void QETDiagramEditor : : editCurrentProjectProperties ( ) {
editProjectProperties ( currentProject ( ) ) ;
}
/**
Edite les proprietes du projet project_view .
@ param project_view Vue sur le projet dont il faut editer les proprietes
*/
void QETDiagramEditor : : editProjectProperties ( ProjectView * project_view ) {
if ( ! project_view ) return ;
activateProject ( project_view ) ;
project_view - > editProjectProperties ( ) ;
}
/**
Edite les proprietes du projet project .
@ param project Projet dont il faut editer les proprietes
*/
void QETDiagramEditor : : editProjectProperties ( QETProject * project ) {
editProjectProperties ( findProject ( project ) ) ;
}
/**
Ajoute un nouveau schema au projet courant
*/
void QETDiagramEditor : : addDiagramToProject ( ) {
if ( ProjectView * current_project = currentProject ( ) ) {
current_project - > addNewDiagram ( ) ;
}
}
2014-09-18 18:12:05 +00:00
/**
* @ brief QETDiagramEditor : : addDiagramFolioListToProject
* Add new folio list to project
*/
2014-02-07 07:54:54 +00:00
void QETDiagramEditor : : addDiagramFolioListToProject ( ) {
2014-09-18 18:12:05 +00:00
if ( ProjectView * current_project = currentProject ( ) )
2014-12-12 13:27:13 +00:00
current_project - > addNewDiagramFolioList ( ) ;
2014-02-07 07:54:54 +00:00
}
2009-04-03 19:30:25 +00:00
/**
Ajoute un nouveau schema a un projet
@ param project Projet auquel il faut ajouter un schema
*/
void QETDiagramEditor : : addDiagramToProject ( QETProject * project ) {
if ( ! project ) return ;
// recupere le ProjectView visualisant ce projet
if ( ProjectView * project_view = findProject ( project ) ) {
// affiche le projet en question
activateProject ( project ) ;
// ajoute un schema au projet
project_view - > addNewDiagram ( ) ;
}
}
/**
Supprime un schema de son projet
@ param diagram Schema a supprimer
*/
void QETDiagramEditor : : removeDiagram ( Diagram * diagram ) {
if ( ! diagram ) return ;
// recupere le projet contenant le schema
if ( QETProject * diagram_project = diagram - > project ( ) ) {
// recupere la vue sur ce projet
if ( ProjectView * project_view = findProject ( diagram_project ) ) {
// affiche le schema en question
project_view - > showDiagram ( diagram ) ;
// supprime le schema
project_view - > removeDiagram ( diagram ) ;
}
}
}
2010-02-28 16:13:45 +00:00
/**
Change l ' ordre des schemas d ' un projet , en decalant le schema vers le haut /
la gauche
@ param diagram Schema a decaler vers le haut / la gauche
*/
void QETDiagramEditor : : moveDiagramUp ( Diagram * diagram ) {
if ( ! diagram ) return ;
// recupere le projet contenant le schema
if ( QETProject * diagram_project = diagram - > project ( ) ) {
if ( diagram_project - > isReadOnly ( ) ) return ;
// recupere la vue sur ce projet
if ( ProjectView * project_view = findProject ( diagram_project ) ) {
project_view - > moveDiagramUp ( diagram ) ;
}
}
}
/**
Change l ' ordre des schemas d ' un projet , en decalant le schema vers le bas /
la droite
@ param diagram Schema a decaler vers le bas / la droite
*/
void QETDiagramEditor : : moveDiagramDown ( Diagram * diagram ) {
if ( ! diagram ) return ;
// recupere le projet contenant le schema
if ( QETProject * diagram_project = diagram - > project ( ) ) {
if ( diagram_project - > isReadOnly ( ) ) return ;
// recupere la vue sur ce projet
if ( ProjectView * project_view = findProject ( diagram_project ) ) {
project_view - > moveDiagramDown ( diagram ) ;
}
}
}
2015-03-04 06:00:25 +00:00
/**
Change l ' ordre des schemas d ' un projet , en decalant le schema vers le haut /
la gauche en position 0
@ param diagram Schema a decaler vers le haut / la gauche en position 0
*/
void QETDiagramEditor : : moveDiagramUpTop ( Diagram * diagram ) {
if ( ! diagram ) return ;
// recupere le projet contenant le schema
if ( QETProject * diagram_project = diagram - > project ( ) ) {
if ( diagram_project - > isReadOnly ( ) ) return ;
// recupere la vue sur ce projet
if ( ProjectView * project_view = findProject ( diagram_project ) ) {
project_view - > moveDiagramUpTop ( diagram ) ;
}
}
}
2014-12-14 17:01:11 +00:00
/**
Change l ' ordre des schemas d ' un projet , en decalant le schema vers le haut /
la gauche x10
@ param diagram Schema a decaler vers le haut / la gauche x10
*/
void QETDiagramEditor : : moveDiagramUpx10 ( Diagram * diagram ) {
if ( ! diagram ) return ;
// recupere le projet contenant le schema
if ( QETProject * diagram_project = diagram - > project ( ) ) {
if ( diagram_project - > isReadOnly ( ) ) return ;
// recupere la vue sur ce projet
if ( ProjectView * project_view = findProject ( diagram_project ) ) {
project_view - > moveDiagramUpx10 ( diagram ) ;
}
}
}
/**
Change l ' ordre des schemas d ' un projet , en decalant le schema vers le bas /
la droite x10
@ param diagram Schema a decaler vers le bas / la droite x10
*/
void QETDiagramEditor : : moveDiagramDownx10 ( Diagram * diagram ) {
if ( ! diagram ) return ;
// recupere le projet contenant le schema
if ( QETProject * diagram_project = diagram - > project ( ) ) {
if ( diagram_project - > isReadOnly ( ) ) return ;
// recupere la vue sur ce projet
if ( ProjectView * project_view = findProject ( diagram_project ) ) {
project_view - > moveDiagramDownx10 ( diagram ) ;
}
}
}
2009-04-03 19:30:25 +00:00
/**
Nettoie le projet courant
*/
void QETDiagramEditor : : cleanCurrentProject ( ) {
if ( ProjectView * current_project = currentProject ( ) ) {
int clean_count = current_project - > cleanProject ( ) ;
if ( clean_count ) pa - > reloadAndFilter ( ) ;
}
}
2016-09-14 13:58:44 +00:00
void QETDiagramEditor : : reloadOldElementPanel ( ) {
pa - > reloadAndFilter ( ) ;
}
2013-04-11 09:35:10 +00:00
/**
* @ brief export nomemclature of schema
*/
void QETDiagramEditor : : nomenclatureProject ( ) {
//TODO: Test nomenclature CYRIL F.
2014-10-05 13:35:01 +00:00
nomenclature nomencl ( currentProject ( ) - > project ( ) , this ) ;
nomencl . saveToCSVFile ( ) ;
2013-04-11 09:35:10 +00:00
}
2009-04-03 19:30:25 +00:00
/**
Supprime le schema courant du projet courant
*/
void QETDiagramEditor : : removeDiagramFromProject ( ) {
if ( ProjectView * current_project = currentProject ( ) ) {
if ( DiagramView * current_diagram = current_project - > currentDiagram ( ) ) {
2014-02-10 11:48:05 +00:00
bool isFolioList = false ;
2014-02-11 05:10:16 +00:00
// if diagram to remove is a "folio list sheet", then set a flag.
2014-10-19 11:25:03 +00:00
if ( dynamic_cast < DiagramFolioList * > ( current_diagram - > diagram ( ) ) )
2014-02-10 11:48:05 +00:00
isFolioList = true ;
2014-02-11 05:10:16 +00:00
2009-04-03 19:30:25 +00:00
current_project - > removeDiagram ( current_diagram ) ;
2014-02-11 05:10:16 +00:00
// if the removed diagram was a folio sheet, then delete all the remaining folio sheets also.
2014-02-10 11:48:05 +00:00
if ( isFolioList ) {
2017-02-18 13:30:38 +00:00
foreach ( DiagramView * diag , current_project - > diagram_views ( ) ) {
2014-10-19 11:25:03 +00:00
if ( dynamic_cast < DiagramFolioList * > ( diag - > diagram ( ) ) ) {
2014-02-10 11:48:05 +00:00
current_project - > removeDiagram ( diag ) ;
}
}
2014-02-11 05:10:16 +00:00
// else if after diagram removal, the total diagram quantity becomes a factor of 58, then
// remove one (last) folio sheet.
2017-02-18 13:30:38 +00:00
} else if ( current_project - > diagram_views ( ) . size ( ) % 58 = = 0 ) {
foreach ( DiagramView * diag , current_project - > diagram_views ( ) ) {
2014-02-10 11:48:05 +00:00
DiagramFolioList * ptr = dynamic_cast < DiagramFolioList * > ( diag - > diagram ( ) ) ;
2014-02-10 13:58:30 +00:00
if ( ptr & & ptr - > getId ( ) = = current_project - > project ( ) - > getFolioSheetsQuantity ( ) - 1 ) {
2014-02-10 11:48:05 +00:00
current_project - > removeDiagram ( diag ) ;
}
}
}
2009-04-03 19:30:25 +00:00
}
}
}
/**
2014-12-26 19:41:00 +00:00
* @ brief QETDiagramEditor : : diagramWasAdded
* Manage the adding of diagram view in a project
* @ param dv , added diagram view
*/
void QETDiagramEditor : : diagramWasAdded ( DiagramView * dv )
{
2015-05-07 22:15:00 +00:00
connect ( dv , SIGNAL ( selectionChanged ( ) ) , this , SLOT ( selectionChanged ( ) ) ) ;
2014-12-26 19:41:00 +00:00
connect ( dv , SIGNAL ( modeChanged ( ) ) , this , SLOT ( slot_updateModeActions ( ) ) ) ;
2009-04-03 19:30:25 +00:00
}
2009-05-19 19:00:37 +00:00
/**
2017-05-01 11:42:55 +00:00
* @ brief QETDiagramEditor : : findElementInPanel
* Find the item for @ location in the element panel
* @ param location
*/
void QETDiagramEditor : : findElementInPanel ( const ElementsLocation & location )
{
m_element_collection_widget - > setCurrentLocation ( location ) ;
2009-05-19 19:00:37 +00:00
}
2009-07-08 09:41:20 +00:00
/**
Lance l ' editeur d ' element pour l ' element filename
@ param location Emplacement de l ' element a editer
*/
void QETDiagramEditor : : editElementInEditor ( const ElementsLocation & location ) {
2010-03-28 16:27:48 +00:00
QETApp : : instance ( ) - > openElementLocations ( QList < ElementsLocation > ( ) < < location ) ;
2009-07-08 09:41:20 +00:00
}
2013-02-12 18:37:08 +00:00
/**
Launch an element editor to edit the selected element in the current
diagram view .
*/
void QETDiagramEditor : : editSelectedElementInEditor ( ) {
if ( CustomElement * selected_element = currentCustomElement ( ) ) {
editElementInEditor ( selected_element - > location ( ) ) ;
}
}
2012-07-13 07:21:19 +00:00
/**
Show the error message contained in \ a result .
*/
void QETDiagramEditor : : showError ( const QETResult & result ) {
if ( result . isOk ( ) ) return ;
showError ( result . errorMessage ( ) ) ;
}
/**
Show the \ a error message .
*/
void QETDiagramEditor : : showError ( const QString & error ) {
if ( error . isEmpty ( ) ) return ;
2015-03-02 20:14:56 +00:00
QET : : QetMessageBox : : critical ( this , tr ( " Erreur " , " message box title " ) , error ) ;
2012-07-13 07:21:19 +00:00
}
2014-12-26 19:41:00 +00:00
/**
* @ brief QETDiagramEditor : : subWindowActivated
* Slot used to update menu and undo stack when subwindows of MDIarea was activated
* @ param subWindows
*/
void QETDiagramEditor : : subWindowActivated ( QMdiSubWindow * subWindows )
{
Q_UNUSED ( subWindows ) ;
slot_updateActions ( ) ;
slot_updateWindowsMenu ( ) ;
}
2015-05-07 22:15:00 +00:00
/**
* @ brief QETDiagramEditor : : selectionChanged
* This slot is called when a diagram selection was changed .
*/
void QETDiagramEditor : : selectionChanged ( )
{
slot_updateComplexActions ( ) ;
DiagramView * dv = currentDiagram ( ) ;
if ( dv & & dv - > diagram ( ) )
m_selection_properties_editor - > setDiagram ( dv - > diagram ( ) ) ;
}
2017-01-11 00:04:43 +00:00
///**
// * @brief QETDiagramEditor::activeUndoStackCleanChanged
// * Enable the QAction save_file when @clean is set to false
// * @clean at true do nothing;
// * @param clean
// */
//void QETDiagramEditor::activeUndoStackCleanChanged(bool clean) {
2017-01-10 14:56:34 +00:00
// if (!clean) {
2017-01-11 00:04:43 +00:00
// //save_file -> setEnabled(true);
2017-01-10 14:56:34 +00:00
// }
2017-01-11 00:04:43 +00:00
//}
2016-08-30 21:42:35 +00:00
/**
* @ brief QETDiagramEditor : : slot_generateTerminalBlock
*/
void QETDiagramEditor : : slot_generateTerminalBlock ( ) {
bool success ;
QProcess * process = new QProcess ( qApp ) ;
2016-08-30 22:42:23 +00:00
2016-08-30 21:42:35 +00:00
// If launched under control:
//connect(process, SIGNAL(errorOcurred(int error)), this, SLOT(slot_generateTerminalBlock_error()));
//process->start("qet_tb_generator");
2016-08-30 22:42:23 +00:00
2016-10-13 00:08:29 +00:00
# ifdef Q_OS_MAC
success = process - > startDetached ( " /Library/Frameworks/Python.framework/Versions/3.5/bin/qet_tb_generator " ) ;
# else
2016-08-30 21:42:35 +00:00
success = process - > startDetached ( " qet_tb_generator " ) ;
2016-10-13 00:08:29 +00:00
# endif
2016-08-30 21:42:35 +00:00
if ( ! success ) {
QMessageBox : : warning ( 0 ,
" Error launching plugin " ,
" To install the plugin qet_tb_generator \n Visit https://pypi.python.org/pypi/qet-tb-generator/ \n "
" \n "
" Requires python 3.5 or above. \n "
" >> First install on Linux \n "
" 1. check you have pip3 installed: pip3 --version. \n "
" If not install with: sudo apt-get install python3-pip \n "
" 2. Install the program: sudo pip3 install qet_tb_generator \n "
" 3. Run the program: qet_tb_generator \n "
" >> Update on Linux \n "
" sudo pip3 install --upgrade qet_tb_generator \n "
" \n "
" >> First install on Windows \n "
" 1. Install, if required, python 3.5 or above \n "
" 2. pip install qet_generator \n "
" >> Update on Windows \n "
" python -m pip install --upgrade qet_tb_generator \n "
2016-10-13 00:08:29 +00:00
" >> First install on macOSX \n "
" 1. Install, if required, python 3.5 or above \n "
" 2. Install tkinter with Tcl/Tk \n "
" 3. Visit https://qelectrotech.org/forum/viewtopic.php?pid=5674#p5674 \n "
" 2. pip3 install qet_generator \n "
" >> Update on macOSX \n "
" pip3 install --upgrade qet_tb_generator \n "
2016-08-30 21:42:35 +00:00
) ;
}
}