2017-08-03 17:36:08 +00:00
|
|
|
/*
|
|
|
|
Copyright 2006-2017 The QElectroTech Team
|
|
|
|
This file is part of QElectroTech.
|
|
|
|
|
|
|
|
QElectroTech is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
QElectroTech is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
#ifndef DYNAMICELEMENTTEXTITEM_H
|
|
|
|
#define DYNAMICELEMENTTEXTITEM_H
|
|
|
|
|
|
|
|
#include "diagramtextitem.h"
|
|
|
|
#include <QUuid>
|
2017-08-16 13:52:15 +00:00
|
|
|
#include <QPointer>
|
2017-08-03 17:36:08 +00:00
|
|
|
|
|
|
|
class Element;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief The DynamicElementTextItem class
|
|
|
|
* This class provide a simple text field of element who can be added or removed directly from the diagram editor.
|
|
|
|
* This text is created to compensate a big lack of the ElementTextItem : ElementTextItem can't be added or removed directly in the diagram editor
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
class DynamicElementTextItem : public DiagramTextItem
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
Q_PROPERTY(QString tagg READ tagg WRITE setTagg NOTIFY taggChanged)
|
|
|
|
Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged)
|
2017-08-16 13:52:15 +00:00
|
|
|
Q_PROPERTY(TextFrom textFrom READ textFrom WRITE setTextFrom NOTIFY textFromChanged)
|
|
|
|
Q_PROPERTY(QString infoName READ infoName WRITE setInfoName NOTIFY infoNameChanged)
|
|
|
|
Q_PROPERTY(QString compositeText READ compositeText WRITE setCompositeText NOTIFY compositeTextChanged)
|
2017-08-03 17:36:08 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
Q_ENUMS(TextFrom)
|
|
|
|
enum TextFrom {
|
|
|
|
UserText,
|
2017-08-16 13:52:15 +00:00
|
|
|
ElementInfo,
|
|
|
|
CompositeText
|
2017-08-03 17:36:08 +00:00
|
|
|
};
|
|
|
|
enum {Type = UserType + 1010};
|
2017-08-05 02:10:01 +00:00
|
|
|
int type() const override {return Type;}
|
2017-08-03 17:36:08 +00:00
|
|
|
|
|
|
|
signals:
|
|
|
|
void taggChanged(QString tagg);
|
|
|
|
void textChanged(QString text);
|
2017-08-16 13:52:15 +00:00
|
|
|
void textFromChanged(DynamicElementTextItem::TextFrom text_from);
|
|
|
|
void infoNameChanged(QString info);
|
|
|
|
void compositeTextChanged(QString text);
|
2017-08-03 17:36:08 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
DynamicElementTextItem(Element *parent_element);
|
2017-08-05 02:10:01 +00:00
|
|
|
~DynamicElementTextItem() override;
|
2017-08-03 17:36:08 +00:00
|
|
|
private:
|
|
|
|
DynamicElementTextItem(const DynamicElementTextItem &);
|
|
|
|
|
|
|
|
public:
|
2017-08-05 02:10:01 +00:00
|
|
|
QDomElement toXml(QDomDocument &dom_doc) const override;
|
|
|
|
void fromXml(const QDomElement &dom_elmt) override;
|
2017-08-03 17:36:08 +00:00
|
|
|
|
2017-08-22 18:27:23 +00:00
|
|
|
Element *parentElement() const;
|
2017-08-29 14:54:27 +00:00
|
|
|
Element *elementUseForInfo() const;
|
2017-08-03 17:36:08 +00:00
|
|
|
|
|
|
|
DynamicElementTextItem::TextFrom textFrom() const;
|
|
|
|
void setTextFrom (DynamicElementTextItem::TextFrom text_from);
|
|
|
|
QString tagg() const;
|
|
|
|
void setTagg(const QString &tagg);
|
|
|
|
QString text() const;
|
|
|
|
void setText(const QString &text);
|
|
|
|
static QString xmlTaggName() {return QString("dynamic_elmt_text");}
|
2017-08-06 10:18:33 +00:00
|
|
|
void setInfoName(const QString &info_name);
|
|
|
|
QString infoName() const;
|
2017-08-16 13:52:15 +00:00
|
|
|
void setCompositeText(const QString &text);
|
|
|
|
QString compositeText() const;
|
2017-08-03 17:36:08 +00:00
|
|
|
|
|
|
|
protected:
|
2017-08-05 02:10:01 +00:00
|
|
|
void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override;
|
|
|
|
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override;
|
2017-08-29 14:54:27 +00:00
|
|
|
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) override;
|
2017-08-03 17:36:08 +00:00
|
|
|
|
2017-08-06 10:18:33 +00:00
|
|
|
private:
|
|
|
|
void elementInfoChanged();
|
2017-08-29 14:54:27 +00:00
|
|
|
void masterChanged();
|
2017-08-06 10:18:33 +00:00
|
|
|
|
2017-08-03 17:36:08 +00:00
|
|
|
private:
|
2017-08-29 14:54:27 +00:00
|
|
|
QPointer <Element> m_parent_element,
|
|
|
|
m_master_element;
|
2017-08-03 17:36:08 +00:00
|
|
|
QString m_tagg,
|
|
|
|
m_text,
|
2017-08-16 13:52:15 +00:00
|
|
|
m_info_name,
|
|
|
|
m_composite_text;
|
2017-08-03 17:36:08 +00:00
|
|
|
DynamicElementTextItem::TextFrom m_text_from = UserText;
|
|
|
|
QUuid m_uuid;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // DYNAMICELEMENTTEXTITEM_H
|