Cosmetics.

This commit is contained in:
2025-12-18 18:39:52 +01:00
parent 2acf280c55
commit 1d558198c9
4 changed files with 58 additions and 4 deletions

1
.gitignore vendored
View File

@@ -2,3 +2,4 @@ BionxControl.pro.user
build/ build/
bcvalue.cpp.autosave bcvalue.cpp.autosave
.qtcreator/BionxControl.pro.user .qtcreator/BionxControl.pro.user
.user

View File

@@ -6,6 +6,7 @@
#include "bcvaluedelegate.h" #include "bcvaluedelegate.h"
#include "bcvalue.h" #include "bcvalue.h"
#include "qapplication.h"
BCValueDelegate::BCValueDelegate(QObject *parent) BCValueDelegate::BCValueDelegate(QObject *parent)
@@ -117,3 +118,49 @@ void BCValueDelegate::updateEditorGeometry(QWidget *editor, const QStyleOptionVi
{ {
editor->setGeometry(option.rect); editor->setGeometry(option.rect);
} }
QSize BCValueDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
{
return QStyledItemDelegate::sizeHint(option,index);
/*
QStyleOptionViewItem opt = option;
initStyleOption(&opt, index);
opt.text = formatDisplayString(index);
QStyle *style = opt.widget ? opt.widget->style() : QApplication::style();
return style->sizeFromContents(QStyle::CT_ItemViewItem, &opt, QSize(), opt.widget);
*/
}
QString BCValueDelegate::formatDisplayString(const QModelIndex &index) const
{
if (!index.isValid())
return QString();
QString displayStr;
/*
QString label = index.data(BCValueListModel::LabelRole).toString();
QVariant value = index.data(BCValueListModel::ValueRole);
QString unit = index.data(BCValueListModel::UnitRole).toString();
QString valueStr = value.toString();
// Formatierung für Zahlen
bool ok;
double numValue = value.toDouble(&ok);
if (ok) {
valueStr = QString::number(numValue, 'f', 2);
}
// Zusammensetzen des Anzeige-Strings
QString displayStr = label;
if (!displayStr.isEmpty() && !valueStr.isEmpty())
displayStr += ": ";
displayStr += valueStr;
if (!unit.isEmpty())
displayStr += " " + unit;
*/
return displayStr;
}

View File

@@ -10,6 +10,7 @@ class BCValueDelegate : public QStyledItemDelegate
Q_OBJECT Q_OBJECT
public: public:
explicit BCValueDelegate(QObject *parent = nullptr); explicit BCValueDelegate(QObject *parent = nullptr);
// WICHTIG: Zuständig für die normale Anzeige (ohne Editor) // WICHTIG: Zuständig für die normale Anzeige (ohne Editor)
@@ -20,6 +21,11 @@ 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;
QSize sizeHint(const QStyleOptionViewItem &option,const QModelIndex &index) const override;
private:
QString formatDisplayString(const QModelIndex &index) const;
}; };

View File

@@ -90,11 +90,11 @@ void BCValueManager::onToggleConnectionState( bool connect )
} }
qDebug() << " ---HAIL to the kings: " << hwVersion;
}
} }
}
std::optional<BCValueModel*> BCValueManager::getModel(const QString& key ) std::optional<BCValueModel*> BCValueManager::getModel(const QString& key )
{ {