Element Autonumbering now has sequential variables and selectautonum widget. Renamed autonumbering variables.

git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@4569 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
dfochi
2016-07-10 01:33:49 +00:00
parent 518f0efd46
commit f8a829d328
23 changed files with 746 additions and 311 deletions

View File

@@ -30,7 +30,7 @@ ElementAutonumberingW::ElementAutonumberingW(QWidget *parent) :
{
ui->setupUi(this);
applyEnable(false);
setContext(formula_);
}
/**
@@ -49,6 +49,14 @@ void ElementAutonumberingW::setContext(QString formula) {
ui->m_formula_le->insert(formula);
}
/**
* @brief ElementAutonumberingW::clearContext
* @param clear formula line edit text
*/
void ElementAutonumberingW::clearContext() {
ui->m_formula_le->clear();
}
/**
* @brief ElementAutonumberingW::formula
* @return formula to be stored into project
@@ -61,32 +69,6 @@ QString ElementAutonumberingW::formula() {
* @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);
void ElementAutonumberingW::on_m_formula_le_textChanged(QString text) {
emit (textChanged(text));
}

View File

@@ -42,23 +42,24 @@ class ElementAutonumberingW : public QWidget
~ElementAutonumberingW();
QString formula();
void setContext(QString);
void clearContext();
Ui::ElementAutonumberingW *ui;
private:
// SIGNALS
signals:
void applyPressed();
void textChanged(QString);
//SLOTS
private slots:
void on_m_formula_le_textChanged();
void on_buttonBox_clicked(QAbstractButton *);
void applyEnable (bool = true);
void on_m_formula_le_textChanged(QString);
//ATTRIBUTES
private:
Ui::ElementAutonumberingW *ui;
QString formula_;
};
#endif // ELEMENTAUTONUMBERINGW_H

View File

@@ -6,19 +6,19 @@
<rect>
<x>0</x>
<y>0</y>
<width>460</width>
<height>550</height>
<width>383</width>
<height>305</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>460</width>
<width>0</width>
<height>0</height>
</size>
</property>
@@ -30,117 +30,59 @@
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<item>
<widget class="QScrollArea" name="scrollArea">
<widget class="QGroupBox" name="groupBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>50</verstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
<property name="title">
<string>Auto Naming Pattern:</string>
</property>
<property name="sizeIncrement">
<size>
<width>0</width>
<height>50</height>
</size>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="1">
<widget class="QLineEdit" name="m_formula_le">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" 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="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>498</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="locale">
<locale language="French" country="France"/>
</property>
<property name="text">
<string>You can use the following variables to your formula:
<property name="text">
<string>You can use the following variables to your formula:
-%prefix: Default Element Prefix
-%l: Element Line
-%c: Element Column
@@ -148,29 +90,23 @@
-%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>
that you create. Text and number inputs are
also available.</string>
</property>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Apply</set>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</widget>
</spacer>
</item>
</layout>
</widget>

View File

@@ -29,6 +29,7 @@ NumPartEditorW::NumPartEditorW(QWidget *parent) :
{
ui -> setupUi(this);
if (parentWidget()->parentWidget()->objectName()=="FolioTab") ui->type_combo->setMaxCount(4);
else if (parentWidget()->parentWidget()->objectName()=="ConductorTab") ui->type_combo->setMaxCount(6);
setType(NumPartEditorW::unit, true);
}
@@ -42,7 +43,8 @@ NumPartEditorW::NumPartEditorW (NumerotationContext &context, int i, QWidget *pa
intValidator (new QIntValidator(0,99999,this))
{
ui -> setupUi(this);
if (parentWidget()->parentWidget()->objectName()=="FolioTab") ui->type_combo->setMaxCount(5);
if (parentWidget()->parentWidget()->objectName()=="FolioTab") ui->type_combo->setMaxCount(4);
else if (parentWidget()->parentWidget()->objectName()=="ConductorTab") ui->type_combo->setMaxCount(6);
//if @context contains nothing build with default value
if(context.size()==0) setType(NumPartEditorW::unit, true);
@@ -54,6 +56,9 @@ NumPartEditorW::NumPartEditorW (NumerotationContext &context, int i, QWidget *pa
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)=="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());
}
@@ -94,6 +99,15 @@ NumerotationContext NumPartEditorW::toNumContext() {
case folio:
type_str = "folio";
break;
case elementline:
type_str = "elementline";
break;
case elementcolumn:
type_str = "elementcolumn";
break;
case elementprefix:
type_str = "elementprefix";
break;
}
nc.addValue(type_str, ui -> value_field -> displayText(), ui -> increase_spinBox -> value());
return nc;
@@ -104,7 +118,8 @@ NumerotationContext NumPartEditorW::toNumContext() {
* @return true if value field isn't empty or if type is folio
*/
bool NumPartEditorW::isValid() {
if (type_ == folio||type_ == idfolio) {return true;}
if (type_ == folio || type_ == idfolio || type_ == elementline ||
type_ == elementcolumn || type_ == elementprefix) {return true;}
else if(ui -> value_field -> text().isEmpty()) {return false;}
else return true;
}
@@ -133,6 +148,15 @@ void NumPartEditorW::on_type_combo_activated(int index) {
case folio:
setType(folio);
break;
case elementline:
setType(elementline);
break;
case elementcolumn:
setType(elementcolumn);
break;
case elementprefix:
setType(elementprefix);
break;
};
emit changed();
}
@@ -164,7 +188,10 @@ void NumPartEditorW::setType(NumPartEditorW::type t, bool fnum) {
//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==ten || t==hundred) && (type_==string || type_==folio || type_==idfolio)) || fnum) {
if ( ((t==unit || t==ten || t==hundred) &&
(type_==string || type_==folio || type_==idfolio ||
type_==elementcolumn || type_==elementline || type_==elementprefix))
|| fnum) {
ui -> value_field -> clear();
ui -> value_field -> setEnabled(true);
ui -> value_field -> setValidator(intValidator);
@@ -172,7 +199,8 @@ void NumPartEditorW::setType(NumPartEditorW::type t, bool fnum) {
ui -> increase_spinBox -> setValue(1);
}
//@t isn't a numeric type
else if (t==string || t==folio || t==idfolio) {
else if (t == string || t == folio || t == idfolio || t == elementline ||
t == elementcolumn || t == elementprefix) {
ui -> value_field -> clear();
ui -> increase_spinBox -> setDisabled(true);
if (t==string) {
@@ -187,6 +215,18 @@ void NumPartEditorW::setType(NumPartEditorW::type t, bool fnum) {
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;
}

View File

@@ -41,10 +41,10 @@ class NumPartEditorW : public QWidget
NumPartEditorW (NumerotationContext &, int, QWidget *parent=0);
~NumPartEditorW();
enum type {unit,ten,hundred,string,idfolio,folio};
enum type {unit,ten,hundred,string,idfolio,folio,elementline,elementcolumn,elementprefix};
NumerotationContext toNumContext();
bool isValid ();
type type_;
private slots:
void on_type_combo_activated(int);
@@ -58,7 +58,7 @@ class NumPartEditorW : public QWidget
private:
Ui::NumPartEditorW *ui;
QValidator *intValidator;
type type_;
};

View File

@@ -6,20 +6,29 @@
<rect>
<x>0</x>
<y>0</y>
<width>308</width>
<height>45</height>
<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_combo">
<property name="sizePolicy">
@@ -61,6 +70,21 @@
<string>Folio</string>
</property>
</item>
<item>
<property name="text">
<string>Element Line</string>
</property>
</item>
<item>
<property name="text">
<string>Element Column</string>
</property>
</item>
<item>
<property name="text">
<string>Element Prefix</string>
</property>
</item>
</widget>
</item>
<item>

View File

@@ -20,6 +20,9 @@
#include "numparteditorw.h"
#include <QMessageBox>
#include "numerotationcontextcommands.h"
#include "elementautonumberingw.h"
#include "ui_elementautonumberingw.h"
#include "qdebug.h"
/**
* Constructor
@@ -28,7 +31,13 @@ SelectAutonumW::SelectAutonumW(QWidget *parent) :
QWidget(parent),
ui(new Ui::SelectAutonumW)
{
ui->setupUi(this);
if (this->parentWidget() -> objectName()=="ElementTab"){
m_eaw = new ElementAutonumberingW();
connect(m_eaw,SIGNAL(textChanged(QString)),this,SLOT(formula_textChanged(QString)));
ui->scrollAreaWidgetContents->layout()->addWidget(m_eaw);
}
setContext(NumerotationContext());
}
@@ -36,6 +45,11 @@ SelectAutonumW::SelectAutonumW(const NumerotationContext &context, QWidget *pare
QWidget(parent),
ui(new Ui::SelectAutonumW)
{
if (this->parentWidget() -> objectName()=="ElementTab"){
m_eaw = new ElementAutonumberingW();
connect(m_eaw,SIGNAL(textChanged(QString)),this,SLOT(formula_textChanged(QString)));
ui->scrollAreaWidgetContents->layout()->addWidget(m_eaw);
}
ui->setupUi(this);
setContext(context);
}
@@ -117,6 +131,14 @@ void SelectAutonumW::on_remove_button_clicked() {
applyEnable();
}
/**
* @brief SelectAutonumW::elementFormula
* @return element autonumbering widget formula
*/
QString SelectAutonumW::elementFormula() {
return m_eaw->formula();
}
/**
* @brief SelectAutonumW::on_buttonBox_clicked
* Action on @buttonBox clicked
@@ -189,8 +211,56 @@ void SelectAutonumW::applyEnable(bool b) {
foreach (NumPartEditorW *npe, num_part_list_) if (!npe -> isValid()) valid= false;
ui -> buttonBox -> button(QDialogButtonBox::Apply) -> setEnabled(valid);
}
else
else {
ui -> buttonBox -> button(QDialogButtonBox::Apply) -> setEnabled(b);
}
if (this->parentWidget() -> objectName()=="ElementTab")
contextToFormula();
}
/**
* @brief SelectAutonumW::contextToFormula
* Apply formula to ElementAutonumbering Widget
*/
void SelectAutonumW::contextToFormula() {
m_eaw->clearContext();
int count_unit = 0;
int count_ten = 0;
int count_hundred = 0;
foreach (NumPartEditorW *npe, num_part_list_) {
if (npe->isValid()) {
if (npe->type_ == NumPartEditorW::idfolio) {
m_eaw->setContext("%id");
}
else if (npe->type_ == NumPartEditorW::folio) {
m_eaw->setContext("%F");
}
else if (npe->type_ == NumPartEditorW::elementcolumn) {
m_eaw->setContext("%c");
}
else if (npe->type_ == NumPartEditorW::elementline) {
m_eaw->setContext("%l");
}
else if (npe->type_ == NumPartEditorW::elementprefix) {
m_eaw->setContext("%prefix");
}
else if (npe->type_ == NumPartEditorW::string) {
m_eaw->setContext(npe->toNumContext().itemAt(0).at(1));
}
else if (npe->type_ == NumPartEditorW::unit) {
count_unit++;
m_eaw->setContext("%sequ_"+QString::number(count_unit));
}
else if (npe->type_ == NumPartEditorW::ten) {
count_ten++;
m_eaw->setContext("%seqt_"+QString::number(count_ten));
}
else if (npe->type_ == NumPartEditorW::hundred) {
count_hundred++;
m_eaw->setContext("%seqh_"+QString::number(count_hundred));
}
}
}
}
/**

View File

@@ -20,6 +20,7 @@
#include <QWidget>
#include "numerotationcontext.h"
#include "elementautonumberingw.h"
class NumPartEditorW;
class QAbstractButton;
@@ -40,6 +41,8 @@ class SelectAutonumW : public QWidget
void setContext (const NumerotationContext &context);
NumerotationContext toNumContext() const;
void contextToFormula ();
QString elementFormula();
signals:
void applyPressed();
@@ -51,15 +54,15 @@ class SelectAutonumW : public QWidget
void on_buttonBox_clicked(QAbstractButton *);
void applyEnable (bool = true);
//ATTRIBUTS
//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;
ElementAutonumberingW *m_eaw;
};
#endif // SELECTAUTONUMW_H

View File

@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>418</width>
<height>506</height>
<height>508</height>
</rect>
</property>
<property name="sizePolicy">
@@ -269,7 +269,7 @@
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>30</height>
<height>0</height>
</size>
</property>
</spacer>