implement currentParts() for every elementItemEditor so the editor can be extended to multi part edit in a later step

This commit is contained in:
Martin Marmsoler
2020-06-01 20:45:01 +02:00
committed by Laurent Trinques
parent 1ccffda93b
commit e36a4ddd0a
19 changed files with 62 additions and 3 deletions

View File

@@ -128,6 +128,10 @@ CustomElementPart *ArcEditor::currentPart() const {
return(part); return(part);
} }
QList<CustomElementPart*> ArcEditor::currentParts() const {
return style_->currentParts();
}
/** /**
* @brief ArcEditor::updateArcS * @brief ArcEditor::updateArcS
* Update the start angle of the arc according to the edited value. * Update the start angle of the arc according to the edited value.

View File

@@ -51,6 +51,7 @@ class ArcEditor : public ElementItemEditor
public: public:
bool setPart(CustomElementPart *) override; bool setPart(CustomElementPart *) override;
CustomElementPart *currentPart() const override; CustomElementPart *currentPart() const override;
QList<CustomElementPart*> currentParts() const override;
public slots: public slots:
void updateArcS(); void updateArcS();

View File

@@ -54,6 +54,7 @@ class ElementItemEditor : public QWidget
virtual bool setParts(QList <CustomElementPart *>) {return false;} virtual bool setParts(QList <CustomElementPart *>) {return false;}
virtual CustomElementPart *currentPart() const = 0; virtual CustomElementPart *currentPart() const = 0;
virtual QList<CustomElementPart*> currentParts() const = 0;
virtual void updateForm() = 0; virtual void updateForm() = 0;
// attributes // attributes

View File

@@ -109,6 +109,10 @@ CustomElementPart *EllipseEditor::currentPart() const {
return(part); return(part);
} }
QList<CustomElementPart*> EllipseEditor::currentParts() const {
return style_->currentParts();
}
void EllipseEditor::editingFinished() void EllipseEditor::editingFinished()
{ {
if (m_locked) return; if (m_locked) return;

View File

@@ -49,6 +49,7 @@ class EllipseEditor : public ElementItemEditor
public: public:
bool setPart(CustomElementPart *) override; bool setPart(CustomElementPart *) override;
CustomElementPart *currentPart() const override; CustomElementPart *currentPart() const override;
QList<CustomElementPart*> currentParts() const override;
public slots: public slots:
void editingFinished(); void editingFinished();

View File

@@ -146,6 +146,10 @@ CustomElementPart *LineEditor::currentPart() const {
return(part); return(part);
} }
QList<CustomElementPart*> LineEditor::currentParts() const {
return style_->currentParts();
}
/** /**
* @brief LineEditor::editedP1 * @brief LineEditor::editedP1
* @return The edited P1 in item coordinate * @return The edited P1 in item coordinate

View File

@@ -51,6 +51,7 @@ class LineEditor : public ElementItemEditor
public: public:
bool setPart(CustomElementPart *) override; bool setPart(CustomElementPart *) override;
CustomElementPart *currentPart() const override; CustomElementPart *currentPart() const override;
QList<CustomElementPart*> currentParts() const override;
QPointF editedP1() const; QPointF editedP1() const;
QPointF editedP2() const; QPointF editedP2() const;

View File

@@ -489,6 +489,7 @@ bool StyleEditor::setPart(CustomElementPart *new_part) {
if (CustomElementGraphicPart *part_graphic = dynamic_cast<CustomElementGraphicPart *>(new_part)) if (CustomElementGraphicPart *part_graphic = dynamic_cast<CustomElementGraphicPart *>(new_part))
{ {
part = part_graphic; part = part_graphic;
m_cep_list.append(part_graphic);
updateForm(); updateForm();
return(true); return(true);
} }
@@ -538,6 +539,10 @@ CustomElementPart *StyleEditor::currentPart() const {
return(part); return(part);
} }
QList<CustomElementPart*> StyleEditor::currentParts() const {
return m_cep_list;
}
/** /**
* @brief StyleEditor::isStyleEditable * @brief StyleEditor::isStyleEditable
* @param cep_list * @param cep_list

View File

@@ -53,8 +53,9 @@ class StyleEditor : public ElementItemEditor
// methods // methods
public: public:
bool setPart(CustomElementPart *) override; bool setPart(CustomElementPart *) override;
bool setParts(QList<CustomElementPart *>) override; bool setParts(QList<CustomElementPart *>);
CustomElementPart *currentPart() const override; CustomElementPart *currentPart() const override;
QList<CustomElementPart*> currentParts() const override;
static bool isStyleEditable (QList <CustomElementPart *> cep_list); static bool isStyleEditable (QList <CustomElementPart *> cep_list);

View File

@@ -153,6 +153,14 @@ CustomElementPart *TerminalEditor::currentPart() const {
return(m_part); return(m_part);
} }
QList<CustomElementPart*> TerminalEditor::currentParts() const {
QList<CustomElementPart*> parts;
for (auto term: m_terminals) {
parts.append(static_cast<CustomElementPart*>(term));
}
return parts;
}
/// Met a jour l'orientation de la borne et cree un objet d'annulation /// Met a jour l'orientation de la borne et cree un objet d'annulation
void TerminalEditor::updateTerminalO() void TerminalEditor::updateTerminalO()
{ {

View File

@@ -55,6 +55,7 @@ class TerminalEditor : public ElementItemEditor {
bool setPart(CustomElementPart *) override; bool setPart(CustomElementPart *) override;
bool setParts(QList<CustomElementPart *> parts) override; bool setParts(QList<CustomElementPart *> parts) override;
CustomElementPart *currentPart() const override; CustomElementPart *currentPart() const override;
QList<CustomElementPart*> currentParts() const override;
public slots: public slots:
void updateTerminalO(); void updateTerminalO();

View File

@@ -30,7 +30,7 @@
#include <QColorDialog> #include <QColorDialog>
DynamicTextFieldEditor::DynamicTextFieldEditor(QETElementEditor *editor, PartDynamicTextField *text_field, QWidget *parent) : DynamicTextFieldEditor::DynamicTextFieldEditor(QETElementEditor *editor, PartDynamicTextField *text_field, QWidget *parent) :
ElementItemEditor(editor, parent), ElementItemEditor(editor, parent),
ui(new Ui::DynamicTextFieldEditor) ui(new Ui::DynamicTextFieldEditor)
{ {
ui->setupUi(this); ui->setupUi(this);
@@ -113,6 +113,14 @@ CustomElementPart *DynamicTextFieldEditor::currentPart() const {
return m_text_field.data(); return m_text_field.data();
} }
QList<CustomElementPart*> DynamicTextFieldEditor::currentParts() const {
QList<CustomElementPart*> parts;
for (auto part: m_parts) {
parts.append(static_cast<CustomElementPart*>(part));
}
return parts;
}
void DynamicTextFieldEditor::updateForm() void DynamicTextFieldEditor::updateForm()
{ {
if(m_text_field) if(m_text_field)

View File

@@ -40,6 +40,7 @@ class DynamicTextFieldEditor : public ElementItemEditor
bool setPart(CustomElementPart *part) override; bool setPart(CustomElementPart *part) override;
bool setParts(QList <CustomElementPart *>) override; bool setParts(QList <CustomElementPart *>) override;
CustomElementPart *currentPart() const override; CustomElementPart *currentPart() const override;
QList<CustomElementPart*> currentParts() const override;
void updateForm() override; void updateForm() override;
private: private:

View File

@@ -98,6 +98,10 @@ CustomElementPart *PolygonEditor::currentPart() const {
return m_part; return m_part;
} }
QList<CustomElementPart*> PolygonEditor::currentParts() const {
return m_style->currentParts();
}
/** /**
* @brief PolygonEditor::updateForm * @brief PolygonEditor::updateForm
* Update the widget * Update the widget

View File

@@ -38,6 +38,7 @@ class PolygonEditor : public ElementItemEditor
bool setPart(CustomElementPart *part) override; bool setPart(CustomElementPart *part) override;
CustomElementPart *currentPart() const override; CustomElementPart *currentPart() const override;
QList<CustomElementPart*> currentParts() const override;
void updateForm() override; void updateForm() override;
QVector<QPointF> pointsFromTree(); QVector<QPointF> pointsFromTree();
bool eventFilter(QObject *watched, QEvent *event) override; bool eventFilter(QObject *watched, QEvent *event) override;

View File

@@ -103,6 +103,10 @@ CustomElementPart *RectangleEditor::currentPart() const {
return m_part; return m_part;
} }
QList<CustomElementPart*> RectangleEditor::currentParts() const {
return m_style->currentParts();
}
/** /**
* @brief RectangleEditor::topLeft * @brief RectangleEditor::topLeft
* @return The edited topLeft already mapped to part coordinate * @return The edited topLeft already mapped to part coordinate

View File

@@ -42,6 +42,7 @@ class RectangleEditor : public ElementItemEditor
bool setPart(CustomElementPart *part) override; bool setPart(CustomElementPart *part) override;
CustomElementPart *currentPart() const override; CustomElementPart *currentPart() const override;
QList<CustomElementPart*> currentParts() const override;
QPointF editedTopLeft () const; QPointF editedTopLeft () const;
public slots: public slots:

View File

@@ -28,7 +28,7 @@
* @param parent : the parent widget * @param parent : the parent widget
*/ */
TextEditor::TextEditor(QETElementEditor *editor, PartText *text, QWidget *parent) : TextEditor::TextEditor(QETElementEditor *editor, PartText *text, QWidget *parent) :
ElementItemEditor(editor, parent), ElementItemEditor(editor, parent),
ui(new Ui::TextEditor) ui(new Ui::TextEditor)
{ {
ui->setupUi(this); ui->setupUi(this);
@@ -164,6 +164,14 @@ CustomElementPart *TextEditor::currentPart() const {
return m_text; return m_text;
} }
QList<CustomElementPart*> TextEditor::currentParts() const {
QList<CustomElementPart*> parts;
for (auto part: m_parts) {
parts.append(static_cast<CustomElementPart*>(part));
}
return parts;
}
/** /**
* @brief TextEditor::setUpEditConnection * @brief TextEditor::setUpEditConnection
* Setup the connection between the widgets of this editor and the undo command * Setup the connection between the widgets of this editor and the undo command

View File

@@ -41,6 +41,7 @@ class TextEditor : public ElementItemEditor
bool setPart(CustomElementPart *part) override; bool setPart(CustomElementPart *part) override;
bool setParts(QList <CustomElementPart *>) override; bool setParts(QList <CustomElementPart *>) override;
CustomElementPart *currentPart() const override; CustomElementPart *currentPart() const override;
QList<CustomElementPart*> currentParts() const override;
private slots: private slots:
void on_m_font_pb_clicked(); void on_m_font_pb_clicked();