Added getter & setter for BCValue
This commit is contained in:
@@ -59,7 +59,7 @@ QWidget* BCValueDelegate::createEditor(QWidget *parent, const QStyleOptionViewIt
|
||||
{
|
||||
const BCValue& bcValue = *(_valueList[ index.row()].get());
|
||||
|
||||
qDebug() << " --- Create EDITOR: " << index.row();
|
||||
qDebug() << " --- Create EDITOR: " << index.row() << " parent: " << parent->objectName();
|
||||
|
||||
Q_UNUSED(option)
|
||||
Q_UNUSED(index)
|
||||
@@ -121,45 +121,51 @@ void BCValueDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, c
|
||||
QStyledItemDelegate::setModelData(editor, model, index);
|
||||
}
|
||||
|
||||
void BCValueDelegate::updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex& index) const
|
||||
{
|
||||
|
||||
Q_UNUSED(index)
|
||||
|
||||
QRect sliderRect = option.rect.adjusted(
|
||||
option.rect.width() - 125, // Von rechts: 115px (Breite der Progress Bar)
|
||||
0, // Oben: kein Offset
|
||||
-8, // Rechts: 8px Padding
|
||||
0 // Unten: kein Offset
|
||||
);
|
||||
editor->setGeometry(sliderRect); // Slider nur über Progress Bar
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
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);
|
||||
*/
|
||||
}
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
// Cpp
|
||||
void BCValueDelegate::destroyEditor(QWidget *editor, const QModelIndex &index) const
|
||||
{
|
||||
// 1. Kontext sichern (bevor der Editor gelöscht wird)
|
||||
// Der Editor ist meist ein Kind des Viewports
|
||||
QWidget *viewport = editor->parentWidget();
|
||||
QRect rect = editor->geometry();
|
||||
|
||||
// 2. Basis-Implementierung aufrufen
|
||||
// WICHTIG: Das löscht (delete) den Editor-Pointer!
|
||||
QStyledItemDelegate::destroyEditor(editor, index);
|
||||
|
||||
// 3. Jetzt den Bereich neu zeichnen ("Dirty Rect")
|
||||
if (viewport)
|
||||
{
|
||||
// Wir nutzen das Rechteck, wo der Editor WAR.
|
||||
qDebug() << " --- DESTROY: " << viewport->objectName() << " : " << rect;
|
||||
viewport->update(rect);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
void BCValueDelegate::paint(QPainter *painter, const QStyleOptionViewItem& option, const QModelIndex& index) const
|
||||
{
|
||||
qDebug() << " ---paint:" << index.row();
|
||||
|
||||
// Standard-Zeichnen (Text, Hintergrund, Selection) durchführen
|
||||
QStyledItemDelegate::paint(painter, option, index);
|
||||
|
||||
int row = index.row();
|
||||
|
||||
if( index.column() == 1 )
|
||||
if( index.column() == 1 )
|
||||
{
|
||||
if( row>-1 && row <= _valueList.size() )
|
||||
{
|
||||
@@ -174,9 +180,6 @@ void BCValueDelegate::paint(QPainter *painter, const QStyleOptionViewItem& optio
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void BCValueDelegate::paintHighlightRow(QPainter* painter, const QStyleOptionViewItem& option, int row) const
|
||||
{
|
||||
painter->save();
|
||||
@@ -205,8 +208,23 @@ void BCValueDelegate::paintHighlightRow(QPainter* painter, const QStyleOptionVie
|
||||
}
|
||||
|
||||
|
||||
void BCValueDelegate::updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex& index) const
|
||||
{
|
||||
|
||||
Q_UNUSED(index)
|
||||
|
||||
QRect sliderRect = option.rect.adjusted(
|
||||
option.rect.width() - cTextBlockOffset, // Von rechts: cTextBlockOffset (==130) px (Breite der Progress Bar)
|
||||
0, // Oben: kein Offset
|
||||
-cPaddingRight, // Rechts: 8px Padding
|
||||
0 // Unten: kein Offset
|
||||
);
|
||||
editor->setGeometry(sliderRect); // Slider nur über Progress Bar
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Zeichnet eine passiven Slider, um den Wertebereich des übergebenen BCValue anzuzeigen.
|
||||
* @brief Zeichnet eine passiven Slider, um den möglichen Wertebereich des übergebenen BCValue anzuzeigen.
|
||||
*/
|
||||
|
||||
void BCValueDelegate::paintSliderIndicator(QPainter* painter, const QStyleOptionViewItem& option, const BCValue& bcValue) const
|
||||
@@ -215,17 +233,22 @@ void BCValueDelegate::paintSliderIndicator(QPainter* painter, const QStyleOption
|
||||
painter->save();
|
||||
painter->setRenderHint(QPainter::Antialiasing);
|
||||
|
||||
QRect barRect = option.rect.adjusted(option.rect.width() - 130,
|
||||
int newX = option.rect.width() - cTextBlockOffset;
|
||||
|
||||
QRect barRect = option.rect.adjusted( newX,
|
||||
option.rect.height() / 2 + 1,
|
||||
-8,
|
||||
- option.rect.width() + cTextBlockOffset + 117 - 18,
|
||||
-option.rect.height() / 2 - 3);
|
||||
|
||||
double ratio = bcValue.calcRatio();
|
||||
|
||||
double ratio = bcValue.calcMinMaxRatio();
|
||||
if( ratio)
|
||||
{
|
||||
// Mini Progress Bar
|
||||
// Mini Progress Bar: der Gesamtbereich
|
||||
painter->setPen(Qt::NoPen);
|
||||
painter->setBrush(QColor(0xE0E0E0));
|
||||
//QColor disabledText = option.palette.color(QPalette::Disabled, QPalette::Text);
|
||||
//painter->setBrush(disabledText);
|
||||
painter->drawRoundedRect(barRect, 2, 2);
|
||||
|
||||
QRect fillRect = barRect;
|
||||
@@ -256,7 +279,7 @@ void BCValueDelegate::paintSliderIndicator(QPainter* painter, const QStyleOption
|
||||
/*
|
||||
// baby-Slider-Indikator zeichnen
|
||||
// Anteil zwischen min und max berechnen
|
||||
double ratio = bcValue.calcRatio();
|
||||
double ratio = bcValue.calcMinMaxRatio();
|
||||
if( !ratio)
|
||||
return;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user