[qet] [3203] BorderPropertiesWridget: replace widget made with C++ by widget build by ui file. |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/qet Archives
]
Revision: 3203
Author: blacksun
Date: 2014-07-11 18:45:18 +0200 (Fri, 11 Jul 2014)
Log Message:
-----------
BorderPropertiesWridget: replace widget made with C++ by widget build by ui file.
Modified Paths:
--------------
trunk/sources/configpages.cpp
trunk/sources/diagramview.cpp
trunk/sources/projectconfigpages.cpp
Added Paths:
-----------
trunk/sources/ui/borderpropertieswidget.cpp
trunk/sources/ui/borderpropertieswidget.h
trunk/sources/ui/borderpropertieswidget.ui
Removed Paths:
-------------
trunk/sources/borderpropertieswidget.cpp
trunk/sources/borderpropertieswidget.h
Deleted: trunk/sources/borderpropertieswidget.cpp
===================================================================
--- trunk/sources/borderpropertieswidget.cpp 2014-07-09 16:50:30 UTC (rev 3202)
+++ trunk/sources/borderpropertieswidget.cpp 2014-07-11 16:45:18 UTC (rev 3203)
@@ -1,163 +0,0 @@
-/*
- 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 "borderpropertieswidget.h"
-#include <QtGui>
-#include "qetapp.h"
-#include "bordertitleblock.h"
-// added to incorporate QColor functionality and so that
-// variable Diagram::background_color is recognized in this file
-#include <QColor>
-#include "diagram.h"
-/**
- Constructeur
- Construit un widget editant les proprietes d'une bordure
- @param bp proprietes a editer
- @param parent QWidget parent
-*/
-BorderPropertiesWidget::BorderPropertiesWidget(const BorderProperties &bp, QWidget *parent) :
- QWidget(parent)
-{
- build();
- setEditedBorder(bp);
-}
-
-/**
- Destructeur
-*/
-BorderPropertiesWidget::~BorderPropertiesWidget() {
-}
-
-/**
- @return Les proprietes editees par ce widget
-*/
-const BorderProperties &BorderPropertiesWidget::borderProperties() {
- border_.columns_count = columns_count -> value();
- border_.columns_width = columns_width -> value();
- border_.display_columns = display_columns -> isChecked();
- border_.rows_count = rows_count -> value();
- border_.rows_height = rows_height -> value();
- border_.display_rows = display_rows -> isChecked();
- return(border_);
-}
-
-/**
- @return true si ce widget est en lecture seule, false sinon
-*/
-bool BorderPropertiesWidget::isReadOnly() const {
- return(columns_count -> isReadOnly());
-}
-
-/**
- @param ro true pour passer ce widget en lecture seule, false sinon
-*/
-void BorderPropertiesWidget::setReadOnly(bool ro) {
- columns_count -> setReadOnly(ro);
- columns_width -> setReadOnly(ro);
- display_columns -> setDisabled(ro);
- rows_count -> setReadOnly(ro);
- rows_height -> setReadOnly(ro);
- display_rows -> setDisabled(ro);
-}
-
-/**
- Definit les proprietes a editer
- @param bp Nouvelles proprietes
-*/
-void BorderPropertiesWidget::setEditedBorder(const BorderProperties &bp) {
- border_ = bp;
- columns_count -> setValue(border_.columns_count);
- columns_width -> setValue(qRound(border_.columns_width));
- display_columns -> setChecked(border_.display_columns);
- rows_count -> setValue(border_.rows_count);
- rows_height -> setValue(qRound(border_.rows_height));
- display_rows -> setChecked(border_.display_rows);
-}
-
-/**
- Construit le widget
-*/
-void BorderPropertiesWidget::build() {
- QVBoxLayout *widget_layout = new QVBoxLayout();
- widget_layout -> setContentsMargins(0, 0, 0, 0);
-
- QGroupBox *diagram_size_box = new QGroupBox(tr("Dimensions du sch\351ma"));
- QGridLayout *diagram_size_box_layout = new QGridLayout(diagram_size_box);
-
- // colonnes : nombre et largeur
- QLabel *ds1 = new QLabel(tr("Colonnes :"));
-
- columns_count = new QSpinBox(diagram_size_box);
- columns_count -> setMinimum(BorderTitleBlock::minNbColumns());
- columns_count -> setMaximum(10000); // valeur arbitraire
-
- columns_width = new QSpinBox(diagram_size_box);
- columns_width -> setMinimum(qRound(BorderTitleBlock::minColumnsWidth()));
- columns_width -> setMaximum(10000);
- columns_width -> setSingleStep(10);
- columns_width -> setPrefix(tr("\327", "multiplication symbol"));
- columns_width -> setSuffix(tr("px", "unit for cols width"));
-
- display_columns = new QCheckBox(tr("Afficher les en-t\352tes"), diagram_size_box);
-
- // lignes : nombre et largeur
- QLabel *ds2 = new QLabel(tr("Lignes :"));
-
- rows_count = new QSpinBox(diagram_size_box);
- rows_count -> setMinimum(BorderTitleBlock::minNbRows());
- rows_count -> setMaximum(10000); // valeur arbitraire
-
- rows_height = new QSpinBox(diagram_size_box);
- rows_height -> setMinimum(qRound(BorderTitleBlock::minRowsHeight()));
- rows_height -> setMaximum(10000);
- rows_height -> setSingleStep(10);
- rows_height -> setPrefix(tr("\327", "multiplication symbol"));
- rows_height -> setSuffix(tr("px", "unit for rows height"));
-
- display_rows = new QCheckBox(tr("Afficher les en-t\352tes"), diagram_size_box);
-
- widget_layout -> addWidget(diagram_size_box);
- // add background color field
- QLabel *ds3 = new QLabel(tr("Couleur de fond :"));
- background_color = new QCheckBox(tr("Gris"), diagram_size_box);
- bool isnotChecked = Diagram::background_color == Qt::white;
- background_color -> setChecked(!isnotChecked);
-
- // layout
- diagram_size_box_layout -> addWidget(ds1, 0, 0);
- diagram_size_box_layout -> addWidget(columns_count, 0, 1);
- diagram_size_box_layout -> addWidget(columns_width, 0, 2);
- diagram_size_box_layout -> addWidget(display_columns,0, 3);
- diagram_size_box_layout -> addWidget(ds2, 1, 0);
- diagram_size_box_layout -> addWidget(rows_count, 1, 1);
- diagram_size_box_layout -> addWidget(rows_height, 1, 2);
- diagram_size_box_layout -> addWidget(display_rows, 1, 3);
-
- diagram_size_box_layout -> addWidget(ds3, 2, 0, 1, 2);
- diagram_size_box_layout -> addWidget(background_color, 2, 2, 1, 2);
-
- //build button connection
- connect(background_color, SIGNAL(stateChanged(int)), this, SLOT(changeColor()));
- setLayout(widget_layout);
-}
- /**
- Background color choose QColorDialog. Makes Diagram::background_color equal to new chosen color.
- */
-void BorderPropertiesWidget::changeColor() {
- Diagram::background_color = (background_color -> isChecked()) ? Qt::gray : Qt::white;
-
-}
Deleted: trunk/sources/borderpropertieswidget.h
===================================================================
--- trunk/sources/borderpropertieswidget.h 2014-07-09 16:50:30 UTC (rev 3202)
+++ trunk/sources/borderpropertieswidget.h 2014-07-11 16:45:18 UTC (rev 3203)
@@ -1,65 +0,0 @@
-/*
- 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 BORDER_PROPERTIES_WIDGET_H
-#define BORDER_PROPERTIES_WIDGET_H
-#include <QWidget>
-#include "borderproperties.h"
-class QCheckBox;
-class QSpinBox;
-class QPushButton;
-/**
- This class provides a widget to edit dimensions and display properties of a
- diagram, title block excluded.
- @see TitleBlockPropertiesWidget
-*/
-class BorderPropertiesWidget : public QWidget {
- Q_OBJECT
-
- // constructors, destructor
- public:
- BorderPropertiesWidget(const BorderProperties &, QWidget * = 0);
- virtual ~BorderPropertiesWidget();
- private:
- BorderPropertiesWidget(const BorderPropertiesWidget &);
-
- // methods
- public:
- const BorderProperties &borderProperties();
- bool isReadOnly() const;
- void setReadOnly(bool);
- void setEditedBorder(const BorderProperties &);
-
- public slots:
- // to choose the back_ground color of diagram.
- void changeColor();
-
- private:
- void build();
-
- // attributes
- private:
- BorderProperties border_; ///< Edited properties
- QSpinBox *columns_count; ///< Widget to edit the columns count
- QSpinBox *columns_width; ///< Widget to edit the columns width
- QCheckBox *display_columns; ///< Checkbox stating whether to display column headers
- QSpinBox *rows_count; ///< Widget to edit the rows count
- QSpinBox *rows_height; ///< Widget to edit the rows height
- QCheckBox *display_rows; ///< Checkbox stating whether to display row headers
- QCheckBox *background_color; ///< Checkbox for selecting diagram background color grey/white
-};
-#endif
Modified: trunk/sources/configpages.cpp
===================================================================
--- trunk/sources/configpages.cpp 2014-07-09 16:50:30 UTC (rev 3202)
+++ trunk/sources/configpages.cpp 2014-07-11 16:45:18 UTC (rev 3203)
@@ -36,7 +36,7 @@
QTabWidget *tab_widget = new QTabWidget(this);
// dimensions by default for diagram
- bpw = new BorderPropertiesWidget(QETDiagramEditor::defaultBorderProperties());
+ bpw = new BorderPropertiesWidget(QETDiagramEditor::defaultBorderProperties());
// default titleblock properties
ipw = new TitleBlockPropertiesWidget(QETDiagramEditor::defaultTitleBlockProperties(), true);
QWidget *diagram_widget = new QWidget();
@@ -75,7 +75,7 @@
QSettings &settings = QETApp::settings();
// dimensions des nouveaux schemas
- bpw -> borderProperties().toSettings(settings, "diagrameditor/default");
+ bpw -> properties().toSettings(settings, "diagrameditor/default");
// proprietes du cartouche
ipw-> titleBlockProperties().toSettings(settings, "diagrameditor/default");
Modified: trunk/sources/diagramview.cpp
===================================================================
--- trunk/sources/diagramview.cpp 2014-07-09 16:50:30 UTC (rev 3202)
+++ trunk/sources/diagramview.cpp 2014-07-11 16:45:18 UTC (rev 3203)
@@ -31,7 +31,6 @@
#include "templatelocation.h"
#include "qetapp.h"
#include "qetproject.h"
-#include "borderpropertieswidget.h"
#include "integrationmoveelementshandler.h"
#include "integrationmovetemplateshandler.h"
#include "qetdiagrameditor.h"
@@ -43,6 +42,7 @@
#include <QGraphicsPixmapItem>
#include <QGraphicsSceneMouseEvent>
#include "factory/elementfactory.h"
+#include "ui/borderpropertieswidget.h"
/**
@@ -688,7 +688,7 @@
// si le dialogue est accepte
if (popup.exec() == QDialog::Accepted && !diagram_is_read_only) {
TitleBlockProperties new_titleblock = titleblock_infos -> titleBlockProperties();
- BorderProperties new_border = border_infos -> borderProperties();
+ BorderProperties new_border = border_infos -> properties();
ConductorProperties new_conductors = cpw -> conductorProperties();
bool adjust_scene = false;
Modified: trunk/sources/projectconfigpages.cpp
===================================================================
--- trunk/sources/projectconfigpages.cpp 2014-07-09 16:50:30 UTC (rev 3202)
+++ trunk/sources/projectconfigpages.cpp 2014-07-11 16:45:18 UTC (rev 3203)
@@ -238,9 +238,9 @@
void ProjectNewDiagramConfigPage::applyProjectConf() {
bool modified_project = false;
- BorderProperties new_border_prop = border_ -> borderProperties();
+ BorderProperties new_border_prop = border_ -> properties();
if (project_ -> defaultBorderProperties() != new_border_prop) {
- project_ -> setDefaultBorderProperties(border_ -> borderProperties());
+ project_ -> setDefaultBorderProperties(border_ -> properties());
modified_project = true;
}
@@ -318,7 +318,7 @@
Read properties from the edited project then fill widgets with them.
*/
void ProjectNewDiagramConfigPage::readValuesFromProject() {
- border_ -> setEditedBorder (project_ -> defaultBorderProperties());
+ border_ -> setProperties (project_ -> defaultBorderProperties());
conductor_ -> setConductorProperties (project_ -> defaultConductorProperties());
titleblock_ -> setTitleBlockProperties (project_ -> defaultTitleBlockProperties());
report_ -> setReportProperties (project_ -> defaultReportProperties());
Added: trunk/sources/ui/borderpropertieswidget.cpp
===================================================================
--- trunk/sources/ui/borderpropertieswidget.cpp (rev 0)
+++ trunk/sources/ui/borderpropertieswidget.cpp 2014-07-11 16:45:18 UTC (rev 3203)
@@ -0,0 +1,93 @@
+/*
+ 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 "borderpropertieswidget.h"
+#include "ui_borderpropertieswidget.h"
+#include "diagram.h"
+
+/**
+ * @brief BorderPropertiesWidget::BorderPropertiesWidget
+ * default constructor
+ * @param bp properties
+ * @param parent paretn widget
+ */
+BorderPropertiesWidget::BorderPropertiesWidget(const BorderProperties &bp, QWidget *parent) :
+ QWidget(parent),
+ ui(new Ui::BorderPropertiesWidget)
+{
+ ui->setupUi(this);
+ setProperties(bp);
+}
+
+/**
+ * @brief BorderPropertiesWidget::~BorderPropertiesWidget
+ * default destructor
+ */
+BorderPropertiesWidget::~BorderPropertiesWidget()
+{
+ delete ui;
+}
+
+/**
+ * @brief BorderPropertiesWidget::setProperties
+ * Set the current properties to edit
+ * @param bp properties to edit
+ */
+void BorderPropertiesWidget::setProperties(const BorderProperties &bp) {
+ m_properties = bp;
+ ui -> m_colums_count_sp ->setValue (m_properties.columns_count);
+ ui -> m_columns_width_sp ->setValue (m_properties.columns_width);
+ ui -> m_display_columns_cb ->setChecked (m_properties.display_columns);
+ ui -> m_rows_count_sp ->setValue (m_properties.rows_count);
+ ui -> m_rows_height_sp ->setValue (m_properties.rows_height);
+ ui -> m_display_rows_cb ->setChecked (m_properties.display_rows);
+ ui -> m_grey_bg_cb ->setChecked (Diagram::background_color != Qt::white);
+}
+
+/**
+ * @brief BorderPropertiesWidget::properties
+ * @return the edited border properties
+ */
+const BorderProperties &BorderPropertiesWidget::properties () {
+ m_properties.columns_count = ui -> m_colums_count_sp -> value();
+ m_properties.columns_width = ui -> m_columns_width_sp -> value();
+ m_properties.display_columns = ui -> m_display_columns_cb -> isChecked();
+ m_properties.rows_count = ui -> m_rows_count_sp -> value();
+ m_properties.rows_height = ui -> m_rows_height_sp -> value();
+ m_properties.display_rows = ui -> m_display_rows_cb -> isChecked();
+ return m_properties;
+}
+
+/**
+ * @brief BorderPropertiesWidget::setReadOnly
+ * Enable or disable this widget
+ * @param ro true-disable / false-enable
+ */
+void BorderPropertiesWidget::setReadOnly(const bool &ro) {
+ ui->border_gb->setDisabled(ro);
+}
+
+/**
+ * @brief BorderPropertiesWidget::on_m_grey_bg_cb_clicked
+ * @param checked
+ */
+void BorderPropertiesWidget::on_m_grey_bg_cb_clicked(bool checked) {
+ if (checked)
+ Diagram::background_color = Qt::gray;
+ else
+ Diagram::background_color = Qt::white;
+}
Added: trunk/sources/ui/borderpropertieswidget.h
===================================================================
--- trunk/sources/ui/borderpropertieswidget.h (rev 0)
+++ trunk/sources/ui/borderpropertieswidget.h 2014-07-11 16:45:18 UTC (rev 3203)
@@ -0,0 +1,52 @@
+/*
+ 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 BORDERPROPERTIESWIDGET_H
+#define BORDERPROPERTIESWIDGET_H
+
+#include <QWidget>
+#include "borderproperties.h"
+
+namespace Ui {
+ class BorderPropertiesWidget;
+}
+
+/**
+ * @brief The BorderPropertiesWidget class
+ * this widget edit the properties of a border
+ */
+class BorderPropertiesWidget : public QWidget
+{
+ Q_OBJECT
+
+ public:
+ explicit BorderPropertiesWidget(const BorderProperties &bp, QWidget *parent = 0);
+ ~BorderPropertiesWidget();
+
+ void setProperties(const BorderProperties &bp);
+ const BorderProperties &properties();
+ void setReadOnly (const bool &ro);
+
+ private slots:
+ void on_m_grey_bg_cb_clicked(bool checked);
+
+ private:
+ Ui::BorderPropertiesWidget *ui;
+ BorderProperties m_properties;
+};
+
+#endif // BORDERPROPERTIESWIDGET_H
Added: trunk/sources/ui/borderpropertieswidget.ui
===================================================================
--- trunk/sources/ui/borderpropertieswidget.ui (rev 0)
+++ trunk/sources/ui/borderpropertieswidget.ui 2014-07-11 16:45:18 UTC (rev 3203)
@@ -0,0 +1,104 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>BorderPropertiesWidget</class>
+ <widget class="QWidget" name="BorderPropertiesWidget">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>412</width>
+ <height>300</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QGroupBox" name="border_gb">
+ <property name="title">
+ <string>Dimensions du schéma</string>
+ </property>
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="1" column="2">
+ <widget class="QSpinBox" name="m_rows_height_sp">
+ <property name="suffix">
+ <string comment="pixel" extracomment="pixel">px</string>
+ </property>
+ <property name="prefix">
+ <string>x</string>
+ </property>
+ <property name="maximum">
+ <number>1000</number>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="label_3">
+ <property name="text">
+ <string>Lignes :</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="3">
+ <widget class="QCheckBox" name="m_grey_bg_cb">
+ <property name="text">
+ <string>Gris</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="0">
+ <widget class="QLabel" name="label_2">
+ <property name="text">
+ <string>Colonnes :</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0">
+ <widget class="QLabel" name="label_4">
+ <property name="text">
+ <string>Couleur de fond :</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="3">
+ <widget class="QCheckBox" name="m_display_rows_cb">
+ <property name="text">
+ <string>Afficher les en-têtes</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="2">
+ <widget class="QSpinBox" name="m_columns_width_sp">
+ <property name="suffix">
+ <string comment="pixel" extracomment="pixel">px</string>
+ </property>
+ <property name="prefix">
+ <string>x</string>
+ </property>
+ <property name="maximum">
+ <number>1000</number>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QSpinBox" name="m_rows_count_sp"/>
+ </item>
+ <item row="0" column="3">
+ <widget class="QCheckBox" name="m_display_columns_cb">
+ <property name="text">
+ <string>Afficher les en-têtes</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QSpinBox" name="m_colums_count_sp"/>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>