From 4604df013f02f61203cf9887fccb6baec83f345d Mon Sep 17 00:00:00 2001 From: Marcel Otte Date: Sun, 10 Jan 2016 21:39:26 +0100 Subject: [PATCH] latest changes --- src/editor/guidededitorelementview.cpp | 26 +++++++++++++++++++------- src/editor/guidededitorelementview.h | 2 +- src/editor/guidededitorview.cpp | 12 ++++++++++++ src/editor/guidededitorview.h | 1 + src/mainwindow.cpp | 10 +++++++++- src/mainwindow.h | 2 ++ 6 files changed, 44 insertions(+), 9 deletions(-) diff --git a/src/editor/guidededitorelementview.cpp b/src/editor/guidededitorelementview.cpp index c2ffffa..4ddfc13 100644 --- a/src/editor/guidededitorelementview.cpp +++ b/src/editor/guidededitorelementview.cpp @@ -6,6 +6,8 @@ #include #include +#include + GuidedEditorElementView::GuidedEditorElementView(QWidget* parent) : QWidget(parent) { @@ -19,16 +21,26 @@ GuidedEditorElementView::GuidedEditorElementView(QWidget* parent) this->layout->addWidget(example.get()); } -void GuidedEditorElementView::setElement(GuidedEditorElement& element) +void GuidedEditorElementView::setElement(std::shared_ptr element) { + std::cout<<"adding element " << element <title->setText("testtitle"); + this->description = std::make_unique("test description"); + this->example->setText("test example"); + this->input = std::make_unique(this); + this->layout->addWidget(input.get()); + this->update(); + return; + } // set title - this->title->setText(element.getTitle()); + this->title->setText(element->getTitle()); // put description somewhere - this->description = std::make_unique(element.getDescription()); + this->description = std::make_unique(element->getDescription()); // set example - this->example->setText(element.getExample()); + this->example->setText(element->getExample()); // set input/static part - switch (element.getType()) { + switch (element->getType()) { case ElementType::CHOOSER: this->combobox = std::make_unique(this); //TODO: data for the combobox ?! @@ -38,12 +50,12 @@ void GuidedEditorElementView::setElement(GuidedEditorElement& element) this->input = std::make_unique(this); this->layout->addWidget(input.get()); - this->input->setValidator(std::make_shared(QRegExp(element.getSyntaxregex())).get()); + this->input->setValidator(std::make_shared(QRegExp(element->getSyntaxregex())).get()); break; case ElementType::STATIC: this->staticLabel = std::make_unique(this); this->layout->addWidget(staticLabel.get()); - this->staticLabel->setText(element.getValue()); + this->staticLabel->setText(element->getValue()); break; } diff --git a/src/editor/guidededitorelementview.h b/src/editor/guidededitorelementview.h index 3b81410..f99b07a 100644 --- a/src/editor/guidededitorelementview.h +++ b/src/editor/guidededitorelementview.h @@ -17,7 +17,7 @@ class GuidedEditorElementView : public QWidget Q_OBJECT public: explicit GuidedEditorElementView(QWidget *parent = 0); - void setElement(GuidedEditorElement& element); + void setElement(std::shared_ptr element); signals: void inputChanged(); diff --git a/src/editor/guidededitorview.cpp b/src/editor/guidededitorview.cpp index 59ce08d..c347662 100644 --- a/src/editor/guidededitorview.cpp +++ b/src/editor/guidededitorview.cpp @@ -1,5 +1,7 @@ #include +#include + #include "guidededitorview.h" #include "guidededitorelementview.h" @@ -16,6 +18,7 @@ GuidedEditorView::GuidedEditorView(QWidget* parent) : QWidget(parent) { "QLineEdit {border: 2px dashed black;background: dark-gray;" "border-radius: 5px;}"); this->setStyleSheet(style); + this->addElement(nullptr); } GuidedEditorView::GuidedEditorView( @@ -27,3 +30,12 @@ GuidedEditorView::GuidedEditorView( } GuidedEditorView::~GuidedEditorView() {} + +void GuidedEditorView::addElement(std::shared_ptr element) +{ + std::cout << "adding elementview from element " << element < elementView = std::make_shared(this); + elementView->setElement(element); + this->layout()->addWidget(elementView.get()); + //this->update(); +} diff --git a/src/editor/guidededitorview.h b/src/editor/guidededitorview.h index a008a9e..881cdc4 100644 --- a/src/editor/guidededitorview.h +++ b/src/editor/guidededitorview.h @@ -18,6 +18,7 @@ public: signals: public slots: + void addElement(std::shared_ptr element); private: std::shared_ptr editorLayout; diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 382e184..bb241a8 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -1,5 +1,13 @@ #include "mainwindow.h" #include +#include + +void MainWindow::doSomething() +{ + std::cout<<"sending nullptr"<editor->addElement(nullptr); + std::cout<<"sent nullptr"<setText("add"); dockLayout->addWidget(button); - //this->connect(button, &QPushButton::pressed,editor, &GuidedEditorView::addElement); + this->connect(button, &QPushButton::pressed,this, &MainWindow::doSomething); } diff --git a/src/mainwindow.h b/src/mainwindow.h index 5d0d87d..1c4e134 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -15,6 +15,8 @@ class MainWindow : public QMainWindow private: std::shared_ptr editor; std::shared_ptr dockWidget; +public slots: + void doSomething(); public: MainWindow(QWidget *parent = 0);