QElectroTech  0.70
replacefoliowidget.cpp
Go to the documentation of this file.
1 /*
2  Copyright 2006-2019 The QElectroTech Team
3  This file is part of QElectroTech.
4 
5  QElectroTech is free software: you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation, either version 2 of the License, or
8  (at your option) any later version.
9 
10  QElectroTech is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
17 */
18 #include "replacefoliowidget.h"
19 #include "ui_replacefoliowidget.h"
20 #include "diagramcontextwidget.h"
21 #include "searchandreplaceworker.h"
22 
23 #include <QDialogButtonBox>
24 
26 
28  QWidget(parent),
29  ui(new Ui::ReplaceFolioWidget)
30 {
31  ui->setupUi(this);
33  ui->m_tab2_vlayout->addWidget(m_diagram_context_widget);
34 }
35 
37 {
38  delete ui;
39 }
40 
46 {
48  prop.title = ui->m_title_le ->text();
49  prop.author = ui->m_author_le->text();
50  prop.filename = ui->m_file_le ->text();
51  prop.plant = ui->m_plant ->text();
52  prop.locmach = ui->m_loc ->text();
53  prop.indexrev = ui->m_indice ->text();
54  prop.folio = ui->m_folio_le ->text();
55 
56  if (ui->m_unchanged_date->isChecked()) {
57  prop.date = QDate();
59  }
60  if (ui->m_no_date_rb->isChecked()) {
63  }
64  else if (ui->m_fixed_date_rb->isChecked()) {
65  prop.date = ui->m_date_edit->date();
67  }
68 
70  return prop;
71 }
72 
79 {
80  sarw::setupLineEdit(ui->m_title_le, ui->m_title_cb, properties.title);
81  sarw::setupLineEdit(ui->m_author_le, ui->m_author_cb, properties.author);
82  sarw::setupLineEdit(ui->m_file_le, ui->m_file_cb, properties.filename);
83  sarw::setupLineEdit(ui->m_plant, ui->m_plant_cb, properties.plant);
84  sarw::setupLineEdit(ui->m_loc, ui->m_loc_cb, properties.locmach);
85  sarw::setupLineEdit(ui->m_indice, ui->m_indice_cb, properties.indexrev);
86  sarw::setupLineEdit(ui->m_folio_le, ui->m_folio_cb, properties.folio);
87 
88  //About date
89  ui->m_date_now_pb->setDisabled(true);
90  ui->m_date_edit ->setDisabled(true);
91  ui->m_date_edit ->setDate(QDate::currentDate());
92 
93 
94  if (properties.useDate == TitleBlockProperties::CurrentDate) {
95  ui -> m_fixed_date_rb ->setChecked(true);
96  }
97  else
98  {
99  if (properties.date.isNull()) {
100  ui->m_unchanged_date->setChecked(true);
101  }
102  else if (properties.date == SearchAndReplaceWorker::eraseDate()) {
103  ui->m_no_date_rb->setChecked(true);
104  }
105  else
106  {
107  ui->m_fixed_date_rb->setChecked(true);
108  ui->m_date_edit->setDate(properties.date);
109  }
110  }
111  //About date
112 
114 }
115 
117  QDialog(parent)
118 {
119  QVBoxLayout *layout = new QVBoxLayout(this);
120  layout->addWidget(m_widget = new ReplaceFolioWidget(this));
121  layout->addWidget(m_button_box = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel | QDialogButtonBox::Reset, this));
122 
123  connect(m_button_box, &QDialogButtonBox::clicked, [this](QAbstractButton *button_)
124  {
125  this->done(m_button_box->buttonRole(button_));
126  });
127 }
128 
130 {}
131 
137  return m_widget->titleBlockProperties();
138 }
139 
145  m_widget->setTitleBlockProperties(properties);
146 }
148  ui->m_title_le->setText(ui->m_title_cb->isChecked() ? SearchAndReplaceWorker::eraseText() : QString());
149  ui->m_title_le->setDisabled(ui->m_title_cb->isChecked());
150 }
151 
153  ui->m_author_le->setText(ui->m_author_cb->isChecked() ? SearchAndReplaceWorker::eraseText() : QString());
154  ui->m_author_le->setDisabled(ui->m_author_cb->isChecked());
155 }
156 
158  ui->m_file_le->setText(ui->m_file_cb->isChecked() ? SearchAndReplaceWorker::eraseText() : QString());
159  ui->m_file_le->setDisabled(ui->m_file_cb->isChecked());
160 }
161 
163  ui->m_folio_le->setText(ui->m_folio_cb->isChecked() ? SearchAndReplaceWorker::eraseText() : QString());
164  ui->m_folio_le->setDisabled(ui->m_folio_cb->isChecked());
165 }
166 
168  ui->m_plant->setText(ui->m_plant_cb->isChecked() ? SearchAndReplaceWorker::eraseText() : QString());
169  ui->m_plant->setDisabled(ui->m_plant_cb->isChecked());
170 }
171 
173  ui->m_loc->setText(ui->m_loc_cb->isChecked() ? SearchAndReplaceWorker::eraseText() : QString());
174  ui->m_loc->setDisabled(ui->m_loc_cb->isChecked());
175 }
176 
178  ui->m_indice->setText(ui->m_indice_cb->isChecked() ? SearchAndReplaceWorker::eraseText() : QString());
179  ui->m_indice->setDisabled(ui->m_indice_cb->isChecked());
180 }
QString locmach
Location(displayed by the default template)
DiagramContextWidget * m_diagram_context_widget
void setTitleBlockProperties(const TitleBlockProperties &properties)
ReplaceFolioWidget::setTitleBlockProperties Set the title block properties edited by this widget...
QString plant
Plant (displayed by the default template)
ReplaceFolioWidget * m_widget
TitleBlockProperties titleBlockProperties() const
ReplaceFolioWidget::titleBlockProperties.
void setTitleBlockProperties(const TitleBlockProperties &properties)
ReplaceFolioDialog::setTitleBlockProperties.
QDate date
Date (displayed by the default template)
Ui::ReplaceFolioWidget * ui
QString filename
Filename (displayed by the default template)
DiagramContext context
Container for the additional, user-defined fields.
ReplaceFolioDialog(QWidget *parent=nullptr)
DiagramContext context() const
DiagramContextWidget::context.
TitleBlockProperties titleBlockProperties() const
ReplaceFolioDialog::titleBlockProperties.
DateManagement useDate
Wheter to use the date attribute.
QString author
Author of the diagram/folio (displayed by the default template)
void setContext(const DiagramContext &context)
DiagramContextWidget::setContext Load the content from into this widget.
SearchAndReplaceWorker sarw
QDialogButtonBox * m_button_box
static void setupLineEdit(QLineEdit *l, QCheckBox *cb, QString str)
SearchAndReplaceWorker::setupLineEdit With search and replace, when the variable to edit is a text...
The SearchAndReplaceWorker class This class is the worker use to change properties when use the searc...
QString indexrev
Revision Index (displayed by the default template)
QIcon Cancel
Definition: qeticons.cpp:34
ReplaceFolioWidget(QWidget *parent=nullptr)
QString folio
Folio information (displayed by the default template)
QString title
Folio title (displayed by the default template)