[qet] [2863] add base for master element feature |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/qet Archives
]
Revision: 2863
Author: blacksun
Date: 2014-02-18 21:44:54 +0100 (Tue, 18 Feb 2014)
Log Message:
-----------
add base for master element feature
Modified Paths:
--------------
trunk/sources/factory/elementfactory.cpp
trunk/sources/qetgraphicsitem/element.cpp
trunk/sources/qetgraphicsitem/element.h
trunk/sources/qetgraphicsitem/reportelement.cpp
trunk/sources/qetgraphicsitem/reportelement.h
trunk/sources/qetgraphicsitem/simpleelement.cpp
trunk/sources/qetgraphicsitem/simpleelement.h
trunk/sources/ui/elementpropertieswidget.cpp
trunk/sources/ui/elementpropertieswidget.h
Added Paths:
-----------
trunk/sources/qetgraphicsitem/masterelement.cpp
trunk/sources/qetgraphicsitem/masterelement.h
trunk/sources/ui/masterpropertieswidget.cpp
trunk/sources/ui/masterpropertieswidget.h
trunk/sources/ui/masterpropertieswidget.ui
Modified: trunk/sources/factory/elementfactory.cpp
===================================================================
--- trunk/sources/factory/elementfactory.cpp 2014-02-18 19:17:04 UTC (rev 2862)
+++ trunk/sources/factory/elementfactory.cpp 2014-02-18 20:44:54 UTC (rev 2863)
@@ -22,6 +22,7 @@
#include "QDomElement"
#include "qetgraphicsitem/simpleelement.h"
#include "qetgraphicsitem/reportelement.h"
+#include "qetgraphicsitem/masterelement.h"
ElementFactory* ElementFactory::factory_ = 0;
/**
@@ -46,7 +47,9 @@
if (element_definition->xml().hasAttribute("link_type")) {
QString link_type = element_definition->xml().attribute("link_type");
if (link_type == "next_report" || link_type == "previous_report") return (new ReportElement(location, link_type, qgi, s, state));
+ if (link_type == "master") return (new MasterElement(location, qgi, s, state));
}
+
//default if nothing match for link_type
return (new SimpleElement(location, qgi, s, state));
}
Modified: trunk/sources/qetgraphicsitem/element.cpp
===================================================================
--- trunk/sources/qetgraphicsitem/element.cpp 2014-02-18 19:17:04 UTC (rev 2862)
+++ trunk/sources/qetgraphicsitem/element.cpp 2014-02-18 20:44:54 UTC (rev 2863)
@@ -33,6 +33,7 @@
internal_connections_(false),
must_highlight_(false)
{
+ link_type_ = 0;
uuid_ = QUuid::createUuid();
setZValue(10);
}
Modified: trunk/sources/qetgraphicsitem/element.h
===================================================================
--- trunk/sources/qetgraphicsitem/element.h 2014-02-18 19:17:04 UTC (rev 2862)
+++ trunk/sources/qetgraphicsitem/element.h 2014-02-18 20:44:54 UTC (rev 2863)
@@ -107,6 +107,7 @@
virtual void unlinkElement(Element *) {}
void initLink(QETProject *);
QList<Element *> linkedElements () const;
+ virtual int linkType() const {return link_type_;} // @return the linkable type
void newUuid() {uuid_ = QUuid::createUuid();} //create new uuid for this element
//ATTRIBUTES related to linked element
@@ -114,6 +115,7 @@
QList <Element *> connected_elements;
QList <QUuid> tmp_uuids_link;
QUuid uuid_;
+ int link_type_;
//METHODS related to information
public:
@@ -133,8 +135,6 @@
virtual QString typeId() const = 0;
/// @return the human name for this element
virtual QString name() const = 0;
- /// @return the linkable type
- virtual int linkType() const = 0;
virtual bool isHighlighted() const;
virtual void setHighlighted(bool);
Added: trunk/sources/qetgraphicsitem/masterelement.cpp
===================================================================
--- trunk/sources/qetgraphicsitem/masterelement.cpp (rev 0)
+++ trunk/sources/qetgraphicsitem/masterelement.cpp 2014-02-18 20:44:54 UTC (rev 2863)
@@ -0,0 +1,67 @@
+#include "masterelement.h"
+
+/**
+ * @brief MasterElement::MasterElement
+ * Default constructor
+ * @param location location of xml definition
+ * @param qgi parent QGraphicItem
+ * @param s parent diagram
+ * @param state int used to know if the creation of element have error
+ */
+MasterElement::MasterElement(const ElementsLocation &location, QGraphicsItem *qgi, Diagram *s, int *state) :
+ CustomElement(location, qgi, s, state)
+{
+ link_type_ = Master;
+}
+
+/**
+ * @brief MasterElement::~MasterElement
+ * default destructor
+ */
+MasterElement::~MasterElement() {
+ unlinkAllElements();
+}
+
+/**
+ * @brief MasterElement::linkToElement
+ * Link this master to another element
+ * For this class element must be a slave
+ * @param elmt
+ */
+void MasterElement::linkToElement(Element *elmt) {
+ // check if this element is already linked
+ if (connected_elements.contains(elmt)) return;
+
+ //check if elmt is a slave
+ if (elmt->linkType() == SlaveNO || elmt->linkType() == SlaveNC) {
+ ///TODO create the cross ref and connection
+ connected_elements << elmt;
+ elmt->linkToElement(this);
+ }
+}
+
+/**
+ * @brief MasterElement::unlinkAllElements
+ * Unlink all of the element in the QList connected_elements
+ */
+void MasterElement::unlinkAllElements() {
+ // if this element is free no need to do something
+ if (!isFree()) {
+ foreach(Element *elmt, connected_elements) {
+ unlinkElement(elmt);
+ }
+ }
+}
+
+/**
+ * @brief MasterElement::unlinkElement
+ * Unlink the given elmt in parametre
+ * @param elmt element to unlink from this
+ */
+void MasterElement::unlinkElement(Element *elmt) {
+ //Ensure elmt is linked to this element
+ if (connected_elements.contains(elmt)) {
+ connected_elements.removeOne(elmt);
+ elmt->unlinkElement(this);
+ }
+}
Added: trunk/sources/qetgraphicsitem/masterelement.h
===================================================================
--- trunk/sources/qetgraphicsitem/masterelement.h (rev 0)
+++ trunk/sources/qetgraphicsitem/masterelement.h 2014-02-18 20:44:54 UTC (rev 2863)
@@ -0,0 +1,23 @@
+#ifndef MASTERELEMENT_H
+#define MASTERELEMENT_H
+
+#include "customelement.h"
+
+class MasterElement : public CustomElement
+{
+ Q_OBJECT
+
+ public:
+ explicit MasterElement(const ElementsLocation &, QGraphicsItem * = 0, Diagram * = 0, int * = 0);
+ ~MasterElement();
+ virtual void linkToElement(Element *elmt);
+ virtual void unlinkAllElements();
+ virtual void unlinkElement(Element *elmt);
+
+ signals:
+
+ public slots:
+
+};
+
+#endif // MASTERELEMENT_H
Modified: trunk/sources/qetgraphicsitem/reportelement.cpp
===================================================================
--- trunk/sources/qetgraphicsitem/reportelement.cpp 2014-02-18 19:17:04 UTC (rev 2862)
+++ trunk/sources/qetgraphicsitem/reportelement.cpp 2014-02-18 20:44:54 UTC (rev 2863)
@@ -93,14 +93,6 @@
}
/**
- * @brief ReportElement::linkType
- * @return the kind of link type
- */
-int ReportElement::linkType() const {
- return link_type_;
-}
-
-/**
* @brief ReportElement::setLabel
* Set new label and call updatelabel
* @param label new label
Modified: trunk/sources/qetgraphicsitem/reportelement.h
===================================================================
--- trunk/sources/qetgraphicsitem/reportelement.h 2014-02-18 19:17:04 UTC (rev 2862)
+++ trunk/sources/qetgraphicsitem/reportelement.h 2014-02-18 20:44:54 UTC (rev 2863)
@@ -35,10 +35,8 @@
virtual void linkToElement(Element *);
virtual void unlinkAllElements();
virtual void unlinkElement(Element *elmt);
- virtual int linkType() const;
private:
- int link_type_;
int inverse_report;
QString label_;
Modified: trunk/sources/qetgraphicsitem/simpleelement.cpp
===================================================================
--- trunk/sources/qetgraphicsitem/simpleelement.cpp 2014-02-18 19:17:04 UTC (rev 2862)
+++ trunk/sources/qetgraphicsitem/simpleelement.cpp 2014-02-18 20:44:54 UTC (rev 2863)
@@ -19,8 +19,6 @@
SimpleElement::SimpleElement(const ElementsLocation &location, QGraphicsItem *qgi, Diagram *s, int *state) :
CustomElement(location, qgi, s, state)
-{}
-
-int SimpleElement::linkType() const {
- return Simple;
+{
+ link_type_ = Simple;
}
Modified: trunk/sources/qetgraphicsitem/simpleelement.h
===================================================================
--- trunk/sources/qetgraphicsitem/simpleelement.h 2014-02-18 19:17:04 UTC (rev 2862)
+++ trunk/sources/qetgraphicsitem/simpleelement.h 2014-02-18 20:44:54 UTC (rev 2863)
@@ -31,8 +31,6 @@
public :
explicit SimpleElement(const ElementsLocation &, QGraphicsItem * = 0, Diagram * = 0, int * = 0);
- virtual int linkType() const;
-
signals:
public slots:
Modified: trunk/sources/ui/elementpropertieswidget.cpp
===================================================================
--- trunk/sources/ui/elementpropertieswidget.cpp 2014-02-18 19:17:04 UTC (rev 2862)
+++ trunk/sources/ui/elementpropertieswidget.cpp 2014-02-18 20:44:54 UTC (rev 2863)
@@ -33,6 +33,7 @@
{
frp_ = 0;
eiw_ = 0;
+ mpw_ = 0;
buildInterface();
}
@@ -105,7 +106,6 @@
setWindowTitle(tr("Propri\351t\351s de l'\351l\351ment"));
tab_ = new QTabWidget(this);
- tab_ -> addTab(generalWidget(), tr("G\351n\351ral"));
//Add tab according to the element
switch (element_ -> linkType()) {
@@ -122,6 +122,8 @@
tab_ -> addTab(frp_, tr("Report de folio"));
break;
case Element::Master:
+ mpw_ = new MasterPropertiesWidget(this);
+ tab_ -> addTab(mpw_, tr("R\351f\351rence crois\351 (maitre)"));
eiw_ = new ElementInfoWidget(element_, this);
tab_ -> addTab(eiw_, tr("Information"));
break;
@@ -135,6 +137,8 @@
break;
}
+ tab_ -> addTab(generalWidget(), tr("G\351n\351ral"));
+
dbb = new QDialogButtonBox(QDialogButtonBox::Apply | QDialogButtonBox::Cancel | QDialogButtonBox::Reset,
Qt::Horizontal, this);
connect(dbb, SIGNAL(clicked(QAbstractButton*)), this, SLOT(standardButtonClicked(QAbstractButton*)));
Modified: trunk/sources/ui/elementpropertieswidget.h
===================================================================
--- trunk/sources/ui/elementpropertieswidget.h 2014-02-18 19:17:04 UTC (rev 2862)
+++ trunk/sources/ui/elementpropertieswidget.h 2014-02-18 20:44:54 UTC (rev 2863)
@@ -23,6 +23,7 @@
#include <diagram.h>
#include <folioreportproperties.h>
#include <elementinfowidget.h>
+#include <masterpropertieswidget.h>
class elementpropertieswidget : public QDialog
{
@@ -48,6 +49,7 @@
private:
FolioReportProperties *frp_;
ElementInfoWidget *eiw_;
+ MasterPropertiesWidget *mpw_;
QDialogButtonBox *dbb;
Element *element_;
Diagram *diagram_;
Added: trunk/sources/ui/masterpropertieswidget.cpp
===================================================================
--- trunk/sources/ui/masterpropertieswidget.cpp (rev 0)
+++ trunk/sources/ui/masterpropertieswidget.cpp 2014-02-18 20:44:54 UTC (rev 2863)
@@ -0,0 +1,14 @@
+#include "masterpropertieswidget.h"
+#include "ui_masterpropertieswidget.h"
+
+MasterPropertiesWidget::MasterPropertiesWidget(QWidget *parent) :
+ QWidget(parent),
+ ui(new Ui::MasterPropertiesWidget)
+{
+ ui->setupUi(this);
+}
+
+MasterPropertiesWidget::~MasterPropertiesWidget()
+{
+ delete ui;
+}
Added: trunk/sources/ui/masterpropertieswidget.h
===================================================================
--- trunk/sources/ui/masterpropertieswidget.h (rev 0)
+++ trunk/sources/ui/masterpropertieswidget.h 2014-02-18 20:44:54 UTC (rev 2863)
@@ -0,0 +1,22 @@
+#ifndef MASTERPROPERTIESWIDGET_H
+#define MASTERPROPERTIESWIDGET_H
+
+#include <QWidget>
+
+namespace Ui {
+ class MasterPropertiesWidget;
+}
+
+class MasterPropertiesWidget : public QWidget
+{
+ Q_OBJECT
+
+ public:
+ explicit MasterPropertiesWidget(QWidget *parent = 0);
+ ~MasterPropertiesWidget();
+
+ private:
+ Ui::MasterPropertiesWidget *ui;
+};
+
+#endif // MASTERPROPERTIESWIDGET_H
Added: trunk/sources/ui/masterpropertieswidget.ui
===================================================================
--- trunk/sources/ui/masterpropertieswidget.ui (rev 0)
+++ trunk/sources/ui/masterpropertieswidget.ui 2014-02-18 20:44:54 UTC (rev 2863)
@@ -0,0 +1,21 @@
+<ui version="4.0">
+ <author/>
+ <comment/>
+ <exportmacro/>
+ <class>MasterPropertiesWidget</class>
+ <widget class="QWidget" name="MasterPropertiesWidget">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>400</width>
+ <height>300</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ </widget>
+ <pixmapfunction/>
+ <connections/>
+</ui>