mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-01-09 07:09:59 +01:00
Element autonumbering. New tab inside autonumbering menu to assign formulas to element label. XML containing elements labels according ISO/IEC 81346 (./elements/10_electric/qet_labels.xml
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@4563 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
92
sources/ui/elementautonumberingw.cpp
Normal file
92
sources/ui/elementautonumberingw.cpp
Normal file
@@ -0,0 +1,92 @@
|
||||
/*
|
||||
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 "elementautonumberingw.h"
|
||||
#include "ui_elementautonumberingw.h"
|
||||
#include <QMessageBox>
|
||||
#include <QPushButton>
|
||||
#include <QtWidgets>
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
ElementAutonumberingW::ElementAutonumberingW(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::ElementAutonumberingW)
|
||||
|
||||
{
|
||||
ui->setupUi(this);
|
||||
applyEnable(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
ElementAutonumberingW::~ElementAutonumberingW()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief ElementAutonumberingW::setContext
|
||||
* @param formula to be inserted into context
|
||||
*/
|
||||
void ElementAutonumberingW::setContext(QString formula) {
|
||||
ui->m_formula_le->insert(formula);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief ElementAutonumberingW::formula
|
||||
* @return formula to be stored into project
|
||||
*/
|
||||
QString ElementAutonumberingW::formula() {
|
||||
return ui->m_formula_le->text();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief ElementAutonumberingW::on_m_formula_le_textChanged
|
||||
* Update Apply Button
|
||||
*/
|
||||
void ElementAutonumberingW::on_m_formula_le_textChanged() {
|
||||
if (!ui->m_formula_le->text().isEmpty())
|
||||
applyEnable(true);
|
||||
else applyEnable(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief ElementAutonumberingW::on_buttonBox_clicked
|
||||
* Action on @buttonBox clicked
|
||||
*/
|
||||
void ElementAutonumberingW::on_buttonBox_clicked(QAbstractButton *button) {
|
||||
//transform button to int
|
||||
int answer = ui -> buttonBox -> buttonRole(button);
|
||||
|
||||
switch (answer) {
|
||||
case QDialogButtonBox::ApplyRole:
|
||||
applyEnable(true);
|
||||
emit applyPressed();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief ElementAutonumberingW::applyEnable
|
||||
* enable/disable the apply button
|
||||
*/
|
||||
void ElementAutonumberingW::applyEnable(bool b) {
|
||||
ui -> buttonBox -> button(QDialogButtonBox::Apply) -> setEnabled(b);
|
||||
}
|
||||
64
sources/ui/elementautonumberingw.h
Normal file
64
sources/ui/elementautonumberingw.h
Normal file
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
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 ELEMENTAUTONUMBERINGW_H
|
||||
#define ELEMENTAUTONUMBERINGW_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
class QAbstractButton;
|
||||
|
||||
namespace Ui {
|
||||
class ElementAutonumberingW;
|
||||
}
|
||||
|
||||
/**
|
||||
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 ElementAutonumberingW : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
//METHODS
|
||||
public:
|
||||
explicit ElementAutonumberingW(QWidget *parent = 0);
|
||||
~ElementAutonumberingW();
|
||||
QString formula();
|
||||
void setContext(QString);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
// SIGNALS
|
||||
signals:
|
||||
void applyPressed();
|
||||
|
||||
//SLOTS
|
||||
private slots:
|
||||
void on_m_formula_le_textChanged();
|
||||
void on_buttonBox_clicked(QAbstractButton *);
|
||||
void applyEnable (bool = true);
|
||||
|
||||
//ATTRIBUTES
|
||||
private:
|
||||
Ui::ElementAutonumberingW *ui;
|
||||
};
|
||||
|
||||
#endif // ELEMENTAUTONUMBERINGW_H
|
||||
176
sources/ui/elementautonumberingw.ui
Normal file
176
sources/ui/elementautonumberingw.ui
Normal file
@@ -0,0 +1,176 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>ElementAutonumberingW</class>
|
||||
<widget class="QWidget" name="ElementAutonumberingW">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>460</width>
|
||||
<height>550</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" 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="Preferred" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>50</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</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>440</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>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetFixedSize</enum>
|
||||
</property>
|
||||
<item row="4" 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>
|
||||
<item row="1" column="1" rowspan="2" colspan="2">
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>Auto Naming Pattern:</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_4">
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="m_formula_le">
|
||||
<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="text">
|
||||
<string>Formula:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" rowspan="2" colspan="3">
|
||||
<widget class="QLabel" name="label">
|
||||
<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>
|
||||
</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</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -135,7 +135,7 @@ void FolioAutonumberingW::on_m_autonumber_tabs_rb_clicked() {
|
||||
* @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(){
|
||||
void FolioAutonumberingW::on_m_new_tabs_sb_valueChanged(int){
|
||||
if (ui->m_new_tabs_sb->value()>0) applyEnable(true);
|
||||
else applyEnable(false);
|
||||
}
|
||||
@@ -144,7 +144,7 @@ void FolioAutonumberingW::on_m_new_tabs_sb_valueChanged(){
|
||||
* @brief FolioAutonumberingW::on_m_from_cb_currentIndexChanged
|
||||
* Enable To ComboBox
|
||||
*/
|
||||
void FolioAutonumberingW::on_m_from_cb_currentIndexChanged(){
|
||||
void FolioAutonumberingW::on_m_from_cb_currentIndexChanged(int){
|
||||
int index = ui->m_from_cb->currentIndex();
|
||||
ui->m_to_cb->clear();
|
||||
if (index > 0){
|
||||
|
||||
@@ -26,7 +26,7 @@ class QAbstractButton;
|
||||
class QETProject;
|
||||
|
||||
namespace Ui {
|
||||
class FolioAutonumberingW;
|
||||
class FolioAutonumberingW;
|
||||
}
|
||||
|
||||
class FolioAutonumberingW : public QWidget
|
||||
@@ -35,16 +35,16 @@ class FolioAutonumberingW : public QWidget
|
||||
|
||||
//METHODS
|
||||
public:
|
||||
explicit FolioAutonumberingW(QETProject *project, QWidget *parent = 0);
|
||||
~FolioAutonumberingW();
|
||||
explicit FolioAutonumberingW(QETProject *project, QWidget *parent = 0);
|
||||
~FolioAutonumberingW();
|
||||
|
||||
void setContext (QList <QString> autonums);
|
||||
void setContext (QList <QString> autonums);
|
||||
NumerotationContext toNumContext() const;
|
||||
QString autoNumSelected();
|
||||
int newFoliosNumber();
|
||||
bool newFolios;
|
||||
int fromFolio();
|
||||
int toFolio();
|
||||
QString autoNumSelected();
|
||||
int newFoliosNumber();
|
||||
bool newFolios;
|
||||
int fromFolio();
|
||||
int toFolio();
|
||||
|
||||
// SIGNALS
|
||||
signals:
|
||||
@@ -53,20 +53,20 @@ class FolioAutonumberingW : public QWidget
|
||||
|
||||
//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();
|
||||
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();
|
||||
void on_m_from_cb_currentIndexChanged(int);
|
||||
void applyEnable (bool = true);
|
||||
|
||||
//ATTRIBUTES
|
||||
private:
|
||||
QETProject *project_;
|
||||
Ui::FolioAutonumberingW *ui;
|
||||
QETProject *project_;
|
||||
Ui::FolioAutonumberingW *ui;
|
||||
QList <NumPartEditorW *> num_part_list_;
|
||||
NumerotationContext m_context;
|
||||
void updateFolioList();
|
||||
void updateFolioList();
|
||||
};
|
||||
|
||||
#endif // FOLIOAUTONUMBERING_H
|
||||
|
||||
@@ -149,7 +149,7 @@ void NumPartEditorW::on_value_field_textEdited() {
|
||||
* @brief NumPartEditorW::on_increase_spinBox_valueChanged
|
||||
* emit changed when @increase_spinBox value changed
|
||||
*/
|
||||
void NumPartEditorW::on_increase_spinBox_valueChanged() {
|
||||
void NumPartEditorW::on_increase_spinBox_valueChanged(int) {
|
||||
if (!ui -> value_field -> text().isEmpty()) emit changed();
|
||||
}
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ class NumPartEditorW : public QWidget
|
||||
private slots:
|
||||
void on_type_combo_activated(int);
|
||||
void on_value_field_textEdited();
|
||||
void on_increase_spinBox_valueChanged();
|
||||
void on_increase_spinBox_valueChanged(int);
|
||||
void setType (NumPartEditorW::type t, bool=false);
|
||||
|
||||
signals:
|
||||
|
||||
@@ -72,5 +72,5 @@ void ProjectPropertiesDialog::setCurrentPage(ProjectPropertiesDialog::Page p) {
|
||||
*/
|
||||
void ProjectPropertiesDialog::changeToFolio() {
|
||||
ProjectAutoNumConfigPage *autoNumPage = static_cast <ProjectAutoNumConfigPage*>(m_properties_dialog->pages.at(2));
|
||||
autoNumPage->changeToTab(1);
|
||||
autoNumPage->changeToTab(2);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user