[qet] qet/qet: [4792] Revamp, and minor improvement about element autonum / formula. |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/qet Archives
]
Revision: 4792
Author: blacksun
Date: 2016-11-26 18:12:31 +0100 (Sat, 26 Nov 2016)
Log Message:
-----------
Revamp, and minor improvement about element autonum / formula.
Modified Paths:
--------------
trunk/sources/autoNum/ui/autonumberingdockwidget.cpp
trunk/sources/autoNum/ui/autonumberingdockwidget.h
trunk/sources/projectconfigpages.cpp
trunk/sources/projectconfigpages.h
trunk/sources/qetproject.cpp
trunk/sources/qetproject.h
Modified: trunk/sources/autoNum/ui/autonumberingdockwidget.cpp
===================================================================
--- trunk/sources/autoNum/ui/autonumberingdockwidget.cpp 2016-11-24 16:45:55 UTC (rev 4791)
+++ trunk/sources/autoNum/ui/autonumberingdockwidget.cpp 2016-11-26 17:12:31 UTC (rev 4792)
@@ -31,7 +31,7 @@
AutoNumberingDockWidget::AutoNumberingDockWidget(QWidget *parent, QETProject *project) :
QDockWidget(parent),
ui(new Ui::AutoNumberingDockWidget),
- project_(project)
+ m_project(project)
{
ui->setupUi(this);
}
@@ -65,30 +65,30 @@
*/
void AutoNumberingDockWidget::setProject(QETProject *project, ProjectView *projectview) {
- project_ = project;
- projectview_ = projectview;
+ m_project = project;
+ m_project_view = projectview;
//Conductor Signals
- connect(project_, SIGNAL(conductorAutoNumChanged()),this,SLOT(conductorAutoNumChanged()));
- connect (project_,SIGNAL(conductorAutoNumRemoved()), this,SLOT(conductorAutoNumChanged()));
- connect (project_,SIGNAL(conductorAutoNumAdded()), this,SLOT(conductorAutoNumChanged()));
- connect(projectview_,SIGNAL(diagramActivated(DiagramView*)),this,SLOT(setConductorActive(DiagramView*)));
+ connect(m_project, SIGNAL(conductorAutoNumChanged()),this,SLOT(conductorAutoNumChanged()));
+ connect (m_project,SIGNAL(conductorAutoNumRemoved()), this,SLOT(conductorAutoNumChanged()));
+ connect (m_project,SIGNAL(conductorAutoNumAdded()), this,SLOT(conductorAutoNumChanged()));
+ connect(m_project_view,SIGNAL(diagramActivated(DiagramView*)),this,SLOT(setConductorActive(DiagramView*)));
//Element Signals
- connect (project_,SIGNAL(elementAutoNumRemoved()), this,SLOT(elementAutoNumChanged()));
- connect (project_,SIGNAL(elementAutoNumAdded()), this,SLOT(elementAutoNumChanged()));
+ connect (m_project,SIGNAL(elementAutoNumRemoved(QString)), this,SLOT(elementAutoNumChanged()));
+ connect (m_project,SIGNAL(elementAutoNumAdded(QString)), this,SLOT(elementAutoNumChanged()));
//Folio Signals
- connect (project_,SIGNAL(folioAutoNumRemoved()), this,SLOT(folioAutoNumChanged()));
- connect (project_,SIGNAL(folioAutoNumAdded()), this,SLOT(folioAutoNumChanged()));
+ connect (m_project,SIGNAL(folioAutoNumRemoved()), this,SLOT(folioAutoNumChanged()));
+ connect (m_project,SIGNAL(folioAutoNumAdded()), this,SLOT(folioAutoNumChanged()));
connect (this,
SIGNAL(folioAutoNumChanged(QString)),
- &projectview_->currentDiagram()->diagram()->border_and_titleblock,
+ &m_project_view->currentDiagram()->diagram()->border_and_titleblock,
SLOT (slot_setAutoPageNum(QString)));
- connect(project_, SIGNAL(defaultTitleBlockPropertiesChanged()),this,SLOT(setActive()));
+ connect(m_project, SIGNAL(defaultTitleBlockPropertiesChanged()),this,SLOT(setActive()));
//Conductor, Element and Folio Signals
- connect(projectview_,SIGNAL(projectClosed(ProjectView*)),this,SLOT(clear()));
+ connect(m_project_view,SIGNAL(projectClosed(ProjectView*)),this,SLOT(clear()));
//Set Combobox Context
setContext();
@@ -104,7 +104,7 @@
//Conductor Combobox
ui->m_conductor_cb->addItem("");
- QList <QString> keys_conductor = project_->conductorAutoNum().keys();
+ QList <QString> keys_conductor = m_project->conductorAutoNum().keys();
if (!keys_conductor.isEmpty()) {
foreach (QString str, keys_conductor) { ui->m_conductor_cb-> addItem(str); }
}
@@ -111,7 +111,7 @@
//Element Combobox
ui->m_element_cb->addItem("");
- QList <QString> keys_element = project_->elementAutoNum().keys();
+ QList <QString> keys_element = m_project->elementAutoNum().keys();
if (!keys_element.isEmpty()) {
foreach (QString str, keys_element) {ui->m_element_cb -> addItem(str);}
}
@@ -118,7 +118,7 @@
//Folio Combobox
ui->m_folio_cb->addItem("");
- QList <QString> keys_folio = project_->folioAutoNum().keys();
+ QList <QString> keys_folio = m_project->folioAutoNum().keys();
if (!keys_folio.isEmpty()) {
foreach (QString str, keys_folio) { ui->m_folio_cb -> addItem(str);}
}
@@ -144,23 +144,23 @@
*/
void AutoNumberingDockWidget::setActive() {
- if (projectview_!=NULL) {
+ if (m_project_view!=NULL) {
//Conductor
- if (projectview_->currentDiagram()) {
- QString conductor_autonum = projectview_->currentDiagram()->diagram()->conductorsAutonumName();
+ if (m_project_view->currentDiagram()) {
+ QString conductor_autonum = m_project_view->currentDiagram()->diagram()->conductorsAutonumName();
int conductor_index = ui->m_conductor_cb->findText(conductor_autonum);
ui->m_conductor_cb->setCurrentIndex(conductor_index);
}
//Element
- QString element_formula = project_->elementAutoNumCurrentFormula();
- QString active_element_autonum = project_->elementCurrentAutoNum();
+ QString element_formula = m_project->elementAutoNumCurrentFormula();
+ QString active_element_autonum = m_project->elementCurrentAutoNum();
int el_index = ui->m_element_cb->findText(active_element_autonum);
ui->m_element_cb->setCurrentIndex(el_index);
//Folio
- if (project_->defaultTitleBlockProperties().folio == "%autonum") {
- QString page_autonum = project_->defaultTitleBlockProperties().auto_page_num;
+ if (m_project->defaultTitleBlockProperties().folio == "%autonum") {
+ QString page_autonum = m_project->defaultTitleBlockProperties().auto_page_num;
int folio_index = ui->m_folio_cb->findText(page_autonum);
ui->m_folio_cb->setCurrentIndex(folio_index);
}
@@ -172,12 +172,11 @@
* Add new or remove conductor auto num from combobox
*/
void AutoNumberingDockWidget::conductorAutoNumChanged() {
-
ui->m_conductor_cb->clear();
//Conductor Combobox
ui->m_conductor_cb->addItem("");
- QList <QString> keys_conductor = project_->conductorAutoNum().keys();
+ QList <QString> keys_conductor = m_project->conductorAutoNum().keys();
if (!keys_conductor.isEmpty()) {
foreach (QString str, keys_conductor) { ui->m_conductor_cb-> addItem(str); }
}
@@ -189,16 +188,20 @@
* @param unused
* Set new conductor AutoNum
*/
-void AutoNumberingDockWidget::on_m_conductor_cb_activated(int) {
+void AutoNumberingDockWidget::on_m_conductor_cb_activated(int)
+{
QString current_autonum = ui->m_conductor_cb->currentText();
- QString current_formula = project_->conductorAutoNumFormula(current_autonum);
- if (current_autonum != "") {
- project_->setConductorAutoNumCurrentFormula(current_formula, current_autonum);
+ QString current_formula = m_project->conductorAutoNumFormula(current_autonum);
+
+ if (!current_autonum.isEmpty()) {
+ m_project->setConductorAutoNumCurrentFormula(current_formula, current_autonum);
}
- else
- project_->setConductorAutoNumCurrentFormula("","");
- projectview_->currentDiagram()->diagram()->setConductorsAutonumName(current_autonum);
- projectview_->currentDiagram()->diagram()->loadCndFolioSeq();
+ else {
+ m_project->setConductorAutoNumCurrentFormula("","");
+ }
+
+ m_project_view->currentDiagram()->diagram()->setConductorsAutonumName(current_autonum);
+ m_project_view->currentDiagram()->diagram()->loadCndFolioSeq();
}
/**
@@ -211,7 +214,7 @@
//Element Combobox
ui->m_element_cb->addItem("");
- QList <QString> keys_element = project_->elementAutoNum().keys();
+ QList <QString> keys_element = m_project->elementAutoNum().keys();
if (!keys_element.isEmpty()) {
foreach (QString str, keys_element) {ui->m_element_cb -> addItem(str);}
}
@@ -223,15 +226,10 @@
* @param unused
* Set new element AutoNum
*/
-void AutoNumberingDockWidget::on_m_element_cb_activated(int) {
- QString current_autonum = ui->m_element_cb->currentText();
- QString current_formula = project_->elementAutoNumFormula(current_autonum);
- if (current_autonum != "") {
- project_->setElementAutoNumCurrentFormula(current_formula, current_autonum);
- }
- else
- project_->setElementAutoNumCurrentFormula("","");
- projectview_->currentDiagram()->diagram()->loadElmtFolioSeq();
+void AutoNumberingDockWidget::on_m_element_cb_activated(int)
+{
+ m_project->setCurrrentElementAutonum(ui->m_element_cb->currentText());
+ m_project_view->currentDiagram()->diagram()->loadElmtFolioSeq();
}
/**
@@ -244,7 +242,7 @@
//Folio Combobox
ui->m_folio_cb->addItem("");
- QList <QString> keys_folio = project_->folioAutoNum().keys();
+ QList <QString> keys_folio = m_project->folioAutoNum().keys();
if (!keys_folio.isEmpty()) {
foreach (QString str, keys_folio) { ui->m_folio_cb -> addItem(str);}
}
@@ -258,15 +256,15 @@
*/
void AutoNumberingDockWidget::on_m_folio_cb_activated(int) {
QString current_autonum = ui->m_folio_cb->currentText();
- TitleBlockProperties ip = project_ -> defaultTitleBlockProperties();
+ TitleBlockProperties ip = m_project -> defaultTitleBlockProperties();
if (current_autonum != "") {
ip.setAutoPageNum(current_autonum);
ip.folio = "%autonum";
- project_->setDefaultTitleBlockProperties(ip);
+ m_project->setDefaultTitleBlockProperties(ip);
}
else {
ip.folio = "%id/%total";
- project_->setDefaultTitleBlockProperties(ip);
+ m_project->setDefaultTitleBlockProperties(ip);
}
emit(folioAutoNumChanged(current_autonum));
}
Modified: trunk/sources/autoNum/ui/autonumberingdockwidget.h
===================================================================
--- trunk/sources/autoNum/ui/autonumberingdockwidget.h 2016-11-24 16:45:55 UTC (rev 4791)
+++ trunk/sources/autoNum/ui/autonumberingdockwidget.h 2016-11-26 17:12:31 UTC (rev 4792)
@@ -55,8 +55,8 @@
private:
Ui::AutoNumberingDockWidget *ui;
- QETProject* project_;
- ProjectView* projectview_;
+ QETProject* m_project;
+ ProjectView* m_project_view;
};
Modified: trunk/sources/projectconfigpages.cpp
===================================================================
--- trunk/sources/projectconfigpages.cpp 2016-11-24 16:45:55 UTC (rev 4791)
+++ trunk/sources/projectconfigpages.cpp 2016-11-26 17:12:31 UTC (rev 4792)
@@ -39,7 +39,7 @@
*/
ProjectConfigPage::ProjectConfigPage(QETProject *project, QWidget *parent) :
ConfigPage(parent),
- project_(project)
+ m_project(project)
{
}
@@ -53,7 +53,7 @@
@return the project being edited by this page
*/
QETProject *ProjectConfigPage::project() const {
- return(project_);
+ return(m_project);
}
/**
@@ -62,11 +62,11 @@
@return the former project
*/
QETProject *ProjectConfigPage::setProject(QETProject *new_project, bool read_values) {
- if (new_project == project_) return(project_);
+ if (new_project == m_project) return(m_project);
- QETProject *former_project = project_;
- project_ = new_project;
- if (project_ && read_values) {
+ QETProject *former_project = m_project;
+ m_project = new_project;
+ if (m_project && read_values) {
readValuesFromProject();
adjustReadOnly();
}
@@ -77,7 +77,7 @@
Apply the configuration after user input
*/
void ProjectConfigPage::applyConf() {
- if (!project_ || project_ -> isReadOnly()) return;
+ if (!m_project || m_project -> isReadOnly()) return;
applyProjectConf();
}
@@ -89,7 +89,7 @@
void ProjectConfigPage::init() {
initWidgets();
initLayout();
- if (project_) {
+ if (m_project) {
readValuesFromProject();
adjustReadOnly();
}
@@ -135,18 +135,18 @@
bool modified_project = false;
QString new_title = title_value_ -> text();
- if (project_ -> title() != new_title) {
- project_ -> setTitle(new_title);
+ if (m_project -> title() != new_title) {
+ m_project -> setTitle(new_title);
modified_project = true;
}
DiagramContext new_properties = project_variables_ -> context();
- if (project_ -> projectProperties() != new_properties) {
- project_ -> setProjectProperties(new_properties);
+ if (m_project -> projectProperties() != new_properties) {
+ m_project -> setProjectProperties(new_properties);
modified_project = true;
}
if (modified_project) {
- project_ -> setModified(true);
+ m_project -> setModified(true);
}
}
@@ -197,8 +197,8 @@
Read properties from the edited project then fill widgets with them.
*/
void ProjectMainConfigPage::readValuesFromProject() {
- title_value_ -> setText(project_ -> title());
- project_variables_ -> setContext(project_ -> projectProperties());
+ title_value_ -> setText(m_project -> title());
+ project_variables_ -> setContext(m_project -> projectProperties());
}
/**
@@ -206,7 +206,7 @@
editable if the project is editable.
*/
void ProjectMainConfigPage::adjustReadOnly() {
- bool is_read_only = project_ -> isReadOnly();
+ bool is_read_only = m_project -> isReadOnly();
title_value_ -> setReadOnly(is_read_only);
}
@@ -383,19 +383,19 @@
*/
void ProjectAutoNumConfigPage::readValuesFromProject() {
//Conductor Tab
- QList <QString> keys_conductor = project_->conductorAutoNum().keys();
+ QList <QString> keys_conductor = m_project->conductorAutoNum().keys();
if (!keys_conductor.isEmpty()){
foreach (QString str, keys_conductor) { m_context_cb_conductor-> addItem(str); }
}
//Element Tab
- QList <QString> keys_element = project_->elementAutoNum().keys();
+ QList <QString> keys_element = m_project->elementAutoNum().keys();
if (!keys_element.isEmpty()){
foreach (QString str, keys_element) { m_context_cb_element -> addItem(str);}
}
//Folio Tab
- QList <QString> keys_folio = project_->folioAutoNum().keys();
+ QList <QString> keys_folio = m_project->folioAutoNum().keys();
if (!keys_folio.isEmpty()){
foreach (QString str, keys_folio) { m_context_cb_folio -> addItem(str);}
}
@@ -428,11 +428,11 @@
connect (m_saw_conductor, SIGNAL (applyPressed()), this, SLOT (saveContext_conductor()));
connect (m_remove_pb_conductor, SIGNAL (clicked()), this, SLOT (removeContext_conductor()));
- //Element Tab
+ //Element Tab
connect (m_context_cb_element, SIGNAL (currentTextChanged(QString)), m_saw_element, SLOT(applyEnableOnContextChanged(QString)));
- 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()));
+ connect (m_context_cb_element, SIGNAL (currentIndexChanged(QString)), this, SLOT (updateContextElement(QString)));
+ connect (m_saw_element, SIGNAL (applyPressed()), this, SLOT (saveContextElement()));
+ connect (m_remove_pb_element, SIGNAL (clicked()), this, SLOT (removeContextElement()));
//Folio Tab
connect (m_context_cb_folio, SIGNAL (currentTextChanged(QString)), m_saw_folio, SLOT(applyEnableOnContextChanged(QString)));
@@ -451,7 +451,7 @@
*/
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));
+ else m_saw_conductor ->setContext(m_project->conductorAutoNum(str));
}
/**
@@ -461,20 +461,71 @@
*/
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));
+ else m_saw_folio ->setContext(m_project->folioAutoNum(str));
}
/**
- * @brief ProjectAutoNumConfigPage::updateContext_element
+ * @brief ProjectAutoNumConfigPage::updateContextElement
* 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));
+void ProjectAutoNumConfigPage::updateContextElement(QString str)
+{
+ if (str == tr("Nom de la nouvelle numérotation"))
+ {
+ m_saw_element->setContext(NumerotationContext());
+ }
+ else
+ {
+ m_saw_element->setContext(m_project->elementAutoNum(str));
+ }
}
/**
+ * @brief ProjectAutoNumConfigPage::saveContextElement
+ * Save the current displayed Element formula in project
+ */
+void ProjectAutoNumConfigPage::saveContextElement()
+{
+ // 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"))
+ {
+ QString title(tr("Sans nom"));
+
+ m_project->addElementAutoNum (title, m_saw_element -> toNumContext());
+ m_project->setCurrrentElementAutonum(title);
+ 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 ( !m_project -> elementAutoNum().keys().contains( m_context_cb_element->currentText()))
+ {
+ m_project->addElementAutoNum(m_context_cb_element->currentText(), m_saw_element->toNumContext());
+ m_project->setCurrrentElementAutonum(m_context_cb_element->currentText());
+ 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
+ {
+ m_project->addElementAutoNum (m_context_cb_element -> currentText(), m_saw_element -> toNumContext());
+ m_project->setCurrrentElementAutonum(m_context_cb_element->currentText());
+ }
+}
+
+/**
+ * @brief ProjectAutoNumConfigPage::removeContextElement
+ * Remove from project the current element numerotation context
+ */
+void ProjectAutoNumConfigPage::removeContextElement()
+{
+ //if default text, return
+ if (m_context_cb_element->currentText() == tr("Nom de la nouvelle numérotation"))
+ return;
+ m_project->removeElementAutoNum (m_context_cb_element->currentText());
+ m_context_cb_element->removeItem (m_context_cb_element->currentIndex());
+}
+
+/**
* @brief ProjectAutoNumConfigPage::saveContext_conductor
* Save the current displayed conductor context in project
*/
@@ -482,13 +533,13 @@
// 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_conductor-> currentText() == tr("Nom de la nouvelle numérotation")) {
- project_->addConductorAutoNum (tr("Sans nom"), m_saw_conductor -> toNumContext());
+ m_project->addConductorAutoNum (tr("Sans nom"), m_saw_conductor -> toNumContext());
project()->addConductorAutoNumFormula (tr("Sans nom"), m_saw_conductor->formula()); //add hash <title, formula>
project()->setConductorAutoNumCurrentFormula (m_saw_conductor->formula(),tr("Sans nom")); //add last added conductor formula to current formula
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_conductor->currentText())) {
+ else if ( !m_project -> conductorAutoNum().keys().contains( m_context_cb_conductor->currentText())) {
project()->addConductorAutoNum(m_context_cb_conductor->currentText(), m_saw_conductor->toNumContext());
project()->addConductorAutoNumFormula (m_context_cb_conductor->currentText(), m_saw_conductor->formula()); //add hash <title, formula>
project()->setConductorAutoNumCurrentFormula (m_saw_conductor->formula(),m_context_cb_conductor->currentText()); //add last added conductor formula to current formula
@@ -498,7 +549,7 @@
else {
project()->addConductorAutoNumFormula (m_context_cb_conductor->currentText(), m_saw_conductor->formula()); //add hash <title, formula>
project()->setConductorAutoNumCurrentFormula (m_saw_conductor->formula(), m_context_cb_conductor->currentText()); //add last added conductor formula to current formula
- project_->addConductorAutoNum (m_context_cb_conductor-> currentText(), m_saw_conductor -> toNumContext());
+ m_project->addConductorAutoNum (m_context_cb_conductor-> currentText(), m_saw_conductor -> toNumContext());
}
project()->conductorAutoNumAdded();
}
@@ -511,52 +562,22 @@
// 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_folio -> currentText() == tr("Nom de la nouvelle numérotation")) {
- project_->addFolioAutoNum (tr("Sans nom"), m_saw_folio -> toNumContext());
+ m_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_folio->currentText())) {
+ else if ( !m_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_folio -> currentText(), m_saw_folio -> toNumContext());
+ m_project->addFolioAutoNum (m_context_cb_folio -> currentText(), m_saw_folio -> toNumContext());
}
project()->folioAutoNumAdded();
}
/**
- * @brief ProjectAutoNumConfigPage::saveContext_element
- * Save the current displayed Element formula in project
- */
-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 (tr("Sans nom"), m_saw_element->formula()); //add hash <title, formula>
- project()->setElementAutoNumCurrentFormula (m_saw_element->formula(),tr("Sans nom")); //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->formula()); //add hash <title, formula>
- project()->setElementAutoNumCurrentFormula (m_saw_element->formula(),m_context_cb_element->currentText()); //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->formula()); //add hash <title, formula>
- project()->setElementAutoNumCurrentFormula (m_saw_element->formula(), m_context_cb_element->currentText()); //add last added element formula to current formula
- }
- project()->elementAutoNumAdded();
-}
-
-/**
* @brief ProjectAutoNumConfigPage::applyAutoNum
* Apply auto folio numbering, New Folios or Selected Folios
*/
@@ -576,7 +597,7 @@
QString autoNum = m_faw->autoNumSelected();
int fromFolio = m_faw->fromFolio();
int toFolio = m_faw->toFolio();
- project_->autoFolioNumberingSelectedFolios(fromFolio,toFolio,autoNum);
+ m_project->autoFolioNumberingSelectedFolios(fromFolio,toFolio,autoNum);
}
}
@@ -681,7 +702,7 @@
void ProjectAutoNumConfigPage::removeContext_conductor() {
//if default text, return
if ( m_context_cb_conductor-> currentText() == tr("Nom de la nouvelle numérotation") ) return;
- project_ -> removeConductorAutoNum (m_context_cb_conductor-> currentText() );
+ m_project -> removeConductorAutoNum (m_context_cb_conductor-> currentText() );
m_context_cb_conductor-> removeItem (m_context_cb_conductor-> currentIndex() );
project()->conductorAutoNumRemoved();
}
@@ -693,24 +714,12 @@
void ProjectAutoNumConfigPage::removeContext_folio() {
//if default text, return
if ( m_context_cb_folio -> currentText() == tr("Nom de la nouvelle numérotation") ) return;
- project_ -> removeFolioAutoNum (m_context_cb_folio -> currentText() );
+ m_project -> removeFolioAutoNum (m_context_cb_folio -> currentText() );
m_context_cb_folio -> removeItem (m_context_cb_folio -> currentIndex() );
project()->folioAutoNumRemoved();
}
/**
- * @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() );
- project()->elementAutoNumRemoved();
-}
-
-/**
* @brief ProjectAutoNumConfigPage::changeToTab
* @param tab index
* Change to Selected Tab
Modified: trunk/sources/projectconfigpages.h
===================================================================
--- trunk/sources/projectconfigpages.h 2016-11-24 16:45:55 UTC (rev 4791)
+++ trunk/sources/projectconfigpages.h 2016-11-26 17:12:31 UTC (rev 4792)
@@ -84,7 +84,7 @@
// attributes
protected:
- QETProject *project_; ///< Currently edited project
+ QETProject *m_project; ///< Currently edited project
};
/**
@@ -146,9 +146,9 @@
void updateContext_folio(QString);//folio
void saveContext_folio();
void removeContext_folio();
- void updateContext_element(QString);//element
- void saveContext_element();
- void removeContext_element();
+ void updateContextElement(QString);//element
+ void saveContextElement();
+ void removeContextElement();
void applyAutoNum();
void applyManagement();
Modified: trunk/sources/qetproject.cpp
===================================================================
--- trunk/sources/qetproject.cpp 2016-11-24 16:45:55 UTC (rev 4791)
+++ trunk/sources/qetproject.cpp 2016-11-26 17:12:31 UTC (rev 4792)
@@ -30,6 +30,7 @@
#include "xmlelementcollection.h"
#include "importelementdialog.h"
#include "numerotationcontextcommands.h"
+#include "assignvariables.h"
#include <QStandardPaths>
@@ -418,14 +419,6 @@
}
/**
- * @brief QETProject::elementAutoNumHash
- * @return Title and Formula Hash
- */
-QHash <QString, QString> QETProject::elementAutoNumHash() {
- return m_element_autonum_formula;
-}
-
-/**
* @brief QETProject::conductorAutoNumHash
* @return Title and Formula Hash
*/
@@ -438,13 +431,40 @@
* @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 "";
+QString QETProject::elementAutoNumFormula (QString key) const
+{
+ if (m_element_autonum.contains(key)) {
+ return autonum::NumerotationContextToFormula(m_element_autonum[key]);
+ }
+
+ return QString();
}
/**
+ * @brief QETProject::elementAutoNumCurrentFormula
+ * @return current formula being used by project
+ */
+QString QETProject::elementAutoNumCurrentFormula() const {
+ return elementAutoNumFormula(m_current_element_autonum);
+}
+
+/**
+ * @brief QETProject::elementCurrentAutoNum
+ * @return current element autonum title
+ */
+QString QETProject::elementCurrentAutoNum () const {
+ return m_current_element_autonum;
+}
+
+/**
+ * @brief QETProject::setCurrrentElementAutonum
+ * @param autoNum : set the current element autonum to @autonum
+ */
+void QETProject::setCurrrentElementAutonum(QString autoNum) {
+ m_current_element_autonum = autoNum;
+}
+
+/**
* @brief QETProject::conductorAutoNumFormula
* @param conductor autonum title
* @return Formula of element autonum stored in conductor autonum
@@ -456,14 +476,6 @@
}
/**
- * @brief QETProject::elementAutoNumCurrentFormula
- * @return current formula being used by project
- */
-QString QETProject::elementAutoNumCurrentFormula() const {
- return m_current_element_formula;
-}
-
-/**
* @brief QETProject::conductorAutoNumCurrentFormula
* @return current formula being used by project
*/
@@ -472,19 +484,19 @@
}
/**
- * @brief QETProject::elementCurrentAutoNum
- * @return current element autonum title
+ * @brief QETProject::conductorCurrentAutoNum
+ * @return current conductor autonum title
*/
-QString QETProject::elementCurrentAutoNum () const {
- return m_current_element_autonum;
+QString QETProject::conductorCurrentAutoNum () const {
+ return m_current_conductor_autonum;
}
/**
- * @brief QETProject::conductorCurrentAutoNum
- * @return current element autonum title
+ * @brief QETProject::setCurrentConductorAutoNum
+ * @param autoNum set the current conductor autonum to @autonum
*/
-QString QETProject::conductorCurrentAutoNum () const {
- return m_current_conductor_autonum;
+void QETProject::setCurrentConductorAutoNum(QString autoNum) {
+ m_current_conductor_autonum = autoNum;
}
/**
@@ -527,26 +539,6 @@
}
/**
- * @brief QETProject::addElementAutoNumFormula
- * Add the new formula
- * @param formula
- */
-void QETProject::addElementAutoNumFormula(QString key, QString formula) {
- m_element_autonum_formula.insert(key, formula);
-}
-
-/**
- * @brief QETProject::setElementAutoNumCurrentFormula
- * Add the formula and title to the current formula and current autonum
- * @param formula
- * @param title
- */
-void QETProject::setElementAutoNumCurrentFormula(QString formula, QString title) {
- m_current_element_formula = formula;
- m_current_element_autonum = title;
-}
-
-/**
* @brief QETProject::addElementAutoNum
* Add a new element numerotation context. If key already exist,
* replace old context by the new context
@@ -553,8 +545,10 @@
* @param key
* @param context
*/
-void QETProject::addElementAutoNum(QString key, NumerotationContext context) {
+void QETProject::addElementAutoNum(QString key, NumerotationContext context)
+{
m_element_autonum.insert(key, context);
+ emit elementAutoNumAdded(key);
}
/**
@@ -582,8 +576,10 @@
* Remove Element Numerotation Context stored with key
* @param key
*/
-void QETProject::removeElementAutoNum(QString key) {
+void QETProject::removeElementAutoNum(QString key)
+{
m_element_autonum.remove(key);
+ emit elementAutoNumRemoved(key);
}
/**
@@ -1497,7 +1493,6 @@
if (!element_autonums.isNull())
{
m_current_element_autonum = element_autonums.attribute("current_autonum");
- m_current_element_formula = element_autonums.attribute("current_formula");
m_freeze_new_elements = element_autonums.attribute("freeze_new_elements") == "true";
foreach (QDomElement elmt, QET::findInDomElement(element_autonums, "element_autonum"))
{
@@ -1504,7 +1499,6 @@
NumerotationContext nc;
nc.fromXml(elmt);
m_element_autonum.insert(elmt.attribute("title"), nc);
- m_element_autonum_formula.insert(elmt.attribute("title"),elmt.attribute("formula"));
}
}
}
@@ -1586,7 +1580,6 @@
//Export Element Autonums
QDomElement element_autonums = xml_document.createElement("element_autonums");
element_autonums.setAttribute("current_autonum", m_current_element_autonum);
- element_autonums.setAttribute("current_formula", m_current_element_formula);
element_autonums.setAttribute("freeze_new_elements", m_freeze_new_elements ? "true" : "false");
foreach (QString key, elementAutoNum().keys()) {
QDomElement element_autonum = elementAutoNum(key).toXml(xml_document, "element_autonum");
Modified: trunk/sources/qetproject.h
===================================================================
--- trunk/sources/qetproject.h 2016-11-24 16:45:55 UTC (rev 4791)
+++ trunk/sources/qetproject.h 2016-11-26 17:12:31 UTC (rev 4792)
@@ -108,7 +108,6 @@
QHash <QString, NumerotationContext> conductorAutoNum() const;
QHash <QString, NumerotationContext> elementAutoNum() const;
- QHash <QString, QString> elementAutoNumHash();
QHash <QString, QString> conductorAutoNumHash();
QHash <QString, NumerotationContext> folioAutoNum() const;
void addConductorAutoNum (QString key, NumerotationContext context);
@@ -115,8 +114,6 @@
void addConductorAutoNumFormula (QString key, QString formula);
void setConductorAutoNumCurrentFormula (QString formula, QString title);
void addElementAutoNum (QString key, NumerotationContext context);
- void addElementAutoNumFormula (QString key, QString formula);
- void setElementAutoNumCurrentFormula (QString formula, QString title);
void addFolioAutoNum (QString key, NumerotationContext context);
void removeConductorAutoNum (QString key);
void removeElementAutoNum (QString key);
@@ -128,10 +125,12 @@
QString conductorAutoNumFormula(const QString key) const; //returns Formula
QString conductorAutoNumCurrentFormula() const;
QString conductorCurrentAutoNum() const;
+ void setCurrentConductorAutoNum(QString autoNum);
- QString elementAutoNumFormula(const QString key) const; //returns Formula
+ QString elementAutoNumFormula(const QString key) const;
QString elementAutoNumCurrentFormula() const;
QString elementCurrentAutoNum() const;
+ void setCurrrentElementAutonum(QString autoNum);
//Element
void freezeExistentElementLabel(int,int);
@@ -175,42 +174,42 @@
QUndoStack* undoStack() {return undo_stack_;}
public slots:
- void componentWritten();
- Diagram *addNewDiagram();
- QList <Diagram *> addNewDiagramFolioList();
- void removeDiagram(Diagram *);
- void diagramOrderChanged(int, int);
- void setModified(bool);
+ void componentWritten();
+ Diagram *addNewDiagram();
+ QList <Diagram *> addNewDiagramFolioList();
+ void removeDiagram(Diagram *);
+ void diagramOrderChanged(int, int);
+ void setModified(bool);
signals:
- void projectFilePathChanged(QETProject *, const QString &);
- void projectTitleChanged(QETProject *, const QString &);
- void projectInformationsChanged(QETProject *);
- void diagramAdded(QETProject *, Diagram *);
- void diagramRemoved(QETProject *, Diagram *);
- void projectModified(QETProject *, bool);
- void projectDiagramsOrderChanged(QETProject *, int, int);
- void diagramUsedTemplate(TitleBlockTemplatesCollection *, const QString &);
- void readOnlyChanged(QETProject *, bool);
- void reportPropertiesChanged(QString);
- void XRefPropertiesChanged ();
- void addAutoNumDiagram();
- void elementAutoNumAdded();
- void elementAutoNumRemoved();
- void conductorAutoNumAdded();
- void conductorAutoNumRemoved();
- void folioAutoNumAdded();
- void folioAutoNumRemoved();
- void folioAutoNumChanged(QString);
- void defaultTitleBlockPropertiesChanged();
- void conductorAutoNumChanged();
+ void projectFilePathChanged(QETProject *, const QString &);
+ void projectTitleChanged(QETProject *, const QString &);
+ void projectInformationsChanged(QETProject *);
+ void diagramAdded(QETProject *, Diagram *);
+ void diagramRemoved(QETProject *, Diagram *);
+ void projectModified(QETProject *, bool);
+ void projectDiagramsOrderChanged(QETProject *, int, int);
+ void diagramUsedTemplate(TitleBlockTemplatesCollection *, const QString &);
+ void readOnlyChanged(QETProject *, bool);
+ void reportPropertiesChanged(QString);
+ void XRefPropertiesChanged ();
+ void addAutoNumDiagram();
+ void elementAutoNumAdded(QString name);
+ void elementAutoNumRemoved(QString name);
+ void conductorAutoNumAdded();
+ void conductorAutoNumRemoved();
+ void folioAutoNumAdded();
+ void folioAutoNumRemoved();
+ void folioAutoNumChanged(QString);
+ void defaultTitleBlockPropertiesChanged();
+ void conductorAutoNumChanged();
private slots:
- void updateDiagramsFolioData();
- void updateDiagramsTitleBlockTemplate(TitleBlockTemplatesCollection *, const QString &);
- void removeDiagramsTitleBlockTemplate(TitleBlockTemplatesCollection *, const QString &);
- void usedTitleBlockTemplateChanged(const QString &);
- void undoStackChanged (bool a) {if (!a) setModified(true);}
+ void updateDiagramsFolioData();
+ void updateDiagramsTitleBlockTemplate(TitleBlockTemplatesCollection *, const QString &);
+ void removeDiagramsTitleBlockTemplate(TitleBlockTemplatesCollection *, const QString &);
+ void usedTitleBlockTemplateChanged(const QString &);
+ void undoStackChanged (bool a) {if (!a) setModified(true);}
private:
void setupTitleBlockTemplatesCollection();
@@ -228,56 +227,55 @@
// attributes
private:
- /// File path this project is saved to
- QString file_path_;
- /// Current state of the project
- ProjectState state_;
- /// Diagrams carried by the project
- QList<Diagram *> diagrams_;
- /// Project title
- QString project_title_;
- /// QElectroTech version declared in the XML document at opening time
- qreal project_qet_version_;
- /// Whether options were modified
- bool modified_;
- /// Whether the project is read only
- bool read_only_;
- /// Filepath for which this project is considered read only
- QString read_only_file_path_;
- /// Default dimensions and properties for new diagrams created within the project
- BorderProperties default_border_properties_;
- /// Default conductor properties for new diagrams created within the project
- ConductorProperties default_conductor_properties_;
- /// Default title block properties for new diagrams created within the project
- TitleBlockProperties default_titleblock_properties_;
- /// Default report properties
- QString default_report_properties_;
- /// Default xref properties
- QHash <QString, XRefProperties> m_default_xref_properties;
- /// Embedded title block templates collection
- TitleBlockTemplatesProjectCollection titleblocks_;
- /// project-wide variables that will be made available to child diagrams
- DiagramContext project_properties_;
- /// undo stack for this project
- QUndoStack *undo_stack_;
- /// Conductor auto numerotation
- QHash <QString, NumerotationContext> m_conductor_autonum;//Title and NumContext hash
- QHash <QString, QString> m_conductor_autonum_formula;//Title and Formula hash
- QString m_current_conductor_formula;
- QString m_current_conductor_autonum;
- /// Folio auto numbering
- QHash <QString, NumerotationContext> m_folio_autonum;
- /// Element Auto Numbering
- QHash <QString, NumerotationContext> m_element_autonum; //Title and NumContext hash
- QHash <QString, QString> m_element_autonum_formula; //Title and Formula hash
- QString m_current_element_formula;
- QString m_current_element_autonum;
- /// Folio List Sheets quantity for this project.
- int folioSheetsQuantity;
- bool m_auto_conductor;
- XmlElementCollection *m_elements_collection;
- bool m_freeze_new_elements;
- bool m_freeze_new_conductors;
+ /// File path this project is saved to
+ QString file_path_;
+ /// Current state of the project
+ ProjectState state_;
+ /// Diagrams carried by the project
+ QList<Diagram *> diagrams_;
+ /// Project title
+ QString project_title_;
+ /// QElectroTech version declared in the XML document at opening time
+ qreal project_qet_version_;
+ /// Whether options were modified
+ bool modified_;
+ /// Whether the project is read only
+ bool read_only_;
+ /// Filepath for which this project is considered read only
+ QString read_only_file_path_;
+ /// Default dimensions and properties for new diagrams created within the project
+ BorderProperties default_border_properties_;
+ /// Default conductor properties for new diagrams created within the project
+ ConductorProperties default_conductor_properties_;
+ /// Default title block properties for new diagrams created within the project
+ TitleBlockProperties default_titleblock_properties_;
+ /// Default report properties
+ QString default_report_properties_;
+ /// Default xref properties
+ QHash <QString, XRefProperties> m_default_xref_properties;
+ /// Embedded title block templates collection
+ TitleBlockTemplatesProjectCollection titleblocks_;
+ /// project-wide variables that will be made available to child diagrams
+ DiagramContext project_properties_;
+ /// undo stack for this project
+ QUndoStack *undo_stack_;
+ /// Conductor auto numerotation
+ QHash <QString, NumerotationContext> m_conductor_autonum;//Title and NumContext hash
+ QHash <QString, QString> m_conductor_autonum_formula;//Title and Formula hash
+ QString m_current_conductor_formula;
+ QString m_current_conductor_autonum;
+ /// Folio auto numbering
+ QHash <QString, NumerotationContext> m_folio_autonum;
+ /// Element Auto Numbering
+ QHash <QString, NumerotationContext> m_element_autonum; //Title and NumContext hash
+ QString m_current_element_autonum;
+ /// Folio List Sheets quantity for this project.
+ int folioSheetsQuantity;
+ bool m_auto_conductor;
+ XmlElementCollection *m_elements_collection;
+ bool m_freeze_new_elements;
+ bool m_freeze_new_conductors;
};
+
Q_DECLARE_METATYPE(QETProject *)
#endif