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
1f68cdcf
Commit
1f68cdcf
authored
Jul 30, 2018
by
Don Gagne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
parent
067c19fe
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
13 deletions
+12
-13
FactValueSliderListModel.cc
src/FactSystem/FactValueSliderListModel.cc
+8
-11
FactValueSliderListModel.h
src/FactSystem/FactValueSliderListModel.h
+4
-2
No files found.
src/FactSystem/FactValueSliderListModel.cc
View file @
1f68cdcf
...
...
@@ -27,7 +27,7 @@ FactValueSliderListModel::FactValueSliderListModel(Fact& fact, QObject* parent)
,
_cPrevValues
(
0
)
,
_cNextValues
(
0
)
,
_initialValue
(
0
)
,
_initialValue
Rounded
(
0
)
,
_initialValue
AtPrecision
(
0
)
,
_increment
(
0
)
{
QQmlEngine
::
setObjectOwnership
(
this
,
QQmlEngine
::
CppOwnership
);
...
...
@@ -47,14 +47,14 @@ int FactValueSliderListModel::resetInitialValue(void)
}
_initialValue
=
_fact
.
cookedValue
().
toDouble
();
_initialValue
Rounded
=
qRound
(
_initialValue
);
_initialValue
AtPrecision
=
_valueAtPrecision
(
_initialValue
);
if
(
qRound
(
_fact
.
rawIncrement
())
==
_fact
.
rawIncrement
())
{
_increment
=
qRound
(
_fact
.
cookedIncrement
());
}
else
{
_increment
=
_fact
.
cookedIncrement
();
}
_cPrevValues
=
qMin
((
_initialValue
-
_fact
.
cookedMin
().
toDouble
())
,
100.0
)
/
_increment
;
_cNextValues
=
qMin
((
_fact
.
cookedMax
().
toDouble
()
-
_initialValue
)
,
100.0
)
/
_increment
;
_cPrevValues
=
qMin
((
_initialValue
-
_fact
.
cookedMin
().
toDouble
())
/
_increment
,
100.0
)
;
_cNextValues
=
qMin
((
_fact
.
cookedMax
().
toDouble
()
-
_initialValue
)
/
_increment
,
100.0
)
;
_initialValueIndex
=
_cPrevValues
;
int
totalValueCount
=
_cPrevValues
+
1
+
_cNextValues
;
...
...
@@ -93,12 +93,9 @@ QVariant FactValueSliderListModel::data(const QModelIndex &index, int role) cons
if
(
cIncrementCount
==
0
)
{
value
=
_initialValue
;
}
else
{
value
=
_initialValueRounded
+
(
cIncrementCount
*
_increment
);
value
=
initialValueAtPrecision
()
+
(
cIncrementCount
*
_increment
);
}
double
precision
=
qPow
(
10
,
_fact
.
decimalPlaces
());
double
atPrecision
=
qRound
(
value
*
precision
)
/
precision
;
//qDebug() << value << precision << atPrecision << _fact.decimalPlaces() << _fact.name();
return
QVariant
(
atPrecision
);
return
QVariant
(
_valueAtPrecision
(
value
));
}
else
if
(
role
==
_valueIndexRole
)
{
return
QVariant
::
fromValue
(
valueIndex
);
}
else
{
...
...
@@ -129,8 +126,8 @@ int FactValueSliderListModel::valueIndexAtModelIndex(int index)
return
data
(
createIndex
(
index
,
0
),
_valueIndexRole
).
toInt
();
}
double
FactValueSliderListModel
::
initialValueAtPrecision
(
void
)
double
FactValueSliderListModel
::
_valueAtPrecision
(
double
value
)
const
{
double
precision
=
qPow
(
10
,
_fact
.
decimalPlaces
());
return
qRound
(
_initialV
alue
*
precision
)
/
precision
;
return
qRound
(
v
alue
*
precision
)
/
precision
;
}
src/FactSystem/FactValueSliderListModel.h
View file @
1f68cdcf
...
...
@@ -25,7 +25,7 @@ public:
/// The initial value of the Fact at the meta data specified decimal place precision
Q_PROPERTY
(
double
initialValueAtPrecision
READ
initialValueAtPrecision
NOTIFY
initialValueAtPrecisionChanged
)
double
initialValueAtPrecision
(
void
)
;
double
initialValueAtPrecision
(
void
)
const
{
return
_initialValueAtPrecision
;
}
Q_INVOKABLE
int
resetInitialValue
(
void
);
Q_INVOKABLE
double
valueAtModelIndex
(
int
index
);
...
...
@@ -35,6 +35,8 @@ signals:
void
initialValueAtPrecisionChanged
(
void
);
private:
double
_valueAtPrecision
(
double
value
)
const
;
// Overrides from QAbstractListModel
int
rowCount
(
const
QModelIndex
&
parent
=
QModelIndex
())
const
override
;
QVariant
data
(
const
QModelIndex
&
index
,
int
role
=
Qt
::
DisplayRole
)
const
override
;
...
...
@@ -48,7 +50,7 @@ private:
int
_cNextValues
;
int
_windowSize
;
double
_initialValue
;
double
_initialValue
Rounded
;
double
_initialValue
AtPrecision
;
double
_increment
;
static
const
int
_valueRole
;
...
...
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