mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-17 20:50:34 +01:00
TitleBlockPropertiesWidget: replace widget made with c++ by widget made with ui file
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3204 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -78,7 +78,7 @@ void NewDiagramPage::applyConf() {
|
|||||||
bpw -> properties().toSettings(settings, "diagrameditor/default");
|
bpw -> properties().toSettings(settings, "diagrameditor/default");
|
||||||
|
|
||||||
// proprietes du cartouche
|
// proprietes du cartouche
|
||||||
ipw-> titleBlockProperties().toSettings(settings, "diagrameditor/default");
|
ipw-> properties().toSettings(settings, "diagrameditor/default");
|
||||||
|
|
||||||
// proprietes par defaut des conducteurs
|
// proprietes par defaut des conducteurs
|
||||||
cpw -> conductorProperties().toSettings(settings, "diagrameditor/defaultconductor");
|
cpw -> conductorProperties().toSettings(settings, "diagrameditor/defaultconductor");
|
||||||
|
|||||||
@@ -653,7 +653,7 @@ void DiagramView::editDiagramProperties() {
|
|||||||
titleblock_infos -> setTitleBlockTemplatesVisible(true);
|
titleblock_infos -> setTitleBlockTemplatesVisible(true);
|
||||||
// we have to parse again the TitleBlockProperties object, since the
|
// we have to parse again the TitleBlockProperties object, since the
|
||||||
// first parsing did not know of our templates
|
// first parsing did not know of our templates
|
||||||
titleblock_infos -> setTitleBlockProperties(titleblock);
|
titleblock_infos -> setProperties(titleblock);
|
||||||
// relay the signal that requires a title block template edition
|
// relay the signal that requires a title block template edition
|
||||||
connect(titleblock_infos, SIGNAL(editTitleBlockTemplate(QString, bool)), this, SIGNAL(editTitleBlockTemplate(QString, bool)));
|
connect(titleblock_infos, SIGNAL(editTitleBlockTemplate(QString, bool)), this, SIGNAL(editTitleBlockTemplate(QString, bool)));
|
||||||
}
|
}
|
||||||
@@ -667,27 +667,15 @@ void DiagramView::editDiagramProperties() {
|
|||||||
connect(&boutons, SIGNAL(accepted()), &popup, SLOT(accept()));
|
connect(&boutons, SIGNAL(accepted()), &popup, SLOT(accept()));
|
||||||
connect(&boutons, SIGNAL(rejected()), &popup, SLOT(reject()));
|
connect(&boutons, SIGNAL(rejected()), &popup, SLOT(reject()));
|
||||||
|
|
||||||
// usual layout for these three widgets
|
QGridLayout glayout(&popup);
|
||||||
QHBoxLayout *hlayout1 = new QHBoxLayout();
|
glayout.addWidget(border_infos,0,0);
|
||||||
QVBoxLayout *vlayout2 = new QVBoxLayout();
|
glayout.addWidget(titleblock_infos, 1, 0);
|
||||||
|
glayout.addWidget(cpw, 0, 1, 0 ,1, Qt::AlignTop);
|
||||||
vlayout2 -> addWidget(border_infos);
|
glayout.addWidget(&boutons, 2, 1);
|
||||||
vlayout2 -> addWidget(titleblock_infos);
|
|
||||||
vlayout2 -> setSpacing(5);
|
|
||||||
hlayout1 -> addLayout(vlayout2);
|
|
||||||
hlayout1 -> addWidget(cpw);
|
|
||||||
hlayout1 -> setAlignment(cpw, Qt::AlignTop);
|
|
||||||
|
|
||||||
// ajout dans une disposition verticale
|
|
||||||
QVBoxLayout layout_v(&popup);
|
|
||||||
layout_v.addLayout(hlayout1);
|
|
||||||
layout_v.addStretch();
|
|
||||||
layout_v.addWidget(&boutons);
|
|
||||||
|
|
||||||
|
// if dialog is accepted
|
||||||
// si le dialogue est accepte
|
|
||||||
if (popup.exec() == QDialog::Accepted && !diagram_is_read_only) {
|
if (popup.exec() == QDialog::Accepted && !diagram_is_read_only) {
|
||||||
TitleBlockProperties new_titleblock = titleblock_infos -> titleBlockProperties();
|
TitleBlockProperties new_titleblock = titleblock_infos -> properties();
|
||||||
BorderProperties new_border = border_infos -> properties();
|
BorderProperties new_border = border_infos -> properties();
|
||||||
ConductorProperties new_conductors = cpw -> conductorProperties();
|
ConductorProperties new_conductors = cpw -> conductorProperties();
|
||||||
|
|
||||||
|
|||||||
@@ -244,9 +244,9 @@ void ProjectNewDiagramConfigPage::applyProjectConf() {
|
|||||||
modified_project = true;
|
modified_project = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
TitleBlockProperties new_tbt_prop = titleblock_ -> titleBlockProperties();
|
TitleBlockProperties new_tbt_prop = titleblock_ -> properties();
|
||||||
if (project_ -> defaultTitleBlockProperties() != new_tbt_prop) {
|
if (project_ -> defaultTitleBlockProperties() != new_tbt_prop) {
|
||||||
project_ -> setDefaultTitleBlockProperties(titleblock_ -> titleBlockProperties());
|
project_ -> setDefaultTitleBlockProperties(titleblock_ -> properties());
|
||||||
modified_project = true;
|
modified_project = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -320,7 +320,7 @@ void ProjectNewDiagramConfigPage::initLayout() {
|
|||||||
void ProjectNewDiagramConfigPage::readValuesFromProject() {
|
void ProjectNewDiagramConfigPage::readValuesFromProject() {
|
||||||
border_ -> setProperties (project_ -> defaultBorderProperties());
|
border_ -> setProperties (project_ -> defaultBorderProperties());
|
||||||
conductor_ -> setConductorProperties (project_ -> defaultConductorProperties());
|
conductor_ -> setConductorProperties (project_ -> defaultConductorProperties());
|
||||||
titleblock_ -> setTitleBlockProperties (project_ -> defaultTitleBlockProperties());
|
titleblock_ -> setProperties (project_ -> defaultTitleBlockProperties());
|
||||||
report_ -> setReportProperties (project_ -> defaultReportProperties());
|
report_ -> setReportProperties (project_ -> defaultReportProperties());
|
||||||
xref_ -> setProperties (project_ -> defaultXRefProperties());
|
xref_ -> setProperties (project_ -> defaultXRefProperties());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,439 +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 "titleblockpropertieswidget.h"
|
|
||||||
#include "diagramcontextwidget.h"
|
|
||||||
#include "qeticons.h"
|
|
||||||
#include "templatescollection.h"
|
|
||||||
#include "titleblocktemplate.h"
|
|
||||||
|
|
||||||
/**
|
|
||||||
Constructeur
|
|
||||||
@param titleblock TitleBlockProperties a afficher
|
|
||||||
@param current true pour afficher l'option "Date courante"
|
|
||||||
@param parent QWidget parent
|
|
||||||
*/
|
|
||||||
TitleBlockPropertiesWidget::TitleBlockPropertiesWidget(const TitleBlockProperties &titleblock, bool current, QWidget *parent) :
|
|
||||||
QWidget(parent),
|
|
||||||
display_current_date(false),
|
|
||||||
tbt_collection_(0)
|
|
||||||
{
|
|
||||||
initWidgets(titleblock);
|
|
||||||
initLayouts();
|
|
||||||
connect(tabbar, SIGNAL(currentChanged(int)), stack_layout, SLOT(setCurrentIndex(int)));
|
|
||||||
|
|
||||||
titleblock_current_date -> setVisible(display_current_date = current);
|
|
||||||
setTitleBlockProperties(titleblock);
|
|
||||||
|
|
||||||
// by default, we do not display the template combo box
|
|
||||||
titleblock_template_label -> setVisible(false);
|
|
||||||
titleblock_template_name -> setVisible(false);
|
|
||||||
titleblock_template_button_ -> setVisible(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Destructeur
|
|
||||||
TitleBlockPropertiesWidget::~TitleBlockPropertiesWidget() {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
@return Les proprietes affichees par le widget
|
|
||||||
*/
|
|
||||||
TitleBlockProperties TitleBlockPropertiesWidget::titleBlockProperties() const {
|
|
||||||
TitleBlockProperties prop;
|
|
||||||
prop.title = titleblock_title -> text();
|
|
||||||
prop.author = titleblock_author -> text();
|
|
||||||
prop.filename = titleblock_filename -> text();
|
|
||||||
prop.folio = titleblock_folio -> text();
|
|
||||||
if (titleblock_no_date -> isChecked()) {
|
|
||||||
prop.useDate = TitleBlockProperties::UseDateValue;
|
|
||||||
prop.date = QDate();
|
|
||||||
} else if (titleblock_fixed_date -> isChecked()) {
|
|
||||||
prop.useDate = TitleBlockProperties::UseDateValue;
|
|
||||||
prop.date = titleblock_date -> date();
|
|
||||||
} else if (display_current_date && titleblock_current_date -> isChecked()) {
|
|
||||||
prop.useDate = TitleBlockProperties::CurrentDate;
|
|
||||||
prop.date = QDate::currentDate();
|
|
||||||
}
|
|
||||||
|
|
||||||
QString current_template_name = currentTitleBlockTemplateName();
|
|
||||||
if (!current_template_name.isEmpty()) prop.template_name = current_template_name;
|
|
||||||
|
|
||||||
prop.context = additional_fields_ -> context();
|
|
||||||
|
|
||||||
return(prop);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
Specifie les proprietes que le widget doit afficher
|
|
||||||
@param titleblock nouvelles proprietes affichees par le widget
|
|
||||||
*/
|
|
||||||
void TitleBlockPropertiesWidget::setTitleBlockProperties(const TitleBlockProperties &titleblock) {
|
|
||||||
titleblock_title -> setText(titleblock.title);
|
|
||||||
titleblock_author -> setText(titleblock.author);
|
|
||||||
titleblock_filename -> setText(titleblock.filename);
|
|
||||||
titleblock_folio -> setText(titleblock.folio);
|
|
||||||
if (display_current_date) {
|
|
||||||
if (titleblock.useDate == TitleBlockProperties::CurrentDate) {
|
|
||||||
titleblock_current_date -> setChecked(true);
|
|
||||||
} else {
|
|
||||||
if (titleblock.date.isNull()) {
|
|
||||||
titleblock_no_date -> setChecked(true);
|
|
||||||
} else {
|
|
||||||
titleblock_fixed_date -> setChecked(true);
|
|
||||||
titleblock_date -> setDate(titleblock.date);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (titleblock.useDate == TitleBlockProperties::CurrentDate) {
|
|
||||||
titleblock_fixed_date -> setChecked(true);
|
|
||||||
titleblock_date -> setDate(QDate::currentDate());
|
|
||||||
} else {
|
|
||||||
if (titleblock.date.isNull()) {
|
|
||||||
titleblock_no_date -> setChecked(true);
|
|
||||||
} else {
|
|
||||||
titleblock_fixed_date -> setChecked(true);
|
|
||||||
titleblock_date -> setDate(titleblock.date);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!titleblock.template_name.isEmpty()) {
|
|
||||||
int matching_index = titleblock_template_name -> findData(titleblock.template_name);
|
|
||||||
if (matching_index != -1) {
|
|
||||||
titleblock_template_name -> setCurrentIndex(matching_index);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
setDiagramContext(titleblock.context);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
Clear the custom variables list.
|
|
||||||
*/
|
|
||||||
void TitleBlockPropertiesWidget::clearDiagramContext() {
|
|
||||||
additional_fields_ -> clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
Clear the custom variables table then add the key/value pairs from \a context to it.
|
|
||||||
*/
|
|
||||||
void TitleBlockPropertiesWidget::setDiagramContext(const DiagramContext &context) {
|
|
||||||
additional_fields_ -> setContext(context);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
@return true si le widget affiche la proposition "Date courante", false sinon
|
|
||||||
*/
|
|
||||||
bool TitleBlockPropertiesWidget::displayCurrentDate() const {
|
|
||||||
return(display_current_date);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
@return true si ce widget est en lecture seule, false sinon
|
|
||||||
*/
|
|
||||||
bool TitleBlockPropertiesWidget::isReadOnly() const {
|
|
||||||
return(titleblock_title -> isReadOnly());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
@param ro true pour passer ce widget en lecture seule, false sinon
|
|
||||||
*/
|
|
||||||
void TitleBlockPropertiesWidget::setReadOnly(bool ro) {
|
|
||||||
titleblock_title -> setReadOnly(ro);
|
|
||||||
titleblock_author -> setReadOnly(ro);
|
|
||||||
titleblock_date -> setReadOnly(ro);
|
|
||||||
titleblock_filename -> setReadOnly(ro);
|
|
||||||
titleblock_folio -> setReadOnly(ro);
|
|
||||||
titleblock_no_date -> setDisabled(ro);
|
|
||||||
titleblock_current_date -> setDisabled(ro);
|
|
||||||
titleblock_fixed_date -> setDisabled(ro);
|
|
||||||
titleblock_template_name -> setDisabled(ro);
|
|
||||||
additional_fields_ -> setDisabled(ro);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
@param templates List of template names the dedicated combo box should
|
|
||||||
display.
|
|
||||||
*/
|
|
||||||
void TitleBlockPropertiesWidget::setTitleBlockTemplatesList(const QList<QString> &templates) {
|
|
||||||
titleblock_template_name -> clear();
|
|
||||||
titleblock_template_name -> addItem(QET::Icons::TitleBlock, tr("Mod\350le par d\351faut"), QString());
|
|
||||||
foreach (QString template_name, templates) {
|
|
||||||
titleblock_template_name -> addItem(QET::Icons::TitleBlock, template_name, template_name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
@param tbt_collection Collection from which title block templates should be read.
|
|
||||||
*/
|
|
||||||
void TitleBlockPropertiesWidget::setTitleBlockTemplatesCollection(TitleBlockTemplatesCollection *tbt_collection) {
|
|
||||||
if (!tbt_collection) return;
|
|
||||||
if (tbt_collection_ && tbt_collection != tbt_collection_) {
|
|
||||||
// forget any connection with the previous collection
|
|
||||||
disconnect(tbt_collection_, 0, this, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
tbt_collection_ = tbt_collection;
|
|
||||||
updateTemplateList();
|
|
||||||
connect(tbt_collection_, SIGNAL(changed(TitleBlockTemplatesCollection*, QString)), this, SLOT(updateTemplateList()));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
@param visible true to display the title block templates list, false to
|
|
||||||
hide it.
|
|
||||||
*/
|
|
||||||
void TitleBlockPropertiesWidget::setTitleBlockTemplatesVisible(bool visible) {
|
|
||||||
titleblock_template_name -> setVisible(visible);
|
|
||||||
titleblock_template_label -> setVisible(visible);
|
|
||||||
titleblock_template_button_ -> setVisible(visible);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
@return the name of the currenlty selected title block template.
|
|
||||||
*/
|
|
||||||
QString TitleBlockPropertiesWidget::currentTitleBlockTemplateName() const {
|
|
||||||
int index = titleblock_template_name -> currentIndex();
|
|
||||||
if (index != -1) {
|
|
||||||
return(titleblock_template_name -> itemData(index).toString());
|
|
||||||
}
|
|
||||||
return(QString());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
Set the currently selected title block template.
|
|
||||||
@param template_name Template to be selected
|
|
||||||
*/
|
|
||||||
void TitleBlockPropertiesWidget::setCurrentTitleBlockTemplateName(const QString &template_name) {
|
|
||||||
int matching_index = titleblock_template_name -> findData(template_name);
|
|
||||||
if (matching_index != -1) {
|
|
||||||
titleblock_template_name -> setCurrentIndex(matching_index);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
Update the title block templates list.
|
|
||||||
*/
|
|
||||||
void TitleBlockPropertiesWidget::updateTemplateList() {
|
|
||||||
if (!tbt_collection_) return;
|
|
||||||
|
|
||||||
QString current_template_name = currentTitleBlockTemplateName();
|
|
||||||
setTitleBlockTemplatesList(tbt_collection_ -> templates());
|
|
||||||
setCurrentTitleBlockTemplateName(current_template_name);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
Edit the currently selected title block template
|
|
||||||
*/
|
|
||||||
void TitleBlockPropertiesWidget::editCurrentTitleBlockTemplate() {
|
|
||||||
emit(editTitleBlockTemplate(currentTitleBlockTemplateName(), false));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
Duplicate the currently selected title block template (the user is asked
|
|
||||||
for a name), then edit it.
|
|
||||||
*/
|
|
||||||
void TitleBlockPropertiesWidget::duplicateCurrentTitleBlockTemplate() {
|
|
||||||
emit(editTitleBlockTemplate(currentTitleBlockTemplateName(), true));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief changeCurrentTitleBlockTemplate load the fields of the template to additional_fields_
|
|
||||||
* @param text
|
|
||||||
*/
|
|
||||||
void TitleBlockPropertiesWidget::changeCurrentTitleBlockTemplate(QString text) {
|
|
||||||
// delete all entry
|
|
||||||
additional_fields_ -> clear() ;
|
|
||||||
// get template
|
|
||||||
TitleBlockTemplate *tpl = tbt_collection_ -> getTemplate( text );
|
|
||||||
if(tpl != 0) {
|
|
||||||
// get all template fields
|
|
||||||
QStringList fields = tpl -> listOfVariables();
|
|
||||||
// set fields to additional_fields_ widget
|
|
||||||
DiagramContext templateContext;
|
|
||||||
for(int i =0; i<fields.count(); i++)
|
|
||||||
templateContext.addValue(fields.at(i), "");
|
|
||||||
setDiagramContext(templateContext);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
Builds the various child widgets for this widget
|
|
||||||
*/
|
|
||||||
void TitleBlockPropertiesWidget::initWidgets(const TitleBlockProperties &titleblock) {
|
|
||||||
// actions
|
|
||||||
titleblock_template_edit_ = new QAction(tr("\311diter ce mod\350le", "menu entry"), this);
|
|
||||||
titleblock_template_duplicate_ = new QAction(tr("Dupliquer et editer ce mod\350le", "menu entry"), this);
|
|
||||||
|
|
||||||
connect(titleblock_template_edit_, SIGNAL(triggered()), this, SLOT(editCurrentTitleBlockTemplate()));
|
|
||||||
connect(titleblock_template_duplicate_, SIGNAL(triggered()), this, SLOT(duplicateCurrentTitleBlockTemplate()));
|
|
||||||
|
|
||||||
// menu
|
|
||||||
titleblock_template_menu_ = new QMenu(tr("Title block templates actions"));
|
|
||||||
titleblock_template_menu_ -> addAction(titleblock_template_edit_);
|
|
||||||
titleblock_template_menu_ -> addAction(titleblock_template_duplicate_);
|
|
||||||
|
|
||||||
// widgets
|
|
||||||
titleblock_template_label = new QLabel(tr("Mod\350le :"), this);
|
|
||||||
titleblock_template_name = new QComboBox(this);
|
|
||||||
connect(titleblock_template_name, SIGNAL(currentIndexChanged(QString)),this, SLOT(changeCurrentTitleBlockTemplate(QString)) );
|
|
||||||
titleblock_template_button_ = new QPushButton(QET::Icons::TitleBlock, QString());
|
|
||||||
titleblock_template_button_ -> setMenu(titleblock_template_menu_);
|
|
||||||
|
|
||||||
titleblock_title = new QLineEdit(this);
|
|
||||||
titleblock_author = new QLineEdit(this);
|
|
||||||
titleblock_filename = new QLineEdit(this);
|
|
||||||
|
|
||||||
titleblock_folio = new QLineEdit(this);
|
|
||||||
folio_tip = new QLabel(
|
|
||||||
tr(
|
|
||||||
"Les variables suivantes sont utilisables dans le champ Folio :\n"
|
|
||||||
" - %id : num\351ro du sch\351ma courant dans le projet\n"
|
|
||||||
" - %total : nombre total de sch\351mas dans le projet"
|
|
||||||
)
|
|
||||||
);
|
|
||||||
folio_tip -> setWordWrap(true);
|
|
||||||
|
|
||||||
QButtonGroup *date_policy_group = new QButtonGroup(this);
|
|
||||||
titleblock_no_date = new QRadioButton(tr("Pas de date"), this);
|
|
||||||
titleblock_current_date = new QRadioButton(tr("Date courante"), this);
|
|
||||||
titleblock_fixed_date = new QRadioButton(tr("Date fixe : "), this);
|
|
||||||
date_policy_group -> addButton(titleblock_no_date);
|
|
||||||
date_policy_group -> addButton(titleblock_current_date);
|
|
||||||
date_policy_group -> addButton(titleblock_fixed_date);
|
|
||||||
titleblock_date = new QDateEdit(QDate::currentDate(), this);
|
|
||||||
titleblock_date -> setEnabled(titleblock_fixed_date -> isChecked());
|
|
||||||
titleblock_current_date -> setVisible(display_current_date);
|
|
||||||
connect(titleblock_fixed_date, SIGNAL(toggled(bool)), titleblock_date, SLOT(setEnabled(bool)));
|
|
||||||
titleblock_date -> setCalendarPopup(true);
|
|
||||||
|
|
||||||
titleblock_date_now = new QPushButton (QET::Icons::Start, "", this);
|
|
||||||
titleblock_date_now -> setEnabled(titleblock_fixed_date -> isChecked());
|
|
||||||
titleblock_date_now -> setIconSize(QSize(16, 16));
|
|
||||||
connect(titleblock_fixed_date, SIGNAL(toggled(bool)), titleblock_date_now, SLOT(setEnabled(bool)));
|
|
||||||
connect(titleblock_date_now, SIGNAL(clicked()), this, SLOT(setDate_now()));
|
|
||||||
|
|
||||||
// we add a bunch of tooltips for users to know how they can put these
|
|
||||||
// values into their title block templates
|
|
||||||
QString variable_tooltip = tr("Disponible en tant que %1 pour les mod\350les de cartouches.");
|
|
||||||
titleblock_title -> setToolTip(QString(variable_tooltip).arg("%title"));
|
|
||||||
titleblock_author -> setToolTip(QString(variable_tooltip).arg("%author"));
|
|
||||||
titleblock_filename -> setToolTip(QString(variable_tooltip).arg("%filename"));
|
|
||||||
titleblock_folio -> setToolTip(QString(variable_tooltip).arg("%folio"));
|
|
||||||
QString date_variable_tooltip = QString(variable_tooltip).arg("%date");
|
|
||||||
titleblock_current_date -> setToolTip(date_variable_tooltip);
|
|
||||||
titleblock_fixed_date -> setToolTip(date_variable_tooltip);
|
|
||||||
titleblock_date -> setToolTip(date_variable_tooltip);
|
|
||||||
titleblock_date_now -> setToolTip(tr("Appliquer la date actuelle"));
|
|
||||||
folio_tip -> setToolTip(tr("%id et %total sont disponibles en tant que %{folio-id} et %{folio-total} (respectivement) pour les mod\350les de cartouches."));
|
|
||||||
|
|
||||||
// widgets for users to enter their own name/value pairs
|
|
||||||
additional_fields_label = new QLabel(
|
|
||||||
tr(
|
|
||||||
"Vous pouvez d\351finir ici vos propres associations noms/valeurs pour"
|
|
||||||
" que le cartouche en tienne compte. Exemple : associer le nom "
|
|
||||||
"\"volta\" et la valeur \"1745\" remplacera %{volta} par 1745 dans le "
|
|
||||||
"cartouche."
|
|
||||||
)
|
|
||||||
);
|
|
||||||
additional_fields_label -> setWordWrap(true);
|
|
||||||
additional_fields_label -> setAlignment(Qt::AlignJustify);
|
|
||||||
additional_fields_ = new DiagramContextWidget();
|
|
||||||
additional_fields_ -> setContext(titleblock.context);
|
|
||||||
|
|
||||||
tabbar = new QTabBar(this);
|
|
||||||
tabbar -> addTab(tr("Principales"));
|
|
||||||
tabbar -> addTab(tr("Personnalis\351es"));
|
|
||||||
tabbar -> setShape(QTabBar::RoundedSouth);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
Builds the various layouts for this widget
|
|
||||||
*/
|
|
||||||
void TitleBlockPropertiesWidget::initLayouts() {
|
|
||||||
// layouts for tab #0
|
|
||||||
QGridLayout *layout_date = new QGridLayout();
|
|
||||||
layout_date -> addWidget(titleblock_no_date, 0, 0);
|
|
||||||
layout_date -> addWidget(titleblock_current_date, 1, 0);
|
|
||||||
layout_date -> addWidget(titleblock_fixed_date, 2, 0);
|
|
||||||
layout_date -> addWidget(titleblock_date, 2, 1);
|
|
||||||
layout_date -> addWidget(titleblock_date_now, 2, 2);
|
|
||||||
layout_date -> setColumnStretch(0, 1);
|
|
||||||
layout_date -> setColumnStretch(1, 500);
|
|
||||||
|
|
||||||
QWidget *widget_main_fields = new QWidget(this);
|
|
||||||
QGridLayout *layout_main_fields = new QGridLayout(widget_main_fields);
|
|
||||||
layout_main_fields -> addWidget(new QLabel(tr("Titre : ")), 0, 0);
|
|
||||||
layout_main_fields -> addWidget(titleblock_title, 0, 1);
|
|
||||||
layout_main_fields -> addWidget(new QLabel(tr("Auteur : ")), 1, 0);
|
|
||||||
layout_main_fields -> addWidget(titleblock_author, 1, 1);
|
|
||||||
layout_main_fields -> addWidget(new QLabel(tr("Date : ")), 2, 0, Qt::AlignTop);
|
|
||||||
layout_main_fields -> addLayout(layout_date, 2, 1);
|
|
||||||
layout_main_fields -> addWidget(new QLabel(tr("Fichier : ")), 3, 0);
|
|
||||||
layout_main_fields -> addWidget(titleblock_filename, 3, 1);
|
|
||||||
layout_main_fields -> addWidget(new QLabel(tr("Folio : ")), 4, 0);
|
|
||||||
layout_main_fields -> addWidget(titleblock_folio, 4, 1);
|
|
||||||
layout_main_fields -> addWidget(folio_tip, 5, 1, Qt::AlignTop);
|
|
||||||
layout_main_fields -> setContentsMargins(0, 0, 0, 0);
|
|
||||||
layout_main_fields -> setRowStretch(5, 500);
|
|
||||||
|
|
||||||
// layouts for tab #1
|
|
||||||
QWidget *widget_user_fields = new QWidget(this);
|
|
||||||
QVBoxLayout *layout_user_fields = new QVBoxLayout(widget_user_fields);
|
|
||||||
layout_user_fields -> addWidget(additional_fields_label);
|
|
||||||
layout_user_fields -> addWidget(additional_fields_);
|
|
||||||
layout_user_fields -> setContentsMargins(0, 0, 0, 0);
|
|
||||||
|
|
||||||
// stacked layout
|
|
||||||
stack_layout = new QStackedLayout();
|
|
||||||
stack_layout -> addWidget(widget_main_fields);
|
|
||||||
stack_layout -> addWidget(widget_user_fields);
|
|
||||||
stack_layout -> setContentsMargins(0, 0, 0, 0);
|
|
||||||
stack_layout -> setCurrentIndex(0);
|
|
||||||
|
|
||||||
// template layout
|
|
||||||
QHBoxLayout *template_layout = new QHBoxLayout();
|
|
||||||
template_layout -> addWidget(titleblock_template_label);
|
|
||||||
template_layout -> addWidget(titleblock_template_name);
|
|
||||||
template_layout -> addWidget(titleblock_template_button_);
|
|
||||||
template_layout -> setStretch(0, 1);
|
|
||||||
template_layout -> setStretch(1, 500);
|
|
||||||
|
|
||||||
// groupbox layout
|
|
||||||
QVBoxLayout *groupbox_layout = new QVBoxLayout();
|
|
||||||
groupbox_layout -> addLayout(template_layout);
|
|
||||||
groupbox_layout -> addLayout(stack_layout);
|
|
||||||
groupbox_layout -> addWidget(tabbar);
|
|
||||||
|
|
||||||
// groupbox
|
|
||||||
QGroupBox *titleblock_infos = new QGroupBox(tr("Informations du cartouche"), this);
|
|
||||||
titleblock_infos -> setLayout(groupbox_layout);
|
|
||||||
titleblock_infos -> setMinimumSize(300, 330);
|
|
||||||
|
|
||||||
// widget layout
|
|
||||||
QVBoxLayout *this_layout = new QVBoxLayout();
|
|
||||||
this_layout -> setContentsMargins(0, 0, 0, 0);
|
|
||||||
this_layout -> addWidget(titleblock_infos);
|
|
||||||
setLayout(this_layout);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
Set the current Date to the combo Date
|
|
||||||
*/
|
|
||||||
void TitleBlockPropertiesWidget::setDate_now(){
|
|
||||||
titleblock_date -> setDate( QDate::currentDate() );
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,90 +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 TITLEBLOCK_PROPERTIES_WIDGET_H
|
|
||||||
#define TITLEBLOCK_PROPERTIES_WIDGET_H
|
|
||||||
#include <QtGui>
|
|
||||||
#include "titleblockproperties.h"
|
|
||||||
class DiagramContextWidget;
|
|
||||||
class TitleBlockTemplatesCollection;
|
|
||||||
/**
|
|
||||||
This widget enable users to edit the properties of a title block.
|
|
||||||
*/
|
|
||||||
class TitleBlockPropertiesWidget : public QWidget {
|
|
||||||
Q_OBJECT
|
|
||||||
// constructors, destructor
|
|
||||||
public:
|
|
||||||
TitleBlockPropertiesWidget(const TitleBlockProperties &titleblock = TitleBlockProperties(), bool = false, QWidget * = 0);
|
|
||||||
virtual ~TitleBlockPropertiesWidget();
|
|
||||||
private:
|
|
||||||
TitleBlockPropertiesWidget(const TitleBlockPropertiesWidget &);
|
|
||||||
|
|
||||||
// methods
|
|
||||||
public:
|
|
||||||
TitleBlockProperties titleBlockProperties() const;
|
|
||||||
void setTitleBlockProperties(const TitleBlockProperties &);
|
|
||||||
void clearDiagramContext();
|
|
||||||
void setDiagramContext(const DiagramContext &);
|
|
||||||
bool displayCurrentDate() const;
|
|
||||||
bool isReadOnly() const;
|
|
||||||
void setReadOnly(bool);
|
|
||||||
void setTitleBlockTemplatesList(const QList<QString> &);
|
|
||||||
void setTitleBlockTemplatesCollection(TitleBlockTemplatesCollection *);
|
|
||||||
void setTitleBlockTemplatesVisible(bool);
|
|
||||||
QString currentTitleBlockTemplateName() const;
|
|
||||||
void setCurrentTitleBlockTemplateName(const QString &);
|
|
||||||
|
|
||||||
private slots:
|
|
||||||
void updateTemplateList();
|
|
||||||
void editCurrentTitleBlockTemplate();
|
|
||||||
void duplicateCurrentTitleBlockTemplate();
|
|
||||||
void changeCurrentTitleBlockTemplate(QString text);
|
|
||||||
void setDate_now();
|
|
||||||
|
|
||||||
private:
|
|
||||||
void initWidgets(const TitleBlockProperties &);
|
|
||||||
void initLayouts();
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void editTitleBlockTemplate(const QString &, bool);
|
|
||||||
|
|
||||||
// attributes
|
|
||||||
private:
|
|
||||||
QStackedLayout *stack_layout;
|
|
||||||
QLabel *titleblock_template_label;
|
|
||||||
QComboBox *titleblock_template_name;
|
|
||||||
QPushButton *titleblock_template_button_;
|
|
||||||
QMenu *titleblock_template_menu_;
|
|
||||||
QAction *titleblock_template_edit_;
|
|
||||||
QAction *titleblock_template_duplicate_;
|
|
||||||
QLineEdit *titleblock_title;
|
|
||||||
QLineEdit *titleblock_author;
|
|
||||||
QDateEdit *titleblock_date;
|
|
||||||
QPushButton *titleblock_date_now;
|
|
||||||
QLineEdit *titleblock_filename;
|
|
||||||
QLineEdit *titleblock_folio;
|
|
||||||
QLabel *folio_tip;
|
|
||||||
QRadioButton *titleblock_no_date;
|
|
||||||
QRadioButton *titleblock_current_date;
|
|
||||||
QRadioButton *titleblock_fixed_date;
|
|
||||||
bool display_current_date;
|
|
||||||
QLabel *additional_fields_label;
|
|
||||||
DiagramContextWidget *additional_fields_;
|
|
||||||
QTabBar *tabbar;
|
|
||||||
TitleBlockTemplatesCollection *tbt_collection_;
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
284
sources/ui/titleblockpropertieswidget.cpp
Normal file
284
sources/ui/titleblockpropertieswidget.cpp
Normal file
@@ -0,0 +1,284 @@
|
|||||||
|
/*
|
||||||
|
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 "titleblockpropertieswidget.h"
|
||||||
|
#include "ui_titleblockpropertieswidget.h"
|
||||||
|
#include "templatescollection.h"
|
||||||
|
#include "qeticons.h"
|
||||||
|
#include "titleblocktemplate.h"
|
||||||
|
#include <QMenu>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief TitleBlockPropertiesWidget::TitleBlockPropertiesWidget
|
||||||
|
* default constructor
|
||||||
|
* @param titleblock properties to edit
|
||||||
|
* @param current_date if true, display the radio button "current date"
|
||||||
|
* @param parent parent widget
|
||||||
|
*/
|
||||||
|
TitleBlockPropertiesWidget::TitleBlockPropertiesWidget(const TitleBlockProperties &titleblock, bool current_date, QWidget *parent) :
|
||||||
|
QWidget(parent),
|
||||||
|
ui(new Ui::TitleBlockPropertiesWidget),
|
||||||
|
m_tbt_collection(nullptr)
|
||||||
|
{
|
||||||
|
ui->setupUi(this);
|
||||||
|
initDialog(current_date);
|
||||||
|
setProperties(titleblock);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief TitleBlockPropertiesWidget::~TitleBlockPropertiesWidget
|
||||||
|
* destructor
|
||||||
|
*/
|
||||||
|
TitleBlockPropertiesWidget::~TitleBlockPropertiesWidget()
|
||||||
|
{
|
||||||
|
delete ui;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief TitleBlockPropertiesWidget::setProperties
|
||||||
|
* @param properties
|
||||||
|
*/
|
||||||
|
void TitleBlockPropertiesWidget::setProperties(const TitleBlockProperties &properties) {
|
||||||
|
ui -> m_title_le -> setText (properties.title);
|
||||||
|
ui -> m_author_le -> setText (properties.author);
|
||||||
|
ui -> m_file_le -> setText (properties.filename);
|
||||||
|
ui -> m_folio_le -> setText (properties.folio);
|
||||||
|
|
||||||
|
//About date
|
||||||
|
on_m_fixed_date_rb_toggled(ui->m_fixed_date_rb->isChecked());
|
||||||
|
ui -> m_date_edit -> setDate(QDate::currentDate());
|
||||||
|
|
||||||
|
if (ui -> m_current_date_rb -> isVisible()) {
|
||||||
|
if(properties.useDate == TitleBlockProperties::CurrentDate)
|
||||||
|
ui -> m_current_date_rb -> setChecked(true);
|
||||||
|
else {
|
||||||
|
if (properties.date.isNull())
|
||||||
|
ui -> m_no_date_rb -> setChecked(true);
|
||||||
|
else {
|
||||||
|
ui -> m_fixed_date_rb -> setChecked(true);
|
||||||
|
ui -> m_date_edit -> setDate(properties.date);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (properties.useDate == TitleBlockProperties::CurrentDate)
|
||||||
|
ui -> m_fixed_date_rb ->setChecked(true);
|
||||||
|
else {
|
||||||
|
if (properties.date.isNull())
|
||||||
|
ui -> m_no_date_rb -> setChecked(true);
|
||||||
|
else {
|
||||||
|
ui -> m_fixed_date_rb -> setChecked(true);
|
||||||
|
ui -> m_date_edit -> setDate(properties.date);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} //About date
|
||||||
|
|
||||||
|
if (!properties.template_name.isEmpty()) {
|
||||||
|
int matching_index = ui -> m_tbt_cb -> findData (properties.template_name);
|
||||||
|
if (matching_index != -1)
|
||||||
|
ui -> m_tbt_cb -> setCurrentIndex(matching_index);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_dcw -> setContext(properties.context);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief TitleBlockPropertiesWidget::properties
|
||||||
|
* @return the edited properties
|
||||||
|
*/
|
||||||
|
TitleBlockProperties TitleBlockPropertiesWidget::properties() const {
|
||||||
|
TitleBlockProperties prop;
|
||||||
|
prop.title = ui -> m_title_le -> text();
|
||||||
|
prop.author = ui -> m_author_le -> text();
|
||||||
|
prop.filename = ui -> m_file_le -> text();
|
||||||
|
prop.folio = ui -> m_folio_le -> text();
|
||||||
|
|
||||||
|
if (ui->m_no_date_rb->isChecked()) {
|
||||||
|
prop.useDate = TitleBlockProperties::UseDateValue;
|
||||||
|
prop.date = QDate();
|
||||||
|
}
|
||||||
|
else if (ui -> m_fixed_date_rb -> isChecked()) {
|
||||||
|
prop.useDate = TitleBlockProperties::UseDateValue;
|
||||||
|
prop.date = ui->m_date_edit->date();
|
||||||
|
}
|
||||||
|
else if (ui->m_current_date_rb->isVisible() && ui->m_current_date_rb->isChecked()) {
|
||||||
|
prop.useDate = TitleBlockProperties::CurrentDate;
|
||||||
|
prop.date = QDate::currentDate();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!currentTitleBlockTemplateName().isEmpty())
|
||||||
|
prop.template_name = currentTitleBlockTemplateName();
|
||||||
|
|
||||||
|
prop.context = m_dcw -> context();
|
||||||
|
|
||||||
|
return prop;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief TitleBlockPropertiesWidget::setTitleBlockTemplatesVisible
|
||||||
|
* if true, title block template combo box and menu button is visible
|
||||||
|
*/
|
||||||
|
void TitleBlockPropertiesWidget::setTitleBlockTemplatesVisible(const bool &visible) {
|
||||||
|
ui -> m_tbt_label -> setVisible(visible);
|
||||||
|
ui -> m_tbt_cb -> setVisible(visible);
|
||||||
|
ui -> m_tbt_pb -> setVisible(visible);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief TitleBlockPropertiesWidget::setReadOnly
|
||||||
|
* if true, this widget is disable
|
||||||
|
*/
|
||||||
|
void TitleBlockPropertiesWidget::setReadOnly(const bool &ro) {
|
||||||
|
ui->m_tbt_gb->setDisabled(ro);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief TitleBlockPropertiesWidget::currentTitleBlockTemplateName
|
||||||
|
* @return the current title block name
|
||||||
|
*/
|
||||||
|
QString TitleBlockPropertiesWidget::currentTitleBlockTemplateName() const {
|
||||||
|
int index = ui -> m_tbt_cb -> currentIndex();
|
||||||
|
if(index != -1)
|
||||||
|
return (ui -> m_tbt_cb -> itemData(index).toString());
|
||||||
|
return QString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief TitleBlockPropertiesWidget::setCurrentTitleBlockTemplateName
|
||||||
|
* set the current title block "name", if "name" doesn't match, this method do nothing
|
||||||
|
* @param name
|
||||||
|
*/
|
||||||
|
void TitleBlockPropertiesWidget::setCurrentTitleBlockTemplateName (const QString &name) {
|
||||||
|
int index = ui -> m_tbt_cb -> findData(name);
|
||||||
|
if (index != -1)
|
||||||
|
ui -> m_tbt_cb -> setCurrentIndex(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief TitleBlockPropertiesWidget::setTitleBlockTemplatesCollection
|
||||||
|
* Set the collection of title block
|
||||||
|
* @param tbt_collection
|
||||||
|
*/
|
||||||
|
void TitleBlockPropertiesWidget::setTitleBlockTemplatesCollection(TitleBlockTemplatesCollection *tbt_collection) {
|
||||||
|
if (!tbt_collection) return;
|
||||||
|
if (m_tbt_collection && tbt_collection != m_tbt_collection) {
|
||||||
|
// forget any connection with the previous collection
|
||||||
|
disconnect(m_tbt_collection, 0, this, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_tbt_collection = tbt_collection;
|
||||||
|
updateTemplateList();
|
||||||
|
connect(m_tbt_collection, SIGNAL(changed(TitleBlockTemplatesCollection*,QString)), this, SLOT(updateTemplateList()));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief TitleBlockPropertiesWidget::setTitleBlockTemplatesList
|
||||||
|
* Set the list of title block used.
|
||||||
|
* Fill the combo box of title box with each name of title block.
|
||||||
|
* @param tbt
|
||||||
|
*/
|
||||||
|
void TitleBlockPropertiesWidget::setTitleBlockTemplatesList(const QStringList &tbt) {
|
||||||
|
ui -> m_tbt_cb ->clear();
|
||||||
|
ui -> m_tbt_cb -> addItem(QET::Icons::TitleBlock, tr("Mod\350le par d\351faut"));
|
||||||
|
foreach (QString tbt_name, tbt) {
|
||||||
|
ui -> m_tbt_cb -> addItem(QET::Icons::TitleBlock, tbt_name, tbt_name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief TitleBlockPropertiesWidget::initDialog
|
||||||
|
* Init this dialog
|
||||||
|
* @param current_date true for display current date radio button
|
||||||
|
*/
|
||||||
|
void TitleBlockPropertiesWidget::initDialog(const bool ¤t_date) {
|
||||||
|
m_dcw = new DiagramContextWidget();
|
||||||
|
ui -> m_tab2_vlayout -> addWidget(m_dcw);
|
||||||
|
|
||||||
|
setTitleBlockTemplatesVisible(false);
|
||||||
|
ui -> m_current_date_rb -> setVisible(current_date);
|
||||||
|
|
||||||
|
m_tbt_edit = new QAction(tr("\311diter ce mod\350le", "menu entry"), this);
|
||||||
|
m_tbt_duplicate = new QAction(tr("Dupliquer et editer ce mod\350le", "menu entry"), this);
|
||||||
|
|
||||||
|
connect(m_tbt_edit, SIGNAL(triggered()), this, SLOT(editCurrentTitleBlockTemplate()));
|
||||||
|
connect(m_tbt_duplicate, SIGNAL(triggered()), this, SLOT(duplicateCurrentTitleBlockTemplate()));
|
||||||
|
|
||||||
|
m_tbt_menu = new QMenu(tr("Title block templates actions"));
|
||||||
|
m_tbt_menu -> addAction(m_tbt_edit);
|
||||||
|
m_tbt_menu -> addAction(m_tbt_duplicate);
|
||||||
|
ui -> m_tbt_pb -> setMenu(m_tbt_menu);
|
||||||
|
|
||||||
|
connect(ui->m_tbt_cb, SIGNAL(currentIndexChanged(QString)), this, SLOT(changeCurrentTitleBlockTemplate(QString)));
|
||||||
|
}
|
||||||
|
|
||||||
|
void TitleBlockPropertiesWidget::editCurrentTitleBlockTemplate() {
|
||||||
|
emit(editTitleBlockTemplate(currentTitleBlockTemplateName(), false));
|
||||||
|
}
|
||||||
|
|
||||||
|
void TitleBlockPropertiesWidget::duplicateCurrentTitleBlockTemplate() {
|
||||||
|
emit(editTitleBlockTemplate(currentTitleBlockTemplateName(), true));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief TitleBlockPropertiesWidget::updateTemplateList
|
||||||
|
* Update the title block template list
|
||||||
|
*/
|
||||||
|
void TitleBlockPropertiesWidget::updateTemplateList() {
|
||||||
|
if (!m_tbt_collection) return;
|
||||||
|
|
||||||
|
QString current_template_name = currentTitleBlockTemplateName();
|
||||||
|
setTitleBlockTemplatesList(m_tbt_collection -> templates());
|
||||||
|
setCurrentTitleBlockTemplateName(current_template_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief TitleBlockPropertiesWidget::changeCurrentTitleBlockTemplate
|
||||||
|
* Load the additionnal field of title block "text"
|
||||||
|
*/
|
||||||
|
void TitleBlockPropertiesWidget::changeCurrentTitleBlockTemplate(QString name) {
|
||||||
|
// delete all entry
|
||||||
|
m_dcw -> clear();
|
||||||
|
// get template
|
||||||
|
TitleBlockTemplate *tpl = m_tbt_collection -> getTemplate( name );
|
||||||
|
if(tpl != 0) {
|
||||||
|
// get all template fields
|
||||||
|
QStringList fields = tpl -> listOfVariables();
|
||||||
|
// set fields to additional_fields_ widget
|
||||||
|
DiagramContext templateContext;
|
||||||
|
for(int i =0; i<fields.count(); i++)
|
||||||
|
templateContext.addValue(fields.at(i), "");
|
||||||
|
m_dcw->setContext(templateContext);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief TitleBlockPropertiesWidget::on_m_date_now_pb_clicked
|
||||||
|
* Set the date to current date
|
||||||
|
*/
|
||||||
|
void TitleBlockPropertiesWidget::on_m_date_now_pb_clicked() {
|
||||||
|
ui -> m_date_edit -> setDate(QDate::currentDate());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief TitleBlockPropertiesWidget::on_m_fixed_date_rb_toggled
|
||||||
|
* Disable widget related to fixed date, if radio button
|
||||||
|
* current date isn't checked
|
||||||
|
*/
|
||||||
|
void TitleBlockPropertiesWidget::on_m_fixed_date_rb_toggled(bool checked) {
|
||||||
|
ui -> m_date_edit -> setEnabled(checked);
|
||||||
|
ui -> m_date_now_pb -> setEnabled(checked);
|
||||||
|
}
|
||||||
72
sources/ui/titleblockpropertieswidget.h
Normal file
72
sources/ui/titleblockpropertieswidget.h
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
/*
|
||||||
|
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 TITLEBLOCKPROPERTIESWIDGET_H
|
||||||
|
#define TITLEBLOCKPROPERTIESWIDGET_H
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
#include "titleblockproperties.h"
|
||||||
|
#include "diagramcontextwidget.h"
|
||||||
|
|
||||||
|
class QMenu;
|
||||||
|
class TitleBlockTemplatesCollection;
|
||||||
|
|
||||||
|
namespace Ui {
|
||||||
|
class TitleBlockPropertiesWidget;
|
||||||
|
}
|
||||||
|
|
||||||
|
class TitleBlockPropertiesWidget : public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit TitleBlockPropertiesWidget(const TitleBlockProperties &titleblock = TitleBlockProperties(), bool current_date = false, QWidget *parent = 0);
|
||||||
|
~TitleBlockPropertiesWidget();
|
||||||
|
|
||||||
|
void setProperties(const TitleBlockProperties &properties);
|
||||||
|
TitleBlockProperties properties() const;
|
||||||
|
|
||||||
|
void setTitleBlockTemplatesVisible(const bool &visible);
|
||||||
|
void setReadOnly (const bool &ro);
|
||||||
|
void setTitleBlockTemplatesCollection(TitleBlockTemplatesCollection *tbt_collection);
|
||||||
|
|
||||||
|
private:
|
||||||
|
QString currentTitleBlockTemplateName () const;
|
||||||
|
void setCurrentTitleBlockTemplateName (const QString &name);
|
||||||
|
void setTitleBlockTemplatesList(const QStringList &tbt);
|
||||||
|
void initDialog(const bool ¤t_date);
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void editCurrentTitleBlockTemplate();
|
||||||
|
void duplicateCurrentTitleBlockTemplate();
|
||||||
|
void updateTemplateList();
|
||||||
|
void changeCurrentTitleBlockTemplate(QString name);
|
||||||
|
void on_m_date_now_pb_clicked();
|
||||||
|
void on_m_fixed_date_rb_toggled(bool checked);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void editTitleBlockTemplate(const QString &, bool);
|
||||||
|
|
||||||
|
private:
|
||||||
|
Ui::TitleBlockPropertiesWidget *ui;
|
||||||
|
DiagramContextWidget *m_dcw;
|
||||||
|
TitleBlockTemplatesCollection *m_tbt_collection;
|
||||||
|
QAction *m_tbt_edit, *m_tbt_duplicate;
|
||||||
|
QMenu *m_tbt_menu;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // TITLEBLOCKPROPERTIESWIDGET_H
|
||||||
284
sources/ui/titleblockpropertieswidget.ui
Normal file
284
sources/ui/titleblockpropertieswidget.ui
Normal file
@@ -0,0 +1,284 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>TitleBlockPropertiesWidget</class>
|
||||||
|
<widget class="QWidget" name="TitleBlockPropertiesWidget">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>508</width>
|
||||||
|
<height>567</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>0</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Form</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||||
|
<property name="spacing">
|
||||||
|
<number>6</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>9</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="QGroupBox" name="m_tbt_gb">
|
||||||
|
<property name="title">
|
||||||
|
<string>Informations des cartouche</string>
|
||||||
|
</property>
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="checked">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="m_tbt_hlayout" stretch="0,1,0">
|
||||||
|
<property name="sizeConstraint">
|
||||||
|
<enum>QLayout::SetDefaultConstraint</enum>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="m_tbt_label">
|
||||||
|
<property name="text">
|
||||||
|
<string>Modèle :</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QComboBox" name="m_tbt_cb"/>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="m_tbt_pb">
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="../../qelectrotech.qrc">
|
||||||
|
<normaloff>:/ico/16x16/label.png</normaloff>:/ico/16x16/label.png</iconset>
|
||||||
|
</property>
|
||||||
|
<property name="flat">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QTabWidget" name="tabWidget">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="tabPosition">
|
||||||
|
<enum>QTabWidget::South</enum>
|
||||||
|
</property>
|
||||||
|
<property name="tabShape">
|
||||||
|
<enum>QTabWidget::Rounded</enum>
|
||||||
|
</property>
|
||||||
|
<property name="currentIndex">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="elideMode">
|
||||||
|
<enum>Qt::ElideNone</enum>
|
||||||
|
</property>
|
||||||
|
<property name="usesScrollButtons">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="tabsClosable">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<widget class="QWidget" name="tab">
|
||||||
|
<attribute name="title">
|
||||||
|
<string>Principales</string>
|
||||||
|
</attribute>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||||
|
<item>
|
||||||
|
<layout class="QGridLayout" name="gridLayout_4">
|
||||||
|
<item row="5" column="1">
|
||||||
|
<widget class="QLabel" name="label_6">
|
||||||
|
<property name="text">
|
||||||
|
<string>Folio :</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="1">
|
||||||
|
<widget class="QLabel" name="label_3">
|
||||||
|
<property name="text">
|
||||||
|
<string>Auteur :</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="4" column="2">
|
||||||
|
<widget class="QLineEdit" name="m_file_le">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Disponible en tant que %filename pour les modèles de cartouches</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="2">
|
||||||
|
<layout class="QGridLayout" name="gridLayout_2" columnstretch="0,1,0">
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QRadioButton" name="m_no_date_rb">
|
||||||
|
<property name="text">
|
||||||
|
<string>Pas de date</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QRadioButton" name="m_current_date_rb">
|
||||||
|
<property name="text">
|
||||||
|
<string>Date courante</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="2">
|
||||||
|
<widget class="QPushButton" name="m_date_now_pb">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Appliquer la date actuelle</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="../../qelectrotech.qrc">
|
||||||
|
<normaloff>:/ico/22x22/start.png</normaloff>:/ico/22x22/start.png</iconset>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="1">
|
||||||
|
<widget class="QDateEdit" name="m_date_edit">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Disponible en tant que %date pour les modèles de cartouches</string>
|
||||||
|
</property>
|
||||||
|
<property name="frame">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="calendarPopup">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="0">
|
||||||
|
<widget class="QRadioButton" name="m_fixed_date_rb">
|
||||||
|
<property name="text">
|
||||||
|
<string>Date fixe :</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="QLabel" name="label_2">
|
||||||
|
<property name="text">
|
||||||
|
<string>Titre :</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="4" column="1">
|
||||||
|
<widget class="QLabel" name="label_5">
|
||||||
|
<property name="text">
|
||||||
|
<string>Fichier :</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="5" column="2">
|
||||||
|
<widget class="QLineEdit" name="m_folio_le">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Disponible en tant que %folio pour les modèles de cartouches</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="6" column="2">
|
||||||
|
<widget class="QLabel" name="label_7">
|
||||||
|
<property name="frameShape">
|
||||||
|
<enum>QFrame::NoFrame</enum>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Les variables suivantes sont utilisables dans le champ Folio :
|
||||||
|
- %id : numéro du schéma courant dans le projet
|
||||||
|
- %total : nombre total de schémas dans le projet</string>
|
||||||
|
</property>
|
||||||
|
<property name="scaledContents">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="1">
|
||||||
|
<widget class="QLabel" name="label_4">
|
||||||
|
<property name="text">
|
||||||
|
<string>Date :</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="2">
|
||||||
|
<widget class="QLineEdit" name="m_author_le">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Disponible en tant que %author pour les modèles de cartouches</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="2">
|
||||||
|
<widget class="QLineEdit" name="m_title_le">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Disponible en tant que %title pour les modèles de cartouches</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<widget class="QWidget" name="tab_2">
|
||||||
|
<attribute name="title">
|
||||||
|
<string>Personnalisées</string>
|
||||||
|
</attribute>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<item>
|
||||||
|
<layout class="QVBoxLayout" name="m_tab2_vlayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_8">
|
||||||
|
<property name="text">
|
||||||
|
<string>Vous pouvez définir ici vos propres associations noms/valeurs pour que le cartouche en tienne compte. Exemple :
|
||||||
|
associer le nom "volta" et la valeur "1745" remplacera %{volta} par 1745 dans le cartouche.</string>
|
||||||
|
</property>
|
||||||
|
<property name="wordWrap">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<resources>
|
||||||
|
<include location="../../qelectrotech.qrc"/>
|
||||||
|
</resources>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
||||||
Reference in New Issue
Block a user