Update Policy now works with conductor autonumberings

git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@4680 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
dfochi 2016-09-01 19:41:49 +00:00
parent 47b0fd7f10
commit 30a9aa9cfe
10 changed files with 224 additions and 36 deletions

View File

@ -60,7 +60,8 @@ Diagram::Diagram(QETProject *project) :
draw_terminals_ (true), draw_terminals_ (true),
draw_colored_conductors_ (true), draw_colored_conductors_ (true),
m_event_interface (nullptr), m_event_interface (nullptr),
m_freeze_new_elements_ (false) m_freeze_new_elements_ (false),
m_freeze_new_conductors_ (false)
{ {
setProject(project); setProject(project);
qgi_manager_ = new QGIManager(this); qgi_manager_ = new QGIManager(this);
@ -478,6 +479,9 @@ QDomDocument Diagram::toXml(bool whole_content) {
//Default New Element //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");
//Element Folio Sequential Variables //Element Folio Sequential Variables
if (!m_elmt_unitfolio_max.isEmpty() || !m_elmt_tenfolio_max.isEmpty() || !m_elmt_hundredfolio_max.isEmpty()) { if (!m_elmt_unitfolio_max.isEmpty() || !m_elmt_tenfolio_max.isEmpty() || !m_elmt_hundredfolio_max.isEmpty()) {
QDomElement elmtfoliosequential = document.createElement("elementautonumfoliosequentials"); QDomElement elmtfoliosequential = document.createElement("elementautonumfoliosequentials");
@ -724,6 +728,9 @@ bool Diagram::fromXml(QDomElement &document, QPointF position, bool consider_inf
// Load Freeze New Element // 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();
//Load Element Folio Sequential //Load Element Folio Sequential
folioSequentialsFromXml(root, &m_elmt_unitfolio_max, "elementunitfolioseq","sequf_","unitfolioseq", "elementautonumfoliosequentials"); folioSequentialsFromXml(root, &m_elmt_unitfolio_max, "elementunitfolioseq","sequf_","unitfolioseq", "elementautonumfoliosequentials");
folioSequentialsFromXml(root, &m_elmt_tenfolio_max, "elementtenfolioseq","seqtf_", "tenfolioseq", "elementautonumfoliosequentials"); folioSequentialsFromXml(root, &m_elmt_tenfolio_max, "elementtenfolioseq","seqtf_", "tenfolioseq", "elementautonumfoliosequentials");
@ -861,6 +868,10 @@ bool Diagram::fromXml(QDomElement &document, QPointF position, bool consider_inf
addItem(c); addItem(c);
c -> fromXml(f); c -> fromXml(f);
added_conductors << c; added_conductors << c;
if (item_paste) {
c->m_frozen_label = f.attribute("frozenlabel");
qDebug() << "Frozen Label" << f.attribute("frozenlabel");
}
} }
else else
delete c; delete c;
@ -1361,6 +1372,19 @@ QList <Element *> Diagram::elements() const {
return (element_list); return (element_list);
} }
/**
* @brief Diagram::conductors
* Return the list containing all conductors
*/
QList <Conductor *> Diagram::conductors() const {
QList<Conductor *> cnd_list;
foreach (QGraphicsItem *qgi, items()) {
if (Conductor *cnd = qgraphicsitem_cast<Conductor *>(qgi))
cnd_list <<cnd;
}
return (cnd_list);
}
/** /**
Initialise un deplacement d'elements, conducteurs et champs de texte sur le Initialise un deplacement d'elements, conducteurs et champs de texte sur le
schema. schema.
@ -1461,19 +1485,11 @@ void Diagram::unfreezeElements() {
} }
/** /**
* @brief Diagram::freezeNew * @brief Diagram::freezeNewElements
* Set new element label to be frozen. * Set new element label to be frozen.
*/ */
void Diagram::freezeNew() { void Diagram::setFreezeNewElements(bool b) {
m_freeze_new_elements_ = true; m_freeze_new_elements_ = b;
}
/**
* @brief Diagram::unfreezeNew
* Set new element label to not be frozen.
*/
void Diagram::unfreezeNew() {
m_freeze_new_elements_ = false;
} }
/** /**
@ -1484,6 +1500,42 @@ bool Diagram::freezeNewElements() {
return m_freeze_new_elements_; return m_freeze_new_elements_;
} }
/**
* @brief Diagram::freezeConductors
* Freeze every existent conductor label.
*/
void Diagram::freezeConductors() {
foreach (Conductor *cnd, conductors()) {
cnd->freezeLabel();
}
}
/**
* @brief Diagram::unfreezeConductors
* Unfreeze every existent conductor label.
*/
void Diagram::unfreezeConductors() {
foreach (Conductor *cnd, conductors()) {
cnd->unfreezeLabel();
}
}
/**
* @brief Diagram::setfreezeNewConductors
* Set new conductor label to be frozen.
*/
void Diagram::setFreezeNewConductors(bool b) {
m_freeze_new_conductors_ = b;
}
/**
* @brief Diagram::freezeNewConductors
* @return current freeze new conductor status .
*/
bool Diagram::freezeNewConductors() {
return m_freeze_new_conductors_;
}
/** /**
* @brief Diagram::adjustSceneRect * @brief Diagram::adjustSceneRect
* Recalcul and adjust the size of the scene * Recalcul and adjust the size of the scene

View File

@ -113,6 +113,7 @@ class Diagram : public QGraphicsScene
DiagramEventInterface *m_event_interface; DiagramEventInterface *m_event_interface;
bool m_freeze_new_elements_; bool m_freeze_new_elements_;
bool m_freeze_new_conductors_;
// METHODS // METHODS
protected: protected:
@ -194,6 +195,7 @@ class Diagram : public QGraphicsScene
QList<CustomElement *> customElements() const; QList<CustomElement *> customElements() const;
QList<Element *> elements() const; QList<Element *> elements() const;
QList<Conductor *> conductors() const;
QSet<DiagramTextItem *> selectedTexts() const; QSet<DiagramTextItem *> selectedTexts() const;
QSet<ConductorTextItem *> selectedConductorTexts() const; QSet<ConductorTextItem *> selectedConductorTexts() const;
QSet<ElementTextItem*> selectedElementTexts() const; QSet<ElementTextItem*> selectedElementTexts() const;
@ -216,10 +218,15 @@ class Diagram : public QGraphicsScene
//methods related to element label Update Policy //methods related to element label Update Policy
void freezeElements(); void freezeElements();
void unfreezeElements(); void unfreezeElements();
void freezeNew(); void setFreezeNewElements(bool);
void unfreezeNew();
bool freezeNewElements(); bool freezeNewElements();
//methods related to conductor label Update Policy
void freezeConductors();
void unfreezeConductors();
void setFreezeNewConductors(bool);
bool freezeNewConductors();
//methods related to insertion and loading of folio sequential //methods related to insertion and loading of folio sequential
void insertFolioSeqHash (QHash<QString, QStringList> *hash, QString title, QString seq, NumerotationContext *nc); void insertFolioSeqHash (QHash<QString, QStringList> *hash, QString title, QString seq, NumerotationContext *nc);
void loadFolioSeqHash (QHash<QString, QStringList> *hash, QString title, QString seq, NumerotationContext *nc); void loadFolioSeqHash (QHash<QString, QStringList> *hash, QString title, QString seq, NumerotationContext *nc);

View File

@ -232,6 +232,8 @@ void DiagramEventAddElement::addElement()
ConductorAutoNumerotation can (conductor, m_diagram, undo_object); ConductorAutoNumerotation can (conductor, m_diagram, undo_object);
can.numerate(); can.numerate();
conductor->setSeq = true; conductor->setSeq = true;
if (m_diagram->freezeNewConductors() || m_diagram->project()->freezeNewConductors() )
conductor->freeze_label = true;
}; };
m_diagram -> undoStack().push(undo_object); m_diagram -> undoStack().push(undo_object);
element->setSequential(); element->setSequential();

View File

@ -598,18 +598,34 @@ void ProjectAutoNumConfigPage::applyManagement() {
to = m_amw->ui->m_to_folios_cb->itemData(m_amw->ui->m_to_folios_cb->currentIndex()).toInt(); to = m_amw->ui->m_to_folios_cb->itemData(m_amw->ui->m_to_folios_cb->currentIndex()).toInt();
} }
//Conductor Autonumbering Status //Conductor Autonumbering Update Policy
//Allow Both Existent and New Conductors
if (m_amw->ui->m_both_conductor_rb->isChecked()) { if (m_amw->ui->m_both_conductor_rb->isChecked()) {
//Unfreeze Existent and New Conductors
project()->unfreezeExistentConductorLabel(from,to);
project()->unfreezeNewConductorLabel(from,to);
project()->setFreezeNewConductors(false);
} }
//Allow Only New
else if (m_amw->ui->m_new_conductor_rb->isChecked()) { else if (m_amw->ui->m_new_conductor_rb->isChecked()) {
//Freeze Existent and Unfreeze New Conductors
project()->freezeExistentConductorLabel(from,to);
project()->unfreezeNewConductorLabel(from,to);
project()->setFreezeNewConductors(false);
} }
//Allow Only Existent
else if (m_amw->ui->m_existent_conductor_rb->isChecked()) { else if (m_amw->ui->m_existent_conductor_rb->isChecked()) {
//Freeze Existent and Unfreeze New Conductors
project()->unfreezeExistentConductorLabel(from,to);
project()->freezeNewConductorLabel(from,to);
project()->setFreezeNewConductors(true);
} }
//Disable
else if (m_amw->ui->m_disable_conductor_rb->isChecked()) { else if (m_amw->ui->m_disable_conductor_rb->isChecked()) {
//Freeze Existent and New Elements, Set Freeze Element Project Wide
project()->freezeExistentConductorLabel(from,to);
project()->freezeNewConductorLabel(from,to);
project()->setFreezeNewConductors(true);
} }
//Element Autonumbering Update Policy //Element Autonumbering Update Policy

View File

@ -48,6 +48,7 @@ Conductor::Conductor(Terminal *p1, Terminal* p2) :
terminal1(p1), terminal1(p1),
terminal2(p2), terminal2(p2),
setSeq(true), setSeq(true),
freeze_label(false),
bMouseOver(false), bMouseOver(false),
m_handler(10), m_handler(10),
text_item(0), text_item(0),
@ -826,6 +827,8 @@ bool Conductor::fromXml(QDomElement &e) {
loadSequential(&e,"seqh_",&seq_hundred); loadSequential(&e,"seqh_",&seq_hundred);
loadSequential(&e,"seqhf_",&seq_hundredfolio); loadSequential(&e,"seqhf_",&seq_hundredfolio);
m_frozen_label = e.attribute("frozenlabel");
setProperties(pr); setProperties(pr);
return return_; return return_;
@ -906,6 +909,8 @@ QDomElement Conductor::toXml(QDomDocument &d, QHash<Terminal *, int> &table_adr_
e.setAttribute("seqhf_" + QString::number(i+1),seq_hundredfolio.at(i)); e.setAttribute("seqhf_" + QString::number(i+1),seq_hundredfolio.at(i));
} }
if (m_frozen_label != "") e.setAttribute("frozenlabel", m_frozen_label);
// Export the properties and text // Export the properties and text
properties_. toXml(e); properties_. toXml(e);
text_item -> toXml(e); text_item -> toXml(e);
@ -1466,6 +1471,12 @@ void Conductor::setProperties(const ConductorProperties &properties)
} }
setText(properties_.text); setText(properties_.text);
text_item -> setFontSize(properties_.text_size); text_item -> setFontSize(properties_.text_size);
if (terminal1->diagram()->item_paste)
m_frozen_label = "";
else
m_frozen_label = properties_.text;
if (freeze_label)
freezeLabel();
if (properties_.type != ConductorProperties::Multi) if (properties_.type != ConductorProperties::Multi)
text_item -> setVisible(false); text_item -> setVisible(false);
else else
@ -1867,3 +1878,23 @@ QList <Conductor *> relatedConductors(const Conductor *conductor) {
other_conductors_list.removeAll(const_cast<Conductor *> (conductor)); other_conductors_list.removeAll(const_cast<Conductor *> (conductor));
return(other_conductors_list); return(other_conductors_list);
} }
/**
* @brief Conductor::freezeLabel
* Freeze this conductor label
*/
void Conductor::freezeLabel() {
QString freezelabel = this->text_item->toPlainText();
m_frozen_label = properties_.text;
this->setText(freezelabel);
this->properties_.text = freezelabel;
}
/**
* @brief Conductor::unfreezeLabel
* Unfreeze this conductor label
*/
void Conductor::unfreezeLabel() {
this->setText(m_frozen_label);
properties_.text = m_frozen_label;
}

View File

@ -131,6 +131,10 @@ class Conductor : public QObject, public QGraphicsPathItem
QStringList seq_hundred; QStringList seq_hundred;
QStringList seq_hundredfolio; QStringList seq_hundredfolio;
bool setSeq; bool setSeq;
bool freeze_label;
void freezeLabel();
void unfreezeLabel();
QString m_frozen_label;
public slots: public slots:
void displayedTextChanged(); void displayedTextChanged();

View File

@ -49,7 +49,8 @@ QETProject::QETProject(int diagrams, QObject *parent) :
folioSheetsQuantity (0 ), folioSheetsQuantity (0 ),
m_auto_conductor (true ), m_auto_conductor (true ),
m_elements_collection (nullptr), m_elements_collection (nullptr),
m_freeze_new_elements (false) m_freeze_new_elements (false),
m_freeze_new_conductors (false)
{ {
// 0 a n schema(s) vide(s) // 0 a n schema(s) vide(s)
int diagrams_count = qMax(0, diagrams); int diagrams_count = qMax(0, diagrams);
@ -627,6 +628,70 @@ NumerotationContext QETProject::folioAutoNum (const QString &key) const {
else return NumerotationContext(); else return NumerotationContext();
} }
/**
* @brief QETProject::freezeExistentConductorLabel
* Freeze Existent Conductors in the selected folios
* @param from - first folio index to apply freeze
* @param to - last folio index to apply freeze
*/
void QETProject::freezeExistentConductorLabel(int from, int to) {
for (int i = from; i <= to; i++) {
diagrams_.at(i)->freezeConductors();
}
}
/**
* @brief QETProject::unfreezeExistentConductorLabel
* Unfreeze Existent Conductors in the selected folios
* @param from - first folio index to apply unfreeze
* @param to - last folio index to apply unfreeze
*/
void QETProject::unfreezeExistentConductorLabel(int from, int to) {
for (int i = from; i <= to; i++) {
diagrams_.at(i)->unfreezeConductors();
}
}
/**
* @brief QETProject::freezeNewConductorLabel
* Freeze New Conductors in the selected folios
* @param from - first folio index to apply freeze
* @param to - last folio index to apply freeze
*/
void QETProject::freezeNewConductorLabel(int from, int to) {
for (int i = from; i <= to; i++) {
diagrams_.at(i)->setFreezeNewConductors(true);
}
}
/**
* @brief QETProject::unfreezeNewElementLabel
* Unfreeze New Conductors in the selected folios
* @param from - first folio index to apply unfreeze
* @param to - last folio index to apply unfreeze
*/
void QETProject::unfreezeNewConductorLabel(int from, int to) {
for (int i = from; i <= to; i++) {
diagrams_.at(i)->setFreezeNewConductors(false);
}
}
/**
* @brief QETProject::freezeNewConductors
* @return freeze new conductors Project Wide status
*/
bool QETProject::freezeNewConductors() {
return m_freeze_new_conductors;
}
/**
* @brief QETProject::setfreezeNewConductors
* Set Project Wide freeze new conductors
*/
void QETProject::setFreezeNewConductors(bool set) {
m_freeze_new_conductors = set;
}
/** /**
* @brief QETProject::freezeExistentElementLabel * @brief QETProject::freezeExistentElementLabel
* Freeze Existent Elements in the selected folios * Freeze Existent Elements in the selected folios
@ -659,7 +724,7 @@ void QETProject::unfreezeExistentElementLabel(int from, int to) {
*/ */
void QETProject::freezeNewElementLabel(int from, int to) { void QETProject::freezeNewElementLabel(int from, int to) {
for (int i = from; i <= to; i++) { for (int i = from; i <= to; i++) {
diagrams_.at(i)->freezeNew(); diagrams_.at(i)->setFreezeNewElements(true);
} }
} }
@ -671,7 +736,7 @@ void QETProject::freezeNewElementLabel(int from, int to) {
*/ */
void QETProject::unfreezeNewElementLabel(int from, int to) { void QETProject::unfreezeNewElementLabel(int from, int to) {
for (int i = from; i <= to; i++) { for (int i = from; i <= to; i++) {
diagrams_.at(i)->unfreezeNew(); diagrams_.at(i)->setFreezeNewElements(false);
} }
} }
@ -1410,6 +1475,7 @@ void QETProject::readDefaultPropertiesXml(QDomDocument &xml_project)
{ {
m_current_conductor_autonum = conds_autonums.attribute("current_autonum"); m_current_conductor_autonum = conds_autonums.attribute("current_autonum");
m_current_conductor_formula = conds_autonums.attribute("current_formula"); m_current_conductor_formula = conds_autonums.attribute("current_formula");
m_freeze_new_conductors = conds_autonums.attribute("freeze_new_conductors") == "true";
foreach (QDomElement elmt, QET::findInDomElement(conds_autonums, "conductor_autonum")) foreach (QDomElement elmt, QET::findInDomElement(conds_autonums, "conductor_autonum"))
{ {
NumerotationContext nc; NumerotationContext nc;
@ -1431,7 +1497,7 @@ void QETProject::readDefaultPropertiesXml(QDomDocument &xml_project)
{ {
m_current_element_autonum = element_autonums.attribute("current_autonum"); m_current_element_autonum = element_autonums.attribute("current_autonum");
m_current_element_formula = element_autonums.attribute("current_formula"); m_current_element_formula = element_autonums.attribute("current_formula");
m_freeze_new_elements = element_autonums.attribute("freeze_new_elements").toInt(); m_freeze_new_elements = element_autonums.attribute("freeze_new_elements") == "true";
foreach (QDomElement elmt, QET::findInDomElement(element_autonums, "element_autonum")) foreach (QDomElement elmt, QET::findInDomElement(element_autonums, "element_autonum"))
{ {
NumerotationContext nc; NumerotationContext nc;
@ -1496,6 +1562,7 @@ void QETProject::writeDefaultPropertiesXml(QDomElement &xml_element) {
QDomElement conductor_autonums = xml_document.createElement("conductors_autonums"); QDomElement conductor_autonums = xml_document.createElement("conductors_autonums");
conductor_autonums.setAttribute("current_autonum", m_current_conductor_autonum); conductor_autonums.setAttribute("current_autonum", m_current_conductor_autonum);
conductor_autonums.setAttribute("current_formula", m_current_conductor_formula); conductor_autonums.setAttribute("current_formula", m_current_conductor_formula);
conductor_autonums.setAttribute("freeze_new_conductors", m_freeze_new_conductors ? "true" : "false");
foreach (QString key, conductorAutoNum().keys()) { foreach (QString key, conductorAutoNum().keys()) {
QDomElement conductor_autonum = conductorAutoNum(key).toXml(xml_document, "conductor_autonum"); QDomElement conductor_autonum = conductorAutoNum(key).toXml(xml_document, "conductor_autonum");
if (key != "" && conductorAutoNumFormula(key) != "") { if (key != "" && conductorAutoNumFormula(key) != "") {

View File

@ -133,6 +133,7 @@ class QETProject : public QObject
QString elementAutoNumCurrentFormula() const; QString elementAutoNumCurrentFormula() const;
QString elementCurrentAutoNum() const; QString elementCurrentAutoNum() const;
//Element
void freezeExistentElementLabel(int,int); void freezeExistentElementLabel(int,int);
void freezeNewElementLabel(int,int); void freezeNewElementLabel(int,int);
void unfreezeExistentElementLabel(int,int); void unfreezeExistentElementLabel(int,int);
@ -140,6 +141,14 @@ class QETProject : public QObject
bool freezeNewElements(); bool freezeNewElements();
void setFreezeNewElements(bool); void setFreezeNewElements(bool);
//Conductor
void freezeExistentConductorLabel(int,int);
void unfreezeExistentConductorLabel(int,int);
void freezeNewConductorLabel(int,int);
void unfreezeNewConductorLabel(int,int);
bool freezeNewConductors();
void setFreezeNewConductors(bool);
bool autoConductor () const; bool autoConductor () const;
bool autoElement () const; bool autoElement () const;
bool autoFolio () const; bool autoFolio () const;
@ -268,6 +277,7 @@ class QETProject : public QObject
bool m_auto_conductor; bool m_auto_conductor;
XmlElementCollection *m_elements_collection; XmlElementCollection *m_elements_collection;
bool m_freeze_new_elements; bool m_freeze_new_elements;
bool m_freeze_new_conductors;
}; };
Q_DECLARE_METATYPE(QETProject *) Q_DECLARE_METATYPE(QETProject *)
#endif #endif

View File

@ -37,7 +37,6 @@ AutoNumberingManagementW::AutoNumberingManagementW(QETProject *project, QWidget
ui->setupUi(this); ui->setupUi(this);
ui->m_apply_locations_rb->setHidden(true); ui->m_apply_locations_rb->setHidden(true);
ui->m_selected_locations_le->setHidden(true); ui->m_selected_locations_le->setHidden(true);
ui->conductorWidget->setHidden(true);
ui->folioWidget->setHidden(true); ui->folioWidget->setHidden(true);
ui->m_selected_folios_widget->setDisabled(true); ui->m_selected_folios_widget->setDisabled(true);
ui->m_selected_folios_le->setDisabled(true); ui->m_selected_folios_le->setDisabled(true);

View File

@ -76,7 +76,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>630</width> <width>630</width>
<height>498</height> <height>495</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy"> <property name="sizePolicy">
@ -254,6 +254,16 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QRadioButton" name="m_both_conductor_rb">
<property name="text">
<string>Both</string>
</property>
<property name="autoExclusive">
<bool>true</bool>
</property>
</widget>
</item>
<item> <item>
<widget class="QRadioButton" name="m_new_conductor_rb"> <widget class="QRadioButton" name="m_new_conductor_rb">
<property name="text"> <property name="text">
@ -267,17 +277,7 @@
<item> <item>
<widget class="QRadioButton" name="m_existent_conductor_rb"> <widget class="QRadioButton" name="m_existent_conductor_rb">
<property name="text"> <property name="text">
<string>Existent and New</string> <string>Only Existent</string>
</property>
<property name="autoExclusive">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="m_both_conductor_rb">
<property name="text">
<string>Both</string>
</property> </property>
<property name="autoExclusive"> <property name="autoExclusive">
<bool>true</bool> <bool>true</bool>