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
ab9e52ea
Commit
ab9e52ea
authored
Apr 27, 2018
by
Jacob Walser
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
UnitsSettings: rework/bugfix metadata translators setup
parent
1dcbcf61
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
14 deletions
+48
-14
FactMetaData.cc
src/FactSystem/FactMetaData.cc
+46
-12
FactMetaData.h
src/FactSystem/FactMetaData.h
+2
-2
No files found.
src/FactSystem/FactMetaData.cc
View file @
ab9e52ea
...
...
@@ -616,7 +616,7 @@ void FactMetaData::setBuiltInTranslator(void)
for
(
size_t
i
=
0
;
i
<
sizeof
(
_rgBuiltInTranslations
)
/
sizeof
(
_rgBuiltInTranslations
[
0
]);
i
++
)
{
const
BuiltInTranslation_s
*
pBuiltInTranslation
=
&
_rgBuiltInTranslations
[
i
];
if
(
pBuiltInTranslation
->
rawUnits
==
_rawUnits
.
toLower
())
{
if
(
pBuiltInTranslation
->
rawUnits
.
toLower
()
==
_rawUnits
.
toLower
())
{
_cookedUnits
=
pBuiltInTranslation
->
cookedUnits
;
setTranslators
(
pBuiltInTranslation
->
rawTranslator
,
pBuiltInTranslation
->
cookedTranslator
);
return
;
...
...
@@ -875,13 +875,33 @@ void FactMetaData::_setAppSettingsTranslators(void)
if
(
!
_enumStrings
.
count
()
&&
(
type
()
==
valueTypeDouble
||
type
()
==
valueTypeFloat
))
{
for
(
size_t
i
=
0
;
i
<
sizeof
(
_rgAppSettingsTranslations
)
/
sizeof
(
_rgAppSettingsTranslations
[
0
]);
i
++
)
{
const
AppSettingsTranslation_s
*
pAppSettingsTranslation
=
&
_rgAppSettingsTranslations
[
i
];
if
(
pAppSettingsTranslation
->
rawUnits
==
_rawUnits
.
toLower
()
&&
(
(
pAppSettingsTranslation
->
unitType
==
UnitTemperature
&&
pAppSettingsTranslation
->
unitOption
==
qgcApp
()
->
toolbox
()
->
settingsManager
()
->
unitsSettings
()
->
temperatureUnits
()
->
rawValue
().
toUInt
())
||
(
pAppSettingsTranslation
->
unitType
==
UnitSpeed
&&
pAppSettingsTranslation
->
unitOption
==
qgcApp
()
->
toolbox
()
->
settingsManager
()
->
unitsSettings
()
->
speedUnits
()
->
rawValue
().
toUInt
())
||
(
pAppSettingsTranslation
->
unitType
==
UnitDistance
&&
pAppSettingsTranslation
->
unitOption
==
qgcApp
()
->
toolbox
()
->
settingsManager
()
->
unitsSettings
()
->
distanceUnits
()
->
rawValue
().
toUInt
())
||
(
pAppSettingsTranslation
->
unitType
==
UnitArea
&&
pAppSettingsTranslation
->
unitOption
==
qgcApp
()
->
toolbox
()
->
settingsManager
()
->
unitsSettings
()
->
areaUnits
()
->
rawValue
().
toUInt
())))
{
_cookedUnits
=
pAppSettingsTranslation
->
cookedUnits
;
if
(
_rawUnits
.
toLower
()
!=
pAppSettingsTranslation
->
rawUnits
.
toLower
())
{
continue
;
}
UnitsSettings
*
settings
=
qgcApp
()
->
toolbox
()
->
settingsManager
()
->
unitsSettings
();
uint
settingsUnits
=
0
;
switch
(
pAppSettingsTranslation
->
unitType
)
{
case
UnitDistance
:
settingsUnits
=
settings
->
distanceUnits
()
->
rawValue
().
toUInt
();
break
;
case
UnitSpeed
:
settingsUnits
=
settings
->
speedUnits
()
->
rawValue
().
toUInt
();
break
;
case
UnitArea
:
settingsUnits
=
settings
->
areaUnits
()
->
rawValue
().
toUInt
();
break
;
case
UnitTemperature
:
settingsUnits
=
settings
->
temperatureUnits
()
->
rawValue
().
toUInt
();
break
;
default:
break
;
}
if
(
settingsUnits
==
pAppSettingsTranslation
->
unitOption
)
{
_cookedUnits
=
pAppSettingsTranslation
->
cookedUnits
;
setTranslators
(
pAppSettingsTranslation
->
rawTranslator
,
pAppSettingsTranslation
->
cookedTranslator
);
return
;
}
...
...
@@ -893,8 +913,15 @@ const FactMetaData::AppSettingsTranslation_s* FactMetaData::_findAppSettingsDist
{
for
(
size_t
i
=
0
;
i
<
sizeof
(
_rgAppSettingsTranslations
)
/
sizeof
(
_rgAppSettingsTranslations
[
0
]);
i
++
)
{
const
AppSettingsTranslation_s
*
pAppSettingsTranslation
=
&
_rgAppSettingsTranslations
[
i
];
if
(
pAppSettingsTranslation
->
rawUnits
==
rawUnits
.
toLower
()
&&
(
pAppSettingsTranslation
->
unitType
==
UnitDistance
&&
pAppSettingsTranslation
->
unitOption
==
qgcApp
()
->
toolbox
()
->
settingsManager
()
->
unitsSettings
()
->
distanceUnits
()
->
rawValue
().
toUInt
()))
{
if
(
rawUnits
.
toLower
()
!=
pAppSettingsTranslation
->
rawUnits
.
toLower
())
{
continue
;
}
uint
settingsUnits
=
qgcApp
()
->
toolbox
()
->
settingsManager
()
->
unitsSettings
()
->
areaUnits
()
->
rawValue
().
toUInt
();
if
(
pAppSettingsTranslation
->
unitType
==
UnitDistance
&&
pAppSettingsTranslation
->
unitOption
==
settingsUnits
)
{
return
pAppSettingsTranslation
;
}
}
...
...
@@ -905,8 +932,15 @@ const FactMetaData::AppSettingsTranslation_s* FactMetaData::_findAppSettingsArea
{
for
(
size_t
i
=
0
;
i
<
sizeof
(
_rgAppSettingsTranslations
)
/
sizeof
(
_rgAppSettingsTranslations
[
0
]);
i
++
)
{
const
AppSettingsTranslation_s
*
pAppSettingsTranslation
=
&
_rgAppSettingsTranslations
[
i
];
if
(
pAppSettingsTranslation
->
rawUnits
==
rawUnits
.
toLower
()
&&
(
pAppSettingsTranslation
->
unitType
==
UnitArea
&&
pAppSettingsTranslation
->
unitOption
==
qgcApp
()
->
toolbox
()
->
settingsManager
()
->
unitsSettings
()
->
areaUnits
()
->
rawValue
().
toUInt
()))
{
if
(
rawUnits
.
toLower
()
!=
pAppSettingsTranslation
->
rawUnits
.
toLower
())
{
continue
;
}
uint
settingsUnits
=
qgcApp
()
->
toolbox
()
->
settingsManager
()
->
unitsSettings
()
->
areaUnits
()
->
rawValue
().
toUInt
();
if
(
pAppSettingsTranslation
->
unitType
==
UnitArea
&&
pAppSettingsTranslation
->
unitOption
==
settingsUnits
)
{
return
pAppSettingsTranslation
;
}
}
...
...
src/FactSystem/FactMetaData.h
View file @
ab9e52ea
...
...
@@ -216,7 +216,7 @@ private:
};
struct
AppSettingsTranslation_s
{
const
char
*
rawUnits
;
QString
rawUnits
;
const
char
*
cookedUnits
;
UnitTypes
unitType
;
uint32_t
unitOption
;
...
...
@@ -265,7 +265,7 @@ private:
}
constants
;
struct
BuiltInTranslation_s
{
const
char
*
rawUnits
;
QString
rawUnits
;
const
char
*
cookedUnits
;
Translator
rawTranslator
;
Translator
cookedTranslator
;
...
...
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