Add design prototype, some renamings.

This commit is contained in:
2025-12-22 21:27:20 +01:00
parent 4bd8f30a09
commit 03381ea705
20 changed files with 1219 additions and 159 deletions

View File

@@ -12,7 +12,7 @@
#include <QPainter>
#include "bcitemdelegate.h"
#include "bcvalue.h"
#include "bcdata.h"
#include "qapplication.h"
@@ -27,15 +27,19 @@ 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<BCValue*>())
if (dataValue.canConvert<BCData*>())
{
BCValue& bc = *dataValue.value<BCValue*>();
//qDebug() << " --- YES: " << bc.label;
BCData& bc = *dataValue.value<BCData*>();
qDebug() << " --- YES: " << bc.label;
// Hier bauen wir den String zusammen, den man sieht,
// wenn KEIN Editor offen ist.
// Format: "Label: Wert Einheit"
return QString("%1: %2 %3").arg(bc.label, bc.value.toString(), "mmX");
}
else
{
qDebug() << " --- Nö!";
}
// Fallback für normale Strings/Zahlen
return QStyledItemDelegate::displayText(dataValue, locale);
@@ -45,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<BCValue*>())
if (!rawData.canConvert<BCData*>())
return QStyledItemDelegate::createEditor(parent, option, index);
const BCValue& bc = *rawData.value<BCValue*>();
const BCData& bc = *rawData.value<BCData*>();
// Nur bei Integern den Slider-Editor bauen
if (bc.value.typeId() == QMetaType::Int)
@@ -93,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 BCValue& bc = *index.data(Qt::EditRole).value<BCValue*>();
const BCData& bc = *index.data(Qt::EditRole).value<BCData*>();
QSlider *slider = editor->findChild<QSlider*>("slider");
QLabel *lblUnit = editor->findChild<QLabel*>("lblUnit");
@@ -330,9 +334,9 @@ QString BCItemDelegate::formatDisplayString(const QModelIndex &index) const
QString displayStr;
/*
QString label = index.data(BCValueListModel::LabelRole).toString();
QVariant value = index.data(BCValueListModel::ValueRole);
QString unit = index.data(BCValueListModel::UnitRole).toString();
QString label = index.data(BCDataListModel::LabelRole).toString();
QVariant value = index.data(BCDataListModel::ValueRole);
QString unit = index.data(BCDataListModel::UnitRole).toString();
QString valueStr = value.toString();