mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-01-03 19:10:53 +01:00
Revert "Merge branch 'XMLPropertiesNew'"
**Break a lot of thing.** This reverts commit1db1800572, reversing changes made to4c563821e8.
This commit is contained in:
@@ -210,7 +210,7 @@ void ArcEditor::updateArcA()
|
||||
@brief ArcEditor::updateForm
|
||||
Update the value of the widgets
|
||||
*/
|
||||
void ArcEditor::updateFormPriv()
|
||||
void ArcEditor::updateForm()
|
||||
{
|
||||
if (!m_part) return;
|
||||
activeConnections(false);
|
||||
|
||||
@@ -46,6 +46,8 @@ class ArcEditor : public ElementItemEditor
|
||||
QDoubleSpinBox *x, *y, *h, *v;
|
||||
QSpinBox *angle, *start_angle;
|
||||
bool m_locked;
|
||||
|
||||
QList <QMetaObject::Connection> m_change_connections;
|
||||
|
||||
// methods
|
||||
public:
|
||||
@@ -57,7 +59,7 @@ class ArcEditor : public ElementItemEditor
|
||||
public slots:
|
||||
void updateArcS();
|
||||
void updateArcA();
|
||||
void updateFormPriv() override;
|
||||
void updateForm() override;
|
||||
void updateRect();
|
||||
|
||||
private:
|
||||
|
||||
@@ -42,11 +42,6 @@ ElementScene *ElementItemEditor::elementScene() const
|
||||
return(element_editor -> elementScene());
|
||||
}
|
||||
|
||||
void ElementItemEditor::updateForm()
|
||||
{
|
||||
updateFormPriv();
|
||||
}
|
||||
|
||||
/// @return la QUndoStack a utiliser pour les annulations
|
||||
QUndoStack &ElementItemEditor::undoStack() const
|
||||
{
|
||||
|
||||
@@ -55,16 +55,8 @@ class ElementItemEditor : public QWidget
|
||||
|
||||
virtual CustomElementPart *currentPart() const = 0;
|
||||
virtual QList<CustomElementPart*> currentParts() const = 0;
|
||||
/*!
|
||||
* \brief updateForm
|
||||
* update the values of the widget
|
||||
*/
|
||||
virtual void updateForm();
|
||||
private:
|
||||
virtual void updateFormPriv() = 0;
|
||||
virtual void updateForm() = 0;
|
||||
|
||||
protected:
|
||||
QList<QMetaObject::Connection> m_change_connections;
|
||||
// attributes
|
||||
private:
|
||||
QETElementEditor *element_editor;
|
||||
|
||||
@@ -79,8 +79,8 @@ class AbstractPartEllipse : public CustomElementGraphicPart
|
||||
protected:
|
||||
QList<QPointF> saved_points_;
|
||||
QRectF m_rect;
|
||||
qreal m_start_angle{0};
|
||||
qreal m_span_angle{-1440};
|
||||
qreal m_start_angle;
|
||||
qreal m_span_angle;
|
||||
QVector<QetGraphicsHandlerItem *> m_handler_vector;
|
||||
};
|
||||
|
||||
|
||||
@@ -20,8 +20,6 @@
|
||||
#include "../../QPropertyUndoCommand/qpropertyundocommand.h"
|
||||
#include "../elementscene.h"
|
||||
|
||||
#include "../../qetxml.h"
|
||||
|
||||
#include <QRegularExpression>
|
||||
|
||||
/**
|
||||
@@ -116,7 +114,7 @@ qreal CustomElementGraphicPart::penWeight() const
|
||||
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;
|
||||
else if (_lineweight == BigWeight) return 5;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -169,21 +167,21 @@ void CustomElementGraphicPart::stylesToXml(QDomElement &qde) const
|
||||
QString css_like_styles;
|
||||
|
||||
css_like_styles += "line-style:";
|
||||
if (_linestyle == DashedStyle) css_like_styles += "dashed";
|
||||
else if (_linestyle == DottedStyle) css_like_styles += "dotted";
|
||||
if (_linestyle == DashedStyle) css_like_styles += "dashed";
|
||||
else if (_linestyle == DottedStyle) css_like_styles += "dotted";
|
||||
else if (_linestyle == DashdottedStyle) css_like_styles += "dashdotted";
|
||||
else if (_linestyle == NormalStyle) css_like_styles += "normal";
|
||||
else if (_linestyle == NormalStyle) css_like_styles += "normal";
|
||||
|
||||
css_like_styles += ";line-weight:";
|
||||
if (_lineweight == NoneWeight) css_like_styles += "none";
|
||||
if (_lineweight == NoneWeight) css_like_styles += "none";
|
||||
else if (_lineweight == ThinWeight) css_like_styles += "thin";
|
||||
else if (_lineweight == NormalWeight) css_like_styles += "normal";
|
||||
else if (_lineweight == UltraWeight) css_like_styles += "hight";
|
||||
else if (_lineweight == BigWeight) css_like_styles += "eleve";
|
||||
else if (_lineweight == BigWeight) css_like_styles += "eleve";
|
||||
|
||||
|
||||
css_like_styles += ";filling:";
|
||||
if (_filling == NoneFilling) css_like_styles += "none";
|
||||
if (_filling == NoneFilling) css_like_styles += "none";
|
||||
else if (_filling == BlackFilling) css_like_styles += "black";
|
||||
else if (_filling == WhiteFilling) css_like_styles += "white";
|
||||
else if (_filling == GreenFilling) css_like_styles += "green";
|
||||
@@ -344,7 +342,7 @@ void CustomElementGraphicPart::stylesToXml(QDomElement &qde) const
|
||||
|
||||
|
||||
css_like_styles += ";color:";
|
||||
if (_color == WhiteColor) css_like_styles += "white";
|
||||
if (_color == WhiteColor) css_like_styles += "white";
|
||||
else if (_color == BlackColor) css_like_styles += "black";
|
||||
else if (_color == GreenColor) css_like_styles += "green";
|
||||
else if (_color == RedColor) css_like_styles += "red";
|
||||
@@ -499,6 +497,7 @@ void CustomElementGraphicPart::stylesToXml(QDomElement &qde) const
|
||||
else if (_color == HTMLGrayBlackColor) css_like_styles += "HTMLGrayBlack";
|
||||
else if (_color == NoneColor) css_like_styles += "none";
|
||||
|
||||
|
||||
qde.setAttribute("style", css_like_styles);
|
||||
qde.setAttribute("antialias", _antialiased ? "true" : "false");
|
||||
}
|
||||
@@ -513,9 +512,6 @@ void CustomElementGraphicPart::stylesFromXml(const QDomElement &qde)
|
||||
{
|
||||
resetStyles();
|
||||
|
||||
QString style_string;
|
||||
QETXML::propertyString(qde, "style", &style_string);
|
||||
|
||||
//Get the list of pair style/value
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) // ### Qt 6: remove
|
||||
QStringList styles = qde.attribute("style").split(";", QString::SkipEmptyParts);
|
||||
@@ -903,17 +899,17 @@ void CustomElementGraphicPart::applyStylesToQPainter(QPainter &painter) const
|
||||
QBrush brush = painter.brush();
|
||||
|
||||
//Apply pen style
|
||||
if (_linestyle == DashedStyle) pen.setStyle(Qt::DashLine);
|
||||
if (_linestyle == DashedStyle) pen.setStyle(Qt::DashLine);
|
||||
else if (_linestyle == DashdottedStyle) pen.setStyle(Qt::DashDotLine);
|
||||
else if (_linestyle == DottedStyle) pen.setStyle(Qt::DotLine);
|
||||
else if (_linestyle == NormalStyle) pen.setStyle(Qt::SolidLine);
|
||||
else if (_linestyle == DottedStyle) pen.setStyle(Qt::DotLine);
|
||||
else if (_linestyle == NormalStyle) pen.setStyle(Qt::SolidLine);
|
||||
|
||||
//Apply pen width
|
||||
if (_lineweight == NoneWeight) pen.setColor(QColor(0, 0, 0, 0));
|
||||
if (_lineweight == NoneWeight) pen.setColor(QColor(0, 0, 0, 0));
|
||||
else if (_lineweight == ThinWeight) pen.setWidth(0);
|
||||
else if (_lineweight == NormalWeight) pen.setWidthF(1.0);
|
||||
else if (_lineweight == UltraWeight) pen.setWidthF(2.0);
|
||||
else if (_lineweight == BigWeight) pen.setWidthF(5.0);
|
||||
else if (_lineweight == BigWeight) pen.setWidthF(5.0);
|
||||
|
||||
//Apply brush color
|
||||
if (_filling == NoneFilling) brush.setStyle(Qt::NoBrush);
|
||||
@@ -924,7 +920,7 @@ void CustomElementGraphicPart::applyStylesToQPainter(QPainter &painter) const
|
||||
else
|
||||
{
|
||||
brush.setStyle(Qt::SolidPattern);
|
||||
if (_filling == BlackFilling) brush.setColor(Qt::black);
|
||||
if (_filling == BlackFilling) brush.setColor(Qt::black);
|
||||
else if (_filling == WhiteFilling) brush.setColor(Qt::white);
|
||||
else if (_filling == GreenFilling) brush.setColor(Qt::green);
|
||||
else if (_filling == RedFilling) brush.setColor(Qt::red);
|
||||
@@ -1080,7 +1076,7 @@ void CustomElementGraphicPart::applyStylesToQPainter(QPainter &painter) const
|
||||
}
|
||||
|
||||
//Apply pen color
|
||||
if (_color == WhiteColor) pen.setColor(QColor(255, 255, 255, pen.color().alpha()));
|
||||
if (_color == WhiteColor) pen.setColor(QColor(255, 255, 255, pen.color().alpha()));
|
||||
else if (_color == BlackColor) pen.setColor(QColor( 0, 0, 0, pen.color().alpha()));
|
||||
else if (_color == GreenColor) pen.setColor(QColor(Qt::green));
|
||||
else if (_color == RedColor) pen.setColor(QColor(Qt::red));
|
||||
@@ -1236,8 +1232,8 @@ void CustomElementGraphicPart::applyStylesToQPainter(QPainter &painter) const
|
||||
else if (_color == NoneColor) pen.setBrush(Qt::transparent);
|
||||
|
||||
//Apply antialiasing
|
||||
painter.setRenderHint(QPainter::Antialiasing, _antialiased);
|
||||
painter.setRenderHint(QPainter::TextAntialiasing, _antialiased);
|
||||
painter.setRenderHint(QPainter::Antialiasing, _antialiased);
|
||||
painter.setRenderHint(QPainter::TextAntialiasing, _antialiased);
|
||||
painter.setRenderHint(QPainter::SmoothPixmapTransform, _antialiased);
|
||||
|
||||
painter.setPen(pen);
|
||||
@@ -1316,7 +1312,7 @@ void CustomElementGraphicPart::mouseReleaseEvent(QGraphicsSceneMouseEvent *event
|
||||
if((event->button() & Qt::LeftButton) && (flags() & QGraphicsItem::ItemIsMovable) && m_origin_pos != pos())
|
||||
{
|
||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(this, "pos", QVariant(m_origin_pos), QVariant(pos()));
|
||||
undo->setText(tr("D??placer une primitive"));
|
||||
undo->setText(tr("Déplacer une primitive"));
|
||||
undo->enableAnimation();
|
||||
elementScene()->undoStack().push(undo);
|
||||
}
|
||||
|
||||
@@ -40,9 +40,9 @@ class CustomElementGraphicPart : public QGraphicsObject, public CustomElementPar
|
||||
|
||||
Q_PROPERTY(LineStyle line_style READ lineStyle WRITE setLineStyle)
|
||||
Q_PROPERTY(LineWeight line_weight READ lineWeight WRITE setLineWeight)
|
||||
Q_PROPERTY(Filling filling READ filling WRITE setFilling)
|
||||
Q_PROPERTY(Color color READ color WRITE setColor)
|
||||
Q_PROPERTY(bool antialias READ antialiased WRITE setAntialiased)
|
||||
Q_PROPERTY(Filling filling READ filling WRITE setFilling)
|
||||
Q_PROPERTY(Color color READ color WRITE setColor)
|
||||
Q_PROPERTY(bool antialias READ antialiased WRITE setAntialiased)
|
||||
|
||||
public:
|
||||
//Line style
|
||||
@@ -62,122 +62,122 @@ class CustomElementGraphicPart : public QGraphicsObject, public CustomElementPar
|
||||
|
||||
//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};
|
||||
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
|
||||
@@ -269,18 +269,18 @@ class CustomElementGraphicPart : public QGraphicsObject, public CustomElementPar
|
||||
~CustomElementGraphicPart() override;
|
||||
|
||||
static void drawCross (const QPointF ¢er,
|
||||
QPainter *painter);
|
||||
QPainter *painter);
|
||||
|
||||
//Getter and setter
|
||||
LineStyle lineStyle () const {return _linestyle;}
|
||||
void setLineStyle (const LineStyle ls);
|
||||
LineStyle lineStyle () const {return _linestyle;}
|
||||
void setLineStyle (const LineStyle ls);
|
||||
|
||||
LineWeight lineWeight () const {return _lineweight;}
|
||||
void setLineWeight (const LineWeight lw);
|
||||
qreal penWeight () const;
|
||||
LineWeight lineWeight () const {return _lineweight;}
|
||||
void setLineWeight (const LineWeight lw);
|
||||
qreal penWeight () const;
|
||||
|
||||
Filling filling () const {return _filling;}
|
||||
void setFilling(const Filling f);
|
||||
void setFilling(const Filling f);
|
||||
|
||||
Color color () const {return _color;}
|
||||
void setColor(const Color c);
|
||||
@@ -299,11 +299,11 @@ class CustomElementGraphicPart : public QGraphicsObject, public CustomElementPar
|
||||
|
||||
virtual QPainterPath shadowShape ()const = 0;
|
||||
virtual void setHandlerColor(QPointF /*pos*/,
|
||||
const QColor &/*color*/) {}
|
||||
const QColor &/*color*/) {}
|
||||
virtual void resetAllHandlerColor() {}
|
||||
|
||||
protected:
|
||||
void stylesToXml (QDomElement &) const;
|
||||
void stylesToXml (QDomElement &) const;
|
||||
void stylesFromXml(const QDomElement &);
|
||||
void resetStyles ();
|
||||
void applyStylesToQPainter(QPainter &) const;
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
#define CUSTOM_ELEMENT_PART_H
|
||||
|
||||
#include "../../qet.h"
|
||||
#include "../../properties/propertiesinterface.h"
|
||||
|
||||
class CustomElement;
|
||||
class ElementPrimitiveDecorator;
|
||||
@@ -38,7 +37,7 @@ class QGraphicsSceneMouseEvent;
|
||||
there is no point for those classes to store their visual representation
|
||||
with anything more complex than a QImage.
|
||||
*/
|
||||
class CustomElementPart: public PropertiesInterface {
|
||||
class CustomElementPart {
|
||||
// constructors, destructor
|
||||
public:
|
||||
/**
|
||||
@@ -62,6 +61,14 @@ class CustomElementPart: public PropertiesInterface {
|
||||
|
||||
// methods
|
||||
public:
|
||||
/**
|
||||
Load the primitive from an XML element that describes it
|
||||
*/
|
||||
virtual void fromXml(const QDomElement &) = 0;
|
||||
/**
|
||||
Export the primitive as an XML element
|
||||
*/
|
||||
virtual const QDomElement toXml(QDomDocument &) const = 0;
|
||||
/**
|
||||
Set a specific property of the primitive
|
||||
*/
|
||||
@@ -85,7 +92,7 @@ class CustomElementPart: public PropertiesInterface {
|
||||
Make this part fit into the provided rectangle.
|
||||
*/
|
||||
virtual void handleUserTransformation(const QRectF &,
|
||||
const QRectF &) = 0;
|
||||
const QRectF &) = 0;
|
||||
/// @return a pointer to the parent element editor
|
||||
virtual QETElementEditor *elementEditor() const;
|
||||
/**
|
||||
|
||||
@@ -22,8 +22,6 @@
|
||||
#include "../../QetGraphicsItemModeler/qetgraphicshandlerutility.h"
|
||||
#include "../elementscene.h"
|
||||
|
||||
#include "../../qetxml.h"
|
||||
|
||||
/**
|
||||
@brief PartArc::PartArc
|
||||
Constructor
|
||||
@@ -31,9 +29,10 @@
|
||||
@param parent : parent item
|
||||
*/
|
||||
PartArc::PartArc(QETElementEditor *editor, QGraphicsItem *parent) :
|
||||
AbstractPartEllipse(editor, parent)
|
||||
AbstractPartEllipse(editor, parent)
|
||||
{
|
||||
setTagName("arc");
|
||||
m_start_angle = 0;
|
||||
m_span_angle = -1440;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -103,18 +102,19 @@ void PartArc::paint(QPainter *painter, const QStyleOptionGraphicsItem *options,
|
||||
@param xml_document : Xml document to use for create the xml element.
|
||||
@return : an xml element that describe this arc
|
||||
*/
|
||||
void PartArc::toXmlPriv(QDomElement& xml_element) const
|
||||
const QDomElement PartArc::toXml(QDomDocument &xml_document) const
|
||||
{
|
||||
xml_element.setTagName("arc");
|
||||
QPointF top_left(sceneTopLeft());
|
||||
xml_element.setAttribute("x", QString("%1").arg(top_left.x()));
|
||||
xml_element.setAttribute("y", QString("%1").arg(top_left.y()));
|
||||
xml_element.setAttribute("width", QString("%1").arg(rect().width()));
|
||||
xml_element.setAttribute("height", QString("%1").arg(rect().height()));
|
||||
//to maintain compatibility with the previous version, we write the angle in degrees.
|
||||
xml_element.setAttribute("start", QString("%1").arg(m_start_angle / 16));
|
||||
xml_element.setAttribute("angle", QString("%1").arg(m_span_angle / 16));
|
||||
stylesToXml(xml_element);
|
||||
QDomElement xml_element = xml_document.createElement("arc");
|
||||
QPointF top_left(sceneTopLeft());
|
||||
xml_element.setAttribute("x", QString("%1").arg(top_left.x()));
|
||||
xml_element.setAttribute("y", QString("%1").arg(top_left.y()));
|
||||
xml_element.setAttribute("width", QString("%1").arg(rect().width()));
|
||||
xml_element.setAttribute("height", QString("%1").arg(rect().height()));
|
||||
//to maintain compatibility with the previous version, we write the angle in degrees.
|
||||
xml_element.setAttribute("start", QString("%1").arg(m_start_angle / 16));
|
||||
xml_element.setAttribute("angle", QString("%1").arg(m_span_angle / 16));
|
||||
stylesToXml(xml_element);
|
||||
return(xml_element);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -122,41 +122,15 @@ void PartArc::toXmlPriv(QDomElement& xml_element) const
|
||||
Import the properties of this arc from a xml element.
|
||||
@param qde : Xml document to use.
|
||||
*/
|
||||
bool PartArc::fromXmlPriv(const QDomElement &qde) {
|
||||
void PartArc::fromXml(const QDomElement &qde) {
|
||||
stylesFromXml(qde);
|
||||
m_rect = QRectF(mapFromScene(qde.attribute("x", "0").toDouble(),
|
||||
qde.attribute("y", "0").toDouble()),
|
||||
QSizeF(qde.attribute("width", "0").toDouble(),
|
||||
qde.attribute("height", "0").toDouble()) );
|
||||
|
||||
double x=0, y=0, w=0, h=0;
|
||||
if (QETXML::propertyDouble(qde, "x", &x) == QETXML::PropertyFlags::NoValidConversion ||
|
||||
QETXML::propertyDouble(qde, "y", &y) == QETXML::PropertyFlags::NoValidConversion ||
|
||||
QETXML::propertyDouble(qde, "width", &w) == QETXML::PropertyFlags::NoValidConversion ||
|
||||
QETXML::propertyDouble(qde, "height", &h) == QETXML::PropertyFlags::NoValidConversion)
|
||||
return false;
|
||||
|
||||
m_rect = QRectF(mapFromScene(x, y), QSizeF(w, h) );
|
||||
|
||||
m_start_angle = 0;
|
||||
if (QETXML::propertyDouble(qde, "start", &m_start_angle) == QETXML::PropertyFlags::NoValidConversion)
|
||||
return false;
|
||||
m_start_angle *= 16;
|
||||
|
||||
m_span_angle = -1440;
|
||||
if (QETXML::propertyDouble(qde, "angle", &m_span_angle) == QETXML::PropertyFlags::NoValidConversion)
|
||||
return false;
|
||||
m_span_angle *= 16;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PartArc::valideXml(QDomElement& element) {
|
||||
|
||||
if (QETXML::propertyDouble(element, "x") == QETXML::PropertyFlags::NoValidConversion ||
|
||||
QETXML::propertyDouble(element, "y") == QETXML::PropertyFlags::NoValidConversion ||
|
||||
QETXML::propertyDouble(element, "width") == QETXML::PropertyFlags::NoValidConversion ||
|
||||
QETXML::propertyDouble(element, "height") == QETXML::PropertyFlags::NoValidConversion ||
|
||||
QETXML::propertyDouble(element, "start") == QETXML::PropertyFlags::NoValidConversion ||
|
||||
QETXML::propertyDouble(element, "angle") == QETXML::PropertyFlags::NoValidConversion)
|
||||
return false;
|
||||
return true;
|
||||
m_start_angle = qde.attribute("start", "0").toDouble() * 16;
|
||||
m_span_angle = qde.attribute("angle", "-1440").toDouble() * 16;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -49,13 +49,10 @@ class PartArc : public AbstractPartEllipse
|
||||
void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget * = nullptr) override;
|
||||
|
||||
//Name and XML
|
||||
QString name() const override { return(QObject::tr("arc", "element part name")); }
|
||||
QString name() const override { return(QObject::tr("arc", "element part name")); }
|
||||
QString xmlName() const override { return(QString("arc")); }
|
||||
void toXmlPriv(QDomElement&xml_element) const override;
|
||||
bool fromXmlPriv (const QDomElement &) override;
|
||||
static bool valideXml(QDomElement& element);
|
||||
void toSettings(QSettings &,const QString & = QString()) const override {/*TODO: implement*/}
|
||||
void fromSettings(QSettings &,const QString & = QString()) override{/*TODO: implement*/}
|
||||
const QDomElement toXml (QDomDocument &) const override;
|
||||
void fromXml (const QDomElement &) override;
|
||||
|
||||
QPainterPath shape() const override;
|
||||
QPainterPath shadowShape() const override;
|
||||
@@ -73,7 +70,7 @@ class PartArc : public AbstractPartEllipse
|
||||
void switchResizeMode();
|
||||
void adjusteHandlerPos();
|
||||
void handlerMousePressEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
|
||||
void handlerMouseMoveEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
|
||||
void handlerMouseMoveEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
|
||||
void handlerMouseReleaseEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
|
||||
void sceneSelectionChanged ();
|
||||
|
||||
|
||||
@@ -21,8 +21,6 @@
|
||||
#include "../../qetapp.h"
|
||||
#include "../elementscene.h"
|
||||
|
||||
#include "../../qetxml.h"
|
||||
|
||||
#include <QColor>
|
||||
#include <QFont>
|
||||
#include <QGraphicsSceneMouseEvent>
|
||||
@@ -32,7 +30,6 @@ PartDynamicTextField::PartDynamicTextField(QETElementEditor *editor, QGraphicsIt
|
||||
CustomElementPart(editor),
|
||||
m_uuid(QUuid::createUuid())
|
||||
{
|
||||
setTagName(xmlName());
|
||||
setDefaultTextColor(Qt::black);
|
||||
setFont(QETApp::dynamicTextsItemFont());
|
||||
QSettings settings;
|
||||
@@ -96,91 +93,88 @@ void PartDynamicTextField::handleUserTransformation(
|
||||
@param dom_doc
|
||||
@return
|
||||
*/
|
||||
void PartDynamicTextField::toXmlPriv(QDomElement& root_element) const
|
||||
const QDomElement PartDynamicTextField::toXml(QDomDocument &dom_doc) const
|
||||
{
|
||||
QDomElement root_element = dom_doc.createElement(xmlName());
|
||||
|
||||
root_element.setAttribute("x", QString::number(pos().x()));
|
||||
root_element.setAttribute("y", QString::number(pos().y()));
|
||||
root_element.setAttribute("z", QString::number(zValue()));
|
||||
root_element.setAttribute("rotation", QString::number(QET::correctAngle(rotation())));
|
||||
root_element.setAttribute("font", font().toString());
|
||||
root_element.setAttribute("uuid", m_uuid.toString());
|
||||
root_element.setAttribute("frame", m_frame? "true" : "false");
|
||||
root_element.setAttribute("text_width", QString::number(m_text_width));
|
||||
root_element.setAttribute("x", QString::number(pos().x()));
|
||||
root_element.setAttribute("y", QString::number(pos().y()));
|
||||
root_element.setAttribute("z", QString::number(zValue()));
|
||||
root_element.setAttribute("rotation", QString::number(QET::correctAngle(rotation())));
|
||||
root_element.setAttribute("font", font().toString());
|
||||
root_element.setAttribute("uuid", m_uuid.toString());
|
||||
root_element.setAttribute("frame", m_frame? "true" : "false");
|
||||
root_element.setAttribute("text_width", QString::number(m_text_width));
|
||||
|
||||
QMetaEnum me = DynamicElementTextItem::textFromMetaEnum();
|
||||
root_element.setAttribute("text_from", me.valueToKey(m_text_from));
|
||||
QMetaEnum me = DynamicElementTextItem::textFromMetaEnum();
|
||||
root_element.setAttribute("text_from", me.valueToKey(m_text_from));
|
||||
|
||||
me = QMetaEnum::fromType<Qt::Alignment>();
|
||||
if(this -> alignment() &Qt::AlignRight)
|
||||
root_element.setAttribute("Halignment", me.valueToKey(Qt::AlignRight));
|
||||
else if(this -> alignment() &Qt::AlignLeft)
|
||||
root_element.setAttribute("Halignment", me.valueToKey(Qt::AlignLeft));
|
||||
else if(this -> alignment() &Qt::AlignHCenter)
|
||||
root_element.setAttribute("Halignment", me.valueToKey(Qt::AlignHCenter));
|
||||
me = QMetaEnum::fromType<Qt::Alignment>();
|
||||
if(this -> alignment() &Qt::AlignRight)
|
||||
root_element.setAttribute("Halignment", me.valueToKey(Qt::AlignRight));
|
||||
else if(this -> alignment() &Qt::AlignLeft)
|
||||
root_element.setAttribute("Halignment", me.valueToKey(Qt::AlignLeft));
|
||||
else if(this -> alignment() &Qt::AlignHCenter)
|
||||
root_element.setAttribute("Halignment", me.valueToKey(Qt::AlignHCenter));
|
||||
|
||||
if(this -> alignment() &Qt::AlignBottom)
|
||||
root_element.setAttribute("Valignment", me.valueToKey(Qt::AlignBottom));
|
||||
else if(this -> alignment() & Qt::AlignTop)
|
||||
root_element.setAttribute("Valignment", me.valueToKey(Qt::AlignTop));
|
||||
else if(this -> alignment() &Qt::AlignVCenter)
|
||||
root_element.setAttribute("Valignment", me.valueToKey(Qt::AlignVCenter));
|
||||
if(this -> alignment() &Qt::AlignBottom)
|
||||
root_element.setAttribute("Valignment", me.valueToKey(Qt::AlignBottom));
|
||||
else if(this -> alignment() & Qt::AlignTop)
|
||||
root_element.setAttribute("Valignment", me.valueToKey(Qt::AlignTop));
|
||||
else if(this -> alignment() &Qt::AlignVCenter)
|
||||
root_element.setAttribute("Valignment", me.valueToKey(Qt::AlignVCenter));
|
||||
|
||||
QDomElement dom_text = root_element.ownerDocument().createElement("text");
|
||||
dom_text.appendChild(root_element.ownerDocument().createTextNode(toPlainText()));
|
||||
root_element.appendChild(dom_text);
|
||||
QDomElement dom_text = dom_doc.createElement("text");
|
||||
dom_text.appendChild(dom_doc.createTextNode(toPlainText()));
|
||||
root_element.appendChild(dom_text);
|
||||
|
||||
//Info name
|
||||
if(!m_info_name.isEmpty()) {
|
||||
QDomElement dom_info_name = root_element.ownerDocument().createElement("info_name");
|
||||
dom_info_name.appendChild(root_element.ownerDocument().createTextNode(m_info_name));
|
||||
root_element.appendChild(dom_info_name);
|
||||
}
|
||||
//Info name
|
||||
if(!m_info_name.isEmpty()) {
|
||||
QDomElement dom_info_name = dom_doc.createElement("info_name");
|
||||
dom_info_name.appendChild(dom_doc.createTextNode(m_info_name));
|
||||
root_element.appendChild(dom_info_name);
|
||||
}
|
||||
|
||||
//Composite text
|
||||
if(!m_composite_text.isEmpty()) {
|
||||
QDomElement dom_comp_text = root_element.ownerDocument().createElement("composite_text");
|
||||
dom_comp_text.appendChild(root_element.ownerDocument().createTextNode(m_composite_text));
|
||||
root_element.appendChild(dom_comp_text);
|
||||
}
|
||||
//Composite text
|
||||
if(!m_composite_text.isEmpty()) {
|
||||
QDomElement dom_comp_text = dom_doc.createElement("composite_text");
|
||||
dom_comp_text.appendChild(dom_doc.createTextNode(m_composite_text));
|
||||
root_element.appendChild(dom_comp_text);
|
||||
}
|
||||
|
||||
//Color
|
||||
if(color() != QColor(Qt::black)) {
|
||||
QDomElement dom_color = root_element.ownerDocument().createElement("color");
|
||||
dom_color.appendChild(root_element.ownerDocument().createTextNode(color().name()));
|
||||
root_element.appendChild(dom_color);
|
||||
}
|
||||
//Color
|
||||
if(color() != QColor(Qt::black)) {
|
||||
QDomElement dom_color = dom_doc.createElement("color");
|
||||
dom_color.appendChild(dom_doc.createTextNode(color().name()));
|
||||
root_element.appendChild(dom_color);
|
||||
}
|
||||
|
||||
return root_element;
|
||||
}
|
||||
|
||||
/**
|
||||
@brief PartDynamicTextField::fromXml
|
||||
@param dom_elmt
|
||||
*/
|
||||
bool PartDynamicTextField::fromXmlPriv(const QDomElement &dom_elmt)
|
||||
{
|
||||
void PartDynamicTextField::fromXml(const QDomElement &dom_elmt) {
|
||||
if (dom_elmt.tagName() != xmlName()) {
|
||||
qDebug() << "PartDynamicTextField::fromXml : Wrong tagg name";
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
|
||||
double x=0, y=0, z=0, rot=0;
|
||||
if (QETXML::propertyDouble(dom_elmt, "x", &x) == QETXML::PropertyFlags::NoValidConversion ||
|
||||
QETXML::propertyDouble(dom_elmt, "y", &y) == QETXML::PropertyFlags::NoValidConversion ||
|
||||
QETXML::propertyDouble(dom_elmt, "z", &z) == QETXML::PropertyFlags::NoValidConversion ||
|
||||
QETXML::propertyDouble(dom_elmt, "rotation", &rot) == QETXML::PropertyFlags::NoValidConversion)
|
||||
return false;
|
||||
|
||||
QGraphicsTextItem::setPos(x, y);
|
||||
setZValue(z);
|
||||
QGraphicsTextItem::setRotation(rot);
|
||||
QGraphicsTextItem::setPos(
|
||||
dom_elmt.attribute("x", QString::number(0)).toDouble(),
|
||||
dom_elmt.attribute("y", QString::number(0)).toDouble()
|
||||
);
|
||||
setZValue(dom_elmt.attribute("z", QString::number(zValue())).toDouble());
|
||||
QGraphicsTextItem::setRotation(dom_elmt.attribute("rotation", QString::number(0)).toDouble());
|
||||
|
||||
QString font;
|
||||
if (QETXML::propertyString(dom_elmt, "font", &font) == QETXML::PropertyFlags::Success)
|
||||
{
|
||||
if (dom_elmt.hasAttribute("font")) {
|
||||
QFont font_;
|
||||
font_.fromString(font);
|
||||
font_.fromString(dom_elmt.attribute("font"));
|
||||
setFont(font_);
|
||||
} else { //Keep compatibility TODO remove in futur
|
||||
}
|
||||
else {
|
||||
#if TODO_LIST
|
||||
#pragma message("@TODO remove in futur")
|
||||
#endif
|
||||
@@ -188,24 +182,19 @@ bool PartDynamicTextField::fromXmlPriv(const QDomElement &dom_elmt)
|
||||
setFont(QETApp::dynamicTextsItemFont(9));
|
||||
}
|
||||
|
||||
QETXML::propertyUuid(dom_elmt, "uuid", &m_uuid);
|
||||
bool frame;
|
||||
QETXML::propertyBool(dom_elmt, "frame", &frame);
|
||||
|
||||
double text_width=-1;
|
||||
QETXML::propertyDouble(dom_elmt, "text_width", &text_width);
|
||||
setTextWidth(text_width);
|
||||
m_uuid = QUuid(dom_elmt.attribute("uuid", QUuid::createUuid().toString()));
|
||||
setFrame(dom_elmt.attribute("frame", "false") == "true"? true : false);
|
||||
setTextWidth(dom_elmt.attribute("text_width", QString::number(-1)).toDouble());
|
||||
|
||||
QMetaEnum me = DynamicElementTextItem::textFromMetaEnum();
|
||||
QString text_from;
|
||||
QETXML::propertyString(dom_elmt, "text_from", &text_from);
|
||||
m_text_from = DynamicElementTextItem::TextFrom(me.keyToValue(text_from.toStdString().data()));
|
||||
m_text_from = DynamicElementTextItem::TextFrom(
|
||||
me.keyToValue(dom_elmt.attribute("text_from").toStdString().data()));
|
||||
|
||||
me = QMetaEnum::fromType<Qt::Alignment>();
|
||||
QString alignment;
|
||||
if(QETXML::propertyString(dom_elmt, "Halignment", &alignment) != QETXML::PropertyFlags::NotFound)
|
||||
setAlignment(Qt::Alignment(me.keyToValue(alignment.toStdString().data())));
|
||||
if(QETXML::propertyString(dom_elmt, "Valignment", &alignment) != QETXML::PropertyFlags::NotFound)
|
||||
if(dom_elmt.hasAttribute("Halignment"))
|
||||
setAlignment(Qt::Alignment(
|
||||
me.keyToValue(dom_elmt.attribute("Halignment").toStdString().data())));
|
||||
if(dom_elmt.hasAttribute(("Valignment")))
|
||||
setAlignment(Qt::Alignment(
|
||||
me.keyToValue(dom_elmt.attribute("Valignment").toStdString().data())) | this -> alignment());
|
||||
|
||||
@@ -232,29 +221,6 @@ bool PartDynamicTextField::fromXmlPriv(const QDomElement &dom_elmt)
|
||||
QDomElement dom_color = dom_elmt.firstChildElement("color");
|
||||
if(!dom_color.isNull())
|
||||
setColor(QColor(dom_color.text()));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PartDynamicTextField::valideXml(QDomElement& dom_elmt) {
|
||||
if (QETXML::propertyDouble(dom_elmt, "x") == QETXML::PropertyFlags::NoValidConversion ||
|
||||
QETXML::propertyDouble(dom_elmt, "y") == QETXML::PropertyFlags::NoValidConversion ||
|
||||
QETXML::propertyDouble(dom_elmt, "z") == QETXML::PropertyFlags::NoValidConversion ||
|
||||
QETXML::propertyDouble(dom_elmt, "rotation") == QETXML::PropertyFlags::NoValidConversion)
|
||||
return false;
|
||||
|
||||
if (QETXML::propertyUuid(dom_elmt, "uuid") == QETXML::PropertyFlags::NoValidConversion)
|
||||
return false;
|
||||
|
||||
if (QETXML::propertyString(dom_elmt, "text_from"))
|
||||
return false;
|
||||
|
||||
if(QETXML::propertyString(dom_elmt, "Halignment") == QETXML::PropertyFlags::NotFound)
|
||||
return false;
|
||||
if(QETXML::propertyString(dom_elmt, "Valignment") == QETXML::PropertyFlags::NotFound)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -498,7 +464,7 @@ void PartDynamicTextField::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) {
|
||||
m_origine_pos != pos()) {
|
||||
QPropertyUndoCommand *undo =\
|
||||
new QPropertyUndoCommand(this, "pos", QVariant(m_origine_pos), QVariant(pos()));
|
||||
undo -> setText(tr("D??placer un champ texte"));
|
||||
undo -> setText(tr("Déplacer un champ texte"));
|
||||
undo -> enableAnimation();
|
||||
elementScene() -> undoStack().push(undo);
|
||||
}
|
||||
|
||||
@@ -75,12 +75,9 @@ class PartDynamicTextField : public QGraphicsTextItem, public CustomElementPart
|
||||
void startUserTransformation(const QRectF &initial_selection_rect) override;
|
||||
void handleUserTransformation(const QRectF &initial_selection_rect, const QRectF &new_selection_rect) override;
|
||||
|
||||
void toXmlPriv(QDomElement&root_element) const override;
|
||||
bool fromXmlPriv(const QDomElement &dom_elmt) override;
|
||||
const QDomElement toXml(QDomDocument &dom_doc) const override;
|
||||
void fromXml(const QDomElement &dom_elmt) override;
|
||||
void fromTextFieldXml(const QDomElement &dom_element);
|
||||
static bool valideXml(QDomElement& dom_elmt);
|
||||
void toSettings(QSettings &,const QString & = QString()) const override {/*TODO: implement*/}
|
||||
void fromSettings(QSettings &,const QString & = QString()) override{/*TODO: implement*/}
|
||||
|
||||
DynamicElementTextItem::TextFrom textFrom() const;
|
||||
void setTextFrom (DynamicElementTextItem::TextFrom text_from);
|
||||
@@ -119,7 +116,7 @@ class PartDynamicTextField : public QGraphicsTextItem, public CustomElementPart
|
||||
m_info_name,
|
||||
m_composite_text;
|
||||
DynamicElementTextItem::TextFrom m_text_from = DynamicElementTextItem::UserText;
|
||||
QUuid m_uuid{QUuid::createUuid()};
|
||||
QUuid m_uuid;
|
||||
bool m_frame = false,
|
||||
m_first_add = true,
|
||||
m_block_alignment = false;
|
||||
|
||||
@@ -22,8 +22,6 @@
|
||||
#include "../../QetGraphicsItemModeler/qetgraphicshandlerutility.h"
|
||||
#include "../elementscene.h"
|
||||
|
||||
#include "../../qetxml.h"
|
||||
|
||||
/**
|
||||
@brief PartEllipse::PartEllipse
|
||||
Constructor
|
||||
@@ -81,81 +79,56 @@ void PartEllipse::paint(QPainter *painter, const QStyleOptionGraphicsItem *optio
|
||||
}
|
||||
|
||||
/**
|
||||
@brief PartEllipse::toXmlPriv
|
||||
@brief PartEllipse::toXml
|
||||
Export this ellipse in xml
|
||||
@param xml_document : Xml document to use for create the xml element.
|
||||
@return : an xml element that describe this ellipse
|
||||
*/
|
||||
void PartEllipse::toXmlPriv(QDomElement& xml_element) const
|
||||
const QDomElement PartEllipse::toXml(QDomDocument &xml_document) const
|
||||
{
|
||||
if (qFuzzyCompare(rect().width(), rect().height()))
|
||||
{
|
||||
xml_element.setTagName("circle");
|
||||
xml_element.setAttribute("diameter", QString("%1").arg(rect().width()));
|
||||
}
|
||||
else
|
||||
{
|
||||
xml_element.setTagName("ellipse");
|
||||
xml_element.setAttribute("width", QString("%1").arg(rect().width()));
|
||||
xml_element.setAttribute("height", QString("%1").arg(rect().height()));
|
||||
}
|
||||
QDomElement xml_element;
|
||||
if (qFuzzyCompare(rect().width(), rect().height()))
|
||||
{
|
||||
xml_element = xml_document.createElement("circle");
|
||||
xml_element.setAttribute("diameter", QString("%1").arg(rect().width()));
|
||||
}
|
||||
else
|
||||
{
|
||||
xml_element = xml_document.createElement("ellipse");
|
||||
xml_element.setAttribute("width", QString("%1").arg(rect().width()));
|
||||
xml_element.setAttribute("height", QString("%1").arg(rect().height()));
|
||||
}
|
||||
|
||||
QPointF top_left(sceneTopLeft());
|
||||
xml_element.setAttribute("x", QString("%1").arg(top_left.x()));
|
||||
xml_element.setAttribute("y", QString("%1").arg(top_left.y()));
|
||||
QPointF top_left(sceneTopLeft());
|
||||
xml_element.setAttribute("x", QString("%1").arg(top_left.x()));
|
||||
xml_element.setAttribute("y", QString("%1").arg(top_left.y()));
|
||||
|
||||
stylesToXml(xml_element);
|
||||
stylesToXml(xml_element);
|
||||
|
||||
return(xml_element);
|
||||
}
|
||||
|
||||
/**
|
||||
@brief PartEllipse::fromXmlPriv
|
||||
@brief PartEllipse::fromXml
|
||||
Import the properties of this ellipse from a xml element.
|
||||
@param qde : Xml document to use.
|
||||
*/
|
||||
bool PartEllipse::fromXmlPriv(const QDomElement &qde)
|
||||
void PartEllipse::fromXml(const QDomElement &qde)
|
||||
{
|
||||
stylesFromXml(qde);
|
||||
double x=0, y=0, width=0, height=0;
|
||||
qreal width, height;
|
||||
|
||||
if (qde.tagName() == "ellipse")
|
||||
{
|
||||
if (QETXML::propertyDouble(qde, "width", &width) == QETXML::PropertyFlags::NoValidConversion ||
|
||||
QETXML::propertyDouble(qde, "height", &height) == QETXML::PropertyFlags::NoValidConversion)
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
if (QETXML::propertyDouble(qde, "diameter", &width) == QETXML::PropertyFlags::NoValidConversion)
|
||||
return false;
|
||||
height = width;
|
||||
width = qde.attribute("width", "0").toDouble();
|
||||
height = qde.attribute("height", "0").toDouble();
|
||||
}
|
||||
else
|
||||
width = height = qde.attribute("diameter", "0").toDouble();
|
||||
|
||||
|
||||
if (QETXML::propertyDouble(qde, "x", &x) == QETXML::PropertyFlags::NoValidConversion ||
|
||||
QETXML::propertyDouble(qde, "y", &y) == QETXML::PropertyFlags::NoValidConversion)
|
||||
return false;
|
||||
|
||||
m_rect = QRectF(mapFromScene(x, y), QSizeF(width, height));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PartEllipse::valideXml(QDomElement& element) {
|
||||
if (element.tagName() == "ellipse")
|
||||
{
|
||||
if (QETXML::propertyDouble(element, "width") & QETXML::PropertyFlags::NoValidConversion ||
|
||||
QETXML::propertyDouble(element, "height") & QETXML::PropertyFlags::NoValidConversion)
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
if (QETXML::propertyDouble(element, "diameter") & QETXML::PropertyFlags::NoValidConversion)
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if ((QETXML::propertyDouble(element, "x") & QETXML::PropertyFlags::NoValidConversion) ||
|
||||
(QETXML::propertyDouble(element, "y") & QETXML::PropertyFlags::NoValidConversion))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
m_rect = QRectF(mapFromScene(qde.attribute("x", "0").toDouble(),
|
||||
qde.attribute("y", "0").toDouble()),
|
||||
QSizeF(width, height));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -50,13 +50,10 @@ class PartEllipse : public AbstractPartEllipse
|
||||
void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget * = nullptr) override;
|
||||
|
||||
//Name and XML
|
||||
QString name() const override { return(QObject::tr("ellipse", "element part name")); }
|
||||
QString name() const override { return(QObject::tr("ellipse", "element part name")); }
|
||||
QString xmlName() const override { return(QString("ellipse")); }
|
||||
void toXmlPriv(QDomElement&xml_element) const override;
|
||||
bool fromXmlPriv(const QDomElement &) override;
|
||||
static bool valideXml(QDomElement& element);
|
||||
void toSettings(QSettings &,const QString & = QString()) const override {/*TODO: implement*/}
|
||||
void fromSettings(QSettings &,const QString & = QString()) override{/*TODO: implement*/}
|
||||
const QDomElement toXml (QDomDocument &) const override;
|
||||
void fromXml (const QDomElement &) override;
|
||||
QPainterPath shape() const override;
|
||||
QPainterPath shadowShape() const override;
|
||||
void setRect(const QRectF &rect) override {AbstractPartEllipse::setRect(rect); adjusteHandlerPos();}
|
||||
@@ -70,7 +67,7 @@ class PartEllipse : public AbstractPartEllipse
|
||||
void switchResizeMode();
|
||||
void adjusteHandlerPos();
|
||||
void handlerMousePressEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
|
||||
void handlerMouseMoveEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
|
||||
void handlerMouseMoveEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
|
||||
void handlerMouseReleaseEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
|
||||
void sceneSelectionChanged ();
|
||||
|
||||
|
||||
@@ -21,8 +21,6 @@
|
||||
#include "../../QetGraphicsItemModeler/qetgraphicshandleritem.h"
|
||||
#include "../elementscene.h"
|
||||
|
||||
#include "../../qetxml.h"
|
||||
|
||||
#include <cmath>
|
||||
|
||||
/**
|
||||
@@ -32,10 +30,13 @@
|
||||
@param parent : parent item
|
||||
*/
|
||||
PartLine::PartLine(QETElementEditor *editor, QGraphicsItem *parent) :
|
||||
CustomElementGraphicPart(editor, parent)
|
||||
{
|
||||
setTagName("line");
|
||||
}
|
||||
CustomElementGraphicPart(editor, parent),
|
||||
first_end(Qet::None),
|
||||
first_length(1.5),
|
||||
second_end(Qet::None),
|
||||
second_length(1.5),
|
||||
m_undo_command(nullptr)
|
||||
{}
|
||||
|
||||
/// Destructeur
|
||||
PartLine::~PartLine()
|
||||
@@ -104,26 +105,28 @@ void PartLine::paint(QPainter *painter, const QStyleOptionGraphicsItem *options,
|
||||
}
|
||||
|
||||
/**
|
||||
@brief PartLine::toXmlPriv
|
||||
@brief PartLine::toXml
|
||||
Export this line in xml
|
||||
@param xml_document : Xml document to use for create the xml element.
|
||||
@return an xml element that describe this line
|
||||
*/
|
||||
void PartLine::toXmlPriv(QDomElement& xml_element) const
|
||||
const QDomElement PartLine::toXml(QDomDocument &xml_document) const
|
||||
{
|
||||
QPointF p1(sceneP1());
|
||||
QPointF p2(sceneP2());
|
||||
QPointF p1(sceneP1());
|
||||
QPointF p2(sceneP2());
|
||||
|
||||
xml_element.setAttribute("x1", QString("%1").arg(p1.x()));
|
||||
xml_element.setAttribute("y1", QString("%1").arg(p1.y()));
|
||||
xml_element.setAttribute("x2", QString("%1").arg(p2.x()));
|
||||
xml_element.setAttribute("y2", QString("%1").arg(p2.y()));
|
||||
xml_element.setAttribute("end1", Qet::endTypeToString(first_end));
|
||||
xml_element.setAttribute("length1", QString("%1").arg(first_length));
|
||||
xml_element.setAttribute("end2", Qet::endTypeToString(second_end));
|
||||
xml_element.setAttribute("length2", QString("%1").arg(second_length));
|
||||
QDomElement xml_element = xml_document.createElement("line");
|
||||
xml_element.setAttribute("x1", QString("%1").arg(p1.x()));
|
||||
xml_element.setAttribute("y1", QString("%1").arg(p1.y()));
|
||||
xml_element.setAttribute("x2", QString("%1").arg(p2.x()));
|
||||
xml_element.setAttribute("y2", QString("%1").arg(p2.y()));
|
||||
xml_element.setAttribute("end1", Qet::endTypeToString(first_end));
|
||||
xml_element.setAttribute("length1", QString("%1").arg(first_length));
|
||||
xml_element.setAttribute("end2", Qet::endTypeToString(second_end));
|
||||
xml_element.setAttribute("length2", QString("%1").arg(second_length));
|
||||
|
||||
stylesToXml(xml_element);
|
||||
stylesToXml(xml_element);
|
||||
return(xml_element);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -131,48 +134,17 @@ void PartLine::toXmlPriv(QDomElement& xml_element) const
|
||||
Import the properties of this line from a xml element.
|
||||
@param qde : Xml document to use
|
||||
*/
|
||||
bool PartLine::fromXmlPriv(const QDomElement &qde) {
|
||||
void PartLine::fromXml(const QDomElement &qde) {
|
||||
stylesFromXml(qde);
|
||||
m_line = QLineF(mapFromScene(qde.attribute("x1", "0").toDouble(),
|
||||
qde.attribute("y1", "0").toDouble()),
|
||||
mapFromScene(qde.attribute("x2", "0").toDouble(),
|
||||
qde.attribute("y2", "0").toDouble()));
|
||||
|
||||
double x1 = 0, y1 = 0, x2 = 0, y2 = 0;
|
||||
if (QETXML::propertyDouble(qde, "x1", &x1) == QETXML::PropertyFlags::NoValidConversion ||
|
||||
QETXML::propertyDouble(qde, "y1", &y1) == QETXML::PropertyFlags::NoValidConversion ||
|
||||
QETXML::propertyDouble(qde, "x2", &x2) == QETXML::PropertyFlags::NoValidConversion ||
|
||||
QETXML::propertyDouble(qde, "y2", &y2) == QETXML::PropertyFlags::NoValidConversion)
|
||||
return false;
|
||||
|
||||
m_line = QLineF(mapFromScene(x1, y1),
|
||||
mapFromScene(x2, y2));
|
||||
|
||||
QString s;
|
||||
if (QETXML::propertyString(qde, "end1", &s) != QETXML::PropertyFlags::Success)
|
||||
return false;
|
||||
first_end = Qet::endTypeFromString(s);
|
||||
|
||||
if (QETXML::propertyString(qde, "end2", &s) != QETXML::PropertyFlags::Success)
|
||||
return false;
|
||||
|
||||
first_end = Qet::endTypeFromString(s);
|
||||
|
||||
if (QETXML::propertyDouble(qde, "length1", &first_length) == QETXML::PropertyFlags::NoValidConversion ||
|
||||
QETXML::propertyDouble(qde, "length2", &second_length) == QETXML::PropertyFlags::NoValidConversion)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PartLine::valideXml(QDomElement& element) const {
|
||||
if (QETXML::propertyDouble(element, "x1") ||
|
||||
QETXML::propertyDouble(element, "y1") ||
|
||||
QETXML::propertyDouble(element, "x2") ||
|
||||
QETXML::propertyDouble(element, "y2") ||
|
||||
QETXML::propertyString(element, "end1") ||
|
||||
QETXML::propertyString(element, "end2") ||
|
||||
QETXML::propertyDouble(element, "length1") ||
|
||||
QETXML::propertyDouble(element, "length2") )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
first_end = Qet::endTypeFromString(qde.attribute("end1"));
|
||||
first_length = qde.attribute("length1", "1.5").toDouble();
|
||||
second_end = Qet::endTypeFromString(qde.attribute("end2"));
|
||||
second_length = qde.attribute("length2", "1.5").toDouble();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -70,11 +70,8 @@ class PartLine : public CustomElementGraphicPart
|
||||
void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget * = nullptr) override;
|
||||
QString name() const override { return(QObject::tr("ligne", "element part name")); }
|
||||
QString xmlName() const override { return(QString("line")); }
|
||||
void toXmlPriv(QDomElement&xml_element) const override;
|
||||
bool fromXmlPriv(const QDomElement &) override;
|
||||
bool valideXml(QDomElement& element) const;
|
||||
void toSettings(QSettings &,const QString & = QString()) const override {/*TODO: implement*/}
|
||||
void fromSettings(QSettings &,const QString & = QString()) override{/*TODO: implement*/}
|
||||
const QDomElement toXml(QDomDocument &) const override;
|
||||
void fromXml(const QDomElement &) override;
|
||||
virtual QPointF sceneP1() const;
|
||||
virtual QPointF sceneP2() const;
|
||||
QPainterPath shape() const override;
|
||||
@@ -105,7 +102,7 @@ class PartLine : public CustomElementGraphicPart
|
||||
private:
|
||||
void adjusteHandlerPos();
|
||||
void handlerMousePressEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
|
||||
void handlerMouseMoveEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
|
||||
void handlerMouseMoveEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
|
||||
void handlerMouseReleaseEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
|
||||
void sceneSelectionChanged ();
|
||||
|
||||
@@ -117,15 +114,15 @@ class PartLine : public CustomElementGraphicPart
|
||||
QRectF secondEndCircleRect() const;
|
||||
|
||||
/*****************/
|
||||
Qet::EndType first_end{Qet::EndType::None};
|
||||
qreal first_length{1.5};
|
||||
Qet::EndType first_end;
|
||||
qreal first_length;
|
||||
|
||||
Qet::EndType second_end{Qet::EndType::None};
|
||||
qreal second_length{1.5};
|
||||
Qet::EndType second_end;
|
||||
qreal second_length;
|
||||
QList<QPointF> saved_points_;
|
||||
QLineF m_line;
|
||||
int m_vector_index = -1;
|
||||
QPropertyUndoCommand *m_undo_command{nullptr};
|
||||
QPropertyUndoCommand *m_undo_command;
|
||||
QVector<QetGraphicsHandlerItem *> m_handler_vector;
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -24,8 +24,6 @@
|
||||
#include "../elementscene.h"
|
||||
#include "../ui/qetelementeditor.h"
|
||||
|
||||
#include "../../qetxml.h"
|
||||
|
||||
/**
|
||||
@brief PartPolygon::PartPolygon
|
||||
Constructor
|
||||
@@ -37,7 +35,6 @@ PartPolygon::PartPolygon(QETElementEditor *editor, QGraphicsItem *parent) :
|
||||
m_closed(false),
|
||||
m_undo_command(nullptr)
|
||||
{
|
||||
setTagName("polygon");
|
||||
m_insert_point = new QAction(tr("Ajouter un point"), this);
|
||||
m_insert_point->setIcon(QET::Icons::Add);
|
||||
connect(m_insert_point, &QAction::triggered, this, &PartPolygon::insertPoint);
|
||||
@@ -92,60 +89,50 @@ void PartPolygon::paint(QPainter *painter, const QStyleOptionGraphicsItem *optio
|
||||
Import the properties of this polygon from a xml element
|
||||
@param qde : Xml document to use
|
||||
*/
|
||||
bool PartPolygon::fromXmlPriv(const QDomElement &qde)
|
||||
void PartPolygon::fromXml(const QDomElement &qde)
|
||||
{
|
||||
stylesFromXml(qde);
|
||||
|
||||
int error_counter = 0;
|
||||
int i = 1;
|
||||
while(true)
|
||||
{
|
||||
if (QETXML::propertyDouble(qde, QString("x%1").arg(i)) == QETXML::PropertyFlags::Success &&
|
||||
QETXML::propertyDouble(qde, QString("y%1").arg(i)) == QETXML::PropertyFlags::Success)
|
||||
i++;
|
||||
if (QET::attributeIsAReal(qde, QString("x%1").arg(i)) &&\
|
||||
QET::attributeIsAReal(qde, QString("y%1").arg(i)))
|
||||
++ i;
|
||||
|
||||
else break;
|
||||
}
|
||||
|
||||
QPolygonF temp_polygon;
|
||||
double x, y;
|
||||
for (int j = 1 ; j < i ; ++ j)
|
||||
{
|
||||
error_counter += QETXML::propertyDouble(qde, QString("x%1").arg(j), &x);
|
||||
error_counter += QETXML::propertyDouble(qde, QString("y%1").arg(j), &y);
|
||||
if (error_counter)
|
||||
return false;
|
||||
temp_polygon << QPointF(x, y);
|
||||
temp_polygon << QPointF(qde.attribute(QString("x%1").arg(j)).toDouble(),
|
||||
qde.attribute(QString("y%1").arg(j)).toDouble());
|
||||
}
|
||||
m_polygon = temp_polygon;
|
||||
|
||||
if (QETXML::propertyBool(qde, "closed", &m_closed) != QETXML::PropertyFlags::Success)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
m_closed = qde.attribute("closed") != "false";
|
||||
}
|
||||
|
||||
/**
|
||||
@brief PartPolygon::toXmlPriv
|
||||
@brief PartPolygon::toXml
|
||||
Export this polygin in xml
|
||||
@param e: properties get part of this DomElement
|
||||
@param xml_document : Xml document to use for create the xml element
|
||||
@return an xml element that describe this polygon
|
||||
*/
|
||||
void PartPolygon::toXmlPriv(QDomElement& xml_element) const
|
||||
const QDomElement PartPolygon::toXml(QDomDocument &xml_document) const
|
||||
{
|
||||
int i = 1;
|
||||
foreach(QPointF point, m_polygon) {
|
||||
point = mapToScene(point);
|
||||
xml_element.setAttribute(QString("x%1").arg(i), QString("%1").arg(point.x()));
|
||||
xml_element.setAttribute(QString("y%1").arg(i), QString("%1").arg(point.y()));
|
||||
++ i;
|
||||
}
|
||||
if (!m_closed) xml_element.setAttribute("closed", "false");
|
||||
stylesToXml(xml_element);
|
||||
}
|
||||
|
||||
bool PartPolygon::valideXml(QDomElement& element) {
|
||||
// TODO: implement
|
||||
return true;
|
||||
QDomElement xml_element = xml_document.createElement("polygon");
|
||||
int i = 1;
|
||||
foreach(QPointF point, m_polygon) {
|
||||
point = mapToScene(point);
|
||||
xml_element.setAttribute(QString("x%1").arg(i), QString("%1").arg(point.x()));
|
||||
xml_element.setAttribute(QString("y%1").arg(i), QString("%1").arg(point.y()));
|
||||
++ i;
|
||||
}
|
||||
if (!m_closed) xml_element.setAttribute("closed", "false");
|
||||
stylesToXml(xml_element);
|
||||
return(xml_element);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -538,7 +525,7 @@ void PartPolygon::insertPoint()
|
||||
if(new_polygon != m_polygon)
|
||||
{
|
||||
//Wrap the undo for avoid to merge the undo commands when user add several points.
|
||||
QUndoCommand *undo = new QUndoCommand(tr("Ajouter un point ?? un polygone"));
|
||||
QUndoCommand *undo = new QUndoCommand(tr("Ajouter un point à un polygone"));
|
||||
new QPropertyUndoCommand(this, "polygon", m_polygon, new_polygon, undo);
|
||||
elementScene()->undoStack().push(undo);
|
||||
}
|
||||
|
||||
@@ -61,12 +61,8 @@ class PartPolygon : public CustomElementGraphicPart
|
||||
|
||||
QString name() const override { return(QObject::tr("polygone", "element part name")); }
|
||||
QString xmlName() const override { return(QString("polygon")); }
|
||||
bool fromXmlPriv(const QDomElement &) override;
|
||||
void toXmlPriv(QDomElement&xml_element) const override;
|
||||
static bool valideXml(QDomElement& element);
|
||||
void toSettings(QSettings &,const QString & = QString()) const override {/*TODO: implement*/}
|
||||
void fromSettings(QSettings &,const QString & = QString()) override{/*TODO: implement*/}
|
||||
|
||||
void fromXml(const QDomElement &) override;
|
||||
const QDomElement toXml(QDomDocument &) const override;
|
||||
|
||||
QPainterPath shape () const override;
|
||||
QPainterPath shadowShape() const override;
|
||||
@@ -81,8 +77,8 @@ class PartPolygon : public CustomElementGraphicPart
|
||||
QPolygonF polygon () const;
|
||||
void setPolygon (const QPolygonF &polygon);
|
||||
|
||||
void addPoint (const QPointF &point);
|
||||
void setLastPoint (const QPointF &point);
|
||||
void addPoint (const QPointF &point);
|
||||
void setLastPoint (const QPointF &point);
|
||||
void removeLastPoint ();
|
||||
|
||||
bool isClosed () const {return m_closed;}
|
||||
@@ -99,7 +95,7 @@ class PartPolygon : public CustomElementGraphicPart
|
||||
private:
|
||||
void adjusteHandlerPos();
|
||||
void handlerMousePressEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
|
||||
void handlerMouseMoveEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
|
||||
void handlerMouseMoveEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
|
||||
void handlerMouseReleaseEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
|
||||
void sceneSelectionChanged ();
|
||||
|
||||
@@ -109,7 +105,7 @@ class PartPolygon : public CustomElementGraphicPart
|
||||
void removePoint();
|
||||
|
||||
|
||||
bool m_closed{false};
|
||||
bool m_closed;
|
||||
QList<QPointF> saved_points_;
|
||||
QPolygonF m_polygon;
|
||||
QPropertyUndoCommand *m_undo_command;
|
||||
|
||||
@@ -22,8 +22,6 @@
|
||||
#include "../../QetGraphicsItemModeler/qetgraphicshandlerutility.h"
|
||||
#include "../elementscene.h"
|
||||
|
||||
#include "../../qetxml.h"
|
||||
|
||||
/**
|
||||
@brief PartRectangle::PartRectangle
|
||||
Constructor
|
||||
@@ -32,9 +30,7 @@
|
||||
*/
|
||||
PartRectangle::PartRectangle(QETElementEditor *editor, QGraphicsItem *parent) :
|
||||
CustomElementGraphicPart(editor, parent)
|
||||
{
|
||||
setTagName("rect");
|
||||
}
|
||||
{}
|
||||
|
||||
/**
|
||||
@brief PartRectangle::~PartRectangle
|
||||
@@ -84,33 +80,35 @@ void PartRectangle::paint(QPainter *painter, const QStyleOptionGraphicsItem *opt
|
||||
}
|
||||
|
||||
/**
|
||||
@brief PartRectangle::toXmlPriv
|
||||
@brief PartRectangle::toXml
|
||||
Export this rectangle in xml
|
||||
@param xml_document : Xml document to use for create the xml element.
|
||||
@return an xml element that describe this ellipse
|
||||
*/
|
||||
void PartRectangle::toXmlPriv(QDomElement& xml_element) const
|
||||
const QDomElement PartRectangle::toXml(QDomDocument &xml_document) const
|
||||
{
|
||||
QPointF top_left(sceneTopLeft());
|
||||
xml_element.setAttribute("x", QString("%1").arg(top_left.x()));
|
||||
xml_element.setAttribute("y", QString("%1").arg(top_left.y()));
|
||||
xml_element.setAttribute("width", QString("%1").arg(m_rect.width()));
|
||||
xml_element.setAttribute("height", QString("%1").arg(m_rect.height()));
|
||||
QDomElement xml_element = xml_document.createElement("rect");
|
||||
QPointF top_left(sceneTopLeft());
|
||||
xml_element.setAttribute("x", QString("%1").arg(top_left.x()));
|
||||
xml_element.setAttribute("y", QString("%1").arg(top_left.y()));
|
||||
xml_element.setAttribute("width", QString("%1").arg(m_rect.width()));
|
||||
xml_element.setAttribute("height", QString("%1").arg(m_rect.height()));
|
||||
|
||||
QRectF rect = m_rect.normalized();
|
||||
qreal x = m_xRadius;
|
||||
if (x > rect.width()/2) {
|
||||
x = rect.width()/2;
|
||||
}
|
||||
qreal y = m_yRadius;
|
||||
if (y > rect.height()/2) {
|
||||
y = rect.height()/2;
|
||||
}
|
||||
QRectF rect = m_rect.normalized();
|
||||
qreal x = m_xRadius;
|
||||
if (x > rect.width()/2) {
|
||||
x = rect.width()/2;
|
||||
}
|
||||
qreal y = m_yRadius;
|
||||
if (y > rect.height()/2) {
|
||||
y = rect.height()/2;
|
||||
}
|
||||
|
||||
xml_element.setAttribute("rx", QString::number(m_xRadius));
|
||||
xml_element.setAttribute("ry", QString::number(m_yRadius));
|
||||
xml_element.setAttribute("rx", QString::number(m_xRadius));
|
||||
xml_element.setAttribute("ry", QString::number(m_yRadius));
|
||||
|
||||
stylesToXml(xml_element);
|
||||
stylesToXml(xml_element);
|
||||
return(xml_element);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -118,45 +116,18 @@ void PartRectangle::toXmlPriv(QDomElement& xml_element) const
|
||||
Import the properties of this rectangle from a xml element.
|
||||
@param qde : Xml document to use.
|
||||
*/
|
||||
bool PartRectangle::fromXmlPriv(const QDomElement &qde)
|
||||
void PartRectangle::fromXml(const QDomElement &qde)
|
||||
{
|
||||
stylesFromXml(qde);
|
||||
setPos(mapFromScene(qde.attribute("x", "0").toDouble(),
|
||||
qde.attribute("y", "0").toDouble()));
|
||||
|
||||
double x=0, y=0, w=0, h=0, rx=0, ry=0;
|
||||
if (QETXML::propertyDouble(qde, "x", &x) == QETXML::PropertyFlags::NoValidConversion ||
|
||||
QETXML::propertyDouble(qde, "y", &y) == QETXML::PropertyFlags::NoValidConversion)
|
||||
return false;
|
||||
|
||||
setPos(mapFromScene(x, y));
|
||||
|
||||
if (QETXML::propertyDouble(qde, "width", &w) == QETXML::PropertyFlags::NoValidConversion ||
|
||||
QETXML::propertyDouble(qde, "height", &h) == QETXML::PropertyFlags::NoValidConversion)
|
||||
return false;
|
||||
|
||||
QRectF rect(QPointF(0,0), QSizeF(w, h));
|
||||
QRectF rect(QPointF(0,0), QSizeF(qde.attribute("width", "0").toDouble(),
|
||||
qde.attribute("height", "0").toDouble()));
|
||||
|
||||
setRect(rect.normalized());
|
||||
|
||||
if (QETXML::propertyDouble(qde, "rx", &rx) == QETXML::PropertyFlags::NoValidConversion ||
|
||||
QETXML::propertyDouble(qde, "ry", &ry) == QETXML::PropertyFlags::NoValidConversion)
|
||||
return false;
|
||||
|
||||
setXRadius(rx);
|
||||
setYRadius(ry);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PartRectangle::valideXml(QDomElement& element) {
|
||||
// parameters have default values so no value is not a non valid xml element
|
||||
if ((QETXML::propertyDouble(element, "x") & QETXML::PropertyFlags::NoValidConversion) |
|
||||
(QETXML::propertyDouble(element, "y") & QETXML::PropertyFlags::NoValidConversion) |
|
||||
(QETXML::propertyDouble(element, "width") & QETXML::PropertyFlags::NoValidConversion) |
|
||||
(QETXML::propertyDouble(element, "height") & QETXML::PropertyFlags::NoValidConversion) |
|
||||
(QETXML::propertyDouble(element, "rx") & QETXML::PropertyFlags::NoValidConversion) |
|
||||
(QETXML::propertyDouble(element, "ry") & QETXML::PropertyFlags::NoValidConversion))
|
||||
return false;
|
||||
return true;
|
||||
setXRadius(qde.attribute("rx", "0").toDouble());
|
||||
setYRadius(qde.attribute("ry", "0").toDouble());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -566,9 +537,9 @@ void PartRectangle::addHandler()
|
||||
for (QetGraphicsHandlerItem *handler : m_handler_vector)
|
||||
{
|
||||
QColor color;
|
||||
if(m_resize_mode == 1) {color = Qt::blue;}
|
||||
if(m_resize_mode == 1) {color = Qt::blue;}
|
||||
else if (m_resize_mode == 2) {color = Qt::darkGreen;}
|
||||
else {color = Qt::magenta;}
|
||||
else {color = Qt::magenta;}
|
||||
|
||||
handler->setColor(color);
|
||||
scene()->addItem(handler);
|
||||
|
||||
@@ -55,16 +55,13 @@ class PartRectangle : public CustomElementGraphicPart
|
||||
Enable the use of qgraphicsitem_cast to safely cast a QGraphicsItem into a PartRectangle.
|
||||
@return the QGraphicsItem type
|
||||
*/
|
||||
int type () const override { return Type; }
|
||||
void paint (QPainter *, const QStyleOptionGraphicsItem *, QWidget * = nullptr) override;
|
||||
int type () const override { return Type; }
|
||||
void paint (QPainter *, const QStyleOptionGraphicsItem *, QWidget * = nullptr) override;
|
||||
QString name () const override { return(QObject::tr("rectangle", "element part name")); }
|
||||
|
||||
QString xmlName () const override { return(QString("rect")); }
|
||||
void toXmlPriv(QDomElement&xml_element) const override;
|
||||
bool fromXmlPriv (const QDomElement &) override;
|
||||
static bool valideXml(QDomElement& element);
|
||||
void toSettings(QSettings &,const QString & = QString()) const override {/*TODO: implement*/}
|
||||
void fromSettings(QSettings &,const QString & = QString()) override{/*TODO: implement*/}
|
||||
QString xmlName () const override { return(QString("rect")); }
|
||||
const QDomElement toXml (QDomDocument &) const override;
|
||||
void fromXml (const QDomElement &) override;
|
||||
|
||||
QRectF rect() const;
|
||||
void setRect(const QRectF &rect);
|
||||
@@ -93,7 +90,7 @@ class PartRectangle : public CustomElementGraphicPart
|
||||
void switchResizeMode();
|
||||
void adjusteHandlerPos();
|
||||
void handlerMousePressEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
|
||||
void handlerMouseMoveEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
|
||||
void handlerMouseMoveEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
|
||||
void handlerMouseReleaseEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
|
||||
void sceneSelectionChanged ();
|
||||
|
||||
|
||||
@@ -19,8 +19,6 @@
|
||||
|
||||
#include "../../qetgraphicsitem/terminal.h"
|
||||
|
||||
#include "../../qetxml.h"
|
||||
|
||||
/**
|
||||
@brief PartTerminal::PartTerminal
|
||||
@param editor :
|
||||
@@ -31,9 +29,7 @@
|
||||
PartTerminal::PartTerminal(QETElementEditor *editor, QGraphicsItem *parent) :
|
||||
CustomElementGraphicPart(editor, parent)
|
||||
{
|
||||
setTagName("terminal");
|
||||
d = new TerminalData(this);
|
||||
d->m_name = tr("terminal");
|
||||
d -> m_orientation = Qet::North;
|
||||
d -> m_uuid = QUuid::createUuid(); // if part is loaded this uuid will be overwritten, but being sure that terminal has a uuid
|
||||
updateSecondPoint();
|
||||
@@ -49,20 +45,10 @@ PartTerminal::~PartTerminal()
|
||||
Importe les proprietes d'une borne depuis un element XML
|
||||
@param xml_elmt Element XML a lire
|
||||
*/
|
||||
bool PartTerminal::fromXmlPriv(const QDomElement &xml_elmt) {
|
||||
|
||||
// update part and add uuid, which is used in the new version to connect terminals together
|
||||
// if the attribute not exists, means, the element is created with an older version of qet. So use the legacy approach
|
||||
// to identify terminals
|
||||
QETXML::propertyUuid(xml_elmt, "uuid", &d->m_uuid);
|
||||
|
||||
if (!d->fromXml(xml_elmt))
|
||||
return false;
|
||||
|
||||
void PartTerminal::fromXml(const QDomElement &xml_elmt) {
|
||||
d -> fromXml(xml_elmt);
|
||||
setPos(d -> m_pos);
|
||||
updateSecondPoint();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -70,19 +56,9 @@ bool PartTerminal::fromXmlPriv(const QDomElement &xml_elmt) {
|
||||
@param xml_document Document XML a utiliser pour creer l'element XML
|
||||
@return un element XML decrivant la borne
|
||||
*/
|
||||
void PartTerminal::toXmlPriv(QDomElement& e) const {
|
||||
|
||||
e.setAttribute("uuid", d->m_uuid.toString());
|
||||
|
||||
d->m_pos = pos();
|
||||
|
||||
QDomDocument doc = e.ownerDocument();
|
||||
e.appendChild(d -> toXml(doc));
|
||||
|
||||
}
|
||||
|
||||
bool PartTerminal::valideXml(QDomElement& element) {
|
||||
return TerminalData::valideXml(element);
|
||||
const QDomElement PartTerminal::toXml(QDomDocument &xml_document) const
|
||||
{
|
||||
return d -> toXml(xml_document);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -100,8 +76,8 @@ void PartTerminal::paint(
|
||||
painter -> save();
|
||||
|
||||
// annulation des renderhints
|
||||
painter -> setRenderHint(QPainter::Antialiasing, false);
|
||||
painter -> setRenderHint(QPainter::TextAntialiasing, false);
|
||||
painter -> setRenderHint(QPainter::Antialiasing, false);
|
||||
painter -> setRenderHint(QPainter::TextAntialiasing, false);
|
||||
painter -> setRenderHint(QPainter::SmoothPixmapTransform, false);
|
||||
|
||||
QPen t;
|
||||
@@ -247,7 +223,7 @@ QRectF PartTerminal::sceneGeometricRect() const
|
||||
*/
|
||||
void PartTerminal::startUserTransformation(const QRectF &initial_selection_rect) {
|
||||
Q_UNUSED(initial_selection_rect)
|
||||
m_saved_position = scenePos();
|
||||
saved_position_ = scenePos();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -255,6 +231,6 @@ void PartTerminal::startUserTransformation(const QRectF &initial_selection_rect)
|
||||
*/
|
||||
void PartTerminal::handleUserTransformation(const QRectF &initial_selection_rect, const QRectF &new_selection_rect) {
|
||||
QPointF mapped_point = mapPoints(
|
||||
initial_selection_rect, new_selection_rect, QList<QPointF>() << m_saved_position).first();
|
||||
initial_selection_rect, new_selection_rect, QList<QPointF>() << saved_position_).first();
|
||||
setPos(mapped_point);
|
||||
}
|
||||
|
||||
@@ -56,12 +56,9 @@ class PartTerminal : public CustomElementGraphicPart
|
||||
*/
|
||||
int type() const override { return Type; }
|
||||
QString xmlName() const override { return(QString("terminal")); }
|
||||
bool fromXmlPriv(const QDomElement &) override;
|
||||
void toXmlPriv(QDomElement&xml_element) const override;
|
||||
static bool valideXml(QDomElement& element);
|
||||
void toSettings(QSettings &,const QString & = QString()) const override {/*TODO: implement*/}
|
||||
void fromSettings(QSettings &,const QString & = QString()) override{/*TODO: implement*/}
|
||||
void paint(
|
||||
void fromXml(const QDomElement &) override;
|
||||
const QDomElement toXml(QDomDocument &) const override;
|
||||
void paint(
|
||||
QPainter *painter,
|
||||
const QStyleOptionGraphicsItem *,
|
||||
QWidget *) override;
|
||||
@@ -87,9 +84,9 @@ class PartTerminal : public CustomElementGraphicPart
|
||||
|
||||
private:
|
||||
void updateSecondPoint();
|
||||
TerminalData* d{nullptr}; // pointer to the terminal data
|
||||
TerminalData* d; // pointer to the terminal data
|
||||
|
||||
private:
|
||||
QPointF m_saved_position;
|
||||
QPointF saved_position_;
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -23,8 +23,6 @@
|
||||
#include "../elementscene.h"
|
||||
#include "../ui/texteditor.h"
|
||||
|
||||
#include "../../qetxml.h"
|
||||
|
||||
/**
|
||||
Constructeur
|
||||
@param editor L'editeur d'element concerne
|
||||
@@ -45,8 +43,8 @@ PartText::PartText(QETElementEditor *editor, QGraphicsItem *parent) :
|
||||
setAcceptHoverEvents(true);
|
||||
setDefaultTextColor(Qt::black);
|
||||
setPlainText(QObject::tr(
|
||||
"T",
|
||||
"default text when adding a text in the element editor"));
|
||||
"T",
|
||||
"default text when adding a text in the element editor"));
|
||||
|
||||
adjustItemPosition(1);
|
||||
// adjust textfield position after line additions/deletions
|
||||
@@ -69,49 +67,29 @@ PartText::~PartText()
|
||||
Importe les proprietes d'un texte statique depuis un element XML
|
||||
@param xml_element Element XML a lire
|
||||
*/
|
||||
bool PartText::fromXmlPriv(const QDomElement &xml_element)
|
||||
{
|
||||
int size;
|
||||
QString font;
|
||||
void PartText::fromXml(const QDomElement &xml_element) {
|
||||
bool ok;
|
||||
|
||||
if (QETXML::propertyInteger(xml_element, "size", &size) != QETXML::PropertyFlags::NotFound)
|
||||
{
|
||||
if (size < 1) {
|
||||
size = 20;
|
||||
if (xml_element.hasAttribute("size")) {
|
||||
int font_size = xml_element.attribute("size").toInt(&ok);
|
||||
if (!ok || font_size < 1) {
|
||||
font_size = 20;
|
||||
}
|
||||
QFont font_ = this -> font();
|
||||
font_.setPointSize(size);
|
||||
font_.setPointSize(font_size);
|
||||
setFont(font_);
|
||||
}
|
||||
else if (QETXML::propertyString(xml_element, "font", &font) != QETXML::PropertyFlags::NotFound)
|
||||
{
|
||||
else if (xml_element.hasAttribute("font")) {
|
||||
QFont font_;
|
||||
font_.fromString(font);
|
||||
font_.fromString(xml_element.attribute("font"));
|
||||
setFont(font_);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
QColor color;
|
||||
QString text;
|
||||
QETXML::propertyColor(xml_element, "color", &color);
|
||||
setDefaultTextColor(color);
|
||||
|
||||
|
||||
QETXML::propertyString(xml_element, "text", &text);
|
||||
setPlainText(text);
|
||||
|
||||
double x=0, y=0, rot=0;
|
||||
if (QETXML::propertyDouble(xml_element, "x", &x) == QETXML::PropertyFlags::NoValidConversion ||
|
||||
QETXML::propertyDouble(xml_element, "y", &y) == QETXML::PropertyFlags::NoValidConversion)
|
||||
return false;
|
||||
setPos(x, y);
|
||||
|
||||
if (QETXML::propertyDouble(xml_element, "rotation", &rot) == QETXML::PropertyFlags::NoValidConversion)
|
||||
return false;
|
||||
setRotation(rot);
|
||||
|
||||
return true;
|
||||
setDefaultTextColor(QColor(xml_element.attribute("color", "#000000")));
|
||||
setPlainText(xml_element.attribute("text"));
|
||||
setPos(xml_element.attribute("x").toDouble(),
|
||||
xml_element.attribute("y").toDouble());
|
||||
setRotation(xml_element.attribute("rotation", QString::number(0)).toDouble());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -119,38 +97,18 @@ bool PartText::fromXmlPriv(const QDomElement &xml_element)
|
||||
@param xml_document Document XML a utiliser pour creer l'element XML
|
||||
@return un element XML decrivant le texte statique
|
||||
*/
|
||||
void PartText::toXmlPriv(QDomElement& xml_element) const
|
||||
const QDomElement PartText::toXml(QDomDocument &xml_document) const
|
||||
{
|
||||
xml_element.setAttribute("x", QString::number(pos().x()));
|
||||
xml_element.setAttribute("y", QString::number(pos().y()));
|
||||
xml_element.setAttribute("text", toPlainText());
|
||||
xml_element.setAttribute("font", font().toString());
|
||||
xml_element.setAttribute("rotation", QString::number(rotation()));
|
||||
xml_element.setAttribute("color", defaultTextColor().name());
|
||||
}
|
||||
QDomElement xml_element = xml_document.createElement(xmlName());
|
||||
|
||||
bool PartText::valideXml(QDomElement& element) {
|
||||
xml_element.setAttribute("x", QString::number(pos().x()));
|
||||
xml_element.setAttribute("y", QString::number(pos().y()));
|
||||
xml_element.setAttribute("text", toPlainText());
|
||||
xml_element.setAttribute("font", font().toString());
|
||||
xml_element.setAttribute("rotation", QString::number(rotation()));
|
||||
xml_element.setAttribute("color", defaultTextColor().name());
|
||||
|
||||
if (QETXML::propertyInteger(element, "size") == QETXML::PropertyFlags::NotFound ||
|
||||
QETXML::propertyString(element, "font") == QETXML::PropertyFlags::NotFound) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (QETXML::propertyString(element, "color") == QETXML::PropertyFlags::NoValidConversion)
|
||||
return false;
|
||||
|
||||
|
||||
if (QETXML::propertyString(element, "text"))
|
||||
return false;
|
||||
|
||||
if (QETXML::propertyDouble(element, "x") == QETXML::PropertyFlags::NoValidConversion ||
|
||||
QETXML::propertyDouble(element, "y") == QETXML::PropertyFlags::NoValidConversion)
|
||||
return false;
|
||||
|
||||
if (QETXML::propertyDouble(element, "rotation", 0) == QETXML::PropertyFlags::NoValidConversion)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
return(xml_element);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -59,11 +59,8 @@ class PartText : public QGraphicsTextItem, public CustomElementPart {
|
||||
int type() const override { return Type; }
|
||||
QString name() const override { return(QObject::tr("texte", "element part name")); }
|
||||
QString xmlName() const override { return(QString("text")); }
|
||||
bool fromXmlPriv(const QDomElement &) override;
|
||||
static bool valideXml(QDomElement& element);
|
||||
void toSettings(QSettings &,const QString & = QString()) const override {/*TODO: implement*/}
|
||||
void fromSettings(QSettings &,const QString & = QString()) override{/*TODO: implement*/}
|
||||
void toXmlPriv(QDomElement&xml_element) const override;
|
||||
void fromXml(const QDomElement &) override;
|
||||
const QDomElement toXml(QDomDocument &) const override;
|
||||
void setRotation(qreal angle) {(QGraphicsObject::setRotation(QET::correctAngle(angle)));}
|
||||
bool isUseless() const override;
|
||||
QRectF sceneGeometricRect() const override;
|
||||
|
||||
@@ -440,10 +440,10 @@ void StyleEditor::updatePartFilling()
|
||||
}
|
||||
|
||||
/**
|
||||
@brief StyleEditor::updateFormPriv
|
||||
@brief StyleEditor::updateForm
|
||||
Update the edition form according to the value of edited part(s)
|
||||
*/
|
||||
void StyleEditor::updateFormPriv()
|
||||
void StyleEditor::updateForm()
|
||||
{
|
||||
if (!part && m_part_list.isEmpty()) return;
|
||||
activeConnections(false);
|
||||
|
||||
@@ -60,7 +60,7 @@ class StyleEditor : public ElementItemEditor
|
||||
static bool isStyleEditable (QList <CustomElementPart *> cep_list);
|
||||
|
||||
public slots:
|
||||
void updateFormPriv() override;
|
||||
void updateForm() override;
|
||||
void updatePartAntialiasing();
|
||||
void updatePartColor();
|
||||
void updatePartLineStyle();
|
||||
|
||||
@@ -51,8 +51,8 @@ DynamicTextFieldEditor::DynamicTextFieldEditor(QETElementEditor *editor,
|
||||
DynamicTextFieldEditor::~DynamicTextFieldEditor()
|
||||
{
|
||||
delete ui;
|
||||
if(!m_change_connections.isEmpty()) {
|
||||
for(const QMetaObject::Connection& con : m_change_connections) {
|
||||
if(!m_connection_list.isEmpty()) {
|
||||
for(const QMetaObject::Connection& con : m_connection_list) {
|
||||
disconnect(con);
|
||||
}
|
||||
}
|
||||
@@ -130,7 +130,7 @@ QList<CustomElementPart*> DynamicTextFieldEditor::currentParts() const
|
||||
return parts;
|
||||
}
|
||||
|
||||
void DynamicTextFieldEditor::updateFormPriv()
|
||||
void DynamicTextFieldEditor::updateForm()
|
||||
{
|
||||
if(m_text_field) {
|
||||
ui -> m_x_sb -> setValue(m_text_field.data() -> x());
|
||||
@@ -182,38 +182,38 @@ void DynamicTextFieldEditor::setupWidget()
|
||||
|
||||
void DynamicTextFieldEditor::setUpConnections()
|
||||
{
|
||||
assert(m_change_connections.isEmpty());
|
||||
assert(m_connection_list.isEmpty());
|
||||
//Setup the connection
|
||||
m_change_connections << connect(m_text_field.data(), &PartDynamicTextField::colorChanged,
|
||||
m_connection_list << connect(m_text_field.data(), &PartDynamicTextField::colorChanged,
|
||||
[this](){this -> updateForm();});
|
||||
m_change_connections << connect(m_text_field.data(), &PartDynamicTextField::fontChanged,
|
||||
m_connection_list << connect(m_text_field.data(), &PartDynamicTextField::fontChanged,
|
||||
[this](){this -> updateForm();});
|
||||
m_change_connections << connect(m_text_field.data(), &PartDynamicTextField::taggChanged,
|
||||
m_connection_list << connect(m_text_field.data(), &PartDynamicTextField::taggChanged,
|
||||
[this](){this -> updateForm();});
|
||||
m_change_connections << connect(m_text_field.data(), &PartDynamicTextField::textFromChanged,
|
||||
m_connection_list << connect(m_text_field.data(), &PartDynamicTextField::textFromChanged,
|
||||
[this](){this -> updateForm();});
|
||||
m_change_connections << connect(m_text_field.data(), &PartDynamicTextField::textChanged,
|
||||
m_connection_list << connect(m_text_field.data(), &PartDynamicTextField::textChanged,
|
||||
[this](){this -> updateForm();});
|
||||
m_change_connections << connect(m_text_field.data(), &PartDynamicTextField::infoNameChanged,
|
||||
m_connection_list << connect(m_text_field.data(), &PartDynamicTextField::infoNameChanged,
|
||||
[this](){this -> updateForm();});
|
||||
m_change_connections << connect(m_text_field.data(), &PartDynamicTextField::rotationChanged,
|
||||
m_connection_list << connect(m_text_field.data(), &PartDynamicTextField::rotationChanged,
|
||||
[this](){this -> updateForm();});
|
||||
m_change_connections << connect(m_text_field.data(), &PartDynamicTextField::frameChanged,
|
||||
m_connection_list << connect(m_text_field.data(), &PartDynamicTextField::frameChanged,
|
||||
[this](){this -> updateForm();});
|
||||
m_change_connections << connect(m_text_field.data(), &PartDynamicTextField::textWidthChanged,
|
||||
m_connection_list << connect(m_text_field.data(), &PartDynamicTextField::textWidthChanged,
|
||||
[this](){this -> updateForm();});
|
||||
m_change_connections << connect(m_text_field.data(), &PartDynamicTextField::compositeTextChanged,
|
||||
m_connection_list << connect(m_text_field.data(), &PartDynamicTextField::compositeTextChanged,
|
||||
[this](){this -> updateForm();});
|
||||
}
|
||||
|
||||
void DynamicTextFieldEditor::disconnectConnections()
|
||||
{
|
||||
//Remove previous connection
|
||||
if(!m_change_connections.isEmpty())
|
||||
for(const QMetaObject::Connection& con : m_change_connections) {
|
||||
if(!m_connection_list.isEmpty())
|
||||
for(const QMetaObject::Connection& con : m_connection_list) {
|
||||
disconnect(con);
|
||||
}
|
||||
m_change_connections.clear();
|
||||
m_connection_list.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -45,7 +45,7 @@ class DynamicTextFieldEditor : public ElementItemEditor {
|
||||
bool setParts(QList <CustomElementPart *>) override;
|
||||
CustomElementPart *currentPart() const override;
|
||||
QList<CustomElementPart*> currentParts() const override;
|
||||
void updateFormPriv() override;
|
||||
void updateForm() override;
|
||||
|
||||
private:
|
||||
void setupWidget();
|
||||
@@ -73,6 +73,7 @@ class DynamicTextFieldEditor : public ElementItemEditor {
|
||||
Ui::DynamicTextFieldEditor *ui;
|
||||
QPointer<PartDynamicTextField> m_text_field;
|
||||
QList<PartDynamicTextField*> m_parts;
|
||||
QList<QMetaObject::Connection> m_connection_list;
|
||||
|
||||
#ifdef BUILD_WITHOUT_KF5
|
||||
#else
|
||||
|
||||
@@ -110,9 +110,9 @@ QList<CustomElementPart *> EllipseEditor::currentParts() const {
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief EllipseEditor::updateFormPriv
|
||||
* @brief EllipseEditor::updateForm
|
||||
*/
|
||||
void EllipseEditor::updateFormPriv()
|
||||
void EllipseEditor::updateForm()
|
||||
{
|
||||
if (!m_part) {
|
||||
return;
|
||||
|
||||
@@ -43,7 +43,7 @@ class EllipseEditor : public ElementItemEditor
|
||||
bool setParts(QList<CustomElementPart *> parts) override;
|
||||
CustomElementPart *currentPart() const override;
|
||||
QList<CustomElementPart*> currentParts() const override;
|
||||
void updateFormPriv() override;
|
||||
void updateForm() override;
|
||||
|
||||
private slots:
|
||||
void on_m_x_sb_editingFinished();
|
||||
@@ -59,7 +59,8 @@ class EllipseEditor : public ElementItemEditor
|
||||
private:
|
||||
Ui::EllipseEditor *ui;
|
||||
PartEllipse *m_part = nullptr;
|
||||
StyleEditor *m_style = nullptr;
|
||||
StyleEditor *m_style = nullptr;
|
||||
QList <QMetaObject::Connection> m_change_connections;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -176,10 +176,10 @@ QList<CustomElementPart *> LineEditor::currentParts() const {
|
||||
}
|
||||
|
||||
/**
|
||||
@brief LineEditor::updateFormPriv
|
||||
@brief LineEditor::updateForm
|
||||
Reimplemented from ElementItemEditor
|
||||
*/
|
||||
void LineEditor::updateFormPriv()
|
||||
void LineEditor::updateForm()
|
||||
{
|
||||
if (!m_part) {
|
||||
return;
|
||||
|
||||
@@ -43,7 +43,7 @@ class LineEditor : public ElementItemEditor
|
||||
bool setParts(QList <CustomElementPart *> parts) override;
|
||||
CustomElementPart *currentPart() const override;
|
||||
QList<CustomElementPart *> currentParts() const override;
|
||||
void updateFormPriv() override;
|
||||
void updateForm() override;
|
||||
|
||||
private:
|
||||
void setUpChangeConnections();
|
||||
@@ -59,7 +59,8 @@ class LineEditor : public ElementItemEditor
|
||||
private:
|
||||
PartLine *m_part = nullptr;
|
||||
Ui::LineEditor *ui;
|
||||
StyleEditor *m_style = nullptr;
|
||||
StyleEditor *m_style = nullptr;
|
||||
QList <QMetaObject::Connection> m_change_connections;
|
||||
bool m_locked = false;
|
||||
};
|
||||
|
||||
|
||||
@@ -130,10 +130,10 @@ QList<CustomElementPart*> PolygonEditor::currentParts() const
|
||||
}
|
||||
|
||||
/**
|
||||
@brief PolygonEditor::updateFormPriv
|
||||
@brief PolygonEditor::updateForm
|
||||
Update the widget
|
||||
*/
|
||||
void PolygonEditor::updateFormPriv()
|
||||
void PolygonEditor::updateForm()
|
||||
{
|
||||
if (!m_part) {
|
||||
return;
|
||||
|
||||
@@ -39,7 +39,7 @@ class PolygonEditor : public ElementItemEditor
|
||||
bool setPart(CustomElementPart *part) override;
|
||||
CustomElementPart *currentPart() const override;
|
||||
QList<CustomElementPart*> currentParts() const override;
|
||||
void updateFormPriv() override;
|
||||
void updateForm() override;
|
||||
QVector<QPointF> pointsFromTree();
|
||||
bool eventFilter(QObject *watched, QEvent *event) override;
|
||||
|
||||
@@ -63,6 +63,7 @@ class PolygonEditor : public ElementItemEditor
|
||||
Ui::PolygonEditor *ui;
|
||||
StyleEditor *m_style = nullptr;
|
||||
PartPolygon *m_part = nullptr;
|
||||
QList <QMetaObject::Connection> m_change_connections;
|
||||
};
|
||||
|
||||
#endif // POLYGONEDITOR_H
|
||||
|
||||
@@ -136,7 +136,7 @@ QPointF RectangleEditor::editedTopLeft() const
|
||||
/**
|
||||
@brief RectangleEditor::updateForm
|
||||
*/
|
||||
void RectangleEditor::updateFormPriv()
|
||||
void RectangleEditor::updateForm()
|
||||
{
|
||||
if (!m_part) {
|
||||
return;
|
||||
|
||||
@@ -48,7 +48,7 @@ class RectangleEditor : public ElementItemEditor
|
||||
QPointF editedTopLeft () const;
|
||||
|
||||
public slots:
|
||||
void updateFormPriv() override;
|
||||
void updateForm() override;
|
||||
private:
|
||||
void editingFinished();
|
||||
void activeConnections(bool active);
|
||||
@@ -70,6 +70,7 @@ class RectangleEditor : public ElementItemEditor
|
||||
StyleEditor *m_style;
|
||||
PartRectangle *m_part;
|
||||
Ui::RectangleEditor *ui;
|
||||
QList <QMetaObject::Connection> m_change_connections;
|
||||
};
|
||||
|
||||
#endif // RECTANGLEEDITOR_H
|
||||
|
||||
@@ -46,11 +46,11 @@ TerminalEditor::~TerminalEditor()
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief TerminalEditor::updateFormPriv
|
||||
* @brief TerminalEditor::updateForm
|
||||
* Reimplemented from ElementItemEditor
|
||||
* Update the content of this widget
|
||||
*/
|
||||
void TerminalEditor::updateFormPriv()
|
||||
void TerminalEditor::updateForm()
|
||||
{
|
||||
if (!m_part) {
|
||||
return;
|
||||
|
||||
@@ -39,7 +39,7 @@ class TerminalEditor : public ElementItemEditor
|
||||
TerminalEditor(QETElementEditor *editor, QWidget *parent = nullptr);
|
||||
~TerminalEditor() override;
|
||||
|
||||
void updateFormPriv() override;
|
||||
void updateForm() override;
|
||||
bool setPart(CustomElementPart *new_part) override;
|
||||
CustomElementPart *currentPart() const override;
|
||||
QList<CustomElementPart *> currentParts() const override {return QList<CustomElementPart *>();}
|
||||
@@ -55,7 +55,8 @@ class TerminalEditor : public ElementItemEditor
|
||||
|
||||
private:
|
||||
Ui::TerminalEditor *ui;
|
||||
QVector<QMetaObject::Connection> m_editor_connections;
|
||||
QVector<QMetaObject::Connection> m_editor_connections,
|
||||
m_change_connections;
|
||||
PartTerminal *m_part = nullptr;
|
||||
bool m_locked = false;
|
||||
};
|
||||
|
||||
@@ -48,7 +48,7 @@ TextEditor::~TextEditor() {}
|
||||
@brief TextEditor::updateForm
|
||||
Update the gui
|
||||
*/
|
||||
void TextEditor::updateFormPriv()
|
||||
void TextEditor::updateForm()
|
||||
{
|
||||
if (m_text.isNull()) {
|
||||
return;
|
||||
|
||||
@@ -38,7 +38,7 @@ class TextEditor : public ElementItemEditor {
|
||||
explicit TextEditor(QETElementEditor *editor, PartText *text = nullptr, QWidget *parent = nullptr);
|
||||
~TextEditor() override;
|
||||
|
||||
void updateFormPriv() override;
|
||||
void updateForm() override;
|
||||
bool setPart(CustomElementPart *part) override;
|
||||
bool setParts(QList <CustomElementPart *>) override;
|
||||
CustomElementPart *currentPart() const override;
|
||||
|
||||
Reference in New Issue
Block a user