Wrap code for better readability

This commit is contained in:
Simon De Backer
2020-08-20 21:58:23 +02:00
parent 0c00d83b27
commit 331918d143
41 changed files with 716 additions and 190 deletions

View File

@@ -27,7 +27,8 @@
@param editor QETElement editor that belong this.
@param parent
*/
CustomElementGraphicPart::CustomElementGraphicPart(QETElementEditor *editor, QGraphicsItem *parent) :
CustomElementGraphicPart::CustomElementGraphicPart(QETElementEditor *editor,
QGraphicsItem *parent) :
QGraphicsObject (parent),
CustomElementPart(editor),
m_hovered (false),
@@ -37,7 +38,9 @@ CustomElementGraphicPart::CustomElementGraphicPart(QETElementEditor *editor, QGr
_color(BlackColor),
_antialiased(false)
{
setFlags(QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemSendsGeometryChanges);
setFlags(QGraphicsItem::ItemIsSelectable
| QGraphicsItem::ItemIsMovable
| QGraphicsItem::ItemSendsGeometryChanges);
setAcceptHoverEvents(true);
}
@@ -54,13 +57,24 @@ CustomElementGraphicPart::~CustomElementGraphicPart() {}
@param painter : painter to use for draw cross,
the painter state is restored at end of this method.
*/
void CustomElementGraphicPart::drawCross(const QPointF &center, QPainter *painter)
void CustomElementGraphicPart::drawCross(const QPointF &center,
QPainter *painter)
{
painter -> save();
painter -> setRenderHint(QPainter::Antialiasing, false);
painter -> setPen((painter -> brush().color() == QColor(Qt::black) && painter -> brush().isOpaque()) ? Qt::yellow : Qt::blue);
painter -> drawLine(QLineF(center.x() - 2.0, center.y(), center.x() + 2.0, center.y()));
painter -> drawLine(QLineF(center.x(), center.y() - 2.0, center.x(), center.y() + 2.0));
painter -> setPen((painter -> brush().color()
== QColor(Qt::black)
&& painter -> brush().isOpaque())
? Qt::yellow
: Qt::blue);
painter -> drawLine(QLineF(center.x() - 2.0,
center.y(),
center.x() + 2.0,
center.y()));
painter -> drawLine(QLineF(center.x(),
center.y() - 2.0,
center.x(),
center.y() + 2.0));
painter -> restore();
}
@@ -94,7 +108,7 @@ void CustomElementGraphicPart::setLineWeight(const LineWeight lw)
*/
qreal CustomElementGraphicPart::penWeight() const
{
if (_lineweight == NoneWeight || _lineweight == ThinWeight) return 0;
if (_lineweight == NoneWeight || _lineweight == ThinWeight) return 0;
else if (_lineweight == NormalWeight) return 1;
else if (_lineweight == UltraWeight) return 2;
else if (_lineweight == BigWeight) return 5;

View File

@@ -46,28 +46,230 @@ class CustomElementGraphicPart : public QGraphicsObject, public CustomElementPar
public:
//Line style
enum LineStyle {NormalStyle, DashedStyle, DottedStyle, DashdottedStyle};
enum LineStyle {NormalStyle,
DashedStyle,
DottedStyle,
DashdottedStyle};
Q_ENUM (LineStyle)
//Line weight : invisible, 0px, 1px, 2px, 5px
enum LineWeight {NoneWeight, ThinWeight, NormalWeight, UltraWeight, BigWeight};
enum LineWeight {NoneWeight,
ThinWeight,
NormalWeight,
UltraWeight,
BigWeight};
Q_ENUM (LineWeight)
//Filling color of the part : NoneFilling -> No filling (i.e. transparent)
enum Filling { NoneFilling, BlackFilling, WhiteFilling, GreenFilling, RedFilling, BlueFilling, GrayFilling, BrunFilling, YellowFilling, CyanFilling, MagentaFilling, LightgrayFilling, OrangeFilling, PurpleFilling, HTMLPinkPinkFilling, HTMLPinkLightPinkFilling, HTMLPinkHotPinkFilling, HTMLPinkDeepPinkFilling, HTMLPinkPaleVioletRedFilling, HTMLPinkMediumVioletRedFilling, HTMLRedLightSalmonFilling, HTMLRedSalmonFilling, HTMLRedDarkSalmonFilling, HTMLRedLightCoralFilling, HTMLRedIndianRedFilling, HTMLRedCrimsonFilling, HTMLRedFirebrickFilling, HTMLRedDarkRedFilling, HTMLRedRedFilling, HTMLOrangeOrangeRedFilling, HTMLOrangeTomatoFilling, HTMLOrangeCoralFilling, HTMLOrangeDarkOrangeFilling, HTMLOrangeOrangeFilling, HTMLYellowYellowFilling, HTMLYellowLightYellowFilling, HTMLYellowLemonChiffonFilling, HTMLYellowLightGoldenrodYellowFilling, HTMLYellowPapayaWhipFilling, HTMLYellowMoccasinFilling, HTMLYellowPeachPuffFilling, HTMLYellowPaleGoldenrodFilling, HTMLYellowKhakiFilling, HTMLYellowDarkKhakiFilling, HTMLYellowGoldFilling, HTMLBrownCornsilkFilling, HTMLBrownBlanchedAlmondFilling, HTMLBrownBisqueFilling, HTMLBrownNavajoWhiteFilling, HTMLBrownWheatFilling, HTMLBrownBurlywoodFilling, HTMLBrownTanFilling, HTMLBrownRosyBrownFilling, HTMLBrownSandyBrownFilling, HTMLBrownGoldenrodFilling, HTMLBrownDarkGoldenrodFilling, HTMLBrownPeruFilling, HTMLBrownChocolateFilling, HTMLBrownSaddleBrownFilling, HTMLBrownSiennaFilling, HTMLBrownBrownFilling, HTMLBrownMaroonFilling, HTMLGreenDarkOliveGreenFilling, HTMLGreenOliveFilling, HTMLGreenOliveDrabFilling, HTMLGreenYellowGreenFilling, HTMLGreenLimeGreenFilling, HTMLGreenLimeFilling, HTMLGreenLawnGreenFilling, HTMLGreenChartreuseFilling, HTMLGreenGreenYellowFilling, HTMLGreenSpringGreenFilling, HTMLGreenMediumSpringGreenFilling, HTMLGreenLightGreenFilling, HTMLGreenPaleGreenFilling, HTMLGreenDarkSeaGreenFilling, HTMLGreenMediumAquamarineFilling, HTMLGreenMediumSeaGreenFilling, HTMLGreenSeaGreenFilling, HTMLGreenForestGreenFilling, HTMLGreenGreenFilling, HTMLGreenDarkGreenFilling, HTMLCyanAquaFilling, HTMLCyanCyanFilling, HTMLCyanLightCyanFilling, HTMLCyanPaleTurquoiseFilling, HTMLCyanAquamarineFilling, HTMLCyanTurquoiseFilling, HTMLCyanMediumTurquoiseFilling, HTMLCyanDarkTurquoiseFilling, HTMLCyanLightSeaGreenFilling, HTMLCyanCadetBlueFilling, HTMLCyanDarkCyanFilling, HTMLCyanTealFilling, HTMLBlueLightSteelBlueFilling, HTMLBluePowderBlueFilling, HTMLBlueLightBlueFilling, HTMLBlueSkyBlueFilling, HTMLBlueLightSkyBlueFilling, HTMLBlueDeepSkyBlueFilling, HTMLBlueDodgerBlueFilling, HTMLBlueCornflowerBlueFilling, HTMLBlueSteelBlueFilling, HTMLBlueRoyalBlueFilling, HTMLBlueBlueFilling, HTMLBlueMediumBlueFilling, HTMLBlueDarkBlueFilling, HTMLBlueNavyFilling, HTMLBlueMidnightBlueFilling, HTMLPurpleLavenderFilling, HTMLPurpleThistleFilling, HTMLPurplePlumFilling, HTMLPurpleVioletFilling, HTMLPurpleOrchidFilling, HTMLPurpleFuchsiaFilling, HTMLPurpleMagentaFilling, HTMLPurpleMediumOrchidFilling, HTMLPurpleMediumPurpleFilling, HTMLPurpleBlueVioletFilling, HTMLPurpleDarkVioletFilling, HTMLPurpleDarkOrchidFilling, HTMLPurpleDarkMagentaFilling, HTMLPurplePurpleFilling, HTMLPurpleIndigoFilling, HTMLPurpleDarkSlateBlueFilling, HTMLPurpleSlateBlueFilling, HTMLPurpleMediumSlateBlueFilling, HTMLWhiteWhiteFilling, HTMLWhiteSnowFilling, HTMLWhiteHoneydewFilling, HTMLWhiteMintCreamFilling, HTMLWhiteAzureFilling, HTMLWhiteAliceBlueFilling, HTMLWhiteGhostWhiteFilling, HTMLWhiteWhiteSmokeFilling, HTMLWhiteSeashellFilling, HTMLWhiteBeigeFilling, HTMLWhiteOldLaceFilling, HTMLWhiteFloralWhiteFilling, HTMLWhiteIvoryFilling, HTMLWhiteAntiqueWhiteFilling, HTMLWhiteLinenFilling, HTMLWhiteLavenderBlushFilling, HTMLWhiteMistyRoseFilling, HTMLGrayGainsboroFilling, HTMLGrayLightGrayFilling, HTMLGraySilverFilling, HTMLGrayDarkGrayFilling, HTMLGrayGrayFilling, HTMLGrayDimGrayFilling, HTMLGrayLightSlateGrayFilling, HTMLGraySlateGrayFilling, HTMLGrayDarkSlateGrayFilling, HTMLGrayBlackFilling, HorFilling, VerFilling, BdiagFilling, FdiagFilling};
//Filling color of the part : NoneFilling -> No filling (i.e. transparent)
enum Filling { NoneFilling, BlackFilling, WhiteFilling,
GreenFilling, RedFilling, BlueFilling,
GrayFilling, BrunFilling, YellowFilling,
CyanFilling, MagentaFilling, LightgrayFilling,
OrangeFilling, PurpleFilling,
HTMLPinkPinkFilling, HTMLPinkLightPinkFilling,
HTMLPinkHotPinkFilling, HTMLPinkDeepPinkFilling,
HTMLPinkPaleVioletRedFilling,
HTMLPinkMediumVioletRedFilling,
HTMLRedLightSalmonFilling, HTMLRedSalmonFilling,
HTMLRedDarkSalmonFilling,
HTMLRedLightCoralFilling,
HTMLRedIndianRedFilling, HTMLRedCrimsonFilling,
HTMLRedFirebrickFilling, HTMLRedDarkRedFilling,
HTMLRedRedFilling, HTMLOrangeOrangeRedFilling,
HTMLOrangeTomatoFilling, HTMLOrangeCoralFilling,
HTMLOrangeDarkOrangeFilling,
HTMLOrangeOrangeFilling, HTMLYellowYellowFilling,
HTMLYellowLightYellowFilling,
HTMLYellowLemonChiffonFilling,
HTMLYellowLightGoldenrodYellowFilling,
HTMLYellowPapayaWhipFilling,
HTMLYellowMoccasinFilling,
HTMLYellowPeachPuffFilling,
HTMLYellowPaleGoldenrodFilling,
HTMLYellowKhakiFilling,
HTMLYellowDarkKhakiFilling,
HTMLYellowGoldFilling, HTMLBrownCornsilkFilling,
HTMLBrownBlanchedAlmondFilling,
HTMLBrownBisqueFilling,
HTMLBrownNavajoWhiteFilling,
HTMLBrownWheatFilling, HTMLBrownBurlywoodFilling,
HTMLBrownTanFilling, HTMLBrownRosyBrownFilling,
HTMLBrownSandyBrownFilling,
HTMLBrownGoldenrodFilling,
HTMLBrownDarkGoldenrodFilling,
HTMLBrownPeruFilling, HTMLBrownChocolateFilling,
HTMLBrownSaddleBrownFilling,
HTMLBrownSiennaFilling, HTMLBrownBrownFilling,
HTMLBrownMaroonFilling,
HTMLGreenDarkOliveGreenFilling,
HTMLGreenOliveFilling, HTMLGreenOliveDrabFilling,
HTMLGreenYellowGreenFilling,
HTMLGreenLimeGreenFilling, HTMLGreenLimeFilling,
HTMLGreenLawnGreenFilling,
HTMLGreenChartreuseFilling,
HTMLGreenGreenYellowFilling,
HTMLGreenSpringGreenFilling,
HTMLGreenMediumSpringGreenFilling,
HTMLGreenLightGreenFilling,
HTMLGreenPaleGreenFilling,
HTMLGreenDarkSeaGreenFilling,
HTMLGreenMediumAquamarineFilling,
HTMLGreenMediumSeaGreenFilling,
HTMLGreenSeaGreenFilling,
HTMLGreenForestGreenFilling,
HTMLGreenGreenFilling, HTMLGreenDarkGreenFilling,
HTMLCyanAquaFilling, HTMLCyanCyanFilling,
HTMLCyanLightCyanFilling,
HTMLCyanPaleTurquoiseFilling,
HTMLCyanAquamarineFilling,
HTMLCyanTurquoiseFilling,
HTMLCyanMediumTurquoiseFilling,
HTMLCyanDarkTurquoiseFilling,
HTMLCyanLightSeaGreenFilling,
HTMLCyanCadetBlueFilling,
HTMLCyanDarkCyanFilling, HTMLCyanTealFilling,
HTMLBlueLightSteelBlueFilling,
HTMLBluePowderBlueFilling,
HTMLBlueLightBlueFilling, HTMLBlueSkyBlueFilling,
HTMLBlueLightSkyBlueFilling,
HTMLBlueDeepSkyBlueFilling,
HTMLBlueDodgerBlueFilling,
HTMLBlueCornflowerBlueFilling,
HTMLBlueSteelBlueFilling,
HTMLBlueRoyalBlueFilling, HTMLBlueBlueFilling,
HTMLBlueMediumBlueFilling,
HTMLBlueDarkBlueFilling, HTMLBlueNavyFilling,
HTMLBlueMidnightBlueFilling,
HTMLPurpleLavenderFilling,
HTMLPurpleThistleFilling, HTMLPurplePlumFilling,
HTMLPurpleVioletFilling, HTMLPurpleOrchidFilling,
HTMLPurpleFuchsiaFilling,
HTMLPurpleMagentaFilling,
HTMLPurpleMediumOrchidFilling,
HTMLPurpleMediumPurpleFilling,
HTMLPurpleBlueVioletFilling,
HTMLPurpleDarkVioletFilling,
HTMLPurpleDarkOrchidFilling,
HTMLPurpleDarkMagentaFilling,
HTMLPurplePurpleFilling, HTMLPurpleIndigoFilling,
HTMLPurpleDarkSlateBlueFilling,
HTMLPurpleSlateBlueFilling,
HTMLPurpleMediumSlateBlueFilling,
HTMLWhiteWhiteFilling, HTMLWhiteSnowFilling,
HTMLWhiteHoneydewFilling,
HTMLWhiteMintCreamFilling, HTMLWhiteAzureFilling,
HTMLWhiteAliceBlueFilling,
HTMLWhiteGhostWhiteFilling,
HTMLWhiteWhiteSmokeFilling,
HTMLWhiteSeashellFilling, HTMLWhiteBeigeFilling,
HTMLWhiteOldLaceFilling,
HTMLWhiteFloralWhiteFilling,
HTMLWhiteIvoryFilling,
HTMLWhiteAntiqueWhiteFilling,
HTMLWhiteLinenFilling,
HTMLWhiteLavenderBlushFilling,
HTMLWhiteMistyRoseFilling,
HTMLGrayGainsboroFilling,
HTMLGrayLightGrayFilling, HTMLGraySilverFilling,
HTMLGrayDarkGrayFilling, HTMLGrayGrayFilling,
HTMLGrayDimGrayFilling,
HTMLGrayLightSlateGrayFilling,
HTMLGraySlateGrayFilling,
HTMLGrayDarkSlateGrayFilling,
HTMLGrayBlackFilling, HorFilling, VerFilling,
BdiagFilling, FdiagFilling};
Q_ENUM (Filling)
//Line color
enum Color {BlackColor, WhiteColor, GreenColor, RedColor, BlueColor, GrayColor, BrunColor, YellowColor, CyanColor, MagentaColor, LightgrayColor, OrangeColor, PurpleColor, HTMLPinkPinkColor, HTMLPinkLightPinkColor, HTMLPinkHotPinkColor, HTMLPinkDeepPinkColor, HTMLPinkPaleVioletRedColor, HTMLPinkMediumVioletRedColor, HTMLRedLightSalmonColor, HTMLRedSalmonColor, HTMLRedDarkSalmonColor, HTMLRedLightCoralColor, HTMLRedIndianRedColor, HTMLRedCrimsonColor, HTMLRedFirebrickColor, HTMLRedDarkRedColor, HTMLRedRedColor, HTMLOrangeOrangeRedColor, HTMLOrangeTomatoColor, HTMLOrangeCoralColor, HTMLOrangeDarkOrangeColor, HTMLOrangeOrangeColor, HTMLYellowYellowColor, HTMLYellowLightYellowColor, HTMLYellowLemonChiffonColor, HTMLYellowLightGoldenrodYellowColor, HTMLYellowPapayaWhipColor, HTMLYellowMoccasinColor, HTMLYellowPeachPuffColor, HTMLYellowPaleGoldenrodColor, HTMLYellowKhakiColor, HTMLYellowDarkKhakiColor, HTMLYellowGoldColor, HTMLBrownCornsilkColor, HTMLBrownBlanchedAlmondColor, HTMLBrownBisqueColor, HTMLBrownNavajoWhiteColor, HTMLBrownWheatColor, HTMLBrownBurlywoodColor, HTMLBrownTanColor, HTMLBrownRosyBrownColor, HTMLBrownSandyBrownColor, HTMLBrownGoldenrodColor, HTMLBrownDarkGoldenrodColor, HTMLBrownPeruColor, HTMLBrownChocolateColor, HTMLBrownSaddleBrownColor, HTMLBrownSiennaColor, HTMLBrownBrownColor, HTMLBrownMaroonColor, HTMLGreenDarkOliveGreenColor, HTMLGreenOliveColor, HTMLGreenOliveDrabColor, HTMLGreenYellowGreenColor, HTMLGreenLimeGreenColor, HTMLGreenLimeColor, HTMLGreenLawnGreenColor, HTMLGreenChartreuseColor, HTMLGreenGreenYellowColor, HTMLGreenSpringGreenColor, HTMLGreenMediumSpringGreenColor, HTMLGreenLightGreenColor, HTMLGreenPaleGreenColor, HTMLGreenDarkSeaGreenColor, HTMLGreenMediumAquamarineColor, HTMLGreenMediumSeaGreenColor, HTMLGreenSeaGreenColor, HTMLGreenForestGreenColor, HTMLGreenGreenColor, HTMLGreenDarkGreenColor, HTMLCyanAquaColor, HTMLCyanCyanColor, HTMLCyanLightCyanColor, HTMLCyanPaleTurquoiseColor, HTMLCyanAquamarineColor, HTMLCyanTurquoiseColor, HTMLCyanMediumTurquoiseColor, HTMLCyanDarkTurquoiseColor, HTMLCyanLightSeaGreenColor, HTMLCyanCadetBlueColor, HTMLCyanDarkCyanColor, HTMLCyanTealColor, HTMLBlueLightSteelBlueColor, HTMLBluePowderBlueColor, HTMLBlueLightBlueColor, HTMLBlueSkyBlueColor, HTMLBlueLightSkyBlueColor, HTMLBlueDeepSkyBlueColor, HTMLBlueDodgerBlueColor, HTMLBlueCornflowerBlueColor, HTMLBlueSteelBlueColor, HTMLBlueRoyalBlueColor, HTMLBlueBlueColor, HTMLBlueMediumBlueColor, HTMLBlueDarkBlueColor, HTMLBlueNavyColor, HTMLBlueMidnightBlueColor, HTMLPurpleLavenderColor, HTMLPurpleThistleColor, HTMLPurplePlumColor, HTMLPurpleVioletColor, HTMLPurpleOrchidColor, HTMLPurpleFuchsiaColor, HTMLPurpleMagentaColor, HTMLPurpleMediumOrchidColor, HTMLPurpleMediumPurpleColor, HTMLPurpleBlueVioletColor, HTMLPurpleDarkVioletColor, HTMLPurpleDarkOrchidColor, HTMLPurpleDarkMagentaColor, HTMLPurplePurpleColor, HTMLPurpleIndigoColor, HTMLPurpleDarkSlateBlueColor, HTMLPurpleSlateBlueColor, HTMLPurpleMediumSlateBlueColor, HTMLWhiteWhiteColor, HTMLWhiteSnowColor, HTMLWhiteHoneydewColor, HTMLWhiteMintCreamColor, HTMLWhiteAzureColor, HTMLWhiteAliceBlueColor, HTMLWhiteGhostWhiteColor, HTMLWhiteWhiteSmokeColor, HTMLWhiteSeashellColor, HTMLWhiteBeigeColor, HTMLWhiteOldLaceColor, HTMLWhiteFloralWhiteColor, HTMLWhiteIvoryColor, HTMLWhiteAntiqueWhiteColor, HTMLWhiteLinenColor, HTMLWhiteLavenderBlushColor, HTMLWhiteMistyRoseColor, HTMLGrayGainsboroColor, HTMLGrayLightGrayColor, HTMLGraySilverColor, HTMLGrayDarkGrayColor, HTMLGrayGrayColor, HTMLGrayDimGrayColor, HTMLGrayLightSlateGrayColor, HTMLGraySlateGrayColor, HTMLGrayDarkSlateGrayColor, HTMLGrayBlackColor, NoneColor};
enum Color {
BlackColor, WhiteColor, GreenColor, RedColor, BlueColor,
GrayColor, BrunColor, YellowColor, CyanColor,
MagentaColor, LightgrayColor, OrangeColor, PurpleColor,
HTMLPinkPinkColor, HTMLPinkLightPinkColor,
HTMLPinkHotPinkColor, HTMLPinkDeepPinkColor,
HTMLPinkPaleVioletRedColor,
HTMLPinkMediumVioletRedColor, HTMLRedLightSalmonColor,
HTMLRedSalmonColor, HTMLRedDarkSalmonColor,
HTMLRedLightCoralColor, HTMLRedIndianRedColor,
HTMLRedCrimsonColor, HTMLRedFirebrickColor,
HTMLRedDarkRedColor, HTMLRedRedColor,
HTMLOrangeOrangeRedColor, HTMLOrangeTomatoColor,
HTMLOrangeCoralColor, HTMLOrangeDarkOrangeColor,
HTMLOrangeOrangeColor, HTMLYellowYellowColor,
HTMLYellowLightYellowColor, HTMLYellowLemonChiffonColor,
HTMLYellowLightGoldenrodYellowColor,
HTMLYellowPapayaWhipColor, HTMLYellowMoccasinColor,
HTMLYellowPeachPuffColor, HTMLYellowPaleGoldenrodColor,
HTMLYellowKhakiColor, HTMLYellowDarkKhakiColor,
HTMLYellowGoldColor, HTMLBrownCornsilkColor,
HTMLBrownBlanchedAlmondColor, HTMLBrownBisqueColor,
HTMLBrownNavajoWhiteColor, HTMLBrownWheatColor,
HTMLBrownBurlywoodColor, HTMLBrownTanColor,
HTMLBrownRosyBrownColor, HTMLBrownSandyBrownColor,
HTMLBrownGoldenrodColor, HTMLBrownDarkGoldenrodColor,
HTMLBrownPeruColor, HTMLBrownChocolateColor,
HTMLBrownSaddleBrownColor, HTMLBrownSiennaColor,
HTMLBrownBrownColor, HTMLBrownMaroonColor,
HTMLGreenDarkOliveGreenColor, HTMLGreenOliveColor,
HTMLGreenOliveDrabColor, HTMLGreenYellowGreenColor,
HTMLGreenLimeGreenColor, HTMLGreenLimeColor,
HTMLGreenLawnGreenColor, HTMLGreenChartreuseColor,
HTMLGreenGreenYellowColor, HTMLGreenSpringGreenColor,
HTMLGreenMediumSpringGreenColor,
HTMLGreenLightGreenColor, HTMLGreenPaleGreenColor,
HTMLGreenDarkSeaGreenColor,
HTMLGreenMediumAquamarineColor,
HTMLGreenMediumSeaGreenColor, HTMLGreenSeaGreenColor,
HTMLGreenForestGreenColor, HTMLGreenGreenColor,
HTMLGreenDarkGreenColor, HTMLCyanAquaColor,
HTMLCyanCyanColor, HTMLCyanLightCyanColor,
HTMLCyanPaleTurquoiseColor, HTMLCyanAquamarineColor,
HTMLCyanTurquoiseColor, HTMLCyanMediumTurquoiseColor,
HTMLCyanDarkTurquoiseColor, HTMLCyanLightSeaGreenColor,
HTMLCyanCadetBlueColor, HTMLCyanDarkCyanColor,
HTMLCyanTealColor, HTMLBlueLightSteelBlueColor,
HTMLBluePowderBlueColor, HTMLBlueLightBlueColor,
HTMLBlueSkyBlueColor, HTMLBlueLightSkyBlueColor,
HTMLBlueDeepSkyBlueColor, HTMLBlueDodgerBlueColor,
HTMLBlueCornflowerBlueColor, HTMLBlueSteelBlueColor,
HTMLBlueRoyalBlueColor, HTMLBlueBlueColor,
HTMLBlueMediumBlueColor, HTMLBlueDarkBlueColor,
HTMLBlueNavyColor, HTMLBlueMidnightBlueColor,
HTMLPurpleLavenderColor, HTMLPurpleThistleColor,
HTMLPurplePlumColor, HTMLPurpleVioletColor,
HTMLPurpleOrchidColor, HTMLPurpleFuchsiaColor,
HTMLPurpleMagentaColor, HTMLPurpleMediumOrchidColor,
HTMLPurpleMediumPurpleColor, HTMLPurpleBlueVioletColor,
HTMLPurpleDarkVioletColor, HTMLPurpleDarkOrchidColor,
HTMLPurpleDarkMagentaColor, HTMLPurplePurpleColor,
HTMLPurpleIndigoColor, HTMLPurpleDarkSlateBlueColor,
HTMLPurpleSlateBlueColor,
HTMLPurpleMediumSlateBlueColor,
HTMLWhiteWhiteColor, HTMLWhiteSnowColor,
HTMLWhiteHoneydewColor, HTMLWhiteMintCreamColor,
HTMLWhiteAzureColor, HTMLWhiteAliceBlueColor,
HTMLWhiteGhostWhiteColor, HTMLWhiteWhiteSmokeColor,
HTMLWhiteSeashellColor, HTMLWhiteBeigeColor,
HTMLWhiteOldLaceColor, HTMLWhiteFloralWhiteColor,
HTMLWhiteIvoryColor, HTMLWhiteAntiqueWhiteColor,
HTMLWhiteLinenColor, HTMLWhiteLavenderBlushColor,
HTMLWhiteMistyRoseColor, HTMLGrayGainsboroColor,
HTMLGrayLightGrayColor, HTMLGraySilverColor,
HTMLGrayDarkGrayColor, HTMLGrayGrayColor,
HTMLGrayDimGrayColor, HTMLGrayLightSlateGrayColor,
HTMLGraySlateGrayColor, HTMLGrayDarkSlateGrayColor,
HTMLGrayBlackColor, NoneColor};
Q_ENUM (Color)
// constructors, destructor
public:
CustomElementGraphicPart(QETElementEditor *editor, QGraphicsItem *parent = nullptr);
CustomElementGraphicPart(QETElementEditor *editor,
QGraphicsItem *parent = nullptr);
~CustomElementGraphicPart() override;
static void drawCross (const QPointF &center, QPainter *painter);
static void drawCross (const QPointF &center,
QPainter *painter);
//Getter and setter
LineStyle lineStyle () const {return _linestyle;}
@@ -89,11 +291,15 @@ class CustomElementGraphicPart : public QGraphicsObject, public CustomElementPar
//Rediriged to QObject Q_PROPERTY system
void setProperty (const char *name, const QVariant &value) override {QObject::setProperty(name, value);}
QVariant property (const char *name) const override {return QObject::property(name);}
void setProperty (const char *name,
const QVariant &value) override {
QObject::setProperty(name, value);}
QVariant property (const char *name) const override {
return QObject::property(name);}
virtual QPainterPath shadowShape ()const = 0;
virtual void setHandlerColor(QPointF /*pos*/, const QColor &/*color*/) {}
virtual void setHandlerColor(QPointF /*pos*/,
const QColor &/*color*/) {}
virtual void resetAllHandlerColor() {}
protected:
@@ -103,13 +309,15 @@ class CustomElementGraphicPart : public QGraphicsObject, public CustomElementPar
void applyStylesToQPainter(QPainter &) const;
void drawShadowShape (QPainter *painter);
QVariant itemChange(GraphicsItemChange change, const QVariant &value) override;
QVariant itemChange(GraphicsItemChange change,
const QVariant &value) override;
void hoverEnterEvent(QGraphicsSceneHoverEvent *event) override;
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) override;
void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override;
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override;
void mouseReleaseEvent(
QGraphicsSceneMouseEvent *event) override;
// attributes
bool m_hovered;

View File

@@ -36,15 +36,25 @@ PartText::PartText(QETElementEditor *editor, QGraphicsItem *parent) :
setDefaultTextColor(Qt::black);
setFont(QETApp::diagramTextsFont());
real_font_size_ = font().pointSize();
setFlags(QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemSendsGeometryChanges | QGraphicsItem::ItemIsMovable);
setFlags(QGraphicsItem::ItemIsSelectable
| QGraphicsItem::ItemSendsGeometryChanges
| QGraphicsItem::ItemIsMovable);
setAcceptHoverEvents(true);
setDefaultTextColor(Qt::black);
setPlainText(QObject::tr("T", "default text when adding a text in the element editor"));
setPlainText(QObject::tr(
"T",
"default text when adding a text in the element editor"));
adjustItemPosition(1);
// adjust textfield position after line additions/deletions
connect(document(), SIGNAL(blockCountChanged(int)), this, SLOT(adjustItemPosition(int)));
connect(document(), SIGNAL(contentsChanged()), this, SLOT(adjustItemPosition()));
connect(document(),
SIGNAL(blockCountChanged(int)),
this,
SLOT(adjustItemPosition(int)));
connect(document(),
SIGNAL(contentsChanged()),
this,
SLOT(adjustItemPosition()));
}
/// Destructeur