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);
celmt->parseLabels();
}
elmt->updateLabel();
}
break;

View File

@@ -233,4 +233,6 @@ void DiagramEventAddElement::addElement()
can.numerate();
};
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
*/
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_);
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));
}
/**
* 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 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

View File

@@ -257,38 +257,51 @@ void ProjectAutoNumConfigPage::initWidgets() {
//Conductor Tab
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->setEditable(true);
m_context_cb->lineEdit()->setClearButtonEnabled(true);
m_context_cb->addItem(tr("Nom de la nouvelle numérotation"));
m_context_cb_conductor= new QComboBox(conductor_tab_widget);
m_context_cb_conductor->setEditable(true);
m_context_cb_conductor->lineEdit()->setClearButtonEnabled(true);
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 -> setToolTip(tr("Supprimer la numérotation"));
m_remove_pb_conductor= new QPushButton(QET::Icons::EditDelete, QString(), conductor_tab_widget);
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_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_widget = new QWidget(this);
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_2->setEditable(true);
m_context_cb_2->lineEdit()->setClearButtonEnabled(true);
m_context_cb_2->addItem(tr("Nom de la nouvelle numérotation"));
m_context_cb_folio = new QComboBox(folio_tab_widget);
m_context_cb_folio->setEditable(true);
m_context_cb_folio->lineEdit()->setClearButtonEnabled(true);
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_2 -> setToolTip(tr("Supprimer la numérotation"));
m_remove_pb_folio = new QPushButton(QET::Icons::EditDelete, QString(), folio_tab_widget);
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_widget = new QWidget(this);
@@ -304,42 +317,55 @@ void ProjectAutoNumConfigPage::initLayout() {
//Conductor Tab
tab_widget->addTab(conductor_tab_widget, tr("Conductor"));
QHBoxLayout *context_layout = new QHBoxLayout();
context_layout -> addWidget (m_label);
context_layout -> addWidget (m_context_cb);
context_layout -> addWidget (m_remove_pb);
QHBoxLayout *context_layout_conductor = new QHBoxLayout();
context_layout_conductor -> addWidget (m_label_conductor);
context_layout_conductor -> addWidget (m_context_cb_conductor);
context_layout_conductor -> addWidget (m_remove_pb_conductor);
QVBoxLayout *main_layout = new QVBoxLayout();
QVBoxLayout *aux_layout = new QVBoxLayout();
aux_layout->addLayout(context_layout);
aux_layout->addWidget(m_saw);
QVBoxLayout *main_layout_conductor = new QVBoxLayout();
QVBoxLayout *aux_layout_conductor = new QVBoxLayout();
aux_layout_conductor->addLayout(context_layout_conductor);
aux_layout_conductor->addWidget(m_saw_conductor);
main_layout->addLayout(aux_layout);
conductor_tab_widget -> setLayout (main_layout);
main_layout_conductor->addLayout(aux_layout_conductor);
conductor_tab_widget -> setLayout (main_layout_conductor);
//Element Tab
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
tab_widget->addTab(folio_tab_widget, tr("Folio"));
QHBoxLayout *context_layout_2 = new QHBoxLayout();
context_layout_2 -> addWidget (m_label_2);
context_layout_2 -> addWidget (m_context_cb_2);
context_layout_2 -> addWidget (m_remove_pb_2);
QHBoxLayout *context_layout_folio = new QHBoxLayout();
context_layout_folio -> addWidget (m_label_folio);
context_layout_folio -> addWidget (m_context_cb_folio);
context_layout_folio -> addWidget (m_remove_pb_folio);
QVBoxLayout *main_layout_2 = new QVBoxLayout();
QVBoxLayout *aux_layout_2 = new QVBoxLayout();
aux_layout_2->addLayout(context_layout_2);
aux_layout_2->addWidget(m_saw_2);
QVBoxLayout *main_layout_folio = new QVBoxLayout();
QVBoxLayout *aux_layout_folio = new QVBoxLayout();
aux_layout_folio->addLayout(context_layout_folio);
aux_layout_folio->addWidget(m_saw_folio);
main_layout_2->addLayout(aux_layout_2);
folio_tab_widget -> setLayout (main_layout_2);
main_layout_folio->addLayout(aux_layout_folio);
folio_tab_widget->setLayout(main_layout_folio);
//Auto Numbering Tab
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() {
//Conductor Tab
QList <QString> keys = project_->conductorAutoNum().keys();
if (!keys.isEmpty()){
foreach (QString str, keys) { m_context_cb -> addItem(str); }
QList <QString> keys_conductor = project_->conductorAutoNum().keys();
if (!keys_conductor.isEmpty()){
foreach (QString str, keys_conductor) { m_context_cb_conductor-> addItem(str); }
}
//Element Tab
if (!project_->elementAutoNum().isEmpty())
m_eaw->setContext(project_->elementAutoNum());
QList <QString> keys_element = project_->elementAutoNum().keys();
if (!keys_element.isEmpty()){
foreach (QString str, keys_element) { m_context_cb_element -> addItem(str);}
}
//Folio Tab
QList <QString> keys_2 = project_->folioAutoNum().keys();
if (!keys_2.isEmpty()){
foreach (QString str, keys_2) { m_context_cb_2 -> addItem(str);}
QList <QString> keys_folio = project_->folioAutoNum().keys();
if (!keys_folio.isEmpty()){
foreach (QString str, keys_folio) { m_context_cb_folio -> addItem(str);}
}
//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)));
//Conductor Tab
connect (m_context_cb, SIGNAL (currentIndexChanged(QString)), this, SLOT (updateContext(QString)));
connect (m_saw, SIGNAL (applyPressed()), this, SLOT (saveContext()));
connect (m_remove_pb, SIGNAL (clicked()), this, SLOT(removeContext()));
connect (m_context_cb_conductor, SIGNAL (currentIndexChanged(QString)), this, SLOT (updateContext_conductor(QString)));
connect (m_saw_conductor, SIGNAL (applyPressed()), this, SLOT (saveContext_conductor()));
connect (m_remove_pb_conductor, SIGNAL (clicked()), this, SLOT (removeContext_conductor()));
//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
connect (m_context_cb_2, SIGNAL (currentIndexChanged(QString)), this, SLOT (updateContext_2(QString)));
connect (m_saw_2, SIGNAL (applyPressed()), this, SLOT (saveContext_2()));
connect (m_remove_pb_2, SIGNAL (clicked()), this, SLOT (removeContext_2()));
connect (m_context_cb_folio, SIGNAL (currentIndexChanged(QString)), this, SLOT (updateContext_folio(QString)));
connect (m_saw_folio, SIGNAL (applyPressed()), this, SLOT (saveContext_folio()));
connect (m_remove_pb_folio, SIGNAL (clicked()), this, SLOT (removeContext_folio()));
// Auto Folio Numbering
connect (m_faw, SIGNAL (applyPressed()), this, SLOT (applyAutoNum()));
}
/**
* @brief ProjectAutoNumConfigPage::updateContext
* @brief ProjectAutoNumConfigPage::updateContext_conductor
* Display the current selected context for conductor
* @param str, key of context stored in project
*/
void ProjectAutoNumConfigPage::updateContext(QString str) {
if (str == tr("Nom de la nouvelle numérotation")) m_saw -> setContext(NumerotationContext());
else m_saw ->setContext(project_->conductorAutoNum(str));
void ProjectAutoNumConfigPage::updateContext_conductor(QString str) {
if (str == tr("Nom de la nouvelle numérotation")) m_saw_conductor -> setContext(NumerotationContext());
else m_saw_conductor ->setContext(project_->conductorAutoNum(str));
}
/**
* @brief ProjectAutoNumConfigPage::updateContext_2
* @brief ProjectAutoNumConfigPage::updateContext_folio
* Display the current selected context for folio
* @param str, key of context stored in project
*/
void ProjectAutoNumConfigPage::updateContext_2(QString str) {
if (str == tr("Nom de la nouvelle numérotation")) m_saw_2 -> setContext(NumerotationContext());
else m_saw_2 ->setContext(project_->folioAutoNum(str));
void ProjectAutoNumConfigPage::updateContext_folio(QString str) {
if (str == tr("Nom de la nouvelle numérotation")) m_saw_folio -> setContext(NumerotationContext());
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
*/
void ProjectAutoNumConfigPage::saveContext() {
void ProjectAutoNumConfigPage::saveContext_conductor() {
// 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 -> currentText() == tr("Nom de la nouvelle numérotation")) {
project_->addConductorAutoNum (tr("Sans nom"), m_saw -> toNumContext());
m_context_cb -> addItem(tr("Sans nom"));
if (m_context_cb_conductor-> currentText() == tr("Nom de la nouvelle numérotation")) {
project_->addConductorAutoNum (tr("Sans nom"), m_saw_conductor -> toNumContext());
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.
else if ( !project_ -> conductorAutoNum().keys().contains( m_context_cb->currentText())) {
project()->addConductorAutoNum(m_context_cb->currentText(), m_saw->toNumContext());
m_context_cb -> addItem(m_context_cb->currentText());
else if ( !project_ -> conductorAutoNum().keys().contains( m_context_cb_conductor->currentText())) {
project()->addConductorAutoNum(m_context_cb_conductor->currentText(), m_saw_conductor->toNumContext());
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 {
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
*/
void ProjectAutoNumConfigPage::saveContext_2() {
void ProjectAutoNumConfigPage::saveContext_folio() {
// 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_2 -> currentText() == tr("Nom de la nouvelle numérotation")) {
project_->addFolioAutoNum (tr("Sans nom"), m_saw_2 -> toNumContext());
m_context_cb_2 -> addItem(tr("Sans nom"));
if (m_context_cb_folio -> currentText() == tr("Nom de la nouvelle numérotation")) {
project_->addFolioAutoNum (tr("Sans nom"), m_saw_folio -> toNumContext());
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.
else if ( !project_ -> folioAutoNum().keys().contains( m_context_cb_2->currentText())) {
project()->addFolioAutoNum(m_context_cb_2->currentText(), m_saw_2->toNumContext());
m_context_cb_2 -> addItem(m_context_cb_2->currentText());
else if ( !project_ -> folioAutoNum().keys().contains( m_context_cb_folio->currentText())) {
project()->addFolioAutoNum(m_context_cb_folio->currentText(), m_saw_folio->toNumContext());
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 {
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
*/
void ProjectAutoNumConfigPage::saveContext_3() {
project()->addElementAutoNum (m_eaw->formula());
void ProjectAutoNumConfigPage::saveContext_element() {
// 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
* Remove from project the current conductor numerotation context
*/
void ProjectAutoNumConfigPage::removeContext() {
void ProjectAutoNumConfigPage::removeContext_conductor() {
//if default text, return
if ( m_context_cb -> currentText() == tr("Nom de la nouvelle numérotation") ) return;
project_ -> removeConductorAutonum (m_context_cb -> currentText() );
m_context_cb -> removeItem (m_context_cb -> currentIndex() );
if ( m_context_cb_conductor-> currentText() == tr("Nom de la nouvelle numérotation") ) return;
project_ -> removeConductorAutoNum (m_context_cb_conductor-> currentText() );
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
*/
void ProjectAutoNumConfigPage::removeContext_2() {
void ProjectAutoNumConfigPage::removeContext_folio() {
//if default text, return
if ( m_context_cb_2 -> currentText() == tr("Nom de la nouvelle numérotation") ) return;
project_ -> removeFolioAutoNum (m_context_cb_2 -> currentText() );
m_context_cb_2 -> removeItem (m_context_cb_2 -> currentIndex() );
if ( m_context_cb_folio -> currentText() == tr("Nom de la nouvelle numérotation") ) return;
project_ -> removeFolioAutoNum (m_context_cb_folio -> currentText() );
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
* @param tab index
@@ -535,7 +609,7 @@ void ProjectAutoNumConfigPage::tabChanged(int i){
tab_widget->resize(470,tab_widget->height());
}
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:
void buildConnections();
private slots:
void updateContext(QString);
void saveContext();
void removeContext(); //conductor
void updateContext_2(QString);
void saveContext_2(); //folio
void removeContext_2();
void saveContext_3(); //element
void updateContext_conductor(QString);//conductor
void saveContext_conductor();
void removeContext_conductor();
void updateContext_folio(QString);//folio
void saveContext_folio();
void removeContext_folio();
void updateContext_element(QString);//element
void saveContext_element();
void removeContext_element();
void applyAutoNum();
@@ -167,14 +169,18 @@ class ProjectAutoNumConfigPage : public ProjectConfigPage {
QWidget *folio_tab_widget;
QWidget *autoNumbering_tab_widget;
QScrollArea *scrollArea;
QLabel *m_label;
QLabel *m_label_2;
QComboBox *m_context_cb;
QComboBox *m_context_cb_2;
QPushButton *m_remove_pb;
QPushButton *m_remove_pb_2;
SelectAutonumW *m_saw;
SelectAutonumW *m_saw_2;
QLabel *m_label_conductor;
QLabel *m_label_folio;
QLabel *m_label_element;
QComboBox *m_context_cb_conductor;
QComboBox *m_context_cb_folio;
QComboBox *m_context_cb_element;
QPushButton *m_remove_pb_conductor;
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;
ElementAutonumberingW *m_eaw;

View File

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

View File

@@ -26,6 +26,7 @@
#include "terminal.h"
#include "PropertiesEditor/propertieseditordialog.h"
#include "elementpropertieswidget.h"
#include "numerotationcontextcommands.h"
/**
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()));
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;
QUuid uuid_;
kind link_type_;
ElementTextItem* setTaggedText(const QString &tagg, const QString &newstr, const bool noeditable=false);
signals:
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
// kind of contact (simple tempo) or number of contact show by the element.
QString assignVariables (QString, Element *);
void assignSeq ();
//ATTRIBUTES
protected:

View File

@@ -128,7 +128,7 @@ void MasterElement::initLink(QETProject *project) {
*/
void MasterElement::changeElementInfo(){
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)
this->updateLabel(this->elementInformations(),this->elementInformations());
}

View File

@@ -62,7 +62,7 @@ void SimpleElement::initLink(QETProject *project) {
*/
void SimpleElement::changeElementInfo(){
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)
this->updateLabel(this->elementInformations(),this->elementInformations());
}

View File

@@ -410,15 +410,42 @@ QHash <QString, NumerotationContext> QETProject::conductorAutoNum() const {
/**
* @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;
}
/**
* @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
* @return All value of conductor autonum stored in project
* @return All value of folio autonum stored in project
*/
QHash <QString, NumerotationContext> QETProject::folioAutoNum() const {
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
* @param formula
*/
void QETProject::addElementAutoNum(QString formula) {
m_element_autonum = formula;
void QETProject::addElementAutoNumFormula(QString key, QString 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
* @param key
*/
void QETProject::removeConductorAutonum(QString key) {
void QETProject::removeConductorAutoNum(QString 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
* Remove Folio Numerotation Context stored with key
@@ -484,6 +541,17 @@ NumerotationContext QETProject::conductorAutoNum (const QString &key) const {
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
* Return folio numerotation context stored with @key.
@@ -508,7 +576,7 @@ bool QETProject::autoConductor() const
/**
* @brief QETProject::autoFolio
* @return true if use of auto folio is authorized.
* See also Q_PROPERTY autoFolio
* See also Q_PROPERTY autoConductor
*/
bool QETProject::autoFolio() const
{
@@ -531,7 +599,7 @@ void QETProject::setAutoConductor(bool ac)
* @brief QETProject::setAutoFolio
* @param ac
* Enable the use of auto folio if true
* See also Q_PROPERTY autoConductor
* See also Q_PROPERTY autoFolio
*/
void QETProject::setAutoFolio(bool af)
{
@@ -1252,7 +1320,14 @@ void QETProject::readDefaultPropertiesXml(QDomDocument &xml_project)
}
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
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);
}

View File

@@ -107,19 +107,28 @@ class QETProject : public QObject
void setDefaultXRefProperties(QHash <QString, XRefProperties> hash);
QHash <QString, NumerotationContext> conductorAutoNum() const;
QHash <QString, NumerotationContext> elementAutoNum() const;
QHash <QString, QString> elementAutoNum_2();
QHash <QString, NumerotationContext> folioAutoNum() const;
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 removeConductorAutonum (QString key);
void removeConductorAutoNum (QString key);
void removeElementAutoNum (QString key);
void removeFolioAutoNum (QString key);
NumerotationContext conductorAutoNum(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 autoElement () const;
bool autoFolio () const;
void setAutoConductor (bool ac);
void setAutoElement (bool ae);
void setAutoFolio (bool af);
void autoFolioNumberingNewFolios ();
void autoFolioNumberingSelectedFolios(int, int, QString);
@@ -223,7 +232,9 @@ class QETProject : public QObject
/// Folio auto numbering
QHash <QString, NumerotationContext> m_folio_autonum;
/// 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.
int folioSheetsQuantity;
bool m_auto_conductor;

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,92 +30,25 @@
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<item>
<widget class="QScrollArea" name="scrollArea">
<widget class="QGroupBox" name="groupBox">
<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>498</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<sizepolicy hsizetype="Minimum" 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">
<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>
@@ -129,12 +62,21 @@
</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>
<item row="1" column="0" rowspan="2" colspan="3">
</layout>
</widget>
</item>
<item>
<widget class="QLabel" name="label">
<property name="locale">
<locale language="French" country="France"/>
@@ -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>
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>
<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,9 +211,57 @@ 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));
}
}
}
}
/**
* @brief SelectAutonumW::on_m_next_pb_clicked

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>