Further renamings.
This commit is contained in:
@@ -26,7 +26,7 @@ windows
|
||||
|
||||
SOURCES += \
|
||||
bc.cpp \
|
||||
bcdata.cpp \
|
||||
bcdataitem.cpp \
|
||||
bcdatamodel.cpp \
|
||||
bcitemdelegate.cpp \
|
||||
bctransmitter.cpp \
|
||||
@@ -41,7 +41,7 @@ HEADERS += \
|
||||
bc.h \
|
||||
bccandriver.h \
|
||||
bccandrivertinycan.h \
|
||||
bcdata.h \
|
||||
bcdataitem.h \
|
||||
bcdatamodel.h \
|
||||
bcitemdelegate.h \
|
||||
bcmainwindow.h \
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
#include <QMetaEnum>
|
||||
|
||||
|
||||
#include <bcdata.h>
|
||||
#include <bcdataitem.h>
|
||||
|
||||
BCDataType::BCDataType()
|
||||
{
|
||||
@@ -46,18 +46,18 @@ BCDataType::BCDataType( TypeID ID_, QString unitLabel_, optDouble factor_, optDo
|
||||
///-------------------------------
|
||||
|
||||
|
||||
BCData::BCData(const BCDataType& valueType_, BCDevice::ID deviceID_, BC::ID registerID_)
|
||||
BCDataItem::BCDataItem(const BCDataType& valueType_, BCDevice::ID deviceID_, BC::ID registerID_)
|
||||
: valueType{valueType_}, deviceID{deviceID_}, registerID{registerID_}
|
||||
{
|
||||
value = "--";
|
||||
}
|
||||
|
||||
void BCData::readRawValue( const BCAbstractTransmitter& transmitter ) const
|
||||
void BCDataItem::readRawValue( const BCAbstractTransmitter& transmitter ) const
|
||||
{
|
||||
bcdata_t rawValue = transmitter.readRawValue( deviceID, registerID );
|
||||
}
|
||||
|
||||
void BCData::writeRawValue( const BCAbstractTransmitter& transmitter ) const
|
||||
void BCDataItem::writeRawValue( const BCAbstractTransmitter& transmitter ) const
|
||||
{
|
||||
|
||||
}
|
||||
@@ -28,8 +28,8 @@
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#ifndef BCDATA_H
|
||||
#define BCDATA_H
|
||||
#ifndef BCDATAITEM_H
|
||||
#define BCDATAITEM_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
@@ -114,12 +114,12 @@ public:
|
||||
using BCDataTypeCRef = std::optional<std::reference_wrapper<const BCDataType>>;
|
||||
|
||||
|
||||
class BCData
|
||||
class BCDataItem
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
BCData( const BCDataType& valueType_, BCDevice::ID deviceID_, BC::ID registerID_ );
|
||||
BCDataItem( const BCDataType& valueType_, BCDevice::ID deviceID_, BC::ID registerID_ );
|
||||
|
||||
void readRawValue( const BCAbstractTransmitter& transmitter ) const;
|
||||
void writeRawValue( const BCAbstractTransmitter& transmitter ) const;
|
||||
@@ -141,7 +141,7 @@ public:
|
||||
|
||||
|
||||
};
|
||||
Q_DECLARE_METATYPE(BCData*)
|
||||
Q_DECLARE_METATYPE(BCDataItem*)
|
||||
|
||||
|
||||
struct BCDataParams
|
||||
@@ -168,7 +168,7 @@ constexpr auto to_u(E e) noexcept {
|
||||
}
|
||||
*/
|
||||
|
||||
using BCDataList = QVector<BCData>;
|
||||
using BCDataList = QVector<BCDataItem>;
|
||||
|
||||
|
||||
#endif // BCDATA_H
|
||||
#endif // BCDATAITEM_H
|
||||
@@ -35,7 +35,7 @@
|
||||
|
||||
BCDataModel::BCDataModel(QObject *parent) : QAbstractListModel(parent) {}
|
||||
|
||||
void BCDataModel::addValue(const BCData &val)
|
||||
void BCDataModel::addValue(const BCDataItem& val)
|
||||
{
|
||||
int row = _valueList.size();
|
||||
beginInsertRows(QModelIndex(), row, row);
|
||||
@@ -68,7 +68,7 @@ QVariant BCDataModel::data(const QModelIndex& index, int role) const
|
||||
if (!index.isValid() || row >= _valueList.size())
|
||||
return QVariant();
|
||||
|
||||
BCData& entry = const_cast<BCData&>(_valueList.at( row ));
|
||||
BCDataItem& entry = const_cast<BCDataItem&>(_valueList.at( row ));
|
||||
entry.rowInModel = row;
|
||||
|
||||
if (role == Qt::DisplayRole || role == Qt::EditRole)
|
||||
@@ -91,7 +91,7 @@ bool BCDataModel::setData(const QModelIndex &index, const QVariant &value, int r
|
||||
{
|
||||
if (index.isValid() && role == Qt::EditRole)
|
||||
{
|
||||
BCData item = _valueList[index.row()];
|
||||
BCDataItem item = _valueList[index.row()];
|
||||
|
||||
// Wir erwarten hier nur den Value-Teil (vom Slider/Editor)
|
||||
// Checken ob Int oder Double
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
|
||||
#include <QAbstractTableModel>
|
||||
|
||||
#include <bcdata.h>
|
||||
#include <bcdataitem.h>
|
||||
|
||||
|
||||
class BCDataModel : public QAbstractListModel
|
||||
@@ -44,7 +44,7 @@ public:
|
||||
|
||||
explicit BCDataModel(QObject *parent = nullptr);
|
||||
|
||||
void addValue(const BCData &val);
|
||||
void addValue(const BCDataItem& val);
|
||||
void setValueList(const BCDataList& valueList);
|
||||
BCDataList& getValueList();
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include <QPainter>
|
||||
|
||||
#include "bcitemdelegate.h"
|
||||
#include "bcdata.h"
|
||||
#include "bcdataitem.h"
|
||||
#include "qapplication.h"
|
||||
|
||||
|
||||
@@ -27,9 +27,9 @@ BCItemDelegate::BCItemDelegate(QListView *view)
|
||||
QString BCItemDelegate::displayText(const QVariant& dataValue, const QLocale& locale) const
|
||||
{
|
||||
// Wir prüfen, ob im Variant unser Struct steckt
|
||||
if (dataValue.canConvert<BCData*>())
|
||||
if (dataValue.canConvert<BCDataItem*>())
|
||||
{
|
||||
BCData& bc = *dataValue.value<BCData*>();
|
||||
BCDataItem& bc = *dataValue.value<BCDataItem*>();
|
||||
qDebug() << " --- YES: " << bc.label;
|
||||
// Hier bauen wir den String zusammen, den man sieht,
|
||||
// wenn KEIN Editor offen ist.
|
||||
@@ -49,10 +49,10 @@ QString BCItemDelegate::displayText(const QVariant& dataValue, const QLocale& lo
|
||||
QWidget *BCItemDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex& index) const
|
||||
{
|
||||
QVariant rawData = index.data(Qt::EditRole);
|
||||
if (!rawData.canConvert<BCData*>())
|
||||
if (!rawData.canConvert<BCDataItem*>())
|
||||
return QStyledItemDelegate::createEditor(parent, option, index);
|
||||
|
||||
const BCData& bc = *rawData.value<BCData*>();
|
||||
const BCDataItem& bc = *rawData.value<BCDataItem*>();
|
||||
|
||||
// Nur bei Integern den Slider-Editor bauen
|
||||
if (bc.value.typeId() == QMetaType::Int)
|
||||
@@ -97,7 +97,7 @@ QWidget *BCItemDelegate::createEditor(QWidget *parent, const QStyleOptionViewIte
|
||||
void BCItemDelegate::setEditorData(QWidget *editor, const QModelIndex& index) const
|
||||
{
|
||||
// Daten vom Model in den Editor laden
|
||||
const BCData& bc = *index.data(Qt::EditRole).value<BCData*>();
|
||||
const BCDataItem& bc = *index.data(Qt::EditRole).value<BCDataItem*>();
|
||||
|
||||
QSlider *slider = editor->findChild<QSlider*>("slider");
|
||||
QLabel *lblUnit = editor->findChild<QLabel*>("lblUnit");
|
||||
|
||||
@@ -50,7 +50,7 @@ void BCTransmitter::onToggleConnectionState( bool connect )
|
||||
}
|
||||
|
||||
|
||||
void BCTransmitter::enqueueValueOp(BC::OpID opID, const BCData* value)
|
||||
void BCTransmitter::enqueueValueOp(BC::OpID opID, const BCDataItem* value)
|
||||
{
|
||||
QMutexLocker locker(&_mutex);
|
||||
_valueQueue.enqueue( value );
|
||||
@@ -83,7 +83,7 @@ void BCTransmitter::processValueOp( BC::OpID opID )
|
||||
|
||||
while (true)
|
||||
{
|
||||
const BCData* currentValue{};
|
||||
const BCDataItem* currentValue{};
|
||||
{
|
||||
QMutexLocker locker(&_mutex);
|
||||
if (_valueQueue.isEmpty())
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#include <QMutex>
|
||||
#include <atomic>
|
||||
|
||||
#include <bcdata.h>
|
||||
#include <bcdataitem.h>
|
||||
#include <bccandrivertinycan.h>
|
||||
|
||||
// template ...
|
||||
@@ -24,7 +24,7 @@ public:
|
||||
public slots:
|
||||
|
||||
void onToggleConnectionState( bool connect );
|
||||
void enqueueValueOp(BC::OpID opID, const BCData* value );
|
||||
void enqueueValueOp(BC::OpID opID, const BCDataItem* value );
|
||||
void processValueOp(BC::OpID opID);
|
||||
|
||||
signals:
|
||||
@@ -34,7 +34,7 @@ signals:
|
||||
|
||||
private:
|
||||
|
||||
using BCDataQueue = QQueue<const BCData*>;
|
||||
using BCDataQueue = QQueue<const BCDataItem*>;
|
||||
|
||||
BCDataQueue _valueQueue;
|
||||
QMutex _mutex;
|
||||
|
||||
@@ -49,8 +49,8 @@ BCDataManager::BCDataManager(QObject *parent)
|
||||
{
|
||||
createValueTypes();
|
||||
|
||||
//qRegisterMetaType<BCData*>("BCData*");
|
||||
qRegisterMetaType<BCData*>();
|
||||
//qRegisterMetaType<BCDataItem*>("BCDataItem*");
|
||||
qRegisterMetaType<BCDataItem*>();
|
||||
|
||||
_transmitter.moveToThread(&_worker);
|
||||
|
||||
@@ -144,9 +144,9 @@ void BCDataManager::onSyncFromDevice()
|
||||
BCDataModel* model = _valueModels[_currentDeviceID];
|
||||
BCDataList& currentList = model->getValueList();
|
||||
|
||||
//BCData& value = currentList[4];
|
||||
//BCDataItem& value = currentList[4];
|
||||
|
||||
for( const BCData& value : currentList )
|
||||
for( const BCDataItem& value : currentList )
|
||||
{
|
||||
qDebug() << " --- value: " << value.label;
|
||||
|
||||
@@ -294,10 +294,10 @@ void BCDataManager::loadDeviceData( BCDataList& parsedValues )
|
||||
};
|
||||
|
||||
// __fix! können ungültige werte erzeugt werden ?
|
||||
//BCData newValue = BCData::makeValue( _currentDeviceID, params );
|
||||
//BCDataItem newValue = BCData::makeDataItem( _currentDeviceID, params );
|
||||
//if(newValue)
|
||||
// parsedValues.push_back( newValue );
|
||||
std::optional<BCData> newValue = makeValue( _currentDeviceID, params );
|
||||
std::optional<BCDataItem> newValue = makeDataItem( _currentDeviceID, params );
|
||||
if(newValue)
|
||||
parsedValues.push_back( *newValue );
|
||||
}
|
||||
@@ -307,7 +307,7 @@ void BCDataManager::loadDeviceData( BCDataList& parsedValues )
|
||||
}
|
||||
}
|
||||
|
||||
std::optional<BCData> BCDataManager::makeValue( BCDevice::ID deviceID, const BCDataParams& params )
|
||||
std::optional<BCDataItem> BCDataManager::makeDataItem( BCDevice::ID deviceID, const BCDataParams& params )
|
||||
{
|
||||
|
||||
/*
|
||||
@@ -332,7 +332,7 @@ std::optional<BCData> BCDataManager::makeValue( BCDevice::ID deviceID, const BCD
|
||||
|
||||
*/
|
||||
|
||||
std::optional<BCData> newValue;
|
||||
std::optional<BCDataItem> newValue;
|
||||
|
||||
std::optional<quint64> IDVal = s_bcValueEnum.keyToValue64( params.ID.toLatin1().constData() );
|
||||
if( IDVal.has_value() )
|
||||
@@ -341,7 +341,7 @@ std::optional<BCData> BCDataManager::makeValue( BCDevice::ID deviceID, const BCD
|
||||
{
|
||||
|
||||
const BCDataType& valueType = _valueTypes[params.UnitType];
|
||||
newValue = BCData( valueType, deviceID, static_cast<BC::ID>(IDVal.value()) );
|
||||
newValue = BCDataItem( valueType, deviceID, static_cast<BC::ID>(IDVal.value()) );
|
||||
|
||||
/*
|
||||
setIfExists( params.Factor, newValue.factor );
|
||||
|
||||
@@ -53,7 +53,7 @@ public:
|
||||
std::optional<BCDataModel*> getModel(BCDevice::ID deviceID );
|
||||
BCTransmitter* getTransmitter();
|
||||
|
||||
std::optional<BCData> makeValue( BCDevice::ID deviceID, const BCDataParams& params );
|
||||
std::optional<BCDataItem> makeDataItem( BCDevice::ID deviceID, const BCDataParams& params );
|
||||
|
||||
public slots:
|
||||
|
||||
@@ -64,8 +64,8 @@ public slots:
|
||||
signals:
|
||||
|
||||
// Internes Signal, um Daten an den Worker Thread zu senden
|
||||
void sendValueCommand( BC::OpID, const BCData* cmd);
|
||||
//void valuedTouched(const BCData& cmd);
|
||||
void sendValueCommand( BC::OpID, const BCDataItem* cmd);
|
||||
//void valuedTouched(const BCDataItem& cmd);
|
||||
void valueTouched(int rowInModel );
|
||||
|
||||
private slots:
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user