mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-21 16:50:53 +01:00
When link report, check if all text of the potential is equal.
If not ask user what must to do. git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@2801 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2014 The QElectroTech Team
|
||||
Copyright 2006-2014 The QElectroTech team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -79,6 +79,30 @@ void ConductorAutoNumerotation::numerateDiagram() {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief ConductorAutoNumerotation::checkPotential
|
||||
* Check if text of this potential is identical.
|
||||
* If not, ask user how to numerate
|
||||
* @param conductor
|
||||
* One conductor of this potential.
|
||||
*/
|
||||
void ConductorAutoNumerotation::checkPotential(Conductor *conductor) {
|
||||
//fill list of potential
|
||||
QSet <Conductor *> c_list = conductor->relatedPotentialConductors();
|
||||
c_list << conductor;
|
||||
//fill list of text
|
||||
QStringList strl;
|
||||
foreach (const Conductor *c, c_list) strl<<(c->text());
|
||||
|
||||
//check text list, isn't same in potential, ask user what to do
|
||||
if (!eachIsEqual(strl)) {
|
||||
ConductorAutoNumerotationWidget *canw = new ConductorAutoNumerotationWidget(conductor, c_list, conductor -> diagramEditor());
|
||||
ConductorAutoNumerotation can(conductor);
|
||||
connect(canw, SIGNAL(textIsSelected(QString)), &can, SLOT(applyText(QString)));
|
||||
canw -> exec();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief ConductorAutoNumerotation::applyText
|
||||
* apply the text @t to @conductor_ and all conductors at the same potential
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2014 The QElectroTech Team
|
||||
Copyright 2006-2014 The QElectroTech team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -34,6 +34,7 @@ class ConductorAutoNumerotation: public AutoNumerotation
|
||||
void numerate();
|
||||
void numerateDiagram();
|
||||
void removeNumOfDiagram();
|
||||
static void checkPotential(Conductor *);
|
||||
|
||||
public slots:
|
||||
void applyText(QString);
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include "elementtextitem.h"
|
||||
#include "diagramposition.h"
|
||||
#include "qetproject.h"
|
||||
#include "conductorautonumerotation.h"
|
||||
|
||||
ReportElement::ReportElement(const ElementsLocation &location, QString link_type,QGraphicsItem *qgi, Diagram *s, int *state) :
|
||||
CustomElement(location, qgi, s, state)
|
||||
@@ -56,8 +57,11 @@ void ReportElement::linkToElement(Element * elmt) {
|
||||
connect(elmt, SIGNAL(positionChange(QPointF)), this, SLOT(updateLabel()));
|
||||
connect(diagram()->project(), SIGNAL(projectDiagramsOrderChanged(QETProject*,int,int)), this, SLOT(updateLabel()));
|
||||
updateLabel();
|
||||
tmp_uuids_link.removeAll(elmt->uuid());
|
||||
elmt->linkToElement(this);
|
||||
//Check if text of this potential is identical.
|
||||
if (conductors().count() && elmt->conductors().count()) {
|
||||
ConductorAutoNumerotation::checkPotential(conductors().first());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,14 +121,16 @@ void ReportElement::setLabel(QString label) {
|
||||
* ie the folio and position of the linked folio report
|
||||
*/
|
||||
void ReportElement::updateLabel() {
|
||||
ElementTextItem *text = texts().first();
|
||||
|
||||
if (!connected_elements.isEmpty()){
|
||||
Element *elmt = connected_elements.at(0);
|
||||
QString label = label_;
|
||||
label.replace("%f", QString::number(elmt->diagram()->folioIndex()+1));
|
||||
label.replace("%c", QString::number(elmt->diagram() -> convertPosition(elmt -> scenePos()).number()));
|
||||
label.replace("%l", elmt->diagram() -> convertPosition(elmt -> scenePos()).letter());
|
||||
texts().at(0)->setPlainText(label);
|
||||
text->setPlainText(label);
|
||||
} else {
|
||||
texts().at(0)->setPlainText("_");
|
||||
text->setPlainText("_");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user