QT6: QStyleOptionGraphicsItem

This commit is contained in:
Simon De Backer
2020-10-03 15:48:40 +02:00
parent 2e2a652343
commit c1e93fc442
9 changed files with 261 additions and 192 deletions

View File

@@ -1,17 +1,17 @@
/*
Copyright 2006-2020 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/>.
*/
@@ -38,7 +38,7 @@ class Terminal : public QGraphicsObject
signals:
void conductorWasAdded(Conductor *conductor);
void conductorWasRemoved(Conductor *conductor);
// constructors, destructor
public:
Terminal(QPointF, Qet::Orientation, Element * = nullptr);
@@ -47,10 +47,10 @@ class Terminal : public QGraphicsObject
Terminal(QPointF, Qet::Orientation, QString number,
QString name, bool hiddenName, Element * = nullptr);
~Terminal() override;
private:
Terminal(const Terminal &);
// methods
public:
/**
@@ -60,13 +60,15 @@ class Terminal : public QGraphicsObject
@return the QGraphicsItem type
*/
int type() const override { return Type; }
void paint (QPainter *,const QStyleOptionGraphicsItem *,
QWidget *) override;
void paint(
QPainter *painter,
const QStyleOptionGraphicsItem *,
QWidget *) override;
void drawHelpLine (bool draw = true);
QLineF HelpLine () const;
QRectF boundingRect () const override;
// methods to manage conductors attached to the terminal
Terminal* alignedWithTerminal () const;
bool addConductor (Conductor *conductor);
@@ -75,7 +77,7 @@ class Terminal : public QGraphicsObject
Diagram *diagram () const;
Element *parentElement () const;
QUuid uuid () const;
QList<Conductor *> conductors() const;
Qet::Orientation orientation() const;
QPointF dockConductor() const;
@@ -86,12 +88,12 @@ class Terminal : public QGraphicsObject
void updateConductor();
bool isLinkedTo(Terminal *);
bool canBeLinkedTo(Terminal *);
// methods related to XML import/export
static bool valideXml(QDomElement &);
bool fromXml (QDomElement &);
QDomElement toXml (QDomDocument &) const;
protected:
// methods related to events management
void hoverEnterEvent (QGraphicsSceneHoverEvent *) override;
@@ -100,7 +102,7 @@ class Terminal : public QGraphicsObject
void mousePressEvent (QGraphicsSceneMouseEvent *) override;
void mouseMoveEvent (QGraphicsSceneMouseEvent *) override;
void mouseReleaseEvent(QGraphicsSceneMouseEvent *) override;
// attributes
public:
enum { Type = UserType + 1002 };
@@ -116,7 +118,7 @@ class Terminal : public QGraphicsObject
static QColor warningColor;
/// color for forbidden actions
static QColor forbiddenColor;
private:
bool m_draw_help_line{false};
QGraphicsLineItem *m_help_line{nullptr};
@@ -127,10 +129,10 @@ class Terminal : public QGraphicsObject
/// Parent electrical element
Element *parent_element_{nullptr};
public:
public:
/// docking point for parent element
QPointF dock_elmt_;
private:
private:
/// List of conductors attached to the terminal
QList<Conductor *> conductors_;
/**
@@ -150,7 +152,7 @@ class Terminal : public QGraphicsObject
/// Name of Terminal
QString name_terminal_;
bool name_terminal_hidden;
private:
void init(QString number, QString name, bool hiddenName);
void init(QPointF pf, Qet::Orientation o, QString number,
@@ -185,6 +187,6 @@ inline QString Terminal::name() const
}
QList<Terminal *> relatedPotentialTerminal (const Terminal *terminal,
const bool all_diagram = true);
const bool all_diagram = true);
#endif