From faf504f2d05966ffee8975be4c5053894bb85b5a Mon Sep 17 00:00:00 2001 From: xavierqet Date: Thu, 14 Aug 2008 22:51:08 +0000 Subject: [PATCH] Ajout des classes BorderProperties et BorderPropertiesWidget git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@371 bfdf4180-ca20-0410-9c96-a3a8aa849046 --- qelectrotech.pro | 4 + sources/borderinset.cpp | 68 +++++++++++++--- sources/borderinset.h | 24 ++---- sources/borderproperties.cpp | 55 +++++++++++++ sources/borderproperties.h | 45 +++++++++++ sources/borderpropertieswidget.cpp | 109 ++++++++++++++++++++++++++ sources/borderpropertieswidget.h | 54 +++++++++++++ sources/conductorpropertieswidget.cpp | 1 + sources/configpages.cpp | 73 +++++------------ sources/configpages.h | 6 +- sources/diagramview.cpp | 76 ++++-------------- sources/qetarguments.cpp | 17 ++++ sources/qetdiagrameditor.cpp | 22 ++++++ sources/qetdiagrameditor.h | 2 + sources/recentfiles.cpp | 17 ++++ 15 files changed, 423 insertions(+), 150 deletions(-) create mode 100644 sources/borderproperties.cpp create mode 100644 sources/borderproperties.h create mode 100644 sources/borderpropertieswidget.cpp create mode 100644 sources/borderpropertieswidget.h diff --git a/qelectrotech.pro b/qelectrotech.pro index f19be5728..5794f9f00 100644 --- a/qelectrotech.pro +++ b/qelectrotech.pro @@ -40,6 +40,8 @@ INCLUDEPATH += sources sources/editor # Fichiers sources HEADERS += sources/aboutqet.h \ sources/borderinset.h \ + sources/borderproperties.h \ + sources/borderpropertieswidget.h \ sources/conductor.h \ sources/conductorprofile.h \ sources/conductorproperties.h \ @@ -109,6 +111,8 @@ HEADERS += sources/aboutqet.h \ sources/editor/textfieldeditor.h SOURCES += sources/aboutqet.cpp \ sources/borderinset.cpp \ + sources/borderproperties.cpp \ + sources/borderpropertieswidget.cpp \ sources/conductor.cpp \ sources/conductorprofile.cpp \ sources/conductorproperties.cpp \ diff --git a/sources/borderinset.cpp b/sources/borderinset.cpp index aaf86daa7..661a7c8d0 100644 --- a/sources/borderinset.cpp +++ b/sources/borderinset.cpp @@ -18,6 +18,7 @@ #include #include "borderinset.h" #include "qetapp.h" +#include "qetdiagrameditor.h" #include "math.h" /** @@ -26,22 +27,13 @@ @param parent QObject parent de ce BorderInset */ BorderInset::BorderInset(QObject *parent) : QObject(parent) { - // initialise les dimensions des colonnes (ainsi que la largeur du cartouche) - columns_header_height = 20.0; - setNbColumns (QETApp::settings().value("diagrameditor/defaultcols", 15).toInt()); - setColumnsWidth(QETApp::settings().value("diagrameditor/defaultcolsize", 50.0).toDouble()); - - // initialise les dimensions des lignes - rows_header_width = 20.0; - setNbRows(QETApp::settings().value("diagrameditor/defaultrows", 6).toInt()); - setRowsHeight(QETApp::settings().value("diagrameditor/defaultrowsize", 80.0).toDouble()); + // dimensions par defaut du schema + importBorder(QETDiagramEditor::defaultBorderProperties()); // hauteur du cartouche inset_height = 50.0; display_inset = true; - display_columns = true; - display_rows = true; display_border = true; updateRectangles(); @@ -89,6 +81,60 @@ qreal BorderInset::minRowsHeight() { return(5.0); } +/** + @return les proprietes du cartouches +*/ +InsetProperties BorderInset::exportInset() { + InsetProperties ip; + ip.author = bi_author; + ip.date = bi_date; + ip.title = bi_title; + ip.folio = bi_folio; + ip.filename = bi_filename; + return(ip); +} + +/** + @param ip les nouvelles proprietes du cartouche +*/ +void BorderInset::importInset(const InsetProperties &ip) { + bi_author = ip.author; + bi_date = ip.date; + bi_title = ip.title; + bi_folio = ip.folio; + bi_filename = ip.filename; +} + +/** + @return les proprietes de la bordure +*/ +BorderProperties BorderInset::exportBorder() { + BorderProperties bp; + bp.columns_count = nbColumns(); + bp.columns_width = columnsWidth(); + bp.columns_header_height = columnsHeaderHeight(); + bp.display_columns = columnsAreDisplayed(); + bp.rows_count = nbRows(); + bp.rows_height = rowsHeight(); + bp.rows_header_width = rowsHeaderWidth(); + bp.display_rows = rowsAreDisplayed(); + return(bp); +} + +/** + @param ip les nouvelles proprietes de la bordure +*/ +void BorderInset::importBorder(const BorderProperties &bp) { + setColumnsHeaderHeight(bp.columns_header_height); + setNbColumns(bp.columns_count); + setColumnsWidth(bp.columns_width); + displayColumns(bp.display_columns); + setRowsHeaderWidth(bp.rows_header_width); + setNbRows(bp.rows_count); + setRowsHeight(bp.rows_height); + displayRows(bp.display_rows); +} + /** Methode recalculant les rectangles composant le cadre et le cartouche en fonction des attributs de taille diff --git a/sources/borderinset.h b/sources/borderinset.h index b65141528..edb0b9040 100644 --- a/sources/borderinset.h +++ b/sources/borderinset.h @@ -18,6 +18,7 @@ #ifndef BORDERINSET_H #define BORDERINSET_H #include "insetproperties.h" +#include "borderproperties.h" #include #include #include @@ -135,25 +136,10 @@ class BorderInset : public QObject { /// @param filename le nouveau contenu du champ "Fichier" void setFileName (const QString &filename) { bi_filename = filename; } - /// @return les proprietes du cartouches - InsetProperties exportInset() { - InsetProperties ip; - ip.author = bi_author; - ip.date = bi_date; - ip.title = bi_title; - ip.folio = bi_folio; - ip.filename = bi_filename; - return(ip); - } - - /// @param ip les nouvelles proprietes du cartouche - void importInset(const InsetProperties &ip) { - bi_author = ip.author; - bi_date = ip.date; - bi_title = ip.title; - bi_folio = ip.folio; - bi_filename = ip.filename; - } + InsetProperties exportInset(); + void importInset(const InsetProperties &); + BorderProperties exportBorder(); + void importBorder(const BorderProperties &); // methodes d'acces en ecriture aux options /// @param di true pour afficher le cartouche, false sinon diff --git a/sources/borderproperties.cpp b/sources/borderproperties.cpp new file mode 100644 index 000000000..6eb7c53a8 --- /dev/null +++ b/sources/borderproperties.cpp @@ -0,0 +1,55 @@ +/* + Copyright 2006-2008 Xavier Guerrin + 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 "borderproperties.h" + +/** + Constructeur +*/ +BorderProperties::BorderProperties() { +} + +/** + Destructeur +*/ +BorderProperties::~BorderProperties() { +} + +/** + @param bp autre conteneur BorderProperties + @return true si ip et ce conteneur sont identiques, false sinon +*/ +bool BorderProperties::operator==(const BorderProperties &bp) { + return( + bp.columns_count == columns_count &&\ + bp.columns_width == columns_width &&\ + bp.columns_header_height == columns_header_height &&\ + bp.display_columns == display_columns &&\ + bp.rows_count == rows_count &&\ + bp.rows_height == rows_height &&\ + bp.rows_header_width == rows_header_width &&\ + bp.display_rows == display_rows + ); +} + +/** + @param bp autre conteneur BorderProperties + @return false si bp et ce conteneur sont identiques, true sinon +*/ +bool BorderProperties::operator!=(const BorderProperties &bp) { + return(!(*this == bp)); +} diff --git a/sources/borderproperties.h b/sources/borderproperties.h new file mode 100644 index 000000000..e40b4bac4 --- /dev/null +++ b/sources/borderproperties.h @@ -0,0 +1,45 @@ +/* + Copyright 2006-2008 Xavier Guerrin + 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 BORDER_PROPERTIES_H +#define BORDER_PROPERTIES_H +#include +/** + Cette classe est un conteneur pour les dimensions et proprietes d'affichage + d'un schema : affichage, nombre et dimensions des colonnes et lignes, ... +*/ +class BorderProperties { + public: + // constructeur, destructeur, operateurs + BorderProperties(); + virtual ~BorderProperties(); + + bool operator==(const BorderProperties &); + bool operator!=(const BorderProperties &); + + // attributs + int columns_count; ///< Nombre de colonnes + qreal columns_width; ///< Largeur des colonnes + qreal columns_header_height; ///< Hauteur des entetes des colonnes + bool display_columns; ///< Afficher ou non les entetes des colonnes + + int rows_count; ///< Nombre de lignes + qreal rows_height; ///< Hauteur des lignes + qreal rows_header_width; ///< Largeur des entetes des lignes + bool display_rows; ///< Afficher ou non les entetes des lignes +}; +#endif diff --git a/sources/borderpropertieswidget.cpp b/sources/borderpropertieswidget.cpp new file mode 100644 index 000000000..cf1b23d4b --- /dev/null +++ b/sources/borderpropertieswidget.cpp @@ -0,0 +1,109 @@ +/* + Copyright 2006-2008 Xavier Guerrin + 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 "borderpropertieswidget.h" +#include +#include "qetapp.h" +#include "borderinset.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 the border properties edited and modified by +*/ +const BorderProperties &BorderPropertiesWidget::borderProperties() { + border_.columns_count = columns_count -> value(); + border_.columns_width = columns_width -> value(); + border_.rows_count = rows_count -> value(); + border_.rows_height = rows_height -> value(); + return(border_); +} + +/** + 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(border_.columns_width); + rows_count -> setValue(border_.rows_count); + rows_height -> setValue(border_.rows_height); +} + +/** + 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(BorderInset::minNbColumns()); + + columns_width = new QSpinBox(diagram_size_box); + columns_width -> setMinimum(qRound(BorderInset::minColumnsWidth())); + columns_width -> setSingleStep(10); + columns_width -> setPrefix(tr("\327")); + columns_width -> setSuffix(tr("px")); + + // lignes : nombre et largeur + QLabel *ds2 = new QLabel(tr("Lignes :")); + + rows_count = new QSpinBox(diagram_size_box); + rows_count -> setMinimum(BorderInset::minNbRows()); + + rows_height = new QSpinBox(diagram_size_box); + rows_height -> setMinimum(qRound(BorderInset::minRowsHeight())); + rows_height -> setSingleStep(10); + rows_height -> setPrefix(tr("\327")); + rows_height -> setSuffix(tr("px")); + + // 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(ds2, 1, 0); + diagram_size_box_layout -> addWidget(rows_count, 1, 1); + diagram_size_box_layout -> addWidget(rows_height, 1, 2); + + widget_layout -> addWidget(diagram_size_box); + setLayout(widget_layout); +} diff --git a/sources/borderpropertieswidget.h b/sources/borderpropertieswidget.h new file mode 100644 index 000000000..5ed59be33 --- /dev/null +++ b/sources/borderpropertieswidget.h @@ -0,0 +1,54 @@ +/* + Copyright 2006-2008 Xavier Guerrin + 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 BORDER_PROPERTIES_WIDGET_H +#define BORDER_PROPERTIES_WIDGET_H +#include +#include "borderproperties.h" +class QSpinBox; +/** + Cette classe represente un widget permettant d'editer les dimensions et les + options d'affichage d'un schema, cartouche non inclus. + @see InsetPropertiesWidget +*/ +class BorderPropertiesWidget : public QWidget { + Q_OBJECT + + // constructeurs, destructeur + public: + BorderPropertiesWidget(const BorderProperties &, QWidget * = 0); + virtual ~BorderPropertiesWidget(); + private: + BorderPropertiesWidget(const BorderPropertiesWidget &); + + // methodes + public: + const BorderProperties &borderProperties(); + + private: + void setEditedBorder(const BorderProperties &); + void build(); + + // attributs + private: + BorderProperties border_; ///< Proprietes editees + QSpinBox *columns_count; ///< Widget d'edition du nombre de colonnes + QSpinBox *columns_width; ///< Widget d'edition de la largeur des colonnes + QSpinBox *rows_count; ///< Widget d'edition du nombre de lignes + QSpinBox *rows_height; ///< Widget d'edition de la hauteur des lignes +}; +#endif diff --git a/sources/conductorpropertieswidget.cpp b/sources/conductorpropertieswidget.cpp index 0b97d4cf1..85770fca6 100644 --- a/sources/conductorpropertieswidget.cpp +++ b/sources/conductorpropertieswidget.cpp @@ -47,6 +47,7 @@ void ConductorPropertiesWidget::buildInterface() { setMinimumSize(380, 280); QVBoxLayout *main_layout = new QVBoxLayout(this); + main_layout -> setContentsMargins(0, 0, 0, 0); QGroupBox *groupbox = new QGroupBox(tr("Type de conducteur")); main_layout -> addWidget(groupbox); diff --git a/sources/configpages.cpp b/sources/configpages.cpp index b372aa285..c3669970f 100644 --- a/sources/configpages.cpp +++ b/sources/configpages.cpp @@ -16,6 +16,7 @@ along with QElectroTech. If not, see . */ #include "configpages.h" +#include "borderpropertieswidget.h" #include "conductorpropertieswidget.h" #include "insetpropertieswidget.h" #include "qetapp.h" @@ -31,11 +32,17 @@ NewDiagramPage::NewDiagramPage(QWidget *parent) : ConfigPage(parent) { // acces a la configuration de QElectroTech QSettings &settings = QETApp::settings(); - // recupere les dimensions du schema - int columns_count_value = settings.value("diagrameditor/defaultcols", 15).toInt(); - int columns_width_value = qRound(settings.value("diagrameditor/defaultcolsize", 50.0).toDouble()); - int rows_count_value = settings.value("diagrameditor/defaultrows", 6).toInt(); - int rows_height_value = qRound(settings.value("diagrameditor/defaultrowsize", 80.0).toDouble()); + // dimensions par defaut d'un schema + bpw = new BorderPropertiesWidget(QETDiagramEditor::defaultBorderProperties()); + + // proprietes par defaut d'un cartouche + ipw = new InsetPropertiesWidget(QETDiagramEditor::defaultInsetProperties(), true); + + // proprietes par defaut des conducteurs + ConductorProperties cp; + cp.fromSettings(settings, "diagrameditor/defaultconductor"); + cpw = new ConductorPropertiesWidget(cp); + cpw -> setContentsMargins(0, 0, 0, 0); QVBoxLayout *vlayout1 = new QVBoxLayout(); @@ -49,52 +56,9 @@ NewDiagramPage::NewDiagramPage(QWidget *parent) : ConfigPage(parent) { QHBoxLayout *hlayout1 = new QHBoxLayout(); QVBoxLayout *vlayout2 = new QVBoxLayout(); - QGroupBox *diagram_size_box = new QGroupBox(tr("Dimensions du sch\351ma")); - diagram_size_box -> setMinimumWidth(300); - QGridLayout *diagram_size_box_layout = new QGridLayout(diagram_size_box); - - QLabel *ds1 = new QLabel(tr("Colonnes :")); - - columns_count = new QSpinBox(diagram_size_box); - columns_count -> setMinimum(BorderInset::minNbColumns()); - columns_count -> setValue(columns_count_value); - - columns_width = new QSpinBox(diagram_size_box); - columns_width -> setMinimum(qRound(BorderInset::minColumnsWidth())); - columns_width -> setSingleStep(10); - columns_width -> setValue(columns_width_value); - columns_width -> setPrefix(tr("\327")); - columns_width -> setSuffix(tr("px")); - - QLabel *ds2 = new QLabel(tr("Lignes :")); - - rows_count = new QSpinBox(diagram_size_box); - rows_count -> setMinimum(BorderInset::minNbRows()); - rows_count -> setValue(rows_count_value); - - rows_height = new QSpinBox(diagram_size_box); - rows_height -> setMinimum(qRound(BorderInset::minRowsHeight())); - rows_height -> setSingleStep(10); - rows_height -> setValue(rows_height_value); - rows_height -> setPrefix(tr("\327")); - rows_height -> setSuffix(tr("px")); - - 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(ds2, 1, 0); - diagram_size_box_layout -> addWidget(rows_count, 1, 1); - diagram_size_box_layout -> addWidget(rows_height, 1, 2); - - ipw = new InsetPropertiesWidget(QETDiagramEditor::defaultInsetProperties(), true, this); - - // proprietes par defaut des conducteurs - ConductorProperties cp; - cp.fromSettings(settings, "diagrameditor/defaultconductor"); - cpw = new ConductorPropertiesWidget(cp); - - vlayout2 -> addWidget(diagram_size_box); + vlayout2 -> addWidget(bpw); vlayout2 -> addWidget(ipw); + vlayout2 -> setSpacing(5); hlayout1 -> addLayout(vlayout2); hlayout1 -> addWidget(cpw); vlayout1 -> addLayout(hlayout1); @@ -114,10 +78,11 @@ void NewDiagramPage::applyConf() { QSettings &settings = QETApp::settings(); // dimensions des nouveaux schemas - settings.setValue("diagrameditor/defaultcols", columns_count -> value()); - settings.setValue("diagrameditor/defaultcolsize", columns_width -> value()); - settings.setValue("diagrameditor/defaultrows", rows_count -> value()); - settings.setValue("diagrameditor/defaultrowsize", rows_height -> value()); + BorderProperties border = bpw -> borderProperties(); + settings.setValue("diagrameditor/defaultcols", border.columns_count); + settings.setValue("diagrameditor/defaultcolsize", border.columns_width); + settings.setValue("diagrameditor/defaultrows", border.rows_count); + settings.setValue("diagrameditor/defaultrowsize", border.rows_height); // proprietes du cartouche InsetProperties inset = ipw-> insetProperties(); diff --git a/sources/configpages.h b/sources/configpages.h index 697fd014e..9bc8af990 100644 --- a/sources/configpages.h +++ b/sources/configpages.h @@ -18,6 +18,7 @@ #ifndef CONFIG_PAGES_H #define CONFIG_PAGES_H #include +class BorderPropertiesWidget; class ConductorPropertiesWidget; class InsetPropertiesWidget; @@ -63,10 +64,7 @@ class NewDiagramPage : public ConfigPage { // attributs public: - QSpinBox *columns_count; ///< Widget d'edition du nombre par defaut de colonnes - QSpinBox *columns_width; ///< Widget d'edition de la largeur par defaut des colonnes - QSpinBox *rows_count; ///< Widget d'edition du nombre par defaut de lignes - QSpinBox *rows_height; ///< Widget d'edition de la hauteur par defaut des lignes + BorderPropertiesWidget *bpw; ///< Widget d'edition des dimensions du schema InsetPropertiesWidget *ipw; ///< Widget d'edition des proprietes par defaut du cartouche ConductorPropertiesWidget *cpw; ///< Widget d'edition des proprietes par defaut des conducteurs }; diff --git a/sources/diagramview.cpp b/sources/diagramview.cpp index 5003d2c97..940aabd79 100644 --- a/sources/diagramview.cpp +++ b/sources/diagramview.cpp @@ -24,6 +24,7 @@ #include "diagramcommands.h" #include "conductorpropertieswidget.h" #include "insetpropertieswidget.h" +#include "borderpropertieswidget.h" /** Constructeur @@ -547,61 +548,17 @@ void DiagramView::dialogPrint() { Edite les informations du schema. */ void DiagramView::dialogEditInfos() { - // recupere le cartouche du schema - InsetProperties inset = scene -> border_and_inset.exportInset(); - - // recupere les dimensions du schema - int columns_count_value = scene -> border_and_inset.nbColumns(); - int columns_width_value = qRound(scene -> border_and_inset.columnsWidth()); - int rows_count_value = scene -> border_and_inset.nbRows(); - int rows_height_value = qRound(scene -> border_and_inset.rowsHeight()); + // recupere le cartouche et les dimensions du schema + InsetProperties inset = scene -> border_and_inset.exportInset(); + BorderProperties border = scene -> border_and_inset.exportBorder(); // construit le dialogue QDialog popup; popup.setMinimumWidth(400); popup.setWindowTitle(tr("Propri\351t\351s du sch\351ma")); - QGroupBox *diagram_size_box = new QGroupBox(tr("Dimensions du sch\351ma"), &popup); - QGridLayout diagram_size_box_layout(diagram_size_box); - - QLabel *ds1 = new QLabel(tr("Colonnes :")); - - QSpinBox *columns_count = new QSpinBox(diagram_size_box); - columns_count -> setMinimum(BorderInset::minNbColumns()); - columns_count -> setValue(columns_count_value); - - QSpinBox *columns_width = new QSpinBox(diagram_size_box); - columns_width -> setMinimum(qRound(BorderInset::minColumnsWidth())); - columns_width -> setSingleStep(10); - columns_width -> setValue(columns_width_value); - columns_width -> setPrefix(tr("\327")); - columns_width -> setSuffix(tr("px")); - - QLabel *ds2 = new QLabel(tr("Lignes :")); - - QSpinBox *rows_count = new QSpinBox(diagram_size_box); - rows_count -> setMinimum(BorderInset::minNbRows()); - rows_count -> setValue(rows_count_value); - - QSpinBox *rows_height = new QSpinBox(diagram_size_box); - rows_height -> setMinimum(qRound(BorderInset::minRowsHeight())); - rows_height -> setSingleStep(10); - rows_height -> setValue(rows_height_value); - rows_height -> setPrefix(tr("\327")); - rows_height -> setSuffix(tr("px")); - - 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(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.setColumnStretch(0, 1); - diagram_size_box_layout.setColumnStretch(1, 1); - diagram_size_box_layout.setColumnStretch(2, 1); - diagram_size_box_layout.setColumnStretch(3, 500); - - InsetPropertiesWidget *inset_infos = new InsetPropertiesWidget(inset, false, &popup); + BorderPropertiesWidget *border_infos = new BorderPropertiesWidget(border, &popup); + InsetPropertiesWidget *inset_infos = new InsetPropertiesWidget(inset, false, &popup); // boutons QDialogButtonBox boutons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); @@ -610,31 +567,26 @@ void DiagramView::dialogEditInfos() { // ajout dans une disposition verticale QVBoxLayout layout_v(&popup); - layout_v.addWidget(diagram_size_box); + layout_v.addWidget(border_infos); layout_v.addWidget(inset_infos); layout_v.addStretch(); layout_v.addWidget(&boutons); // si le dialogue est accepte if (popup.exec() == QDialog::Accepted) { - InsetProperties new_inset = inset_infos -> insetProperties(); - + InsetProperties new_inset = inset_infos -> insetProperties(); + BorderProperties new_border = border_infos -> borderProperties(); // s'il y a des modifications au cartouche if (new_inset != inset) { scene -> undoStack().push(new ChangeInsetCommand(scene, inset, new_inset)); } // s'il y a des modifications aux dimensions du schema - if ( - columns_count_value != columns_count -> value() ||\ - columns_width_value != columns_width -> value() ||\ - rows_count_value != rows_count -> value() ||\ - rows_height_value != rows_height -> value() - ) { + if (new_border != border) { ChangeBorderCommand *cbc = new ChangeBorderCommand(scene); - cbc -> columnsCountDifference = columns_count -> value() - columns_count_value; - cbc -> columnsWidthDifference = columns_width -> value() - columns_width_value; - cbc -> rowsCountDifference = rows_count -> value() - rows_count_value; - cbc -> rowsHeightDifference = rows_height -> value() - rows_height_value; + cbc -> columnsCountDifference = new_border.columns_count - border.columns_count; + cbc -> columnsWidthDifference = new_border.columns_width - border.columns_width; + cbc -> rowsCountDifference = new_border.rows_count - border.rows_count; + cbc -> rowsHeightDifference = new_border.rows_height - border.rows_height; scene -> undoStack().push(cbc); } } diff --git a/sources/qetarguments.cpp b/sources/qetarguments.cpp index 83397fabc..a1b9e7bd6 100644 --- a/sources/qetarguments.cpp +++ b/sources/qetarguments.cpp @@ -1,3 +1,20 @@ +/* + Copyright 2006-2008 Xavier Guerrin + 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 "qetarguments.h" /** diff --git a/sources/qetdiagrameditor.cpp b/sources/qetdiagrameditor.cpp index 38682becc..00c8f43f3 100644 --- a/sources/qetdiagrameditor.cpp +++ b/sources/qetdiagrameditor.cpp @@ -24,6 +24,7 @@ #include "conductorpropertieswidget.h" #include "configdialog.h" #include "recentfiles.h" + /** constructeur @param files Liste de fichiers a ouvrir @@ -1090,3 +1091,24 @@ InsetProperties QETDiagramEditor::defaultInsetProperties() { 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; + def.columns_count = settings.value("diagrameditor/defaultcols", 15).toInt(); + def.columns_width = qRound(settings.value("diagrameditor/defaultcolsize", 50.0).toDouble()); + def.columns_header_height = 20.0; + def.display_columns = true; + + def.rows_count = settings.value("diagrameditor/defaultrows", 6).toInt(); + def.rows_height = qRound(settings.value("diagrameditor/defaultrowsize", 80.0).toDouble()); + def.rows_header_width = 20.0; + def.display_rows = true; + + return(def); +} diff --git a/sources/qetdiagrameditor.h b/sources/qetdiagrameditor.h index 396632cc4..7a692332d 100644 --- a/sources/qetdiagrameditor.h +++ b/sources/qetdiagrameditor.h @@ -18,6 +18,7 @@ #ifndef QET_DIAGRAM_EDITOR_H #define QET_DIAGRAM_EDITOR_H #include +#include "borderproperties.h" #include "insetproperties.h" class DiagramView; class ElementsPanelWidget; @@ -48,6 +49,7 @@ class QETDiagramEditor : public QMainWindow { QList editedFiles() const; DiagramView *viewForFile(const QString &) const; static InsetProperties defaultInsetProperties(); + static BorderProperties defaultBorderProperties(); protected: void actions(); diff --git a/sources/recentfiles.cpp b/sources/recentfiles.cpp index 702de7842..df87b6d39 100644 --- a/sources/recentfiles.cpp +++ b/sources/recentfiles.cpp @@ -1,3 +1,20 @@ +/* + Copyright 2006-2008 Xavier Guerrin + 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 "recentfiles.h" #include "qetapp.h"