Added AutoNumbering Management Tab. Update Policy support to Element.

git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@4585 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
dfochi
2016-07-20 15:07:21 +00:00
parent 302d54d035
commit 3a7d210bcb
14 changed files with 1044 additions and 41 deletions

View File

@@ -153,7 +153,7 @@ void AutoNumberingDockWidget::setActive() {
//Element
QString current_element_autonum = project_->elementCurrentAutoNum();
QString element_formula = project_->elementAutoNumFormula();
QString active_element_autonum = project_->elementAutoNum_2().key(element_formula);
QString active_element_autonum = project_->elementAutoNumHash().key(element_formula);
int el_index = ui->m_element_cb->findText(active_element_autonum);
ui->m_element_cb->setCurrentIndex(el_index);

View File

@@ -0,0 +1,214 @@
/*
Copyright 2006-2016 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 "autonumberingmanagementw.h"
#include "ui_autonumberingmanagementw.h"
#include "numparteditorw.h"
#include <QMessageBox>
#include "numerotationcontextcommands.h"
#include "elementautonumberingw.h"
#include "ui_elementautonumberingw.h"
#include "qdebug.h"
#include "qetproject.h"
#include "diagram.h"
/**
* Constructor
*/
AutoNumberingManagementW::AutoNumberingManagementW(QETProject *project, QWidget *parent) :
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->conductorWidget->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);
applyEnable(false);
setProjectContext();
}
/**
* Destructor
*/
AutoNumberingManagementW::~AutoNumberingManagementW()
{
delete ui;
}
/**
* @brief AutoNumberingManagementW::setProjectContext
* Add Default Project Status
*/
void AutoNumberingManagementW::setProjectContext() {
ui->m_status_cb->addItem(tr("Under Development"));
ui->m_status_cb->addItem(tr("Installing"));
ui->m_status_cb->addItem(tr("Built"));
}
/**
* @brief AutoNumberingManagementW::on_m_status_cb_currentIndexChanged
* Load Default Status Options
*/
void AutoNumberingManagementW::on_m_status_cb_currentIndexChanged(int index) {
//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);
}
}
/**
* @brief AutoNumberingManagementW::on_m_apply_folios_rb_clicked
* Set From Folios Combobox
*/
void AutoNumberingManagementW::on_m_apply_folios_rb_clicked() {
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("");
foreach (Diagram *diagram, project_->diagrams()){
if (diagram->title() != "")
ui->m_from_folios_cb->addItem(diagram->title(),diagram->folioIndex());
else ui->m_from_folios_cb->addItem(QString::number(diagram->folioIndex()),diagram->folioIndex());
}
}
if (ui->m_from_folios_cb->currentIndex() > 0)
applyEnable(true);
else applyEnable(false);
}
}
/**
* @brief AutoNumberingManagementW::on_m_from_folios_cb_currentIndexChanged
* Set To Folios Combobox
*/
void AutoNumberingManagementW::on_m_from_folios_cb_currentIndexChanged(int index) {
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() != "") {
ui->m_to_folios_cb->addItem(project_->diagrams().at(i)->title(),project_->diagrams().at(i)->folioIndex());
}
else ui->m_to_folios_cb->addItem(QString::number(project_->diagrams().at(i)->folioIndex()),project_->diagrams().at(i)->folioIndex());
}
applyEnable(true);
ui->m_selected_folios_le->clear();
ui->m_selected_folios_le->insert(ui->m_from_folios_cb->currentText());
}
else applyEnable(false);
}
/**
* @brief AutoNumberingManagementW::on_m_to_folios_cb_currentIndexChanged
* Set selected folios Line Edit content
*/
void AutoNumberingManagementW::on_m_to_folios_cb_currentIndexChanged(int index) {
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);
}
/**
* @brief AutoNumberingManagementW::on_m_apply_project_rb_clicked
* Disable folio widget
*/
void AutoNumberingManagementW::on_m_apply_project_rb_clicked() {
ui->m_selected_folios_widget->setDisabled(true);
ui->m_selected_folios_le->setDisabled(true);
applyEnable(true);
}
/**
* @brief AutoNumberingManagementW::on_buttonBox_clicked
* Action on @buttonBox clicked
*/
void AutoNumberingManagementW::on_buttonBox_clicked(QAbstractButton *button) {
//transform button to int
int answer = ui -> buttonBox -> buttonRole(button);
switch (answer) {
//apply the context in the diagram displayed by @diagram_chooser.
case QDialogButtonBox::ApplyRole:
applyEnable(false);
emit applyPressed();
break;
case QDialogButtonBox::HelpRole:
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."
));
break;
}
}
/**
* @brief AutoNumberingManagementW::applyEnable
* enable/disable the apply button
*/
void AutoNumberingManagementW::applyEnable(bool b) {
if (b){
bool valid= true;
if (ui->m_apply_project_rb->isChecked())
ui -> buttonBox -> button(QDialogButtonBox::Apply) -> setEnabled(valid);
else if (ui->m_apply_folios_rb->isChecked())
ui -> buttonBox -> button(QDialogButtonBox::Apply) -> setEnabled(valid);
}
else {
ui -> buttonBox -> button(QDialogButtonBox::Apply) -> setEnabled(b);
}
}

View File

@@ -0,0 +1,63 @@
/*
Copyright 2006-2016 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 AUTONUMBERINGMANAGEMENTW_H
#define AUTONUMBERINGMANAGEMENTW_H
#include <QWidget>
class NumPartEditorW;
class QAbstractButton;
class QETProject;
namespace Ui {
class AutoNumberingManagementW;
}
class AutoNumberingManagementW : public QWidget
{
Q_OBJECT
//METHODS
public:
explicit AutoNumberingManagementW(QETProject *project, QWidget *parent = 0);
~AutoNumberingManagementW();
Ui::AutoNumberingManagementW *ui;
void setProjectContext ();
void contextToFormula ();
QString elementFormula();
//SIGNALS
signals:
void applyPressed();
//SLOTS
private slots:
void on_m_from_folios_cb_currentIndexChanged(int);
void on_m_to_folios_cb_currentIndexChanged(int);
void on_m_status_cb_currentIndexChanged(int);
void on_m_apply_folios_rb_clicked();
void on_m_apply_project_rb_clicked();
void on_buttonBox_clicked(QAbstractButton *);
void applyEnable (bool = true);
//ATTRIBUTES
private:
QETProject *project_;
};
#endif // AUTONUMBERINGMANAGEMENTW_H

View File

@@ -0,0 +1,470 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>AutoNumberingManagementW</class>
<widget class="QWidget" name="AutoNumberingManagementW">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>520</width>
<height>550</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>460</width>
<height>0</height>
</size>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<item>
<widget class="QScrollArea" name="scrollArea">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>50</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>450</width>
<height>253</height>
</size>
</property>
<property name="sizeIncrement">
<size>
<width>0</width>
<height>50</height>
</size>
</property>
<property name="mouseTracking">
<bool>false</bool>
</property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAsNeeded</enum>
</property>
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="sizeAdjustPolicy">
<enum>QAbstractScrollArea::AdjustToContents</enum>
</property>
<property name="widgetResizable">
<bool>true</bool>
</property>
<property name="alignment">
<set>Qt::AlignHCenter|Qt::AlignTop</set>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>500</width>
<height>495</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>430</width>
<height>250</height>
</size>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="sizeConstraint">
<enum>QLayout::SetFixedSize</enum>
</property>
<item row="0" column="1">
<widget class="QLabel" name="label">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Project Status:</string>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QComboBox" name="m_status_cb">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="sizeAdjustPolicy">
<enum>QComboBox::AdjustToContents</enum>
</property>
</widget>
</item>
<item row="5" column="1" colspan="3">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="3" column="1" colspan="3">
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Range</string>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="2" column="0">
<widget class="QLineEdit" name="m_selected_folios_le">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QRadioButton" name="m_apply_locations_rb">
<property name="text">
<string>Apply to Selected Locations</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QRadioButton" name="m_apply_folios_rb">
<property name="text">
<string>Apply to Selected Folios</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QRadioButton" name="m_apply_project_rb">
<property name="text">
<string>Apply to Entire Project</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLineEdit" name="m_selected_locations_le"/>
</item>
<item row="5" column="0">
<widget class="QWidget" name="m_selected_folios_widget" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QLabel" name="label_5">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>From</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="m_from_folios_cb">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_6">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>To</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="m_to_folios_cb">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
<item row="1" column="0" colspan="4">
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Update Policy</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QWidget" name="conductorWidget" native="true">
<layout class="QHBoxLayout" name="conductor_hl">
<item>
<widget class="QLabel" name="label_2">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Conductor</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="m_new_conductor_rb">
<property name="text">
<string>Only New</string>
</property>
<property name="autoExclusive">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="m_existent_conductor_rb">
<property name="text">
<string>Existent and New</string>
</property>
<property name="autoExclusive">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="m_both_conductor_rb">
<property name="text">
<string>Both</string>
</property>
<property name="autoExclusive">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="m_disable_conductor_rb">
<property name="text">
<string>Disable</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="elementWidget" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<layout class="QHBoxLayout" name="element_hl">
<item>
<widget class="QLabel" name="label_3">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Element</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="m_both_element_rb">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Both</string>
</property>
<property name="autoExclusive">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="m_new_element_rb">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Only New</string>
</property>
<property name="autoExclusive">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="m_existent_element_rb">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Only Existent</string>
</property>
<property name="autoExclusive">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="m_disable_element_rb">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Disable</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="folioWidget" native="true">
<property name="font">
<font>
<weight>50</weight>
<bold>false</bold>
<kerning>true</kerning>
</font>
</property>
<layout class="QHBoxLayout" name="folio_hl">
<item>
<widget class="QLabel" name="label_4">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Folio</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="m_new_folio_rb">
<property name="text">
<string>Only New</string>
</property>
<property name="autoExclusive">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="m_existent_folio_rb">
<property name="text">
<string>Existent</string>
</property>
<property name="autoExclusive">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="m_both_folio_rb">
<property name="text">
<string>Both</string>
</property>
<property name="autoExclusive">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="m_disable_folio_rb">
<property name="text">
<string>Disable</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Apply|QDialogButtonBox::Help</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@@ -71,6 +71,6 @@ void ProjectPropertiesDialog::setCurrentPage(ProjectPropertiesDialog::Page p) {
* Change the current displayed tab to folio tab.
*/
void ProjectPropertiesDialog::changeToFolio() {
ProjectAutoNumConfigPage *autoNumPage = static_cast <ProjectAutoNumConfigPage*>(m_properties_dialog->pages.at(2));
autoNumPage->changeToTab(2);
ProjectAutoNumConfigPage *autoNumPage = static_cast <ProjectAutoNumConfigPage*>(m_properties_dialog->pages.at(2));
autoNumPage->changeToTab(3);
}