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{
...
@@ -103,11 +103,43 @@ Item{
Label
{
Label
{
text
:
"
Type:
"
text
:
"
Type:
"
}
}
ComboBox
{
RowLayout
{
model
:
moduleTypeModel
ComboBox
{
Layout.preferredWidth
:
200
model
:
moduleTypeModel
currentIndex
:
listView
.
currentItem
.
itemData
.
type
Layout.preferredWidth
:
implicitWidth
+
5
onCurrentIndexChanged
:
listView
.
currentItem
.
itemData
.
type
=
currentIndex
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
{
Label
{
...
@@ -119,10 +151,10 @@ Item{
...
@@ -119,10 +151,10 @@ Item{
anchors.bottomMargin
:
-
20
anchors.bottomMargin
:
-
20
clip
:
true
clip
:
true
Layout.preferredHeight
:
Math
.
max
(
50
,
Math
.
min
(
model
.
rowCount
()
*
20
,
120
))
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]);
print(prop += " (" + typeof(model[prop]) + ") = " + model[prop]);
}
}
}
}
*/
model
:
listView
.
currentItem
.
itemData
.
properties
model
:
listView
.
currentItem
.
itemData
.
properties
delegate
:
ItemDelegate
{
delegate
:
ItemDelegate
{
id
:
delegate
id
:
delegate
...
...
codeeditorhelper.cpp
View file @
b9ebf4a7
...
@@ -325,7 +325,8 @@ void CodeEditorHelper::compile(){
...
@@ -325,7 +325,8 @@ void CodeEditorHelper::compile(){
if
(
file
.
open
(
QIODevice
::
ReadWrite
)
)
if
(
file
.
open
(
QIODevice
::
ReadWrite
)
)
{
{
QString
typeName
=
toName
(
module
->
getType
());
QString
typeName
=
toName
(
module
->
getType
());
QString
valueName
=
toName
(
module
->
getValueType
());
QString
inputType
=
toName
(
module
->
getInputType
());
QString
outputType
=
toName
(
module
->
getOutputType
());
QTextStream
stream
(
&
file
);
QTextStream
stream
(
&
file
);
stream
<<
"#define MODULE_LIBRARY"
<<
endl
;
stream
<<
"#define MODULE_LIBRARY"
<<
endl
;
switch
(
module
->
getType
())
{
switch
(
module
->
getType
())
{
...
@@ -349,9 +350,9 @@ void CodeEditorHelper::compile(){
...
@@ -349,9 +350,9 @@ void CodeEditorHelper::compile(){
stream
<<
"using namespace std;"
<<
endl
;
stream
<<
"using namespace std;"
<<
endl
;
stream
<<
""
<<
endl
;
stream
<<
""
<<
endl
;
if
(
module
->
getType
()
==
Modules
::
Module
::
Filter
){
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
{
}
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
()){
for
(
const
auto
&
p
:
module
->
getProperties
()){
writeDeclaration
(
stream
,
p
);
writeDeclaration
(
stream
,
p
);
...
...
main.cpp
View file @
b9ebf4a7
...
@@ -92,6 +92,7 @@ int main(int argc, char *argv[])
...
@@ -92,6 +92,7 @@ int main(int argc, char *argv[])
qmlRegisterUncreatableType
<
UserManagment
>
(
"custom.licht"
,
1
,
0
,
"Permission"
,
"Singletone in c++"
);
qmlRegisterUncreatableType
<
UserManagment
>
(
"custom.licht"
,
1
,
0
,
"Permission"
,
"Singletone in c++"
);
qRegisterMetaType
<
UserManagment
::
Permission
>
(
"Permission"
);
qRegisterMetaType
<
UserManagment
::
Permission
>
(
"Permission"
);
qRegisterMetaType
<
Modules
::
detail
::
PropertyInformation
::
Type
>
(
"Type"
);
qRegisterMetaType
<
Modules
::
detail
::
PropertyInformation
::
Type
>
(
"Type"
);
qRegisterMetaType
<
Modules
::
ValueType
>
(
"ValueType"
);
qRegisterMetaType
<
Modules
::
PropertiesVector
*>
(
"PropertiesVector*"
);
qRegisterMetaType
<
Modules
::
PropertiesVector
*>
(
"PropertiesVector*"
);
Settings
settings
;
Settings
settings
;
settings
.
setJsonSettingsFilePath
(
"QTJSONFile.json"
);
settings
.
setJsonSettingsFilePath
(
"QTJSONFile.json"
);
...
@@ -114,10 +115,12 @@ int main(int argc, char *argv[])
...
@@ -114,10 +115,12 @@ int main(int argc, char *argv[])
}
}
QStringList
moduleTypeList
;
QStringList
moduleTypeList
;
const
QMetaObject
&
_mom
=
Modules
::
Module
::
staticMetaObject
;
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
)
{
for
(
int
i
=
0
;
i
<
_metaEnum
.
keyCount
();
++
i
)
{
moduleTypeList
.
append
(
_metaEnum
.
key
(
i
));
moduleTypeList
.
append
(
_metaEnum
.
key
(
i
));
}
}
QStringList
valueTypeList
;
valueTypeList
<<
"Brightness"
<<
"RGB"
;
QStringList
modolePropertyTypeList
;
QStringList
modolePropertyTypeList
;
modolePropertyTypeList
<<
"Int"
<<
"Long"
<<
"Float"
<<
"Double"
<<
"Bool"
<<
"String"
;
modolePropertyTypeList
<<
"Int"
<<
"Long"
<<
"Float"
<<
"Double"
<<
"Bool"
<<
"String"
;
...
@@ -155,6 +158,7 @@ int main(int argc, char *argv[])
...
@@ -155,6 +158,7 @@ int main(int argc, char *argv[])
engine
.
rootContext
()
->
setContextProperty
(
"devicePrototypeModel"
,
IDBaseDataModel
<
DevicePrototype
>::
singletone
());
engine
.
rootContext
()
->
setContextProperty
(
"devicePrototypeModel"
,
IDBaseDataModel
<
DevicePrototype
>::
singletone
());
engine
.
rootContext
()
->
setContextProperty
(
"modulesModel"
,
Modules
::
ModuleManager
::
singletone
()
->
getModules
());
engine
.
rootContext
()
->
setContextProperty
(
"modulesModel"
,
Modules
::
ModuleManager
::
singletone
()
->
getModules
());
engine
.
rootContext
()
->
setContextProperty
(
"moduleTypeModel"
,
moduleTypeList
);
engine
.
rootContext
()
->
setContextProperty
(
"moduleTypeModel"
,
moduleTypeList
);
engine
.
rootContext
()
->
setContextProperty
(
"valueTypeList"
,
valueTypeList
);
engine
.
rootContext
()
->
setContextProperty
(
"modolePropertyTypeList"
,
modolePropertyTypeList
);
engine
.
rootContext
()
->
setContextProperty
(
"modolePropertyTypeList"
,
modolePropertyTypeList
);
engine
.
rootContext
()
->
setContextProperty
(
"deviceModel"
,
IDBaseDataModel
<
Device
>::
singletone
());
engine
.
rootContext
()
->
setContextProperty
(
"deviceModel"
,
IDBaseDataModel
<
Device
>::
singletone
());
engine
.
rootContext
()
->
setContextProperty
(
"programmModel"
,
IDBaseDataModel
<
Programm
>::
singletone
());
engine
.
rootContext
()
->
setContextProperty
(
"programmModel"
,
IDBaseDataModel
<
Programm
>::
singletone
());
...
...
programms/modulemanager.cpp
View file @
b9ebf4a7
...
@@ -29,7 +29,8 @@ namespace detail {
...
@@ -29,7 +29,8 @@ namespace detail {
Module
::
Module
(
const
QJsonObject
&
o
)
:
name
(
o
[
"name"
].
toString
(
"no name"
)),
Module
::
Module
(
const
QJsonObject
&
o
)
:
name
(
o
[
"name"
].
toString
(
"no name"
)),
description
(
o
[
"description"
].
toString
()),
code
(
o
[
"code"
].
toString
()),
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
())){
type
(
static_cast
<
Type
>
(
o
[
"type"
].
toInt
())){
QJsonArray
a
=
o
[
"properties"
].
toArray
();
QJsonArray
a
=
o
[
"properties"
].
toArray
();
for
(
const
auto
i
:
a
){
for
(
const
auto
i
:
a
){
...
@@ -42,7 +43,8 @@ void Module::writeJsonObject(QJsonObject &o)const{
...
@@ -42,7 +43,8 @@ void Module::writeJsonObject(QJsonObject &o)const{
o
[
"name"
]
=
name
;
o
[
"name"
]
=
name
;
o
[
"description"
]
=
description
;
o
[
"description"
]
=
description
;
o
[
"code"
]
=
code
;
o
[
"code"
]
=
code
;
o
[
"valueType"
]
=
valueType
;
o
[
"inputType"
]
=
inputType
;
o
[
"outputType"
]
=
outputType
;
o
[
"type"
]
=
type
;
o
[
"type"
]
=
type
;
QJsonArray
a
;
QJsonArray
a
;
for
(
const
auto
&
p
:
properties
){
for
(
const
auto
&
p
:
properties
){
...
...
programms/modulemanager.h
View file @
b9ebf4a7
...
@@ -88,14 +88,16 @@ class Module : public QObject{
...
@@ -88,14 +88,16 @@ class Module : public QObject{
Q_PROPERTY
(
QString
name
READ
getName
WRITE
setName
NOTIFY
nameChanged
)
Q_PROPERTY
(
QString
name
READ
getName
WRITE
setName
NOTIFY
nameChanged
)
Q_PROPERTY
(
QString
description
READ
getDescription
WRITE
setDescription
NOTIFY
descriptionChanged
)
Q_PROPERTY
(
QString
description
READ
getDescription
WRITE
setDescription
NOTIFY
descriptionChanged
)
Q_PROPERTY
(
Type
type
READ
getType
WRITE
setType
NOTIFY
typeChanged
)
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
(
QString
code
READ
getCode
WRITE
setCode
NOTIFY
codeChanged
)
Q_PROPERTY
(
PropertiesVector
*
properties
READ
getPropertiesP
CONSTANT
)
Q_PROPERTY
(
PropertiesVector
*
properties
READ
getPropertiesP
CONSTANT
)
QString
name
=
"No Name"
;
QString
name
=
"No Name"
;
QString
description
;
QString
description
;
PropertiesVector
properties
;
PropertiesVector
properties
;
QString
code
;
QString
code
;
ValueType
valueType
;
ValueType
inputType
;
ValueType
outputType
;
Q_ENUM
(
ValueType
)
Q_ENUM
(
ValueType
)
//Module(Module&)=delete;
//Module(Module&)=delete;
...
@@ -164,14 +166,23 @@ public:
...
@@ -164,14 +166,23 @@ public:
Type
getType
()
const
{
Type
getType
()
const
{
return
type
;
return
type
;
}
}
void
set
Value
Type
(
const
ValueType
_
value
Type
){
void
set
Input
Type
(
const
ValueType
_
input
Type
){
if
(
_
value
Type
!=
value
Type
){
if
(
_
input
Type
!=
input
Type
){
value
Type
=
_
value
Type
;
input
Type
=
_
input
Type
;
emit
value
TypeChanged
();
emit
input
TypeChanged
();
}
}
}
}
ValueType
getValueType
()
const
{
ValueType
getInputType
()
const
{
return
valueType
;
return
inputType
;
}
void
setOutputType
(
const
ValueType
_outputType
){
if
(
_outputType
!=
outputType
){
outputType
=
_outputType
;
emit
outputTypeChanged
();
}
}
ValueType
getOutputType
()
const
{
return
outputType
;
}
}
void
setCode
(
const
QString
_code
){
void
setCode
(
const
QString
_code
){
if
(
_code
!=
code
){
if
(
_code
!=
code
){
...
@@ -187,7 +198,8 @@ signals:
...
@@ -187,7 +198,8 @@ signals:
void
nameChanged
();
void
nameChanged
();
void
descriptionChanged
();
void
descriptionChanged
();
void
typeChanged
();
void
typeChanged
();
void
valueTypeChanged
();
void
inputTypeChanged
();
void
outputTypeChanged
();
void
codeChanged
();
void
codeChanged
();
};
};
...
...
Write
Preview
Supports
Markdown
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