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

@@ -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());
}
}
}