Cosmetics.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user