Wrap code for better readability

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

View File

@@ -49,13 +49,24 @@ void NumerotationContext::clear () {
@param initialvalue @param initialvalue
@return true if value is append @return true if value is append
*/ */
bool NumerotationContext::addValue(const QString &type, const QVariant &value, const int increase, const int initialvalue) { bool NumerotationContext::addValue(const QString &type,
if (!keyIsAcceptable(type) && !value.canConvert(QVariant::String)) return false; const QVariant &value,
if (keyIsNumber(type) && !value.canConvert(QVariant::Int)) return false; const int increase,
const int initialvalue) {
if (!keyIsAcceptable(type) && !value.canConvert(QVariant::String))
return false;
if (keyIsNumber(type) && !value.canConvert(QVariant::Int))
return false;
QString valuestr = value.toString(); QString valuestr = value.toString();
valuestr.remove("|"); valuestr.remove("|");
content_ << type + "|" + valuestr + "|" + QString::number(increase) + "|" + QString::number(initialvalue); content_ << type
+ "|"
+ valuestr
+ "|"
+ QString::number(increase)
+ "|"
+ QString::number(initialvalue);
return true; return true;
} }

View File

@@ -33,7 +33,10 @@ class NumerotationContext
NumerotationContext (); NumerotationContext ();
NumerotationContext (QDomElement &); NumerotationContext (QDomElement &);
void clear(); void clear();
bool addValue(const QString &, const QVariant & = QVariant(1), const int = 1, const int = 0); bool addValue(const QString &,
const QVariant & = QVariant(1),
const int = 1,
const int = 0);
QString operator[] (const int &) const; QString operator[] (const int &) const;
void operator << (const NumerotationContext &); void operator << (const NumerotationContext &);
int size() const; int size() const;

View File

@@ -37,10 +37,18 @@ NumPartEditorW::NumPartEditorW(int type, QWidget *parent) :
} }
/** /**
@brief NumPartEditorW::NumPartEditorW
Constructor Constructor
Build with value of @context at position i Build with value of context at position i
@param context
@param i
@param type
@param parent
*/ */
NumPartEditorW::NumPartEditorW (NumerotationContext &context, int i, int type, QWidget *parent): NumPartEditorW::NumPartEditorW (NumerotationContext &context,
int i,
int type,
QWidget *parent):
QWidget(parent), QWidget(parent),
ui(new Ui::NumPartEditorW), ui(new Ui::NumPartEditorW),
intValidator (new QIntValidator(0,99999,this)), intValidator (new QIntValidator(0,99999,this)),
@@ -86,21 +94,40 @@ void NumPartEditorW::setVisibleItems()
QStringList items; QStringList items;
if (m_edited_type == 2) if (m_edited_type == 2)
{ {
items << tr("Chiffre 1") << tr("Chiffre 01") items << tr("Chiffre 1")
<< tr("Chiffre 01")
<< tr("Chiffre 001") << tr("Chiffre 001")
<< tr("Texte"); << tr("Texte");
} }
else if (m_edited_type == 1) else if (m_edited_type == 1)
{ {
items << tr("Chiffre 1") << tr("Chiffre 1 - Folio") << tr("Chiffre 01") items << tr("Chiffre 1")
<< tr("Chiffre 01 - Folio") << tr("Chiffre 001") << tr("Chiffre 001 - Folio") << tr("Chiffre 1 - Folio")
<< tr("Texte") << tr("N° folio") << tr("Folio") << tr("Installation") << tr("Locmach"); << tr("Chiffre 01")
<< tr("Chiffre 01 - Folio")
<< tr("Chiffre 001")
<< tr("Chiffre 001 - Folio")
<< tr("Texte")
<< tr("N° folio")
<< tr("Folio")
<< tr("Installation")
<< tr("Locmach");
} }
else else
items << tr("Chiffre 1") << tr("Chiffre 1 - Folio") << tr("Chiffre 01") items << tr("Chiffre 1")
<< tr("Chiffre 01 - Folio") << tr("Chiffre 001") << tr("Chiffre 001 - Folio") << tr("Chiffre 1 - Folio")
<< tr("Texte") << tr("N° folio") << tr("Folio") << tr("Installation") << tr("Locmach") << tr("Chiffre 01")
<< tr("Element Line") << tr("Element Column") << tr("Element Prefix"); << tr("Chiffre 01 - Folio")
<< tr("Chiffre 001")
<< tr("Chiffre 001 - Folio")
<< tr("Texte")
<< tr("N° folio")
<< tr("Folio")
<< tr("Installation")
<< tr("Locmach")
<< tr("Element Line")
<< tr("Element Column")
<< tr("Element Prefix");
ui->type_cb->insertItems(0,items); ui->type_cb->insertItems(0,items);
} }
@@ -155,10 +182,17 @@ NumerotationContext NumPartEditorW::toNumContext() {
type_str = "elementprefix"; type_str = "elementprefix";
break; break;
} }
if (type_str == "unitfolio" || type_str == "tenfolio" || type_str == "hundredfolio") if (type_str == "unitfolio"
nc.addValue(type_str, ui -> value_field -> displayText(), ui -> increase_spinBox -> value(), ui->value_field->displayText().toInt()); || type_str == "tenfolio"
|| type_str == "hundredfolio")
nc.addValue(type_str,
ui -> value_field -> displayText(),
ui -> increase_spinBox -> value(),
ui->value_field->displayText().toInt());
else else
nc.addValue(type_str, ui -> value_field -> displayText(), ui -> increase_spinBox -> value()); nc.addValue(type_str,
ui -> value_field -> displayText(),
ui -> increase_spinBox -> value());
return nc; return nc;
} }
@@ -167,8 +201,13 @@ NumerotationContext NumPartEditorW::toNumContext() {
@return true if value field isn't empty or if type is folio @return true if value field isn't empty or if type is folio
*/ */
bool NumPartEditorW::isValid() { bool NumPartEditorW::isValid() {
if (type_ == folio || type_ == idfolio || type_ == elementline || type_ == plant || type_ == locmach || if (type_ == folio
type_ == elementcolumn || type_ == elementprefix) {return true;} || type_ == idfolio
|| type_ == elementline
|| type_ == plant
|| type_ == locmach
|| type_ == elementcolumn
|| type_ == elementprefix) {return true;}
else if(ui -> value_field -> text().isEmpty()) {return false;} else if(ui -> value_field -> text().isEmpty()) {return false;}
else return true; else return true;
} }

View File

@@ -657,9 +657,11 @@ void Createdxf::drawRectangle (const QString &fileName, double x1, double y1, do
Conveniance function for draw rectangle Conveniance function for draw rectangle
@param filepath @param filepath
@param rect @param rect
@param color @param colorcode
*/ */
void Createdxf::drawRectangle(const QString &filepath, const QRectF &rect, const int &colorcode) { void Createdxf::drawRectangle(const QString &filepath,
const QRectF &rect,
const int &colorcode) {
drawRectangle(filepath, rect.bottomLeft().x() * xScale, drawRectangle(filepath, rect.bottomLeft().x() * xScale,
sheetHeight - (rect.bottomLeft().y() * yScale), sheetHeight - (rect.bottomLeft().y() * yScale),
rect.width() * xScale, rect.width() * xScale,
@@ -667,8 +669,24 @@ void Createdxf::drawRectangle(const QString &filepath, const QRectF &rect, const
colorcode); colorcode);
} }
/* draw arc in dx format */ /**
void Createdxf::drawArc(const QString& fileName,double x,double y,double rad,double startAngle,double endAngle,int color) @brief Createdxf::drawArc
draw arc in dx format
@param fileName
@param x
@param y
@param rad
@param startAngle
@param endAngle
@param color
*/
void Createdxf::drawArc(const QString& fileName,
double x,
double y,
double rad,
double startAngle,
double endAngle,
int color)
{ {
if (!fileName.isEmpty()) { if (!fileName.isEmpty()) {
QFile file(fileName); QFile file(fileName);
@@ -704,8 +722,24 @@ void Createdxf::drawArc(const QString& fileName,double x,double y,double rad,dou
} }
} }
/* draw simple text in dxf format without any alignment specified */ /**
void Createdxf::drawText(const QString& fileName, const QString& text,double x, double y, double height, double rotation, int colour) @brief Createdxf::drawText
draw simple text in dxf format without any alignment specified
@param fileName
@param text
@param x
@param y
@param height
@param rotation
@param colour
*/
void Createdxf::drawText(const QString& fileName,
const QString& text,
double x,
double y,
double height,
double rotation,
int colour)
{ {
if (!fileName.isEmpty()) { if (!fileName.isEmpty()) {
QFile file(fileName); QFile file(fileName);
@@ -744,8 +778,20 @@ void Createdxf::drawText(const QString& fileName, const QString& text,double x,
/* draw aligned text in DXF Format */ /* draw aligned text in DXF Format */
// leftAlign flag added. If the alignment requested is 'fit to width' and the text length is very small, // leftAlign flag added. If the alignment requested is 'fit to width' and the text length is very small,
// then the text is either centered or left-aligned, depnding on the value of leftAlign. // then the text is either centered or left-aligned, depnding on the value of leftAlign.
void Createdxf::drawTextAligned(const QString& fileName, const QString& text,double x, double y, double height, double rotation, double oblique,int hAlign, int vAlign, double xAlign, double xScale, int colour, void Createdxf::drawTextAligned(const QString& fileName,
bool leftAlign, float scale) const QString& text,
double x,
double y,
double height,
double rotation,
double oblique,
int hAlign,
int vAlign,
double xAlign,
double xScale,
int colour,
bool leftAlign,
float scale)
{ {
Q_UNUSED(scale); Q_UNUSED(scale);

View File

@@ -534,7 +534,10 @@ QHash<QString, QString> projectDataBase::elementInfoToString(Element *elmt)
@param caption @param caption
@param dir @param dir
*/ */
void projectDataBase::exportDb(projectDataBase *db, QWidget *parent, const QString &caption, const QString &dir) void projectDataBase::exportDb(projectDataBase *db,
QWidget *parent,
const QString &caption,
const QString &dir)
{ {
auto caption_ = caption; auto caption_ = caption;
if (caption_.isEmpty()) { if (caption_.isEmpty()) {

View File

@@ -42,7 +42,10 @@ class projectDataBase : public QObject
public: public:
projectDataBase(QETProject *project, QObject *parent = nullptr); projectDataBase(QETProject *project, QObject *parent = nullptr);
private: private:
projectDataBase(QETProject *project, const QString &connection_name, const QString &path, QObject *parent = nullptr); projectDataBase(QETProject *project,
const QString &connection_name,
const QString &path,
QObject *parent = nullptr);
public: public:
virtual ~projectDataBase() override; virtual ~projectDataBase() override;
@@ -59,7 +62,8 @@ class projectDataBase : public QObject
void dataBaseUpdated(); void dataBaseUpdated();
private: private:
bool createDataBase(const QString &connection_name= QString(), const QString &name = QString()); bool createDataBase(const QString &connection_name= QString(),
const QString &name = QString());
void createElementNomenclatureView(); void createElementNomenclatureView();
void createSummaryView(); void createSummaryView();
void populateDiagramTable(); void populateDiagramTable();
@@ -67,7 +71,8 @@ class projectDataBase : public QObject
void populateElementInfoTable(); void populateElementInfoTable();
void populateDiagramInfoTable(); void populateDiagramInfoTable();
void prepareQuery(); void prepareQuery();
static QHash<QString, QString> elementInfoToString(Element *elmt); static QHash<QString, QString> elementInfoToString(
Element *elmt);
private: private:
QPointer<QETProject> m_project; QPointer<QETProject> m_project;
@@ -81,7 +86,10 @@ class projectDataBase : public QObject
m_insert_diagram_info_query; m_insert_diagram_info_query;
public: public:
static void exportDb(projectDataBase *db, QWidget *parent = nullptr, const QString &caption = QString(), const QString &dir = QString()); static void exportDb(projectDataBase *db,
QWidget *parent = nullptr,
const QString &caption = QString(),
const QString &dir = QString());
}; };
#endif // PROJECTDATABASE_H #endif // PROJECTDATABASE_H

View File

@@ -133,10 +133,12 @@ class Diagram : public QGraphicsScene
protected: protected:
void drawBackground(QPainter *, const QRectF &) override; void drawBackground(QPainter *, const QRectF &) override;
void mouseDoubleClickEvent (QGraphicsSceneMouseEvent *event) override; void mouseDoubleClickEvent (
QGraphicsSceneMouseEvent *event) override;
void mousePressEvent (QGraphicsSceneMouseEvent *event) override; void mousePressEvent (QGraphicsSceneMouseEvent *event) override;
void mouseMoveEvent (QGraphicsSceneMouseEvent *event) override; void mouseMoveEvent (QGraphicsSceneMouseEvent *event) override;
void mouseReleaseEvent (QGraphicsSceneMouseEvent *event) override; void mouseReleaseEvent (
QGraphicsSceneMouseEvent *event) override;
void wheelEvent (QGraphicsSceneWheelEvent *event) override; void wheelEvent (QGraphicsSceneWheelEvent *event) override;
void keyPressEvent (QKeyEvent *event) override; void keyPressEvent (QKeyEvent *event) override;
void keyReleaseEvent (QKeyEvent *) override; void keyReleaseEvent (QKeyEvent *) override;
@@ -167,18 +169,30 @@ class Diagram : public QGraphicsScene
// methods related to XML import/export // methods related to XML import/export
QDomDocument toXml(bool = true); QDomDocument toXml(bool = true);
bool initFromXml(QDomElement &, QPointF = QPointF(), bool initFromXml(QDomElement &,
bool = true, DiagramContent * = nullptr); QPointF = QPointF(),
bool fromXml(QDomDocument &, QPointF = QPointF(), bool = true,
bool = true, DiagramContent * = nullptr); DiagramContent * = nullptr);
bool fromXml(QDomElement &, QPointF = QPointF(), bool fromXml(QDomDocument &,
bool = true, DiagramContent * = nullptr); QPointF = QPointF(),
void folioSequentialsToXml(QHash<QString, QStringList>*, bool = true,
QDomElement *, const QString&, DiagramContent * = nullptr);
const QString&, QDomDocument *); bool fromXml(QDomElement &,
void folioSequentialsFromXml(const QDomElement&, QHash<QString, QPointF = QPointF(),
QStringList>*, const QString&, bool = true,
const QString&, const QString&, DiagramContent * = nullptr);
void folioSequentialsToXml(QHash<QString,
QStringList>*,
QDomElement *,
const QString&,
const QString&,
QDomDocument *);
void folioSequentialsFromXml(const QDomElement&,
QHash<QString,
QStringList>*,
const QString&,
const QString&,
const QString&,
const QString&); const QString&);
void refreshContents(); void refreshContents();

View File

@@ -181,8 +181,10 @@ class MoveConductorsTextsCommand : public QUndoCommand {
public: public:
void undo() override; void undo() override;
void redo() override; void redo() override;
virtual void addTextMovement(ConductorTextItem *, const QPointF &, virtual void addTextMovement(ConductorTextItem *,
const QPointF &, bool = false); const QPointF &,
const QPointF &,
bool = false);
private: private:
void regenerateTextLabel(); void regenerateTextLabel();

View File

@@ -88,7 +88,8 @@ QString DiagramPrintDialog::docName() const {
@param options : @param options :
@return the rectangle to be printed @return the rectangle to be printed
*/ */
QRect DiagramPrintDialog::diagramRect(Diagram *diagram, const ExportProperties &options) const { QRect DiagramPrintDialog::diagramRect(Diagram *diagram,
const ExportProperties &options) const {
if (!diagram) return(QRect()); if (!diagram) return(QRect());
QRectF diagram_rect = diagram -> border_and_titleblock.borderAndTitleBlockRect(); QRectF diagram_rect = diagram -> border_and_titleblock.borderAndTitleBlockRect();

View File

@@ -49,22 +49,34 @@ class DiagramPrintDialog : public QWidget
void setDocName(const QString &); void setDocName(const QString &);
QString docName() const; QString docName() const;
QRect diagramRect(Diagram *, const ExportProperties &) const; QRect diagramRect(Diagram *, const ExportProperties &) const;
int pagesCount(Diagram *, const ExportProperties &, bool = false) const; int pagesCount(Diagram *,
int horizontalPagesCount(Diagram *, const ExportProperties &, bool = false) const; const ExportProperties &,
int verticalPagesCount(Diagram *, const ExportProperties &, bool = false) const; bool = false) const;
int horizontalPagesCount(Diagram *,
const ExportProperties &,
bool = false) const;
int verticalPagesCount(Diagram *,
const ExportProperties &,
bool = false) const;
void exec(); void exec();
private: private:
void buildPrintTypeDialog(); void buildPrintTypeDialog();
void buildDialog(); void buildDialog();
void saveReloadDiagramParameters(Diagram *, const ExportProperties&, bool); void saveReloadDiagramParameters(Diagram *,
const ExportProperties&,
bool);
void savePageSetupForCurrentPrinter(); void savePageSetupForCurrentPrinter();
void loadPageSetupForCurrentPrinter(); void loadPageSetupForCurrentPrinter();
QString settingsSectionName(const QPrinter *); QString settingsSectionName(const QPrinter *);
private slots: private slots:
void print(const QList<Diagram *> &, bool, const ExportProperties&); void print(const QList<Diagram *> &, bool, const ExportProperties&);
void printDiagram(Diagram *, bool, const ExportProperties &, QPainter *, QPrinter * = nullptr); void printDiagram(Diagram *,
bool,
const ExportProperties &,
QPainter *,
QPrinter * = nullptr);
void updatePrintTypeDialog(); void updatePrintTypeDialog();
void acceptPrintTypeDialog(); void acceptPrintTypeDialog();
void browseFilePrintTypeDialog(); void browseFilePrintTypeDialog();

View File

@@ -28,7 +28,10 @@
in the constructor of this class to avoid have several terminal in the constructor of this class to avoid have several terminal
of an element with the same uuid. of an element with the same uuid.
*/ */
PastePartsCommand::PastePartsCommand(ElementView *view, const ElementContent &content_to_paste, QUndoCommand *parent) : PastePartsCommand::PastePartsCommand(
ElementView *view,
const ElementContent &content_to_paste,
QUndoCommand *parent) :
ElementEditionCommand(view ? view -> scene() : nullptr, view, parent) ElementEditionCommand(view ? view -> scene() : nullptr, view, parent)
{ {
for (auto qgi : content_to_paste) for (auto qgi : content_to_paste)

View File

@@ -25,7 +25,9 @@
@param view @param view
@param parent : Parent command @param parent : Parent command
*/ */
ElementEditionCommand::ElementEditionCommand(ElementScene *scene, ElementView *view, QUndoCommand *parent): ElementEditionCommand::ElementEditionCommand(ElementScene *scene,
ElementView *view,
QUndoCommand *parent):
QUndoCommand(parent), QUndoCommand(parent),
m_scene(scene), m_scene(scene),
m_view(view) m_view(view)
@@ -41,7 +43,10 @@ ElementEditionCommand::ElementEditionCommand(ElementScene *scene, ElementView *v
@param view @param view
@param parent : Parent command @param parent : Parent command
*/ */
ElementEditionCommand::ElementEditionCommand(const QString &text, ElementScene *scene, ElementView *view, QUndoCommand *parent): ElementEditionCommand::ElementEditionCommand(const QString &text,
ElementScene *scene,
ElementView *view,
QUndoCommand *parent):
QUndoCommand(text, parent), QUndoCommand(text, parent),
m_scene(scene), m_scene(scene),
m_view(view) m_view(view)
@@ -543,7 +548,12 @@ void ScalePartsCommand::adjustText() {
@param elmt_info : new info about type. @param elmt_info : new info about type.
@param parent : parent undo @param parent : parent undo
*/ */
ChangePropertiesCommand::ChangePropertiesCommand(ElementScene *scene, const QString& type, const DiagramContext& info, const DiagramContext& elmt_info, QUndoCommand *parent) : ChangePropertiesCommand::ChangePropertiesCommand(
ElementScene *scene,
const QString& type,
const DiagramContext& info,
const DiagramContext& elmt_info,
QUndoCommand *parent) :
ElementEditionCommand(scene, nullptr, parent) ElementEditionCommand(scene, nullptr, parent)
{ {
m_type << scene->m_elmt_type << type; m_type << scene->m_elmt_type << type;

View File

@@ -33,8 +33,13 @@ class ElementEditionCommand : public QUndoCommand
{ {
// constructors, destructor // constructors, destructor
public: public:
ElementEditionCommand(ElementScene * = nullptr, ElementView * = nullptr, QUndoCommand * = nullptr); ElementEditionCommand(ElementScene * = nullptr,
ElementEditionCommand(const QString &, ElementScene * = nullptr, ElementView * = nullptr, QUndoCommand * = nullptr); ElementView * = nullptr,
QUndoCommand * = nullptr);
ElementEditionCommand(const QString &,
ElementScene * = nullptr,
ElementView * = nullptr,
QUndoCommand * = nullptr);
~ElementEditionCommand() override; ~ElementEditionCommand() override;
private: private:
ElementEditionCommand(const ElementEditionCommand &); ElementEditionCommand(const ElementEditionCommand &);
@@ -259,7 +264,12 @@ class ScalePartsCommand : public ElementEditionCommand {
class ChangePropertiesCommand : public ElementEditionCommand { class ChangePropertiesCommand : public ElementEditionCommand {
public: public:
ChangePropertiesCommand (ElementScene *scene, const QString& type, const DiagramContext& info, const DiagramContext& elmt_info, QUndoCommand *parent=nullptr); ChangePropertiesCommand (
ElementScene *scene,
const QString& type,
const DiagramContext& info,
const DiagramContext& elmt_info,
QUndoCommand *parent=nullptr);
~ChangePropertiesCommand () override; ~ChangePropertiesCommand () override;
void undo() override; void undo() override;

View File

@@ -80,11 +80,14 @@ QRectF ElementPrimitiveDecorator::boundingRect() const
@param option : @param option :
The option parameter provides style options for the item, such The option parameter provides style options for the item, such
as its state, exposed area and its level-of-detail hints. as its state, exposed area and its level-of-detail hints.
@param The widget argument is optional. If provided, it points to the @param widget :
widget that is being painted on; otherwise, it is 0. For cached painting, The widget argument is optional. If provided,
widget is always 0. it points to the widget that is being painted on; otherwise, it is 0.
For cached painting, widget is always 0.
*/ */
void ElementPrimitiveDecorator::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) void ElementPrimitiveDecorator::paint(QPainter *painter,
const QStyleOptionGraphicsItem *option,
QWidget *widget)
{ {
Q_UNUSED(option) Q_UNUSED(option)
Q_UNUSED(widget) Q_UNUSED(widget)

View File

@@ -50,7 +50,9 @@ class ElementPrimitiveDecorator : public QGraphicsObject
// methods // methods
QRectF internalBoundingRect() const; QRectF internalBoundingRect() const;
QRectF boundingRect () const override; QRectF boundingRect () const override;
void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget * = nullptr) override; void paint(QPainter *,
const QStyleOptionGraphicsItem *,
QWidget * = nullptr) override;
int type() const override { return Type; } int type() const override { return Type; }
void setItems(const QList<QGraphicsItem *> &); void setItems(const QList<QGraphicsItem *> &);
void setItems(const QList<CustomElementPart *> &); void setItems(const QList<CustomElementPart *> &);

View File

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

View File

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

View File

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

View File

@@ -117,14 +117,19 @@ QList <Element *> ElementProvider::find(const int filter) const {
and not already in all the chain of next/previous table of table (if set) and not already in all the chain of next/previous table of table (if set)
If table and model are nullptr, return every tables If table and model are nullptr, return every tables
*/ */
QVector<QetGraphicsTableItem *> ElementProvider::table(QetGraphicsTableItem *table, QAbstractItemModel *model) QVector<QetGraphicsTableItem *> ElementProvider::table(
QetGraphicsTableItem *table,
QAbstractItemModel *model)
{ {
QVector<QetGraphicsTableItem *> v_; QVector<QetGraphicsTableItem *> v_;
QVector<QetGraphicsTableItem *> linked_vector; QVector<QetGraphicsTableItem *> linked_vector;
if (table) if (table)
{ {
auto linked_table = table->previousTable() ? table->previousTable() : table->nextTable(); //table can be inside a chain, at the head of a chain or alone //table can be inside a chain, at the head of a chain or alone
auto linked_table = table->previousTable()
? table->previousTable()
: table->nextTable();
while (linked_table) { //Go to the first table while (linked_table) { //Go to the first table
if (linked_table->previousTable()) if (linked_table->previousTable())
linked_table = linked_table->previousTable(); linked_table = linked_table->previousTable();

View File

@@ -212,7 +212,10 @@ bool ElementsCollectionCache::fetchData(const ElementsLocation &location) {
int state; int state;
Element *custom_elmt = ElementFactory::Instance() -> createElement(location, nullptr, &state); Element *custom_elmt = ElementFactory::Instance() -> createElement(location, nullptr, &state);
if (state) { if (state) {
qDebug() << "ElementsCollectionCache::fetchData() : Le chargement du composant" << qPrintable(location.toString()) << "a echoue avec le code d'erreur" << state; qDebug() << "ElementsCollectionCache::fetchData() : Le chargement du composant"
<< qPrintable(location.toString())
<< "a echoue avec le code d'erreur"
<< state;
} else { } else {
current_name_ = custom_elmt -> name(); current_name_ = custom_elmt -> name();
current_pixmap_ = custom_elmt -> pixmap(); current_pixmap_ = custom_elmt -> pixmap();
@@ -229,7 +232,8 @@ bool ElementsCollectionCache::fetchData(const ElementsLocation &location) {
@param uuid : Element uuid @param uuid : Element uuid
@return True if the retrieval succeeded, false otherwise. @return True if the retrieval succeeded, false otherwise.
*/ */
bool ElementsCollectionCache::fetchNameFromCache(const QString &path, const QUuid &uuid) bool ElementsCollectionCache::fetchNameFromCache(const QString &path,
const QUuid &uuid)
{ {
select_name_ -> bindValue(":path", path); select_name_ -> bindValue(":path", path);
select_name_ -> bindValue(":locale", locale_); select_name_ -> bindValue(":locale", locale_);
@@ -257,7 +261,8 @@ bool ElementsCollectionCache::fetchNameFromCache(const QString &path, const QUui
@param uuid : Element uuid @param uuid : Element uuid
@return True if the retrieval succeeded, false otherwise. @return True if the retrieval succeeded, false otherwise.
*/ */
bool ElementsCollectionCache::fetchPixmapFromCache(const QString &path, const QUuid &uuid) bool ElementsCollectionCache::fetchPixmapFromCache(const QString &path,
const QUuid &uuid)
{ {
select_pixmap_ -> bindValue(":path", path); select_pixmap_ -> bindValue(":path", path);
select_pixmap_ -> bindValue(":uuid", uuid.toString()); select_pixmap_ -> bindValue(":uuid", uuid.toString());
@@ -287,7 +292,8 @@ bool ElementsCollectionCache::fetchPixmapFromCache(const QString &path, const QU
@return True if the caching succeeded, false otherwise. @return True if the caching succeeded, false otherwise.
@see name() @see name()
*/ */
bool ElementsCollectionCache::cacheName(const QString &path, const QUuid &uuid) bool ElementsCollectionCache::cacheName(const QString &path,
const QUuid &uuid)
{ {
insert_name_ -> bindValue(":path", path); insert_name_ -> bindValue(":path", path);
insert_name_ -> bindValue(":locale", locale_); insert_name_ -> bindValue(":locale", locale_);
@@ -309,7 +315,8 @@ bool ElementsCollectionCache::cacheName(const QString &path, const QUuid &uuid)
@return True if the caching succeeded, false otherwise. @return True if the caching succeeded, false otherwise.
@see pixmap() @see pixmap()
*/ */
bool ElementsCollectionCache::cachePixmap(const QString &path, const QUuid &uuid) bool ElementsCollectionCache::cachePixmap(const QString &path,
const QUuid &uuid)
{ {
QByteArray ba; QByteArray ba;
QBuffer buffer(&ba); QBuffer buffer(&ba);

View File

@@ -31,7 +31,8 @@ class ElementsCollectionCache : public QObject
{ {
public: public:
// constructor, destructor // constructor, destructor
ElementsCollectionCache(const QString &database_path, QObject * = nullptr); ElementsCollectionCache(const QString &database_path,
QObject * = nullptr);
~ElementsCollectionCache() override; ~ElementsCollectionCache() override;
// methods // methods
@@ -46,8 +47,10 @@ class ElementsCollectionCache : public QObject
bool fetchData(const ElementsLocation &); bool fetchData(const ElementsLocation &);
bool fetchNameFromCache(const QString &path, const QUuid &uuid); bool fetchNameFromCache(const QString &path, const QUuid &uuid);
bool fetchPixmapFromCache(const QString &path, const QUuid &uuid); bool fetchPixmapFromCache(const QString &path, const QUuid &uuid);
bool cacheName(const QString &path, const QUuid &uuid = QUuid::createUuid()); bool cacheName(const QString &path,
bool cachePixmap(const QString &path, const QUuid &uuid = QUuid::createUuid()); const QUuid &uuid = QUuid::createUuid());
bool cachePixmap(const QString &path,
const QUuid &uuid = QUuid::createUuid());
// attributes // attributes
private: private:

View File

@@ -128,7 +128,9 @@ void ElementsPanel::panelContentChange() {
@return @return
Le QTreeWidgetItem insere le plus haut Le QTreeWidgetItem insere le plus haut
*/ */
QTreeWidgetItem *ElementsPanel::addProject(QETProject *project, QTreeWidgetItem *parent_item, PanelOptions options) QTreeWidgetItem *ElementsPanel::addProject(QETProject *project,
QTreeWidgetItem *parent_item,
PanelOptions options)
{ {
Q_UNUSED(parent_item) Q_UNUSED(parent_item)
Q_UNUSED(options) Q_UNUSED(options)
@@ -155,8 +157,16 @@ QTreeWidgetItem *ElementsPanel::addProject(QETProject *project, QTreeWidgetItem
return(qtwi_project); return(qtwi_project);
} }
QTreeWidgetItem *ElementsPanel::updateTemplatesCollectionItem(QTreeWidgetItem *tbt_collection_qtwi, TitleBlockTemplatesCollection *tbt_collection, PanelOptions options, bool freshly_created) { QTreeWidgetItem *ElementsPanel::updateTemplatesCollectionItem(
QTreeWidgetItem *tbtc_qtwi = GenericPanel::updateTemplatesCollectionItem(tbt_collection_qtwi, tbt_collection, options, freshly_created); QTreeWidgetItem *tbt_collection_qtwi,
TitleBlockTemplatesCollection *tbt_collection,
PanelOptions options,
bool freshly_created) {
QTreeWidgetItem *tbtc_qtwi = GenericPanel::
updateTemplatesCollectionItem(tbt_collection_qtwi,
tbt_collection,
options,
freshly_created);
if (tbt_collection && tbt_collection -> parentProject()) { if (tbt_collection && tbt_collection -> parentProject()) {
tbtc_qtwi -> setText(0, tr("Cartouches embarqués")); tbtc_qtwi -> setText(0, tr("Cartouches embarqués"));
tbtc_qtwi -> setStatusTip(0, tr("Double-cliquez pour réduire ou développer cette collection de cartouches embarquée", "Status tip")); tbtc_qtwi -> setStatusTip(0, tr("Double-cliquez pour réduire ou développer cette collection de cartouches embarquée", "Status tip"));
@@ -164,12 +174,19 @@ QTreeWidgetItem *ElementsPanel::updateTemplatesCollectionItem(QTreeWidgetItem *t
return(tbtc_qtwi); return(tbtc_qtwi);
} }
QTreeWidgetItem *ElementsPanel::updateTemplateItem(QTreeWidgetItem *tb_template_qtwi, const TitleBlockTemplateLocation &tb_template, PanelOptions options, bool freshly_created) { QTreeWidgetItem *ElementsPanel::updateTemplateItem(
QTreeWidgetItem *item = GenericPanel::updateTemplateItem(tb_template_qtwi, tb_template, options, freshly_created); QTreeWidgetItem *tb_template_qtwi,
const TitleBlockTemplateLocation &tb_template,
PanelOptions options,
bool freshly_created) {
QTreeWidgetItem *item = GenericPanel::updateTemplateItem(
tb_template_qtwi,
tb_template,
options,
freshly_created);
item -> setStatusTip( item -> setStatusTip(
0, 0,
tr( tr("Glissez-déposez ce modèle de cartouche sur un folio pour l'y appliquer.",
"Glissez-déposez ce modèle de cartouche sur un folio pour l'y appliquer.",
"Status tip displayed when selecting a title block template" "Status tip displayed when selecting a title block template"
) )
); );
@@ -179,13 +196,15 @@ QTreeWidgetItem *ElementsPanel::updateTemplateItem(QTreeWidgetItem *tb_template_
/** /**
@return true if \a item matches the filter, false otherwise @return true if \a item matches the filter, false otherwise
*/ */
bool ElementsPanel::matchesFilter(const QTreeWidgetItem *item, const QString& filter) const { bool ElementsPanel::matchesFilter(const QTreeWidgetItem *item,
const QString& filter) const {
if (!item) return(false); if (!item) return(false);
// no filter => we consider the item matches // no filter => we consider the item matches
if (filter.isEmpty()) return(true); if (filter.isEmpty()) return(true);
bool item_matches = item -> text(0).contains(filter, Qt::CaseInsensitive); bool item_matches = item -> text(0).contains(filter,
Qt::CaseInsensitive);
return(item_matches); return(item_matches);
} }

View File

@@ -140,7 +140,8 @@ ImportElementTextPattern::ImportElementTextPattern(Element *elmt):
if(!exist) if(!exist)
{ {
QMessageBox::information(parentWidget(), QMessageBox::information(
parentWidget(),
QObject::tr("Configuration de textes"), QObject::tr("Configuration de textes"),
QObject::tr("Aucune configuration de textes existante.")); QObject::tr("Aucune configuration de textes existante."));
return; return;
@@ -166,9 +167,12 @@ ImportElementTextPattern::ImportElementTextPattern(Element *elmt):
@param erase @param erase
@return @return
*/ */
QString ImportElementTextPattern::getName(const QStringList& list, bool *ok, bool *erase) const QString ImportElementTextPattern::getName(const QStringList& list,
bool *ok,
bool *erase) const
{ {
return ImportElementTextPatternDialog::getItem(parentWidget(), return ImportElementTextPatternDialog::getItem(
parentWidget(),
QObject::tr("Sélectionner une configuration de textes"), QObject::tr("Sélectionner une configuration de textes"),
QObject::tr("Sélectionner la configuration de textes à ajouter à l'élément"), QObject::tr("Sélectionner la configuration de textes à ajouter à l'élément"),
list, list,

View File

@@ -45,7 +45,9 @@ class ImportElementTextPattern
ImportElementTextPattern(Element *elmt); ImportElementTextPattern(Element *elmt);
private: private:
QString getName(const QStringList& list, bool *ok, bool *erase) const; QString getName(const QStringList& list,
bool *ok,
bool *erase) const;
QWidget *parentWidget() const; QWidget *parentWidget() const;
void apply(QString name, bool erase = false) const; void apply(QString name, bool erase = false) const;

View File

@@ -418,9 +418,19 @@ void ExportDialog::generateDxf(Diagram *diagram,
if (epw -> exportProperties().draw_border) { if (epw -> exportProperties().draw_border) {
double bx0 = Diagram::margin * Createdxf::xScale; double bx0 = Diagram::margin * Createdxf::xScale;
double by0 = Diagram::margin * Createdxf::yScale; double by0 = Diagram::margin * Createdxf::yScale;
Createdxf::drawRectangle(file_path, bx0, -by0, double(width)*Createdxf::xScale, double(height)*Createdxf::yScale, 0); Createdxf::drawRectangle(
file_path,
bx0,
-by0,
double(width)*Createdxf::xScale,
double(height)*Createdxf::yScale,
0);
} }
diagram -> border_and_titleblock.drawDxf(width, height, keep_aspect_ratio, file_path, 0); diagram -> border_and_titleblock.drawDxf(width,
height,
keep_aspect_ratio,
file_path,
0);
// Build the lists of elements. // Build the lists of elements.
QList<Element *> list_elements; QList<Element *> list_elements;

View File

@@ -117,7 +117,8 @@ QPixmap ElementPictureFactory::pixmap(const ElementsLocation &location)
@param location @param location
@return The primtive used to draw the element at location @return The primtive used to draw the element at location
*/ */
ElementPictureFactory::primitives ElementPictureFactory::getPrimitives(const ElementsLocation &location) ElementPictureFactory::primitives ElementPictureFactory::getPrimitives(
const ElementsLocation &location)
{ {
if(!m_primitives_H.contains(location.uuid())) if(!m_primitives_H.contains(location.uuid()))
build(location); build(location);
@@ -143,7 +144,9 @@ ElementPictureFactory::~ElementPictureFactory() {
draw on it and store it in m_pictures_H and m_low_pictures_H draw on it and store it in m_pictures_H and m_low_pictures_H
@return @return
*/ */
bool ElementPictureFactory::build(const ElementsLocation &location, QPicture *picture, QPicture *low_picture) bool ElementPictureFactory::build(const ElementsLocation &location,
QPicture *picture,
QPicture *low_picture)
{ {
QDomElement dom = location.xml(); QDomElement dom = location.xml();

View File

@@ -65,7 +65,8 @@ QETProject *ProjectConfigPage::project() const {
@param read_values @param read_values
@return the former project @return the former project
*/ */
QETProject *ProjectConfigPage::setProject(QETProject *new_project, bool read_values) { QETProject *ProjectConfigPage::setProject(QETProject *new_project,
bool read_values) {
if (new_project == m_project) return(m_project); if (new_project == m_project) return(m_project);
QETProject *former_project = m_project; QETProject *former_project = m_project;
@@ -222,7 +223,8 @@ void ProjectMainConfigPage::adjustReadOnly() {
@param project : project to edit @param project : project to edit
@param parent : parent widget @param parent : parent widget
*/ */
ProjectAutoNumConfigPage::ProjectAutoNumConfigPage (QETProject *project, QWidget *parent) : ProjectAutoNumConfigPage::ProjectAutoNumConfigPage (QETProject *project,
QWidget *parent) :
ProjectConfigPage(project, parent) ProjectConfigPage(project, parent)
{ {
initWidgets(); initWidgets();
@@ -626,5 +628,5 @@ void ProjectAutoNumConfigPage::removeContextFolio() {
*/ */
void ProjectAutoNumConfigPage::changeToTab(int i) void ProjectAutoNumConfigPage::changeToTab(int i)
{ {
Q_UNUSED(i); qDebug()<<"Q_UNUSED"<<i;
} }

View File

@@ -123,7 +123,8 @@ class ProjectAutoNumConfigPage : public ProjectConfigPage {
//Methods //Methods
public: public:
ProjectAutoNumConfigPage (QETProject *project, QWidget *parent = nullptr); ProjectAutoNumConfigPage (QETProject *project,
QWidget *parent = nullptr);
QString title() const override; QString title() const override;
QIcon icon() const override; QIcon icon() const override;

View File

@@ -899,7 +899,10 @@ void ProjectView::updateTabTitle(DiagramView *diagram_view)
{ {
QString formula = diagram->border_and_titleblock.folio(); QString formula = diagram->border_and_titleblock.folio();
autonum::sequentialNumbers seq; autonum::sequentialNumbers seq;
title = autonum::AssignVariables::formulaToLabel(formula, seq, diagram); title = autonum::AssignVariables::formulaToLabel(
formula,
seq,
diagram);
} }
else else
title = QString::number(diagram->folioIndex() + 1); title = QString::number(diagram->folioIndex() + 1);

View File

@@ -190,13 +190,19 @@ void ProjectDBModel::setQuery(const QString &query)
if (m_project) if (m_project)
{ {
if (rm_) { if (rm_) {
disconnect(m_project->dataBase(), &projectDataBase::dataBaseUpdated, this, &ProjectDBModel::dataBaseUpdated); disconnect(m_project->dataBase(),
&projectDataBase::dataBaseUpdated,
this,
&ProjectDBModel::dataBaseUpdated);
} }
m_project->dataBase()->updateDB(); m_project->dataBase()->updateDB();
if (rm_) { if (rm_) {
setHeaderString(); setHeaderString();
fillValue(); fillValue();
connect(m_project->dataBase(), &projectDataBase::dataBaseUpdated, this, &ProjectDBModel::dataBaseUpdated); connect(m_project->dataBase(),
&projectDataBase::dataBaseUpdated,
this,
&ProjectDBModel::dataBaseUpdated);
} }
} }

View File

@@ -1504,7 +1504,8 @@ QPainterPath Conductor::path() const
to other conductor in the same potential, to other conductor in the same potential,
the other values of property stay unmodified the other values of property stay unmodified
*/ */
void Conductor::setPropertyToPotential(const ConductorProperties &property, bool only_text) void Conductor::setPropertyToPotential(const ConductorProperties &property,
bool only_text)
{ {
setProperties(property); setProperties(property);
QSet <Conductor *> potential_list = relatedPotentialConductors(); QSet <Conductor *> potential_list = relatedPotentialConductors();

View File

@@ -46,13 +46,18 @@ bool sorting(QGraphicsItem *qgia, QGraphicsItem *qgib)
@param name : @param name :
@param parent : @param parent :
*/ */
ElementTextItemGroup::ElementTextItemGroup(const QString &name, Element *parent) : ElementTextItemGroup::ElementTextItemGroup(const QString &name,
Element *parent) :
QGraphicsItemGroup(parent), QGraphicsItemGroup(parent),
m_name(name), m_name(name),
m_parent_element(parent) m_parent_element(parent)
{ {
setFlags(QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemIsMovable); setFlags(QGraphicsItem::ItemIsSelectable
connect(parent, &Element::linkedElementChanged, this, &ElementTextItemGroup::updateXref); | QGraphicsItem::ItemIsMovable);
connect(parent,
&Element::linkedElementChanged,
this,
&ElementTextItemGroup::updateXref);
} }
ElementTextItemGroup::~ElementTextItemGroup() ElementTextItemGroup::~ElementTextItemGroup()

View File

@@ -81,7 +81,9 @@ class ElementTextItemGroup : public QObject, public QGraphicsItemGroup
void fromXml(QDomElement &dom_element); void fromXml(QDomElement &dom_element);
static QString xmlTaggName() {return QString("texts_group");} static QString xmlTaggName() {return QString("texts_group");}
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override; void paint(QPainter *painter,
const QStyleOptionGraphicsItem *option,
QWidget *widget) override;
QRectF boundingRect() const override; QRectF boundingRect() const override;
void setRotation(qreal angle); void setRotation(qreal angle);
void setPos(const QPointF &pos); void setPos(const QPointF &pos);
@@ -90,8 +92,10 @@ class ElementTextItemGroup : public QObject, public QGraphicsItemGroup
protected: protected:
void mousePressEvent(QGraphicsSceneMouseEvent *event) override; void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override; void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override;
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override; void mouseReleaseEvent(
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) override; QGraphicsSceneMouseEvent *event) override;
void mouseDoubleClickEvent(
QGraphicsSceneMouseEvent *event) override;
void keyPressEvent(QKeyEvent *event) override; void keyPressEvent(QKeyEvent *event) override;
void hoverEnterEvent(QGraphicsSceneHoverEvent *event) override; void hoverEnterEvent(QGraphicsSceneHoverEvent *event) override;
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) override; void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) override;

View File

@@ -28,7 +28,9 @@
@param qgi : parent QGraphicItem @param qgi : parent QGraphicItem
@param state : int used to know if the creation of element have error @param state : int used to know if the creation of element have error
*/ */
MasterElement::MasterElement(const ElementsLocation &location, QGraphicsItem *qgi, int *state) : MasterElement::MasterElement(const ElementsLocation &location,
QGraphicsItem *qgi,
int *state) :
Element(location, qgi, state, Element::Master) Element(location, qgi, state, Element::Master)
{} {}

View File

@@ -29,7 +29,8 @@
@param conductor : conductor to edit propertie @param conductor : conductor to edit propertie
@param parent : parent widget @param parent : parent widget
*/ */
ConductorPropertiesDialog::ConductorPropertiesDialog(Conductor *conductor, QWidget *parent) : ConductorPropertiesDialog::ConductorPropertiesDialog(Conductor *conductor,
QWidget *parent) :
QDialog(parent), QDialog(parent),
ui(new Ui::ConductorPropertiesDialog) ui(new Ui::ConductorPropertiesDialog)
{ {
@@ -58,11 +59,13 @@ ConductorPropertiesDialog::~ConductorPropertiesDialog()
@param conductor : conductor to edit propertie @param conductor : conductor to edit propertie
@param parent : parent widget @param parent : parent widget
*/ */
void ConductorPropertiesDialog::PropertiesDialog(Conductor *conductor, QWidget *parent) void ConductorPropertiesDialog::PropertiesDialog(Conductor *conductor,
QWidget *parent)
{ {
ConductorPropertiesDialog cpd (conductor, parent); ConductorPropertiesDialog cpd (conductor, parent);
if (cpd.exec() == QDialog::Rejected || cpd.properties() == conductor->properties()) return; if (cpd.exec() == QDialog::Rejected
|| cpd.properties() == conductor->properties()) return;
QVariant old_value, new_value; QVariant old_value, new_value;
old_value.setValue(conductor->properties()); old_value.setValue(conductor->properties());

View File

@@ -34,8 +34,10 @@ class ConductorPropertiesDialog : public QDialog
Q_OBJECT Q_OBJECT
public: public:
explicit ConductorPropertiesDialog (Conductor *conductor, QWidget *parent = nullptr); explicit ConductorPropertiesDialog (Conductor *conductor,
static void PropertiesDialog (Conductor *conductor, QWidget *parent = nullptr); QWidget *parent = nullptr);
static void PropertiesDialog (Conductor *conductor,
QWidget *parent = nullptr);
~ConductorPropertiesDialog() override; ~ConductorPropertiesDialog() override;
ConductorProperties properties() const; ConductorProperties properties() const;

View File

@@ -43,7 +43,9 @@ ConductorPropertiesWidget::ConductorPropertiesWidget(QWidget *parent) :
@param properties : properties to edit @param properties : properties to edit
@param parent : parent widget @param parent : parent widget
*/ */
ConductorPropertiesWidget::ConductorPropertiesWidget(const ConductorProperties &properties, QWidget *parent) : ConductorPropertiesWidget::ConductorPropertiesWidget(
const ConductorProperties &properties,
QWidget *parent) :
QWidget(parent), QWidget(parent),
ui(new Ui::ConductorPropertiesWidget) ui(new Ui::ConductorPropertiesWidget)
{ {
@@ -66,7 +68,8 @@ ConductorPropertiesWidget::~ConductorPropertiesWidget()
Set the properties Set the properties
@param properties @param properties
*/ */
void ConductorPropertiesWidget::setProperties(const ConductorProperties &properties) void ConductorPropertiesWidget::setProperties(
const ConductorProperties &properties)
{ {
if (m_properties == properties) if (m_properties == properties)
return; return;

View File

@@ -34,7 +34,9 @@ class ConductorPropertiesWidget : public QWidget
public: public:
explicit ConductorPropertiesWidget(QWidget *parent = nullptr); explicit ConductorPropertiesWidget(QWidget *parent = nullptr);
explicit ConductorPropertiesWidget(const ConductorProperties &properties, QWidget *parent = nullptr); explicit ConductorPropertiesWidget(
const ConductorProperties &properties,
QWidget *parent = nullptr);
~ConductorPropertiesWidget() override; ~ConductorPropertiesWidget() override;
//METHODS //METHODS

View File

@@ -32,8 +32,10 @@ class DiagramPropertiesEditorDockWidget : public PropertiesEditorDockWidget
void setDiagram(Diagram *diagram); void setDiagram(Diagram *diagram);
private: //Make this method private because only this class manage the editor widget. private: //Make this method private because only this class manage the editor widget.
bool addEditor(PropertiesEditorWidget *editor, int index = 0) { return PropertiesEditorDockWidget::addEditor(editor, index); } bool addEditor(PropertiesEditorWidget *editor,int index = 0)
bool removeEditor(PropertiesEditorWidget *editor) { return PropertiesEditorDockWidget::removeEditor(editor); } {return PropertiesEditorDockWidget::addEditor(editor,index); }
bool removeEditor(PropertiesEditorWidget *editor)
{ return PropertiesEditorDockWidget::removeEditor(editor); }
private slots: private slots:
void selectionChanged(); void selectionChanged();

View File

@@ -66,8 +66,12 @@ class DynamicElementTextModel : public QStandardItemModel
DynamicElementTextItem *textFromIndex(const QModelIndex &index) const; DynamicElementTextItem *textFromIndex(const QModelIndex &index) const;
DynamicElementTextItem *textFromItem(QStandardItem *item) const; DynamicElementTextItem *textFromItem(QStandardItem *item) const;
QModelIndex indexFromText(DynamicElementTextItem *text) const; QModelIndex indexFromText(DynamicElementTextItem *text) const;
QUndoCommand *undoForEditedText(DynamicElementTextItem *deti, QUndoCommand *parent_undo = nullptr) const; QUndoCommand *undoForEditedText(
QUndoCommand *undoForEditedGroup(ElementTextItemGroup *group, QUndoCommand *parent_undo = nullptr) const; DynamicElementTextItem *deti,
QUndoCommand *parent_undo = nullptr) const;
QUndoCommand *undoForEditedGroup(
ElementTextItemGroup *group,
QUndoCommand *parent_undo = nullptr) const;
ElementTextItemGroup *groupFromIndex(const QModelIndex &index) const; ElementTextItemGroup *groupFromIndex(const QModelIndex &index) const;
ElementTextItemGroup *groupFromItem(QStandardItem *item) const; ElementTextItemGroup *groupFromItem(QStandardItem *item) const;
@@ -75,8 +79,16 @@ class DynamicElementTextModel : public QStandardItemModel
bool indexIsText(const QModelIndex &index) const; bool indexIsText(const QModelIndex &index) const;
bool indexIsGroup(const QModelIndex &index) const; bool indexIsGroup(const QModelIndex &index) const;
bool canDropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) const override; bool canDropMimeData(const QMimeData *data,
bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override; Qt::DropAction action,
int row,
int column,
const QModelIndex &parent) const override;
bool dropMimeData(const QMimeData *data,
Qt::DropAction action,
int row,
int column,
const QModelIndex &parent) override;
QMimeData *mimeData(const QModelIndexList &indexes) const override; QMimeData *mimeData(const QModelIndexList &indexes) const override;
QStringList mimeTypes() const override; QStringList mimeTypes() const override;
@@ -89,22 +101,29 @@ class DynamicElementTextModel : public QStandardItemModel
void removeText(DynamicElementTextItem *deti); void removeText(DynamicElementTextItem *deti);
void addGroup(ElementTextItemGroup *group); void addGroup(ElementTextItemGroup *group);
void removeGroup(ElementTextItemGroup *group); void removeGroup(ElementTextItemGroup *group);
void addTextToGroup(DynamicElementTextItem *deti, ElementTextItemGroup *group); void addTextToGroup(DynamicElementTextItem *deti,
void removeTextFromGroup(DynamicElementTextItem *deti, ElementTextItemGroup *group); ElementTextItemGroup *group);
void enableSourceText(DynamicElementTextItem *deti, DynamicElementTextItem::TextFrom tf ); void removeTextFromGroup(DynamicElementTextItem *deti,
ElementTextItemGroup *group);
void enableSourceText(DynamicElementTextItem *deti,
DynamicElementTextItem::TextFrom tf );
void enableGroupRotationAndPos(ElementTextItemGroup *group); void enableGroupRotationAndPos(ElementTextItemGroup *group);
void itemDataChanged(QStandardItem *qsi); void itemDataChanged(QStandardItem *qsi);
void setConnection(DynamicElementTextItem *deti, bool set); void setConnection(DynamicElementTextItem *deti, bool set);
void setConnection(ElementTextItemGroup *group, bool set); void setConnection(ElementTextItemGroup *group, bool set);
void updateDataFromText(DynamicElementTextItem *deti, DynamicElementTextModel::ValueType type); void updateDataFromText(DynamicElementTextItem *deti,
void updateDataFromGroup(ElementTextItemGroup *group, DynamicElementTextModel::ValueType type); DynamicElementTextModel::ValueType type);
void updateDataFromGroup(ElementTextItemGroup *group,
DynamicElementTextModel::ValueType type);
private: private:
QPointer<Element> m_element; QPointer<Element> m_element;
QHash <DynamicElementTextItem *, QStandardItem *> m_texts_list; QHash <DynamicElementTextItem *, QStandardItem *> m_texts_list;
QHash <ElementTextItemGroup *, QStandardItem *> m_groups_list; QHash <ElementTextItemGroup *, QStandardItem *> m_groups_list;
QHash <DynamicElementTextItem *, QList<QMetaObject::Connection>> m_hash_text_connect; QHash <DynamicElementTextItem *,
QHash <ElementTextItemGroup *, QList<QMetaObject::Connection>> m_hash_group_connect; QList<QMetaObject::Connection>> m_hash_text_connect;
QHash <ElementTextItemGroup *,
QList<QMetaObject::Connection>> m_hash_group_connect;
bool m_block_dataChanged = false; bool m_block_dataChanged = false;
}; };
@@ -115,8 +134,12 @@ class DynamicTextItemDelegate : public QStyledItemDelegate
public: public:
DynamicTextItemDelegate(QObject *parent = Q_NULLPTR); DynamicTextItemDelegate(QObject *parent = Q_NULLPTR);
QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const override; QWidget *createEditor(QWidget *parent,
void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const override; const QStyleOptionViewItem &option,
const QModelIndex &index) const override;
void setModelData(QWidget *editor,
QAbstractItemModel *model,
const QModelIndex &index) const override;
protected: protected:
bool eventFilter(QObject *object, QEvent *event) override; bool eventFilter(QObject *object, QEvent *event) override;

View File

@@ -41,15 +41,25 @@ class NewConductorPotentialSelector : public AbstractPotentialSelector
{ {
Terminal *terminal_1 = conductor->terminal1; Terminal *terminal_1 = conductor->terminal1;
Terminal *terminal_2 = conductor->terminal2; Terminal *terminal_2 = conductor->terminal2;
//We temporarily remove the conductor of his two terminals, to get the two existing potential //We temporarily remove the conductor of his two terminals,
//to get the two existing potential
terminal_1->removeConductor(conductor); terminal_1->removeConductor(conductor);
terminal_2->removeConductor(conductor); terminal_2->removeConductor(conductor);
getPotential(terminal_1, m_seq_num_1, m_conductor_number_1, m_properties_list_1, m_conductors_list_1); getPotential(terminal_1,
getPotential(terminal_2, m_seq_num_2, m_conductor_number_2, m_properties_list_2, m_conductors_list_2); m_seq_num_1,
m_conductor_number_1,
m_properties_list_1,
m_conductors_list_1);
getPotential(terminal_2,
m_seq_num_2,
m_conductor_number_2,
m_properties_list_2,
m_conductors_list_2);
//There isn't a potential at terminal 1 or 2. //There isn't a potential at terminal 1 or 2.
if (m_conductor_number_1 == 0 && m_conductor_number_2 == 0) return; if (m_conductor_number_1 == 0
&& m_conductor_number_2 == 0) return;
//Re-add conductor to his terminals. //Re-add conductor to his terminals.
terminal_1->addConductor(conductor); terminal_1->addConductor(conductor);
@@ -69,7 +79,11 @@ class NewConductorPotentialSelector : public AbstractPotentialSelector
@param properties_list @param properties_list
@param c_list @param c_list
*/ */
void getPotential(Terminal *terminal, autonum::sequentialNumbers &seq_num , int &number, QList<ConductorProperties> &properties_list, QList<Conductor*> &c_list) void getPotential(
Terminal *terminal,
autonum::sequentialNumbers &seq_num ,
int &number, QList<ConductorProperties> &properties_list,
QList<Conductor*> &c_list)
{ {
Conductor *conductor_in_potential = nullptr; Conductor *conductor_in_potential = nullptr;
@@ -105,7 +119,8 @@ class NewConductorPotentialSelector : public AbstractPotentialSelector
if (!conductor_in_potential) if (!conductor_in_potential)
return; return;
seq_num = conductor_in_potential->sequenceNum(); seq_num = conductor_in_potential->sequenceNum();
number = conductor_in_potential->relatedPotentialConductors().size()+1; //We add +1 because conductor_in_potential isn't count by relatedPotentialConductors //We add +1 because conductor_in_potential isn't count by relatedPotentialConductors
number = conductor_in_potential->relatedPotentialConductors().size()+1;
c_list = conductor_in_potential->relatedPotentialConductors().values(); c_list = conductor_in_potential->relatedPotentialConductors().values();
c_list.append(conductor_in_potential); c_list.append(conductor_in_potential);