From c7aaf5b5094a1791bea567dbf52d572ac483e98d Mon Sep 17 00:00:00 2001 From: blacksun Date: Fri, 11 Apr 2014 09:51:21 +0000 Subject: [PATCH] -add class for store Xref properties -add widget for edit it -make link betwen QET -> QETproject -> Diagram, for transmit the xrefproperties -xrefpropertie can save/load to xml and setting. -XRefItem don't use the properties yet git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@2983 bfdf4180-ca20-0410-9c96-a3a8aa849046 --- qelectrotech.pro | 13 ++-- sources/configpages.cpp | 8 +++ sources/configpages.h | 5 +- sources/diagram.cpp | 15 ++-- sources/diagram.h | 5 +- sources/projectconfigpages.cpp | 39 +++++++---- sources/projectconfigpages.h | 2 + sources/properties/propertiesinterface.cpp | 22 ++++++ sources/properties/propertiesinterface.h | 41 +++++++++++ sources/properties/xrefproperties.cpp | 74 ++++++++++++++++++++ sources/properties/xrefproperties.h | 47 +++++++++++++ sources/qetdiagrameditor.cpp | 29 +++++--- sources/qetdiagrameditor.h | 5 +- sources/qetproject.cpp | 77 +++++++++++++-------- sources/qetproject.h | 6 ++ sources/ui/xrefpropertieswidget.cpp | 80 ++++++++++++++++++++++ sources/ui/xrefpropertieswidget.h | 53 ++++++++++++++ sources/ui/xrefpropertieswidget.ui | 41 +++++++++++ 18 files changed, 498 insertions(+), 64 deletions(-) create mode 100644 sources/properties/propertiesinterface.cpp create mode 100644 sources/properties/propertiesinterface.h create mode 100644 sources/properties/xrefproperties.cpp create mode 100644 sources/properties/xrefproperties.h create mode 100644 sources/ui/xrefpropertieswidget.cpp create mode 100644 sources/ui/xrefpropertieswidget.h create mode 100644 sources/ui/xrefpropertieswidget.ui diff --git a/qelectrotech.pro b/qelectrotech.pro index 5fbade5d9..097529ef8 100644 --- a/qelectrotech.pro +++ b/qelectrotech.pro @@ -61,12 +61,16 @@ DEFINES += QET_ALLOW_OVERRIDE_CD_OPTION TEMPLATE = app DEPENDPATH += . -INCLUDEPATH += sources sources/editor sources/titleblock sources/ui sources/qetgraphicsitem sources/richtext sources/factory +INCLUDEPATH += sources sources/editor sources/titleblock sources/ui sources/qetgraphicsitem sources/richtext sources/factory sources/properties # Fichiers sources -HEADERS += sources/*.h sources/ui/*.h sources/editor/*.h sources/titleblock/*.h sources/richtext/*.h sources/qetgraphicsitem/*.h sources/factory/*.cpp +HEADERS += sources/*.h sources/ui/*.h sources/editor/*.h sources/titleblock/*.h sources/richtext/*.h sources/qetgraphicsitem/*.h sources/factory/*.cpp \ + sources/properties/propertiesinterface.h \ + sources/properties/xrefproperties.h -SOURCES += sources/*.cpp sources/editor/*.cpp sources/titleblock/*.cpp sources/richtext/*.cpp sources/ui/*.cpp sources/qetgraphicsitem/*.cpp sources/factory/*.cpp +SOURCES += sources/*.cpp sources/editor/*.cpp sources/titleblock/*.cpp sources/richtext/*.cpp sources/ui/*.cpp sources/qetgraphicsitem/*.cpp sources/factory/*.cpp \ + sources/properties/propertiesinterface.cpp \ + sources/properties/xrefproperties.cpp # Liste des fichiers qui seront incorpores au binaire en tant que ressources Qt RESOURCES += qelectrotech.qrc @@ -82,7 +86,8 @@ QT += xml svg network sql # UI DESIGNER FILES AND GENERATION SOURCES FILES FORMS += sources/richtext/addlinkdialog.ui sources/ui/*.ui \ - sources/ui/linksingleelementwidget.ui + sources/ui/linksingleelementwidget.ui \ + sources/ui/xrefpropertieswidget.ui UI_SOURCES_DIR = sources/ui/ UI_HEADERS_DIR = sources/ui/ diff --git a/sources/configpages.cpp b/sources/configpages.cpp index 353019d43..c5be9176f 100644 --- a/sources/configpages.cpp +++ b/sources/configpages.cpp @@ -25,6 +25,7 @@ #include "qeticons.h" #include "exportpropertieswidget.h" #include "ui/reportpropertiewidget.h" +#include "ui/xrefpropertieswidget.h" /** Constructeur @@ -52,6 +53,10 @@ NewDiagramPage::NewDiagramPage(QWidget *parent) : ConfigPage(parent) { // default propertie of report label rpw = new ReportPropertieWidget(QETDiagramEditor::defaultReportProperties()); tab_widget->addTab(rpw, tr("Report de folio")); + + // default properties of xref + xrefpw = new XRefPropertiesWidget(QETDiagramEditor::defaultXRefProperties(), this); + tab_widget->addTab(xrefpw, tr("R\351f\351rence crois\351es")); QVBoxLayout *vlayout1 = new QVBoxLayout(); vlayout1->addWidget(tab_widget); @@ -80,6 +85,9 @@ void NewDiagramPage::applyConf() { // default report propertie rpw->toSettings(settings, "diagrameditor/defaultreport"); + + // default xref properties + xrefpw -> properties().toSettings(settings, "diagrameditor/defaultxref"); } /// @return l'icone de cette page diff --git a/sources/configpages.h b/sources/configpages.h index b2cd35958..9d00a6d18 100644 --- a/sources/configpages.h +++ b/sources/configpages.h @@ -24,6 +24,7 @@ class ConductorPropertiesWidget; class TitleBlockPropertiesWidget; class ExportPropertiesWidget; class ReportPropertieWidget; +class XRefPropertiesWidget; /** This configuration page enables users to define the properties of new @@ -49,7 +50,9 @@ class NewDiagramPage : public ConfigPage { BorderPropertiesWidget *bpw; ///< Widget to edit default diagram dimensions TitleBlockPropertiesWidget *ipw; ///< Widget to edit default title block properties ConductorPropertiesWidget *cpw; ///< Widget to edit default conductor properties - ReportPropertieWidget *rpw;///< Widget to edit default report label + ReportPropertieWidget *rpw; ///< Widget to edit default report label + XRefPropertiesWidget *xrefpw; ///< Widget to edit default xref properties + }; /** diff --git a/sources/diagram.cpp b/sources/diagram.cpp index 616ed65f3..c0b35387c 100644 --- a/sources/diagram.cpp +++ b/sources/diagram.cpp @@ -1187,12 +1187,19 @@ QETProject *Diagram::project() const { } /** - @param project le nouveau projet auquel ce schema appartient ou 0 s'il - s'agit d'un schema independant. Indiquer 0 pour rendre ce schema independant. -*/ + * @brief Diagram::setProject + * @param project: set parent project of this diagram or 0 if this diagram haven't got a parent project + */ void Diagram::setProject(QETProject *project) { + if (project_) { + disconnect (project_, SIGNAL(reportPropertiesChanged(QString)), this, SIGNAL(reportPropertiesChanged(QString))); + disconnect (project_, SIGNAL(XRefPropertiesChanged(XRefProperties)), this, SIGNAL(XRefPropertiesChanged(XRefProperties))); + } project_ = project; - connect(project_, SIGNAL(reportPropertiesChanged(QString)), this, SIGNAL(reportPropertiesChanged(QString))); + if (project_) { + connect (project_, SIGNAL(reportPropertiesChanged(QString)), this, SIGNAL(reportPropertiesChanged(QString))); + connect (project_, SIGNAL(XRefPropertiesChanged(XRefProperties)), this, SIGNAL(XRefPropertiesChanged(XRefProperties))); + } } /** diff --git a/sources/diagram.h b/sources/diagram.h index a9921dfa3..8cc08a322 100644 --- a/sources/diagram.h +++ b/sources/diagram.h @@ -26,6 +26,7 @@ #include "qgimanager.h" #include "numerotationcontext.h" #include "qetproject.h" +#include "properties/xrefproperties.h" class Conductor; class CustomElement; @@ -102,7 +103,8 @@ class Diagram : public QGraphicsScene { virtual void keyReleaseEvent(QKeyEvent *); public: - QString defaultReportProperties () const {return project_->defaultReportProperties();} + QString defaultReportProperties () const {return project_ -> defaultReportProperties();} + XRefProperties defaultXRefProperties () const {return project_ -> defaultXrefProperties();} static bool clipboardMayContainDiagram(); bool setNumerotation (NumerotationType, NumerotationContext); NumerotationContext getNumerotation (NumerotationType) const; @@ -210,6 +212,7 @@ class Diagram : public QGraphicsScene { /// Signal emitted when users wish to edit an element from the diagram void editElementRequired(const ElementsLocation &); void reportPropertiesChanged(QString); + void XRefPropertiesChanged(XRefProperties); }; Q_DECLARE_METATYPE(Diagram *) diff --git a/sources/projectconfigpages.cpp b/sources/projectconfigpages.cpp index c786d3289..b5f6b948e 100644 --- a/sources/projectconfigpages.cpp +++ b/sources/projectconfigpages.cpp @@ -24,6 +24,7 @@ #include "titleblockpropertieswidget.h" #include #include "ui/reportpropertiewidget.h" +#include "ui/xrefpropertieswidget.h" /** Constructor @@ -260,6 +261,12 @@ void ProjectNewDiagramConfigPage::applyProjectConf() { project_->setDefaultReportProperties(new_report_prop); modified_project = true; } + + XRefProperties new_xref_properties = xref_ -> properties(); + if (project_ -> defaultXrefProperties() != new_xref_properties) { + project_ -> setDefaultXRefProperties(new_xref_properties); + modified_project = true; + } if (modified_project) { project_ -> setModified(modified_project); @@ -276,11 +283,12 @@ void ProjectNewDiagramConfigPage::initWidgets() { "explicative label" ) ); - border_ = new BorderPropertiesWidget(BorderProperties()); + border_ = new BorderPropertiesWidget(BorderProperties()); titleblock_ = new TitleBlockPropertiesWidget(TitleBlockProperties(), true); - conductor_ = new ConductorPropertiesWidget(); - conductor_ -> setContentsMargins(0, 0, 0, 0); - report_ = new ReportPropertieWidget("_"); + conductor_ = new ConductorPropertiesWidget(); + conductor_ -> setContentsMargins(0, 0, 0, 0); + report_ = new ReportPropertieWidget("_"); + xref_ = new XRefPropertiesWidget(); } /** @@ -294,11 +302,11 @@ void ProjectNewDiagramConfigPage::initLayout() { QVBoxLayout *diagram_layout = new QVBoxLayout(diagram_widget); diagram_layout -> addWidget(border_); diagram_layout -> addWidget(titleblock_); - tab_widget->addTab(diagram_widget, tr("Sch\351ma")); - tab_widget->addTab(conductor_, tr("Conducteur")); - - tab_widget->addTab(report_, tr("Report de folio")); + tab_widget -> addTab (diagram_widget, tr("Sch\351ma")); + tab_widget -> addTab (conductor_, tr("Conducteur")); + tab_widget -> addTab (report_, tr("Report de folio")); + tab_widget -> addTab (xref_, tr("R\351f\351rence crois\351es")); QVBoxLayout *vlayout1 = new QVBoxLayout(); vlayout1->addWidget(tab_widget); @@ -310,19 +318,20 @@ void ProjectNewDiagramConfigPage::initLayout() { Read properties from the edited project then fill widgets with them. */ void ProjectNewDiagramConfigPage::readValuesFromProject() { - border_ -> setEditedBorder(project_ -> defaultBorderProperties()); - conductor_ -> setConductorProperties(project_ -> defaultConductorProperties()); - titleblock_ -> setTitleBlockProperties(project_ -> defaultTitleBlockProperties()); - report_->setReportProperties(project_->defaultReportProperties()); + border_ -> setEditedBorder (project_ -> defaultBorderProperties()); + conductor_ -> setConductorProperties (project_ -> defaultConductorProperties()); + titleblock_ -> setTitleBlockProperties (project_ -> defaultTitleBlockProperties()); + report_ -> setReportProperties (project_ -> defaultReportProperties()); + xref_ -> setProperties (project_ -> defaultXrefProperties()); } /** - Set the content of this page read only if the project is read only, editable if the project is editable. */ void ProjectNewDiagramConfigPage::adjustReadOnly() { bool is_read_only = project_ -> isReadOnly(); - border_ -> setReadOnly(is_read_only); + border_ -> setReadOnly(is_read_only); titleblock_ -> setReadOnly(is_read_only); - conductor_ -> setReadOnly(is_read_only); + conductor_ -> setReadOnly(is_read_only); + xref_ -> setReadOnly(is_read_only); } diff --git a/sources/projectconfigpages.h b/sources/projectconfigpages.h index 79f2d0255..9358ab226 100644 --- a/sources/projectconfigpages.h +++ b/sources/projectconfigpages.h @@ -26,6 +26,7 @@ class TitleBlockPropertiesWidget; class ConductorPropertiesWidget; class DiagramContextWidget; class ReportPropertieWidget; +class XRefPropertiesWidget; /** This class, derived from ConfigPage, aims at providing the basic skeleton @@ -144,6 +145,7 @@ class ProjectNewDiagramConfigPage : public ProjectConfigPage { TitleBlockPropertiesWidget *titleblock_; ConductorPropertiesWidget *conductor_; ReportPropertieWidget *report_; + XRefPropertiesWidget *xref_; }; #endif diff --git a/sources/properties/propertiesinterface.cpp b/sources/properties/propertiesinterface.cpp new file mode 100644 index 000000000..cb24f9393 --- /dev/null +++ b/sources/properties/propertiesinterface.cpp @@ -0,0 +1,22 @@ +/* + 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 . +*/ +#include "propertiesinterface.h" + +PropertiesInterface::PropertiesInterface() +{ +} diff --git a/sources/properties/propertiesinterface.h b/sources/properties/propertiesinterface.h new file mode 100644 index 000000000..612d0ee79 --- /dev/null +++ b/sources/properties/propertiesinterface.h @@ -0,0 +1,41 @@ +/* + 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 . +*/ +#ifndef PROPERTIESINTERFACE_H +#define PROPERTIESINTERFACE_H + +#include +#include +#include + +/** + * @brief The PropertiesInterface class + * This class is an interface for have common way to use properties in QElectroTech + */ +class PropertiesInterface +{ + public: + PropertiesInterface(); + // Save/load properties to setting file. QString is use for prefix a word befor the name of each paramètre + virtual void toSettings (QSettings &settings, const QString = QString()) const =0; + virtual void fromSettings (const QSettings &settings, const QString = QString()) =0; + // Save/load properties to xml element + virtual void toXml (QDomElement &xml_element) const =0; + virtual void fromXml (const QDomElement &xml_element) =0; +}; + +#endif // PROPERTIESINTERFACE_H diff --git a/sources/properties/xrefproperties.cpp b/sources/properties/xrefproperties.cpp new file mode 100644 index 000000000..21b50ff2e --- /dev/null +++ b/sources/properties/xrefproperties.cpp @@ -0,0 +1,74 @@ +/* + 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 . +*/ +#include "xrefproperties.h" + +/** + * @brief XRefProperties::XRefProperties + * Default Constructor + */ +XRefProperties::XRefProperties() +{ +} + +/** + * @brief XRefProperties::toSettings + * Save to settings + * @param settings: QSettings to use + * @param prefix: prefix before properties name + */ +void XRefProperties::toSettings(QSettings &settings, const QString prefix) const { + settings.setValue(prefix + "showpowerctc", m_show_power_ctc); +} + +/** + * @brief XRefProperties::fromSettings + * load from settings + * @param settings: QSettings to use + * @param prefix: prefix before properties name + */ +void XRefProperties::fromSettings(const QSettings &settings, const QString prefix) { + m_show_power_ctc = settings.value(prefix + "showpowerctc", false).toBool(); +} + +/** + * @brief XRefProperties::toXml + * Save to xml + * @param xml_element: QDomElement to use for saving + */ +void XRefProperties::toXml(QDomElement &xml_element) const { + xml_element.setAttribute("showpowerctc", m_show_power_ctc? "true" : "fasle"); +} + +/** + * @brief XRefProperties::fromXml + * Load from xml + * @param xml_element: QDomElement to use for load + */ +void XRefProperties::fromXml(const QDomElement &xml_element) { + m_show_power_ctc = xml_element.attribute("showpowerctc") == "true"; +} + +bool XRefProperties::operator ==(const XRefProperties &xrp) const{ + return (m_show_power_ctc == xrp.m_show_power_ctc); +} + +bool XRefProperties::operator !=(const XRefProperties &xrp) const { + return (! (*this == xrp)); +} + + diff --git a/sources/properties/xrefproperties.h b/sources/properties/xrefproperties.h new file mode 100644 index 000000000..e77d5b0f3 --- /dev/null +++ b/sources/properties/xrefproperties.h @@ -0,0 +1,47 @@ +/* + 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 . +*/ +#ifndef XREFPROPERTIES_H +#define XREFPROPERTIES_H + +#include "propertiesinterface.h" + +/** + * @brief The XRefProperties class + * this class store properties used by XrefItem + */ +class XRefProperties : public PropertiesInterface +{ + public: + XRefProperties(); + + virtual void toSettings (QSettings &settings, const QString = QString()) const; + virtual void fromSettings (const QSettings &settings, const QString = QString()); + virtual void toXml (QDomElement &xml_element) const; + virtual void fromXml (const QDomElement &xml_element); + + bool operator == (const XRefProperties &xrp) const; + bool operator != (const XRefProperties &xrp) const; + + void setShowPowerContac (const bool a) {m_show_power_ctc = a;} + bool showPowerContact () const {return m_show_power_ctc;} + + private: + bool m_show_power_ctc; +}; + +#endif // XREFPROPERTIES_H diff --git a/sources/qetdiagrameditor.cpp b/sources/qetdiagrameditor.cpp index eb2d905ba..0ea314bc7 100644 --- a/sources/qetdiagrameditor.cpp +++ b/sources/qetdiagrameditor.cpp @@ -651,17 +651,20 @@ void QETDiagramEditor::saveCurrentDiagram() { } /** - Cree un nouveau projet vide -*/ + * @brief QETDiagramEditor::newProject + * Create an empty project + * @return + */ bool QETDiagramEditor::newProject() { - // cree un nouveau projet sans schema + // create new project without diagram QETProject *new_project = new QETProject(0); - // transmet les proprietes par defaut des nouveaux schemas - new_project -> setDefaultBorderProperties(defaultBorderProperties()); - new_project -> setDefaultConductorProperties(defaultConductorProperties()); - new_project -> setDefaultTitleBlockProperties(defaultTitleBlockProperties()); - new_project -> setDefaultReportProperties(defaultReportProperties()); + // 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()); // add new diagram new_project -> addNewDiagram(); @@ -2084,3 +2087,13 @@ 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 + */ +XRefProperties QETDiagramEditor::defaultXRefProperties() { + XRefProperties properties; + properties.fromSettings(QETApp::settings(), "diagrameditor/defaultxref"); + return properties; +} diff --git a/sources/qetdiagrameditor.h b/sources/qetdiagrameditor.h index 74b6f92a4..6cb690d32 100644 --- a/sources/qetdiagrameditor.h +++ b/sources/qetdiagrameditor.h @@ -23,6 +23,8 @@ #include "conductorproperties.h" #include "titleblockproperties.h" #include "exportproperties.h" +#include "properties/xrefproperties.h" + class QETProject; class QETResult; class ProjectView; @@ -62,7 +64,8 @@ class QETDiagramEditor : public QETMainWindow { static ConductorProperties defaultConductorProperties(); static ExportProperties defaultExportProperties(); static ExportProperties defaultPrintProperties(); - static QString defaultReportProperties(); + static QString defaultReportProperties(); + static XRefProperties defaultXRefProperties(); protected: void actions(); diff --git a/sources/qetproject.cpp b/sources/qetproject.cpp index f90e4c10e..615858ec9 100644 --- a/sources/qetproject.cpp +++ b/sources/qetproject.cpp @@ -29,7 +29,6 @@ #include "basicmoveelementshandler.h" #include "qetmessagebox.h" #include "titleblocktemplate.h" - #include "ui/dialogwaiting.h" QString QETProject::integration_category_name = "import"; @@ -452,6 +451,15 @@ void QETProject::setDefaultReportProperties(const QString &properties) { emit reportPropertiesChanged(properties); } +XRefProperties QETProject::defaultXrefProperties() const{ + return m_default_xref_properties; +} + +void QETProject::setDefaultXRefProperties(const XRefProperties &properties) { + m_default_xref_properties = properties; + emit XRefPropertiesChanged(properties); +} + /** @return un document XML representant le projet */ @@ -481,7 +489,7 @@ QDomDocument QETProject::toXml() { writeProjectPropertiesXml(project_properties); project_root.appendChild(project_properties); - // proprietes pour les nouveaux schemas + // Properties for news diagrams QDomElement new_diagrams_properties = xml_doc.createElement("newdiagrams"); writeDefaultPropertiesXml(new_diagrams_properties); project_root.appendChild(new_diagrams_properties); @@ -1139,29 +1147,27 @@ void QETProject::writeProjectPropertiesXml(QDomElement &xml_element) { } /** - Charge les proprietes par defaut des nouveaux schemas depuis la description - XML du projet : - * dimensions - * contenu du cartouche - * conducteurs par defaut -*/ + * @brief QETProject::readDefaultPropertiesXml + * load default properties for new diagram, found in the xml of this project + * or by default find in the QElectroTech global conf + */ void QETProject::readDefaultPropertiesXml() { - // repere l'element XML decrivant les proprietes des nouveaux schemas + // Find xml element where is stored properties for new diagram QDomNodeList newdiagrams_nodes = document_root_.elementsByTagName("newdiagrams"); if (newdiagrams_nodes.isEmpty()) return; QDomElement newdiagrams_elmt = newdiagrams_nodes.at(0).toElement(); - // par defaut, les valeurs sont celles de la configuration QElectroTech - default_border_properties_ = QETDiagramEditor::defaultBorderProperties(); - default_titleblock_properties_ = QETDiagramEditor::defaultTitleBlockProperties(); - default_conductor_properties_ = QETDiagramEditor::defaultConductorProperties(); - default_report_properties_ = QETDiagramEditor::defaultReportProperties(); + // 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(); - // lecture des valeurs indiquees dans le projet - QDomElement border_elmt, titleblock_elmt, conductors_elmt, report_elmt; + //Read values indicate in project + QDomElement border_elmt, titleblock_elmt, conductors_elmt, report_elmt, xref_elmt; - // recherche des elements XML concernant les dimensions, le cartouche et les conducteurs for (QDomNode child = newdiagrams_elmt.firstChild() ; !child.isNull() ; child = child.nextSibling()) { QDomElement child_elmt = child.toElement(); if (child_elmt.isNull()) continue; @@ -1173,38 +1179,44 @@ void QETProject::readDefaultPropertiesXml() { conductors_elmt = child_elmt; } else if (child_elmt.tagName() == "report") { report_elmt = child_elmt; + } else if (child_elmt.tagName() == "xref") { + xref_elmt = child_elmt; } } // size, titleblock, conductor, report - if (!border_elmt.isNull()) default_border_properties_.fromXml(border_elmt); - if (!titleblock_elmt.isNull()) default_titleblock_properties_.fromXml(titleblock_elmt); + if (!border_elmt.isNull()) default_border_properties_.fromXml(border_elmt); + if (!titleblock_elmt.isNull()) default_titleblock_properties_.fromXml(titleblock_elmt); if (!conductors_elmt.isNull()) default_conductor_properties_.fromXml(conductors_elmt); - if (!report_elmt.isNull()) setDefaultReportProperties(report_elmt.attribute("label")); + if (!report_elmt.isNull()) setDefaultReportProperties(report_elmt.attribute("label")); + if (!xref_elmt.isNull()) m_default_xref_properties.fromXml(xref_elmt); } + /** - Exporte les proprietes par defaut des nouveaux schemas dans l'element XML : - * dimensions - * contenu du cartouche - * conducteurs par defaut - @param xml_element Element XML sous lequel seront exportes les proprietes - par defaut des nouveaux schemas -*/ + * @brief QETProject::writeDefaultPropertiesXml + * Export all defaults properties used by a new diagram and his content + * #size of border + * #content of titleblock + * #default conductor + * #defaut folio report + * #default Xref + * @param xml_element xml element to use for store default propertie. + */ void QETProject::writeDefaultPropertiesXml(QDomElement &xml_element) { QDomDocument xml_document = xml_element.ownerDocument(); - // exporte les dimensions + // export size of border QDomElement border_elmt = xml_document.createElement("border"); default_border_properties_.toXml(border_elmt); xml_element.appendChild(border_elmt); - // exporte le contenu du cartouche + // export content of titleblock QDomElement titleblock_elmt = xml_document.createElement("inset"); default_titleblock_properties_.toXml(titleblock_elmt); xml_element.appendChild(titleblock_elmt); - // exporte le type de conducteur par defaut + // exporte default conductor QDomElement conductor_elmt = xml_document.createElement("conductors"); default_conductor_properties_.toXml(conductor_elmt); xml_element.appendChild(conductor_elmt); @@ -1213,6 +1225,11 @@ void QETProject::writeDefaultPropertiesXml(QDomElement &xml_element) { QDomElement report_elmt = xml_document.createElement("report"); report_elmt.setAttribute("label", defaultReportProperties()); xml_element.appendChild(report_elmt); + + // export default XRef properties + QDomElement xref_elmt = xml_document.createElement("xref"); + defaultXrefProperties().toXml(xref_elmt); + xml_element.appendChild(xref_elmt); } /** diff --git a/sources/qetproject.h b/sources/qetproject.h index 64ada790a..040712410 100644 --- a/sources/qetproject.h +++ b/sources/qetproject.h @@ -25,6 +25,7 @@ #include "conductorproperties.h" #include "titleblockproperties.h" #include "templatescollection.h" +#include "properties/xrefproperties.h" class Diagram; class ElementsCollection; @@ -99,6 +100,8 @@ class QETProject : public QObject { void setDefaultConductorProperties(const ConductorProperties &); QString defaultReportProperties() const; void setDefaultReportProperties (const QString &properties); + XRefProperties defaultXrefProperties () const; + void setDefaultXRefProperties(const XRefProperties &properties); QDomDocument toXml(); bool close(); QETResult write(); @@ -144,6 +147,7 @@ class QETProject : public QObject { void diagramUsedTemplate(TitleBlockTemplatesCollection *, const QString &); void readOnlyChanged(QETProject *, bool); void reportPropertiesChanged(QString); + void XRefPropertiesChanged (XRefProperties); private slots: void updateDiagramsFolioData(); @@ -201,6 +205,8 @@ class QETProject : public QObject { TitleBlockProperties default_titleblock_properties_; /// Default report properties QString default_report_properties_; + /// Default xref properties + XRefProperties m_default_xref_properties; /// Embedded title block templates collection TitleBlockTemplatesProjectCollection titleblocks_; /// project-wide variables that will be made available to child diagrams diff --git a/sources/ui/xrefpropertieswidget.cpp b/sources/ui/xrefpropertieswidget.cpp new file mode 100644 index 000000000..c3434dacd --- /dev/null +++ b/sources/ui/xrefpropertieswidget.cpp @@ -0,0 +1,80 @@ +/* + 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 . +*/ +#include "xrefpropertieswidget.h" +#include "ui_xrefpropertieswidget.h" +#include "qdebug.h" + +/** + * @brief XRefPropertiesWidget::XRefPropertiesWidget + * Default constructor + * @param properties: properties to use + * @param parent: parent widget + */ +XRefPropertiesWidget::XRefPropertiesWidget(XRefProperties properties, QWidget *parent) : + QWidget(parent), + ui(new Ui::XRefPropertiesWidget), + m_properties(properties) +{ + ui->setupUi(this); + updateDisplay(); +} + +/** + * @brief XRefPropertiesWidget::~XRefPropertiesWidget + * Default destructor + */ +XRefPropertiesWidget::~XRefPropertiesWidget() +{ + delete ui; +} + +/** + * @brief XRefPropertiesWidget::setProperties + * set new properties for this widget + * @param properties + */ +void XRefPropertiesWidget::setProperties(const XRefProperties &properties) { + m_properties = properties; + updateDisplay(); +} + +/** + * @brief XRefPropertiesWidget::properties + * @return the propertie edited by this widget + */ +XRefProperties XRefPropertiesWidget::properties() { + m_properties.setShowPowerContac(ui->cb_show_power->isChecked()); + return m_properties; +} + +/** + * @brief XRefPropertiesWidget::setReadOnly + * Set all of this widget disable if true + * @param ro + */ +void XRefPropertiesWidget::setReadOnly(bool ro) { + ui->cb_show_power->setDisabled(ro); +} + +/** + * @brief XRefPropertiesWidget::updateDisplay + * Update display with the content of the properties + */ +void XRefPropertiesWidget::updateDisplay() { + ui->cb_show_power->setChecked(m_properties.showPowerContact()); +} diff --git a/sources/ui/xrefpropertieswidget.h b/sources/ui/xrefpropertieswidget.h new file mode 100644 index 000000000..8bdc776dc --- /dev/null +++ b/sources/ui/xrefpropertieswidget.h @@ -0,0 +1,53 @@ +/* + 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 . +*/ +#ifndef XREFPROPERTIESWIDGET_H +#define XREFPROPERTIESWIDGET_H + +#include +#include "properties/xrefproperties.h" + +namespace Ui { + class XRefPropertiesWidget; +} + +/** + * @brief The XRefPropertiesWidget class + * This class provide a widget to edit the XRefProperties + */ +class XRefPropertiesWidget : public QWidget +{ + Q_OBJECT + + public: + XRefPropertiesWidget(XRefProperties properties = XRefProperties(), QWidget *parent = 0); + ~XRefPropertiesWidget(); + + void setProperties (const XRefProperties &properties); + XRefProperties properties(); + + void setReadOnly (bool = true); + + private: + void updateDisplay(); + + private: + Ui::XRefPropertiesWidget *ui; + XRefProperties m_properties; +}; + +#endif // XREFPROPERTIESWIDGET_H diff --git a/sources/ui/xrefpropertieswidget.ui b/sources/ui/xrefpropertieswidget.ui new file mode 100644 index 000000000..a68522154 --- /dev/null +++ b/sources/ui/xrefpropertieswidget.ui @@ -0,0 +1,41 @@ + + + XRefPropertiesWidget + + + + 0 + 0 + 400 + 300 + + + + Form + + + + + + Afficher les contacts de puissance dans la croix + + + + + + + Qt::Vertical + + + + 20 + 253 + + + + + + + + +