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
3a2a3584
Unverified
Commit
3a2a3584
authored
Jul 07, 2018
by
Don Gagne
Committed by
GitHub
Jul 07, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #6694 from DonLakeFlyer/SliderFix
FactValueSlider: Fix element sizing
parents
d264eda0
e494ad44
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
4 deletions
+21
-4
FactValueSlider.qml
src/FactSystem/FactControls/FactValueSlider.qml
+3
-2
FactValueSliderListModel.cc
src/FactSystem/FactValueSliderListModel.cc
+10
-2
FactValueSliderListModel.h
src/FactSystem/FactValueSliderListModel.h
+8
-0
No files found.
src/FactSystem/FactControls/FactValueSlider.qml
View file @
3a2a3584
...
...
@@ -13,10 +13,11 @@ Rectangle {
color
:
qgcPal
.
textField
property
Fact
fact
:
undefined
property
int
digitCount
:
4
///< The number of digits to show for each value
property
int
digitCount
:
4
///< The
minimum
number of digits to show for each value
property
int
incrementSlots
:
1
///< The number of visible slots to left/right of center value
property
int
_totalDigitCount
:
digitCount
+
1
+
fact
.
units
.
length
property
int
_adjustedDigitCount
:
Math
.
max
(
digitCount
,
_model
.
initialValueAtPrecision
.
toString
().
length
)
property
int
_totalDigitCount
:
_adjustedDigitCount
+
1
+
fact
.
units
.
length
property
real
_margins
:
(
ScreenTools
.
implicitTextFieldHeight
-
ScreenTools
.
defaultFontPixelHeight
)
/
2
property
real
_increment
:
fact
.
increment
property
real
_value
:
fact
.
value
...
...
src/FactSystem/FactValueSliderListModel.cc
View file @
3a2a3584
...
...
@@ -53,8 +53,8 @@ int FactValueSliderListModel::resetInitialValue(void)
}
else
{
_increment
=
_fact
.
cookedIncrement
();
}
_cPrevValues
=
qMin
((
_initialValue
-
_fact
.
cookedMin
().
toDouble
()),
100
0
.0
)
/
_increment
;
_cNextValues
=
qMin
((
_fact
.
cookedMax
().
toDouble
()
-
_initialValue
),
100
0
.0
)
/
_increment
;
_cPrevValues
=
qMin
((
_initialValue
-
_fact
.
cookedMin
().
toDouble
()),
100.0
)
/
_increment
;
_cNextValues
=
qMin
((
_fact
.
cookedMax
().
toDouble
()
-
_initialValue
),
100.0
)
/
_increment
;
_initialValueIndex
=
_cPrevValues
;
int
totalValueCount
=
_cPrevValues
+
1
+
_cNextValues
;
...
...
@@ -62,6 +62,8 @@ int FactValueSliderListModel::resetInitialValue(void)
_cValues
=
totalValueCount
;
endInsertRows
();
emit
initialValueAtPrecisionChanged
();
return
_initialValueIndex
;
}
...
...
@@ -126,3 +128,9 @@ int FactValueSliderListModel::valueIndexAtModelIndex(int index)
{
return
data
(
createIndex
(
index
,
0
),
_valueIndexRole
).
toInt
();
}
double
FactValueSliderListModel
::
initialValueAtPrecision
(
void
)
{
double
precision
=
qPow
(
10
,
_fact
.
decimalPlaces
());
return
qRound
(
_initialValue
*
precision
)
/
precision
;
}
src/FactSystem/FactValueSliderListModel.h
View file @
3a2a3584
...
...
@@ -22,10 +22,18 @@ public:
FactValueSliderListModel
(
Fact
&
fact
,
QObject
*
parent
=
NULL
);
~
FactValueSliderListModel
();
/// 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
);
Q_INVOKABLE
int
resetInitialValue
(
void
);
Q_INVOKABLE
double
valueAtModelIndex
(
int
index
);
Q_INVOKABLE
int
valueIndexAtModelIndex
(
int
index
);
signals:
void
initialValueAtPrecisionChanged
(
void
);
private:
// Overrides from QAbstractListModel
int
rowCount
(
const
QModelIndex
&
parent
=
QModelIndex
())
const
override
;
...
...
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