2016-07-20 15:07:21 +00:00
|
|
|
/*
|
2020-06-15 17:42:37 +02:00
|
|
|
Copyright 2006-2020 The QElectroTech Team
|
2016-07-20 15:07:21 +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 "autonumberingmanagementw.h"
|
2020-12-08 19:57:35 +01:00
|
|
|
|
|
|
|
#include "../../diagram.h"
|
|
|
|
#include "../../qetproject.h"
|
|
|
|
#include "../numerotationcontextcommands.h"
|
2016-08-29 15:37:42 +00:00
|
|
|
#include "formulaautonumberingw.h"
|
2020-12-08 19:57:35 +01:00
|
|
|
#include "numparteditorw.h"
|
2016-07-20 15:07:21 +00:00
|
|
|
#include "qdebug.h"
|
2020-12-08 19:57:35 +01:00
|
|
|
#include "ui_autonumberingmanagementw.h"
|
|
|
|
#include "ui_formulaautonumberingw.h"
|
|
|
|
|
|
|
|
#include <QMessageBox>
|
2016-07-20 15:07:21 +00:00
|
|
|
|
|
|
|
/**
|
2020-08-08 23:58:17 +02:00
|
|
|
@brief AutoNumberingManagementW::AutoNumberingManagementW
|
|
|
|
Constructor
|
|
|
|
@param project
|
|
|
|
@param parent
|
|
|
|
*/
|
|
|
|
AutoNumberingManagementW::AutoNumberingManagementW(QETProject *project,
|
|
|
|
QWidget *parent) :
|
2016-07-20 15:07:21 +00:00
|
|
|
QWidget(parent),
|
|
|
|
project_(project)
|
|
|
|
{
|
|
|
|
ui = new Ui::AutoNumberingManagementW;
|
|
|
|
ui->setupUi(this);
|
|
|
|
ui->m_apply_locations_rb->setHidden(true);
|
|
|
|
ui->m_selected_locations_le->setHidden(true);
|
|
|
|
ui->folioWidget->setHidden(true);
|
|
|
|
ui->m_selected_folios_widget->setDisabled(true);
|
|
|
|
ui->m_selected_folios_le->setDisabled(true);
|
|
|
|
ui->m_selected_folios_le->setReadOnly(true);
|
2016-12-10 12:00:52 +00:00
|
|
|
ui->m_apply_project_rb->setChecked(true);
|
2016-07-20 15:07:21 +00:00
|
|
|
setProjectContext();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2020-08-08 23:58:17 +02:00
|
|
|
@brief AutoNumberingManagementW::~AutoNumberingManagementW
|
|
|
|
Destructor
|
|
|
|
*/
|
2016-07-20 15:07:21 +00:00
|
|
|
AutoNumberingManagementW::~AutoNumberingManagementW()
|
|
|
|
{
|
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2020-08-08 23:58:17 +02:00
|
|
|
@brief AutoNumberingManagementW::setProjectContext
|
|
|
|
Add Default Project Status
|
|
|
|
*/
|
2020-08-29 19:21:51 +02:00
|
|
|
void AutoNumberingManagementW::setProjectContext()
|
|
|
|
{
|
2016-07-20 15:07:21 +00:00
|
|
|
ui->m_status_cb->addItem(tr("Under Development"));
|
|
|
|
ui->m_status_cb->addItem(tr("Installing"));
|
|
|
|
ui->m_status_cb->addItem(tr("Built"));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2020-08-08 23:58:17 +02:00
|
|
|
@brief AutoNumberingManagementW::on_m_status_cb_currentIndexChanged
|
|
|
|
Load Default Status Options
|
|
|
|
@param index
|
|
|
|
*/
|
2020-08-29 19:21:51 +02:00
|
|
|
void AutoNumberingManagementW::on_m_status_cb_currentIndexChanged(int index)
|
|
|
|
{
|
2016-07-20 15:07:21 +00:00
|
|
|
|
|
|
|
//Under Development
|
|
|
|
if (index == 0) {
|
|
|
|
ui->conductorWidget->setEnabled(true);
|
|
|
|
ui->elementWidget->setEnabled(true);
|
|
|
|
ui->folioWidget->setEnabled(true);
|
|
|
|
ui->m_both_conductor_rb->setChecked(true);
|
|
|
|
ui->m_both_element_rb->setChecked(true);
|
|
|
|
ui->m_both_folio_rb->setChecked(true);
|
|
|
|
}
|
|
|
|
//Installing
|
|
|
|
else if (index == 1) {
|
|
|
|
ui->conductorWidget->setEnabled(true);
|
|
|
|
ui->elementWidget->setEnabled(true);
|
|
|
|
ui->folioWidget->setEnabled(true);
|
|
|
|
ui->m_new_conductor_rb->setChecked(true);
|
|
|
|
ui->m_new_element_rb->setChecked(true);
|
|
|
|
ui->m_new_folio_rb->setChecked(true);
|
|
|
|
}
|
|
|
|
//Built
|
|
|
|
else if (index == 2) {
|
|
|
|
ui->m_disable_conductor_rb->setChecked(true);
|
|
|
|
ui->m_disable_element_rb->setChecked(true);
|
|
|
|
ui->m_disable_folio_rb->setChecked(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2020-08-08 23:58:17 +02:00
|
|
|
@brief AutoNumberingManagementW::on_m_apply_folios_rb_clicked
|
|
|
|
Set From Folios Combobox
|
|
|
|
*/
|
2020-08-29 19:21:51 +02:00
|
|
|
void AutoNumberingManagementW::on_m_apply_folios_rb_clicked()
|
|
|
|
{
|
2016-07-20 15:07:21 +00:00
|
|
|
if (ui->m_apply_folios_rb->isChecked()) {
|
|
|
|
ui->m_selected_folios_widget->setEnabled(true);
|
|
|
|
ui->m_selected_folios_le->setEnabled(true);
|
|
|
|
if (ui->m_from_folios_cb->count()<=0) {
|
|
|
|
ui->m_from_folios_cb->clear();
|
|
|
|
ui->m_from_folios_cb->addItem("");
|
2017-02-05 16:18:50 +00:00
|
|
|
foreach (Diagram *diagram, project_->diagrams()){
|
2016-07-20 15:07:21 +00:00
|
|
|
if (diagram->title() != "")
|
2020-08-29 19:21:51 +02:00
|
|
|
ui->m_from_folios_cb->addItem(
|
|
|
|
diagram->title(),
|
|
|
|
diagram->folioIndex());
|
|
|
|
else ui->m_from_folios_cb->addItem(
|
|
|
|
QString::number(
|
|
|
|
diagram->folioIndex()),
|
|
|
|
diagram->folioIndex());
|
2016-07-20 15:07:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (ui->m_from_folios_cb->currentIndex() > 0)
|
|
|
|
applyEnable(true);
|
|
|
|
else applyEnable(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2020-08-08 23:58:17 +02:00
|
|
|
@brief AutoNumberingManagementW::on_m_from_folios_cb_currentIndexChanged
|
|
|
|
Set To Folios Combobox
|
|
|
|
@param index
|
|
|
|
*/
|
2020-08-29 19:21:51 +02:00
|
|
|
void AutoNumberingManagementW::on_m_from_folios_cb_currentIndexChanged(
|
|
|
|
int index)
|
|
|
|
{
|
2016-07-20 15:07:21 +00:00
|
|
|
ui->m_to_folios_cb->clear();
|
|
|
|
ui->m_selected_folios_le->clear();
|
|
|
|
ui->m_selected_folios_le->setEnabled(true);
|
|
|
|
if (index > 0) {
|
|
|
|
ui->m_to_folios_cb->setEnabled(true);
|
|
|
|
ui->m_to_folios_cb->addItem("");
|
|
|
|
for (int i=index;i<project_->diagrams().size();i++) {
|
|
|
|
if (project_->diagrams().at(i)->title() != "") {
|
2020-08-08 23:58:17 +02:00
|
|
|
ui->m_to_folios_cb->addItem(
|
|
|
|
project_->diagrams().at(i)->title(),
|
|
|
|
project_->diagrams().at(i)->folioIndex());
|
2016-07-20 15:07:21 +00:00
|
|
|
}
|
2020-08-08 23:58:17 +02:00
|
|
|
else ui->m_to_folios_cb->addItem(
|
|
|
|
QString::number(
|
|
|
|
project_->diagrams().at(i)->folioIndex()),
|
|
|
|
project_->diagrams().at(i)->folioIndex());
|
2016-07-20 15:07:21 +00:00
|
|
|
}
|
|
|
|
applyEnable(true);
|
|
|
|
ui->m_selected_folios_le->clear();
|
|
|
|
ui->m_selected_folios_le->insert(ui->m_from_folios_cb->currentText());
|
|
|
|
}
|
|
|
|
else applyEnable(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2020-08-08 23:58:17 +02:00
|
|
|
@brief AutoNumberingManagementW::on_m_to_folios_cb_currentIndexChanged
|
|
|
|
Set selected folios Line Edit content
|
|
|
|
@param index
|
|
|
|
*/
|
2020-08-29 19:21:51 +02:00
|
|
|
void AutoNumberingManagementW::on_m_to_folios_cb_currentIndexChanged(int index)
|
|
|
|
{
|
2016-07-20 15:07:21 +00:00
|
|
|
if (index > 0) {
|
|
|
|
QString from = ui->m_from_folios_cb->currentText();
|
|
|
|
QString to = ui->m_to_folios_cb->currentText();
|
|
|
|
ui->m_selected_folios_le->clear();
|
|
|
|
ui->m_selected_folios_le->insert(from + " - " + to);
|
|
|
|
ui->m_selected_folios_le->setDisabled(true);
|
|
|
|
}
|
|
|
|
applyEnable(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2020-08-08 23:58:17 +02:00
|
|
|
@brief AutoNumberingManagementW::on_m_apply_project_rb_clicked
|
|
|
|
Disable folio widget
|
|
|
|
*/
|
2020-08-29 19:21:51 +02:00
|
|
|
void AutoNumberingManagementW::on_m_apply_project_rb_clicked()
|
|
|
|
{
|
2016-07-20 15:07:21 +00:00
|
|
|
ui->m_selected_folios_widget->setDisabled(true);
|
|
|
|
ui->m_selected_folios_le->setDisabled(true);
|
|
|
|
applyEnable(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2020-08-08 23:58:17 +02:00
|
|
|
@brief AutoNumberingManagementW::on_buttonBox_clicked
|
2020-08-18 20:07:55 +02:00
|
|
|
Action on buttonBox clicked
|
2020-08-08 23:58:17 +02:00
|
|
|
@param button
|
|
|
|
*/
|
2020-08-29 19:21:51 +02:00
|
|
|
void AutoNumberingManagementW::on_buttonBox_clicked(QAbstractButton *button)
|
|
|
|
{
|
2016-07-20 15:07:21 +00:00
|
|
|
//transform button to int
|
|
|
|
int answer = ui -> buttonBox -> buttonRole(button);
|
|
|
|
switch (answer) {
|
2020-08-29 19:21:51 +02:00
|
|
|
//apply the context in the diagram displayed by diagram_chooser.
|
2016-07-20 15:07:21 +00:00
|
|
|
case QDialogButtonBox::ApplyRole:
|
|
|
|
applyEnable(false);
|
|
|
|
emit applyPressed();
|
|
|
|
break;
|
|
|
|
case QDialogButtonBox::HelpRole:
|
2020-08-18 20:08:32 +02:00
|
|
|
QMessageBox::information(
|
|
|
|
this,
|
|
|
|
tr("Auto Numbering Management", "title window"),
|
|
|
|
tr("In this Menu you can set whether you want the Auto Numberings to be updated or not."
|
|
|
|
" For Element Auto Numbering you have 4 options of Update Policy:\n"
|
|
|
|
"-Both: both New and Existent Element labels will be updated. This is the default option.\n"
|
|
|
|
"-Update Only New: only new created Elements will be updated. Existent Element labels will be frozen.\n"
|
|
|
|
"-Update Only Existent: only existent Elements will be updated. New Elements will be assigned "
|
|
|
|
"their formula but will not update once created.\n"
|
|
|
|
"-Disable: both New and Existent Element labels will not be updated. This is valid for new folios as well.\n"
|
|
|
|
"Note: These options DO NOT allow or block Auto Numberings, only their Update Policy."
|
|
|
|
));
|
2016-07-20 15:07:21 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2020-08-08 23:58:17 +02:00
|
|
|
@brief AutoNumberingManagementW::applyEnable
|
|
|
|
enable/disable the apply button
|
|
|
|
@param b
|
|
|
|
*/
|
2020-08-29 19:21:51 +02:00
|
|
|
void AutoNumberingManagementW::applyEnable(bool b)
|
|
|
|
{
|
2016-07-20 15:07:21 +00:00
|
|
|
if (b){
|
|
|
|
bool valid= true;
|
|
|
|
if (ui->m_apply_project_rb->isChecked())
|
2020-08-29 19:21:51 +02:00
|
|
|
ui->buttonBox->button(QDialogButtonBox::Apply)
|
|
|
|
->setEnabled(valid);
|
2016-07-20 15:07:21 +00:00
|
|
|
else if (ui->m_apply_folios_rb->isChecked())
|
2020-08-29 19:21:51 +02:00
|
|
|
ui->buttonBox-> button(QDialogButtonBox::Apply)
|
|
|
|
->setEnabled(valid);
|
2016-07-20 15:07:21 +00:00
|
|
|
}
|
|
|
|
else {
|
2020-08-29 19:21:51 +02:00
|
|
|
ui->buttonBox->button(QDialogButtonBox::Apply)->setEnabled(b);
|
2016-07-20 15:07:21 +00:00
|
|
|
}
|
|
|
|
}
|