Commit e494ad44 authored by DonLakeFlyer's avatar DonLakeFlyer

Fix element sizing

parent a5b8891b
...@@ -13,10 +13,11 @@ Rectangle { ...@@ -13,10 +13,11 @@ Rectangle {
color: qgcPal.textField color: qgcPal.textField
property Fact fact: undefined 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 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 _margins: (ScreenTools.implicitTextFieldHeight - ScreenTools.defaultFontPixelHeight) / 2
property real _increment: fact.increment property real _increment: fact.increment
property real _value: fact.value property real _value: fact.value
......
...@@ -53,8 +53,8 @@ int FactValueSliderListModel::resetInitialValue(void) ...@@ -53,8 +53,8 @@ int FactValueSliderListModel::resetInitialValue(void)
} else { } else {
_increment = _fact.cookedIncrement(); _increment = _fact.cookedIncrement();
} }
_cPrevValues = qMin((_initialValue - _fact.cookedMin().toDouble()), 1000.0) / _increment; _cPrevValues = qMin((_initialValue - _fact.cookedMin().toDouble()), 100.0) / _increment;
_cNextValues = qMin((_fact.cookedMax().toDouble() - _initialValue), 1000.0) / _increment; _cNextValues = qMin((_fact.cookedMax().toDouble() - _initialValue), 100.0) / _increment;
_initialValueIndex = _cPrevValues; _initialValueIndex = _cPrevValues;
int totalValueCount = _cPrevValues + 1 + _cNextValues; int totalValueCount = _cPrevValues + 1 + _cNextValues;
...@@ -62,6 +62,8 @@ int FactValueSliderListModel::resetInitialValue(void) ...@@ -62,6 +62,8 @@ int FactValueSliderListModel::resetInitialValue(void)
_cValues = totalValueCount; _cValues = totalValueCount;
endInsertRows(); endInsertRows();
emit initialValueAtPrecisionChanged();
return _initialValueIndex; return _initialValueIndex;
} }
...@@ -126,3 +128,9 @@ int FactValueSliderListModel::valueIndexAtModelIndex(int index) ...@@ -126,3 +128,9 @@ int FactValueSliderListModel::valueIndexAtModelIndex(int index)
{ {
return data(createIndex(index, 0), _valueIndexRole).toInt(); return data(createIndex(index, 0), _valueIndexRole).toInt();
} }
double FactValueSliderListModel::initialValueAtPrecision(void)
{
double precision = qPow(10, _fact.decimalPlaces());
return qRound(_initialValue * precision) / precision;
}
...@@ -22,10 +22,18 @@ public: ...@@ -22,10 +22,18 @@ public:
FactValueSliderListModel(Fact& fact, QObject* parent = NULL); FactValueSliderListModel(Fact& fact, QObject* parent = NULL);
~FactValueSliderListModel(); ~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 int resetInitialValue(void);
Q_INVOKABLE double valueAtModelIndex(int index); Q_INVOKABLE double valueAtModelIndex(int index);
Q_INVOKABLE int valueIndexAtModelIndex(int index); Q_INVOKABLE int valueIndexAtModelIndex(int index);
signals:
void initialValueAtPrecisionChanged(void);
private: private:
// Overrides from QAbstractListModel // Overrides from QAbstractListModel
int rowCount(const QModelIndex & parent = QModelIndex()) const override; int rowCount(const QModelIndex & parent = QModelIndex()) const override;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment