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

@@ -866,7 +866,6 @@ void Diagram::addItem(QGraphicsItem *item)
CustomElement *celmt = static_cast<CustomElement*>(item); CustomElement *celmt = static_cast<CustomElement*>(item);
celmt->parseLabels(); celmt->parseLabels();
} }
elmt->updateLabel(); elmt->updateLabel();
} }
break; break;

View File

@@ -233,4 +233,6 @@ void DiagramEventAddElement::addElement()
can.numerate(); can.numerate();
}; };
m_diagram -> undoStack().push(undo_object); m_diagram -> undoStack().push(undo_object);
element->assignSeq();
element->updateLabel();
} }

View File

@@ -99,7 +99,7 @@ QStringList NumerotationContext::itemAt(const int i) const {
* @return all type use to numerotation * @return all type use to numerotation
*/ */
QString NumerotationContext::validRegExpNum () const { QString NumerotationContext::validRegExpNum () const {
return ("unit|ten|hundred|string|idfolio|folio"); return ("unit|ten|hundred|string|idfolio|folio|elementline|elementcolumn|elementprefix");
} }
/** /**

View File

@@ -112,6 +112,18 @@ void NumerotationContextCommands::setNumStrategy(const QString &str) {
strategy_ = new FolioNum (diagram_); strategy_ = new FolioNum (diagram_);
return; return;
} }
else if (str=="elementline"){
strategy_ = new ElementLineNum (diagram_);
return;
}
else if (str=="elementcolumn"){
strategy_ = new ElementColumnNum (diagram_);
return;
}
else if (str=="elementprefix"){
strategy_ = new ElementPrefixNum (diagram_);
return;
}
} }
@@ -359,3 +371,99 @@ NumerotationContext FolioNum::previous(const NumerotationContext &nc, const int
return (nextString(nc, i)); return (nextString(nc, i));
} }
/**
* Constructor
*/
ElementLineNum::ElementLineNum (Diagram *d):
NumStrategy (d)
{}
/**
* @brief ElementLineNum::toRepresentedString
* @return the represented string of folio
*/
QString ElementLineNum::toRepresentedString(const QString str) const {
Q_UNUSED(str);
return "%l";
}
/**
* @brief ElementLineNum::next
* @return the next NumerotationContext nc at position i
*/
NumerotationContext ElementLineNum::next (const NumerotationContext &nc, const int i) const {
return (nextString(nc, i));
}
/**
* @brief ElementLineNum::previous
* @return the previous NumerotationContext nc at posiiton i
*/
NumerotationContext ElementLineNum::previous(const NumerotationContext &nc, const int i) const {
return (nextString(nc, i));
}
/**
* Constructor
*/
ElementColumnNum::ElementColumnNum (Diagram *d):
NumStrategy (d)
{}
/**
* @brief ElementColumnNum::toRepresentedString
* @return the represented string of folio
*/
QString ElementColumnNum::toRepresentedString(const QString str) const {
Q_UNUSED(str);
return "%c";
}
/**
* @brief ElementColumnNum::next
* @return the next NumerotationContext nc at position i
*/
NumerotationContext ElementColumnNum::next (const NumerotationContext &nc, const int i) const {
return (nextString(nc, i));
}
/**
* @brief ElementColumnNum::previous
* @return the previous NumerotationContext nc at posiiton i
*/
NumerotationContext ElementColumnNum::previous(const NumerotationContext &nc, const int i) const {
return (nextString(nc, i));
}
/**
* Constructor
*/
ElementPrefixNum::ElementPrefixNum (Diagram *d):
NumStrategy (d)
{}
/**
* @brief ElementPrefixNum::toRepresentedString
* @return the represented string of folio
*/
QString ElementPrefixNum::toRepresentedString(const QString str) const {
Q_UNUSED(str);
return "%prefix";
}
/**
* @brief ElementPrefixNum::next
* @return the next NumerotationContext nc at position i
*/
NumerotationContext ElementPrefixNum::next (const NumerotationContext &nc, const int i) const {
return (nextString(nc, i));
}
/**
* @brief ElementPrefixNum::previous
* @return the previous NumerotationContext nc at posiiton i
*/
NumerotationContext ElementPrefixNum::previous(const NumerotationContext &nc, const int i) const {
return (nextString(nc, i));
}

View File

@@ -113,4 +113,33 @@ class FolioNum: public NumStrategy
NumerotationContext next (const NumerotationContext &, const int) const; NumerotationContext next (const NumerotationContext &, const int) const;
NumerotationContext previous (const NumerotationContext &, const int) const; NumerotationContext previous (const NumerotationContext &, const int) const;
}; };
class ElementLineNum: public NumStrategy
{
public:
ElementLineNum (Diagram *);
QString toRepresentedString(const QString) const;
NumerotationContext next (const NumerotationContext &, const int) const;
NumerotationContext previous (const NumerotationContext &, const int) const;
};
class ElementColumnNum: public NumStrategy
{
public:
ElementColumnNum (Diagram *);
QString toRepresentedString(const QString) const;
NumerotationContext next (const NumerotationContext &, const int) const;
NumerotationContext previous (const NumerotationContext &, const int) const;
};
class ElementPrefixNum: public NumStrategy
{
public:
ElementPrefixNum (Diagram *);
QString toRepresentedString(const QString) const;
NumerotationContext next (const NumerotationContext &, const int) const;
NumerotationContext previous (const NumerotationContext &, const int) const;
};
#endif // NUMEROTATIONCONTEXTCOMMANDS_H #endif // NUMEROTATIONCONTEXTCOMMANDS_H

View File

@@ -257,38 +257,51 @@ void ProjectAutoNumConfigPage::initWidgets() {
//Conductor Tab //Conductor Tab
conductor_tab_widget = new QWidget(this); conductor_tab_widget = new QWidget(this);
conductor_tab_widget->setObjectName("ConductorTab");
m_label = new QLabel(tr("Numérotations disponibles :", "availables numerotations"), conductor_tab_widget); m_label_conductor = new QLabel(tr("Numérotations disponibles :", "availables numerotations"), conductor_tab_widget);
m_context_cb = new QComboBox(conductor_tab_widget); m_context_cb_conductor= new QComboBox(conductor_tab_widget);
m_context_cb->setEditable(true); m_context_cb_conductor->setEditable(true);
m_context_cb->lineEdit()->setClearButtonEnabled(true); m_context_cb_conductor->lineEdit()->setClearButtonEnabled(true);
m_context_cb->addItem(tr("Nom de la nouvelle numérotation")); m_context_cb_conductor->addItem(tr("Nom de la nouvelle numérotation"));
m_remove_pb = new QPushButton(QET::Icons::EditDelete, QString(), conductor_tab_widget); m_remove_pb_conductor= new QPushButton(QET::Icons::EditDelete, QString(), conductor_tab_widget);
m_remove_pb -> setToolTip(tr("Supprimer la numérotation")); m_remove_pb_conductor-> setToolTip(tr("Supprimer la numérotation"));
m_saw = new SelectAutonumW(conductor_tab_widget); m_saw_conductor = new SelectAutonumW(conductor_tab_widget);
//Element Tab //Element Tab
element_tab_widget = new QWidget(this); element_tab_widget = new QWidget(this);
m_eaw = new ElementAutonumberingW(element_tab_widget); element_tab_widget->setObjectName("ElementTab");
m_label_element = new QLabel(tr("Numérotations disponibles :", "availables numerotations"), element_tab_widget);
m_context_cb_element = new QComboBox(element_tab_widget);
m_context_cb_element->setEditable(true);
m_context_cb_element->lineEdit()->setClearButtonEnabled(true);
m_context_cb_element->addItem(tr("Nom de la nouvelle numérotation"));
m_remove_pb_element = new QPushButton(QET::Icons::EditDelete, QString(), element_tab_widget);
m_remove_pb_element -> setToolTip(tr("Supprimer la numérotation"));
m_saw_element = new SelectAutonumW(element_tab_widget);
//Folio Tab //Folio Tab
folio_tab_widget = new QWidget(this); folio_tab_widget = new QWidget(this);
folio_tab_widget->setObjectName("FolioTab"); folio_tab_widget->setObjectName("FolioTab");
m_label_2 = new QLabel(tr("Numérotations disponibles :", "availables numerotations"), folio_tab_widget); m_label_folio = new QLabel(tr("Numérotations disponibles :", "availables numerotations"), folio_tab_widget);
m_context_cb_2 = new QComboBox(folio_tab_widget); m_context_cb_folio = new QComboBox(folio_tab_widget);
m_context_cb_2->setEditable(true); m_context_cb_folio->setEditable(true);
m_context_cb_2->lineEdit()->setClearButtonEnabled(true); m_context_cb_folio->lineEdit()->setClearButtonEnabled(true);
m_context_cb_2->addItem(tr("Nom de la nouvelle numérotation")); m_context_cb_folio->addItem(tr("Nom de la nouvelle numérotation"));
m_remove_pb_2 = new QPushButton(QET::Icons::EditDelete, QString(), folio_tab_widget); m_remove_pb_folio = new QPushButton(QET::Icons::EditDelete, QString(), folio_tab_widget);
m_remove_pb_2 -> setToolTip(tr("Supprimer la numérotation")); m_remove_pb_folio -> setToolTip(tr("Supprimer la numérotation"));
m_saw_2 = new SelectAutonumW(folio_tab_widget); m_saw_folio = new SelectAutonumW(folio_tab_widget);
//AutoNumbering Tab //AutoNumbering Tab
autoNumbering_tab_widget = new QWidget(this); autoNumbering_tab_widget = new QWidget(this);
@@ -304,42 +317,55 @@ void ProjectAutoNumConfigPage::initLayout() {
//Conductor Tab //Conductor Tab
tab_widget->addTab(conductor_tab_widget, tr("Conductor")); tab_widget->addTab(conductor_tab_widget, tr("Conductor"));
QHBoxLayout *context_layout = new QHBoxLayout(); QHBoxLayout *context_layout_conductor = new QHBoxLayout();
context_layout -> addWidget (m_label); context_layout_conductor -> addWidget (m_label_conductor);
context_layout -> addWidget (m_context_cb); context_layout_conductor -> addWidget (m_context_cb_conductor);
context_layout -> addWidget (m_remove_pb); context_layout_conductor -> addWidget (m_remove_pb_conductor);
QVBoxLayout *main_layout = new QVBoxLayout(); QVBoxLayout *main_layout_conductor = new QVBoxLayout();
QVBoxLayout *aux_layout = new QVBoxLayout(); QVBoxLayout *aux_layout_conductor = new QVBoxLayout();
aux_layout->addLayout(context_layout); aux_layout_conductor->addLayout(context_layout_conductor);
aux_layout->addWidget(m_saw); aux_layout_conductor->addWidget(m_saw_conductor);
main_layout->addLayout(aux_layout); main_layout_conductor->addLayout(aux_layout_conductor);
conductor_tab_widget -> setLayout (main_layout); conductor_tab_widget -> setLayout (main_layout_conductor);
//Element Tab //Element Tab
tab_widget->addTab(element_tab_widget,tr ("Element")); tab_widget->addTab(element_tab_widget,tr ("Element"));
QHBoxLayout *element_context_layout = new QHBoxLayout();
element_context_layout -> addWidget (m_label_element);
element_context_layout -> addWidget (m_context_cb_element);
element_context_layout -> addWidget (m_remove_pb_element);
QVBoxLayout *main_layout_element = new QVBoxLayout();
QVBoxLayout *aux_layout_element = new QVBoxLayout();
aux_layout_element->addLayout(element_context_layout);
aux_layout_element->addWidget(m_saw_element);
main_layout_element->addLayout(aux_layout_element);
element_tab_widget->setLayout(main_layout_element);
// Folio Tab // Folio Tab
tab_widget->addTab(folio_tab_widget, tr("Folio")); tab_widget->addTab(folio_tab_widget, tr("Folio"));
QHBoxLayout *context_layout_2 = new QHBoxLayout(); QHBoxLayout *context_layout_folio = new QHBoxLayout();
context_layout_2 -> addWidget (m_label_2); context_layout_folio -> addWidget (m_label_folio);
context_layout_2 -> addWidget (m_context_cb_2); context_layout_folio -> addWidget (m_context_cb_folio);
context_layout_2 -> addWidget (m_remove_pb_2); context_layout_folio -> addWidget (m_remove_pb_folio);
QVBoxLayout *main_layout_2 = new QVBoxLayout(); QVBoxLayout *main_layout_folio = new QVBoxLayout();
QVBoxLayout *aux_layout_2 = new QVBoxLayout(); QVBoxLayout *aux_layout_folio = new QVBoxLayout();
aux_layout_2->addLayout(context_layout_2); aux_layout_folio->addLayout(context_layout_folio);
aux_layout_2->addWidget(m_saw_2); aux_layout_folio->addWidget(m_saw_folio);
main_layout_2->addLayout(aux_layout_2); main_layout_folio->addLayout(aux_layout_folio);
folio_tab_widget -> setLayout (main_layout_2); folio_tab_widget->setLayout(main_layout_folio);
//Auto Numbering Tab //Auto Numbering Tab
tab_widget->addTab(autoNumbering_tab_widget,tr ("Folio Auto Numbering")); tab_widget->addTab(autoNumbering_tab_widget,tr ("Folio Auto Numbering"));
tab_widget->resize(455,590); tab_widget->resize(465,590);
} }
/** /**
@@ -348,23 +374,25 @@ void ProjectAutoNumConfigPage::initLayout() {
*/ */
void ProjectAutoNumConfigPage::readValuesFromProject() { void ProjectAutoNumConfigPage::readValuesFromProject() {
//Conductor Tab //Conductor Tab
QList <QString> keys = project_->conductorAutoNum().keys(); QList <QString> keys_conductor = project_->conductorAutoNum().keys();
if (!keys.isEmpty()){ if (!keys_conductor.isEmpty()){
foreach (QString str, keys) { m_context_cb -> addItem(str); } foreach (QString str, keys_conductor) { m_context_cb_conductor-> addItem(str); }
} }
//Element Tab //Element Tab
if (!project_->elementAutoNum().isEmpty()) QList <QString> keys_element = project_->elementAutoNum().keys();
m_eaw->setContext(project_->elementAutoNum()); if (!keys_element.isEmpty()){
foreach (QString str, keys_element) { m_context_cb_element -> addItem(str);}
}
//Folio Tab //Folio Tab
QList <QString> keys_2 = project_->folioAutoNum().keys(); QList <QString> keys_folio = project_->folioAutoNum().keys();
if (!keys_2.isEmpty()){ if (!keys_folio.isEmpty()){
foreach (QString str, keys_2) { m_context_cb_2 -> addItem(str);} foreach (QString str, keys_folio) { m_context_cb_folio -> addItem(str);}
} }
//Folio AutoNumbering Tab //Folio AutoNumbering Tab
m_faw->setContext(keys_2); m_faw->setContext(keys_folio);
} }
/** /**
@@ -383,92 +411,125 @@ void ProjectAutoNumConfigPage::buildConnections() {
connect(tab_widget,SIGNAL(currentChanged(int)),this,SLOT(tabChanged(int))); connect(tab_widget,SIGNAL(currentChanged(int)),this,SLOT(tabChanged(int)));
//Conductor Tab //Conductor Tab
connect (m_context_cb, SIGNAL (currentIndexChanged(QString)), this, SLOT (updateContext(QString))); connect (m_context_cb_conductor, SIGNAL (currentIndexChanged(QString)), this, SLOT (updateContext_conductor(QString)));
connect (m_saw, SIGNAL (applyPressed()), this, SLOT (saveContext())); connect (m_saw_conductor, SIGNAL (applyPressed()), this, SLOT (saveContext_conductor()));
connect (m_remove_pb, SIGNAL (clicked()), this, SLOT(removeContext())); connect (m_remove_pb_conductor, SIGNAL (clicked()), this, SLOT (removeContext_conductor()));
//Element Tab //Element Tab
connect (m_eaw, SIGNAL (applyPressed()), this, SLOT (saveContext_3())); connect (m_context_cb_element, SIGNAL (currentIndexChanged(QString)), this, SLOT (updateContext_element(QString)));
connect (m_saw_element, SIGNAL (applyPressed()), this, SLOT (saveContext_element()));
connect (m_remove_pb_element, SIGNAL (clicked()), this, SLOT (removeContext_element()));
//Folio Tab //Folio Tab
connect (m_context_cb_2, SIGNAL (currentIndexChanged(QString)), this, SLOT (updateContext_2(QString))); connect (m_context_cb_folio, SIGNAL (currentIndexChanged(QString)), this, SLOT (updateContext_folio(QString)));
connect (m_saw_2, SIGNAL (applyPressed()), this, SLOT (saveContext_2())); connect (m_saw_folio, SIGNAL (applyPressed()), this, SLOT (saveContext_folio()));
connect (m_remove_pb_2, SIGNAL (clicked()), this, SLOT (removeContext_2())); connect (m_remove_pb_folio, SIGNAL (clicked()), this, SLOT (removeContext_folio()));
// Auto Folio Numbering // Auto Folio Numbering
connect (m_faw, SIGNAL (applyPressed()), this, SLOT (applyAutoNum())); connect (m_faw, SIGNAL (applyPressed()), this, SLOT (applyAutoNum()));
} }
/** /**
* @brief ProjectAutoNumConfigPage::updateContext * @brief ProjectAutoNumConfigPage::updateContext_conductor
* Display the current selected context for conductor * Display the current selected context for conductor
* @param str, key of context stored in project * @param str, key of context stored in project
*/ */
void ProjectAutoNumConfigPage::updateContext(QString str) { void ProjectAutoNumConfigPage::updateContext_conductor(QString str) {
if (str == tr("Nom de la nouvelle numérotation")) m_saw -> setContext(NumerotationContext()); if (str == tr("Nom de la nouvelle numérotation")) m_saw_conductor -> setContext(NumerotationContext());
else m_saw ->setContext(project_->conductorAutoNum(str)); else m_saw_conductor ->setContext(project_->conductorAutoNum(str));
} }
/** /**
* @brief ProjectAutoNumConfigPage::updateContext_2 * @brief ProjectAutoNumConfigPage::updateContext_folio
* Display the current selected context for folio * Display the current selected context for folio
* @param str, key of context stored in project * @param str, key of context stored in project
*/ */
void ProjectAutoNumConfigPage::updateContext_2(QString str) { void ProjectAutoNumConfigPage::updateContext_folio(QString str) {
if (str == tr("Nom de la nouvelle numérotation")) m_saw_2 -> setContext(NumerotationContext()); if (str == tr("Nom de la nouvelle numérotation")) m_saw_folio -> setContext(NumerotationContext());
else m_saw_2 ->setContext(project_->folioAutoNum(str)); else m_saw_folio ->setContext(project_->folioAutoNum(str));
} }
/** /**
* @brief ProjectAutoNumConfigPage::saveContext * @brief ProjectAutoNumConfigPage::updateContext_element
* Display the current selected context for element
* @param str, key of context stored in project
*/
void ProjectAutoNumConfigPage::updateContext_element(QString str) {
if (str == tr("Nom de la nouvelle numérotation")) m_saw_element -> setContext(NumerotationContext());
else m_saw_element ->setContext(project_->elementAutoNum(str));
}
/**
* @brief ProjectAutoNumConfigPage::saveContext_conductor
* Save the current displayed conductor context in project * Save the current displayed conductor context in project
*/ */
void ProjectAutoNumConfigPage::saveContext() { void ProjectAutoNumConfigPage::saveContext_conductor() {
// If the text is the default text "Name of new numerotation" save the edited context // If the text is the default text "Name of new numerotation" save the edited context
// With the the name "No name" // With the the name "No name"
if (m_context_cb -> currentText() == tr("Nom de la nouvelle numérotation")) { if (m_context_cb_conductor-> currentText() == tr("Nom de la nouvelle numérotation")) {
project_->addConductorAutoNum (tr("Sans nom"), m_saw -> toNumContext()); project_->addConductorAutoNum (tr("Sans nom"), m_saw_conductor -> toNumContext());
m_context_cb -> addItem(tr("Sans nom")); m_context_cb_conductor-> addItem(tr("Sans nom"));
} }
// If the text isn't yet to the autonum of the project, add this new item to the combo box. // If the text isn't yet to the autonum of the project, add this new item to the combo box.
else if ( !project_ -> conductorAutoNum().keys().contains( m_context_cb->currentText())) { else if ( !project_ -> conductorAutoNum().keys().contains( m_context_cb_conductor->currentText())) {
project()->addConductorAutoNum(m_context_cb->currentText(), m_saw->toNumContext()); project()->addConductorAutoNum(m_context_cb_conductor->currentText(), m_saw_conductor->toNumContext());
m_context_cb -> addItem(m_context_cb->currentText()); m_context_cb_conductor-> addItem(m_context_cb_conductor->currentText());
} }
// Else, the text already exist in the autonum of the project, just update the context // Else, the text already exist in the autonum of the project, just update the context
else { else {
project_->addConductorAutoNum (m_context_cb -> currentText(), m_saw -> toNumContext()); project_->addConductorAutoNum (m_context_cb_conductor-> currentText(), m_saw_conductor -> toNumContext());
} }
} }
/** /**
* @brief ProjectAutoNumConfigPage::saveContext_2 * @brief ProjectAutoNumConfigPage::saveContext_folio
* Save the current displayed folio context in project * Save the current displayed folio context in project
*/ */
void ProjectAutoNumConfigPage::saveContext_2() { void ProjectAutoNumConfigPage::saveContext_folio() {
// If the text is the default text "Name of new numerotation" save the edited context // If the text is the default text "Name of new numerotation" save the edited context
// With the the name "No name" // With the the name "No name"
if (m_context_cb_2 -> currentText() == tr("Nom de la nouvelle numérotation")) { if (m_context_cb_folio -> currentText() == tr("Nom de la nouvelle numérotation")) {
project_->addFolioAutoNum (tr("Sans nom"), m_saw_2 -> toNumContext()); project_->addFolioAutoNum (tr("Sans nom"), m_saw_folio -> toNumContext());
m_context_cb_2 -> addItem(tr("Sans nom")); m_context_cb_folio -> addItem(tr("Sans nom"));
} }
// If the text isn't yet to the autonum of the project, add this new item to the combo box. // If the text isn't yet to the autonum of the project, add this new item to the combo box.
else if ( !project_ -> folioAutoNum().keys().contains( m_context_cb_2->currentText())) { else if ( !project_ -> folioAutoNum().keys().contains( m_context_cb_folio->currentText())) {
project()->addFolioAutoNum(m_context_cb_2->currentText(), m_saw_2->toNumContext()); project()->addFolioAutoNum(m_context_cb_folio->currentText(), m_saw_folio->toNumContext());
m_context_cb_2 -> addItem(m_context_cb_2->currentText()); m_context_cb_folio -> addItem(m_context_cb_folio->currentText());
} }
// Else, the text already exist in the autonum of the project, just update the context // Else, the text already exist in the autonum of the project, just update the context
else { else {
project_->addFolioAutoNum (m_context_cb_2 -> currentText(), m_saw_2 -> toNumContext()); project_->addFolioAutoNum (m_context_cb_folio -> currentText(), m_saw_folio -> toNumContext());
} }
} }
/** /**
* @brief ProjectAutoNumConfigPage::saveContext_3 * @brief ProjectAutoNumConfigPage::saveContext_element
* Save the current displayed Element formula in project * Save the current displayed Element formula in project
*/ */
void ProjectAutoNumConfigPage::saveContext_3() { void ProjectAutoNumConfigPage::saveContext_element() {
project()->addElementAutoNum (m_eaw->formula());
// If the text is the default text "Name of new numerotation" save the edited context
// With the the name "No name"
if (m_context_cb_element -> currentText() == tr("Nom de la nouvelle numérotation")) {
project_->addElementAutoNum (tr("Sans nom"), m_saw_element -> toNumContext());
project()->addElementAutoNumFormula (m_context_cb_element->currentText(), m_saw_element->elementFormula()); //add hash <title, formula>
project()->addElementAutoNumCurrentFormula (m_saw_element->elementFormula()); //add last added element formula to current formula
m_context_cb_element -> addItem(tr("Sans nom"));
}
// If the text isn't yet to the autonum of the project, add this new item to the combo box.
else if ( !project_ -> elementAutoNum().keys().contains( m_context_cb_element->currentText())) {
project()->addElementAutoNum(m_context_cb_element->currentText(), m_saw_element->toNumContext()); //add hash <title, numcontext>
project()->addElementAutoNumFormula (m_context_cb_element->currentText(), m_saw_element->elementFormula()); //add hash <title, formula>
project()->addElementAutoNumCurrentFormula (m_saw_element->elementFormula()); //add last added element formula to current formula
m_context_cb_element -> addItem(m_context_cb_element->currentText());
}
// Else, the text already exist in the autonum of the project, just update the context
else {
project_->addElementAutoNum (m_context_cb_element -> currentText(), m_saw_element -> toNumContext()); //add hash <title, numcontext>
project()->addElementAutoNumFormula (m_context_cb_element->currentText(), m_saw_element->elementFormula()); //add hash <title, formula>
project()->addElementAutoNumCurrentFormula (m_saw_element->elementFormula()); //add last added element formula to current formula
}
} }
/** /**
@@ -499,22 +560,35 @@ void ProjectAutoNumConfigPage::applyAutoNum() {
* @brief ProjectAutoNumConfigPage::removeContext * @brief ProjectAutoNumConfigPage::removeContext
* Remove from project the current conductor numerotation context * Remove from project the current conductor numerotation context
*/ */
void ProjectAutoNumConfigPage::removeContext() { void ProjectAutoNumConfigPage::removeContext_conductor() {
//if default text, return //if default text, return
if ( m_context_cb -> currentText() == tr("Nom de la nouvelle numérotation") ) return; if ( m_context_cb_conductor-> currentText() == tr("Nom de la nouvelle numérotation") ) return;
project_ -> removeConductorAutonum (m_context_cb -> currentText() ); project_ -> removeConductorAutoNum (m_context_cb_conductor-> currentText() );
m_context_cb -> removeItem (m_context_cb -> currentIndex() ); m_context_cb_conductor-> removeItem (m_context_cb_conductor-> currentIndex() );
} }
/** /**
* @brief ProjectAutoNumConfigPage::removeContext_2 * @brief ProjectAutoNumConfigPage::removeContext_folio
* Remove from project the current folio numerotation context * Remove from project the current folio numerotation context
*/ */
void ProjectAutoNumConfigPage::removeContext_2() { void ProjectAutoNumConfigPage::removeContext_folio() {
//if default text, return //if default text, return
if ( m_context_cb_2 -> currentText() == tr("Nom de la nouvelle numérotation") ) return; if ( m_context_cb_folio -> currentText() == tr("Nom de la nouvelle numérotation") ) return;
project_ -> removeFolioAutoNum (m_context_cb_2 -> currentText() ); project_ -> removeFolioAutoNum (m_context_cb_folio -> currentText() );
m_context_cb_2 -> removeItem (m_context_cb_2 -> currentIndex() ); m_context_cb_folio -> removeItem (m_context_cb_folio -> currentIndex() );
} }
/**
* @brief ProjectAutoNumConfigPage::removeContext_element
* Remove from project the current element numerotation context
*/
void ProjectAutoNumConfigPage::removeContext_element() {
//if default text, return
if ( m_context_cb_element -> currentText() == tr("Nom de la nouvelle numérotation") ) return;
project_ -> removeElementAutoNum (m_context_cb_element -> currentText() );
m_context_cb_element -> removeItem (m_context_cb_element -> currentIndex() );
}
/** /**
* @brief ProjectAutoNumConfigPage::changeToTab * @brief ProjectAutoNumConfigPage::changeToTab
* @param tab index * @param tab index
@@ -535,7 +609,7 @@ void ProjectAutoNumConfigPage::tabChanged(int i){
tab_widget->resize(470,tab_widget->height()); tab_widget->resize(470,tab_widget->height());
} }
else { else {
tab_widget->resize(455,tab_widget->height()); tab_widget->resize(465,tab_widget->height());
} }
} }
} }

View File

@@ -141,13 +141,15 @@ class ProjectAutoNumConfigPage : public ProjectConfigPage {
private: private:
void buildConnections(); void buildConnections();
private slots: private slots:
void updateContext(QString); void updateContext_conductor(QString);//conductor
void saveContext(); void saveContext_conductor();
void removeContext(); //conductor void removeContext_conductor();
void updateContext_2(QString); void updateContext_folio(QString);//folio
void saveContext_2(); //folio void saveContext_folio();
void removeContext_2(); void removeContext_folio();
void saveContext_3(); //element void updateContext_element(QString);//element
void saveContext_element();
void removeContext_element();
void applyAutoNum(); void applyAutoNum();
@@ -167,14 +169,18 @@ class ProjectAutoNumConfigPage : public ProjectConfigPage {
QWidget *folio_tab_widget; QWidget *folio_tab_widget;
QWidget *autoNumbering_tab_widget; QWidget *autoNumbering_tab_widget;
QScrollArea *scrollArea; QScrollArea *scrollArea;
QLabel *m_label; QLabel *m_label_conductor;
QLabel *m_label_2; QLabel *m_label_folio;
QComboBox *m_context_cb; QLabel *m_label_element;
QComboBox *m_context_cb_2; QComboBox *m_context_cb_conductor;
QPushButton *m_remove_pb; QComboBox *m_context_cb_folio;
QPushButton *m_remove_pb_2; QComboBox *m_context_cb_element;
SelectAutonumW *m_saw; QPushButton *m_remove_pb_conductor;
SelectAutonumW *m_saw_2; QPushButton *m_remove_pb_folio;
QPushButton *m_remove_pb_element;
SelectAutonumW *m_saw_conductor;
SelectAutonumW *m_saw_folio;
SelectAutonumW *m_saw_element;
FolioAutonumberingW *m_faw; FolioAutonumberingW *m_faw;
ElementAutonumberingW *m_eaw; ElementAutonumberingW *m_eaw;

View File

@@ -309,8 +309,8 @@ void CustomElement::parseLabels() {
prefix = rxml.readElementText(); prefix = rxml.readElementText();
DiagramContext &dc = this->rElementInformations(); DiagramContext &dc = this->rElementInformations();
//if there is a formula to assign, assign it //if there is a formula to assign, assign it
if (!location().project()->elementAutoNum().isEmpty() && this->linkType()!=Element::Slave) { if (!location().project()->elementAutoNumFormula().isEmpty() && this->linkType()!=Element::Slave) {
QString formula = location().project()->elementAutoNum(); QString formula = location().project()->elementAutoNumFormula();
formula.replace("%prefix", prefix); formula.replace("%prefix", prefix);
dc.addValue("label", formula); dc.addValue("label", formula);
this->setTaggedText("label",formula); this->setTaggedText("label",formula);
@@ -336,8 +336,8 @@ void CustomElement::parseLabels() {
} }
//apply formula to specific label //apply formula to specific label
else if ((this->taggedText("label")!= NULL) && (location().projectId()!=-1) && else if ((this->taggedText("label")!= NULL) && (location().projectId()!=-1) &&
(!location().project()->elementAutoNum().isEmpty()) && (this->linkType()!=Element::Slave)) { (!location().project()->elementAutoNumFormula().isEmpty()) && (this->linkType()!=Element::Slave)) {
QString formula = location().project()->elementAutoNum(); QString formula = location().project()->elementAutoNumFormula();
DiagramContext &dc = this->rElementInformations(); DiagramContext &dc = this->rElementInformations();
QString prefix = this->taggedText("label")->toPlainText(); QString prefix = this->taggedText("label")->toPlainText();
formula.replace("%prefix", prefix); formula.replace("%prefix", prefix);

View File

@@ -26,6 +26,7 @@
#include "terminal.h" #include "terminal.h"
#include "PropertiesEditor/propertieseditordialog.h" #include "PropertiesEditor/propertieseditordialog.h"
#include "elementpropertieswidget.h" #include "elementpropertieswidget.h"
#include "numerotationcontextcommands.h"
/** /**
Constructeur pour un element sans scene ni parent Constructeur pour un element sans scene ni parent
@@ -677,3 +678,69 @@ QString Element::assignVariables(QString label, Element *elmt){
label.replace("%total", QString::number(elmt->diagram()->border_and_titleblock.folioTotal())); label.replace("%total", QString::number(elmt->diagram()->border_and_titleblock.folioTotal()));
return label; return label;
} }
/**
* @brief Element::assignSeq()
* Assign sequential values to element label
*/
void Element::assignSeq() {
DiagramContext &dc = this->rElementInformations();
QString formula = diagram()->project()->elementAutoNumFormula();
QHash <QString,QString> hash = diagram()->project()->elementAutoNum_2();
QString formula_name = hash.key(formula);
QString label = dc["label"].toString();
qDebug() << "Label" << label;
NumerotationContext nc = diagram()->project()->elementAutoNum(formula_name);
NumerotationContextCommands ncc (nc);
if (!nc.isEmpty()) {
if (label.contains("%sequ_")) {
int count = 1;
for (int i = 0; i < nc.size(); i++) {
if (nc.itemAt(i).at(0) == "unit") {
label.replace("%sequ_" + QString::number(count), QString::number(nc.itemAt(i).at(1).toInt()));
count++;
}
}
}
if (label.contains("%seqt_")) {
int count = 1;
for (int i = 0; i < nc.size(); i++) {
if (nc.itemAt(i).at(0) == "ten") {
label.replace("%seqt_" + QString::number(count), QString::number(nc.itemAt(i).at(1).toInt()));
count++;
}
}
}
if (label.contains("%seqh_")) {
int count = 1;
for (int i = 0; i < nc.size(); i++) {
if (nc.itemAt(i).at(0) == "hundred") {
label.replace("%seqh_" + QString::number(count), QString::number(nc.itemAt(i).at(1).toInt()));
count++;
}
}
}
}
dc.addValue("label",label);
this->diagram()->project()->addElementAutoNum(formula_name,ncc.next());
this->setElementInformations(dc);
this->setTaggedText("label", label);
}
/**
* @brief ElementTextItem::setTaggedText
* Set text @newstr to the text tagged with @tagg.
* If tagg is found return the text item, else return NULL.
* @param tagg required tagg
* @param newstr new label
* @param noeditable set editable or not (by default, set editable)
*/
ElementTextItem* Element::setTaggedText(const QString &tagg, const QString &newstr, const bool noeditable) {
ElementTextItem *eti = taggedText(tagg);
if (eti) {
eti -> setPlainText(newstr);
eti -> setNoEditable(noeditable);
}
return eti;
}

View File

@@ -118,6 +118,7 @@ class Element : public QetGraphicsItem {
QList <QUuid> tmp_uuids_link; QList <QUuid> tmp_uuids_link;
QUuid uuid_; QUuid uuid_;
kind link_type_; kind link_type_;
ElementTextItem* setTaggedText(const QString &tagg, const QString &newstr, const bool noeditable=false);
signals: signals:
void linkedElementChanged(); //This signal is emited when the linked elements with this element change void linkedElementChanged(); //This signal is emited when the linked elements with this element change
@@ -133,6 +134,7 @@ class Element : public QetGraphicsItem {
//about the herited class like contactelement for know //about the herited class like contactelement for know
// kind of contact (simple tempo) or number of contact show by the element. // kind of contact (simple tempo) or number of contact show by the element.
QString assignVariables (QString, Element *); QString assignVariables (QString, Element *);
void assignSeq ();
//ATTRIBUTES //ATTRIBUTES
protected: protected:

View File

@@ -128,7 +128,7 @@ void MasterElement::initLink(QETProject *project) {
*/ */
void MasterElement::changeElementInfo(){ void MasterElement::changeElementInfo(){
QString temp_label = this->elementInformations()["label"].toString(); QString temp_label = this->elementInformations()["label"].toString();
if (temp_label.contains("\%l")||temp_label.contains("\%c")||temp_label.contains("\%f")||temp_label.contains("\%F")) { if (temp_label.contains("\%")) {
if (this->diagram()!=NULL) if (this->diagram()!=NULL)
this->updateLabel(this->elementInformations(),this->elementInformations()); this->updateLabel(this->elementInformations(),this->elementInformations());
} }

View File

@@ -62,7 +62,7 @@ void SimpleElement::initLink(QETProject *project) {
*/ */
void SimpleElement::changeElementInfo(){ void SimpleElement::changeElementInfo(){
QString temp_label = this->elementInformations()["label"].toString(); QString temp_label = this->elementInformations()["label"].toString();
if (temp_label.contains("\%l")||temp_label.contains("\%c")||temp_label.contains("\%f")||temp_label.contains("\%F")) { if (temp_label.contains("\%")) {
if (this->diagram()!=NULL) if (this->diagram()!=NULL)
this->updateLabel(this->elementInformations(),this->elementInformations()); this->updateLabel(this->elementInformations(),this->elementInformations());
} }

View File

@@ -410,15 +410,42 @@ QHash <QString, NumerotationContext> QETProject::conductorAutoNum() const {
/** /**
* @brief QETProject::elementAutoNum * @brief QETProject::elementAutoNum
* @return Formula of element autonum stored in project * @return All value of element autonum stored in project
*/ */
QString QETProject::elementAutoNum() const { QHash <QString, NumerotationContext> QETProject::elementAutoNum() const {
return m_element_autonum; return m_element_autonum;
} }
/**
* @brief QETProject::elementAutoNum_2
* @return Title and Formula Hash
*/
QHash <QString, QString> QETProject::elementAutoNum_2() {
return m_element_autonum_formula;
}
/**
* @brief QETProject::elementAutoNumFormula
* @param element autonum title
* @return Formula of element autonum stored in element autonum
*/
QString QETProject::elementAutoNumFormula (QString key) const {
if (m_element_autonum.contains(key))
return m_element_autonum_formula[key];
else return "";
}
/**
* @brief QETProject::elementAutoNumFormula
* @return current formula being used by project
*/
QString QETProject::elementAutoNumFormula () const {
return m_current_element_formula;
}
/** /**
* @brief QETProject::folioAutoNum * @brief QETProject::folioAutoNum
* @return All value of conductor autonum stored in project * @return All value of folio autonum stored in project
*/ */
QHash <QString, NumerotationContext> QETProject::folioAutoNum() const { QHash <QString, NumerotationContext> QETProject::folioAutoNum() const {
return m_folio_autonum; return m_folio_autonum;
@@ -436,12 +463,33 @@ void QETProject::addConductorAutoNum(QString key, NumerotationContext context) {
} }
/** /**
* @brief QETProject::addElementAutoNum * @brief QETProject::addElementAutoNumFormula
* Add the new formula * Add the new formula
* @param formula * @param formula
*/ */
void QETProject::addElementAutoNum(QString formula) { void QETProject::addElementAutoNumFormula(QString key, QString formula) {
m_element_autonum = formula; m_element_autonum_formula.insert(key, formula);
}
/**
* @brief QETProject::addElementAutoNumCurrentFormula
* Add the formula to the current formula
* @param formula
*/
void QETProject::addElementAutoNumCurrentFormula(QString formula) {
m_current_element_formula = formula;
}
/**
* @brief QETProject::addElementAutoNum
* Add a new element numerotation context. If key already exist,
* replace old context by the new context
* @param key
* @param context
*/
void QETProject::addElementAutoNum(QString key, NumerotationContext context) {
m_element_autonum.insert(key, context);
} }
/** /**
@@ -456,14 +504,23 @@ void QETProject::addFolioAutoNum(QString key, NumerotationContext context) {
} }
/** /**
* @brief QETProject::removeConductorAutonum * @brief QETProject::removeConductorAutoNum
* Remove Conductor Numerotation Context stored with key * Remove Conductor Numerotation Context stored with key
* @param key * @param key
*/ */
void QETProject::removeConductorAutonum(QString key) { void QETProject::removeConductorAutoNum(QString key) {
m_conductor_autonum.remove(key); m_conductor_autonum.remove(key);
} }
/**
* @brief QETProject::removeElementAutonum
* Remove Element Numerotation Context stored with key
* @param key
*/
void QETProject::removeElementAutoNum(QString key) {
m_element_autonum.remove(key);
}
/** /**
* @brief QETProject::removeFolioAutonum * @brief QETProject::removeFolioAutonum
* Remove Folio Numerotation Context stored with key * Remove Folio Numerotation Context stored with key
@@ -484,6 +541,17 @@ NumerotationContext QETProject::conductorAutoNum (const QString &key) const {
else return NumerotationContext(); else return NumerotationContext();
} }
/**
* @brief QETProject::elementAutoNum
* Return element numerotation context stored with @key.
* If key is not found, return an empty numerotation context
* @param key
*/
NumerotationContext QETProject::elementAutoNum (const QString &key) const {
if (m_element_autonum.contains(key)) return m_element_autonum[key];
else return NumerotationContext();
}
/** /**
* @brief QETProject::folioAutoNum * @brief QETProject::folioAutoNum
* Return folio numerotation context stored with @key. * Return folio numerotation context stored with @key.
@@ -508,7 +576,7 @@ bool QETProject::autoConductor() const
/** /**
* @brief QETProject::autoFolio * @brief QETProject::autoFolio
* @return true if use of auto folio is authorized. * @return true if use of auto folio is authorized.
* See also Q_PROPERTY autoFolio * See also Q_PROPERTY autoConductor
*/ */
bool QETProject::autoFolio() const bool QETProject::autoFolio() const
{ {
@@ -531,7 +599,7 @@ void QETProject::setAutoConductor(bool ac)
* @brief QETProject::setAutoFolio * @brief QETProject::setAutoFolio
* @param ac * @param ac
* Enable the use of auto folio if true * Enable the use of auto folio if true
* See also Q_PROPERTY autoConductor * See also Q_PROPERTY autoFolio
*/ */
void QETProject::setAutoFolio(bool af) void QETProject::setAutoFolio(bool af)
{ {
@@ -1252,7 +1320,14 @@ void QETProject::readDefaultPropertiesXml(QDomDocument &xml_project)
} }
if (!element_autonums.isNull()) if (!element_autonums.isNull())
{ {
m_element_autonum = element_autonums.attribute("formula"); m_current_element_formula = element_autonums.attribute("current_formula");
foreach (QDomElement elmt, QET::findInDomElement(element_autonums, "element_autonum"))
{
NumerotationContext nc;
nc.fromXml(elmt);
m_element_autonum.insert(elmt.attribute("title"), nc);
m_element_autonum_formula.insert(elmt.attribute("title"),elmt.attribute("formula"));
}
} }
} }
@@ -1326,7 +1401,13 @@ void QETProject::writeDefaultPropertiesXml(QDomElement &xml_element) {
//Export Element Autonums //Export Element Autonums
QDomElement element_autonums = xml_document.createElement("element_autonums"); QDomElement element_autonums = xml_document.createElement("element_autonums");
element_autonums.setAttribute("formula", m_element_autonum); element_autonums.setAttribute("current_formula", m_current_element_formula);
foreach (QString key, elementAutoNum().keys()) {
QDomElement element_autonum = elementAutoNum(key).toXml(xml_document, "element_autonum");
element_autonum.setAttribute("title", key);
element_autonum.setAttribute("formula", elementAutoNumFormula(key));
element_autonums.appendChild(element_autonum);
}
xml_element.appendChild(element_autonums); xml_element.appendChild(element_autonums);
} }

View File

@@ -107,19 +107,28 @@ class QETProject : public QObject
void setDefaultXRefProperties(QHash <QString, XRefProperties> hash); void setDefaultXRefProperties(QHash <QString, XRefProperties> hash);
QHash <QString, NumerotationContext> conductorAutoNum() const; QHash <QString, NumerotationContext> conductorAutoNum() const;
QHash <QString, NumerotationContext> elementAutoNum() const;
QHash <QString, QString> elementAutoNum_2();
QHash <QString, NumerotationContext> folioAutoNum() const; QHash <QString, NumerotationContext> folioAutoNum() const;
void addConductorAutoNum (QString key, NumerotationContext context); void addConductorAutoNum (QString key, NumerotationContext context);
void addElementAutoNum (QString formula); void addElementAutoNum (QString key, NumerotationContext context);
void addElementAutoNumFormula (QString key, QString formula);
void addElementAutoNumCurrentFormula (QString formula);
void addFolioAutoNum (QString key, NumerotationContext context); void addFolioAutoNum (QString key, NumerotationContext context);
void removeConductorAutonum (QString key); void removeConductorAutoNum (QString key);
void removeElementAutoNum (QString key);
void removeFolioAutoNum (QString key); void removeFolioAutoNum (QString key);
NumerotationContext conductorAutoNum(const QString &key) const; NumerotationContext conductorAutoNum(const QString &key) const;
NumerotationContext folioAutoNum(const QString &key) const; NumerotationContext folioAutoNum(const QString &key) const;
QString elementAutoNum() const; NumerotationContext elementAutoNum(const QString &key) const;
QString elementAutoNumFormula(const QString key) const; //returns Formula
QString elementAutoNumFormula() const;
bool autoConductor () const; bool autoConductor () const;
bool autoElement () const;
bool autoFolio () const; bool autoFolio () const;
void setAutoConductor (bool ac); void setAutoConductor (bool ac);
void setAutoElement (bool ae);
void setAutoFolio (bool af); void setAutoFolio (bool af);
void autoFolioNumberingNewFolios (); void autoFolioNumberingNewFolios ();
void autoFolioNumberingSelectedFolios(int, int, QString); void autoFolioNumberingSelectedFolios(int, int, QString);
@@ -223,7 +232,9 @@ class QETProject : public QObject
/// Folio auto numbering /// Folio auto numbering
QHash <QString, NumerotationContext> m_folio_autonum; QHash <QString, NumerotationContext> m_folio_autonum;
/// Element Auto Numbering /// Element Auto Numbering
QString m_element_autonum; QHash <QString, QString> m_element_autonum_formula; //Title and Formula hash
QHash <QString, NumerotationContext> m_element_autonum; //Title and NumContext hash
QString m_current_element_formula;
/// Folio List Sheets quantity for this project. /// Folio List Sheets quantity for this project.
int folioSheetsQuantity; int folioSheetsQuantity;
bool m_auto_conductor; bool m_auto_conductor;

View File

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

View File

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

View File

@@ -6,19 +6,19 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>460</width> <width>383</width>
<height>550</height> <height>305</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum"> <sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>460</width> <width>0</width>
<height>0</height> <height>0</height>
</size> </size>
</property> </property>
@@ -30,92 +30,25 @@
<enum>QLayout::SetDefaultConstraint</enum> <enum>QLayout::SetDefaultConstraint</enum>
</property> </property>
<item> <item>
<widget class="QScrollArea" name="scrollArea"> <widget class="QGroupBox" name="groupBox">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding"> <sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<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>498</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </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"> <property name="title">
<string>Auto Naming Pattern:</string> <string>Auto Naming Pattern:</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout_4"> <layout class="QGridLayout" name="gridLayout">
<item row="0" column="1"> <item row="0" column="1">
<widget class="QLineEdit" name="m_formula_le"> <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"> <property name="inputMask">
<string notr="true"/> <string notr="true"/>
</property> </property>
@@ -129,12 +62,21 @@
</item> </item>
<item row="0" column="0"> <item row="0" column="0">
<widget class="QLabel" name="label_5"> <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"> <property name="text">
<string>Formula:</string> <string>Formula:</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="0" rowspan="2" colspan="3"> </layout>
</widget>
</item>
<item>
<widget class="QLabel" name="label"> <widget class="QLabel" name="label">
<property name="locale"> <property name="locale">
<locale language="French" country="France"/> <locale language="French" country="France"/>
@@ -148,29 +90,23 @@
-%f or %id: Folio ID -%f or %id: Folio ID
-%total: Total of folios -%total: Total of folios
You can also assign any other titleblock variable You can also assign any other titleblock variable
that you create. Text and number inputs are also available</string> that you create. Text and number inputs are
also available.</string>
</property> </property>
</widget> </widget>
</item> </item>
</layout>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item> <item>
<widget class="QDialogButtonBox" name="buttonBox"> <spacer name="verticalSpacer">
<property name="sizePolicy"> <property name="orientation">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed"> <enum>Qt::Vertical</enum>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property> </property>
<property name="standardButtons"> <property name="sizeHint" stdset="0">
<set>QDialogButtonBox::Apply</set> <size>
<width>20</width>
<height>40</height>
</size>
</property> </property>
</widget> </spacer>
</item> </item>
</layout> </layout>
</widget> </widget>

View File

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

View File

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

View File

@@ -6,20 +6,29 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>308</width> <width>368</width>
<height>45</height> <height>33</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>Form</string> <string>Form</string>
</property> </property>
<layout class="QHBoxLayout" name="horizontalLayout_2"> <layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="spacing">
<number>3</number>
</property>
<property name="leftMargin"> <property name="leftMargin">
<number>0</number> <number>0</number>
</property> </property>
<property name="topMargin">
<number>2</number>
</property>
<property name="rightMargin"> <property name="rightMargin">
<number>0</number> <number>0</number>
</property> </property>
<property name="bottomMargin">
<number>2</number>
</property>
<item> <item>
<widget class="QComboBox" name="type_combo"> <widget class="QComboBox" name="type_combo">
<property name="sizePolicy"> <property name="sizePolicy">
@@ -61,6 +70,21 @@
<string>Folio</string> <string>Folio</string>
</property> </property>
</item> </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> </widget>
</item> </item>
<item> <item>

View File

@@ -20,6 +20,9 @@
#include "numparteditorw.h" #include "numparteditorw.h"
#include <QMessageBox> #include <QMessageBox>
#include "numerotationcontextcommands.h" #include "numerotationcontextcommands.h"
#include "elementautonumberingw.h"
#include "ui_elementautonumberingw.h"
#include "qdebug.h"
/** /**
* Constructor * Constructor
@@ -28,7 +31,13 @@ SelectAutonumW::SelectAutonumW(QWidget *parent) :
QWidget(parent), QWidget(parent),
ui(new Ui::SelectAutonumW) ui(new Ui::SelectAutonumW)
{ {
ui->setupUi(this); 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()); setContext(NumerotationContext());
} }
@@ -36,6 +45,11 @@ SelectAutonumW::SelectAutonumW(const NumerotationContext &context, QWidget *pare
QWidget(parent), QWidget(parent),
ui(new Ui::SelectAutonumW) 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); ui->setupUi(this);
setContext(context); setContext(context);
} }
@@ -117,6 +131,14 @@ void SelectAutonumW::on_remove_button_clicked() {
applyEnable(); applyEnable();
} }
/**
* @brief SelectAutonumW::elementFormula
* @return element autonumbering widget formula
*/
QString SelectAutonumW::elementFormula() {
return m_eaw->formula();
}
/** /**
* @brief SelectAutonumW::on_buttonBox_clicked * @brief SelectAutonumW::on_buttonBox_clicked
* Action on @buttonBox clicked * Action on @buttonBox clicked
@@ -189,9 +211,57 @@ void SelectAutonumW::applyEnable(bool b) {
foreach (NumPartEditorW *npe, num_part_list_) if (!npe -> isValid()) valid= false; foreach (NumPartEditorW *npe, num_part_list_) if (!npe -> isValid()) valid= false;
ui -> buttonBox -> button(QDialogButtonBox::Apply) -> setEnabled(valid); ui -> buttonBox -> button(QDialogButtonBox::Apply) -> setEnabled(valid);
} }
else else {
ui -> buttonBox -> button(QDialogButtonBox::Apply) -> setEnabled(b); 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));
}
}
}
}
/** /**
* @brief SelectAutonumW::on_m_next_pb_clicked * @brief SelectAutonumW::on_m_next_pb_clicked

View File

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

View File

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