QElectroTech  0.70
autonumberingmanagementw.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 */
19 #include "ui_autonumberingmanagementw.h"
20 #include "numparteditorw.h"
21 #include <QMessageBox>
23 #include "formulaautonumberingw.h"
24 #include "ui_formulaautonumberingw.h"
25 #include "qdebug.h"
26 #include "qetproject.h"
27 #include "diagram.h"
28 
33  QWidget(parent),
34  project_(project)
35 {
36  ui = new Ui::AutoNumberingManagementW;
37  ui->setupUi(this);
38  ui->m_apply_locations_rb->setHidden(true);
39  ui->m_selected_locations_le->setHidden(true);
40  ui->folioWidget->setHidden(true);
41  ui->m_selected_folios_widget->setDisabled(true);
42  ui->m_selected_folios_le->setDisabled(true);
43  ui->m_selected_folios_le->setReadOnly(true);
44  ui->m_apply_project_rb->setChecked(true);
46 }
47 
52 {
53  delete ui;
54 }
55 
61  ui->m_status_cb->addItem(tr("Under Development"));
62  ui->m_status_cb->addItem(tr("Installing"));
63  ui->m_status_cb->addItem(tr("Built"));
64 }
65 
71 
72  //Under Development
73  if (index == 0) {
74  ui->conductorWidget->setEnabled(true);
75  ui->elementWidget->setEnabled(true);
76  ui->folioWidget->setEnabled(true);
77  ui->m_both_conductor_rb->setChecked(true);
78  ui->m_both_element_rb->setChecked(true);
79  ui->m_both_folio_rb->setChecked(true);
80  }
81  //Installing
82  else if (index == 1) {
83  ui->conductorWidget->setEnabled(true);
84  ui->elementWidget->setEnabled(true);
85  ui->folioWidget->setEnabled(true);
86  ui->m_new_conductor_rb->setChecked(true);
87  ui->m_new_element_rb->setChecked(true);
88  ui->m_new_folio_rb->setChecked(true);
89  }
90  //Built
91  else if (index == 2) {
92  ui->m_disable_conductor_rb->setChecked(true);
93  ui->m_disable_element_rb->setChecked(true);
94  ui->m_disable_folio_rb->setChecked(true);
95  }
96 }
97 
103  if (ui->m_apply_folios_rb->isChecked()) {
104  ui->m_selected_folios_widget->setEnabled(true);
105  ui->m_selected_folios_le->setEnabled(true);
106  if (ui->m_from_folios_cb->count()<=0) {
107  ui->m_from_folios_cb->clear();
108  ui->m_from_folios_cb->addItem("");
109  foreach (Diagram *diagram, project_->diagrams()){
110  if (diagram->title() != "")
111  ui->m_from_folios_cb->addItem(diagram->title(),diagram->folioIndex());
112  else ui->m_from_folios_cb->addItem(QString::number(diagram->folioIndex()),diagram->folioIndex());
113  }
114  }
115  if (ui->m_from_folios_cb->currentIndex() > 0)
116  applyEnable(true);
117  else applyEnable(false);
118  }
119 }
120 
126  ui->m_to_folios_cb->clear();
127  ui->m_selected_folios_le->clear();
128  ui->m_selected_folios_le->setEnabled(true);
129  if (index > 0) {
130  ui->m_to_folios_cb->setEnabled(true);
131  ui->m_to_folios_cb->addItem("");
132  for (int i=index;i<project_->diagrams().size();i++) {
133  if (project_->diagrams().at(i)->title() != "") {
134  ui->m_to_folios_cb->addItem(project_->diagrams().at(i)->title(),project_->diagrams().at(i)->folioIndex());
135  }
136  else ui->m_to_folios_cb->addItem(QString::number(project_->diagrams().at(i)->folioIndex()),project_->diagrams().at(i)->folioIndex());
137  }
138  applyEnable(true);
139  ui->m_selected_folios_le->clear();
140  ui->m_selected_folios_le->insert(ui->m_from_folios_cb->currentText());
141  }
142  else applyEnable(false);
143 }
144 
150  if (index > 0) {
151  QString from = ui->m_from_folios_cb->currentText();
152  QString to = ui->m_to_folios_cb->currentText();
153  ui->m_selected_folios_le->clear();
154  ui->m_selected_folios_le->insert(from + " - " + to);
155  ui->m_selected_folios_le->setDisabled(true);
156  }
157  applyEnable(true);
158 }
159 
165  ui->m_selected_folios_widget->setDisabled(true);
166  ui->m_selected_folios_le->setDisabled(true);
167  applyEnable(true);
168 }
169 
174 void AutoNumberingManagementW::on_buttonBox_clicked(QAbstractButton *button) {
175  //transform button to int
176  int answer = ui -> buttonBox -> buttonRole(button);
177  switch (answer) {
178  //apply the context in the diagram displayed by @diagram_chooser.
179  case QDialogButtonBox::ApplyRole:
180  applyEnable(false);
181  emit applyPressed();
182  break;
183  case QDialogButtonBox::HelpRole:
184  QMessageBox::information(this, tr("Auto Numbering Management", "title window"),
185  tr("In this Menu you can set whether you want the Auto Numberings to be updated or not."
186  " For Element Auto Numbering you have 4 options of Update Policy:\n"
187  "-Both: both New and Existent Element labels will be updated. This is the default option.\n"
188  "-Update Only New: only new created Elements will be updated. Existent Element labels will be frozen.\n"
189  "-Update Only Existent: only existent Elements will be updated. New Elements will be assigned "
190  "their formula but will not update once created.\n"
191  "-Disable: both New and Existent Element labels will not be updated. This is valid for new folios as well.\n"
192  "Note: These options DO NOT allow or block Auto Numberings, only their Update Policy."
193  ));
194  break;
195  }
196 }
197 
203  if (b){
204  bool valid= true;
205  if (ui->m_apply_project_rb->isChecked())
206  ui -> buttonBox -> button(QDialogButtonBox::Apply) -> setEnabled(valid);
207  else if (ui->m_apply_folios_rb->isChecked())
208  ui -> buttonBox -> button(QDialogButtonBox::Apply) -> setEnabled(valid);
209  }
210  else {
211  ui -> buttonBox -> button(QDialogButtonBox::Apply) -> setEnabled(b);
212  }
213 }
QList< Diagram * > diagrams() const
Definition: qetproject.cpp:210
void on_m_apply_project_rb_clicked()
AutoNumberingManagementW::on_m_apply_project_rb_clicked Disable folio widget.
AutoNumberingManagementW(QETProject *project, QWidget *parent=nullptr)
int folioIndex() const
Definition: diagram.cpp:1738
Ui::AutoNumberingManagementW * ui
void on_m_apply_folios_rb_clicked()
AutoNumberingManagementW::on_m_apply_folios_rb_clicked Set From Folios Combobox.
void applyEnable(bool=true)
AutoNumberingManagementW::applyEnable enable/disable the apply button.
QString title() const
Definition: diagram.cpp:1473
QIcon tr
Definition: qeticons.cpp:204
QMessageBox::StandardButton information(QWidget *, const QString &, const QString &, QMessageBox::StandardButtons=QMessageBox::Ok, QMessageBox::StandardButton=QMessageBox::NoButton)
void on_buttonBox_clicked(QAbstractButton *)
AutoNumberingManagementW::on_buttonBox_clicked Action on clicked.
void setProjectContext()
AutoNumberingManagementW::setProjectContext Add Default Project Status.
void on_m_to_folios_cb_currentIndexChanged(int)
AutoNumberingManagementW::on_m_to_folios_cb_currentIndexChanged Set selected folios Line Edit content...
void on_m_status_cb_currentIndexChanged(int)
AutoNumberingManagementW::on_m_status_cb_currentIndexChanged Load Default Status Options.
void on_m_from_folios_cb_currentIndexChanged(int)
AutoNumberingManagementW::on_m_from_folios_cb_currentIndexChanged Set To Folios Combobox.