From 65faf279631276aa283482876f2b7ff16592b8b3 Mon Sep 17 00:00:00 2001 From: Marcel Otte Date: Sun, 6 Sep 2015 18:57:18 +0200 Subject: [PATCH] working again on npc, finally --- abstractguidededitormodel.cpp | 7 ++ abstractguidededitormodel.h | 26 +++++++ guidededitor.h | 26 ------- guidededitorelement.cpp | 90 ++++++++++++++++++------ guidededitorelement.h | 52 +++++++++----- guidededitorelementview.cpp | 7 ++ guidededitorelementview.h | 27 +++++++ guidededitorlayer.cpp | 27 +++++++ guidededitorlayer.h | 31 ++++++++ guidededitor.cpp => guidededitorview.cpp | 17 +++-- guidededitorview.h | 29 ++++++++ mainwindow.cpp | 4 +- mainwindow.h | 4 +- networkpacketcomposer.pro | 12 +++- 14 files changed, 281 insertions(+), 78 deletions(-) create mode 100644 abstractguidededitormodel.cpp create mode 100644 abstractguidededitormodel.h delete mode 100644 guidededitor.h create mode 100644 guidededitorelementview.cpp create mode 100644 guidededitorelementview.h create mode 100644 guidededitorlayer.cpp create mode 100644 guidededitorlayer.h rename guidededitor.cpp => guidededitorview.cpp (55%) create mode 100644 guidededitorview.h diff --git a/abstractguidededitormodel.cpp b/abstractguidededitormodel.cpp new file mode 100644 index 0000000..85c552c --- /dev/null +++ b/abstractguidededitormodel.cpp @@ -0,0 +1,7 @@ +#include "abstractguidededitormodel.h" + +AbstractGuidedEditorModel::AbstractGuidedEditorModel(QObject *parent) : QObject(parent) +{ + +} + diff --git a/abstractguidededitormodel.h b/abstractguidededitormodel.h new file mode 100644 index 0000000..e0543b6 --- /dev/null +++ b/abstractguidededitormodel.h @@ -0,0 +1,26 @@ +#ifndef ABSTRACTGUIDEDEDITORMODEL_H +#define ABSTRACTGUIDEDEDITORMODEL_H + +#include +#include +#include "guidededitorelement.h" + +class AbstractGuidedEditorModel : public QObject +{ + Q_OBJECT +public: + explicit AbstractGuidedEditorModel(QObject *parent = 0); + virtual ~AbstractGuidedEditorModel(); + + virtual uint getCount()=0; + virtual GuidedEditorElement& getElement(uint index) = 0; + virtual void setElementValue(const uint index, const QString value)= 0; + +signals: + void dataChanged(); + void dataChanged(uint index); + +public slots: +}; + +#endif // ABSTRACTGUIDEDEDITORMODEL_H diff --git a/guidededitor.h b/guidededitor.h deleted file mode 100644 index 72d088e..0000000 --- a/guidededitor.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef GUIDEDEDITOR_H -#define GUIDEDEDITOR_H - -#include -#include "flowlayout.h" -#include "guidededitorelement.h" - -class GuidedEditor : public QWidget -{ - Q_OBJECT -public: - explicit GuidedEditor(QWidget *parent = 0); - ~GuidedEditor(); - -signals: - -public slots: - void addElement(); - -private: - FlowLayout* editorLayout; - QList* list; - -}; - -#endif // GUIDEDEDITOR_H diff --git a/guidededitorelement.cpp b/guidededitorelement.cpp index ae72f32..5e5e370 100644 --- a/guidededitorelement.cpp +++ b/guidededitorelement.cpp @@ -1,27 +1,75 @@ #include "guidededitorelement.h" -#include +#include -EditorElement::EditorElement(QWidget *parent) : QWidget(parent) -{ - this->layout = new QBoxLayout(QBoxLayout::TopToBottom, this); - this->setLayout(layout); - label = new QLabel(this); - hint = new QLabel(this); - edit = new QLineEdit(this); - layout->addWidget(label); - layout->addWidget(hint); - layout->addWidget(edit); - - label->setText("test"); - hint->setText("another test"); - edit->setText("content test"); - this->setStyleSheet("QWidget {border: 2px dashed red}"); - - -} - -EditorElement::~EditorElement() +GuidedEditorElement::GuidedEditorElement(QObject *parent) : QObject(parent) { } + + +GuidedEditorElement::~GuidedEditorElement() +{ + +} + +QString GuidedEditorElement::getTitle() const +{ + return title; +} + +void GuidedEditorElement::setTitle(const QString &value) +{ + title = value; +} + +QString GuidedEditorElement::getDescription() const +{ + return description; +} + +void GuidedEditorElement::setDescription(const QString &value) +{ + description = value; +} + +QString GuidedEditorElement::getExample() const +{ + return example; +} + +void GuidedEditorElement::setExample(const QString &value) +{ + example = value; +} + +QString GuidedEditorElement::getSyntaxregex() const +{ + return syntaxregex; +} + +void GuidedEditorElement::setSyntaxregex(const QString &value) +{ + syntaxregex = value; +} + +ElementType GuidedEditorElement::getType() const +{ + return type; +} + +void GuidedEditorElement::setType(const ElementType &value) +{ + type = value; +} + +QString GuidedEditorElement::getValue() const +{ + return value; +} + +void GuidedEditorElement::setValue(const QString &value) +{ + this->value = value; +} + diff --git a/guidededitorelement.h b/guidededitorelement.h index 7df81dd..0aa0cc5 100644 --- a/guidededitorelement.h +++ b/guidededitorelement.h @@ -1,28 +1,48 @@ #ifndef EDITORELEMENT_H #define EDITORELEMENT_H -#include #include -#include -#include -#include -#include +#include -class EditorElement : public QWidget + +enum class ElementType { + INPUT, CHOOSER, STATIC +}; + +class GuidedEditorElement : public QObject { Q_OBJECT public: - explicit EditorElement(QWidget *parent = 0); - ~EditorElement(); + + + explicit GuidedEditorElement(QObject *parent = 0); + ~GuidedEditorElement(); + + QString getTitle() const; + void setTitle(const QString &value); + + QString getDescription() const; + void setDescription(const QString &value); + + QString getExample() const; + void setExample(const QString &value); + + QString getSyntaxregex() const; + void setSyntaxregex(const QString &value); + + ElementType getType() const; + void setType(const ElementType &value); + + QString getValue() const; + void setValue(const QString &value); + private: - QBoxLayout*layout; - QLabel * label; - QLabel * hint; - QLineEdit* edit; + QString title; + QString description; + QString example; + QString syntaxregex; + ElementType type; + QString value; - -signals: - -public slots: }; #endif // EDITORELEMENT_H diff --git a/guidededitorelementview.cpp b/guidededitorelementview.cpp new file mode 100644 index 0000000..29adf36 --- /dev/null +++ b/guidededitorelementview.cpp @@ -0,0 +1,7 @@ +#include "guidededitorelementview.h" + +GuidedEditorElementView::GuidedEditorElementView(GuidedEditorElement *element, QWidget *parent) : QWidget(parent) +{ + +} + diff --git a/guidededitorelementview.h b/guidededitorelementview.h new file mode 100644 index 0000000..a408ef0 --- /dev/null +++ b/guidededitorelementview.h @@ -0,0 +1,27 @@ +#ifndef GUIDEDEDITORELEMENTVIEW_H +#define GUIDEDEDITORELEMENTVIEW_H + +#include "guidededitorelement.h" +#include + + +class GuidedEditorElementView : public QWidget +{ + Q_OBJECT +public: + explicit GuidedEditorElementView(GuidedEditorElement* element, QWidget *parent = 0); + +signals: + +public slots: + +private: + // widget container + // title label + // example/regex label + // mouseover description? + // input field based on element type + // layer information +}; + +#endif // GUIDEDEDITORELEMENTVIEW_H diff --git a/guidededitorlayer.cpp b/guidededitorlayer.cpp new file mode 100644 index 0000000..feb4248 --- /dev/null +++ b/guidededitorlayer.cpp @@ -0,0 +1,27 @@ +#include "guidededitorlayer.h" + +GuidedEditorLayer::GuidedEditorLayer(QObject *parent) : QObject(parent) +{ + +} + +QString GuidedEditorLayer::getTitle() const +{ + return title; +} + +void GuidedEditorLayer::setTitle(const QString &value) +{ + title = value; +} + +QColor GuidedEditorLayer::getColor() const +{ + return color; +} + +void GuidedEditorLayer::setColor(const QColor &value) +{ + color = value; +} + diff --git a/guidededitorlayer.h b/guidededitorlayer.h new file mode 100644 index 0000000..6354d01 --- /dev/null +++ b/guidededitorlayer.h @@ -0,0 +1,31 @@ +#ifndef GUIDEDEDITORLAYER_H +#define GUIDEDEDITORLAYER_H + +#include +#include +#include + +class GuidedEditorLayer : public QObject +{ + Q_OBJECT +public: + explicit GuidedEditorLayer(QObject *parent = 0); + GuidedEditorLayer(QString title, QObject *parent = 0); + + QString getTitle() const; + void setTitle(const QString &value); + + QColor getColor() const; + void setColor(const QColor &value); + +private: + QString title; + QColor color; + + +signals: + +public slots: +}; + +#endif // GUIDEDEDITORLAYER_H diff --git a/guidededitor.cpp b/guidededitorview.cpp similarity index 55% rename from guidededitor.cpp rename to guidededitorview.cpp index 472ac56..f4d248c 100644 --- a/guidededitor.cpp +++ b/guidededitorview.cpp @@ -1,12 +1,9 @@ -#include "guidededitor.h" +#include "guidededitorview.h" -GuidedEditor::GuidedEditor(QWidget *parent) : QWidget(parent) -{ +GuidedEditorView::GuidedEditorView(QWidget * parent): QWidget(parent) { editorLayout = new FlowLayout(this); this->setLayout(editorLayout); //tests - this->editorLayout->addWidget(new EditorElement(this)); - this->editorLayout->addWidget(new EditorElement(this)); QString style = QString( "QWidget {" "border-radius: 5px;" @@ -17,14 +14,16 @@ GuidedEditor::GuidedEditor(QWidget *parent) : QWidget(parent) "border-radius: 5px;}" ); this->setStyleSheet(style); +} + +GuidedEditorView::GuidedEditorView(std::shared_ptr model,QWidget *parent) :GuidedEditorView(parent) +{ + } -void GuidedEditor::addElement() { - this->editorLayout->addWidget(new EditorElement(this)); -} -GuidedEditor::~GuidedEditor() +GuidedEditorView::~GuidedEditorView() { } diff --git a/guidededitorview.h b/guidededitorview.h new file mode 100644 index 0000000..d994778 --- /dev/null +++ b/guidededitorview.h @@ -0,0 +1,29 @@ +#ifndef GUIDEDEDITOR_H +#define GUIDEDEDITOR_H + +#include +#include +#include "flowlayout.h" +#include "guidededitorelement.h" +#include "abstractguidededitormodel.h" + +class GuidedEditorView : public QWidget +{ + Q_OBJECT +public: + explicit GuidedEditorView(QWidget *parent = 0); + explicit GuidedEditorView(std::shared_ptr model, QWidget *parent); + ~GuidedEditorView(); + +signals: + +public slots: + +private: + FlowLayout* editorLayout; + + + +}; + +#endif // GUIDEDEDITOR_H diff --git a/mainwindow.cpp b/mainwindow.cpp index 50a056e..57b0555 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -4,7 +4,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { - editor = new GuidedEditor(this); + editor = new GuidedEditorView(this); this->setCentralWidget(editor); dockWidget = new QDockWidget(this); this->addDockWidget(Qt::LeftDockWidgetArea, dockWidget); @@ -15,7 +15,7 @@ MainWindow::MainWindow(QWidget *parent) QPushButton* button = new QPushButton(dockWidget); button->setText("add"); dockLayout->addWidget(button); - this->connect(button, &QPushButton::pressed,editor, &GuidedEditor::addElement); +// this->connect(button, &QPushButton::pressed,editor, &GuidedEditorView::addElement); } diff --git a/mainwindow.h b/mainwindow.h index 774d41d..e4ff0cf 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -4,7 +4,7 @@ #include #include #include "flowlayout.h" -#include "guidededitor.h" +#include "guidededitorview.h" #include #include @@ -12,7 +12,7 @@ class MainWindow : public QMainWindow { Q_OBJECT private: - GuidedEditor* editor; + GuidedEditorView* editor; QDockWidget* dockWidget; public: diff --git a/networkpacketcomposer.pro b/networkpacketcomposer.pro index 396b071..c724c8b 100644 --- a/networkpacketcomposer.pro +++ b/networkpacketcomposer.pro @@ -8,6 +8,8 @@ QT += core gui greaterThan(QT_MAJOR_VERSION, 4): QT += widgets +QMAKE_CXXFLAGS += -std=c++14 + TARGET = networkpacketcomposer TEMPLATE = app @@ -16,12 +18,18 @@ SOURCES += main.cpp\ mainwindow.cpp \ flowlayout.cpp \ guidededitorelement.cpp \ - guidededitor.cpp + abstractguidededitormodel.cpp \ + guidededitorview.cpp \ + guidededitorlayer.cpp \ + guidededitorelementview.cpp HEADERS += mainwindow.h \ flowlayout.h \ guidededitorelement.h \ - guidededitor.h + abstractguidededitormodel.h \ + guidededitorview.h \ + guidededitorlayer.h \ + guidededitorelementview.h INCLUDEPATH += $$PWD/../QtGuidedEditor DEPENDPATH += $$PWD/../QtGuidedEditor