more structure, proper cmake-ing and c++14 fixes

This commit is contained in:
Marcel Otte 2016-01-04 17:49:12 +01:00
parent 938006d498
commit 14605ac0cb
26 changed files with 270 additions and 380 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
*.mm *.mm
*.pro.user *.pro.user
build build
*.user*

View File

@ -1,285 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 3.6.0, 2015-12-19T17:43:29. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
<value type="QByteArray">{8fe85189-3226-423c-bccf-c2236465442c}</value>
</data>
<data>
<variable>ProjectExplorer.Project.ActiveTarget</variable>
<value type="int">0</value>
</data>
<data>
<variable>ProjectExplorer.Project.EditorSettings</variable>
<valuemap type="QVariantMap">
<value type="bool" key="EditorConfiguration.AutoIndent">true</value>
<value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value>
<value type="bool" key="EditorConfiguration.CamelCaseNavigation">true</value>
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0">
<value type="QString" key="language">Cpp</value>
<valuemap type="QVariantMap" key="value">
<value type="QByteArray" key="CurrentPreferences">CppGlobal</value>
</valuemap>
</valuemap>
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1">
<value type="QString" key="language">QmlJS</value>
<valuemap type="QVariantMap" key="value">
<value type="QByteArray" key="CurrentPreferences">QmlJSGlobal</value>
</valuemap>
</valuemap>
<value type="int" key="EditorConfiguration.CodeStyle.Count">2</value>
<value type="QByteArray" key="EditorConfiguration.Codec">UTF-8</value>
<value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
<value type="int" key="EditorConfiguration.IndentSize">4</value>
<value type="bool" key="EditorConfiguration.KeyboardTooltips">false</value>
<value type="int" key="EditorConfiguration.MarginColumn">80</value>
<value type="bool" key="EditorConfiguration.MouseHiding">true</value>
<value type="bool" key="EditorConfiguration.MouseNavigation">true</value>
<value type="int" key="EditorConfiguration.PaddingMode">1</value>
<value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value>
<value type="bool" key="EditorConfiguration.ShowMargin">false</value>
<value type="int" key="EditorConfiguration.SmartBackspaceBehavior">0</value>
<value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
<value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
<value type="int" key="EditorConfiguration.TabSize">8</value>
<value type="bool" key="EditorConfiguration.UseGlobal">true</value>
<value type="int" key="EditorConfiguration.Utf8BomBehavior">1</value>
<value type="bool" key="EditorConfiguration.addFinalNewLine">true</value>
<value type="bool" key="EditorConfiguration.cleanIndentation">true</value>
<value type="bool" key="EditorConfiguration.cleanWhitespace">true</value>
<value type="bool" key="EditorConfiguration.inEntireDocument">false</value>
</valuemap>
</data>
<data>
<variable>ProjectExplorer.Project.PluginSettings</variable>
<valuemap type="QVariantMap">
<valuemap type="QVariantMap" key="ClangProjectSettings">
<value type="QString" key="CustomPchFile"></value>
<value type="int" key="PchUsage">1</value>
</valuemap>
</valuemap>
</data>
<data>
<variable>ProjectExplorer.Project.Target.0</variable>
<valuemap type="QVariantMap">
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{211a0c20-f25f-4bf4-b929-1284740fe4d9}</value>
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
<value type="QString" key="CMakeProjectManager.CMakeBuildConfiguration.InitialArgument"></value>
<value type="bool" key="CMakeProjectManager.CMakeBuildConfiguration.UseNinja">false</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/qwc/source/npc/build</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="QString" key="CMakeProjectManager.MakeStep.AdditionalArguments"></value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets"/>
<value type="bool" key="CMakeProjectManager.MakeStep.Clean">false</value>
<value type="QString" key="CMakeProjectManager.MakeStep.MakeCommand"></value>
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="QString" key="CMakeProjectManager.MakeStep.AdditionalArguments">clean</value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets"/>
<value type="bool" key="CMakeProjectManager.MakeStep.Clean">true</value>
<value type="QString" key="CMakeProjectManager.MakeStep.MakeCommand"></value>
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Bereinigen</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Vorgabe</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Vorgabe</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.CMakeBuildConfiguration</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1">
<value type="QString" key="CMakeProjectManager.CMakeBuildConfiguration.InitialArgument">-DCMAKE_BUILD_TYPE=Debug</value>
<value type="bool" key="CMakeProjectManager.CMakeBuildConfiguration.UseNinja">false</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/qwc/source/npc/build/debug</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="QString" key="CMakeProjectManager.MakeStep.AdditionalArguments"></value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets"/>
<value type="bool" key="CMakeProjectManager.MakeStep.Clean">false</value>
<value type="QString" key="CMakeProjectManager.MakeStep.MakeCommand"></value>
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="QString" key="CMakeProjectManager.MakeStep.AdditionalArguments">clean</value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets"/>
<value type="bool" key="CMakeProjectManager.MakeStep.Clean">true</value>
<value type="QString" key="CMakeProjectManager.MakeStep.MakeCommand"></value>
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Bereinigen</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Debug</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Debug</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.CMakeBuildConfiguration</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.2">
<value type="QString" key="CMakeProjectManager.CMakeBuildConfiguration.InitialArgument">-DCMAKE_BUILD_TYPE=Release</value>
<value type="bool" key="CMakeProjectManager.CMakeBuildConfiguration.UseNinja">false</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/qwc/source/npc/build/release</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="QString" key="CMakeProjectManager.MakeStep.AdditionalArguments"></value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets"/>
<value type="bool" key="CMakeProjectManager.MakeStep.Clean">false</value>
<value type="QString" key="CMakeProjectManager.MakeStep.MakeCommand"></value>
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="QString" key="CMakeProjectManager.MakeStep.AdditionalArguments">clean</value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets"/>
<value type="bool" key="CMakeProjectManager.MakeStep.Clean">true</value>
<value type="QString" key="CMakeProjectManager.MakeStep.MakeCommand"></value>
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Bereinigen</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Release</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Release</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.CMakeBuildConfiguration</value>
</valuemap>
<value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">3</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deployment</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Lokales Deployment</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
</valuemap>
<value type="int" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.PluginSettings"/>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
<value type="bool" key="Analyzer.QmlProfiler.FlushEnabled">false</value>
<value type="uint" key="Analyzer.QmlProfiler.FlushInterval">1000</value>
<value type="QString" key="Analyzer.QmlProfiler.LastTraceFile"></value>
<value type="bool" key="Analyzer.QmlProfiler.Settings.UseGlobalSettings">true</value>
<valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
<value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
<value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
<value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
<value type="int" key="Analyzer.Valgrind.LeakCheckOnFinish">1</value>
<value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
<valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
<value type="int" key="Analyzer.Valgrind.SelfModifyingCodeDetection">1</value>
<value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
<value type="bool" key="Analyzer.Valgrind.ShowReachable">false</value>
<value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
<value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
<valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
<value type="int">0</value>
<value type="int">1</value>
<value type="int">2</value>
<value type="int">3</value>
<value type="int">4</value>
<value type="int">5</value>
<value type="int">6</value>
<value type="int">7</value>
<value type="int">8</value>
<value type="int">9</value>
<value type="int">10</value>
<value type="int">11</value>
<value type="int">12</value>
<value type="int">13</value>
<value type="int">14</value>
</valuelist>
<value type="QString" key="CMakeProjectManager.CMakeRunConfiguation.Title">npc</value>
<value type="QString" key="CMakeProjectManager.CMakeRunConfiguration.Arguments"></value>
<value type="QString" key="CMakeProjectManager.CMakeRunConfiguration.UserWorkingDirectory"></value>
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">npc</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.CMakeRunConfiguration.npc</value>
<value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
<value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
<value type="bool" key="RunConfiguration.UseMultiProcess">false</value>
<value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
</valuemap>
<value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
</valuemap>
</data>
<data>
<variable>ProjectExplorer.Project.TargetCount</variable>
<value type="int">1</value>
</data>
<data>
<variable>ProjectExplorer.Project.Updater.FileVersion</variable>
<value type="int">18</value>
</data>
<data>
<variable>Version</variable>
<value type="int">18</value>
</data>
</qtcreator>

View File

@ -1,20 +1,12 @@
set(HEADERS abstractguidededitormodel.h set(HEADERS mainwindow.h
flowlayout.h
guidededitorelement.h
guidededitorelementview.h
guidededitorlayer.h
guidededitorview.h
mainwindow.h
) )
set(SOURCES abstractguidededitormodel.cpp set(SOURCES mainwindow.cpp
flowlayout.cpp
guidededitorelement.cpp
guidededitorelementview.cpp
guidededitorlayer.cpp
guidededitorview.cpp
mainwindow.cpp
) )
add_subdirectory(model)
add_subdirectory(editor)
add_library(src ${HEADERS} ${SOURCES}) add_library(src ${HEADERS} ${SOURCES})
target_link_libraries(src model editor)
qt5_use_modules(src Widgets) qt5_use_modules(src Widgets)

20
src/editor/CMakeLists.txt Normal file
View File

@ -0,0 +1,20 @@
set(HEADERS abstractguidededitormodel.h
guidededitorelement.h
guidededitorelementview.h
guidededitorlayer.h
guidededitorlayer.h
flowlayout.h
)
set(SOURCES guidededitorelementview.cpp
guidededitorelement.cpp
abstractguidededitormodel.cpp
guidededitorlayer.cpp
guidededitorview.cpp
flowlayout.cpp
)
add_library(editor ${HEADERS} ${SOURCES})
qt5_use_modules(editor Widgets)

View File

@ -0,0 +1,17 @@
#include "guidededitorelementview.h"
GuidedEditorElementView::GuidedEditorElementView(QWidget *parent) : QWidget(parent)
{
}
void GuidedEditorElementView::setElement()
{
}
void GuidedEditorElementView::dataChanged()
{
}

View File

@ -1,23 +1,24 @@
#ifndef GUIDEDEDITORELEMENTVIEW_H #ifndef GUIDEDEDITORELEMENTVIEW_H
#define GUIDEDEDITORELEMENTVIEW_H #define GUIDEDEDITORELEMENTVIEW_H
#include "guidededitorelement.h"
#include <QWidget> #include <QWidget>
#include <QLabel> #include <QLabel>
#include <QLineEdit> #include <QLineEdit>
#include "guidededitorlayer.h"
#include <QBoxLayout> #include <QBoxLayout>
#include <memory> #include <memory>
#include <QComboBox> #include <QComboBox>
#include "guidededitorlayer.h"
class GuidedEditorElementView : public QWidget class GuidedEditorElementView : public QWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit GuidedEditorElementView(GuidedEditorElement* element, QWidget *parent = 0); explicit GuidedEditorElementView(QWidget *parent = 0);
//explicit GuidedEditorElementView( QWidget *parent = 0);
void setElement(GuidedEditorElement* element); void setElement();
signals: signals:
@ -42,6 +43,7 @@ private:
std::unique_ptr<QComboBox> combobox; std::unique_ptr<QComboBox> combobox;
// layer information // layer information
std::shared_ptr<GuidedEditorLayer> layer; std::shared_ptr<GuidedEditorLayer> layer;
}; };
#endif // GUIDEDEDITORELEMENTVIEW_H #endif // GUIDEDEDITORELEMENTVIEW_H

View File

@ -0,0 +1,28 @@
#include "guidededitorview.h"
#include "guidededitorelementview.h"
GuidedEditorView::GuidedEditorView(QWidget* parent) : QWidget(parent) {
editorLayout = new FlowLayout(this);
this->setLayout(editorLayout);
// tests
QString style = QString(
"QWidget {"
"border-radius: 5px;"
"background: white }"
"QLabel {border: 2px dashed black; background: gray; "
"border-radius: 5px;}"
"QLineEdit {border: 2px dashed black;background: dark-gray;"
"border-radius: 5px;}");
this->setStyleSheet(style);
}
GuidedEditorView::GuidedEditorView(
std::shared_ptr<AbstractGuidedEditorModel> model,
QWidget* parent)
: GuidedEditorView(parent) {}
GuidedEditorView::~GuidedEditorView() {}
void GuidedEditorView::addElement() {
this->editorLayout->addWidget(new GuidedEditorElementView());
}

View File

@ -0,0 +1,27 @@
#ifndef GUIDEDEDITOR_H
#define GUIDEDEDITOR_H
#include <memory>
#include <QWidget>
#include "flowlayout.h"
#include "guidededitorelement.h"
#include "abstractguidededitormodel.h"
class GuidedEditorView : public QWidget {
Q_OBJECT
public:
explicit GuidedEditorView(QWidget* parent = 0);
GuidedEditorView(std::shared_ptr<AbstractGuidedEditorModel> model,
QWidget* parent = 0);
~GuidedEditorView();
signals:
public slots:
void addElement();
private:
FlowLayout* editorLayout;
};
#endif // GUIDEDEDITOR_H

View File

@ -1,7 +0,0 @@
#include "guidededitorelementview.h"
GuidedEditorElementView::GuidedEditorElementView(GuidedEditorElement *element, QWidget *parent) : QWidget(parent)
{
}

View File

@ -1,30 +0,0 @@
#include "guidededitorview.h"
GuidedEditorView::GuidedEditorView(QWidget * parent): QWidget(parent) {
editorLayout = new FlowLayout(this);
this->setLayout(editorLayout);
//tests
QString style = QString(
"QWidget {"
"border-radius: 5px;"
"background: white }"
"QLabel {border: 2px dashed black; background: gray; "
"border-radius: 5px;}"
"QLineEdit {border: 2px dashed black;background: dark-gray;"
"border-radius: 5px;}"
);
this->setStyleSheet(style);
}
GuidedEditorView::GuidedEditorView(std::shared_ptr<AbstractGuidedEditorModel> model,QWidget *parent) :GuidedEditorView(parent)
{
}
GuidedEditorView::~GuidedEditorView()
{
}

View File

@ -1,29 +0,0 @@
#ifndef GUIDEDEDITOR_H
#define GUIDEDEDITOR_H
#include <memory>
#include <QWidget>
#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<AbstractGuidedEditorModel> model, QWidget *parent);
~GuidedEditorView();
signals:
public slots:
private:
FlowLayout* editorLayout;
};
#endif // GUIDEDEDITOR_H

View File

@ -4,18 +4,18 @@
MainWindow::MainWindow(QWidget *parent) MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent) : QMainWindow(parent)
{ {
editor = new GuidedEditorView(this); editor = std::make_shared<GuidedEditorView>(this);
this->setCentralWidget(editor); this->setCentralWidget(editor.get());
dockWidget = new QDockWidget(this); dockWidget = std::make_shared<QDockWidget>(this);
this->addDockWidget(Qt::LeftDockWidgetArea, dockWidget); this->addDockWidget(Qt::LeftDockWidgetArea, dockWidget.get());
// dockwidget // dockwidget
QVBoxLayout* dockLayout = new QVBoxLayout(dockWidget); QVBoxLayout* dockLayout = new QVBoxLayout(dockWidget.get());
dockWidget->setLayout(dockLayout); dockWidget->setLayout(dockLayout);
QPushButton* button = new QPushButton(dockWidget); QPushButton* button = new QPushButton(dockWidget.get());
button->setText("add"); button->setText("add");
dockLayout->addWidget(button); dockLayout->addWidget(button);
// this->connect(button, &QPushButton::pressed,editor, &GuidedEditorView::addElement); //this->connect(button, &QPushButton::pressed,editor, &GuidedEditorView::addElement);
} }

View File

@ -1,19 +1,20 @@
#ifndef MAINWINDOW_H #ifndef MAINWINDOW_H
#define MAINWINDOW_H #define MAINWINDOW_H
#include <memory>
#include <QMainWindow> #include <QMainWindow>
#include <QList> #include <QList>
#include "flowlayout.h"
#include "guidededitorview.h"
#include <QGridLayout> #include <QGridLayout>
#include <QDockWidget> #include <QDockWidget>
#include "editor/guidededitorview.h"
class MainWindow : public QMainWindow class MainWindow : public QMainWindow
{ {
Q_OBJECT Q_OBJECT
private: private:
GuidedEditorView* editor; std::shared_ptr<GuidedEditorView> editor;
QDockWidget* dockWidget; std::shared_ptr<QDockWidget> dockWidget;
public: public:
MainWindow(QWidget *parent = 0); MainWindow(QWidget *parent = 0);

10
src/model/CMakeLists.txt Normal file
View File

@ -0,0 +1,10 @@
set(HEADERS packetmodel.h
packetelement.h
)
set(SOURCES packetmodel.cpp
packetelement.cpp
)
add_library(model ${HEADERS} ${SOURCES})

View File

@ -0,0 +1,11 @@
#include "packetelement.h"
PacketElement::PacketElement(std::__cxx11::string name, uint32_t sizeInBit, uint16_t layer): name(name), sizeInBit(sizeInBit), layer(layer)
{
}
void PacketElement::setValue(std::__cxx11::string &value, ValueType type)
{
}

99
src/model/packetelement.h Normal file
View File

@ -0,0 +1,99 @@
#ifndef PACKETELEMENT_H
#define PACKETELEMENT_H
#include <cstdint>
#include <string>
#include <list>
#include <memory>
class PacketElement;
typedef
std::list<std::shared_ptr<PacketElement>>
PacketElementList_t;
/**
@brief The ValueType enum
*/
enum class ValueType { hexBinary, integer, text, base64 };
class ElementSyntax
{
public:
std::string triggerRegex;
std::string completeRegex;
std::string example;
};
/**
@brief The PacketElement class
*/
class PacketElement
{
public:
/**
@brief PacketElement
@param name
@param sizeInBit
@param layer
*/
PacketElement(std::string name, uint32_t sizeInBit, uint16_t layer);
/**
@brief setValue
@param value
*/
void setValue(std::string& value) {this->value = value; this->valueType = ValueType::text; }
/**
@brief setValue
@param value
@param type
*/
void setValue(std::string& value, ValueType type);
const std::string getValue() { return value; }
uint32_t getSizeInBit() { return sizeInBit; }
uint16_t getLayer() { return layer; }
const std::string getName() { return name; }
const std::string getDescription() { return description; }
const std::shared_ptr<PacketElementList_t> getNextLayer() { return nextLayer; }
/**
@brief hasNextLayer
@return
*/
bool hasNextLayer() { return nextLayer != nullptr && sizeInBit == 0; }
/**
@brief setNextLayer
@param layerElements
*/
void setNextLayer(std::shared_ptr<PacketElementList_t>& layerElements) { nextLayer = layerElements; }
void addSyntax(std::string minimalRegex, std::string completeRegex, std::string example)
{
ElementSyntax syntax;
syntax.triggerRegex = minimalRegex;
syntax.completeRegex = completeRegex;
syntax.example = example;
syntaxes.push_back(syntax);
}
private:
std::string name;
uint32_t sizeInBit;
uint16_t layer;
std::string value;
ValueType valueType;
std::shared_ptr<PacketElementList_t> nextLayer;
//additional data
std::string description;
std::list<ElementSyntax> syntaxes;
};
#endif // PACKETELEMENT_H

13
src/model/packetmodel.cpp Normal file
View File

@ -0,0 +1,13 @@
#include "packetmodel.h"
#include "packetelement.h"
PacketModel::PacketModel()
{
this->elementList = std::make_shared<PacketElementList_t>();
}
const std::shared_ptr<PacketElementList_t> PacketModel::getList()
{
return this->elementList;
}

20
src/model/packetmodel.h Normal file
View File

@ -0,0 +1,20 @@
#ifndef PACKETMODEL_H
#define PACKETMODEL_H
#include <memory>
#include <list>
#include <string>
#include "packetelement.h"
class PacketModel
{
public:
PacketModel();
const std::shared_ptr<PacketElementList_t> getList();
private:
std::shared_ptr<PacketElementList_t> elementList;
};
#endif // PACKETMODEL_H