mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-05-22 13:19:58 +02:00
Improve code style, Wrap code for better readability, Mod doc
This commit is contained in:
@@ -26,10 +26,15 @@ class QETProject;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
@brief The ProjectDBModel class
|
@brief The ProjectDBModel class
|
||||||
This model is intended to be use with the @class projectDataBase
|
This model is intended to be use with the class projectDataBase
|
||||||
and is designed to be displayed by the @class QetGraphicsTableItem (but can be use by other view class since it inherit from QAbstractTableModel).
|
and is designed to be displayed by the class QetGraphicsTableItem
|
||||||
This class should be sufficient to display the content of the project data base from a query set by the method void ProjectDBModel::setQuery(const QString &query).
|
(but can be use by other view class since it inherit from QAbstractTableModel).
|
||||||
The indentifier method is used by widget editor to retrieve the good widget for edit the query. By defaut identifer return the string 'unknow'.
|
This class should be sufficient to display the content of
|
||||||
|
the project data base from a query set by the method
|
||||||
|
void ProjectDBModel::setQuery(const QString &query).
|
||||||
|
The indentifier method is used by widget editor to retrieve
|
||||||
|
the good widget for edit the query.
|
||||||
|
By defaut identifer return the string 'unknow'.
|
||||||
You should use setIdentfier method to set your custom identifier.
|
You should use setIdentfier method to set your custom identifier.
|
||||||
At the time this sentence is written, there is two identifier :
|
At the time this sentence is written, there is two identifier :
|
||||||
nomenclature
|
nomenclature
|
||||||
@@ -37,39 +42,48 @@ class QETProject;
|
|||||||
*/
|
*/
|
||||||
class ProjectDBModel : public QAbstractTableModel
|
class ProjectDBModel : public QAbstractTableModel
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit ProjectDBModel(QETProject *project, QObject *parent = nullptr);
|
explicit ProjectDBModel(QETProject *project, QObject *parent = nullptr);
|
||||||
explicit ProjectDBModel (const ProjectDBModel &other_model);
|
explicit ProjectDBModel (const ProjectDBModel &other_model);
|
||||||
|
|
||||||
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||||
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
|
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||||
bool setHeaderData(int section, Qt::Orientation orientation, const QVariant &value, int role = Qt::EditRole) override;
|
bool setHeaderData(int section,
|
||||||
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
|
Qt::Orientation orientation,
|
||||||
bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
|
const QVariant &value,
|
||||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
int role = Qt::EditRole) override;
|
||||||
void setQuery(const QString &setQuery);
|
QVariant headerData(int section,
|
||||||
QString queryString() const;
|
Qt::Orientation orientation,
|
||||||
QETProject *project() const;
|
int role = Qt::DisplayRole) const override;
|
||||||
|
bool setData(const QModelIndex &index,
|
||||||
|
const QVariant &value,
|
||||||
|
int role = Qt::EditRole) override;
|
||||||
|
QVariant data(const QModelIndex &index,
|
||||||
|
int role = Qt::DisplayRole) const override;
|
||||||
|
void setQuery(const QString &setQuery);
|
||||||
|
QString queryString() const;
|
||||||
|
QETProject *project() const;
|
||||||
|
|
||||||
QDomElement toXml(QDomDocument &document) const;
|
QDomElement toXml(QDomDocument &document) const;
|
||||||
void fromXml(const QDomElement &element);
|
void fromXml(const QDomElement &element);
|
||||||
void setIdentifier(const QString &identifier);
|
void setIdentifier(const QString &identifier);
|
||||||
QString identifier() const {return m_identifier;}
|
QString identifier() const {return m_identifier;}
|
||||||
static QString xmlTagName() {return QString("project_data_base_model");}
|
static QString xmlTagName() {return QString("project_data_base_model");}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void dataBaseUpdated();
|
void dataBaseUpdated();
|
||||||
void setHeaderString();
|
void setHeaderString();
|
||||||
void fillValue();
|
void fillValue();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QPointer<QETProject> m_project;
|
QPointer<QETProject> m_project;
|
||||||
QString m_query;
|
QString m_query;
|
||||||
QVector<QStringList> m_record;
|
QVector<QStringList> m_record;
|
||||||
QHash<int, QHash<int, QVariant>> m_header_data; //First int = section, second int = Qt::role, QVariant = value
|
//First int = section, second int = Qt::role, QVariant = value
|
||||||
QHash<int, QVariant> m_index_0_0_data;
|
QHash<int, QHash<int, QVariant>> m_header_data;
|
||||||
|
QHash<int, QVariant> m_index_0_0_data;
|
||||||
QString m_identifier = "unknow";
|
QString m_identifier = "unknow";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -41,17 +41,17 @@ class QetGraphicsHeaderItem : public QGraphicsObject
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QetGraphicsHeaderItem(QGraphicsItem *parent = nullptr);
|
QetGraphicsHeaderItem(QGraphicsItem *parent = nullptr);
|
||||||
|
|
||||||
enum { Type = UserType + 1301 };
|
enum { Type = UserType + 1301 };
|
||||||
int type() const override { return Type; }
|
int type() const override { return Type; }
|
||||||
|
|
||||||
void setModel(QAbstractItemModel *model = nullptr);
|
void setModel(QAbstractItemModel *model = nullptr);
|
||||||
QAbstractItemModel *model() const;
|
QAbstractItemModel *model() const;
|
||||||
|
|
||||||
virtual QRectF boundingRect() const override;
|
virtual QRectF boundingRect() const override;
|
||||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
|
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
|
||||||
QRect rect() const;
|
QRect rect() const;
|
||||||
void resizeSection(int logicalIndex, int size);
|
void resizeSection(int logicalIndex, int size);
|
||||||
int sectionSize(int logical_index) const;
|
int sectionSize(int logical_index) const;
|
||||||
@@ -73,9 +73,9 @@ class QetGraphicsHeaderItem : public QGraphicsObject
|
|||||||
void adjustSize();
|
void adjustSize();
|
||||||
void modelReseted();
|
void modelReseted();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QRectF m_bounding_rect;
|
QRectF m_bounding_rect;
|
||||||
QAbstractItemModel *m_model = nullptr;
|
QAbstractItemModel *m_model = nullptr;
|
||||||
QVector<int> m_sections_minimum_width,
|
QVector<int> m_sections_minimum_width,
|
||||||
m_current_sections_width;
|
m_current_sections_width;
|
||||||
int m_section_height=1,
|
int m_section_height=1,
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ class QButtonGroup;
|
|||||||
*/
|
*/
|
||||||
class GraphicsTablePropertiesEditor : public PropertiesEditorWidget
|
class GraphicsTablePropertiesEditor : public PropertiesEditorWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit GraphicsTablePropertiesEditor(QetGraphicsTableItem *table = nullptr, QWidget *parent = nullptr);
|
explicit GraphicsTablePropertiesEditor(QetGraphicsTableItem *table = nullptr, QWidget *parent = nullptr);
|
||||||
|
|||||||
@@ -32,9 +32,9 @@ class ProjectDBModelPropertiesWidget;
|
|||||||
*/
|
*/
|
||||||
class ProjectDBModelPropertiesWidget : public PropertiesEditorWidget
|
class ProjectDBModelPropertiesWidget : public PropertiesEditorWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit ProjectDBModelPropertiesWidget(ProjectDBModel *model = nullptr, QWidget *parent = nullptr);
|
explicit ProjectDBModelPropertiesWidget(ProjectDBModel *model = nullptr, QWidget *parent = nullptr);
|
||||||
~ProjectDBModelPropertiesWidget();
|
~ProjectDBModelPropertiesWidget();
|
||||||
|
|
||||||
|
|||||||
@@ -1011,22 +1011,22 @@ QDomElement Conductor::toXml(QDomDocument &dom_document, QHash<Terminal *, int>
|
|||||||
dom_element.setAttribute("x", QString::number(pos().x()));
|
dom_element.setAttribute("x", QString::number(pos().x()));
|
||||||
dom_element.setAttribute("y", QString::number(pos().y()));
|
dom_element.setAttribute("y", QString::number(pos().y()));
|
||||||
|
|
||||||
// Terminal is uniquely identified by the uuid of the terminal and the element
|
// Terminal is uniquely identified by the uuid of the terminal and the element
|
||||||
if (terminal1->uuid().isNull()) {
|
if (terminal1->uuid().isNull()) {
|
||||||
// legacy method to identify the terminal
|
// legacy method to identify the terminal
|
||||||
dom_element.setAttribute("terminal1", table_adr_id.value(terminal1)); // for backward compability
|
dom_element.setAttribute("terminal1", table_adr_id.value(terminal1)); // for backward compability
|
||||||
} else {
|
} else {
|
||||||
dom_element.setAttribute("element1", terminal1->parentElement()->uuid().toString());
|
dom_element.setAttribute("element1", terminal1->parentElement()->uuid().toString());
|
||||||
dom_element.setAttribute("terminal1", terminal1->uuid().toString());
|
dom_element.setAttribute("terminal1", terminal1->uuid().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (terminal2->uuid().isNull()) {
|
if (terminal2->uuid().isNull()) {
|
||||||
// legacy method to identify the terminal
|
// legacy method to identify the terminal
|
||||||
dom_element.setAttribute("terminal2", table_adr_id.value(terminal2)); // for backward compability
|
dom_element.setAttribute("terminal2", table_adr_id.value(terminal2)); // for backward compability
|
||||||
} else {
|
} else {
|
||||||
dom_element.setAttribute("element2", terminal2->parentElement()->uuid().toString());
|
dom_element.setAttribute("element2", terminal2->parentElement()->uuid().toString());
|
||||||
dom_element.setAttribute("terminal2", terminal2->uuid().toString());
|
dom_element.setAttribute("terminal2", terminal2->uuid().toString());
|
||||||
}
|
}
|
||||||
dom_element.setAttribute("freezeLabel", m_freeze_label? "true" : "false");
|
dom_element.setAttribute("freezeLabel", m_freeze_label? "true" : "false");
|
||||||
|
|
||||||
// on n'exporte les segments du conducteur que si ceux-ci ont
|
// on n'exporte les segments du conducteur que si ceux-ci ont
|
||||||
@@ -2006,8 +2006,9 @@ Conductor * longuestConductorInPotential(Conductor *conductor, bool all_diagram)
|
|||||||
/**
|
/**
|
||||||
@brief relatedConductors
|
@brief relatedConductors
|
||||||
@param conductor
|
@param conductor
|
||||||
@return return all conductors who share the same terminals of @conductor given as parametre,
|
@return return all conductors who share the same terminals
|
||||||
except @conductor himself.
|
of conductor given as parametre,
|
||||||
|
except conductor himself.
|
||||||
*/
|
*/
|
||||||
QList <Conductor *> relatedConductors(const Conductor *conductor) {
|
QList <Conductor *> relatedConductors(const Conductor *conductor) {
|
||||||
QList<Conductor *> other_conductors_list = conductor -> terminal1 -> conductors();
|
QList<Conductor *> other_conductors_list = conductor -> terminal1 -> conductors();
|
||||||
|
|||||||
@@ -142,7 +142,7 @@ class Conductor : public QGraphicsObject
|
|||||||
void hoverEnterEvent(QGraphicsSceneHoverEvent *event) override;
|
void hoverEnterEvent(QGraphicsSceneHoverEvent *event) override;
|
||||||
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) override;
|
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) override;
|
||||||
QVariant itemChange(GraphicsItemChange, const QVariant &) override;
|
QVariant itemChange(GraphicsItemChange, const QVariant &) override;
|
||||||
bool sceneEventFilter(QGraphicsItem *watched, QEvent *event) override;
|
bool sceneEventFilter(QGraphicsItem *watched, QEvent *event) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void adjusteHandlerPos();
|
void adjusteHandlerPos();
|
||||||
|
|||||||
@@ -38,9 +38,9 @@ ConductorTextItem::ConductorTextItem(Conductor *parent_conductor) :
|
|||||||
Constructeur
|
Constructeur
|
||||||
@param text Le texte affiche par le champ de texte
|
@param text Le texte affiche par le champ de texte
|
||||||
@param parent_conductor Conducteur auquel ce texte est rattache
|
@param parent_conductor Conducteur auquel ce texte est rattache
|
||||||
@param parent_diagram Schema auquel ce texte et son conducteur parent sont rattaches
|
|
||||||
*/
|
*/
|
||||||
ConductorTextItem::ConductorTextItem(const QString &text, Conductor *parent_conductor) :
|
ConductorTextItem::ConductorTextItem(const QString &text,
|
||||||
|
Conductor *parent_conductor) :
|
||||||
DiagramTextItem(text, parent_conductor),
|
DiagramTextItem(text, parent_conductor),
|
||||||
parent_conductor_(parent_conductor),
|
parent_conductor_(parent_conductor),
|
||||||
moved_by_user_(false),
|
moved_by_user_(false),
|
||||||
|
|||||||
@@ -29,40 +29,40 @@ class Conductor;
|
|||||||
class ConductorTextItem : public DiagramTextItem
|
class ConductorTextItem : public DiagramTextItem
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
// constructors, destructor
|
// constructors, destructor
|
||||||
public:
|
public:
|
||||||
ConductorTextItem(Conductor * = nullptr);
|
ConductorTextItem(Conductor * = nullptr);
|
||||||
ConductorTextItem(const QString &, Conductor * = nullptr);
|
ConductorTextItem(const QString &, Conductor * = nullptr);
|
||||||
~ConductorTextItem() override;
|
~ConductorTextItem() override;
|
||||||
private:
|
private:
|
||||||
ConductorTextItem(const ConductorTextItem &);
|
ConductorTextItem(const ConductorTextItem &);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum { Type = UserType + 1006 };
|
enum { Type = UserType + 1006 };
|
||||||
Conductor *parentConductor() const;
|
Conductor *parentConductor() const;
|
||||||
void fromXml(const QDomElement &) override;
|
void fromXml(const QDomElement &) override;
|
||||||
int type() const override { return Type; }
|
int type() const override { return Type; }
|
||||||
virtual bool wasMovedByUser() const;
|
virtual bool wasMovedByUser() const;
|
||||||
virtual bool wasRotateByUser() const;
|
virtual bool wasRotateByUser() const;
|
||||||
virtual void forceMovedByUser(bool);
|
virtual void forceMovedByUser(bool);
|
||||||
virtual void forceRotateByUser(bool);
|
virtual void forceRotateByUser(bool);
|
||||||
virtual void setPos(const QPointF &pos);
|
virtual void setPos(const QPointF &pos);
|
||||||
virtual void setPos(qreal x, qreal y);
|
virtual void setPos(qreal x, qreal y);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void mousePressEvent (QGraphicsSceneMouseEvent *event) override;
|
void mousePressEvent (QGraphicsSceneMouseEvent *event) override;
|
||||||
void mouseMoveEvent (QGraphicsSceneMouseEvent *event) override;
|
void mouseMoveEvent (QGraphicsSceneMouseEvent *event) override;
|
||||||
void mouseReleaseEvent (QGraphicsSceneMouseEvent *event) override;
|
void mouseReleaseEvent (QGraphicsSceneMouseEvent *event) override;
|
||||||
void hoverEnterEvent(QGraphicsSceneHoverEvent *) override;
|
void hoverEnterEvent(QGraphicsSceneHoverEvent *) override;
|
||||||
void hoverLeaveEvent(QGraphicsSceneHoverEvent *) override;
|
void hoverLeaveEvent(QGraphicsSceneHoverEvent *) override;
|
||||||
void hoverMoveEvent(QGraphicsSceneHoverEvent *) override;
|
void hoverMoveEvent(QGraphicsSceneHoverEvent *) override;
|
||||||
|
|
||||||
// attributes
|
// attributes
|
||||||
private:
|
private:
|
||||||
Conductor *parent_conductor_;
|
Conductor *parent_conductor_;
|
||||||
bool moved_by_user_;
|
bool moved_by_user_;
|
||||||
bool rotate_by_user_;
|
bool rotate_by_user_;
|
||||||
QPointF before_mov_pos_;
|
QPointF before_mov_pos_;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ void DiagramImageItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *
|
|||||||
painter -> setRenderHint(QPainter::Antialiasing, false);
|
painter -> setRenderHint(QPainter::Antialiasing, false);
|
||||||
painter -> setRenderHint(QPainter::TextAntialiasing, false);
|
painter -> setRenderHint(QPainter::TextAntialiasing, false);
|
||||||
painter -> setRenderHint(QPainter::SmoothPixmapTransform, false);
|
painter -> setRenderHint(QPainter::SmoothPixmapTransform, false);
|
||||||
// Dessin du cadre de selection en noir à partir du boundingrect
|
// Dessin du cadre de selection en noir à partir du boundingrect
|
||||||
QPen t(Qt::black);
|
QPen t(Qt::black);
|
||||||
t.setStyle(Qt::DashLine);
|
t.setStyle(Qt::DashLine);
|
||||||
painter -> setPen(t);
|
painter -> setPen(t);
|
||||||
|
|||||||
@@ -166,7 +166,7 @@ void DiagramTextItem::setFont(const QFont &font)
|
|||||||
|
|
||||||
void DiagramTextItem::setColor(const QColor& color)
|
void DiagramTextItem::setColor(const QColor& color)
|
||||||
{
|
{
|
||||||
setDefaultTextColor(color);
|
setDefaultTextColor(color);
|
||||||
emit colorChanged(color);
|
emit colorChanged(color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -33,8 +33,8 @@ class QDomDocument;
|
|||||||
class DiagramTextItem : public QGraphicsTextItem
|
class DiagramTextItem : public QGraphicsTextItem
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
|
Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
|
||||||
Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment NOTIFY alignmentChanged)
|
Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment NOTIFY alignmentChanged)
|
||||||
Q_PROPERTY(QString plainText READ toPlainText WRITE setPlainText)
|
Q_PROPERTY(QString plainText READ toPlainText WRITE setPlainText)
|
||||||
Q_PROPERTY(QFont font READ font WRITE setFont NOTIFY fontChanged)
|
Q_PROPERTY(QFont font READ font WRITE setFont NOTIFY fontChanged)
|
||||||
@@ -68,10 +68,10 @@ class DiagramTextItem : public QGraphicsTextItem
|
|||||||
QPointF mapMovementFromParent (const QPointF &) const;
|
QPointF mapMovementFromParent (const QPointF &) const;
|
||||||
|
|
||||||
void setFont(const QFont &font);
|
void setFont(const QFont &font);
|
||||||
|
|
||||||
void setColor(const QColor& color);
|
void setColor(const QColor& color);
|
||||||
QColor color() const;
|
QColor color() const;
|
||||||
|
|
||||||
void setNoEditable(bool e = true) {m_no_editable = e;}
|
void setNoEditable(bool e = true) {m_no_editable = e;}
|
||||||
|
|
||||||
void setAlignment(const Qt::Alignment &alignment);
|
void setAlignment(const Qt::Alignment &alignment);
|
||||||
@@ -85,7 +85,9 @@ class DiagramTextItem : public QGraphicsTextItem
|
|||||||
bool isHtml() const;
|
bool isHtml() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *) override;
|
void paint(QPainter *,
|
||||||
|
const QStyleOptionGraphicsItem *,
|
||||||
|
QWidget *) override;
|
||||||
void focusInEvent(QFocusEvent *) override;
|
void focusInEvent(QFocusEvent *) override;
|
||||||
void focusOutEvent(QFocusEvent *) override;
|
void focusOutEvent(QFocusEvent *) override;
|
||||||
|
|
||||||
@@ -104,13 +106,15 @@ class DiagramTextItem : public QGraphicsTextItem
|
|||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool m_mouse_hover = false,
|
bool
|
||||||
m_first_move = true,
|
m_mouse_hover = false,
|
||||||
m_no_editable,
|
m_first_move = true,
|
||||||
m_is_html = false;
|
m_no_editable,
|
||||||
|
m_is_html = false;
|
||||||
|
|
||||||
QString m_previous_html_text,
|
QString
|
||||||
m_previous_text;
|
m_previous_html_text,
|
||||||
|
m_previous_text;
|
||||||
|
|
||||||
QPointF m_mouse_to_origin_movement;
|
QPointF m_mouse_to_origin_movement;
|
||||||
|
|
||||||
|
|||||||
@@ -40,16 +40,16 @@ class DynamicElementTextItem : public DiagramTextItem
|
|||||||
friend class DynamicTextItemDelegate;
|
friend class DynamicTextItemDelegate;
|
||||||
friend class CompositeTextEditDialog;
|
friend class CompositeTextEditDialog;
|
||||||
friend class Element;
|
friend class Element;
|
||||||
|
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged)
|
Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged)
|
||||||
Q_PROPERTY(TextFrom textFrom READ textFrom WRITE setTextFrom NOTIFY textFromChanged)
|
Q_PROPERTY(TextFrom textFrom READ textFrom WRITE setTextFrom NOTIFY textFromChanged)
|
||||||
Q_PROPERTY(QString infoName READ infoName WRITE setInfoName NOTIFY infoNameChanged)
|
Q_PROPERTY(QString infoName READ infoName WRITE setInfoName NOTIFY infoNameChanged)
|
||||||
Q_PROPERTY(QString compositeText READ compositeText WRITE setCompositeText NOTIFY compositeTextChanged)
|
Q_PROPERTY(QString compositeText READ compositeText WRITE setCompositeText NOTIFY compositeTextChanged)
|
||||||
Q_PROPERTY(bool frame READ frame WRITE setFrame NOTIFY frameChanged)
|
Q_PROPERTY(bool frame READ frame WRITE setFrame NOTIFY frameChanged)
|
||||||
Q_PROPERTY(qreal textWidth READ textWidth WRITE setTextWidth NOTIFY textWidthChanged)
|
Q_PROPERTY(qreal textWidth READ textWidth WRITE setTextWidth NOTIFY textWidthChanged)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
enum TextFrom {
|
enum TextFrom {
|
||||||
@@ -60,7 +60,7 @@ class DynamicElementTextItem : public DiagramTextItem
|
|||||||
Q_ENUM (TextFrom)
|
Q_ENUM (TextFrom)
|
||||||
enum {Type = UserType + 1010};
|
enum {Type = UserType + 1010};
|
||||||
int type() const override {return Type;}
|
int type() const override {return Type;}
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void textChanged(QString text);
|
void textChanged(QString text);
|
||||||
void textFromChanged(DynamicElementTextItem::TextFrom text_from);
|
void textFromChanged(DynamicElementTextItem::TextFrom text_from);
|
||||||
@@ -69,7 +69,7 @@ class DynamicElementTextItem : public DiagramTextItem
|
|||||||
void frameChanged(bool frame);
|
void frameChanged(bool frame);
|
||||||
void plainTextChanged();
|
void plainTextChanged();
|
||||||
void textWidthChanged(qreal width);
|
void textWidthChanged(qreal width);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DynamicElementTextItem(Element *parent_element);
|
DynamicElementTextItem(Element *parent_element);
|
||||||
~DynamicElementTextItem() override;
|
~DynamicElementTextItem() override;
|
||||||
@@ -81,12 +81,12 @@ class DynamicElementTextItem : public DiagramTextItem
|
|||||||
public:
|
public:
|
||||||
QDomElement toXml(QDomDocument &dom_doc) const override;
|
QDomElement toXml(QDomDocument &dom_doc) const override;
|
||||||
void fromXml(const QDomElement &dom_elmt) override;
|
void fromXml(const QDomElement &dom_elmt) override;
|
||||||
|
|
||||||
Element *parentElement() const;
|
Element *parentElement() const;
|
||||||
ElementTextItemGroup *parentGroup() const;
|
ElementTextItemGroup *parentGroup() const;
|
||||||
Element *elementUseForInfo() const;
|
Element *elementUseForInfo() const;
|
||||||
void refreshLabelConnection();
|
void refreshLabelConnection();
|
||||||
|
|
||||||
DynamicElementTextItem::TextFrom textFrom() const;
|
DynamicElementTextItem::TextFrom textFrom() const;
|
||||||
void setTextFrom (DynamicElementTextItem::TextFrom text_from);
|
void setTextFrom (DynamicElementTextItem::TextFrom text_from);
|
||||||
QString text() const;
|
QString text() const;
|
||||||
@@ -103,7 +103,7 @@ class DynamicElementTextItem : public DiagramTextItem
|
|||||||
void setPlainText(const QString &text);
|
void setPlainText(const QString &text);
|
||||||
void setTextWidth(qreal width);
|
void setTextWidth(qreal width);
|
||||||
void setXref_item(Qt::AlignmentFlag m_exHrefPos);
|
void setXref_item(Qt::AlignmentFlag m_exHrefPos);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
|
void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
|
||||||
void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override;
|
void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override;
|
||||||
@@ -114,7 +114,7 @@ class DynamicElementTextItem : public DiagramTextItem
|
|||||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
|
||||||
QVariant itemChange(GraphicsItemChange change, const QVariant &value) override;
|
QVariant itemChange(GraphicsItemChange change, const QVariant &value) override;
|
||||||
bool sceneEventFilter(QGraphicsItem *watched, QEvent *event) override;
|
bool sceneEventFilter(QGraphicsItem *watched, QEvent *event) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void elementInfoChanged();
|
void elementInfoChanged();
|
||||||
void masterChanged();
|
void masterChanged();
|
||||||
@@ -134,25 +134,28 @@ class DynamicElementTextItem : public DiagramTextItem
|
|||||||
QString reportReplacedCompositeText() const;
|
QString reportReplacedCompositeText() const;
|
||||||
void zoomToLinkedElement();
|
void zoomToLinkedElement();
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QPointer <Element> m_parent_element,
|
QPointer <Element>
|
||||||
m_master_element,
|
m_parent_element,
|
||||||
m_other_report;
|
m_master_element,
|
||||||
|
m_other_report;
|
||||||
QPointer <Conductor> m_watched_conductor;
|
QPointer <Conductor> m_watched_conductor;
|
||||||
QString m_text,
|
QString
|
||||||
m_info_name,
|
m_text,
|
||||||
m_composite_text,
|
m_info_name,
|
||||||
m_report_formula,
|
m_composite_text,
|
||||||
m_F_str;
|
m_report_formula,
|
||||||
|
m_F_str;
|
||||||
DynamicElementTextItem::TextFrom m_text_from = UserText;
|
DynamicElementTextItem::TextFrom m_text_from = UserText;
|
||||||
QUuid m_uuid;
|
QUuid m_uuid;
|
||||||
QMetaObject::Connection m_report_formula_con;
|
QMetaObject::Connection m_report_formula_con;
|
||||||
QList<QMetaObject::Connection> m_formula_connection,
|
QList<QMetaObject::Connection>
|
||||||
m_update_slave_Xref_connection;
|
m_formula_connection,
|
||||||
|
m_update_slave_Xref_connection;
|
||||||
QColor m_user_color;
|
QColor m_user_color;
|
||||||
bool m_frame = false,
|
bool
|
||||||
m_first_scene_change = true;
|
m_frame = false,
|
||||||
|
m_first_scene_change = true;
|
||||||
CrossRefItem *m_Xref_item = nullptr;
|
CrossRefItem *m_Xref_item = nullptr;
|
||||||
QGraphicsTextItem *m_slave_Xref_item = nullptr;
|
QGraphicsTextItem *m_slave_Xref_item = nullptr;
|
||||||
qreal m_text_width = -1;
|
qreal m_text_width = -1;
|
||||||
|
|||||||
@@ -64,8 +64,8 @@ QetShapeItem::QetShapeItem(QPointF p1, QPointF p2, ShapeType type, QGraphicsItem
|
|||||||
|
|
||||||
QetShapeItem::~QetShapeItem()
|
QetShapeItem::~QetShapeItem()
|
||||||
{
|
{
|
||||||
if(!m_handler_vector.isEmpty())
|
if(!m_handler_vector.isEmpty())
|
||||||
qDeleteAll(m_handler_vector);
|
qDeleteAll(m_handler_vector);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -221,8 +221,9 @@ void QetShapeItem::setNextPoint(QPointF P)
|
|||||||
/**
|
/**
|
||||||
@brief QetShapeItem::removePoints
|
@brief QetShapeItem::removePoints
|
||||||
Number of point to remove on the polygon
|
Number of point to remove on the polygon
|
||||||
If @number is superior to number of polygon points-2,
|
If number is superior to number of polygon points-2,
|
||||||
all points of polygon will be removed except the first two (minimum point for the polygon);
|
all points of polygon will be removed except
|
||||||
|
the first two (minimum point for the polygon);
|
||||||
*/
|
*/
|
||||||
void QetShapeItem::removePoints(int number)
|
void QetShapeItem::removePoints(int number)
|
||||||
{
|
{
|
||||||
@@ -259,12 +260,14 @@ QPainterPath QetShapeItem::shape() const
|
|||||||
|
|
||||||
switch (m_shapeType)
|
switch (m_shapeType)
|
||||||
{
|
{
|
||||||
case Line:
|
case Line:
|
||||||
path.moveTo(m_P1);
|
path.moveTo(m_P1);
|
||||||
path.lineTo(m_P2);
|
path.lineTo(m_P2);
|
||||||
break;
|
break;
|
||||||
case Rectangle:
|
case Rectangle:
|
||||||
path.addRoundedRect(QRectF(m_P1, m_P2), m_xRadius, m_yRadius);
|
path.addRoundedRect(QRectF(m_P1, m_P2),
|
||||||
|
m_xRadius,
|
||||||
|
m_yRadius);
|
||||||
break;
|
break;
|
||||||
case Ellipse:
|
case Ellipse:
|
||||||
path.addEllipse(QRectF(m_P1, m_P2));
|
path.addEllipse(QRectF(m_P1, m_P2));
|
||||||
@@ -292,7 +295,9 @@ QPainterPath QetShapeItem::shape() const
|
|||||||
@param option
|
@param option
|
||||||
@param widget
|
@param widget
|
||||||
*/
|
*/
|
||||||
void QetShapeItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
void QetShapeItem::paint(QPainter *painter,
|
||||||
|
const QStyleOptionGraphicsItem *option,
|
||||||
|
QWidget *widget)
|
||||||
{
|
{
|
||||||
Q_UNUSED(option)
|
Q_UNUSED(option)
|
||||||
Q_UNUSED(widget)
|
Q_UNUSED(widget)
|
||||||
@@ -317,9 +322,12 @@ void QetShapeItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *opti
|
|||||||
switch (m_shapeType)
|
switch (m_shapeType)
|
||||||
{
|
{
|
||||||
case Line: painter->drawLine(QLineF(m_P1, m_P2)); break;
|
case Line: painter->drawLine(QLineF(m_P1, m_P2)); break;
|
||||||
case Rectangle: painter->drawRoundedRect(QRectF(m_P1, m_P2), m_xRadius, m_yRadius); break;
|
case Rectangle: painter->drawRoundedRect(QRectF(m_P1, m_P2),
|
||||||
|
m_xRadius,
|
||||||
|
m_yRadius); break;
|
||||||
case Ellipse: painter->drawEllipse(QRectF(m_P1, m_P2)); break;
|
case Ellipse: painter->drawEllipse(QRectF(m_P1, m_P2)); break;
|
||||||
case Polygon: m_closed ? painter->drawPolygon(m_polygon) : painter->drawPolyline(m_polygon); break;
|
case Polygon: m_closed ? painter->drawPolygon(m_polygon)
|
||||||
|
: painter->drawPolyline(m_polygon); break;
|
||||||
}
|
}
|
||||||
|
|
||||||
painter->restore();
|
painter->restore();
|
||||||
@@ -364,11 +372,13 @@ void QetShapeItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
|||||||
@param value
|
@param value
|
||||||
@return
|
@return
|
||||||
*/
|
*/
|
||||||
QVariant QetShapeItem::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value)
|
QVariant QetShapeItem::itemChange(QGraphicsItem::GraphicsItemChange change,
|
||||||
|
const QVariant &value)
|
||||||
{
|
{
|
||||||
if (change == ItemSelectedHasChanged)
|
if (change == ItemSelectedHasChanged)
|
||||||
{
|
{
|
||||||
if (value.toBool() == true) { //If this is selected, wa add handlers.
|
if (value.toBool() == true) {
|
||||||
|
//If this is selected, wa add handlers.
|
||||||
addHandler();
|
addHandler();
|
||||||
}
|
}
|
||||||
else //Else this is deselected, we remove handlers
|
else //Else this is deselected, we remove handlers
|
||||||
@@ -956,11 +966,32 @@ QDomElement QetShapeItem::toXml(QDomDocument &document) const
|
|||||||
bool QetShapeItem::toDXF(const QString &filepath,const QPen &pen)
|
bool QetShapeItem::toDXF(const QString &filepath,const QPen &pen)
|
||||||
{
|
{
|
||||||
|
|
||||||
switch (m_shapeType)
|
switch (m_shapeType)
|
||||||
{
|
{
|
||||||
case Line: Createdxf::drawLine (filepath, QLineF(mapToScene(m_P1), mapToScene(m_P2)), Createdxf::getcolorCode(pen.color().red(),pen.color().green(),pen.color().blue())); return true;
|
case Line:
|
||||||
case Rectangle: Createdxf::drawRectangle(filepath, QRectF(mapToScene(m_P1), mapToScene(m_P2)).normalized(), Createdxf::getcolorCode(pen.color().red(),pen.color().green(),pen.color().blue())); return true;
|
Createdxf::drawLine(filepath,
|
||||||
case Ellipse: Createdxf::drawEllipse (filepath, QRectF(mapToScene(m_P1), mapToScene(m_P2)).normalized(), Createdxf::getcolorCode(pen.color().red(),pen.color().green(),pen.color().blue())); return true;
|
QLineF(mapToScene(m_P1),
|
||||||
|
mapToScene(m_P2)),
|
||||||
|
Createdxf::getcolorCode(pen.color().red(),
|
||||||
|
pen.color().green(),
|
||||||
|
pen.color().blue()));
|
||||||
|
return true;
|
||||||
|
case Rectangle:
|
||||||
|
Createdxf::drawRectangle(filepath,
|
||||||
|
QRectF(mapToScene(m_P1),
|
||||||
|
mapToScene(m_P2)).normalized(),
|
||||||
|
Createdxf::getcolorCode(pen.color().red(),
|
||||||
|
pen.color().green(),
|
||||||
|
pen.color().blue()));
|
||||||
|
return true;
|
||||||
|
case Ellipse:
|
||||||
|
Createdxf::drawEllipse (filepath,
|
||||||
|
QRectF(mapToScene(m_P1),
|
||||||
|
mapToScene(m_P2)).normalized(),
|
||||||
|
Createdxf::getcolorCode(pen.color().red(),
|
||||||
|
pen.color().green(),
|
||||||
|
pen.color().blue()));
|
||||||
|
return true;
|
||||||
default: return false;
|
default: return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -109,8 +109,8 @@ class QetShapeItem : public QetGraphicsItem
|
|||||||
void hoverEnterEvent (QGraphicsSceneHoverEvent *event) override;
|
void hoverEnterEvent (QGraphicsSceneHoverEvent *event) override;
|
||||||
void hoverLeaveEvent (QGraphicsSceneHoverEvent *event) override;
|
void hoverLeaveEvent (QGraphicsSceneHoverEvent *event) override;
|
||||||
void mousePressEvent (QGraphicsSceneMouseEvent *event) override;
|
void mousePressEvent (QGraphicsSceneMouseEvent *event) override;
|
||||||
QVariant itemChange(GraphicsItemChange change, const QVariant &value) override;
|
QVariant itemChange(GraphicsItemChange change, const QVariant &value) override;
|
||||||
bool sceneEventFilter(QGraphicsItem *watched, QEvent *event) override;
|
bool sceneEventFilter(QGraphicsItem *watched, QEvent *event) override;
|
||||||
void contextMenuEvent(QGraphicsSceneContextMenuEvent *event) override;
|
void contextMenuEvent(QGraphicsSceneContextMenuEvent *event) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -140,7 +140,7 @@ class QetShapeItem : public QetGraphicsItem
|
|||||||
bool m_closed = false,
|
bool m_closed = false,
|
||||||
m_modifie_radius_equaly = false;
|
m_modifie_radius_equaly = false;
|
||||||
int m_resize_mode = 1;
|
int m_resize_mode = 1;
|
||||||
QVector<QetGraphicsHandlerItem *> m_handler_vector;
|
QVector<QetGraphicsHandlerItem *> m_handler_vector;
|
||||||
QAction *m_insert_point,
|
QAction *m_insert_point,
|
||||||
*m_remove_point;
|
*m_remove_point;
|
||||||
qreal m_xRadius = 0,
|
qreal m_xRadius = 0,
|
||||||
|
|||||||
Reference in New Issue
Block a user