Creation of folio sequential type for Element Autonumbering. Correction of autonumbering type handling in numparteditorw.cpp

git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@4592 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
dfochi
2016-07-26 18:52:49 +00:00
parent 52e33787a8
commit d6f1381631
18 changed files with 568 additions and 153 deletions

View File

@@ -223,6 +223,7 @@ void AutoNumberingDockWidget::on_m_element_cb_activated(int) {
}
else
project_->setElementAutoNumCurrentFormula("","");
projectview_->currentDiagram()->diagram()->loadElmtFolioSeq();
}
/**

View File

@@ -28,8 +28,7 @@ NumPartEditorW::NumPartEditorW(QWidget *parent) :
intValidator (new QIntValidator(0,99999,this))
{
ui -> setupUi(this);
if (parentWidget()->parentWidget()->objectName()=="FolioTab") ui->type_combo->setMaxCount(4);
else if (parentWidget()->parentWidget()->objectName()=="ConductorTab") ui->type_combo->setMaxCount(6);
setVisibleItems();
setType(NumPartEditorW::unit, true);
}
@@ -43,16 +42,17 @@ 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(4);
else if (parentWidget()->parentWidget()->objectName()=="ConductorTab") ui->type_combo->setMaxCount(6);
//if @context contains nothing build with default value
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);
@@ -73,6 +73,27 @@ NumPartEditorW::~NumPartEditorW()
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") << tr("N° folio");
}
else if (parentWidget()->parentWidget()->objectName()=="ConductorTab") {
items << tr("Chiffre 1") << tr("Chiffre 01")
<< tr("Chiffre 001")
<< tr("Texte") << tr("N° folio") << tr("Folio");
}
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("Element Line") << tr("Element Column") << tr("Element Prefix");
ui->type_cb->insertItems(0,items);
}
/**
* @brief NumPartEditorW::toNumContext
* @return the display to NumerotationContext
@@ -84,12 +105,21 @@ NumerotationContext NumPartEditorW::toNumContext() {
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;
@@ -109,6 +139,9 @@ NumerotationContext NumPartEditorW::toNumContext() {
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;
}
@@ -125,39 +158,34 @@ bool NumPartEditorW::isValid() {
}
/**
* @brief NumPartEditorW::on_type_combo_activated
* @brief NumPartEditorW::on_type_cb_activated
* Action when user change the type comboBox
*/
void NumPartEditorW::on_type_combo_activated(int index) {
switch (index) {
case unit:
setType(unit);
break;
case ten:
setType(ten);
break;
case hundred:
setType(hundred);
break;
case string:
setType(string);
break;
case idfolio:
setType(idfolio);
break;
case folio:
setType(folio);
break;
case elementline:
setType(elementline);
break;
case elementcolumn:
setType(elementcolumn);
break;
case elementprefix:
setType(elementprefix);
break;
};
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("folio"))
setType(idfolio);
else if (ui->type_cb->currentText() == tr("Folio"))
setType(folio);
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();
}
@@ -184,11 +212,11 @@ void NumPartEditorW::on_increase_spinBox_valueChanged(int) {
* @param fnum, force the behavior of numeric type
*/
void NumPartEditorW::setType(NumPartEditorW::type t, bool fnum) {
ui -> type_combo -> setCurrentIndex(t);
// ui -> type_cb -> 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==ten || t==hundred) &&
if ( ((t==unit || t==unitfolio || t==ten || t==tenfolio || t==hundred || t==hundredfolio) &&
(type_==string || type_==folio || type_==idfolio ||
type_==elementcolumn || type_==elementline || type_==elementprefix))
|| fnum) {

View File

@@ -41,13 +41,20 @@ class NumPartEditorW : public QWidget
NumPartEditorW (NumerotationContext &, int, QWidget *parent=0);
~NumPartEditorW();
enum type {unit,ten,hundred,string,idfolio,folio,elementline,elementcolumn,elementprefix};
enum type {unit,unitfolio,ten,tenfolio, hundred, hundredfolio,
string,idfolio,folio,
elementline,elementcolumn,elementprefix,
};
NumerotationContext toNumContext();
bool isValid ();
type type_;
private:
void setVisibleItems();
void disableItem(int index);
private slots:
void on_type_combo_activated(int);
void on_type_cb_activated(int);
void on_value_field_textEdited();
void on_increase_spinBox_valueChanged(int);
void setType (NumPartEditorW::type t, bool=false);

View File

@@ -30,7 +30,7 @@
<number>2</number>
</property>
<item>
<widget class="QComboBox" name="type_combo">
<widget class="QComboBox" name="type_cb">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
@@ -40,51 +40,6 @@
<property name="editable">
<bool>true</bool>
</property>
<item>
<property name="text">
<string>Chiffre 1</string>
</property>
</item>
<item>
<property name="text">
<string>Chiffre 01</string>
</property>
</item>
<item>
<property name="text">
<string>Chiffre 001</string>
</property>
</item>
<item>
<property name="text">
<string>Texte</string>
</property>
</item>
<item>
<property name="text">
<string>N° folio</string>
</property>
</item>
<item>
<property name="text">
<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

@@ -233,8 +233,11 @@ void SelectAutonumW::applyEnable(bool b) {
void SelectAutonumW::contextToFormula() {
m_eaw->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) {
@@ -259,14 +262,26 @@ void SelectAutonumW::contextToFormula() {
count_unit++;
m_eaw->setContext("%sequ_"+QString::number(count_unit));
}
else if (npe->type_ == NumPartEditorW::unitfolio) {
count_unitf++;
m_eaw->setContext("%sequf_"+QString::number(count_unitf));
}
else if (npe->type_ == NumPartEditorW::ten) {
count_ten++;
m_eaw->setContext("%seqt_"+QString::number(count_ten));
}
else if (npe->type_ == NumPartEditorW::tenfolio) {
count_tenf++;
m_eaw->setContext("%seqtf_"+QString::number(count_tenf));
}
else if (npe->type_ == NumPartEditorW::hundred) {
count_hundred++;
m_eaw->setContext("%seqh_"+QString::number(count_hundred));
}
else if (npe->type_ == NumPartEditorW::hundredfolio) {
count_hundredf++;
m_eaw->setContext("%seqhf_"+QString::number(count_hundredf));
}
}
}
}