Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Leander Schulten
Lichtsteuerung
Commits
b9ebf4a7
Commit
b9ebf4a7
authored
Aug 05, 2018
by
Leander Schulten
Browse files
Modules can habe different input and output types
parent
186c0438
Changes
5
Hide whitespace changes
Inline
Side-by-side
ModuleView.qml
View file @
b9ebf4a7
...
...
@@ -103,11 +103,43 @@ Item{
Label
{
text
:
"
Type:
"
}
ComboBox
{
model
:
moduleTypeModel
Layout.preferredWidth
:
200
currentIndex
:
listView
.
currentItem
.
itemData
.
type
onCurrentIndexChanged
:
listView
.
currentItem
.
itemData
.
type
=
currentIndex
RowLayout
{
ComboBox
{
model
:
moduleTypeModel
Layout.preferredWidth
:
implicitWidth
+
5
currentIndex
:
listView
.
currentItem
.
itemData
.
type
onCurrentIndexChanged
:
{
listView
.
currentItem
.
itemData
.
type
=
currentIndex
;
if
(
currentIndex
==
0
/*Program*/
||
currentIndex
==
1
/*LoopProgram*/
){
outputType
.
visible
=
true
;
inputType
.
visible
=
false
;
}
else
if
(
currentIndex
==
2
/*Filter*/
){
outputType
.
visible
=
true
;
inputType
.
visible
=
true
;
}
}
}
Label
{
text
:
"
Input:
"
visible
:
inputType
.
visible
}
ComboBox
{
id
:
inputType
model
:
valueTypeList
currentIndex
:
listView
.
currentItem
.
itemData
.
inputType
Layout.preferredWidth
:
implicitWidth
+
5
onCurrentIndexChanged
:
listView
.
currentItem
.
itemData
.
inputType
=
currentIndex
;
}
Label
{
text
:
"
Output:
"
visible
:
outputType
.
visible
}
ComboBox
{
id
:
outputType
model
:
valueTypeList
currentIndex
:
listView
.
currentItem
.
itemData
.
outputType
Layout.preferredWidth
:
implicitWidth
+
5
onCurrentIndexChanged
:
listView
.
currentItem
.
itemData
.
outputType
=
currentIndex
;
}
}
Label
{
...
...
@@ -119,10 +151,10 @@ Item{
anchors.bottomMargin
:
-
20
clip
:
true
Layout.preferredHeight
:
Math
.
max
(
50
,
Math
.
min
(
model
.
rowCount
()
*
20
,
120
))
onModelChanged
:{
for
(
var
prop
in
model
)
{
/*
onModelChanged:{ for (var prop in model) {
print(prop += " (" + typeof(model[prop]) + ") = " + model[prop]);
}
}
}
*/
model
:
listView
.
currentItem
.
itemData
.
properties
delegate
:
ItemDelegate
{
id
:
delegate
...
...
codeeditorhelper.cpp
View file @
b9ebf4a7
...
...
@@ -325,7 +325,8 @@ void CodeEditorHelper::compile(){
if
(
file
.
open
(
QIODevice
::
ReadWrite
)
)
{
QString
typeName
=
toName
(
module
->
getType
());
QString
valueName
=
toName
(
module
->
getValueType
());
QString
inputType
=
toName
(
module
->
getInputType
());
QString
outputType
=
toName
(
module
->
getOutputType
());
QTextStream
stream
(
&
file
);
stream
<<
"#define MODULE_LIBRARY"
<<
endl
;
switch
(
module
->
getType
())
{
...
...
@@ -349,9 +350,9 @@ void CodeEditorHelper::compile(){
stream
<<
"using namespace std;"
<<
endl
;
stream
<<
""
<<
endl
;
if
(
module
->
getType
()
==
Modules
::
Module
::
Filter
){
stream
<<
"class Impl : public Typed"
<<
typeName
<<
"<"
<<
valueName
<<
","
<<
valueNam
e
<<
">{"
<<
endl
;
stream
<<
"class Impl : public Typed"
<<
typeName
<<
"<"
<<
inputType
<<
","
<<
outputTyp
e
<<
">{"
<<
endl
;
}
else
{
stream
<<
"class Impl : public Typed"
<<
typeName
<<
"<"
<<
valueNam
e
<<
">{"
<<
endl
;
stream
<<
"class Impl : public Typed"
<<
typeName
<<
"<"
<<
outputTyp
e
<<
">{"
<<
endl
;
}
for
(
const
auto
&
p
:
module
->
getProperties
()){
writeDeclaration
(
stream
,
p
);
...
...
main.cpp
View file @
b9ebf4a7
...
...
@@ -92,6 +92,7 @@ int main(int argc, char *argv[])
qmlRegisterUncreatableType
<
UserManagment
>
(
"custom.licht"
,
1
,
0
,
"Permission"
,
"Singletone in c++"
);
qRegisterMetaType
<
UserManagment
::
Permission
>
(
"Permission"
);
qRegisterMetaType
<
Modules
::
detail
::
PropertyInformation
::
Type
>
(
"Type"
);
qRegisterMetaType
<
Modules
::
ValueType
>
(
"ValueType"
);
qRegisterMetaType
<
Modules
::
PropertiesVector
*>
(
"PropertiesVector*"
);
Settings
settings
;
settings
.
setJsonSettingsFilePath
(
"QTJSONFile.json"
);
...
...
@@ -114,10 +115,12 @@ int main(int argc, char *argv[])
}
QStringList
moduleTypeList
;
const
QMetaObject
&
_mom
=
Modules
::
Module
::
staticMetaObject
;
QMetaEnum
_metaEnum
=
_mom
.
enumerator
(
mo
.
indexOfEnumerator
(
"Type"
));
QMetaEnum
_metaEnum
=
_mom
.
enumerator
(
_
mo
m
.
indexOfEnumerator
(
"Type"
));
for
(
int
i
=
0
;
i
<
_metaEnum
.
keyCount
();
++
i
)
{
moduleTypeList
.
append
(
_metaEnum
.
key
(
i
));
}
QStringList
valueTypeList
;
valueTypeList
<<
"Brightness"
<<
"RGB"
;
QStringList
modolePropertyTypeList
;
modolePropertyTypeList
<<
"Int"
<<
"Long"
<<
"Float"
<<
"Double"
<<
"Bool"
<<
"String"
;
...
...
@@ -155,6 +158,7 @@ int main(int argc, char *argv[])
engine
.
rootContext
()
->
setContextProperty
(
"devicePrototypeModel"
,
IDBaseDataModel
<
DevicePrototype
>::
singletone
());
engine
.
rootContext
()
->
setContextProperty
(
"modulesModel"
,
Modules
::
ModuleManager
::
singletone
()
->
getModules
());
engine
.
rootContext
()
->
setContextProperty
(
"moduleTypeModel"
,
moduleTypeList
);
engine
.
rootContext
()
->
setContextProperty
(
"valueTypeList"
,
valueTypeList
);
engine
.
rootContext
()
->
setContextProperty
(
"modolePropertyTypeList"
,
modolePropertyTypeList
);
engine
.
rootContext
()
->
setContextProperty
(
"deviceModel"
,
IDBaseDataModel
<
Device
>::
singletone
());
engine
.
rootContext
()
->
setContextProperty
(
"programmModel"
,
IDBaseDataModel
<
Programm
>::
singletone
());
...
...
programms/modulemanager.cpp
View file @
b9ebf4a7
...
...
@@ -29,7 +29,8 @@ namespace detail {
Module
::
Module
(
const
QJsonObject
&
o
)
:
name
(
o
[
"name"
].
toString
(
"no name"
)),
description
(
o
[
"description"
].
toString
()),
code
(
o
[
"code"
].
toString
()),
valueType
(
static_cast
<
ValueType
>
(
o
[
"valueType"
].
toInt
())),
inputType
(
static_cast
<
ValueType
>
(
o
[
"inputType"
].
toInt
())),
outputType
(
static_cast
<
ValueType
>
(
o
[
"outputType"
].
toInt
())),
type
(
static_cast
<
Type
>
(
o
[
"type"
].
toInt
())){
QJsonArray
a
=
o
[
"properties"
].
toArray
();
for
(
const
auto
i
:
a
){
...
...
@@ -42,7 +43,8 @@ void Module::writeJsonObject(QJsonObject &o)const{
o
[
"name"
]
=
name
;
o
[
"description"
]
=
description
;
o
[
"code"
]
=
code
;
o
[
"valueType"
]
=
valueType
;
o
[
"inputType"
]
=
inputType
;
o
[
"outputType"
]
=
outputType
;
o
[
"type"
]
=
type
;
QJsonArray
a
;
for
(
const
auto
&
p
:
properties
){
...
...
programms/modulemanager.h
View file @
b9ebf4a7
...
...
@@ -88,14 +88,16 @@ class Module : public QObject{
Q_PROPERTY
(
QString
name
READ
getName
WRITE
setName
NOTIFY
nameChanged
)
Q_PROPERTY
(
QString
description
READ
getDescription
WRITE
setDescription
NOTIFY
descriptionChanged
)
Q_PROPERTY
(
Type
type
READ
getType
WRITE
setType
NOTIFY
typeChanged
)
Q_PROPERTY
(
ValueType
valueType
READ
getValueType
WRITE
setValueType
NOTIFY
valueTypeChanged
)
Q_PROPERTY
(
ValueType
inputType
READ
getInputType
WRITE
setInputType
NOTIFY
inputTypeChanged
)
Q_PROPERTY
(
ValueType
outputType
READ
getOutputType
WRITE
setOutputType
NOTIFY
outputTypeChanged
)
Q_PROPERTY
(
QString
code
READ
getCode
WRITE
setCode
NOTIFY
codeChanged
)
Q_PROPERTY
(
PropertiesVector
*
properties
READ
getPropertiesP
CONSTANT
)
QString
name
=
"No Name"
;
QString
description
;
PropertiesVector
properties
;
QString
code
;
ValueType
valueType
;
ValueType
inputType
;
ValueType
outputType
;
Q_ENUM
(
ValueType
)
//Module(Module&)=delete;
...
...
@@ -164,14 +166,23 @@ public:
Type
getType
()
const
{
return
type
;
}
void
set
Value
Type
(
const
ValueType
_
value
Type
){
if
(
_
value
Type
!=
value
Type
){
value
Type
=
_
value
Type
;
emit
value
TypeChanged
();
void
set
Input
Type
(
const
ValueType
_
input
Type
){
if
(
_
input
Type
!=
input
Type
){
input
Type
=
_
input
Type
;
emit
input
TypeChanged
();
}
}
ValueType
getValueType
()
const
{
return
valueType
;
ValueType
getInputType
()
const
{
return
inputType
;
}
void
setOutputType
(
const
ValueType
_outputType
){
if
(
_outputType
!=
outputType
){
outputType
=
_outputType
;
emit
outputTypeChanged
();
}
}
ValueType
getOutputType
()
const
{
return
outputType
;
}
void
setCode
(
const
QString
_code
){
if
(
_code
!=
code
){
...
...
@@ -187,7 +198,8 @@ signals:
void
nameChanged
();
void
descriptionChanged
();
void
typeChanged
();
void
valueTypeChanged
();
void
inputTypeChanged
();
void
outputTypeChanged
();
void
codeChanged
();
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment