working on implementation
This commit is contained in:
parent
14605ac0cb
commit
182becb31b
|
@ -3,6 +3,8 @@
|
|||
|
||||
#include <cstdlib>
|
||||
#include <QObject>
|
||||
#include <memory>
|
||||
#include <list>
|
||||
#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<GuidedEditorElement>& getAllElements() = 0;
|
||||
|
||||
signals:
|
||||
void dataChanged();
|
||||
void dataChanged(uint index);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include "guidededitorelement.h"
|
||||
#include <QString>
|
||||
|
||||
GuidedEditorElement::GuidedEditorElement(QObject *parent) : QObject(parent)
|
||||
GuidedEditorElement::GuidedEditorElement()
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ class GuidedEditorElement : public QObject
|
|||
public:
|
||||
|
||||
|
||||
explicit GuidedEditorElement(QObject *parent = 0);
|
||||
explicit GuidedEditorElement();
|
||||
~GuidedEditorElement();
|
||||
|
||||
QString getTitle() const;
|
||||
|
|
|
@ -1,17 +1,51 @@
|
|||
#include "guidededitorelementview.h"
|
||||
|
||||
GuidedEditorElementView::GuidedEditorElementView(QWidget *parent) : QWidget(parent)
|
||||
{
|
||||
#include <memory>
|
||||
#include <QVBoxLayout>
|
||||
#include <QRegExpValidator>
|
||||
|
||||
GuidedEditorElementView::GuidedEditorElementView(QWidget* parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
this->layout = std::make_unique<QVBoxLayout>(this);
|
||||
this->title = std::make_unique<QLabel>(this);
|
||||
this->description = std::make_unique<QString>();
|
||||
this->example = std::make_unique<QLabel>(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<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<QComboBox>(this);
|
||||
//TODO: data for the combobox ?!
|
||||
this->layout->addWidget(combobox.get());
|
||||
break;
|
||||
case ElementType::INPUT:
|
||||
this->input = std::make_unique<QLineEdit>(this);
|
||||
this->layout->addWidget(input.get());
|
||||
this->input->setValidator(std::make_shared<QRegExpValidator>(element.getSyntaxregex(), input.get()).get());
|
||||
break;
|
||||
case ElementType::STATIC:
|
||||
this->staticLabel = std::make_unique<QLabel>(this);
|
||||
this->layout->addWidget(staticLabel.get());
|
||||
this->staticLabel->setText(element.getValue());
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void GuidedEditorElementView::dataChanged()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -4,10 +4,11 @@
|
|||
#include <QWidget>
|
||||
#include <QLabel>
|
||||
#include <QLineEdit>
|
||||
#include <QBoxLayout>
|
||||
#include <QVBoxLayout>
|
||||
#include <memory>
|
||||
#include <QComboBox>
|
||||
|
||||
#include "guidededitorelement.h"
|
||||
#include "guidededitorlayer.h"
|
||||
|
||||
|
||||
|
@ -16,10 +17,7 @@ class GuidedEditorElementView : public QWidget
|
|||
Q_OBJECT
|
||||
public:
|
||||
explicit GuidedEditorElementView(QWidget *parent = 0);
|
||||
//explicit GuidedEditorElementView( QWidget *parent = 0);
|
||||
|
||||
void setElement();
|
||||
|
||||
void setElement(GuidedEditorElement& element);
|
||||
|
||||
signals:
|
||||
void inputChanged();
|
||||
|
@ -29,7 +27,7 @@ public slots:
|
|||
|
||||
private:
|
||||
// layout
|
||||
std::unique_ptr<QBoxLayout> layout;
|
||||
std::unique_ptr<QVBoxLayout> layout;
|
||||
// widget container
|
||||
//?
|
||||
// title label
|
||||
|
@ -41,6 +39,7 @@ private:
|
|||
// input field based on element type
|
||||
std::unique_ptr<QLineEdit> input;
|
||||
std::unique_ptr<QComboBox> combobox;
|
||||
std::unique_ptr<QLabel> staticLabel;
|
||||
// layer information
|
||||
std::shared_ptr<GuidedEditorLayer> layer;
|
||||
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
#include <memory>
|
||||
|
||||
#include "guidededitorview.h"
|
||||
#include "guidededitorelementview.h"
|
||||
|
||||
GuidedEditorView::GuidedEditorView(QWidget* parent) : QWidget(parent) {
|
||||
editorLayout = new FlowLayout(this);
|
||||
this->setLayout(editorLayout);
|
||||
editorLayout = std::make_shared<FlowLayout>(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<AbstractGuidedEditorModel> model,
|
||||
QWidget* parent)
|
||||
: GuidedEditorView(parent) {}
|
||||
: GuidedEditorView(parent)
|
||||
{
|
||||
this->model = model;
|
||||
}
|
||||
|
||||
GuidedEditorView::~GuidedEditorView() {}
|
||||
|
||||
void GuidedEditorView::addElement() {
|
||||
this->editorLayout->addWidget(new GuidedEditorElementView());
|
||||
}
|
||||
|
|
|
@ -18,10 +18,10 @@ public:
|
|||
signals:
|
||||
|
||||
public slots:
|
||||
void addElement();
|
||||
|
||||
private:
|
||||
FlowLayout* editorLayout;
|
||||
std::shared_ptr<FlowLayout> editorLayout;
|
||||
std::shared_ptr<AbstractGuidedEditorModel> model;
|
||||
};
|
||||
|
||||
#endif // GUIDEDEDITOR_H
|
||||
|
|
Reference in New Issue