Move files related to autonum in autoNum directory

git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@4771 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
blacksun
2016-11-07 15:11:12 +00:00
parent f21034fcbe
commit 2b952f4189
28 changed files with 0 additions and 0 deletions

View File

@@ -0,0 +1,272 @@
/*
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 "autonumberingdockwidget.h"
#include "qetapp.h"
#include "ui_autonumberingdockwidget.h"
#include "diagramview.h"
#include "diagram.h"
#include "titleblockproperties.h"
#include "numerotationcontext.h"
/**
* @brief AutoNumberingDockWidget::AutoNumberingDockWidget
* Constructor
* @param parent : parent widget
*/
AutoNumberingDockWidget::AutoNumberingDockWidget(QWidget *parent, QETProject *project) :
QDockWidget(parent),
ui(new Ui::AutoNumberingDockWidget),
project_(project)
{
ui->setupUi(this);
}
/**
* @brief AutoNumberingDockWidget::~AutoNumberingDockWidget
* Destructor
*/
AutoNumberingDockWidget::~AutoNumberingDockWidget()
{
this->disconnect();
delete ui;
}
/**
* @brief AutoNumberingDockWidget::clear
* Remove all combo box values
*/
void AutoNumberingDockWidget::clear()
{
ui->m_conductor_cb->clear();
ui->m_element_cb->clear();
ui->m_folio_cb->clear();
}
/**
* @brief AutoNumberingDockWidget::setProject
* @param project: project to be setted
* @param projectview: projectview to be setted
* assign Project and ProjectView, connect all signals and setContext
*/
void AutoNumberingDockWidget::setProject(QETProject *project, ProjectView *projectview) {
project_ = project;
projectview_ = projectview;
//Conductor Signals
connect(project_, SIGNAL(conductorAutoNumChanged()),this,SLOT(conductorAutoNumChanged()));
connect (project_,SIGNAL(conductorAutoNumRemoved()), this,SLOT(conductorAutoNumChanged()));
connect (project_,SIGNAL(conductorAutoNumAdded()), this,SLOT(conductorAutoNumChanged()));
connect(projectview_,SIGNAL(diagramActivated(DiagramView*)),this,SLOT(setConductorActive(DiagramView*)));
//Element Signals
connect (project_,SIGNAL(elementAutoNumRemoved()), this,SLOT(elementAutoNumChanged()));
connect (project_,SIGNAL(elementAutoNumAdded()), this,SLOT(elementAutoNumChanged()));
//Folio Signals
connect (project_,SIGNAL(folioAutoNumRemoved()), this,SLOT(folioAutoNumChanged()));
connect (project_,SIGNAL(folioAutoNumAdded()), this,SLOT(folioAutoNumChanged()));
connect (this,
SIGNAL(folioAutoNumChanged(QString)),
&projectview_->currentDiagram()->diagram()->border_and_titleblock,
SLOT (slot_setAutoPageNum(QString)));
connect(project_, SIGNAL(defaultTitleBlockPropertiesChanged()),this,SLOT(setActive()));
//Conductor, Element and Folio Signals
connect(projectview_,SIGNAL(projectClosed(ProjectView*)),this,SLOT(clear()));
//Set Combobox Context
setContext();
}
/**
* @brief AutoNumberingDockWidget::setContext
* Add all itens to comboboxes
*/
void AutoNumberingDockWidget::setContext() {
this->clear();
//Conductor Combobox
ui->m_conductor_cb->addItem("");
QList <QString> keys_conductor = project_->conductorAutoNum().keys();
if (!keys_conductor.isEmpty()) {
foreach (QString str, keys_conductor) { ui->m_conductor_cb-> addItem(str); }
}
//Element Combobox
ui->m_element_cb->addItem("");
QList <QString> keys_element = project_->elementAutoNum().keys();
if (!keys_element.isEmpty()) {
foreach (QString str, keys_element) {ui->m_element_cb -> addItem(str);}
}
//Folio Combobox
ui->m_folio_cb->addItem("");
QList <QString> keys_folio = project_->folioAutoNum().keys();
if (!keys_folio.isEmpty()) {
foreach (QString str, keys_folio) { ui->m_folio_cb -> addItem(str);}
}
this->setActive();
}
/**
* @brief AutoNumberingDockWidget::setConductorActive
* @param dv: activated diagramview
*/
void AutoNumberingDockWidget::setConductorActive(DiagramView* dv) {
if (dv!=NULL) {
QString conductor_autonum = dv->diagram()->conductorsAutonumName();
int conductor_index = ui->m_conductor_cb->findText(conductor_autonum);
ui->m_conductor_cb->setCurrentIndex(conductor_index);
}
}
/**
* @brief AutoNumberingDockWidget::setActive
* Set current used autonumberings
*/
void AutoNumberingDockWidget::setActive() {
if (projectview_!=NULL) {
//Conductor
if (projectview_->currentDiagram()) {
QString conductor_autonum = projectview_->currentDiagram()->diagram()->conductorsAutonumName();
int conductor_index = ui->m_conductor_cb->findText(conductor_autonum);
ui->m_conductor_cb->setCurrentIndex(conductor_index);
}
//Element
QString element_formula = project_->elementAutoNumCurrentFormula();
QString active_element_autonum = project_->elementCurrentAutoNum();
int el_index = ui->m_element_cb->findText(active_element_autonum);
ui->m_element_cb->setCurrentIndex(el_index);
//Folio
if (project_->defaultTitleBlockProperties().folio == "%autonum") {
QString page_autonum = project_->defaultTitleBlockProperties().auto_page_num;
int folio_index = ui->m_folio_cb->findText(page_autonum);
ui->m_folio_cb->setCurrentIndex(folio_index);
}
}
}
/**
* @brief AutoNumberingDockWidget::conductorAutoNumChanged
* Add new or remove conductor auto num from combobox
*/
void AutoNumberingDockWidget::conductorAutoNumChanged() {
ui->m_conductor_cb->clear();
//Conductor Combobox
ui->m_conductor_cb->addItem("");
QList <QString> keys_conductor = project_->conductorAutoNum().keys();
if (!keys_conductor.isEmpty()) {
foreach (QString str, keys_conductor) { ui->m_conductor_cb-> addItem(str); }
}
setActive();
}
/**
* @brief AutoNumberingDockWidget::on_m_conductor_cb_activated
* @param unused
* Set new conductor AutoNum
*/
void AutoNumberingDockWidget::on_m_conductor_cb_activated(int) {
QString current_autonum = ui->m_conductor_cb->currentText();
QString current_formula = project_->conductorAutoNumFormula(current_autonum);
if (current_autonum != "") {
project_->setConductorAutoNumCurrentFormula(current_formula, current_autonum);
}
else
project_->setConductorAutoNumCurrentFormula("","");
projectview_->currentDiagram()->diagram()->setConductorsAutonumName(current_autonum);
projectview_->currentDiagram()->diagram()->loadCndFolioSeq();
}
/**
* @brief AutoNumberingDockWidget::elementAutoNumChanged
* Add new or remove element auto num from combobox
*/
void AutoNumberingDockWidget::elementAutoNumChanged() {
ui->m_element_cb->clear();
//Element Combobox
ui->m_element_cb->addItem("");
QList <QString> keys_element = project_->elementAutoNum().keys();
if (!keys_element.isEmpty()) {
foreach (QString str, keys_element) {ui->m_element_cb -> addItem(str);}
}
setActive();
}
/**
* @brief AutoNumberingDockWidget::on_m_element_cb_activated
* @param unused
* Set new element AutoNum
*/
void AutoNumberingDockWidget::on_m_element_cb_activated(int) {
QString current_autonum = ui->m_element_cb->currentText();
QString current_formula = project_->elementAutoNumFormula(current_autonum);
if (current_autonum != "") {
project_->setElementAutoNumCurrentFormula(current_formula, current_autonum);
}
else
project_->setElementAutoNumCurrentFormula("","");
projectview_->currentDiagram()->diagram()->loadElmtFolioSeq();
}
/**
* @brief AutoNumberingDockWidget::folioAutoNumChanged
* Add new or remove folio auto num from combobox
*/
void AutoNumberingDockWidget::folioAutoNumChanged() {
ui->m_folio_cb->clear();
//Folio Combobox
ui->m_folio_cb->addItem("");
QList <QString> keys_folio = project_->folioAutoNum().keys();
if (!keys_folio.isEmpty()) {
foreach (QString str, keys_folio) { ui->m_folio_cb -> addItem(str);}
}
setActive();
}
/**
* @brief AutoNumberingDockWidget::on_m_folio_cb_activated
* @param unused
* Set new folio AutoNum
*/
void AutoNumberingDockWidget::on_m_folio_cb_activated(int) {
QString current_autonum = ui->m_folio_cb->currentText();
TitleBlockProperties ip = project_ -> defaultTitleBlockProperties();
if (current_autonum != "") {
ip.setAutoPageNum(current_autonum);
ip.folio = "%autonum";
project_->setDefaultTitleBlockProperties(ip);
}
else {
ip.folio = "%id/%total";
project_->setDefaultTitleBlockProperties(ip);
}
emit(folioAutoNumChanged(current_autonum));
}

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 AUTONUMBERINGDOCKWIDGET_H
#define AUTONUMBERINGDOCKWIDGET_H_H
#include "qetproject.h"
#include "projectview.h"
#include <QDockWidget>
namespace Ui {
class AutoNumberingDockWidget;
}
class AutoNumberingDockWidget : public QDockWidget
{
Q_OBJECT
public:
explicit AutoNumberingDockWidget(QWidget *parent = 0, QETProject *project = nullptr);
~AutoNumberingDockWidget();
void setContext();
void setProject(QETProject*, ProjectView*);
public slots:
void setActive();
void setConductorActive(DiagramView*);
private slots:
void on_m_conductor_cb_activated(int);
void on_m_element_cb_activated(int);
void on_m_folio_cb_activated(int);
void conductorAutoNumChanged();
void elementAutoNumChanged();
void folioAutoNumChanged();
void clear();
signals:
void folioAutoNumChanged(QString);
private:
Ui::AutoNumberingDockWidget *ui;
QETProject* project_;
ProjectView* projectview_;
};
#endif // AUTONUMBERINGDOCKWIDGET_H

View File

@@ -0,0 +1,94 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>AutoNumberingDockWidget</class>
<widget class="QDockWidget" name="AutoNumberingDockWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Autonumerotation Séléction</string>
</property>
<widget class="QWidget" name="dockWidgetContents">
<layout class="QVBoxLayout" name="verticalLayout">
<property name="sizeConstraint">
<enum>QLayout::SetMaximumSize</enum>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string/>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Element</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="m_element_cb"/>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="m_conductor_cb"/>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Conductor</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Folio</string>
</property>
</widget>
</item>
<item row="3" column="0">
<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="2" column="1">
<widget class="QComboBox" name="m_folio_cb"/>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</widget>
<resources/>
<connections/>
</ui>

View File

@@ -0,0 +1,213 @@
/*
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 "formulaautonumberingw.h"
#include "ui_formulaautonumberingw.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->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>650</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>630</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_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_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>Only Existent</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

@@ -0,0 +1,79 @@
/*
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 "autonumselectorwidget.h"
#include "ui_autonumselectorwidget.h"
/**
* @brief AutonumSelectorWidget::AutonumSelectorWidget
* Constructor with texts to fill the combo box
* @param items, items for fill the combo box
* @param parent, parent widget
*/
AutonumSelectorWidget::AutonumSelectorWidget(const QStringList &items, QWidget *parent) :
QWidget(parent),
ui(new Ui::AutonumSelectorWidget)
{
ui->setupUi(this);
ui -> m_available_autonum_cb -> addItems(items);
}
/**
* @brief AutonumSelectorWidget::~AutonumSelectorWidget
* Destructor
*/
AutonumSelectorWidget::~AutonumSelectorWidget() {
delete ui;
}
/**
* @brief AutonumSelectorWidget::setCurrentItem
* Set the combo box current index by text.
* If text doesn't exist, set current index -1
* @param item, item of index
*/
void AutonumSelectorWidget::setCurrentItem(const QString &item) {
ui -> m_available_autonum_cb -> setCurrentIndex( ui -> m_available_autonum_cb -> findText(item));
}
/**
* @brief AutonumSelectorWidget::setItems
* Populate this widget with the content of @items
* Previous items is clear.
* @param items
*/
void AutonumSelectorWidget::setItems(const QStringList &items) {
ui -> m_available_autonum_cb -> clear();
ui -> m_available_autonum_cb -> addItems(items);
}
/**
* @brief AutonumSelectorWidget::text
* @return the current displayed text
*/
QString AutonumSelectorWidget::text() const {
return ui -> m_available_autonum_cb -> currentText();
}
/**
* @brief AutonumSelectorWidget::on_m_edit_autonum_pb_clicked
* Just emit the signal openAutonumEditor.
* The owner of AutonumSelectorWidget need to connect the signal.
*/
void AutonumSelectorWidget::on_m_edit_autonum_pb_clicked() {
emit openAutonumEditor();
}

View File

@@ -0,0 +1,55 @@
/*
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 AUTONUMSELECTORWIDGET_H
#define AUTONUMSELECTORWIDGET_H
#include <QWidget>
namespace Ui {
class AutonumSelectorWidget;
}
/**
* @brief The AutonumSelectorWidget class
* This widget show a combobox to select an autonum and a button to edit the autonum
* The combo box is empty and the button isn't linked with anything, it's the role of caller
* of this class to fill the combo box and edit the connection with the button.
*/
class AutonumSelectorWidget : public QWidget
{
Q_OBJECT
public:
explicit AutonumSelectorWidget(const QStringList &items, QWidget *parent = 0);
~AutonumSelectorWidget();
void setCurrentItem (const QString &item);
void setItems (const QStringList &items);
QString text () const;
signals:
void openAutonumEditor ();
private slots:
void on_m_edit_autonum_pb_clicked();
private:
Ui::AutonumSelectorWidget *ui;
};
#endif // AUTONUMSELECTORWIDGET_H

View File

@@ -0,0 +1,66 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>AutonumSelectorWidget</class>
<widget class="QWidget" name="AutonumSelectorWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Autonumérotation :</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="m_available_autonum_cb"/>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="m_edit_autonum_pb">
<property name="enabled">
<bool>true</bool>
</property>
<property name="toolTip">
<string>éditer les numérotations</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../../qelectrotech.qrc">
<normaloff>:/ico/16x16/configure.png</normaloff>:/ico/16x16/configure.png</iconset>
</property>
</widget>
</item>
</layout>
</widget>
<resources>
<include location="../../qelectrotech.qrc"/>
</resources>
<connections/>
</ui>

View File

@@ -0,0 +1,113 @@
/*
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 "dialogautonum.h"
#include "ui_dialogautonum.h"
//#include "conductorautonumerotation.h"
#include "qetmessagebox.h"
#include "ui/selectautonumw.h"
/**
* @brief DialogAutoNum::DialogAutoNum
* @param dg
* @param parent
*/
DialogAutoNum::DialogAutoNum(Diagram *dg, QWidget *parent) :
QDialog(parent),
ui(new Ui::DialogAutoNum),
dg_ (dg)
{
ui -> setupUi(this);
ui -> configuration_layout -> addWidget (new SelectAutonumW());
dgselect_ = new diagramselection( dg_ -> project(), ui -> annotation_tab);
ui -> verticalLayout_Selection -> addWidget(dgselect_);
}
/**
* @brief Destructor
*/
DialogAutoNum::~DialogAutoNum(){
delete ui;
}
/**
* @brief DialogAutoNum::on_pushButton_delete_clicked
*/
void DialogAutoNum::on_pushButton_delete_clicked() {
// get list of diagrams selected
QList<Diagram *>listDiag = dgselect_ -> list_of_DiagramSelected();
if(listDiag.count()<=0) return;
QString diagramsTitle;
for(int i=0; i<listDiag.count(); i++){
diagramsTitle += listDiag.at(i) -> title();
if(i+1 < listDiag.count()) diagramsTitle += ", ";
}
// Ask if user is sure to delete the conductor numerotation
QMessageBox::StandardButton answer = QET::QetMessageBox::critical(
this,
tr("Suppression des annotations conducteurs", "Attention"),
QString(
tr("Voulez-vous vraiment supprimer les annotations conducteurs de :\n\n%1 ?")
).arg(diagramsTitle),
QMessageBox::Yes | QMessageBox::No,
QMessageBox::No
);
// if yes remove all
if( answer == QMessageBox::Yes) {
for(int i=0; i<listDiag.count(); i++){
/*ConductorAutoNumerotation can(listDiag.at(i));
can.removeNumOfDiagram();*/
}
}
}
/**
* @brief set the autonum to all diagram selected
*/
void DialogAutoNum::on_pushButton_annotation_clicked(){
// Get list of diagrams selected
QList<Diagram *>listDiag = dgselect_ -> list_of_DiagramSelected();
if(listDiag.count()<=0) return;
QString diagramsTitle;
for(int i=0; i<listDiag.count(); i++){
diagramsTitle += listDiag.at(i) -> title();
if(i+1 < listDiag.count()) diagramsTitle += ", ";
}
// Ask if user is sure to numerate the conductor
QET::QetMessageBox::warning(
this,
tr("Annotation des conducteurs", "Attention"),
QString(
tr("Voulez-vous vraiment annoter les conducteurs de :\n\n%1 ?")
).arg(diagramsTitle),
QMessageBox::Yes | QMessageBox::No,
QMessageBox::No
);
}
/**
* @brief Close the dialog
*/
void DialogAutoNum::on_pushButton_close_clicked() {
close();
}

View File

@@ -0,0 +1,49 @@
/*
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 DIALOGAUTONUM_H
#define DIALOGAUTONUM_H
#include <QDialog>
#include "diagram.h"
#include "ui/diagramselection.h"
namespace Ui {
class DialogAutoNum;
}
class DialogAutoNum : public QDialog
{
Q_OBJECT
public:
explicit DialogAutoNum(Diagram *dg, QWidget *parent = 0);
~DialogAutoNum();
private slots:
void on_pushButton_annotation_clicked();
void on_pushButton_delete_clicked();
void on_pushButton_close_clicked();
private:
Ui::DialogAutoNum *ui;
Diagram *dg_;
diagramselection *dgselect_;
};
#endif // DialogAutoNum_H

View File

@@ -0,0 +1,162 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DialogAutoNum</class>
<widget class="QDialog" name="DialogAutoNum">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>482</width>
<height>416</height>
</rect>
</property>
<property name="windowTitle">
<string>Annotation des schémas</string>
</property>
<property name="windowIcon">
<iconset resource="../../qelectrotech.qrc">
<normaloff>:/ico/oxygen-icons/32x32/apps/qelectrotech.png</normaloff>:/ico/oxygen-icons/32x32/apps/qelectrotech.png</iconset>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="configuration_tab">
<attribute name="title">
<string>Configuration</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_6">
<item>
<layout class="QVBoxLayout" name="configuration_layout">
<property name="spacing">
<number>0</number>
</property>
</layout>
</item>
</layout>
</widget>
<widget class="QWidget" name="annotation_tab">
<attribute name="title">
<string>Annotation</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QGroupBox" name="groupBox_Selection">
<property name="title">
<string>Sélection</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_">
<item>
<widget class="QRadioButton" name="radioButton_conductor">
<property name="text">
<string>Conducteurs</string>
</property>
<property name="icon">
<iconset resource="../../qelectrotech.qrc">
<normaloff>:/ico/22x22/conductor2.png</normaloff>:/ico/22x22/conductor2.png</iconset>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButton_component">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Composants</string>
</property>
<property name="icon">
<iconset resource="../../qelectrotech.qrc">
<normaloff>:/ico/22x22/single_page.png</normaloff>:/ico/22x22/single_page.png</iconset>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_Selection"/>
</item>
</layout>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QPushButton" name="pushButton_annotation">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Numérotée les folio sélectionné&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Annotation (alpha)</string>
</property>
<property name="icon">
<iconset resource="../../qelectrotech.qrc">
<normaloff>:/ico/16x16/edit-select-all.png</normaloff>:/ico/16x16/edit-select-all.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_delete">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Supprimé la numérotation des folio sélectionné&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Supprimer l'annotation</string>
</property>
<property name="icon">
<iconset resource="../../qelectrotech.qrc">
<normaloff>:/ico/16x16/edit-delete.png</normaloff>:/ico/16x16/edit-delete.png</iconset>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="pushButton_close">
<property name="text">
<string>Fermer</string>
</property>
<property name="default">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources>
<include location="../../qelectrotech.qrc"/>
</resources>
<connections/>
</ui>

View File

@@ -0,0 +1,216 @@
/*
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 "folioautonumbering.h"
#include "ui_folioautonumbering.h"
#include <QMessageBox>
#include <QPushButton>
#include <QtWidgets>
#include "qetproject.h"
#include "diagram.h"
/**
* Constructor
*/
FolioAutonumberingW::FolioAutonumberingW(QETProject *project, QWidget *parent) :
QWidget(parent),
project_(project),
ui(new Ui::FolioAutonumberingW)
{
ui->setupUi(this);
applyEnable(false);
ui->m_from_cb->setEnabled(false);
ui->m_new_tabs_sb->setEnabled(false);
ui->m_to_cb->setEnabled(false);
}
/**
* Destructor
*/
FolioAutonumberingW::~FolioAutonumberingW()
{
delete ui;
}
/**
* @brief FolioAutonumberingW::setContext
* construct autonums in the comboBox selected in the @autonum_chooser QcomboBox
*/
void FolioAutonumberingW::setContext(QList <QString> autonums) {
foreach (QString str, autonums) { ui->m_autonums_cb->addItem(str);}
}
/**
* @brief FolioAutonumberingW::autoNumSelected
* returns the current autonum selected
*/
QString FolioAutonumberingW::autoNumSelected(){
return ui->m_autonums_cb->currentText();
}
/**
* @brief FolioAutonumberingW::fromFolio
* returns the current "From Folio" index
*/
int FolioAutonumberingW::fromFolio(){
return ui->m_from_cb->currentIndex()-1;
}
/**
* @brief FolioAutonumberingW::toFolio
* returns the current "To Folio" index
*/
int FolioAutonumberingW::toFolio(){
return ui->m_to_cb->currentIndex()+this->fromFolio()+1;
}
/**
* @brief FolioAutonumberingW::newFoliosNumber
* returns the number of folios to create
*/
int FolioAutonumberingW::newFoliosNumber(){
return ui->m_new_tabs_sb->value();
}
/**
* @brief FolioAutonumberingW::updateFolioList
* update Folio List in From and To ComboBox
*/
void FolioAutonumberingW::updateFolioList(){
ui -> m_from_cb->clear();
ui -> m_to_cb->clear();
if (newFolios){
this -> on_m_create_new_tabs_rb_clicked();
} else {
this -> on_m_autonumber_tabs_rb_clicked();
}
}
/**
* @brief FolioAutonumberingW::on_m_create_new_tabs_rb_clicked
* Enable New Tabs SpinBox
*/
void FolioAutonumberingW::on_m_create_new_tabs_rb_clicked() {
ui->m_from_cb->setEnabled(false);
ui->m_to_cb->setEnabled(false);
ui->m_new_tabs_sb->setEnabled(true);
applyEnable();
newFolios = true;
}
/**
* @brief FolioAutonumberingW::on_m_autonumber_tabs_rb_clicked
* Enable From ComboBox, fill From ComboBox
*/
void FolioAutonumberingW::on_m_autonumber_tabs_rb_clicked() {
ui->m_new_tabs_sb->setEnabled(false);
ui->m_from_cb->setEnabled(true);
ui->m_to_cb->setEnabled(true);
if (ui->m_from_cb->count()<=0){
ui->m_from_cb->clear();
ui->m_from_cb->addItem("");
foreach (Diagram *diagram, project_->diagrams()){
ui->m_from_cb->addItem(diagram->title());
}
}
applyEnable();
newFolios = false;
}
/**
* @brief FolioAutonumberingW::on_m_new_tabs_sb_valueChanged
* Enable Apply if any new folio is to be created
*/
void FolioAutonumberingW::on_m_new_tabs_sb_valueChanged(int){
if (ui->m_new_tabs_sb->value()>0) applyEnable(true);
else applyEnable(false);
}
/**
* @brief FolioAutonumberingW::on_m_from_cb_currentIndexChanged
* Enable To ComboBox
*/
void FolioAutonumberingW::on_m_from_cb_currentIndexChanged(int){
int index = ui->m_from_cb->currentIndex();
ui->m_to_cb->clear();
if (index > 0){
ui->m_to_cb->setEnabled(true);
for (int i=index;i<project_->diagrams().size();i++)
ui->m_to_cb->addItem(project_->diagrams().at(i)->title());
applyEnable(true);
}
else{
applyEnable();
}
}
/**
* @brief SelectAutonumW::on_buttonBox_clicked
* Action on @buttonBox clicked
*/
void FolioAutonumberingW::on_buttonBox_clicked(QAbstractButton *button) {
//transform button to int
int answer = ui -> buttonBox -> buttonRole(button);
switch (answer) {
//help dialog - not implemented yet -
case QDialogButtonBox::HelpRole:
QMessageBox::information (this, tr("Folio Autonumbering", "title window"),
tr("C'est ici que vous pouvez définir la manière dont sera numéroté les nouveaux folios.\n"
"-Une numérotation est composée d'une variable minimum.\n"
"-Vous pouvez ajouter ou supprimer une variable de numérotation par le biais des boutons - et +.\n"
"-Une variable de numérotation comprant: un type, une valeur et une incrémentation.\n"
"\n-les types \"Chiffre 1\", \"Chiffre 01\" et \"Chiffre 001\", représente un type numérique définie dans le champs \"Valeur\", "
"qui s'incrémente à chaque nouveau folio de la valeur du champ \"Incrémentation\".\n"
"-\"Chiffre 01\" et \"Chiffre 001\", sont respectivement représenté sur le schéma par deux et trois digits minimum.\n"
"Si le chiffre définie dans le champs Valeur posséde moins de digits que le type choisit,"
"celui-ci sera précédé par un ou deux 0 afin de respecter son type.\n"
"\n-Le type \"Texte\", représente un texte fixe.\nLe champs \"Incrémentation\" n'est pas utilisé.\n",
"help dialog about the folio autonumerotation"
));
break;
case QDialogButtonBox::ApplyRole:
applyEnable(true);
emit applyPressed();
updateFolioList();
break;
}
}
/**
* @brief SelectAutonumW::applyEnable
* enable/disable the apply button
*/
void FolioAutonumberingW::applyEnable(bool b) {
if (b){
bool valid = true;
if (ui->m_create_new_tabs_rb->isChecked()){
if (ui->m_new_tabs_sb->value()==0) valid = false;
ui->buttonBox->button(QDialogButtonBox::Apply)->setEnabled(valid);
}
else{
if (ui->m_to_cb->currentText()=="") valid = false;
ui->buttonBox->button(QDialogButtonBox::Apply)->setEnabled(valid);
}
}
else{
ui -> buttonBox -> button(QDialogButtonBox::Apply) -> setEnabled(b);
}
}

View File

@@ -0,0 +1,72 @@
/*
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 FOLIOAUTONUMBERING_H
#define FOLIOAUTONUMBERING_H
#include <QWidget>
#include "numerotationcontext.h"
class NumPartEditorW;
class QAbstractButton;
class QETProject;
namespace Ui {
class FolioAutonumberingW;
}
class FolioAutonumberingW : public QWidget
{
Q_OBJECT
//METHODS
public:
explicit FolioAutonumberingW(QETProject *project, QWidget *parent = 0);
~FolioAutonumberingW();
void setContext (QList <QString> autonums);
NumerotationContext toNumContext() const;
QString autoNumSelected();
int newFoliosNumber();
bool newFolios;
int fromFolio();
int toFolio();
// SIGNALS
signals:
void applyPressed();
void m_autonumber_tabs_rb_clicked();
//SLOTS
private slots:
void on_m_create_new_tabs_rb_clicked();
void on_m_autonumber_tabs_rb_clicked();
void on_m_new_tabs_sb_valueChanged(int);
void on_buttonBox_clicked(QAbstractButton *);
void on_m_from_cb_currentIndexChanged(int);
void applyEnable (bool = true);
//ATTRIBUTES
private:
QETProject *project_;
Ui::FolioAutonumberingW *ui;
QList <NumPartEditorW *> num_part_list_;
NumerotationContext m_context;
void updateFolioList();
};
#endif // FOLIOAUTONUMBERING_H

View File

@@ -0,0 +1,295 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>FolioAutonumberingW</class>
<widget class="QWidget" name="FolioAutonumberingW">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>524</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>504</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="2" column="1" colspan="2">
<widget class="QGroupBox" name="Options">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string> Options de numérotation</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="2" column="1">
<widget class="QComboBox" name="m_to_cb">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="sizeAdjustPolicy">
<enum>QComboBox::AdjustToContents</enum>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Nouveaux Folios</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="m_from_cb">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="sizeAdjustPolicy">
<enum>QComboBox::AdjustToContents</enum>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QSpinBox" name="m_new_tabs_sb">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximum">
<number>999</number>
</property>
<property name="displayIntegerBase">
<number>10</number>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_4">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>À</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_3">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>De</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="1" column="1" colspan="2">
<widget class="QGroupBox" name="Select">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Sélection:</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QRadioButton" name="m_create_new_tabs_rb">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Créer de nouveaux Folios</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="m_autonumber_tabs_rb">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>NumAuto des folios séléctionnés</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<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="text">
<string>Numérotation automatique de Folio :</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QComboBox" name="m_autonums_cb">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="sizeAdjustPolicy">
<enum>QComboBox::AdjustToContents</enum>
</property>
</widget>
</item>
<item row="3" column="1" colspan="2">
<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>
</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</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@@ -0,0 +1,74 @@
/*
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 "formulaautonumberingw.h"
#include "ui_formulaautonumberingw.h"
#include <QMessageBox>
#include <QPushButton>
#include <QtWidgets>
/**
* Constructor
*/
FormulaAutonumberingW::FormulaAutonumberingW(QWidget *parent) :
QWidget(parent),
ui(new Ui::FormulaAutonumberingW)
{
ui->setupUi(this);
setContext(formula_);
}
/**
* Destructor
*/
FormulaAutonumberingW::~FormulaAutonumberingW()
{
delete ui;
}
/**
* @brief FormulaAutonumberingW::setContext
* @param formula to be inserted into context
*/
void FormulaAutonumberingW::setContext(QString formula) {
ui->m_formula_le->insert(formula);
}
/**
* @brief FormulaAutonumberingW::clearContext
* @param clear formula line edit text
*/
void FormulaAutonumberingW::clearContext() {
ui->m_formula_le->clear();
}
/**
* @brief FormulaAutonumberingW::formula
* @return formula to be stored into project
*/
QString FormulaAutonumberingW::formula() {
return ui->m_formula_le->text();
}
/**
* @brief FormulaAutonumberingW::on_m_formula_le_textChanged
* Update Apply Button
*/
void FormulaAutonumberingW::on_m_formula_le_textChanged(QString text) {
emit (textChanged(text));
}

View File

@@ -0,0 +1,65 @@
/*
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 FORMULAAUTONUMBERINGW_H
#define FORMULAAUTONUMBERINGW_H
#include <QWidget>
class QAbstractButton;
namespace Ui {
class FormulaAutonumberingW;
}
/**
This class implements the element autonumbering widget.
It loads the current formula applied to new elements and allows
the user to overwrite it with a new formula. Formula is added
while parsing label in customelement.cpp
*/
class FormulaAutonumberingW : public QWidget
{
Q_OBJECT
//METHODS
public:
explicit FormulaAutonumberingW(QWidget *parent = 0);
~FormulaAutonumberingW();
QString formula();
void setContext(QString);
void clearContext();
Ui::FormulaAutonumberingW *ui;
private:
// SIGNALS
signals:
void applyPressed();
void textChanged(QString);
//SLOTS
private slots:
void on_m_formula_le_textChanged(QString);
//ATTRIBUTES
private:
QString formula_;
};
#endif // FORMULAAUTONUMBERINGW_H

View File

@@ -0,0 +1,115 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>FormulaAutonumberingW</class>
<widget class="QWidget" name="FormulaAutonumberingW">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>370</width>
<height>305</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">
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<item>
<widget class="QGroupBox" name="groupBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Auto Naming Pattern:</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="1">
<widget class="QLineEdit" name="m_formula_le">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="inputMask">
<string notr="true"/>
</property>
<property name="text">
<string notr="true"/>
</property>
<property name="placeholderText">
<string>Insert Formula Here e.g.: %prefix%l%c</string>
</property>
</widget>
</item>
<item row="0" column="0">
<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>Formula:</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QLabel" name="label">
<property name="locale">
<locale language="French" country="France"/>
</property>
<property name="text">
<string>You can use the following variables to your formula:
-%prefix: Default Element Prefix
-%l: Element Line
-%c: Element Column
-%F: Folio Name
-%f or %id: Folio ID
-%total: Total of folios
You can also assign any other titleblock variable
that you create. Text and number inputs are
also available.</string>
</property>
</widget>
</item>
<item>
<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>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@@ -0,0 +1,318 @@
/*
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 <QRegExp>
#include "numparteditorw.h"
#include "ui_numparteditorw.h"
/**
* Constructor
*/
NumPartEditorW::NumPartEditorW(QWidget *parent) :
QWidget(parent),
ui(new Ui::NumPartEditorW),
intValidator (new QIntValidator(0,99999,this))
{
ui -> setupUi(this);
setVisibleItems();
setType(NumPartEditorW::unit, true);
}
/**
* Constructor
* Build with value of @context at position i
*/
NumPartEditorW::NumPartEditorW (NumerotationContext &context, int i, QWidget *parent):
QWidget(parent),
ui(new Ui::NumPartEditorW),
intValidator (new QIntValidator(0,99999,this))
{
ui -> setupUi(this);
setVisibleItems();
if(context.size()==0) setType(NumPartEditorW::unit, true);
else {
QStringList strl = context.itemAt(i);
if (strl.at(0)=="unit") setType(NumPartEditorW::unit, true);
else if (strl.at(0)=="unitfolio") setType(NumPartEditorW::unitfolio, true);
else if (strl.at(0)=="ten") setType(NumPartEditorW::ten, true);
else if (strl.at(0)=="tenfolio") setType(NumPartEditorW::tenfolio, true);
else if (strl.at(0)=="hundred") setType(NumPartEditorW::hundred, true);
else if (strl.at(0)=="hundredfolio") setType(NumPartEditorW::hundredfolio, true);
else if (strl.at(0)=="string") setType(NumPartEditorW::string);
else if (strl.at(0)=="idfolio") setType(NumPartEditorW::idfolio);
else if (strl.at(0)=="folio") setType(NumPartEditorW::folio);
else if (strl.at(0)=="machine") setType(NumPartEditorW::machine);
else if (strl.at(0)=="locmach") setType(NumPartEditorW::locmach);
else if (strl.at(0)=="elementline") setType(NumPartEditorW::elementline);
else if (strl.at(0)=="elementcolumn") setType(NumPartEditorW::elementcolumn);
else if (strl.at(0)=="elementprefix") setType(NumPartEditorW::elementprefix);
ui -> value_field -> setText(strl.at(1));
ui -> increase_spinBox -> setValue(strl.at(2).toInt());
}
}
/**
* Destructor
*/
NumPartEditorW::~NumPartEditorW()
{
delete intValidator;
delete ui;
}
void NumPartEditorW::setVisibleItems() {
ui->type_cb->setInsertPolicy(QComboBox::InsertAtBottom);
QStringList items;
if (parentWidget()->parentWidget()->objectName()=="FolioTab") {
items << tr("Chiffre 1") << tr("Chiffre 01")
<< tr("Chiffre 001")
<< tr("Texte");
}
else if (parentWidget()->parentWidget()->objectName()=="ConductorTab") {
items << tr("Chiffre 1") << tr("Chiffre 1 - Folio") << tr("Chiffre 01")
<< tr("Chiffre 01 - Folio") << tr("Chiffre 001") << tr("Chiffre 001 - Folio")
<< tr("Texte") << tr("N° folio") << tr("Folio") << tr("Machine") << tr("Locmach");
}
else
items << tr("Chiffre 1") << tr("Chiffre 1 - Folio") << tr("Chiffre 01")
<< tr("Chiffre 01 - Folio") << tr("Chiffre 001") << tr("Chiffre 001 - Folio")
<< tr("Texte") << tr("N° folio") << tr("Folio") << tr("Machine") << tr("Locmach")
<< tr("Element Line") << tr("Element Column") << tr("Element Prefix");
ui->type_cb->insertItems(0,items);
}
/**
* @brief NumPartEditorW::toNumContext
* @return the display to NumerotationContext
*/
NumerotationContext NumPartEditorW::toNumContext() {
NumerotationContext nc;
QString type_str;
switch (type_) {
case unit:
type_str = "unit";
break;
case unitfolio:
type_str = "unitfolio";
break;
case ten:
type_str = "ten";
break;
case tenfolio:
type_str = "tenfolio";
break;
case hundred:
type_str = "hundred";
break;
case hundredfolio:
type_str = "hundredfolio";
break;
case string:
type_str = "string";
break;
case idfolio:
type_str = "idfolio";
break;
case folio:
type_str = "folio";
break;
case machine:
type_str = "machine";
break;
case locmach:
type_str = "locmach";
break;
case elementline:
type_str = "elementline";
break;
case elementcolumn:
type_str = "elementcolumn";
break;
case elementprefix:
type_str = "elementprefix";
break;
}
if (type_str == "unitfolio" || type_str == "tenfolio" || type_str == "hundredfolio")
nc.addValue(type_str, ui -> value_field -> displayText(), ui -> increase_spinBox -> value(), ui->value_field->displayText().toInt());
else
nc.addValue(type_str, ui -> value_field -> displayText(), ui -> increase_spinBox -> value());
return nc;
}
/**
* @brief NumPartEditorW::isValid
* @return true if value field isn't empty or if type is folio
*/
bool NumPartEditorW::isValid() {
if (type_ == folio || type_ == idfolio || type_ == elementline || type_ == machine || type_ == locmach ||
type_ == elementcolumn || type_ == elementprefix) {return true;}
else if(ui -> value_field -> text().isEmpty()) {return false;}
else return true;
}
/**
* @brief NumPartEditorW::on_type_cb_activated
* Action when user change the type comboBox
*/
void NumPartEditorW::on_type_cb_activated(int) {
if (ui->type_cb->currentText() == tr("Chiffre 1"))
setType(unit);
else if (ui->type_cb->currentText() == tr("Chiffre 1 - Folio"))
setType(unitfolio);
else if (ui->type_cb->currentText() == tr("Chiffre 01"))
setType(ten);
else if (ui->type_cb->currentText() == tr("Chiffre 01 - Folio"))
setType(tenfolio);
else if (ui->type_cb->currentText() == tr("Chiffre 001"))
setType(hundred);
else if (ui->type_cb->currentText() == tr("Chiffre 001 - Folio"))
setType(hundredfolio);
else if (ui->type_cb->currentText() == tr("Texte"))
setType(string);
else if (ui->type_cb->currentText() == tr("N° folio"))
setType(idfolio);
else if (ui->type_cb->currentText() == tr("Folio"))
setType(folio);
else if (ui->type_cb->currentText() == tr("Machine"))
setType(machine);
else if (ui->type_cb->currentText() == tr("Locmach"))
setType(locmach);
else if (ui->type_cb->currentText() == tr("Element Line"))
setType(elementline);
else if (ui->type_cb->currentText() == tr("Element Column"))
setType(elementcolumn);
else if (ui->type_cb->currentText() == tr("Element Prefix"))
setType(elementprefix);
emit changed();
}
/**
* @brief NumPartEditorW::on_value_field_textChanged
* emit changed when @value_field text changed
*/
void NumPartEditorW::on_value_field_textEdited() {
emit changed();
}
/**
* @brief NumPartEditorW::on_increase_spinBox_valueChanged
* emit changed when @increase_spinBox value changed
*/
void NumPartEditorW::on_increase_spinBox_valueChanged(int) {
if (!ui -> value_field -> text().isEmpty()) emit changed();
}
/**
* @brief NumPartEditorW::setType
* Set good behavior by type @t
* @param t, type used
* @param fnum, force the behavior of numeric type
*/
void NumPartEditorW::setType(NumPartEditorW::type t, bool fnum) {
setCurrentIndex(t);
//if @t is a numeric type and preview type @type_ isn't a numeric type
//or @fnum is true, we set numeric behavior
if ( ((t==unit || t==unitfolio || t==ten || t==tenfolio || t==hundred || t==hundredfolio) &&
(type_==string || type_==folio || type_==machine || type_==locmach ||type_==idfolio ||
type_==elementcolumn || type_==elementline || type_==elementprefix))
|| fnum) {
ui -> value_field -> clear();
ui -> value_field -> setEnabled(true);
ui -> value_field -> setValidator(intValidator);
ui -> increase_spinBox -> setEnabled(true);
ui -> increase_spinBox -> setValue(1);
}
//@t isn't a numeric type
else if (t == string || t == folio || t == idfolio || t == elementline || t == machine || t == locmach ||
t == elementcolumn || t == elementprefix) {
ui -> value_field -> clear();
ui -> increase_spinBox -> setDisabled(true);
if (t==string) {
ui -> value_field -> setValidator(0);
ui -> value_field -> setEnabled(true);
}
else if (t==folio) {
ui -> value_field -> setDisabled(true);
ui -> increase_spinBox -> setDisabled(true);
}
else if (t==machine) {
ui -> value_field -> setDisabled(true);
ui -> increase_spinBox -> setDisabled(true);
}
else if (t==locmach) {
ui -> value_field -> setDisabled(true);
ui -> increase_spinBox -> setDisabled(true);
}
else if (t==idfolio) {
ui -> value_field -> setDisabled(true);
ui -> increase_spinBox -> setDisabled(true);
}
else if (t==elementcolumn) {
ui -> value_field -> setDisabled(true);
ui -> increase_spinBox -> setDisabled(true);
}
else if (t==elementline) {
ui -> value_field -> setDisabled(true);
ui -> increase_spinBox -> setDisabled(true);
}
else if (t==elementprefix) {
ui -> value_field -> setDisabled(true);
ui -> increase_spinBox -> setDisabled(true);
}
}
type_= t;
}
/**
* @brief NumPartEditorW::setCurrentIndex
* Set Current Index of type_cb
* @param t, type used
*/
void NumPartEditorW::setCurrentIndex(NumPartEditorW::type t) {
int i;
if (t == unit)
i = ui->type_cb->findText(tr("Chiffre 1"));
else if (t == unitfolio)
i = ui->type_cb->findText(tr("Chiffre 1 - Folio"));
else if (t == ten)
i = ui->type_cb->findText(tr("Chiffre 01"));
else if (t == tenfolio)
i = ui->type_cb->findText(tr("Chiffre 01 - Folio"));
else if (t == hundred)
i = ui->type_cb->findText(tr("Chiffre 001"));
else if (t == hundredfolio)
i = ui->type_cb->findText(tr("Chiffre 001 - Folio"));
else if (t == string)
i = ui->type_cb->findText(tr("Texte"));
else if (t == idfolio)
i = ui->type_cb->findText(tr("N° folio"));
else if (t == folio)
i = ui->type_cb->findText(tr("Folio"));
else if (t == machine)
i = ui->type_cb->findText(tr("Machine"));
else if (t == locmach)
i = ui->type_cb->findText(tr("Locmach"));
else if (t == elementline)
i = ui->type_cb->findText(tr("Element Line"));
else if (t == elementcolumn)
i = ui->type_cb->findText(tr("Element Column"));
else if (t == elementprefix)
i = ui->type_cb->findText(tr("Element Prefix"));
ui->type_cb->setCurrentIndex(i);
}

View File

@@ -0,0 +1,73 @@
/*
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 NUMPARTEDITORW_H
#define NUMPARTEDITORW_H
#include <QWidget>
#include <QValidator>
#include "numerotationcontext.h"
/**
*This class represent a single part num widget. By this widget, we can define and edit
*how the num auto must work .
*This widget is called by selectautonumw.
*/
namespace Ui {
class NumPartEditorW;
}
class NumPartEditorW : public QWidget
{
Q_OBJECT
//METHODS
public:
explicit NumPartEditorW(QWidget *parent = 0);
NumPartEditorW (NumerotationContext &, int, QWidget *parent=0);
~NumPartEditorW();
enum type {unit,unitfolio,ten,tenfolio, hundred, hundredfolio,
string,idfolio,folio,machine,locmach,
elementline,elementcolumn,elementprefix,
};
NumerotationContext toNumContext();
bool isValid ();
type type_;
private:
void setVisibleItems();
void disableItem(int index);
void setCurrentIndex(NumPartEditorW::type);
private slots:
void on_type_cb_activated(int);
void on_value_field_textEdited();
void on_increase_spinBox_valueChanged(int);
void setType (NumPartEditorW::type t, bool=false);
signals:
void changed ();
private:
Ui::NumPartEditorW *ui;
QValidator *intValidator;
};
#endif // NUMPARTEDITORW_H

View File

@@ -0,0 +1,96 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>NumPartEditorW</class>
<widget class="QWidget" name="NumPartEditorW">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>368</width>
<height>33</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="spacing">
<number>3</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>2</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>2</number>
</property>
<item>
<widget class="QComboBox" name="type_cb">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="editable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="value_field">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="increase_spinBox">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="wrapping">
<bool>false</bool>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="specialValueText">
<string/>
</property>
<property name="accelerated">
<bool>true</bool>
</property>
<property name="prefix">
<string/>
</property>
<property name="minimum">
<number>1</number>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@@ -0,0 +1,334 @@
/*
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 "selectautonumw.h"
#include "ui_selectautonumw.h"
#include "numparteditorw.h"
#include <QMessageBox>
#include "numerotationcontextcommands.h"
#include "formulaautonumberingw.h"
#include "ui_formulaautonumberingw.h"
#include "qdebug.h"
/**
* Constructor
*/
SelectAutonumW::SelectAutonumW(QWidget *parent) :
QWidget(parent),
ui(new Ui::SelectAutonumW)
{
ui->setupUi(this);
if (this->parentWidget() -> objectName()=="ElementTab"){
m_feaw = new FormulaAutonumberingW();
ui->scrollAreaWidgetContents->layout()->addWidget(m_feaw);
}
else if (this->parentWidget() -> objectName()=="ConductorTab"){
m_fcaw = new FormulaAutonumberingW();
m_fcaw->ui->label->setHidden(true);
ui->scrollAreaWidgetContents->layout()->addWidget(m_fcaw);
}
setContext(NumerotationContext());
}
SelectAutonumW::SelectAutonumW(const NumerotationContext &context, QWidget *parent) :
QWidget(parent),
ui(new Ui::SelectAutonumW)
{
if (this->parentWidget() -> objectName()=="ElementTab"){
m_feaw = new FormulaAutonumberingW();
ui->scrollAreaWidgetContents->layout()->addWidget(m_feaw);
}
else if (this->parentWidget() -> objectName()=="ConductorTab"){
m_fcaw = new FormulaAutonumberingW();
m_fcaw->ui->label->setHidden(true);
ui->scrollAreaWidgetContents->layout()->addWidget(m_fcaw);
}
ui->setupUi(this);
setContext(context);
}
/**
* Destructor
*/
SelectAutonumW::~SelectAutonumW()
{
delete ui;
}
/**
* @brief SelectAutonumW::setCurrentContext
* build the context of current diagram selected in the @diagram_chooser QcomboBox
*/
void SelectAutonumW::setContext(const NumerotationContext &context) {
m_context = context;
qDeleteAll(num_part_list_);
num_part_list_.clear();
if (m_context.size() == 0) { //@context contain nothing, build a default numPartEditor
on_add_button_clicked();
}
else {
for (int i=0; i<m_context.size(); ++i) { //build with the content of @context
NumPartEditorW *part= new NumPartEditorW(m_context, i, this);
connect (part, SIGNAL(changed()), this, SLOT(applyEnable()));
num_part_list_ << part;
ui -> editor_layout -> addWidget(part);
}
}
num_part_list_.size() == 1 ?
ui -> remove_button -> setDisabled(true):
ui -> remove_button -> setEnabled (true);
applyEnable(false);
}
/**
* @brief SelectAutonumW::toNumContext
* @return the content to @num_part_list to NumerotationContext
*/
NumerotationContext SelectAutonumW::toNumContext() const {
NumerotationContext nc;
foreach (NumPartEditorW *npew, num_part_list_) nc << npew -> toNumContext();
return nc;
}
/**
* @brief SelectAutonumW::on_add_button_clicked
* Action on add_button, add a @NumPartEditor
*/
void SelectAutonumW::on_add_button_clicked() {
applyEnable(false);
NumPartEditorW *part = new NumPartEditorW(this);
connect (part, SIGNAL(changed()), this, SLOT(applyEnable()));
num_part_list_ << part;
ui -> editor_layout -> addWidget(part);
ui -> remove_button -> setEnabled(true);
}
/**
* @brief SelectAutonumW::on_remove_button_clicked
* Action on remove button, remove the last @NumPartEditor
*/
void SelectAutonumW::on_remove_button_clicked() {
//remove if @num_part_list contains more than one item
if (num_part_list_.size() > 1) {
NumPartEditorW *part = num_part_list_.takeLast();
disconnect(part, SIGNAL(changed()), this, SLOT(applyEnable()));
delete part;
if (num_part_list_.size() == 1) {
ui -> remove_button -> setDisabled(true);
}
}
applyEnable();
}
/**
* @brief SelectAutonumW::formula
* @return autonumbering widget formula
*/
QString SelectAutonumW::formula() {
if (this->parentWidget() -> objectName()=="ElementTab")
return m_feaw->formula();
else if (this->parentWidget() ->objectName()=="ConductorTab")
return m_fcaw->formula();
else return "";
}
/**
* @brief SelectAutonumW::on_buttonBox_clicked
* Action on @buttonBox clicked
*/
void SelectAutonumW::on_buttonBox_clicked(QAbstractButton *button) {
//transform button to int
int answer = ui -> buttonBox -> buttonRole(button);
switch (answer) {
//Reset the curent context
case QDialogButtonBox::ResetRole:
setContext(m_context);
break;
//help dialog
case QDialogButtonBox::HelpRole:
if (this->parentWidget() -> objectName()=="FolioTab"){
QMessageBox::information (this, tr("Folio Autonumérotation", "title window"),
tr("C'est ici que vous pouvez définir la manière dont sera numéroté les nouveaux folios.\n"
"-Une numérotation est composée d'une variable minimum.\n"
"-Vous pouvez ajouter ou supprimer une variable de numérotation par le biais des boutons - et +.\n"
"-Une variable de numérotation comprant: un type, une valeur et une incrémentation.\n"
"\n-les types \"Chiffre 1\", \"Chiffre 01\" et \"Chiffre 001\", représente un type numérique définie dans le champs \"Valeur\", "
"qui s'incrémente à chaque nouveau folio de la valeur du champ \"Incrémentation\".\n"
"-\"Chiffre 01\" et \"Chiffre 001\", sont respectivement représenté sur le schéma par deux et trois digits minimum.\n"
"Si le chiffre définie dans le champs Valeur posséde moins de digits que le type choisit,"
"celui-ci sera précédé par un ou deux 0 afin de respecter son type.\n"
"\n-Le type \"Texte\", représente un texte fixe.\nLe champs \"Incrémentation\" n'est pas utilisé.\n",
"help dialog about the folio autonumerotation"
));
break;
}
else{
QMessageBox::information (this, tr("Conducteur Autonumérotation", "title window"),
tr("C'est ici que vous pouvez définir la manière dont sera numéroté les nouveaux conducteurs.\n"
"-Une numérotation est composée d'une variable minimum.\n"
"-Vous pouvez ajouter ou supprimer une variable de numérotation par le biais des boutons - et +.\n"
"-Une variable de numérotation comprant: un type, une valeur et une incrémentation.\n"
"\n-les types \"Chiffre 1\", \"Chiffre 01\" et \"Chiffre 001\", représente un type numérique définie dans le champs \"Valeur\", "
"qui s'incrémente à chaque nouveau conducteur de la valeur du champ \"Incrémentation\".\n"
"-\"Chiffre 01\" et \"Chiffre 001\", sont respectivement représenté sur le schéma par deux et trois digits minimum.\n"
"Si le chiffre définie dans le champs Valeur posséde moins de digits que le type choisit,"
"celui-ci sera précédé par un ou deux 0 afin de respecter son type.\n"
"\n-Le type \"Texte\", représente un texte fixe.\nLe champs \"Incrémentation\" n'est pas utilisé.\n"
"\n-Le type \"N° folio\" représente le n° du folio en cours.\nLes autres champs ne sont pas utilisés.\n"
"\n-Le type \"Folio\" représente le nom du folio en cours.\nLes autres champs ne sont pas utilisés.",
"help dialog about the conductor autonumerotation"
));
break;
}
//apply the context in the diagram displayed by @diagram_chooser.
case QDialogButtonBox::ApplyRole:
applyEnable(false);
emit applyPressed();
break;
};
}
/**
* @brief SelectAutonumW::applyEnableOnContextChanged
* enable/disable the apply button after changing the autonum name
*/
void SelectAutonumW::applyEnableOnContextChanged(QString) {
applyEnable(true);
}
/**
* @brief SelectAutonumW::applyEnable
* enable/disable the apply button
*/
void SelectAutonumW::applyEnable(bool b) {
if (b){
bool valid= true;
foreach (NumPartEditorW *npe, num_part_list_) if (!npe -> isValid()) valid= false;
ui -> buttonBox -> button(QDialogButtonBox::Apply) -> setEnabled(valid);
}
else {
ui -> buttonBox -> button(QDialogButtonBox::Apply) -> setEnabled(b);
}
if (this->parentWidget() -> objectName()=="ElementTab")
contextToFormula();
if (this->parentWidget()->objectName()=="ConductorTab")
contextToFormula();
}
/**
* @brief SelectAutonumW::contextToFormula
* Apply formula to ElementAutonumbering Widget
*/
void SelectAutonumW::contextToFormula() {
FormulaAutonumberingW* m_faw;
if (this->parentWidget() -> objectName()=="ElementTab")
m_faw = m_feaw;
if (this->parentWidget()->objectName()=="ConductorTab")
m_faw = m_fcaw;
m_faw->clearContext();
int count_unit = 0;
int count_unitf = 0;
int count_ten = 0;
int count_tenf = 0;
int count_hundred = 0;
int count_hundredf = 0;
foreach (NumPartEditorW *npe, num_part_list_) {
if (npe->isValid()) {
if (npe->type_ == NumPartEditorW::idfolio) {
m_faw->setContext("%id");
}
else if (npe->type_ == NumPartEditorW::folio) {
m_faw->setContext("%F");
}
else if (npe->type_ == NumPartEditorW::machine) {
m_faw->setContext("%M");
}
else if (npe->type_ == NumPartEditorW::locmach) {
m_faw->setContext("%LM");
}
else if (npe->type_ == NumPartEditorW::elementcolumn) {
m_faw->setContext("%c");
}
else if (npe->type_ == NumPartEditorW::elementline) {
m_faw->setContext("%l");
}
else if (npe->type_ == NumPartEditorW::elementprefix) {
m_faw->setContext("%prefix");
}
else if (npe->type_ == NumPartEditorW::string) {
m_faw->setContext(npe->toNumContext().itemAt(0).at(1));
}
else if (npe->type_ == NumPartEditorW::unit) {
count_unit++;
m_faw->setContext("%sequ_"+QString::number(count_unit));
}
else if (npe->type_ == NumPartEditorW::unitfolio) {
count_unitf++;
m_faw->setContext("%sequf_"+QString::number(count_unitf));
}
else if (npe->type_ == NumPartEditorW::ten) {
count_ten++;
m_faw->setContext("%seqt_"+QString::number(count_ten));
}
else if (npe->type_ == NumPartEditorW::tenfolio) {
count_tenf++;
m_faw->setContext("%seqtf_"+QString::number(count_tenf));
}
else if (npe->type_ == NumPartEditorW::hundred) {
count_hundred++;
m_faw->setContext("%seqh_"+QString::number(count_hundred));
}
else if (npe->type_ == NumPartEditorW::hundredfolio) {
count_hundredf++;
m_faw->setContext("%seqhf_"+QString::number(count_hundredf));
}
}
}
}
/**
* @brief SelectAutonumW::on_m_next_pb_clicked
* Increase NumerotationContext
*/
void SelectAutonumW::on_m_next_pb_clicked() {
NumerotationContextCommands ncc (toNumContext());
setContext(ncc.next());
applyEnable(true);
}
/**
* @brief SelectAutonumW::on_m_previous_pb_clicked
* Decrease NumerotationContext
*/
void SelectAutonumW::on_m_previous_pb_clicked() {
NumerotationContextCommands ncc (toNumContext());
setContext(ncc.previous());
applyEnable(true);
}

View File

@@ -0,0 +1,73 @@
/*
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 SELECTAUTONUMW_H
#define SELECTAUTONUMW_H
#include <QWidget>
#include "numerotationcontext.h"
#include "formulaautonumberingw.h"
class NumPartEditorW;
class QAbstractButton;
class FormulaAutonumberingW;
namespace Ui {
class SelectAutonumW;
}
class SelectAutonumW : public QWidget
{
Q_OBJECT
//METHODS
public:
explicit SelectAutonumW(QWidget *parent = 0);
explicit SelectAutonumW(const NumerotationContext &context, QWidget *parent = 0);
~SelectAutonumW();
void setContext (const NumerotationContext &context);
NumerotationContext toNumContext() const;
void contextToFormula ();
QString formula();
signals:
void applyPressed();
//SLOT
public slots:
void applyEnableOnContextChanged(QString);
private slots:
void on_add_button_clicked();
void on_remove_button_clicked();
void on_buttonBox_clicked(QAbstractButton *);
void applyEnable (bool = true);
//ATTRIBUTES
void on_m_next_pb_clicked();
void on_m_previous_pb_clicked();
private:
Ui::SelectAutonumW *ui;
QList <NumPartEditorW *> num_part_list_;
NumerotationContext m_context;
FormulaAutonumberingW *m_feaw;
FormulaAutonumberingW *m_fcaw;
};
#endif // SELECTAUTONUMW_H

View File

@@ -0,0 +1,303 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>SelectAutonumW</class>
<widget class="QWidget" name="SelectAutonumW">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>418</width>
<height>508</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QScrollArea" name="scrollArea">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>400</width>
<height>455</height>
</size>
</property>
<property name="sizeIncrement">
<size>
<width>0</width>
<height>0</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::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>453</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>400</width>
<height>450</height>
</size>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="sizeConstraint">
<enum>QLayout::SetFixedSize</enum>
</property>
<item>
<widget class="QGroupBox" name="definition_groupe">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Définition</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<property name="sizeConstraint">
<enum>QLayout::SetFixedSize</enum>
</property>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="remove_button">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Supprimer une variable de numérotation&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../../qelectrotech.qrc">
<normaloff>:/ico/22x22/list-remove.png</normaloff>:/ico/22x22/list-remove.png</iconset>
</property>
<property name="flat">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="add_button">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Ajouter une variable de numérotation&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../../qelectrotech.qrc">
<normaloff>:/ico/22x22/list-add.png</normaloff>:/ico/22x22/list-add.png</iconset>
</property>
<property name="flat">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="m_previous_pb">
<property name="toolTip">
<string>Précédent</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../../qelectrotech.qrc">
<normaloff>:/ico/16x16/arrow-left.png</normaloff>:/ico/16x16/arrow-left.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="m_next_pb">
<property name="toolTip">
<string>Suivant</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../../qelectrotech.qrc">
<normaloff>:/ico/16x16/arrow-right.png</normaloff>:/ico/16x16/arrow-right.png</iconset>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="editor_layout" stretch="0">
<property name="spacing">
<number>0</number>
</property>
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<item>
<layout class="QHBoxLayout" name="label_layout" stretch="0,0,0">
<property name="spacing">
<number>0</number>
</property>
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<item>
<widget class="QLabel" name="type_label">
<property name="text">
<string>Type</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="value_label">
<property name="text">
<string>Valeur</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="increase_label">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Incrémentation</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::MinimumExpanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Apply|QDialogButtonBox::Help|QDialogButtonBox::Reset</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources>
<include location="../../qelectrotech.qrc"/>
</resources>
<connections/>
</ui>