diff --git a/src/editor/guidededitorelementview.cpp b/src/editor/guidededitorelementview.cpp index 4ddfc13..3c58425 100644 --- a/src/editor/guidededitorelementview.cpp +++ b/src/editor/guidededitorelementview.cpp @@ -11,50 +11,50 @@ 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->layout = new QVBoxLayout(this); + this->title = new QLabel(this); + this->description = new QString(); + this->example = new QLabel(this); - this->setLayout(layout.get()); - this->layout->addWidget(title.get()); - this->layout->addWidget(example.get()); + this->setLayout(layout); + this->layout->addWidget(title); + this->layout->addWidget(example); } -void GuidedEditorElementView::setElement(std::shared_ptr element) +void GuidedEditorElementView::setElement(GuidedEditorElement* element) { std::cout<<"adding element " << element <title->setText("testtitle"); - this->description = std::make_unique("test description"); + this->description = new QString("test description"); this->example->setText("test example"); - this->input = std::make_unique(this); - this->layout->addWidget(input.get()); + this->input = new QLineEdit(this); + this->layout->addWidget(input); this->update(); return; } // set title this->title->setText(element->getTitle()); // put description somewhere - this->description = std::make_unique(element->getDescription()); + this->description = new QString(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); + this->combobox = new QComboBox(this); //TODO: data for the combobox ?! - this->layout->addWidget(combobox.get()); + this->layout->addWidget(combobox); break; case ElementType::INPUT: - this->input = std::make_unique(this); - this->layout->addWidget(input.get()); + this->input = new QLineEdit(this); + this->layout->addWidget(input); - this->input->setValidator(std::make_shared(QRegExp(element->getSyntaxregex())).get()); + this->input->setValidator(new QRegExpValidator(QRegExp(element->getSyntaxregex()))); break; case ElementType::STATIC: - this->staticLabel = std::make_unique(this); - this->layout->addWidget(staticLabel.get()); + this->staticLabel = new QLabel(this); + this->layout->addWidget(staticLabel); this->staticLabel->setText(element->getValue()); break; } diff --git a/src/editor/guidededitorelementview.h b/src/editor/guidededitorelementview.h index f99b07a..5f00e25 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(std::shared_ptr element); + void setElement(GuidedEditorElement* element); signals: void inputChanged(); @@ -27,21 +27,21 @@ public slots: private: // layout - std::unique_ptr layout; + QVBoxLayout* layout; // widget container //? // title label - std::unique_ptr title; + QLabel* title; // example/regex label - std::unique_ptr example; + QLabel* example; // mouseover description? - std::unique_ptr description; + QString* description; // input field based on element type - std::unique_ptr input; - std::unique_ptr combobox; - std::unique_ptr staticLabel; + QLineEdit* input; + QComboBox* combobox; + QLabel* staticLabel; // layer information - std::shared_ptr layer; + GuidedEditorLayer* layer; }; diff --git a/src/editor/guidededitorview.cpp b/src/editor/guidededitorview.cpp index c347662..7626c18 100644 --- a/src/editor/guidededitorview.cpp +++ b/src/editor/guidededitorview.cpp @@ -6,8 +6,8 @@ #include "guidededitorelementview.h" GuidedEditorView::GuidedEditorView(QWidget* parent) : QWidget(parent) { - editorLayout = std::make_shared(this); - this->setLayout(editorLayout.get()); + editorLayout = new FlowLayout(this); + this->setLayout(editorLayout); // tests QString style = QString( "QWidget {" @@ -22,7 +22,7 @@ GuidedEditorView::GuidedEditorView(QWidget* parent) : QWidget(parent) { } GuidedEditorView::GuidedEditorView( - std::shared_ptr model, + AbstractGuidedEditorModel* model, QWidget* parent) : GuidedEditorView(parent) { @@ -31,11 +31,11 @@ GuidedEditorView::GuidedEditorView( GuidedEditorView::~GuidedEditorView() {} -void GuidedEditorView::addElement(std::shared_ptr element) +void GuidedEditorView::addElement(GuidedEditorElement* element) { std::cout << "adding elementview from element " << element < elementView = std::make_shared(this); + GuidedEditorElementView* elementView = new GuidedEditorElementView(this); elementView->setElement(element); - this->layout()->addWidget(elementView.get()); + this->layout()->addWidget(elementView); //this->update(); } diff --git a/src/editor/guidededitorview.h b/src/editor/guidededitorview.h index 881cdc4..10624d3 100644 --- a/src/editor/guidededitorview.h +++ b/src/editor/guidededitorview.h @@ -11,18 +11,18 @@ class GuidedEditorView : public QWidget { Q_OBJECT public: explicit GuidedEditorView(QWidget* parent = 0); - GuidedEditorView(std::shared_ptr model, + GuidedEditorView(AbstractGuidedEditorModel* model, QWidget* parent = 0); ~GuidedEditorView(); signals: public slots: - void addElement(std::shared_ptr element); + void addElement(GuidedEditorElement* element); private: - std::shared_ptr editorLayout; - std::shared_ptr model; + FlowLayout* editorLayout; + AbstractGuidedEditorModel* model; }; #endif // GUIDEDEDITOR_H diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index bb241a8..41aa565 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -12,15 +12,15 @@ void MainWindow::doSomething() MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { - editor = std::make_shared(this); - this->setCentralWidget(editor.get()); - dockWidget = std::make_shared(this); - this->addDockWidget(Qt::LeftDockWidgetArea, dockWidget.get()); + editor = new GuidedEditorView(this); + this->setCentralWidget(editor); + dockWidget = new QDockWidget(this); + this->addDockWidget(Qt::LeftDockWidgetArea, dockWidget); // dockwidget - QVBoxLayout* dockLayout = new QVBoxLayout(dockWidget.get()); + QVBoxLayout* dockLayout = new QVBoxLayout(dockWidget); dockWidget->setLayout(dockLayout); - QPushButton* button = new QPushButton(dockWidget.get()); + QPushButton* button = new QPushButton(dockWidget); button->setText("add"); dockLayout->addWidget(button); this->connect(button, &QPushButton::pressed,this, &MainWindow::doSomething); diff --git a/src/mainwindow.h b/src/mainwindow.h index 1c4e134..729540e 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -13,8 +13,8 @@ class MainWindow : public QMainWindow { Q_OBJECT private: - std::shared_ptr editor; - std::shared_ptr dockWidget; + GuidedEditorView* editor; + QDockWidget* dockWidget; public slots: void doSomething();