update folio report when move diagram position

git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@2692 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
blacksun
2014-01-01 16:28:19 +00:00
parent b18576895a
commit c58448bf76
8 changed files with 18 additions and 10 deletions

View File

@@ -767,7 +767,7 @@ void Diagram::removeElement(Element *element) {
if (!element || isReadOnly()) return; if (!element || isReadOnly()) return;
// remove all links of element // remove all links of element
element->unLinkAllElements(); element->unlinkAllElements();
// enleve l'element au schema // enleve l'element au schema
removeItem(element); removeItem(element);

View File

@@ -38,7 +38,7 @@ ElementProvider::ElementProvider(QETProject *prj, Diagram *diagram)
* (You can find all filter with the #define in Element.h) * (You can find all filter with the #define in Element.h)
* @return * @return
*/ */
QList <Element *> ElementProvider::FreeElement(const int filter) const{ QList <Element *> ElementProvider::freeElement(const int filter) const{
QList <Element *> free_elmt; QList <Element *> free_elmt;
//serch in all diagram //serch in all diagram

View File

@@ -32,7 +32,7 @@ class ElementProvider
{ {
public: public:
ElementProvider(QETProject *prj, Diagram *diagram=0); ElementProvider(QETProject *prj, Diagram *diagram=0);
QList <Element *> FreeElement(const int filter) const; QList <Element *> freeElement(const int filter) const;
QList <Element *> fromUuids(QList <QUuid>) const; QList <Element *> fromUuids(QList <QUuid>) const;
private: private:

View File

@@ -89,7 +89,7 @@ class Element : public QetGraphicsItem {
// related method for link between element // related method for link between element
bool isFree () const; bool isFree () const;
virtual void linkToElement(Element *) {} virtual void linkToElement(Element *) {}
virtual void unLinkAllElements() {} virtual void unlinkAllElements() {}
void initLink(QETProject *); void initLink(QETProject *);
QList<Element *> linkedElements () const; QList<Element *> linkedElements () const;

View File

@@ -18,6 +18,7 @@
#include "reportelement.h" #include "reportelement.h"
#include "elementtextitem.h" #include "elementtextitem.h"
#include "diagramposition.h" #include "diagramposition.h"
#include "qetproject.h"
ReportElement::ReportElement(const ElementsLocation &location, QGraphicsItem *qgi, Diagram *s, int *state) : ReportElement::ReportElement(const ElementsLocation &location, QGraphicsItem *qgi, Diagram *s, int *state) :
CustomElement(location, qgi, s, state) CustomElement(location, qgi, s, state)
@@ -25,6 +26,10 @@ ReportElement::ReportElement(const ElementsLocation &location, QGraphicsItem *qg
texts().at(0)->setNoEditable(); texts().at(0)->setNoEditable();
} }
ReportElement::~ReportElement() {
unlinkAllElements();
}
/** /**
* @brief ReportElement::linkToElement * @brief ReportElement::linkToElement
* Link this element to the other element * Link this element to the other element
@@ -40,9 +45,10 @@ void ReportElement::linkToElement(Element * elmt) {
//ensure elmt is a report //ensure elmt is a report
if (elmt->linkType() == Report && i) { if (elmt->linkType() == Report && i) {
unLinkAllElements(); unlinkAllElements();
connected_elements << elmt; connected_elements << elmt;
connect(elmt, SIGNAL(positionChange(QPointF)), this, SLOT(updateLabel())); connect(elmt, SIGNAL(positionChange(QPointF)), this, SLOT(updateLabel()));
connect(diagram()->project(), SIGNAL(projectDiagramsOrderChanged(QETProject*,int,int)), this, SLOT(updateLabel()));
updateLabel(); updateLabel();
tmp_uuids_link.removeAll(elmt->uuid()); tmp_uuids_link.removeAll(elmt->uuid());
elmt->linkToElement(this); elmt->linkToElement(this);
@@ -53,18 +59,19 @@ void ReportElement::linkToElement(Element * elmt) {
* @brief ReportElement::unLinkAllElements * @brief ReportElement::unLinkAllElements
* Unlink all of the element in the QList connected_elements * Unlink all of the element in the QList connected_elements
*/ */
void ReportElement::unLinkAllElements(){ void ReportElement::unlinkAllElements(){
if (!isFree()){ if (!isFree()){
QList <Element *> tmp_elmt = connected_elements; QList <Element *> tmp_elmt = connected_elements;
foreach(Element *elmt, connected_elements) { foreach(Element *elmt, connected_elements) {
disconnect(elmt, SIGNAL(positionChange(QPointF)), this, SLOT(updateLabel())); disconnect(elmt, SIGNAL(positionChange(QPointF)), this, SLOT(updateLabel()));
disconnect(diagram()->project(), SIGNAL(projectDiagramsOrderChanged(QETProject*,int,int)), this, SLOT(updateLabel()));
} }
connected_elements.clear(); connected_elements.clear();
updateLabel(); updateLabel();
foreach(Element *elmt, tmp_elmt){ foreach(Element *elmt, tmp_elmt){
elmt->unLinkAllElements(); elmt->unlinkAllElements();
} }
} }
} }

View File

@@ -31,8 +31,9 @@ class ReportElement : public CustomElement {
public : public :
explicit ReportElement(const ElementsLocation &, QGraphicsItem * = 0, Diagram * = 0, int * = 0); explicit ReportElement(const ElementsLocation &, QGraphicsItem * = 0, Diagram * = 0, int * = 0);
~ReportElement();
virtual void linkToElement(Element *); virtual void linkToElement(Element *);
virtual void unLinkAllElements(); virtual void unlinkAllElements();
virtual int linkType() const; virtual int linkType() const;
private: private:

View File

@@ -37,7 +37,7 @@ FolioReportProperties::~FolioReportProperties()
*/ */
void FolioReportProperties::BuildRadioList() { void FolioReportProperties::BuildRadioList() {
ElementProvider ep(element_->diagram()->project(), element_->diagram()); ElementProvider ep(element_->diagram()->project(), element_->diagram());
QList <Element *> elmt_list = ep.FreeElement(Element::Report); QList <Element *> elmt_list = ep.freeElement(Element::Report);
foreach (Element *elmt, elmt_list) { foreach (Element *elmt, elmt_list) {
if (elmt != element_) { if (elmt != element_) {

View File

@@ -15,7 +15,7 @@
</property> </property>
<layout class="QHBoxLayout" name="horizontalLayout"> <layout class="QHBoxLayout" name="horizontalLayout">
<item> <item>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QHBoxLayout" name="main_H_layout">
<item> <item>
<widget class="QGroupBox" name="Report_gb"> <widget class="QGroupBox" name="Report_gb">
<property name="toolTip"> <property name="toolTip">