Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Q
qgroundcontrol
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Valentin Platzgummer
qgroundcontrol
Commits
526e5c53
Commit
526e5c53
authored
Feb 18, 2017
by
Don Gagne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fact string support
parent
8783b20d
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
71 additions
and
49 deletions
+71
-49
FactTextField.qml
src/FactSystem/FactControls/FactTextField.qml
+5
-3
FactMetaData.cc
src/FactSystem/FactMetaData.cc
+21
-13
FactMetaData.h
src/FactSystem/FactMetaData.h
+4
-1
FactSystem.cc
src/FactSystem/FactSystem.cc
+1
-0
APMParameterMetaData.cc
src/FirmwarePlugin/APM/APMParameterMetaData.cc
+20
-16
PX4ParameterMetaData.cc
src/FirmwarePlugin/PX4/PX4ParameterMetaData.cc
+20
-16
No files found.
src/FactSystem/FactControls/FactTextField.qml
View file @
526e5c53
...
...
@@ -16,12 +16,14 @@ QGCTextField {
showUnits
:
true
showHelp
:
true
property
Fact
fact
:
null
property
Fact
fact
:
null
property
string
_validateString
property
bool
_factIsString
:
fact
?
fact
.
type
===
FactMetaData
.
valueTypeString
:
false
// At this point all Facts are numeric
inputMethodHints
:
ScreenTools
.
isiOS
?
Qt
.
ImhNone
:
// iOS numeric keyboard has no
t
done button, we can't use it
inputMethodHints
:
(
_factIsString
||
ScreenTools
.
isiOS
)
?
Qt
.
ImhNone
:
// iOS numeric keyboard has no done button, we can't use it
Qt
.
ImhFormattedNumbersOnly
// Forces use of virtual numeric keyboard
onEditingFinished
:
{
...
...
src/FactSystem/FactMetaData.cc
View file @
526e5c53
...
...
@@ -7,12 +7,6 @@
*
****************************************************************************/
/// @file
/// @brief Object which exposes a FactMetaData
///
/// @author Don Gagne <don@thegagnes.com>
#include "FactMetaData.h"
#include "SettingsManager.h"
#include "JsonHelper.h"
...
...
@@ -157,7 +151,7 @@ QVariant FactMetaData::rawDefaultValue(void) const
void
FactMetaData
::
setRawDefaultValue
(
const
QVariant
&
rawDefaultValue
)
{
if
(
_
rawMin
<=
rawDefaultValue
&&
rawDefaultValue
<=
_rawMax
)
{
if
(
_
type
==
valueTypeString
||
(
_rawMin
<=
rawDefaultValue
&&
rawDefaultValue
<=
_rawMax
)
)
{
_rawDefaultValue
=
rawDefaultValue
;
_defaultValueAvailable
=
true
;
}
else
{
...
...
@@ -208,6 +202,8 @@ QVariant FactMetaData::_minForType(void) const
return
QVariant
(
-
std
::
numeric_limits
<
float
>::
max
());
case
valueTypeDouble
:
return
QVariant
(
-
std
::
numeric_limits
<
double
>::
max
());
case
valueTypeString
:
return
QVariant
();
}
// Make windows compiler happy, even switch is full cased
...
...
@@ -233,6 +229,8 @@ QVariant FactMetaData::_maxForType(void) const
return
QVariant
(
std
::
numeric_limits
<
float
>::
max
());
case
valueTypeDouble
:
return
QVariant
(
std
::
numeric_limits
<
double
>::
max
());
case
valueTypeString
:
return
QVariant
();
}
// Make windows compiler happy, even switch is full cased
...
...
@@ -285,6 +283,10 @@ bool FactMetaData::convertAndValidateRaw(const QVariant& rawValue, bool convertO
}
}
break
;
case
FactMetaData
:
:
valueTypeString
:
convertOk
=
true
;
typedValue
=
QVariant
(
rawValue
.
toString
());
break
;
}
if
(
!
convertOk
)
{
...
...
@@ -340,6 +342,10 @@ bool FactMetaData::convertAndValidateCooked(const QVariant& cookedValue, bool co
}
}
break
;
case
FactMetaData
:
:
valueTypeString
:
convertOk
=
true
;
typedValue
=
QVariant
(
cookedValue
.
toString
());
break
;
}
if
(
!
convertOk
)
{
...
...
@@ -556,7 +562,8 @@ FactMetaData::ValueType_t FactMetaData::stringToType(const QString& typeString,
<<
QStringLiteral
(
"Uint32"
)
<<
QStringLiteral
(
"Int32"
)
<<
QStringLiteral
(
"Float"
)
<<
QStringLiteral
(
"Double"
);
<<
QStringLiteral
(
"Double"
)
<<
QStringLiteral
(
"String"
);
knownTypes
<<
valueTypeUint8
<<
valueTypeInt8
...
...
@@ -565,7 +572,8 @@ FactMetaData::ValueType_t FactMetaData::stringToType(const QString& typeString,
<<
valueTypeUint32
<<
valueTypeInt32
<<
valueTypeFloat
<<
valueTypeDouble
;
<<
valueTypeDouble
<<
valueTypeString
;
for
(
int
i
=
0
;
i
<
knownTypeStrings
.
count
();
i
++
)
{
if
(
knownTypeStrings
[
i
].
compare
(
typeString
,
Qt
::
CaseInsensitive
)
==
0
)
{
...
...
@@ -599,7 +607,7 @@ size_t FactMetaData::typeToSize(ValueType_t type)
default:
qWarning
()
<<
"Unsupported fact value type"
<<
type
;
return
4
;
return
0
;
}
}
...
...
@@ -766,8 +774,8 @@ FactMetaData* FactMetaData::createFromJsonObject(const QJsonObject& json, QObjec
// Validate key types
QStringList
keys
;
QList
<
QJsonValue
::
Type
>
types
;
keys
<<
_nameJsonKey
<<
_decimalPlacesJsonKey
<<
_typeJsonKey
<<
_shortDescriptionJsonKey
<<
_longDescriptionJsonKey
<<
_unitsJsonKey
<<
_
defaultValueJsonKey
<<
_
minJsonKey
<<
_maxJsonKey
;
types
<<
QJsonValue
::
String
<<
QJsonValue
::
Double
<<
QJsonValue
::
String
<<
QJsonValue
::
String
<<
QJsonValue
::
String
<<
QJsonValue
::
String
<<
QJsonValue
::
Double
<<
QJsonValue
::
Double
<<
QJsonValue
::
Double
;
keys
<<
_nameJsonKey
<<
_decimalPlacesJsonKey
<<
_typeJsonKey
<<
_shortDescriptionJsonKey
<<
_longDescriptionJsonKey
<<
_unitsJsonKey
<<
_minJsonKey
<<
_maxJsonKey
;
types
<<
QJsonValue
::
String
<<
QJsonValue
::
Double
<<
QJsonValue
::
String
<<
QJsonValue
::
String
<<
QJsonValue
::
String
<<
QJsonValue
::
String
<<
QJsonValue
::
Double
<<
QJsonValue
::
Double
;
if
(
!
JsonHelper
::
validateKeyTypes
(
json
,
keys
,
types
,
errorString
))
{
qWarning
()
<<
errorString
;
return
new
FactMetaData
(
valueTypeUint32
,
metaDataParent
);
...
...
@@ -811,7 +819,7 @@ FactMetaData* FactMetaData::createFromJsonObject(const QJsonObject& json, QObjec
metaData
->
setRawUnits
(
json
[
_unitsJsonKey
].
toString
());
}
if
(
json
.
contains
(
_defaultValueJsonKey
))
{
metaData
->
setRawDefaultValue
(
json
[
_defaultValueJsonKey
]
.
toDouble
()
);
metaData
->
setRawDefaultValue
(
json
[
_defaultValueJsonKey
]);
}
if
(
json
.
contains
(
_minJsonKey
))
{
metaData
->
setRawMin
(
json
[
_minJsonKey
].
toDouble
());
...
...
src/FactSystem/FactMetaData.h
View file @
526e5c53
...
...
@@ -37,9 +37,12 @@ public:
valueTypeUint32
,
valueTypeInt32
,
valueTypeFloat
,
valueTypeDouble
valueTypeDouble
,
valueTypeString
}
ValueType_t
;
Q_ENUM
(
ValueType_t
)
typedef
QVariant
(
*
Translator
)(
const
QVariant
&
from
);
FactMetaData
(
QObject
*
parent
=
NULL
);
...
...
src/FactSystem/FactSystem.cc
View file @
526e5c53
...
...
@@ -30,6 +30,7 @@ void FactSystem::setToolbox(QGCToolbox *toolbox)
QGCTool
::
setToolbox
(
toolbox
);
qmlRegisterType
<
Fact
>
(
_factSystemQmlUri
,
1
,
0
,
"Fact"
);
qmlRegisterType
<
FactMetaData
>
(
_factSystemQmlUri
,
1
,
0
,
"FactMetaData"
);
qmlRegisterType
<
FactPanelController
>
(
_factSystemQmlUri
,
1
,
0
,
"FactPanelController"
);
qmlRegisterUncreatableType
<
FactGroup
>
(
_factSystemQmlUri
,
1
,
0
,
"FactGroup"
,
"ReferenceOnly"
);
...
...
src/FirmwarePlugin/APM/APMParameterMetaData.cc
View file @
526e5c53
...
...
@@ -39,22 +39,26 @@ QVariant APMParameterMetaData::_stringToTypedVariant(const QString& string,
int
convertTo
=
QVariant
::
Int
;
// keep compiler warning happy
switch
(
type
)
{
case
FactMetaData
:
:
valueTypeUint8
:
case
FactMetaData
:
:
valueTypeUint16
:
case
FactMetaData
:
:
valueTypeUint32
:
convertTo
=
QVariant
::
UInt
;
break
;
case
FactMetaData
:
:
valueTypeInt8
:
case
FactMetaData
:
:
valueTypeInt16
:
case
FactMetaData
:
:
valueTypeInt32
:
convertTo
=
QVariant
::
Int
;
break
;
case
FactMetaData
:
:
valueTypeFloat
:
convertTo
=
QMetaType
::
Float
;
break
;
case
FactMetaData
:
:
valueTypeDouble
:
convertTo
=
QVariant
::
Double
;
break
;
case
FactMetaData
:
:
valueTypeUint8
:
case
FactMetaData
:
:
valueTypeUint16
:
case
FactMetaData
:
:
valueTypeUint32
:
convertTo
=
QVariant
::
UInt
;
break
;
case
FactMetaData
:
:
valueTypeInt8
:
case
FactMetaData
:
:
valueTypeInt16
:
case
FactMetaData
:
:
valueTypeInt32
:
convertTo
=
QVariant
::
Int
;
break
;
case
FactMetaData
:
:
valueTypeFloat
:
convertTo
=
QMetaType
::
Float
;
break
;
case
FactMetaData
:
:
valueTypeDouble
:
convertTo
=
QVariant
::
Double
;
break
;
case
FactMetaData
:
:
valueTypeString
:
qWarning
()
<<
"Internal Error: No support for string parameters"
;
convertTo
=
QVariant
::
String
;
break
;
}
*
convertOk
=
var
.
convert
(
convertTo
);
...
...
src/FirmwarePlugin/PX4/PX4ParameterMetaData.cc
View file @
526e5c53
...
...
@@ -39,22 +39,26 @@ QVariant PX4ParameterMetaData::_stringToTypedVariant(const QString& string, Fact
int
convertTo
=
QVariant
::
Int
;
// keep compiler warning happy
switch
(
type
)
{
case
FactMetaData
:
:
valueTypeUint8
:
case
FactMetaData
:
:
valueTypeUint16
:
case
FactMetaData
:
:
valueTypeUint32
:
convertTo
=
QVariant
::
UInt
;
break
;
case
FactMetaData
:
:
valueTypeInt8
:
case
FactMetaData
:
:
valueTypeInt16
:
case
FactMetaData
:
:
valueTypeInt32
:
convertTo
=
QVariant
::
Int
;
break
;
case
FactMetaData
:
:
valueTypeFloat
:
convertTo
=
QMetaType
::
Float
;
break
;
case
FactMetaData
:
:
valueTypeDouble
:
convertTo
=
QVariant
::
Double
;
break
;
case
FactMetaData
:
:
valueTypeUint8
:
case
FactMetaData
:
:
valueTypeUint16
:
case
FactMetaData
:
:
valueTypeUint32
:
convertTo
=
QVariant
::
UInt
;
break
;
case
FactMetaData
:
:
valueTypeInt8
:
case
FactMetaData
:
:
valueTypeInt16
:
case
FactMetaData
:
:
valueTypeInt32
:
convertTo
=
QVariant
::
Int
;
break
;
case
FactMetaData
:
:
valueTypeFloat
:
convertTo
=
QMetaType
::
Float
;
break
;
case
FactMetaData
:
:
valueTypeDouble
:
convertTo
=
QVariant
::
Double
;
break
;
case
FactMetaData
:
:
valueTypeString
:
qWarning
()
<<
"Internal Error: No support for string parameters"
;
convertTo
=
QVariant
::
String
;
break
;
}
*
convertOk
=
var
.
convert
(
convertTo
);
...
...
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