Rework itemdelegate, part I.
This commit is contained in:
@@ -49,8 +49,8 @@
|
||||
|
||||
|
||||
|
||||
BCDelegate::BCDelegate(QTableView* view)
|
||||
: QStyledItemDelegate(view), _view{view}
|
||||
BCDelegate::BCDelegate(const BCValueList& valueList, QTableView* view)
|
||||
: QStyledItemDelegate{view}, _valueList{valueList}, _view{view}
|
||||
{
|
||||
|
||||
}
|
||||
@@ -59,10 +59,10 @@ BCDelegate::BCDelegate(QTableView* view)
|
||||
QString BCDelegate::displayText(const QVariant& dataValue, const QLocale& locale) const
|
||||
{
|
||||
// Wir prüfen, ob im Variant unser Struct steckt
|
||||
if (dataValue.canConvert<BCValue*>())
|
||||
if (dataValue.canConvert<const BCValue*>())
|
||||
{
|
||||
BCValue& bc = *dataValue.value<BCValue*>();
|
||||
qDebug() << " --- YES: " << bc.label;
|
||||
const BCValue& bc = *dataValue.value<const BCValue*>();
|
||||
//qDebug() << " --- YES: " << bc.label;
|
||||
// Hier bauen wir den String zusammen, den man sieht,
|
||||
// wenn KEIN Editor offen ist.
|
||||
// Format: "Label: Wert Einheit"
|
||||
@@ -70,7 +70,7 @@ QString BCDelegate::displayText(const QVariant& dataValue, const QLocale& locale
|
||||
}
|
||||
else
|
||||
{
|
||||
//qDebug() << " --- Nö!";
|
||||
qDebug() << " --- Nö!";
|
||||
}
|
||||
|
||||
// Fallback für normale Strings/Zahlen
|
||||
@@ -162,6 +162,7 @@ void BCDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const
|
||||
|
||||
void BCDelegate::updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex& index) const
|
||||
{
|
||||
// __fix!
|
||||
editor->setGeometry(option.rect);
|
||||
}
|
||||
|
||||
@@ -181,11 +182,12 @@ QSize BCDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex
|
||||
|
||||
void BCDelegate::paint(QPainter *painter, const QStyleOptionViewItem& option, const QModelIndex& index) const
|
||||
{
|
||||
|
||||
/*
|
||||
// 1. Standard-Zeichnen (Text, Hintergrund, Selection) durchführen
|
||||
QStyledItemDelegate::paint(painter, option, index);
|
||||
|
||||
// 2. Unser Custom-Overly: Oranger Rahmen, wenn Zeile passt
|
||||
// 2. Unser Custom-Overlay: Oranger Rahmen, wenn Zeile passt
|
||||
if (index.row() == _highlightedRow)
|
||||
{
|
||||
painter->save();
|
||||
|
||||
Reference in New Issue
Block a user