2008-08-14 22:51:08 +00:00
|
|
|
/*
|
2010-01-03 16:25:37 +00:00
|
|
|
Copyright 2006-2010 Xavier Guerrin
|
2008-08-14 22:51:08 +00:00
|
|
|
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 "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() {
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2010-02-28 16:13:45 +00:00
|
|
|
@return Les proprietes editees par ce widget
|
2008-08-14 22:51:08 +00:00
|
|
|
*/
|
|
|
|
const BorderProperties &BorderPropertiesWidget::borderProperties() {
|
2008-08-15 12:46:22 +00:00
|
|
|
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();
|
2008-08-14 22:51:08 +00:00
|
|
|
return(border_);
|
|
|
|
}
|
|
|
|
|
2010-02-28 16:13:45 +00:00
|
|
|
/**
|
|
|
|
@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);
|
|
|
|
}
|
|
|
|
|
2008-08-14 22:51:08 +00:00
|
|
|
/**
|
|
|
|
Definit les proprietes a editer
|
|
|
|
@param bp Nouvelles proprietes
|
|
|
|
*/
|
|
|
|
void BorderPropertiesWidget::setEditedBorder(const BorderProperties &bp) {
|
|
|
|
border_ = bp;
|
2008-08-15 12:46:22 +00:00
|
|
|
columns_count -> setValue(border_.columns_count);
|
2009-04-03 19:30:25 +00:00
|
|
|
columns_width -> setValue(qRound(border_.columns_width));
|
2008-08-15 12:46:22 +00:00
|
|
|
display_columns -> setChecked(border_.display_columns);
|
|
|
|
rows_count -> setValue(border_.rows_count);
|
2009-04-03 19:30:25 +00:00
|
|
|
rows_height -> setValue(qRound(border_.rows_height));
|
2008-08-15 12:46:22 +00:00
|
|
|
display_rows -> setChecked(border_.display_rows);
|
2008-08-14 22:51:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
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());
|
2010-09-14 17:28:17 +00:00
|
|
|
columns_count -> setMaximum(10000); // valeur arbitraire
|
2008-08-14 22:51:08 +00:00
|
|
|
|
|
|
|
columns_width = new QSpinBox(diagram_size_box);
|
|
|
|
columns_width -> setMinimum(qRound(BorderInset::minColumnsWidth()));
|
|
|
|
columns_width -> setSingleStep(10);
|
2009-04-03 19:30:25 +00:00
|
|
|
columns_width -> setPrefix(tr("\327", "multiplication symbol"));
|
|
|
|
columns_width -> setSuffix(tr("px", "unit for cols width"));
|
2008-08-14 22:51:08 +00:00
|
|
|
|
2009-04-03 19:30:25 +00:00
|
|
|
display_columns = new QCheckBox(tr("Afficher les en-t\352tes"), diagram_size_box);
|
2008-08-15 12:46:22 +00:00
|
|
|
|
2008-08-14 22:51:08 +00:00
|
|
|
// lignes : nombre et largeur
|
|
|
|
QLabel *ds2 = new QLabel(tr("Lignes :"));
|
|
|
|
|
|
|
|
rows_count = new QSpinBox(diagram_size_box);
|
|
|
|
rows_count -> setMinimum(BorderInset::minNbRows());
|
2010-09-14 17:28:17 +00:00
|
|
|
rows_count -> setMaximum(10000); // valeur arbitraire
|
2008-08-14 22:51:08 +00:00
|
|
|
|
|
|
|
rows_height = new QSpinBox(diagram_size_box);
|
|
|
|
rows_height -> setMinimum(qRound(BorderInset::minRowsHeight()));
|
|
|
|
rows_height -> setSingleStep(10);
|
2009-04-03 19:30:25 +00:00
|
|
|
rows_height -> setPrefix(tr("\327", "multiplication symbol"));
|
|
|
|
rows_height -> setSuffix(tr("px", "unit for rows height"));
|
2008-08-14 22:51:08 +00:00
|
|
|
|
2009-04-03 19:30:25 +00:00
|
|
|
display_rows = new QCheckBox(tr("Afficher les en-t\352tes"), diagram_size_box);
|
2008-08-15 12:46:22 +00:00
|
|
|
|
2008-08-14 22:51:08 +00:00
|
|
|
// 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);
|
2008-08-15 12:46:22 +00:00
|
|
|
diagram_size_box_layout -> addWidget(display_columns,0, 3);
|
2008-08-14 22:51:08 +00:00
|
|
|
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);
|
2008-08-15 12:46:22 +00:00
|
|
|
diagram_size_box_layout -> addWidget(display_rows, 1, 3);
|
2008-08-14 22:51:08 +00:00
|
|
|
|
|
|
|
widget_layout -> addWidget(diagram_size_box);
|
|
|
|
setLayout(widget_layout);
|
|
|
|
}
|