Cosmetics.
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -2,3 +2,4 @@ BionxControl.pro.user
|
||||
build/
|
||||
bcvalue.cpp.autosave
|
||||
.qtcreator/BionxControl.pro.user
|
||||
.user
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
#include "bcvaluedelegate.h"
|
||||
#include "bcvalue.h"
|
||||
#include "qapplication.h"
|
||||
|
||||
|
||||
BCValueDelegate::BCValueDelegate(QObject *parent)
|
||||
@@ -117,3 +118,49 @@ void BCValueDelegate::updateEditorGeometry(QWidget *editor, const QStyleOptionVi
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ class BCValueDelegate : public QStyledItemDelegate
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
explicit BCValueDelegate(QObject *parent = nullptr);
|
||||
|
||||
// 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 setModelData(QWidget *editor, QAbstractItemModel *model, 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;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -90,11 +90,11 @@ void BCValueManager::onToggleConnectionState( bool connect )
|
||||
|
||||
}
|
||||
|
||||
|
||||
qDebug() << " ---HAIL to the kings: " << hwVersion;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
std::optional<BCValueModel*> BCValueManager::getModel(const QString& key )
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user