[qet] [3317] New diagram properties dialog : |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/qet Archives
]
Revision: 3317
Author: blacksun
Date: 2014-09-20 22:04:02 +0200 (Sat, 20 Sep 2014)
Log Message:
-----------
New diagram properties dialog :
Merge the dialog of default configuration and the dialog of project configuration, into a single configuration dialog.
Modified Paths:
--------------
trunk/sources/configpages.cpp
trunk/sources/configpages.h
trunk/sources/projectconfigpages.cpp
trunk/sources/projectconfigpages.h
trunk/sources/ui/projectpropertiesdialog.cpp
Modified: trunk/sources/configpages.cpp
===================================================================
--- trunk/sources/configpages.cpp 2014-09-20 18:26:13 UTC (rev 3316)
+++ trunk/sources/configpages.cpp 2014-09-20 20:04:02 UTC (rev 3317)
@@ -26,81 +26,148 @@
#include "exportpropertieswidget.h"
#include "ui/reportpropertiewidget.h"
#include "ui/xrefpropertieswidget.h"
+#include "qetproject.h"
/**
- Constructeur
- @param parent QWidget parent
-*/
-NewDiagramPage::NewDiagramPage(QWidget *parent) : ConfigPage(parent) {
- // main tab widget
- QTabWidget *tab_widget = new QTabWidget(this);
+ * @brief NewDiagramPage::NewDiagramPage
+ * Default constructor
+ * @param project, If project, edit the propertie of Project
+ * else edit the properties by default of QElectroTech
+ * @param parent, parent widget
+ */
+NewDiagramPage::NewDiagramPage(QETProject *project, QWidget *parent) :
+ ConfigPage (parent),
+ m_project (project)
+{
+ //By default we set the global default properties
// dimensions by default for diagram
bpw = new BorderPropertiesWidget(QETDiagramEditor::defaultBorderProperties());
// default titleblock properties
ipw = new TitleBlockPropertiesWidget(QETDiagramEditor::defaultTitleBlockProperties(), true);
- QWidget *diagram_widget = new QWidget();
- QVBoxLayout *diagram_layout = new QVBoxLayout(diagram_widget);
- diagram_layout -> addWidget(bpw);
- diagram_layout -> addWidget(ipw);
- tab_widget->addTab(diagram_widget, tr("Sch\351ma"));
-
// default conductor properties
cpw = new ConductorPropertiesWidget(QETDiagramEditor::defaultConductorProperties());
- cpw -> setContentsMargins(0, 0, 0, 0);
- tab_widget->addTab(cpw, tr("Conducteur"));
-
// 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"));
-
+
+ //If there is a project, we edit his properties
+ if (m_project) {
+ bpw -> setProperties (m_project -> defaultBorderProperties());
+ cpw -> setProperties (m_project -> defaultConductorProperties());
+ ipw -> setProperties (m_project -> defaultTitleBlockProperties());
+ rpw -> setReportProperties (m_project -> defaultReportProperties());
+ xrefpw -> setProperties (m_project -> defaultXRefProperties());
+ }
+
+ // main tab widget
+ QTabWidget *tab_widget = new QTabWidget(this);
+ QWidget *diagram_widget = new QWidget();
+ QVBoxLayout *diagram_layout = new QVBoxLayout(diagram_widget);
+
+ diagram_layout -> addWidget(bpw);
+ diagram_layout -> addWidget(ipw);
+
+ tab_widget -> addTab (diagram_widget, tr("Sch\351ma"));
+ tab_widget -> addTab (cpw, tr("Conducteur"));
+ tab_widget -> addTab (rpw, tr("Report de folio"));
+ tab_widget -> addTab (xrefpw, tr("R\351f\351rence crois\351es"));
+
QVBoxLayout *vlayout1 = new QVBoxLayout();
vlayout1->addWidget(tab_widget);
setLayout(vlayout1);
}
-/// Destructeur
+/**
+ * @brief NewDiagramPage::~NewDiagramPage
+ */
NewDiagramPage::~NewDiagramPage() {
}
/**
- Applique la configuration de cette page
-*/
+ * @brief NewDiagramPage::applyConf
+ * Apply conf for this page.
+ * If there is a project, save in the project,
+ * else save to the default conf of QElectroTech
+ */
void NewDiagramPage::applyConf() {
- QSettings &settings = QETApp::settings();
-
- // dimensions des nouveaux schemas
- bpw -> properties().toSettings(settings, "diagrameditor/default");
-
- // proprietes du cartouche
- ipw-> properties().toSettings(settings, "diagrameditor/default");
-
- // proprietes par defaut des conducteurs
- cpw -> properties().toSettings(settings, "diagrameditor/defaultconductor");
+ if (m_project) { //If project we save to the project
+ if (m_project -> isReadOnly()) return;
+ bool modified_project = false;
- // default report propertie
- rpw->toSettings(settings, "diagrameditor/defaultreport");
+ BorderProperties new_border_prop = bpw -> properties();
+ if (m_project -> defaultBorderProperties() != new_border_prop) {
+ m_project -> setDefaultBorderProperties(bpw -> properties());
+ modified_project = true;
+ }
- // default xref properties
- QHash <QString, XRefProperties> hash_xrp = xrefpw -> properties();
- foreach (QString key, hash_xrp.keys()) {
- XRefProperties xrp = hash_xrp[key];
- QString str("diagrameditor/defaultxref");
- xrp.toSettings(settings, str += key);
+ TitleBlockProperties new_tbt_prop = ipw -> properties();
+ if (m_project -> defaultTitleBlockProperties() != new_tbt_prop) {
+ m_project -> setDefaultTitleBlockProperties(ipw -> properties());
+ modified_project = true;
+ }
+
+ ConductorProperties new_conductor_prop = cpw -> properties();
+ if (m_project -> defaultConductorProperties() != new_conductor_prop) {
+ m_project -> setDefaultConductorProperties(cpw -> properties());
+ modified_project = true;
+ }
+
+ QString new_report_prop = rpw -> ReportProperties();
+ if (m_project -> defaultReportProperties() != new_report_prop) {
+ m_project -> setDefaultReportProperties(new_report_prop);
+ modified_project = true;
+ }
+
+ QHash<QString, XRefProperties> new_xref_properties = xrefpw -> properties();
+ if (m_project -> defaultXRefProperties() != new_xref_properties) {
+ m_project -> setDefaultXRefProperties(new_xref_properties);
+ modified_project = true;
+ }
+
+ if (modified_project) {
+ m_project -> setModified(modified_project);
+ }
+
+ } else { //Else we save to the default value
+ QSettings &settings = QETApp::settings();
+
+ // dimensions des nouveaux schemas
+ bpw -> properties().toSettings(settings, "diagrameditor/default");
+
+ // proprietes du cartouche
+ ipw-> properties().toSettings(settings, "diagrameditor/default");
+
+ // proprietes par defaut des conducteurs
+ cpw -> properties().toSettings(settings, "diagrameditor/defaultconductor");
+
+ // default report propertie
+ rpw->toSettings(settings, "diagrameditor/defaultreport");
+
+ // default xref properties
+ QHash <QString, XRefProperties> hash_xrp = xrefpw -> properties();
+ foreach (QString key, hash_xrp.keys()) {
+ XRefProperties xrp = hash_xrp[key];
+ QString str("diagrameditor/defaultxref");
+ xrp.toSettings(settings, str += key);
+ }
}
}
-/// @return l'icone de cette page
+/**
+ * @brief NewDiagramPage::icon
+ * @return icon of this page
+ */
QIcon NewDiagramPage::icon() const {
return(QET::Icons::NewDiagram);
}
-/// @return le titre de cette page
+/**
+ * @brief NewDiagramPage::title
+ * @return title of this page
+ */
QString NewDiagramPage::title() const {
return(tr("Nouveau sch\351ma", "configuration page title"));
}
Modified: trunk/sources/configpages.h
===================================================================
--- trunk/sources/configpages.h 2014-09-20 18:26:13 UTC (rev 3316)
+++ trunk/sources/configpages.h 2014-09-20 20:04:02 UTC (rev 3317)
@@ -25,6 +25,7 @@
class ExportPropertiesWidget;
class ReportPropertieWidget;
class XRefPropertiesWidget;
+class QETProject;
/**
This configuration page enables users to define the properties of new
@@ -34,7 +35,7 @@
Q_OBJECT
// constructors, destructor
public:
- NewDiagramPage(QWidget * = 0);
+ NewDiagramPage(QETProject *project = 0, QWidget * = 0);
virtual ~NewDiagramPage();
private:
NewDiagramPage(const NewDiagramPage &);
@@ -47,11 +48,12 @@
// attributes
private:
- 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
- XRefPropertiesWidget *xrefpw; ///< Widget to edit default xref properties
+ QETProject *m_project; ///< Project to edit propertie
+ 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
+ XRefPropertiesWidget *xrefpw; ///< Widget to edit default xref properties
};
Modified: trunk/sources/projectconfigpages.cpp
===================================================================
--- trunk/sources/projectconfigpages.cpp 2014-09-20 18:26:13 UTC (rev 3316)
+++ trunk/sources/projectconfigpages.cpp 2014-09-20 20:04:02 UTC (rev 3317)
@@ -208,143 +208,6 @@
//######################################################################################//
/**
- Constructor
- @param project Project this page is editing.
- @param parent Parent QWidget
-*/
-ProjectNewDiagramConfigPage::ProjectNewDiagramConfigPage(QETProject *project, QWidget *parent) :
- ProjectConfigPage(project, parent)
-{
- init();
-}
-
-/**
- Destructor
-*/
-ProjectNewDiagramConfigPage::~ProjectNewDiagramConfigPage() {
-}
-
-/**
- @return the title for this page
-*/
-QString ProjectNewDiagramConfigPage::title() const {
- return(tr("Nouveau sch\351ma", "project configuration page title"));
-}
-
-/**
- @return the icon for this page
-*/
-QIcon ProjectNewDiagramConfigPage::icon() const {
- return(QET::Icons::NewDiagram);
-}
-
-/**
- Apply the configuration after user input
-*/
-void ProjectNewDiagramConfigPage::applyProjectConf() {
- bool modified_project = false;
-
- BorderProperties new_border_prop = border_ -> properties();
- if (project_ -> defaultBorderProperties() != new_border_prop) {
- project_ -> setDefaultBorderProperties(border_ -> properties());
- modified_project = true;
- }
-
- TitleBlockProperties new_tbt_prop = titleblock_ -> properties();
- if (project_ -> defaultTitleBlockProperties() != new_tbt_prop) {
- project_ -> setDefaultTitleBlockProperties(titleblock_ -> properties());
- modified_project = true;
- }
-
- ConductorProperties new_conductor_prop = conductor_ -> properties();
- if (project_ -> defaultConductorProperties() != new_conductor_prop) {
- project_ -> setDefaultConductorProperties(conductor_ -> properties());
- modified_project = true;
- }
-
- QString new_report_prop = report_->ReportProperties();
- if (project_->defaultReportProperties() != new_report_prop) {
- project_->setDefaultReportProperties(new_report_prop);
- modified_project = true;
- }
-
- QHash<QString, 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);
- }
-}
-
-/**
- Initialize widgets displayed by the page.
-*/
-void ProjectNewDiagramConfigPage::initWidgets() {
- informative_label_ = new QLabel(
- tr(
- "Propri\351t\351s \340 utiliser lors de l'ajout d'un nouveau sch\351ma au projet :",
- "explicative label"
- )
- );
- border_ = new BorderPropertiesWidget(BorderProperties());
- titleblock_ = new TitleBlockPropertiesWidget(TitleBlockProperties(), true);
- conductor_ = new ConductorPropertiesWidget();
- conductor_ -> setContentsMargins(0, 0, 0, 0);
- report_ = new ReportPropertieWidget("_");
- xref_ = new XRefPropertiesWidget();
-}
-
-/**
- Initialize the layout of this page.
-*/
-void ProjectNewDiagramConfigPage::initLayout() {
- // main tab widget
- QTabWidget *tab_widget = new QTabWidget(this);
-
- QWidget *diagram_widget = new QWidget();
- 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 (xref_, tr("R\351f\351rence crois\351es"));
-
- QVBoxLayout *vlayout1 = new QVBoxLayout();
- vlayout1->addWidget(tab_widget);
-
- setLayout(vlayout1);
-}
-
-/**
- Read properties from the edited project then fill widgets with them.
-*/
-void ProjectNewDiagramConfigPage::readValuesFromProject() {
- border_ -> setProperties (project_ -> defaultBorderProperties());
- conductor_ -> setProperties (project_ -> defaultConductorProperties());
- titleblock_ -> setProperties (project_ -> defaultTitleBlockProperties());
- report_ -> setReportProperties (project_ -> defaultReportProperties());
- xref_ -> setProperties (project_ -> defaultXRefProperties());
-}
-
-/**
- editable if the project is editable.
- */
-void ProjectNewDiagramConfigPage::adjustReadOnly() {
- bool is_read_only = project_ -> isReadOnly();
- border_ -> setReadOnly(is_read_only);
- titleblock_ -> setReadOnly(is_read_only);
- conductor_ -> setReadOnly(is_read_only);
- xref_ -> setReadOnly(is_read_only);
-}
-
-//######################################################################################//
-
-/**
* @brief ProjectAutoNumConfigPage::ProjectAutoNumConfigPage
* Default constructor
* @param project, project to edit
Modified: trunk/sources/projectconfigpages.h
===================================================================
--- trunk/sources/projectconfigpages.h 2014-09-20 18:26:13 UTC (rev 3316)
+++ trunk/sources/projectconfigpages.h 2014-09-20 20:04:02 UTC (rev 3317)
@@ -118,41 +118,6 @@
DiagramContextWidget *project_variables_;
};
-/**
- This page enables users to configure the default properties of diagrams
- newly added to the edited project.
-*/
-class ProjectNewDiagramConfigPage : public ProjectConfigPage {
- Q_OBJECT
- // Constructor, destructor
- public:
- ProjectNewDiagramConfigPage(QETProject *, QWidget * = 0);
- virtual ~ProjectNewDiagramConfigPage();
- private:
- ProjectNewDiagramConfigPage(const ProjectNewDiagramConfigPage &);
-
- // methods
- public:
- QString title() const;
- QIcon icon() const;
- void applyProjectConf();
-
- protected:
- void initWidgets();
- void initLayout();
- void readValuesFromProject();
- void adjustReadOnly();
-
- // attributes
- private:
- QLabel *informative_label_;
- BorderPropertiesWidget *border_;
- TitleBlockPropertiesWidget *titleblock_;
- ConductorPropertiesWidget *conductor_;
- ReportPropertieWidget *report_;
- XRefPropertiesWidget *xref_;
-};
-
class ProjectAutoNumConfigPage : public ProjectConfigPage {
Q_OBJECT
Modified: trunk/sources/ui/projectpropertiesdialog.cpp
===================================================================
--- trunk/sources/ui/projectpropertiesdialog.cpp 2014-09-20 18:26:13 UTC (rev 3316)
+++ trunk/sources/ui/projectpropertiesdialog.cpp 2014-09-20 20:04:02 UTC (rev 3317)
@@ -19,6 +19,7 @@
#include "configdialog.h"
#include "projectconfigpages.h"
#include <QObject>
+#include "configpages.h"
/**
* @brief ProjectPropertiesDialog::ProjectPropertiesDialog
@@ -30,7 +31,7 @@
m_properties_dialog = new ConfigDialog (parent);
m_properties_dialog -> setWindowTitle(QObject::tr("Propri\351t\351s du projet", "window title"));
m_properties_dialog -> addPage(new ProjectMainConfigPage (project));
- m_properties_dialog -> addPage(new ProjectNewDiagramConfigPage (project));
+ m_properties_dialog -> addPage(new NewDiagramPage (project));
m_properties_dialog -> addPage(new ProjectAutoNumConfigPage (project));
}