[qet] [3400] QET is open without diagram, and tool bar are disabled. |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/qet Archives
]
Revision: 3400
Author: blacksun
Date: 2014-10-26 12:57:38 +0100 (Sun, 26 Oct 2014)
Log Message:
-----------
QET is open without diagram, and tool bar are disabled.
Default properties is now a static method of the propertie class himself
Modified Paths:
--------------
trunk/sources/borderproperties.cpp
trunk/sources/borderproperties.h
trunk/sources/conductorproperties.cpp
trunk/sources/conductorproperties.h
trunk/sources/configpages.cpp
trunk/sources/exportdialog.cpp
trunk/sources/exportproperties.cpp
trunk/sources/exportproperties.h
trunk/sources/properties/xrefproperties.cpp
trunk/sources/properties/xrefproperties.h
trunk/sources/qetdiagrameditor.cpp
trunk/sources/qetdiagrameditor.h
trunk/sources/qetprintpreviewdialog.cpp
trunk/sources/qetproject.cpp
trunk/sources/titleblockproperties.cpp
trunk/sources/titleblockproperties.h
Added Paths:
-----------
trunk/sources/properties/reportproperties.cpp
trunk/sources/properties/reportproperties.h
Modified: trunk/sources/borderproperties.cpp
===================================================================
--- trunk/sources/borderproperties.cpp 2014-10-25 21:21:52 UTC (rev 3399)
+++ trunk/sources/borderproperties.cpp 2014-10-26 11:57:38 UTC (rev 3400)
@@ -16,6 +16,7 @@
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/
#include "borderproperties.h"
+#include "qetapp.h"
/**
Constructeur. Initialise un objet BorderProperties avec les proprietes par
@@ -120,3 +121,16 @@
rows_height = qRound(settings.value(prefix + "rowsize", rows_height).toDouble());
display_rows = settings.value(prefix + "displayrows", display_rows).toBool();
}
+
+/**
+ * @brief BorderProperties::defaultProperties
+ * @return the default properties stored in the setting file
+ */
+BorderProperties BorderProperties::defaultProperties() {
+ QSettings &settings = QETApp::settings();
+
+ BorderProperties def;
+ def.fromSettings(settings, "diagrameditor/default");
+
+ return(def);
+}
Modified: trunk/sources/borderproperties.h
===================================================================
--- trunk/sources/borderproperties.h 2014-10-25 21:21:52 UTC (rev 3399)
+++ trunk/sources/borderproperties.h 2014-10-26 11:57:38 UTC (rev 3400)
@@ -36,6 +36,8 @@
void fromXml(QDomElement &);
void toSettings(QSettings &, const QString & = QString()) const;
void fromSettings(QSettings &, const QString & = QString());
+
+ static BorderProperties defaultProperties();
// attributes
int columns_count; ///< Columns count
Modified: trunk/sources/conductorproperties.cpp
===================================================================
--- trunk/sources/conductorproperties.cpp 2014-10-25 21:21:52 UTC (rev 3399)
+++ trunk/sources/conductorproperties.cpp 2014-10-26 11:57:38 UTC (rev 3400)
@@ -16,6 +16,7 @@
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/
#include "conductorproperties.h"
+#include "qetapp.h"
/**
Constructeur par defaut
@@ -362,6 +363,19 @@
}
/**
+ * @brief ConductorProperties::defaultProperties
+ * @return the default properties stored in the setting file
+ */
+ConductorProperties ConductorProperties::defaultProperties() {
+ QSettings &settings = QETApp::settings();
+
+ ConductorProperties def;
+ def.fromSettings(settings, "diagrameditor/defaultconductor");
+
+ return(def);
+}
+
+/**
@param other l'autre ensemble de proprietes avec lequel il faut effectuer la comparaison
@return true si les deux ensembles de proprietes sont identiques, false sinon
*/
Modified: trunk/sources/conductorproperties.h
===================================================================
--- trunk/sources/conductorproperties.h 2014-10-25 21:21:52 UTC (rev 3399)
+++ trunk/sources/conductorproperties.h 2014-10-26 11:57:38 UTC (rev 3400)
@@ -98,6 +98,8 @@
void toSettings(QSettings &, const QString & = QString()) const;
void fromSettings(QSettings &, const QString & = QString());
static QString typeToString(ConductorType);
+
+ static ConductorProperties defaultProperties();
// operators
bool operator==(const ConductorProperties &) const;
Modified: trunk/sources/configpages.cpp
===================================================================
--- trunk/sources/configpages.cpp 2014-10-25 21:21:52 UTC (rev 3399)
+++ trunk/sources/configpages.cpp 2014-10-26 11:57:38 UTC (rev 3400)
@@ -20,13 +20,13 @@
#include "conductorpropertieswidget.h"
#include "titleblockpropertieswidget.h"
#include "qetapp.h"
-#include "qetdiagrameditor.h"
#include "bordertitleblock.h"
#include "qeticons.h"
#include "exportpropertieswidget.h"
#include "ui/reportpropertiewidget.h"
#include "ui/xrefpropertieswidget.h"
#include "qetproject.h"
+#include "reportproperties.h"
/**
* @brief NewDiagramPage::NewDiagramPage
@@ -42,15 +42,15 @@
//By default we set the global default properties
// dimensions by default for diagram
- bpw = new BorderPropertiesWidget(QETDiagramEditor::defaultBorderProperties());
+ bpw = new BorderPropertiesWidget(BorderProperties::defaultProperties());
// default titleblock properties
- ipw = new TitleBlockPropertiesWidget(QETDiagramEditor::defaultTitleBlockProperties(), true);
+ ipw = new TitleBlockPropertiesWidget(TitleBlockProperties::defaultProperties(), true);
// default conductor properties
- cpw = new ConductorPropertiesWidget(QETDiagramEditor::defaultConductorProperties());
+ cpw = new ConductorPropertiesWidget(ConductorProperties::defaultProperties());
// default propertie of report label
- rpw = new ReportPropertieWidget(QETDiagramEditor::defaultReportProperties());
+ rpw = new ReportPropertieWidget(ReportProperties::defaultProperties());
// default properties of xref
- xrefpw = new XRefPropertiesWidget(QETDiagramEditor::defaultXRefProperties(), this);
+ xrefpw = new XRefPropertiesWidget(XRefProperties::defaultProperties(), this);
//If there is a project, we edit his properties
if (m_project) {
@@ -353,7 +353,7 @@
*/
ExportConfigPage::ExportConfigPage(QWidget *parent) : ConfigPage(parent) {
// epw contient les options d'export
- epw = new ExportPropertiesWidget(QETDiagramEditor::defaultExportProperties());
+ epw = new ExportPropertiesWidget(ExportProperties::defaultExportProperties());
// layout vertical contenant le titre, une ligne horizontale et epw
QVBoxLayout *vlayout1 = new QVBoxLayout();
@@ -399,7 +399,7 @@
*/
PrintConfigPage::PrintConfigPage(QWidget *parent) : ConfigPage(parent) {
// epw contient les options d'export
- epw = new ExportPropertiesWidget(QETDiagramEditor::defaultPrintProperties());
+ epw = new ExportPropertiesWidget(ExportProperties::defaultPrintProperties());
epw -> setPrintingMode(true);
// layout vertical contenant le titre, une ligne horizontale et epw
Modified: trunk/sources/exportdialog.cpp
===================================================================
--- trunk/sources/exportdialog.cpp 2014-10-25 21:21:52 UTC (rev 3399)
+++ trunk/sources/exportdialog.cpp 2014-10-26 11:57:38 UTC (rev 3400)
@@ -22,7 +22,6 @@
#include "qeticons.h"
#include "qetmessagebox.h"
#include "exportpropertieswidget.h"
-#include "qetdiagrameditor.h"
#include "createdxf.h"
#include "conductorsegment.h"
#include "qetgraphicsitem/conductor.h"
@@ -48,7 +47,7 @@
project_ = project;
// recupere les parametres d'export definis dans la configuration de l'application
- ExportProperties default_export_properties = QETDiagramEditor::defaultExportProperties();
+ ExportProperties default_export_properties = ExportProperties::defaultExportProperties();
// on utilise le repertoire du projet a exporter si possible
if (!project_ -> filePath().isEmpty()) {
Modified: trunk/sources/exportproperties.cpp
===================================================================
--- trunk/sources/exportproperties.cpp 2014-10-25 21:21:52 UTC (rev 3399)
+++ trunk/sources/exportproperties.cpp 2014-10-26 11:57:38 UTC (rev 3400)
@@ -17,6 +17,7 @@
*/
#include "exportproperties.h"
#include <QDesktopServices>
+#include "qetapp.h"
/**
Constructeur par defaut :
@@ -74,9 +75,35 @@
draw_grid = settings.value(prefix + "drawgrid", false).toBool();
draw_border = settings.value(prefix + "drawborder", true ).toBool();
- draw_titleblock = settings.value(prefix + "drawtitleblock", true ).toBool();
+ draw_titleblock = settings.value(prefix + "drawtitleblock", true ).toBool();
draw_terminals = settings.value(prefix + "drawterminals", false).toBool();
draw_colored_conductors = settings.value(prefix + "drawcoloredconductors", true ).toBool();
exported_area = QET::diagramAreaFromString(settings.value(prefix + "area", "border").toString());
}
+
+/**
+ * @brief ExportProperties::defaultProperties
+ * @return the default properties stored in the setting file
+ */
+ExportProperties ExportProperties::defaultExportProperties() {
+ QSettings &settings = QETApp::settings();
+
+ ExportProperties def;
+ def.fromSettings(settings, "export/default");
+
+ return(def);
+}
+
+/**
+ * @brief ExportProperties::defaultPrintProperties
+ * @return the default properties stored in the setting file
+ */
+ExportProperties ExportProperties::defaultPrintProperties() {
+ QSettings &settings = QETApp::settings();
+
+ ExportProperties def;
+ def.fromSettings(settings, "print/default");
+
+ return(def);
+}
Modified: trunk/sources/exportproperties.h
===================================================================
--- trunk/sources/exportproperties.h 2014-10-25 21:21:52 UTC (rev 3399)
+++ trunk/sources/exportproperties.h 2014-10-26 11:57:38 UTC (rev 3400)
@@ -34,6 +34,9 @@
public:
void toSettings (QSettings &, const QString & = QString()) const;
void fromSettings(QSettings &, const QString & = QString());
+
+ static ExportProperties defaultExportProperties ();
+ static ExportProperties defaultPrintProperties ();
// attributes
public:
Added: trunk/sources/properties/reportproperties.cpp
===================================================================
--- trunk/sources/properties/reportproperties.cpp (rev 0)
+++ trunk/sources/properties/reportproperties.cpp 2014-10-26 11:57:38 UTC (rev 3400)
@@ -0,0 +1,31 @@
+/*
+ Copyright 2006-2014 The QElectroTech Team
+ 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/>.
+*/
+#include "reportproperties.h"
+#include "qetapp.h"
+
+ReportProperties::ReportProperties()
+{}
+
+/**
+ * @brief ReportProperties::defaultProperties
+ * @return the default properties stored in the setting file
+ */
+QString ReportProperties::defaultProperties() {
+ QSettings &settings= QETApp::settings();
+ return(settings.value("diagrameditor/defaultreportlabel", "%f-%l%c").toString());
+}
Added: trunk/sources/properties/reportproperties.h
===================================================================
--- trunk/sources/properties/reportproperties.h (rev 0)
+++ trunk/sources/properties/reportproperties.h 2014-10-26 11:57:38 UTC (rev 3400)
@@ -0,0 +1,31 @@
+/*
+ Copyright 2006-2014 The QElectroTech Team
+ 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/>.
+*/
+#ifndef REPORTPROPERTIES_H
+#define REPORTPROPERTIES_H
+
+#include <QString>
+
+class ReportProperties
+{
+ public:
+ ReportProperties();
+
+ static QString defaultProperties ();
+};
+
+#endif // REPORTPROPERTIES_H
Modified: trunk/sources/properties/xrefproperties.cpp
===================================================================
--- trunk/sources/properties/xrefproperties.cpp 2014-10-25 21:21:52 UTC (rev 3399)
+++ trunk/sources/properties/xrefproperties.cpp 2014-10-26 11:57:38 UTC (rev 3400)
@@ -16,6 +16,7 @@
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/
#include "xrefproperties.h"
+#include "qetapp.h"
/**
* @brief XRefProperties::XRefProperties
@@ -95,6 +96,28 @@
}
}
+/**
+ * @brief XRefProperties::defaultProperties
+ * @return the default properties stored in the setting file
+ * For the xref, there is 2 propreties.
+ * For coil, stored with the string "coil" in the returned QHash.
+ * For protection, stored with the string "protection" in the returned QHash.
+ */
+QHash<QString, XRefProperties> XRefProperties::defaultProperties() {
+ QHash <QString, XRefProperties> hash;
+ QStringList keys;
+ keys << "coil" << "protection";
+
+ foreach (QString key, keys) {
+ XRefProperties properties;
+ QString str("diagrameditor/defaultxref");
+ properties.fromSettings(QETApp::settings(), str += key);
+ hash.insert(key, properties);
+ }
+
+ return hash;
+}
+
bool XRefProperties::operator ==(const XRefProperties &xrp) const{
return (m_show_power_ctc == xrp.m_show_power_ctc &&
m_display == xrp.m_display &&
Modified: trunk/sources/properties/xrefproperties.h
===================================================================
--- trunk/sources/properties/xrefproperties.h 2014-10-25 21:21:52 UTC (rev 3399)
+++ trunk/sources/properties/xrefproperties.h 2014-10-26 11:57:38 UTC (rev 3400)
@@ -45,6 +45,8 @@
virtual void toXml (QDomElement &xml_element) const;
virtual void fromXml (const QDomElement &xml_element);
+ static QHash<QString, XRefProperties> defaultProperties();
+
bool operator == (const XRefProperties &xrp) const;
bool operator != (const XRefProperties &xrp) const;
Modified: trunk/sources/qetdiagrameditor.cpp
===================================================================
--- trunk/sources/qetdiagrameditor.cpp 2014-10-25 21:21:52 UTC (rev 3399)
+++ trunk/sources/qetdiagrameditor.cpp 2014-10-26 11:57:38 UTC (rev 3400)
@@ -38,6 +38,7 @@
#include "dveventaddimage.h"
#include "dveventaddshape.h"
#include "dveventaddtext.h"
+#include "reportproperties.h"
#include "ui/dialogautonum.h"
@@ -82,48 +83,12 @@
// barre de statut de la fenetre
statusBar() -> showMessage(tr("QElectroTech", "status bar message"));
- // ajout du panel d'Elements en tant que QDockWidget
- qdw_pa = new QDockWidget(tr("Panel d'\351l\351ments", "dock title"), this);
- qdw_pa -> setObjectName("elements panel");
- qdw_pa -> setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
- qdw_pa -> setFeatures(QDockWidget::AllDockWidgetFeatures);
- qdw_pa -> setMinimumWidth(160);
- qdw_pa -> setWidget(pa = new ElementsPanelWidget(qdw_pa));
+ setUpElementsPanel();
+ setUpUndoStack();
+ setUpActions();
+ setUpToolBar();
+ setUpMenu();
- connect(pa, SIGNAL(requestForDiagram(Diagram *)), this, SLOT(activateDiagram(Diagram *)));
- 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(requestForDiagramPropertiesEdition(Diagram *)), this, SLOT(editDiagramProperties(Diagram *)));
- connect(pa, SIGNAL(requestForNewDiagram(QETProject *)), this, SLOT(addDiagramToProject(QETProject *)));
- 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 *)));
-
- qdw_undo = new QDockWidget(tr("Annulations", "dock title"));
- qdw_undo -> setObjectName("diagram_undo");
- qdw_pa -> setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
- qdw_undo -> setFeatures(QDockWidget::AllDockWidgetFeatures);
- qdw_undo -> setMinimumWidth(160);
- tabifyDockWidget(qdw_pa, qdw_undo);
- QUndoView *undo_view = new QUndoView(&undo_group, this);
- undo_view -> setEmptyLabel(tr("Aucune modification"));
- undo_view -> setStatusTip(tr("Cliquez sur une action pour revenir en arri\350re dans l'\351dition de votre sch\351ma", "Status tip"));
- undo_view -> setWhatsThis(tr("Ce panneau liste les diff\351rentes actions effectu\351es sur le sch\351ma courant. Cliquer sur une action permet de revenir \340 l'\351tat du sch\351ma juste apr\350s son application.", "\"What's this\" tip"));
- qdw_undo -> setWidget(undo_view);
-
- addDockWidget(Qt::LeftDockWidgetArea, qdw_undo);
- tabifyDockWidget(qdw_undo, qdw_pa);
-
- // mise en place des actions
- actions();
-
- // mise en place de la barre d'outils
- toolbar();
-
- // mise en place des menus
- menus();
-
// la fenetre est maximisee par defaut
setMinimumSize(QSize(500, 350));
setWindowState(Qt::WindowMaximized);
@@ -150,6 +115,8 @@
}
}
}
+
+ slot_updateActions();
// si aucun schema n'a ete ouvert jusqu'a maintenant, on ouvre un nouveau schema
//if (!opened_projects) newProject();
@@ -162,43 +129,63 @@
}
/**
- Permet de quitter l'application lors de la fermeture de la fenetre principale
- @param qce Le QCloseEvent correspondant a l'evenement de fermeture
-*/
-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
- foreach(ProjectView *project, openedProjects()) {
- if (!closeProject(project)) {
- can_quit = false;
- qce -> ignore();
- break;
- }
- }
- }
- if (can_quit) {
- writeSettings();
- setAttribute(Qt::WA_DeleteOnClose);
- qce -> accept();
- }
+ * @brief QETDiagramEditor::setUpElementsPanel
+ * Setup the element panel and element panel widget
+ */
+void QETDiagramEditor::setUpElementsPanel() {
+ //Add the element panel as a QDockWidget
+ qdw_pa = new QDockWidget(tr("Panel d'\351l\351ments", "dock title"), this);
+
+ qdw_pa -> setObjectName ("elements panel");
+ qdw_pa -> setAllowedAreas (Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
+ qdw_pa -> setFeatures (QDockWidget::AllDockWidgetFeatures);
+ qdw_pa -> setMinimumWidth (160);
+ qdw_pa -> setWidget (pa = new ElementsPanelWidget(qdw_pa));
+
+
+ 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 *)));
}
/**
- Mise en place des actions
-*/
-void QETDiagramEditor::actions() {
+ * @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"));
+ undo_view -> setStatusTip (tr("Cliquez sur une action pour revenir en arri\350re dans l'\351dition de votre sch\351ma", "Status tip"));
+ undo_view -> setWhatsThis (tr("Ce panneau liste les diff\351rentes actions effectu\351es sur le sch\351ma courant. Cliquer sur une action permet de revenir \340 l'\351tat du sch\351ma juste apr\350s son application.", "\"What's this\" tip"));
+
+ 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);
+}
+
+/**
+ * @brief QETDiagramEditor::setUpActions
+ * Set up all Qaction
+ */
+void QETDiagramEditor::setUpActions() {
// icones et labels
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);
-
+
undo = undo_group.createUndoAction(this, tr("Annuler"));
undo -> setIcon(QET::Icons::EditUndo);
redo = undo_group.createRedoAction(this, tr("Refaire"));
@@ -222,7 +209,7 @@
cascade_window = new QAction( tr("&Cascade"), this);
next_window = new QAction( tr("Projet suivant"), this);
prev_window = new QAction( tr("Projet pr\351c\351dent"), this);
-
+
///Files action///
QAction *new_file = m_file_actions_group.addAction( QET::Icons::DocumentNew, tr("&Nouveau") );
QAction *open_file = m_file_actions_group.addAction( QET::Icons::DocumentOpen, tr("&Ouvrir") );
@@ -368,12 +355,12 @@
cut -> setShortcut(QKeySequence::Cut);
copy -> setShortcut(QKeySequence::Copy);
paste -> setShortcut(QKeySequence::Paste);
-
+
prj_add_diagram -> setShortcut(QKeySequence(tr("Ctrl+T")));
-
+
next_window -> setShortcut(QKeySequence::NextChild);
prev_window -> setShortcut(QKeySequence::PreviousChild);
-
+
// affichage dans la barre de statut
export_diagram -> setStatusTip(tr("Exporte le sch\351ma courant dans un autre format", "status bar tip"));
print -> setStatusTip(tr("Imprime le sch\351ma courant", "status bar tip"));
@@ -385,35 +372,35 @@
paste -> setStatusTip(tr("Place les \351l\351ments du presse-papier sur le sch\351ma", "status bar tip"));
conductor_reset -> setStatusTip(tr("Recalcule les chemins des conducteurs sans tenir compte des modifications", "status bar tip"));
infos_diagram -> setStatusTip(tr("\311dite les informations affich\351es par le cartouche", "status bar tip"));
-
+
windowed_view_mode -> setStatusTip(tr("Pr\351sente les diff\351rents projets ouverts dans des sous-fen\352tres", "status bar tip"));
tabbed_view_mode -> setStatusTip(tr("Pr\351sente les diff\351rents projets ouverts des onglets", "status bar tip"));
-
+
mode_selection -> setStatusTip(tr("Permet de s\351lectionner les \351l\351ments", "status bar tip"));
mode_visualise -> setStatusTip(tr("Permet de visualiser le sch\351ma sans pouvoir le modifier", "status bar tip"));
-
+
tile_window -> setStatusTip(tr("Dispose les fen\352tres en mosa\357que", "status bar tip"));
cascade_window -> setStatusTip(tr("Dispose les fen\352tres en cascade", "status bar tip"));
next_window -> setStatusTip(tr("Active le projet suivant", "status bar tip"));
prev_window -> setStatusTip(tr("Active le projet pr\351c\351dent", "status bar tip"));
-
+
// traitements speciaux
windowed_view_mode -> setCheckable(true);
tabbed_view_mode -> setCheckable(true);
mode_selection -> setCheckable(true);
mode_visualise -> setCheckable(true);
mode_selection -> setChecked(true);
-
+
grp_visu_sel = new QActionGroup(this);
grp_visu_sel -> addAction(mode_selection);
grp_visu_sel -> addAction(mode_visualise);
grp_visu_sel -> setExclusive(true);
-
+
grp_view_mode = new QActionGroup(this);
grp_view_mode -> addAction(windowed_view_mode);
grp_view_mode -> addAction(tabbed_view_mode);
grp_view_mode -> setExclusive(true);
-
+
// connexion a des slots
connect(quit_editor, SIGNAL(triggered()), this, SLOT(close()) );
connect(windowed_view_mode, SIGNAL(triggered()), this, SLOT(setWindowedMode()) );
@@ -440,41 +427,70 @@
}
/**
- Gere les evenements du l'editeur de schema
- Reimplemente ici pour :
- * eviter un conflit sur le raccourci clavier "Ctrl+W" (QKeySequence::Close)
- @param e Evenement
-*/
-bool QETDiagramEditor::event(QEvent *e) {
- if (e -> type() == QEvent::ShortcutOverride) {
- QKeyEvent *shortcut_event = static_cast<QKeyEvent *>(e);
- if (shortcut_event && shortcut_event -> matches(QKeySequence::Close)) {
- close_file -> trigger();
- e -> accept();
- return(true);
- }
- }
- return(QETMainWindow::event(e));
+ * @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");
+
+ diagram_bar = new QToolBar(tr("Sch\351ma"), this);
+ 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);
+ main_bar -> addAction(selection_prop);
+
+ // Modes selection / visualisation et zoom
+ view_bar -> addAction(mode_selection);
+ view_bar -> addAction(mode_visualise);
+ view_bar -> addSeparator();
+ view_bar -> addActions(m_zoom_action_toolBar);
+
+ diagram_bar -> addAction(infos_diagram);
+ diagram_bar -> addAction(conductor_reset);
+
+ 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);
}
/**
- Mise en place des menus
-*/
-void QETDiagramEditor::menus() {
-
+ * @brief QETDiagramEditor::setUpMenu
+ */
+void QETDiagramEditor::setUpMenu() {
+
QMenu *menu_fichier = new QMenu(tr("&Fichier"));
QMenu *menu_edition = new QMenu(tr("&\311dition"));
QMenu *menu_project = new QMenu(tr("&Projet"));
QMenu *menu_affichage = new QMenu(tr("Afficha&ge"));
//QMenu *menu_outils = new QMenu(tr("O&utils"));
windows_menu = new QMenu(tr("Fe&n\352tres"));
-
+
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);
-
+
// File menu
QMenu *recentfile = menu_fichier -> addMenu(QET::Icons::DocumentOpenRecent, tr("&R\351cemment ouverts"));
recentfile->addActions(QETApp::projectsRecentFiles()->menu()->actions());
@@ -487,7 +503,7 @@
menu_fichier -> addAction(print);
menu_fichier -> addSeparator();
menu_fichier -> addAction(quit_editor);
-
+
// menu Edition
menu_edition -> addAction(undo);
menu_edition -> addAction(redo);
@@ -504,7 +520,7 @@
menu_edition -> addSeparator();
menu_edition -> addAction(infos_diagram);
menu_edition -> addActions(m_row_column_actions_group.actions());
-
+
// menu Projet
menu_project -> addAction(prj_edit_prop);
menu_project -> addAction(prj_add_diagram);
@@ -513,19 +529,19 @@
menu_project -> addSeparator();
menu_project -> addAction(prj_diagramList);
menu_project -> addAction(prj_nomenclature);
-
+
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\351ma"));
qdw_pa -> toggleViewAction() -> setStatusTip(tr("Affiche ou non le panel d'appareils"));
qdw_undo -> toggleViewAction() -> setStatusTip(tr("Affiche ou non la liste des modifications"));
-
+
// menu Affichage
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);
-
+
menu_affichage -> addSeparator();
menu_affichage -> addAction(mode_selection);
menu_affichage -> addAction(mode_visualise);
@@ -537,50 +553,50 @@
}
/**
- Mise en place de la barre d'outils
+ Permet de quitter l'application lors de la fermeture de la fenetre principale
+ @param qce Le QCloseEvent correspondant a l'evenement de fermeture
*/
-void QETDiagramEditor::toolbar() {
- main_bar = new QToolBar(tr("Outils"), this);
- main_bar -> setObjectName("toolbar");
-
- view_bar = new QToolBar(tr("Affichage"), this);
- view_bar -> setObjectName("display");
-
- diagram_bar = new QToolBar(tr("Sch\351ma"), this);
- 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);
- main_bar -> addAction(selection_prop);
-
- // Modes selection / visualisation et zoom
- view_bar -> addAction(mode_selection);
- view_bar -> addAction(mode_visualise);
- view_bar -> addSeparator();
- view_bar -> addActions(m_zoom_action_toolBar);
-
- diagram_bar -> addAction(infos_diagram);
- diagram_bar -> addAction(conductor_reset);
+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
+ foreach(ProjectView *project, openedProjects()) {
+ if (!closeProject(project)) {
+ can_quit = false;
+ qce -> ignore();
+ break;
+ }
+ }
+ }
+ if (can_quit) {
+ writeSettings();
+ setAttribute(Qt::WA_DeleteOnClose);
+ qce -> accept();
+ }
+}
- 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);
+/**
+ Gere les evenements du l'editeur de schema
+ Reimplemente ici pour :
+ * eviter un conflit sur le raccourci clavier "Ctrl+W" (QKeySequence::Close)
+ @param e Evenement
+*/
+bool QETDiagramEditor::event(QEvent *e) {
+ if (e -> type() == QEvent::ShortcutOverride) {
+ QKeyEvent *shortcut_event = static_cast<QKeyEvent *>(e);
+ if (shortcut_event && shortcut_event -> matches(QKeySequence::Close)) {
+ close_file -> trigger();
+ e -> accept();
+ return(true);
+ }
+ }
+ return(QETMainWindow::event(e));
}
/**
@@ -607,11 +623,11 @@
*/
void QETDiagramEditor::save() {
if (ProjectView *project_view = currentProject()) {
- QETResult save_file = project_view -> save();
- if (save_file.isOk()) {
+ QETResult saved = project_view -> save();
+ if (saved.isOk()) {
QETApp::projectsRecentFiles() -> fileWasOpened(project_view -> project() -> filePath());
} else {
- showError(save_file);
+ showError(saved);
}
}
}
@@ -641,11 +657,11 @@
QETProject *new_project = new QETProject(0);
// Set default properties for new diagram
- new_project -> setDefaultBorderProperties (defaultBorderProperties());
- new_project -> setDefaultConductorProperties (defaultConductorProperties());
- new_project -> setDefaultTitleBlockProperties (defaultTitleBlockProperties());
- new_project -> setDefaultReportProperties (defaultReportProperties());
- new_project -> setDefaultXRefProperties (defaultXRefProperties());
+ 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());
// add new diagram
new_project -> addNewDiagram();
@@ -1120,6 +1136,7 @@
void QETDiagramEditor::slot_updateActions() {
DiagramView *dv = currentDiagram();
ProjectView *pv = currentProject();
+
bool opened_project = pv;
bool opened_diagram = dv;
bool editable_project = (pv && !pv -> project() -> isReadOnly());
@@ -1159,8 +1176,8 @@
ProjectView *pv = currentProject();
if (pv && can_update_actions) {
undo_group.setActiveStack(pv->project()->undoStack());
- undo -> setEnabled(undo_group.canUndo());
- redo -> setEnabled(undo_group.canRedo());
+ undo -> setEnabled (undo_group.canUndo());
+ redo -> setEnabled (undo_group.canRedo());
}
}
@@ -1282,8 +1299,10 @@
// lie les schemas du projet a l'editeur :
// quand on change de schemas a l'interieur d'un projet, on met a jour les menus
- connect(project_view, SIGNAL(diagramActivated(DiagramView *)), this, SLOT(slot_updateWindowsMenu()));
- connect(project_view, SIGNAL(diagramActivated(DiagramView *)), this, SLOT(slot_updateActions()));
+ connect(project_view, SIGNAL(diagramActivated(DiagramView *)), this, SLOT(slot_updateWindowsMenu()));
+ connect(project_view, SIGNAL(diagramActivated(DiagramView *)), this, SLOT(slot_updateActions()));
+ //connect(project_view->project(), SIGNAL(projectModified(QETProject*,bool)), save_file, SLOT(setEnabled(bool)));
+
foreach(DiagramView *dv, project_view -> diagrams()) {
diagramWasAdded(dv);
}
@@ -1950,99 +1969,3 @@
void QETDiagramEditor::addItemFinish() {
m_add_item_actions_group.checkedAction()->setChecked(false);
}
-
-/**
- @return Les proprietes par defaut pour le cartouche d'un schema
-*/
-TitleBlockProperties QETDiagramEditor::defaultTitleBlockProperties() {
- // accede a la configuration de l'application
- QSettings &settings = QETApp::settings();
-
- TitleBlockProperties def;
- // lit le cartouche par defaut dans la configuration
- def.fromSettings(settings, "diagrameditor/default");
-
- return(def);
-}
-
-/**
- @return Les dimensions par defaut d'un schema
-*/
-BorderProperties QETDiagramEditor::defaultBorderProperties() {
- // accede a la configuration de l'application
- QSettings &settings = QETApp::settings();
-
- BorderProperties def;
- // lit les dimensions par defaut dans la configuration
- def.fromSettings(settings, "diagrameditor/default");
-
- return(def);
-}
-
-/**
- @return Les proprietes par defaut d'un conducteur
-*/
-ConductorProperties QETDiagramEditor::defaultConductorProperties() {
- // accede a la configuration de l'application
- QSettings &settings = QETApp::settings();
-
- ConductorProperties def;
- // lit les caracteristiques des conducteurs par defaut dans la configuration
- def.fromSettings(settings, "diagrameditor/defaultconductor");
-
- return(def);
-}
-
-/**
- @return Les parametres d'export par defaut pour un schema
-*/
-ExportProperties QETDiagramEditor::defaultExportProperties() {
- // accede a la configuration de l'application
- QSettings &settings = QETApp::settings();
-
- ExportProperties def;
- // lit les caracteristiques des conducteurs par defaut dans la configuration
- def.fromSettings(settings, "export/default");
-
- return(def);
-}
-
-/**
- @return Les parametres d'impression par defaut pour un schema
-*/
-ExportProperties QETDiagramEditor::defaultPrintProperties() {
- // accede a la configuration de l'application
- QSettings &settings = QETApp::settings();
-
- ExportProperties def;
- // lit les caracteristiques des conducteurs par defaut dans la configuration
- def.fromSettings(settings, "print/default");
-
- return(def);
-}
-
-/**
- * @brief QETDiagramEditor::defaultReportProperties
- * @return default folio report properties
- */
-QString QETDiagramEditor::defaultReportProperties() {
- QSettings &settings= QETApp::settings();
- return(settings.value("diagrameditor/defaultreportlabel", "%f-%l%c").toString());
-}
-
-/**
- * @brief QETDiagramEditor::defaultXRefProperties
- * @return the default setting for Xref
- */
-QHash <QString, XRefProperties> QETDiagramEditor::defaultXRefProperties() {
- QHash <QString, XRefProperties> hash;
- QStringList keys;
- keys << "coil" << "protection";
- foreach (QString key, keys) {
- XRefProperties properties;
- QString str("diagrameditor/defaultxref");
- properties.fromSettings(QETApp::settings(), str += key);
- hash.insert(key, properties);
- }
- return hash;
-}
Modified: trunk/sources/qetdiagrameditor.h
===================================================================
--- trunk/sources/qetdiagrameditor.h 2014-10-25 21:21:52 UTC (rev 3399)
+++ trunk/sources/qetdiagrameditor.h 2014-10-26 11:57:38 UTC (rev 3400)
@@ -19,11 +19,6 @@
#define QET_DIAGRAM_EDITOR_H
#include <QtGui>
#include "qetmainwindow.h"
-#include "borderproperties.h"
-#include "conductorproperties.h"
-#include "titleblockproperties.h"
-#include "exportproperties.h"
-#include "properties/xrefproperties.h"
class QETProject;
class QETResult;
@@ -44,11 +39,18 @@
// constructors, destructor
public:
- QETDiagramEditor(const QStringList & = QStringList(), QWidget * = 0);
- virtual ~QETDiagramEditor();
+ QETDiagramEditor(const QStringList & = QStringList(), QWidget * = 0);
+ virtual ~QETDiagramEditor();
private:
- QETDiagramEditor(const QETDiagramEditor &);
+ QETDiagramEditor(const QETDiagramEditor &);
+
+ private:
+ void setUpElementsPanel ();
+ void setUpUndoStack ();
+ void setUpActions ();
+ void setUpToolBar ();
+ void setUpMenu ();
// methods
public:
@@ -59,16 +61,9 @@
QList<DiagramView *> projectViews() const;
QList<QString> editedFiles() const;
ProjectView *viewForFile(const QString &) const;
- static TitleBlockProperties defaultTitleBlockProperties();
- static BorderProperties defaultBorderProperties();
- static ConductorProperties defaultConductorProperties();
- static ExportProperties defaultExportProperties();
- static ExportProperties defaultPrintProperties();
- static QString defaultReportProperties();
- static QHash<QString, XRefProperties> defaultXRefProperties();
protected:
- void actions();
+ //void actions();
virtual bool event(QEvent *);
private:
@@ -83,9 +78,6 @@
ProjectView *findProject(const QString &) const;
QMdiSubWindow *subWindowForWidget(QWidget *) const;
- void menus();
- void toolbar();
-
public slots:
void printDialog();
void exportDialog();
Modified: trunk/sources/qetprintpreviewdialog.cpp
===================================================================
--- trunk/sources/qetprintpreviewdialog.cpp 2014-10-25 21:21:52 UTC (rev 3399)
+++ trunk/sources/qetprintpreviewdialog.cpp 2014-10-26 11:57:38 UTC (rev 3400)
@@ -19,7 +19,6 @@
#include "diagramschooser.h"
#include "exportproperties.h"
#include "exportpropertieswidget.h"
-#include "qetdiagrameditor.h"
#include "qeticons.h"
/**
@@ -253,7 +252,7 @@
fit_diagram_to_page_ -> setChecked(true);
// recupere les parametres d'export definis dans la configuration de l'application
- ExportProperties default_print_properties = QETDiagramEditor::defaultPrintProperties();
+ ExportProperties default_print_properties = ExportProperties::defaultPrintProperties();
render_properties_ = new ExportPropertiesWidget(default_print_properties);
render_properties_ -> setPrintingMode(true);
Modified: trunk/sources/qetproject.cpp
===================================================================
--- trunk/sources/qetproject.cpp 2014-10-25 21:21:52 UTC (rev 3399)
+++ trunk/sources/qetproject.cpp 2014-10-26 11:57:38 UTC (rev 3400)
@@ -22,7 +22,6 @@
#include "xmlelementscollection.h"
#include "elementscategory.h"
#include "qetapp.h"
-#include "qetdiagrameditor.h"
#include "qetresult.h"
#include "integrationmoveelementshandler.h"
#include "movetemplateshandler.h"
@@ -31,6 +30,7 @@
#include "titleblocktemplate.h"
#include "ui/dialogwaiting.h"
#include "numerotationcontext.h"
+#include "reportproperties.h"
QString QETProject::integration_category_name = "import";
@@ -1204,11 +1204,11 @@
QDomElement newdiagrams_elmt = newdiagrams_nodes.at(0).toElement();
// By default, use value find in the global conf of QElectroTech
- default_border_properties_ = QETDiagramEditor::defaultBorderProperties();
- default_titleblock_properties_ = QETDiagramEditor::defaultTitleBlockProperties();
- default_conductor_properties_ = QETDiagramEditor::defaultConductorProperties();
- default_report_properties_ = QETDiagramEditor::defaultReportProperties();
- m_default_xref_properties = QETDiagramEditor::defaultXRefProperties();
+ default_border_properties_ = BorderProperties:: defaultProperties();
+ default_titleblock_properties_ = TitleBlockProperties::defaultProperties();
+ default_conductor_properties_ = ConductorProperties:: defaultProperties();
+ default_report_properties_ = ReportProperties:: defaultProperties();
+ m_default_xref_properties = XRefProperties:: defaultProperties();
//Read values indicate in project
QDomElement border_elmt, titleblock_elmt, conductors_elmt, report_elmt, xref_elmt, conds_autonums;
Modified: trunk/sources/titleblockproperties.cpp
===================================================================
--- trunk/sources/titleblockproperties.cpp 2014-10-25 21:21:52 UTC (rev 3399)
+++ trunk/sources/titleblockproperties.cpp 2014-10-26 11:57:38 UTC (rev 3400)
@@ -17,6 +17,7 @@
*/
#include "titleblockproperties.h"
#include "qet.h"
+#include "qetapp.h"
/**
Constructeur. Initialise un objet TitleBlockProperties avec tous les champs
@@ -131,6 +132,19 @@
}
/**
+ * @brief TitleBlockProperties::defaultProperties
+ * Return the default properties stored in the setting file
+ */
+TitleBlockProperties TitleBlockProperties::defaultProperties() {
+ QSettings &settings = QETApp::settings();
+
+ TitleBlockProperties def;
+ def.fromSettings(settings, "diagrameditor/default");
+
+ return(def);
+}
+
+/**
@return La date a utiliser
*/
QDate TitleBlockProperties::finalDate() const {
Modified: trunk/sources/titleblockproperties.h
===================================================================
--- trunk/sources/titleblockproperties.h 2014-10-25 21:21:52 UTC (rev 3399)
+++ trunk/sources/titleblockproperties.h 2014-10-26 11:57:38 UTC (rev 3400)
@@ -17,7 +17,6 @@
*/
#ifndef TITLEBLOCK_PROPERTIES_H
#define TITLEBLOCK_PROPERTIES_H
-#include <QtCore>
#include <QtXml>
#include "diagramcontext.h"
/**
@@ -42,6 +41,8 @@
void fromXml(const QDomElement &);
void toSettings(QSettings &, const QString & = QString()) const;
void fromSettings(QSettings &, const QString & = QString());
+
+ static TitleBlockProperties defaultProperties();
QDate finalDate() const ;