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);
}
QList<CustomElementPart*> ArcEditor::currentParts() const {
return style_->currentParts();
}
/**
* @brief ArcEditor::updateArcS
* Update the start angle of the arc according to the edited value.

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -51,6 +51,7 @@ class LineEditor : public ElementItemEditor
public:
bool setPart(CustomElementPart *) override;
CustomElementPart *currentPart() const override;
QList<CustomElementPart*> currentParts() const override;
QPointF editedP1() 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))
{
part = part_graphic;
m_cep_list.append(part_graphic);
updateForm();
return(true);
}
@@ -538,6 +539,10 @@ CustomElementPart *StyleEditor::currentPart() const {
return(part);
}
QList<CustomElementPart*> StyleEditor::currentParts() const {
return m_cep_list;
}
/**
* @brief StyleEditor::isStyleEditable
* @param cep_list

View File

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

View File

@@ -153,6 +153,14 @@ CustomElementPart *TerminalEditor::currentPart() const {
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
void TerminalEditor::updateTerminalO()
{

View File

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

View File

@@ -30,7 +30,7 @@
#include <QColorDialog>
DynamicTextFieldEditor::DynamicTextFieldEditor(QETElementEditor *editor, PartDynamicTextField *text_field, QWidget *parent) :
ElementItemEditor(editor, parent),
ElementItemEditor(editor, parent),
ui(new Ui::DynamicTextFieldEditor)
{
ui->setupUi(this);
@@ -113,6 +113,14 @@ CustomElementPart *DynamicTextFieldEditor::currentPart() const {
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()
{
if(m_text_field)

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -28,7 +28,7 @@
* @param parent : the parent widget
*/
TextEditor::TextEditor(QETElementEditor *editor, PartText *text, QWidget *parent) :
ElementItemEditor(editor, parent),
ElementItemEditor(editor, parent),
ui(new Ui::TextEditor)
{
ui->setupUi(this);
@@ -164,6 +164,14 @@ CustomElementPart *TextEditor::currentPart() const {
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
* 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 setParts(QList <CustomElementPart *>) override;
CustomElementPart *currentPart() const override;
QList<CustomElementPart*> currentParts() const override;
private slots:
void on_m_font_pb_clicked();