[qet] qet/qet: [4805] Element : change freeze label variable from a string to a bool. |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/qet Archives
]
Revision: 4805
Author: blacksun
Date: 2016-12-10 13:00:52 +0100 (Sat, 10 Dec 2016)
Log Message:
-----------
Element : change freeze label variable from a string to a bool.
Modified Paths:
--------------
trunk/sources/autoNum/ui/autonumberingmanagementw.cpp
trunk/sources/diagram.cpp
trunk/sources/diagram.h
trunk/sources/projectconfigpages.cpp
trunk/sources/qetgraphicsitem/element.cpp
trunk/sources/qetgraphicsitem/element.h
trunk/sources/qetproject.cpp
trunk/sources/qetproject.h
Modified: trunk/sources/autoNum/ui/autonumberingmanagementw.cpp
===================================================================
--- trunk/sources/autoNum/ui/autonumberingmanagementw.cpp 2016-12-08 16:54:41 UTC (rev 4804)
+++ trunk/sources/autoNum/ui/autonumberingmanagementw.cpp 2016-12-10 12:00:52 UTC (rev 4805)
@@ -41,7 +41,7 @@
ui->m_selected_folios_widget->setDisabled(true);
ui->m_selected_folios_le->setDisabled(true);
ui->m_selected_folios_le->setReadOnly(true);
- applyEnable(false);
+ ui->m_apply_project_rb->setChecked(true);
setProjectContext();
}
Modified: trunk/sources/diagram.cpp
===================================================================
--- trunk/sources/diagram.cpp 2016-12-08 16:54:41 UTC (rev 4804)
+++ trunk/sources/diagram.cpp 2016-12-10 12:00:52 UTC (rev 4805)
@@ -60,7 +60,7 @@
draw_terminals_ (true),
draw_colored_conductors_ (true),
m_event_interface (nullptr),
- m_freeze_new_elements_ (false),
+ m_freeze_new_elements (false),
m_freeze_new_conductors_ (false)
{
setProject(project);
@@ -477,7 +477,7 @@
}
//Default New Element
- racine.setAttribute("freezeNewElement", m_freeze_new_elements_ ? "true" : "false");
+ racine.setAttribute("freezeNewElement", m_freeze_new_elements ? "true" : "false");
//Default New Conductor
racine.setAttribute("freezeNewConductor", m_freeze_new_conductors_ ? "true" : "false");
@@ -726,7 +726,7 @@
m_conductors_autonum_name = root.attribute("conductorAutonum");
// Load Freeze New Element
- m_freeze_new_elements_ = root.attribute("freezeNewElement").toInt();
+ m_freeze_new_elements = root.attribute("freezeNewElement").toInt();
// Load Freeze New Conductor
m_freeze_new_conductors_ = root.attribute("freezeNewConductor").toInt();
@@ -1453,9 +1453,9 @@
* @brief Diagram::freezeElements
* Freeze every existent element label.
*/
-void Diagram::freezeElements() {
+void Diagram::freezeElements(bool freeze) {
foreach (Element *elmt, elements()) {
- elmt->freezeLabel();
+ elmt->freezeLabel(freeze);
}
}
@@ -1465,7 +1465,7 @@
*/
void Diagram::unfreezeElements() {
foreach (Element *elmt, elements()) {
- elmt->unfreezeLabel();
+ elmt->freezeLabel(false);
}
}
@@ -1474,7 +1474,7 @@
* Set new element label to be frozen.
*/
void Diagram::setFreezeNewElements(bool b) {
- m_freeze_new_elements_ = b;
+ m_freeze_new_elements = b;
}
/**
@@ -1482,7 +1482,7 @@
* @return current freeze new element status .
*/
bool Diagram::freezeNewElements() {
- return m_freeze_new_elements_;
+ return m_freeze_new_elements;
}
/**
Modified: trunk/sources/diagram.h
===================================================================
--- trunk/sources/diagram.h 2016-12-08 16:54:41 UTC (rev 4804)
+++ trunk/sources/diagram.h 2016-12-10 12:00:52 UTC (rev 4805)
@@ -112,7 +112,7 @@
QString m_conductors_autonum_name;
DiagramEventInterface *m_event_interface;
- bool m_freeze_new_elements_;
+ bool m_freeze_new_elements;
bool m_freeze_new_conductors_;
// METHODS
@@ -217,7 +217,7 @@
QGIManager &qgiManager();
//methods related to element label Update Policy
- void freezeElements();
+ void freezeElements(bool freeze);
void unfreezeElements();
void setFreezeNewElements(bool);
bool freezeNewElements();
Modified: trunk/sources/projectconfigpages.cpp
===================================================================
--- trunk/sources/projectconfigpages.cpp 2016-12-08 16:54:41 UTC (rev 4804)
+++ trunk/sources/projectconfigpages.cpp 2016-12-10 12:00:52 UTC (rev 4805)
@@ -653,29 +653,29 @@
//Allow Both Existent and New Elements
if (m_amw->ui->m_both_element_rb->isChecked()) {
//Unfreeze Existent and New Elements
- project()->unfreezeExistentElementLabel(from,to);
- project()->unfreezeNewElementLabel(from,to);
+ project()->freezeExistentElementLabel(false, from,to);
+ project()->freezeNewElementLabel(false, from,to);
project()->setFreezeNewElements(false);
}
//Allow Only New
else if (m_amw->ui->m_new_element_rb->isChecked()) {
//Freeze Existent and Unfreeze New Elements
- project()->freezeExistentElementLabel(from,to);
- project()->unfreezeNewElementLabel(from,to);
+ project()->freezeExistentElementLabel(true, from,to);
+ project()->freezeNewElementLabel(false, from,to);
project()->setFreezeNewElements(false);
}
//Allow Only Existent
else if (m_amw->ui->m_existent_element_rb->isChecked()) {
//Freeze New and Unfreeze Existent Elements, Set Freeze Element Project Wide
- project()->unfreezeExistentElementLabel(from,to);
- project()->freezeNewElementLabel(from,to);
+ project()->freezeExistentElementLabel(false, from,to);
+ project()->freezeNewElementLabel(true, from,to);
project()->setFreezeNewElements(true);
}
//Disable
else if (m_amw->ui->m_disable_element_rb->isChecked()) {
//Freeze Existent and New Elements, Set Freeze Element Project Wide
- project()->freezeExistentElementLabel(from,to);
- project()->freezeNewElementLabel(from,to);
+ project()->freezeExistentElementLabel(true, from,to);
+ project()->freezeNewElementLabel(true, from,to);
project()->setFreezeNewElements(true);
}
Modified: trunk/sources/qetgraphicsitem/element.cpp
===================================================================
--- trunk/sources/qetgraphicsitem/element.cpp 2016-12-08 16:54:41 UTC (rev 4804)
+++ trunk/sources/qetgraphicsitem/element.cpp 2016-12-10 12:00:52 UTC (rev 4805)
@@ -462,6 +462,9 @@
//load prefix
m_prefix = e.attribute("prefix");
+ QString fl = e.attribute("freezeLabel", "false");
+ m_freeze_label = fl == "false"? false : true;
+
//Load Sequential Values
if (e.hasAttribute("sequ_1") || e.hasAttribute("sequf_1") || e.hasAttribute("seqt_1") || e.hasAttribute("seqtf_1") || e.hasAttribute("seqh_1") || e.hasAttribute("sequf_1"))
ElementXmlRetroCompatibility::loadSequential(e, this);
@@ -519,6 +522,9 @@
// prefix
element.setAttribute("prefix", m_prefix);
+ //frozen label
+ element.setAttribute("freezeLabel", m_freeze_label? "true" : "false");
+
// sequential num
QDomElement seq = m_autoNum_seq.toXml(document);
if (seq.hasChildNodes())
@@ -836,44 +842,26 @@
* @brief Element::freezeLabel
* Freeze this element label
*/
-void Element::freezeLabel()
+void Element::freezeLabel(bool freeze)
{
- DiagramContext &dc = this->rElementInformations();
- QString freezelabel = dc["label"].toString();
- QString label = autonum::AssignVariables::formulaToLabel(freezelabel, m_autoNum_seq, diagram(),this );
+ if (m_freeze_label != freeze)
+ {
+ m_freeze_label = freeze;
+ QString f = m_element_informations["formula"].toString();
+ setUpConnectionForFormula(f,f);
- if (!(label == freezelabel))
- {
- dc.addValue("frozenlabel", freezelabel);
- dc.addValue("label",label);
- this->setTaggedText("label", label);
- this->setElementInformations(dc);
+ if (m_freeze_label == true)
+ updateLabel();
}
}
/**
- * @brief Element::unfreezeLabel
- * Unfreeze this element label
- */
-void Element::unfreezeLabel()
-{
- DiagramContext &dc = this->rElementInformations();
- QString frozenlabel = dc["frozenlabel"].toString();
- if (frozenlabel == "") return;
- dc.addValue("frozenlabel", "");
- dc.addValue("label",frozenlabel);
- frozenlabel = autonum::AssignVariables::formulaToLabel(frozenlabel, m_autoNum_seq, diagram(),this );
- this->setTaggedText("label", frozenlabel);
- this->setElementInformations(dc);
-}
-
-/**
* @brief Element::freezeNewAddedElement
* Freeze this label if needed
*/
void Element::freezeNewAddedElement() {
if (this->diagram()->freezeNewElements() || this->diagram()->project()->freezeNewElements()) {
- freezeLabel();
+ freezeLabel(true);
}
else return;
}
@@ -893,6 +881,10 @@
if (old_formula.contains("%c"))
disconnect(this, &Element::xChanged, this, &Element::updateLabel);
+ //Label is frozen, so we don't update it.
+ if (m_freeze_label == true)
+ return;
+
if (diagram() && (new_formula.contains("%f") || new_formula.contains("%id")))
connect(diagram()->project(), &QETProject::projectDiagramsOrderChanged, this, &Element::updateLabel);
if (new_formula.contains("%l"))
Modified: trunk/sources/qetgraphicsitem/element.h
===================================================================
--- trunk/sources/qetgraphicsitem/element.h 2016-12-08 16:54:41 UTC (rev 4804)
+++ trunk/sources/qetgraphicsitem/element.h 2016-12-10 12:00:52 UTC (rev 4805)
@@ -144,8 +144,7 @@
void setUpFormula(bool code_letter = true);
void setPrefix(QString);
QString getPrefix() const;
- void freezeLabel();
- void unfreezeLabel();
+ void freezeLabel(bool freeze);
void freezeNewAddedElement();
protected:
@@ -155,6 +154,7 @@
protected:
DiagramContext m_element_informations, kind_informations_;
autonum::sequentialNumbers m_autoNum_seq;
+ bool m_freeze_label = false;
/**
Draw this element
Modified: trunk/sources/qetproject.cpp
===================================================================
--- trunk/sources/qetproject.cpp 2016-12-08 16:54:41 UTC (rev 4804)
+++ trunk/sources/qetproject.cpp 2016-12-10 12:00:52 UTC (rev 4805)
@@ -660,49 +660,25 @@
* @param from - first folio index to apply freeze
* @param to - last folio index to apply freeze
*/
-void QETProject::freezeExistentElementLabel(int from, int to) {
+void QETProject::freezeExistentElementLabel(bool freeze, int from, int to) {
for (int i = from; i <= to; i++) {
- diagrams_.at(i)->freezeElements();
+ diagrams_.at(i)->freezeElements(freeze);
}
}
/**
- * @brief QETProject::unfreezeExistentElementLabel
- * Unfreeze Existent Elements in the selected folios
- * @param from - first folio index to apply unfreeze
- * @param to - last folio index to apply unfreeze
- */
-void QETProject::unfreezeExistentElementLabel(int from, int to) {
- for (int i = from; i <= to; i++) {
- diagrams_.at(i)->unfreezeElements();
- }
-}
-
-/**
* @brief QETProject::freezeNewElementLabel
* Freeze New Elements in the selected folios
* @param from - first folio index to apply freeze
* @param to - last folio index to apply freeze
*/
-void QETProject::freezeNewElementLabel(int from, int to) {
+void QETProject::freezeNewElementLabel(bool freeze, int from, int to) {
for (int i = from; i <= to; i++) {
- diagrams_.at(i)->setFreezeNewElements(true);
+ diagrams_.at(i)->setFreezeNewElements(freeze);
}
}
/**
- * @brief QETProject::unfreezeNewElementLabel
- * Unfreeze New Elements in the selected folios
- * @param from - first folio index to apply unfreeze
- * @param to - last folio index to apply unfreeze
- */
-void QETProject::unfreezeNewElementLabel(int from, int to) {
- for (int i = from; i <= to; i++) {
- diagrams_.at(i)->setFreezeNewElements(false);
- }
-}
-
-/**
* @brief QETProject::freezeNewElements
* @return freeze new elements Project Wide status
*/
Modified: trunk/sources/qetproject.h
===================================================================
--- trunk/sources/qetproject.h 2016-12-08 16:54:41 UTC (rev 4804)
+++ trunk/sources/qetproject.h 2016-12-10 12:00:52 UTC (rev 4805)
@@ -128,15 +128,13 @@
QString elementCurrentAutoNum() const;
void setCurrrentElementAutonum(QString autoNum);
- //Element
- void freezeExistentElementLabel(int,int);
- void freezeNewElementLabel(int,int);
- void unfreezeExistentElementLabel(int,int);
- void unfreezeNewElementLabel(int,int);
+ //Element
+ void freezeExistentElementLabel(bool freeze, int from, int to);
+ void freezeNewElementLabel(bool freeze, int from, int to);
bool freezeNewElements();
void setFreezeNewElements(bool);
- //Conductor
+ //Conductor
void freezeExistentConductorLabel(int,int);
void unfreezeExistentConductorLabel(int,int);
void freezeNewConductorLabel(int,int);