Added getter & setter for BCValue
This commit is contained in:
@@ -46,6 +46,19 @@ BCDeviceView::BCDeviceView(QWidget *parent)
|
|||||||
// __fix! ziemlich wildes ge-pointere, hier
|
// __fix! ziemlich wildes ge-pointere, hier
|
||||||
_itemDelegate = new BCValueDelegate( _valueModel.getValueList(), this);
|
_itemDelegate = new BCValueDelegate( _valueModel.getValueList(), this);
|
||||||
setItemDelegateForColumn( 1, _itemDelegate );
|
setItemDelegateForColumn( 1, _itemDelegate );
|
||||||
|
/*
|
||||||
|
//#e0e0e0
|
||||||
|
setStyleSheet( R"(QTableView::item:selected
|
||||||
|
{
|
||||||
|
background-color: green;
|
||||||
|
border: none;
|
||||||
|
}
|
||||||
|
QTableView:focus
|
||||||
|
{
|
||||||
|
outline: none;
|
||||||
|
}
|
||||||
|
})");
|
||||||
|
*/
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -342,7 +342,7 @@ void BCMainWindow::onSyncDeviceView()
|
|||||||
for( const BCValuePtr& value : currentList )
|
for( const BCValuePtr& value : currentList )
|
||||||
{
|
{
|
||||||
// wir setzen auf 'lesen'
|
// wir setzen auf 'lesen'
|
||||||
value->valueFlags.setFlag( BCValue::Flag::ReadMe );
|
value->getValueFlags().setFlag( BCValue::Flag::ReadMe );
|
||||||
|
|
||||||
// statt '_transmitter.onUpdateValue( value )' müssen wir hier
|
// statt '_transmitter.onUpdateValue( value )' müssen wir hier
|
||||||
// über emit requestValueUpdate() zur Thread sysnchronisation
|
// über emit requestValueUpdate() zur Thread sysnchronisation
|
||||||
|
|||||||
@@ -144,21 +144,21 @@ void BCTransmitter::onUpdateValue( BCValuePtrConst valuePtr)
|
|||||||
// Kosmetik
|
// Kosmetik
|
||||||
const BCValue& value = *(valuePtr.get());
|
const BCValue& value = *(valuePtr.get());
|
||||||
|
|
||||||
uint32_t devID = static_cast<uint32_t>(value.deviceID);
|
uint32_t devID = static_cast<uint32_t>(value.getDeviceID());
|
||||||
uint8_t regID = static_cast<uint8_t> (value.registerID);
|
uint8_t regID = static_cast<uint8_t> (value.getRegisterID());
|
||||||
|
|
||||||
// Für den Fehlerfall: Wir senden den alten Wert einfach zurück
|
// Für den Fehlerfall: Wir senden den alten Wert einfach zurück
|
||||||
uint32_t newValue = value.rawValue;
|
uint32_t newValue = value.getRawValue();
|
||||||
BCValue::Flag newState = BCValue::Flag::Failed;
|
BCValue::Flag newState = BCValue::Flag::Failed;
|
||||||
|
|
||||||
if(value.valueFlags.testFlag( BCValue::Flag::WriteMe ) )
|
if(value.getValueFlags().testFlag( BCValue::Flag::WriteMe ) )
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
// oder sollen wir hier beides erlauben ? readFlag & writeFlag ?
|
// oder sollen wir hier beides erlauben ? readFlag & writeFlag ?
|
||||||
// Was kommt dann zuerst? Schreiben und lesen als verify ?
|
// Was kommt dann zuerst? Schreiben und lesen als verify ?
|
||||||
|
|
||||||
else if( value.valueFlags.testFlag( BCValue::Flag::ReadMe ) )
|
else if( value.getValueFlags().testFlag( BCValue::Flag::ReadMe ) )
|
||||||
{
|
{
|
||||||
// wir sind hier im anderen thread! nicht einfach so reinschreiben, nur lesen
|
// wir sind hier im anderen thread! nicht einfach so reinschreiben, nur lesen
|
||||||
TransmitResult result = value.isWord() ? readWordValue( devID, regID ) : readByteValue( devID, regID );
|
TransmitResult result = value.isWord() ? readWordValue( devID, regID ) : readByteValue( devID, regID );
|
||||||
@@ -170,7 +170,7 @@ void BCTransmitter::onUpdateValue( BCValuePtrConst valuePtr)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
emit valueUpdated( value.deviceID, value.indexRow, newState, newValue );
|
emit valueUpdated( value.getDeviceID(), value.getIndexRow(), newState, newValue );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ bool BCValue::isReadOnly() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
double BCValue::calcRatio() const
|
double BCValue::calcMinMaxRatio() const
|
||||||
{
|
{
|
||||||
|
|
||||||
double ratio = 0;
|
double ratio = 0;
|
||||||
|
|||||||
40
bcvalue.h
40
bcvalue.h
@@ -67,6 +67,8 @@ class BCValue
|
|||||||
{
|
{
|
||||||
Q_GADGET
|
Q_GADGET
|
||||||
|
|
||||||
|
friend class BCXmlLoader;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// Aus dem Type ergibt sich
|
// Aus dem Type ergibt sich
|
||||||
@@ -97,11 +99,46 @@ public:
|
|||||||
BCValue( BCDevice::ID deviceID_, BC::ID registerID_ );
|
BCValue( BCDevice::ID deviceID_, BC::ID registerID_ );
|
||||||
|
|
||||||
QString formatValue() const;
|
QString formatValue() const;
|
||||||
double calcRatio() const;
|
double calcMinMaxRatio() const;
|
||||||
void dumpValue() const;
|
void dumpValue() const;
|
||||||
bool isWord() const;
|
bool isWord() const;
|
||||||
bool isReadOnly() const;
|
bool isReadOnly() const;
|
||||||
|
|
||||||
|
Flags& getValueFlags() const noexcept { return valueFlags; }
|
||||||
|
void setValueFlags(Flags newFlags) { valueFlags = newFlags; }
|
||||||
|
|
||||||
|
BCDevice::ID getDeviceID() const noexcept { return deviceID; }
|
||||||
|
//void setDeviceID(BCDevice::ID newDeviceID) { deviceID = newDeviceID; }
|
||||||
|
|
||||||
|
BC::ID getRegisterID() const noexcept { return registerID; }
|
||||||
|
void setRegisterID(BC::ID newRegisterID) { registerID = newRegisterID; }
|
||||||
|
|
||||||
|
ValueType getValueType() const noexcept { return valueType; }
|
||||||
|
void setValueType(ValueType newValueType) { valueType = newValueType; }
|
||||||
|
|
||||||
|
int getIndexRow() const noexcept { return indexRow; }
|
||||||
|
void setIndexRow(int newIndexRow) { indexRow = newIndexRow; }
|
||||||
|
|
||||||
|
QString getLabel() const { return label; }
|
||||||
|
void setLabel(const QString &newLabel) { label = newLabel; }
|
||||||
|
|
||||||
|
uint32_t getRawValue() const noexcept { return rawValue; }
|
||||||
|
void setRawValue(uint32_t newRawValue) const { rawValue = newRawValue; }
|
||||||
|
|
||||||
|
QString getUnitLabel() const { return unitLabel; }
|
||||||
|
void setUnitLabel(const QString &newUnitLabel) { unitLabel = newUnitLabel; }
|
||||||
|
|
||||||
|
double getFactor() const noexcept { return factor; }
|
||||||
|
void setFactor(double newFactor) { factor = newFactor; }
|
||||||
|
|
||||||
|
const OptDouble getOptMin() const { return optMin; }
|
||||||
|
void setOptMin(const OptDouble &newOptMin) { optMin = newOptMin; }
|
||||||
|
|
||||||
|
const OptDouble getOptMax() const { return optMax; }
|
||||||
|
void setOptMax(const OptDouble &newOptMax) { optMax = newOptMax; }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
mutable Flags valueFlags{BCValue::Flag::NoFlag};
|
mutable Flags valueFlags{BCValue::Flag::NoFlag};
|
||||||
BCDevice::ID deviceID{BCDevice::ID::Invalid};
|
BCDevice::ID deviceID{BCDevice::ID::Invalid};
|
||||||
BC::ID registerID{BC::ID::Invalid};
|
BC::ID registerID{BC::ID::Invalid};
|
||||||
@@ -113,6 +150,7 @@ public:
|
|||||||
double factor{1};
|
double factor{1};
|
||||||
OptDouble optMin;
|
OptDouble optMin;
|
||||||
OptDouble optMax;
|
OptDouble optMax;
|
||||||
|
|
||||||
};
|
};
|
||||||
Q_DECLARE_OPERATORS_FOR_FLAGS(BCValue::Flags)
|
Q_DECLARE_OPERATORS_FOR_FLAGS(BCValue::Flags)
|
||||||
|
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ QWidget* BCValueDelegate::createEditor(QWidget *parent, const QStyleOptionViewIt
|
|||||||
{
|
{
|
||||||
const BCValue& bcValue = *(_valueList[ index.row()].get());
|
const BCValue& bcValue = *(_valueList[ index.row()].get());
|
||||||
|
|
||||||
qDebug() << " --- Create EDITOR: " << index.row();
|
qDebug() << " --- Create EDITOR: " << index.row() << " parent: " << parent->objectName();
|
||||||
|
|
||||||
Q_UNUSED(option)
|
Q_UNUSED(option)
|
||||||
Q_UNUSED(index)
|
Q_UNUSED(index)
|
||||||
@@ -121,45 +121,51 @@ void BCValueDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, c
|
|||||||
QStyledItemDelegate::setModelData(editor, model, index);
|
QStyledItemDelegate::setModelData(editor, model, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BCValueDelegate::updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex& index) const
|
/*
|
||||||
{
|
|
||||||
|
|
||||||
Q_UNUSED(index)
|
|
||||||
|
|
||||||
QRect sliderRect = option.rect.adjusted(
|
|
||||||
option.rect.width() - 125, // Von rechts: 115px (Breite der Progress Bar)
|
|
||||||
0, // Oben: kein Offset
|
|
||||||
-8, // Rechts: 8px Padding
|
|
||||||
0 // Unten: kein Offset
|
|
||||||
);
|
|
||||||
editor->setGeometry(sliderRect); // Slider nur über Progress Bar
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
QSize BCValueDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex& index) const
|
QSize BCValueDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex& index) const
|
||||||
{
|
{
|
||||||
return QStyledItemDelegate::sizeHint(option,index);
|
return QStyledItemDelegate::sizeHint(option,index);
|
||||||
/*
|
|
||||||
QStyleOptionViewItem opt = option;
|
QStyleOptionViewItem opt = option;
|
||||||
initStyleOption(&opt, index);
|
initStyleOption(&opt, index);
|
||||||
opt.text = formatDisplayString(index);
|
opt.text = formatDisplayString(index);
|
||||||
|
|
||||||
QStyle *style = opt.widget ? opt.widget->style() : QApplication::style();
|
QStyle *style = opt.widget ? opt.widget->style() : QApplication::style();
|
||||||
return style->sizeFromContents(QStyle::CT_ItemViewItem, &opt, QSize(), opt.widget);
|
return style->sizeFromContents(QStyle::CT_ItemViewItem, &opt, QSize(), opt.widget);
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
// Cpp
|
||||||
|
void BCValueDelegate::destroyEditor(QWidget *editor, const QModelIndex &index) const
|
||||||
|
{
|
||||||
|
// 1. Kontext sichern (bevor der Editor gelöscht wird)
|
||||||
|
// Der Editor ist meist ein Kind des Viewports
|
||||||
|
QWidget *viewport = editor->parentWidget();
|
||||||
|
QRect rect = editor->geometry();
|
||||||
|
|
||||||
|
// 2. Basis-Implementierung aufrufen
|
||||||
|
// WICHTIG: Das löscht (delete) den Editor-Pointer!
|
||||||
|
QStyledItemDelegate::destroyEditor(editor, index);
|
||||||
|
|
||||||
|
// 3. Jetzt den Bereich neu zeichnen ("Dirty Rect")
|
||||||
|
if (viewport)
|
||||||
|
{
|
||||||
|
// Wir nutzen das Rechteck, wo der Editor WAR.
|
||||||
|
qDebug() << " --- DESTROY: " << viewport->objectName() << " : " << rect;
|
||||||
|
viewport->update(rect);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
void BCValueDelegate::paint(QPainter *painter, const QStyleOptionViewItem& option, const QModelIndex& index) const
|
void BCValueDelegate::paint(QPainter *painter, const QStyleOptionViewItem& option, const QModelIndex& index) const
|
||||||
{
|
{
|
||||||
qDebug() << " ---paint:" << index.row();
|
|
||||||
|
|
||||||
// Standard-Zeichnen (Text, Hintergrund, Selection) durchführen
|
// Standard-Zeichnen (Text, Hintergrund, Selection) durchführen
|
||||||
QStyledItemDelegate::paint(painter, option, index);
|
QStyledItemDelegate::paint(painter, option, index);
|
||||||
|
|
||||||
int row = index.row();
|
int row = index.row();
|
||||||
|
|
||||||
if( index.column() == 1 )
|
if( index.column() == 1 )
|
||||||
{
|
{
|
||||||
if( row>-1 && row <= _valueList.size() )
|
if( row>-1 && row <= _valueList.size() )
|
||||||
{
|
{
|
||||||
@@ -174,9 +180,6 @@ void BCValueDelegate::paint(QPainter *painter, const QStyleOptionViewItem& optio
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void BCValueDelegate::paintHighlightRow(QPainter* painter, const QStyleOptionViewItem& option, int row) const
|
void BCValueDelegate::paintHighlightRow(QPainter* painter, const QStyleOptionViewItem& option, int row) const
|
||||||
{
|
{
|
||||||
painter->save();
|
painter->save();
|
||||||
@@ -205,8 +208,23 @@ void BCValueDelegate::paintHighlightRow(QPainter* painter, const QStyleOptionVie
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void BCValueDelegate::updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex& index) const
|
||||||
|
{
|
||||||
|
|
||||||
|
Q_UNUSED(index)
|
||||||
|
|
||||||
|
QRect sliderRect = option.rect.adjusted(
|
||||||
|
option.rect.width() - cTextBlockOffset, // Von rechts: cTextBlockOffset (==130) px (Breite der Progress Bar)
|
||||||
|
0, // Oben: kein Offset
|
||||||
|
-cPaddingRight, // Rechts: 8px Padding
|
||||||
|
0 // Unten: kein Offset
|
||||||
|
);
|
||||||
|
editor->setGeometry(sliderRect); // Slider nur über Progress Bar
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Zeichnet eine passiven Slider, um den Wertebereich des übergebenen BCValue anzuzeigen.
|
* @brief Zeichnet eine passiven Slider, um den möglichen Wertebereich des übergebenen BCValue anzuzeigen.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void BCValueDelegate::paintSliderIndicator(QPainter* painter, const QStyleOptionViewItem& option, const BCValue& bcValue) const
|
void BCValueDelegate::paintSliderIndicator(QPainter* painter, const QStyleOptionViewItem& option, const BCValue& bcValue) const
|
||||||
@@ -215,17 +233,22 @@ void BCValueDelegate::paintSliderIndicator(QPainter* painter, const QStyleOption
|
|||||||
painter->save();
|
painter->save();
|
||||||
painter->setRenderHint(QPainter::Antialiasing);
|
painter->setRenderHint(QPainter::Antialiasing);
|
||||||
|
|
||||||
QRect barRect = option.rect.adjusted(option.rect.width() - 130,
|
int newX = option.rect.width() - cTextBlockOffset;
|
||||||
|
|
||||||
|
QRect barRect = option.rect.adjusted( newX,
|
||||||
option.rect.height() / 2 + 1,
|
option.rect.height() / 2 + 1,
|
||||||
-8,
|
- option.rect.width() + cTextBlockOffset + 117 - 18,
|
||||||
-option.rect.height() / 2 - 3);
|
-option.rect.height() / 2 - 3);
|
||||||
|
|
||||||
double ratio = bcValue.calcRatio();
|
|
||||||
|
double ratio = bcValue.calcMinMaxRatio();
|
||||||
if( ratio)
|
if( ratio)
|
||||||
{
|
{
|
||||||
// Mini Progress Bar
|
// Mini Progress Bar: der Gesamtbereich
|
||||||
painter->setPen(Qt::NoPen);
|
painter->setPen(Qt::NoPen);
|
||||||
painter->setBrush(QColor(0xE0E0E0));
|
painter->setBrush(QColor(0xE0E0E0));
|
||||||
|
//QColor disabledText = option.palette.color(QPalette::Disabled, QPalette::Text);
|
||||||
|
//painter->setBrush(disabledText);
|
||||||
painter->drawRoundedRect(barRect, 2, 2);
|
painter->drawRoundedRect(barRect, 2, 2);
|
||||||
|
|
||||||
QRect fillRect = barRect;
|
QRect fillRect = barRect;
|
||||||
@@ -256,7 +279,7 @@ void BCValueDelegate::paintSliderIndicator(QPainter* painter, const QStyleOption
|
|||||||
/*
|
/*
|
||||||
// baby-Slider-Indikator zeichnen
|
// baby-Slider-Indikator zeichnen
|
||||||
// Anteil zwischen min und max berechnen
|
// Anteil zwischen min und max berechnen
|
||||||
double ratio = bcValue.calcRatio();
|
double ratio = bcValue.calcMinMaxRatio();
|
||||||
if( !ratio)
|
if( !ratio)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|||||||
@@ -57,8 +57,8 @@ public:
|
|||||||
void setEditorData(QWidget *editor, const QModelIndex& index) const override;
|
void setEditorData(QWidget *editor, const QModelIndex& index) const override;
|
||||||
void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex& index) const override;
|
void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex& index) const override;
|
||||||
void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex& index) const override;
|
void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex& index) const override;
|
||||||
|
//void destroyEditor(QWidget *editor, const QModelIndex &index) const override;
|
||||||
QSize sizeHint(const QStyleOptionViewItem &option,const QModelIndex& index) const override;
|
//QSize sizeHint(const QStyleOptionViewItem &option,const QModelIndex& index) const override;
|
||||||
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex& index) const override;
|
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex& index) const override;
|
||||||
|
|
||||||
void clearAllHighlights();
|
void clearAllHighlights();
|
||||||
@@ -68,10 +68,6 @@ public slots:
|
|||||||
void onHighlightRow(int row);
|
void onHighlightRow(int row);
|
||||||
|
|
||||||
|
|
||||||
signals:
|
|
||||||
|
|
||||||
//void viewUpdateNeeded();
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
void updateRow(int row);
|
void updateRow(int row);
|
||||||
@@ -87,10 +83,13 @@ protected:
|
|||||||
|
|
||||||
QPropertyAnimation* _animation{};
|
QPropertyAnimation* _animation{};
|
||||||
|
|
||||||
|
|
||||||
QHash<int, qreal> _rowOpacities;
|
QHash<int, qreal> _rowOpacities;
|
||||||
QHash<int, QVariantAnimation*> _rowAnimations;
|
QHash<int, QVariantAnimation*> _rowAnimations;
|
||||||
|
|
||||||
|
static constexpr int cTextBlockOffset = 130;
|
||||||
|
static constexpr int cPaddingRight = 8;
|
||||||
|
static constexpr int cSliderWidth = 117;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
#include <bcsliderstyle.h>
|
#include <bcsliderstyle.h>
|
||||||
#include <bcvalueeditor.h>
|
#include <bcvalueeditor.h>
|
||||||
|
#include <bcvalue.h>
|
||||||
|
|
||||||
|
|
||||||
BCValueEditor::BCValueEditor(const BCValue& bcValue, QWidget *parent )
|
BCValueEditor::BCValueEditor(const BCValue& bcValue, QWidget *parent )
|
||||||
@@ -9,12 +9,18 @@ BCValueEditor::BCValueEditor(const BCValue& bcValue, QWidget *parent )
|
|||||||
{
|
{
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
|
|
||||||
|
// wir wollen ja modern sein
|
||||||
_slider->setStyle(new BCSliderStyle());
|
_slider->setStyle(new BCSliderStyle());
|
||||||
setAutoFillBackground(true);
|
setAutoFillBackground(true);
|
||||||
|
|
||||||
QSizePolicy sp = _commitButton->sizePolicy();
|
QSizePolicy sp = _commitButton->sizePolicy();
|
||||||
sp.setRetainSizeWhenHidden(true); // <--- Das ist der magische Schalter
|
sp.setRetainSizeWhenHidden(true); // <--- Das ist der magische Schalter
|
||||||
_commitButton->setSizePolicy(sp);
|
_commitButton->setSizePolicy(sp);
|
||||||
|
|
||||||
|
double ratio = bcValue.calcMinMaxRatio();
|
||||||
|
_slider->setRange(0, 100);
|
||||||
|
_slider->setValue( bcValue.rawValue * ratio);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
_slider = new QSlider(Qt::Horizontal, this);
|
_slider = new QSlider(Qt::Horizontal, this);
|
||||||
_slider->setRange(0, 100);
|
_slider->setRange(0, 100);
|
||||||
@@ -53,13 +59,12 @@ BCValueEditor::BCValueEditor(const BCValue& bcValue, QWidget *parent )
|
|||||||
|
|
||||||
int BCValueEditor::getValue() const
|
int BCValueEditor::getValue() const
|
||||||
{
|
{
|
||||||
qDebug() << " -- jajaja: "<< size();
|
|
||||||
return _slider->value();
|
return _slider->value();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BCValueEditor::setValue(int val)
|
void BCValueEditor::setValue(int val)
|
||||||
{
|
{
|
||||||
// WICHTIG: Block Signals verhindern Endlosschleifen, falls das Model
|
// Block Signals verhindern Endlosschleifen, falls das Model
|
||||||
// das Widget während des Updates neu setzt (passiert manchmal bei Live-Updates).
|
// das Widget während des Updates neu setzt (passiert manchmal bei Live-Updates).
|
||||||
if (val != _slider->value())
|
if (val != _slider->value())
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ void BCValueModel::updateValue(int row, BCValue::Flags newState, uint32_t rawVal
|
|||||||
|
|
||||||
// Obacht hier!
|
// Obacht hier!
|
||||||
//value.valueFlags = state;
|
//value.valueFlags = state;
|
||||||
value.rawValue = rawValue;
|
value.setRawValue( rawValue );
|
||||||
|
|
||||||
QModelIndex idx = index(row,1);
|
QModelIndex idx = index(row,1);
|
||||||
|
|
||||||
@@ -148,12 +148,12 @@ QVariant BCValueModel::data(const QModelIndex& index, int role) const
|
|||||||
const BCValue& value = *(_valueList.at( row ).get());
|
const BCValue& value = *(_valueList.at( row ).get());
|
||||||
|
|
||||||
if( col == 0 )
|
if( col == 0 )
|
||||||
return value.label;
|
return value.getLabel();
|
||||||
|
|
||||||
if( col == 1)
|
if( col == 1)
|
||||||
{
|
{
|
||||||
if( role == Qt::DisplayRole )
|
if( role == Qt::DisplayRole )
|
||||||
return QString("%1 %2").arg( value.formatValue(), value.unitLabel);
|
return QString("%1 %2").arg( value.formatValue(), value.getUnitLabel());
|
||||||
|
|
||||||
return value.formatValue();
|
return value.formatValue();
|
||||||
}
|
}
|
||||||
@@ -185,6 +185,8 @@ bool BCValueModel::setData(const QModelIndex& index, const QVariant& variant, in
|
|||||||
{
|
{
|
||||||
BCValuePtr value = _valueList[index.row()];
|
BCValuePtr value = _valueList[index.row()];
|
||||||
|
|
||||||
|
qDebug() << "--- YES! " << variant.toInt();
|
||||||
|
|
||||||
// Wir erwarten hier nur den Value-Teil (vom Slider/Editor)
|
// Wir erwarten hier nur den Value-Teil (vom Slider/Editor)
|
||||||
// Checken ob Int oder Double
|
// Checken ob Int oder Double
|
||||||
if (variant.canConvert<int>())
|
if (variant.canConvert<int>())
|
||||||
@@ -195,7 +197,8 @@ bool BCValueModel::setData(const QModelIndex& index, const QVariant& variant, in
|
|||||||
qDebug() << "--- YES! " << variant.toInt();
|
qDebug() << "--- YES! " << variant.toInt();
|
||||||
//emit makeSimonHappy();
|
//emit makeSimonHappy();
|
||||||
}
|
}
|
||||||
value->rawValue = variant.toInt();
|
// QUARK!
|
||||||
|
value->setRawValue( variant.toInt() );
|
||||||
}
|
}
|
||||||
|
|
||||||
emit dataChanged(index, index, {Qt::DisplayRole, Qt::EditRole});
|
emit dataChanged(index, index, {Qt::DisplayRole, Qt::EditRole});
|
||||||
|
|||||||
@@ -149,7 +149,7 @@ void BCXmlLoader::loadXmlBikeDeviceData(BCDevice::ID deviceID)
|
|||||||
if(newValue)
|
if(newValue)
|
||||||
{
|
{
|
||||||
// wir merken uns gleich den index in der Werteliste
|
// wir merken uns gleich den index in der Werteliste
|
||||||
(*newValue)->indexRow = currentValues.size();
|
(*newValue)->setIndexRow( currentValues.size() );
|
||||||
currentValues.push_back( *newValue );
|
currentValues.push_back( *newValue );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
<Bike name='franken-wheeler'>
|
<Bike name='franken-wheeler'>
|
||||||
|
|
||||||
|
|
||||||
<Device Type='Motor'>
|
<Device Type='Motor'>
|
||||||
<Value ID='Motor_Rev_Hw' Label='Hardware Version' ValueType='Plain' ReadOnly='true' />
|
<Value ID='Motor_Rev_Hw' Label='Hardware Version' ValueType='Plain' ReadOnly='true' />
|
||||||
<Value ID='Motor_Rev_Sw' Label='Software Version' ValueType='Plain' ReadOnly='true' />
|
<Value ID='Motor_Rev_Sw' Label='Software Version' ValueType='Plain' ReadOnly='true' />
|
||||||
@@ -25,8 +24,8 @@
|
|||||||
<Value ID='Cons_Sn_Product_Hi' Label='Product Number' IsWord='true' ValueType='Plain' ReadOnly='true'/>
|
<Value ID='Cons_Sn_Product_Hi' Label='Product Number' IsWord='true' ValueType='Plain' ReadOnly='true'/>
|
||||||
<Value ID='Cons_Sn_Oem_Hi' Label='OEM Number' IsWord='true' ValueType='Plain' ReadOnly='true' />
|
<Value ID='Cons_Sn_Oem_Hi' Label='OEM Number' IsWord='true' ValueType='Plain' ReadOnly='true' />
|
||||||
|
|
||||||
<Value ID='Cons_Assist_Initlevel' Label='Assistance Init Level' Min='0' Max='4' ValueType='Number'/>
|
<!--<Value ID='Cons_Assist_Initlevel' Label='Assistance Init Level' Min='0' Max='4' ValueType='Number'/>-->
|
||||||
|
<Value ID='Cons_Assist_Initlevel' Label='Assistance Init Level' Min='0' Max='100' UnitLabel='%' ValueType='Float'/>
|
||||||
<Value ID='Cons_Assist_Level_1' Label='Assistance Level 1' Factor='1.5625' UnitLabel='%' Min='0' Max='400' ValueType='Float'/>
|
<Value ID='Cons_Assist_Level_1' Label='Assistance Level 1' Factor='1.5625' UnitLabel='%' Min='0' Max='400' ValueType='Float'/>
|
||||||
<Value ID='Cons_Assist_Level_2' Label='Assistance Level 2' Factor='1.5625' UnitLabel='%' Min='0' Max='400' ValueType='Float'/>
|
<Value ID='Cons_Assist_Level_2' Label='Assistance Level 2' Factor='1.5625' UnitLabel='%' Min='0' Max='400' ValueType='Float'/>
|
||||||
<Value ID='Cons_Assist_Level_3' Label='Assistance Level 3' Factor='1.5625' UnitLabel='%' Min='0' Max='400' ValueType='Float'/>
|
<Value ID='Cons_Assist_Level_3' Label='Assistance Level 3' Factor='1.5625' UnitLabel='%' Min='0' Max='400' ValueType='Float'/>
|
||||||
|
|||||||
Reference in New Issue
Block a user