From 182becb31b4ce9815cb4828ff92482f070899fcc Mon Sep 17 00:00:00 2001 From: "Marcel M. Otte" Date: Mon, 4 Jan 2016 21:58:51 +0100 Subject: [PATCH] working on implementation --- src/editor/abstractguidededitormodel.h | 4 +++ src/editor/guidededitorelement.cpp | 2 +- src/editor/guidededitorelement.h | 2 +- src/editor/guidededitorelementview.cpp | 44 +++++++++++++++++++++++--- src/editor/guidededitorelementview.h | 13 ++++---- src/editor/guidededitorlayer.h | 2 +- src/editor/guidededitorview.cpp | 15 +++++---- src/editor/guidededitorview.h | 4 +-- 8 files changed, 62 insertions(+), 24 deletions(-) diff --git a/src/editor/abstractguidededitormodel.h b/src/editor/abstractguidededitormodel.h index e0543b6..5e0756c 100644 --- a/src/editor/abstractguidededitormodel.h +++ b/src/editor/abstractguidededitormodel.h @@ -3,6 +3,8 @@ #include #include +#include +#include #include "guidededitorelement.h" class AbstractGuidedEditorModel : public QObject @@ -16,6 +18,8 @@ public: virtual GuidedEditorElement& getElement(uint index) = 0; virtual void setElementValue(const uint index, const QString value)= 0; + virtual const std::list& getAllElements() = 0; + signals: void dataChanged(); void dataChanged(uint index); diff --git a/src/editor/guidededitorelement.cpp b/src/editor/guidededitorelement.cpp index 5e5e370..935bf3c 100644 --- a/src/editor/guidededitorelement.cpp +++ b/src/editor/guidededitorelement.cpp @@ -1,7 +1,7 @@ #include "guidededitorelement.h" #include -GuidedEditorElement::GuidedEditorElement(QObject *parent) : QObject(parent) +GuidedEditorElement::GuidedEditorElement() { } diff --git a/src/editor/guidededitorelement.h b/src/editor/guidededitorelement.h index 0aa0cc5..b62a19d 100644 --- a/src/editor/guidededitorelement.h +++ b/src/editor/guidededitorelement.h @@ -14,7 +14,7 @@ class GuidedEditorElement : public QObject public: - explicit GuidedEditorElement(QObject *parent = 0); + explicit GuidedEditorElement(); ~GuidedEditorElement(); QString getTitle() const; diff --git a/src/editor/guidededitorelementview.cpp b/src/editor/guidededitorelementview.cpp index f4e59ca..6cfca84 100644 --- a/src/editor/guidededitorelementview.cpp +++ b/src/editor/guidededitorelementview.cpp @@ -1,17 +1,51 @@ #include "guidededitorelementview.h" -GuidedEditorElementView::GuidedEditorElementView(QWidget *parent) : QWidget(parent) -{ +#include +#include +#include +GuidedEditorElementView::GuidedEditorElementView(QWidget* parent) + : QWidget(parent) +{ + this->layout = std::make_unique(this); + this->title = std::make_unique(this); + this->description = std::make_unique(); + this->example = std::make_unique(this); + + this->setLayout(layout.get()); + this->layout->addWidget(title.get()); + this->layout->addWidget(example.get()); } -void GuidedEditorElementView::setElement() +void GuidedEditorElementView::setElement(GuidedEditorElement& element) { + // set title + this->title->setText(element.getTitle()); + // put description somewhere + this->description = std::make_unique(element.getDescription()); + // set example + this->example->setText(element.getExample()); + // set input/static part + switch (element.getType()) { + case ElementType::CHOOSER: + this->combobox = std::make_unique(this); + //TODO: data for the combobox ?! + this->layout->addWidget(combobox.get()); + break; + case ElementType::INPUT: + this->input = std::make_unique(this); + this->layout->addWidget(input.get()); + this->input->setValidator(std::make_shared(element.getSyntaxregex(), input.get()).get()); + break; + case ElementType::STATIC: + this->staticLabel = std::make_unique(this); + this->layout->addWidget(staticLabel.get()); + this->staticLabel->setText(element.getValue()); + break; + } } void GuidedEditorElementView::dataChanged() { - } - diff --git a/src/editor/guidededitorelementview.h b/src/editor/guidededitorelementview.h index 4ad5a7f..3b81410 100644 --- a/src/editor/guidededitorelementview.h +++ b/src/editor/guidededitorelementview.h @@ -4,10 +4,11 @@ #include #include #include -#include +#include #include #include +#include "guidededitorelement.h" #include "guidededitorlayer.h" @@ -15,11 +16,8 @@ class GuidedEditorElementView : public QWidget { Q_OBJECT public: - explicit GuidedEditorElementView(QWidget *parent = 0); - //explicit GuidedEditorElementView( QWidget *parent = 0); - - void setElement(); - + explicit GuidedEditorElementView(QWidget *parent = 0); + void setElement(GuidedEditorElement& element); signals: void inputChanged(); @@ -29,7 +27,7 @@ public slots: private: // layout - std::unique_ptr layout; + std::unique_ptr layout; // widget container //? // title label @@ -41,6 +39,7 @@ private: // input field based on element type std::unique_ptr input; std::unique_ptr combobox; + std::unique_ptr staticLabel; // layer information std::shared_ptr layer; diff --git a/src/editor/guidededitorlayer.h b/src/editor/guidededitorlayer.h index 6354d01..5354cb4 100644 --- a/src/editor/guidededitorlayer.h +++ b/src/editor/guidededitorlayer.h @@ -16,7 +16,7 @@ public: void setTitle(const QString &value); QColor getColor() const; - void setColor(const QColor &value); + void setColor(const QColor &value); private: QString title; diff --git a/src/editor/guidededitorview.cpp b/src/editor/guidededitorview.cpp index 93eb34e..59ce08d 100644 --- a/src/editor/guidededitorview.cpp +++ b/src/editor/guidededitorview.cpp @@ -1,9 +1,11 @@ +#include + #include "guidededitorview.h" #include "guidededitorelementview.h" GuidedEditorView::GuidedEditorView(QWidget* parent) : QWidget(parent) { - editorLayout = new FlowLayout(this); - this->setLayout(editorLayout); + editorLayout = std::make_shared(this); + this->setLayout(editorLayout.get()); // tests QString style = QString( "QWidget {" @@ -19,10 +21,9 @@ GuidedEditorView::GuidedEditorView(QWidget* parent) : QWidget(parent) { GuidedEditorView::GuidedEditorView( std::shared_ptr model, QWidget* parent) - : GuidedEditorView(parent) {} + : GuidedEditorView(parent) +{ + this->model = model; +} GuidedEditorView::~GuidedEditorView() {} - -void GuidedEditorView::addElement() { - this->editorLayout->addWidget(new GuidedEditorElementView()); -} diff --git a/src/editor/guidededitorview.h b/src/editor/guidededitorview.h index 4814258..a008a9e 100644 --- a/src/editor/guidededitorview.h +++ b/src/editor/guidededitorview.h @@ -18,10 +18,10 @@ public: signals: public slots: - void addElement(); private: - FlowLayout* editorLayout; + std::shared_ptr editorLayout; + std::shared_ptr model; }; #endif // GUIDEDEDITOR_H