Created new painter bug.
This commit is contained in:
@@ -62,8 +62,8 @@ QWidget* BCValueDelegate::createEditor(QWidget *parent, const QStyleOptionViewIt
|
||||
|
||||
const BCValue& bcValue = *(_valueList[ index.row()].get());
|
||||
|
||||
BCValueEditorParams params;
|
||||
bool hasData = bcValue.valuesForSlider( params.value, params.min, params.max );
|
||||
BCValue::ValueRange params;
|
||||
bool hasData = bcValue.valuesForSlider( params );
|
||||
if( !hasData )
|
||||
return nullptr;
|
||||
|
||||
@@ -123,25 +123,26 @@ void BCValueDelegate::paint(QPainter *painter, const QStyleOptionViewItem& optio
|
||||
QStyledItemDelegate::paint(painter, option, index);
|
||||
int row = index.row();
|
||||
|
||||
if( index.column() == 1 )
|
||||
if( index.column() != 1 )
|
||||
return;
|
||||
if( row<0 || row >= _valueList.size() )
|
||||
return;
|
||||
|
||||
const BCValue& bcValue = *(_valueList[ index.row()].get());
|
||||
if( !bcValue.isReadOnly() )
|
||||
{
|
||||
if( row>-1 && row <= _valueList.size() )
|
||||
if( bcValue.valueType() == BCValue::ValueType::Bool )
|
||||
paintButtonIndicator(painter, option, bcValue);
|
||||
else
|
||||
{
|
||||
const BCValue& bcValue = *(_valueList[ index.row()].get());
|
||||
if( !bcValue.isReadOnly() )
|
||||
{
|
||||
if( bcValue.valueType() == BCValue::ValueType::Bool )
|
||||
paintButtonIndicator(painter,option,bcValue);
|
||||
else
|
||||
paintSliderIndicator(painter,option,bcValue);
|
||||
|
||||
}
|
||||
|
||||
qDebug() << " ---WTF1: " <<option.rect;
|
||||
BCValueEditor::paintSliderIndicator(painter, option.rect, bcValue.calcMinMaxRatio() );
|
||||
}
|
||||
|
||||
if(_rowOpacities.contains(row))
|
||||
paintHighlightRow(painter,option,index.row());
|
||||
}
|
||||
|
||||
if(_rowOpacities.contains(row))
|
||||
paintHighlightRow(painter,option,index.row());
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -175,17 +176,10 @@ 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
|
||||
);
|
||||
QRect sliderRect = BCValueEditor::updateEditorRect( option.rect );
|
||||
editor->setGeometry(sliderRect); // Slider nur über Progress Bar
|
||||
|
||||
}
|
||||
|
||||
void BCValueDelegate::paintButtonIndicator(QPainter* painter, const QStyleOptionViewItem& option, const BCValue& bcValue) const
|
||||
@@ -193,79 +187,6 @@ void BCValueDelegate::paintButtonIndicator(QPainter* painter, const QStyleOption
|
||||
|
||||
}
|
||||
|
||||
void BCValueDelegate::paintSliderIndicator(QPainter* painter, const QStyleOptionViewItem& option, const BCValue& bcValue) const
|
||||
{
|
||||
double ratio = bcValue.calcMinMaxRatio();
|
||||
|
||||
int value,min,max;
|
||||
bcValue.valuesForSlider( value, min, max );
|
||||
|
||||
qDebug() << " --- paint: " << bcValue.label() << " value: " << value << " min: " << min << " max: " << max << " ratio:" << ratio*100.0 << '%';
|
||||
|
||||
// Text und kleiner Slider-Indikator zeichnen
|
||||
painter->save();
|
||||
painter->setRenderHint(QPainter::Antialiasing);
|
||||
|
||||
int adjX = option.rect.width() - cTextBlockOffset;
|
||||
|
||||
// Mini Progress Bar: der Gesamtbereich
|
||||
QRect barRect = option.rect.adjusted( adjX, 12, -10-24, -12 );
|
||||
painter->setPen(Qt::NoPen);
|
||||
painter->setBrush(QColor(0xE0E0E0));
|
||||
painter->drawRoundedRect(barRect, 2, 2);
|
||||
|
||||
// Mini Progress Bar: der Wertebereich
|
||||
barRect.setWidth( ratio * barRect.width() );
|
||||
painter->setBrush(QColor(0x0078D4));
|
||||
painter->drawRoundedRect(barRect, 2, 2);
|
||||
|
||||
painter->restore();
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Zeichnet eine passiven Slider, um den möglichen Wertebereich des übergebenen BCValue anzuzeigen.
|
||||
*/
|
||||
|
||||
void BCValueDelegate::paintSliderIndicatorXX(QPainter* painter, const QStyleOptionViewItem& option, const BCValue& bcValue) const
|
||||
{
|
||||
// Text und kleiner Slider-Indikator zeichnen
|
||||
painter->save();
|
||||
painter->setRenderHint(QPainter::Antialiasing);
|
||||
|
||||
int newX = option.rect.width() - cTextBlockOffset;
|
||||
|
||||
QRect barRect = option.rect.adjusted( newX,
|
||||
option.rect.height() / 2 + 1,
|
||||
- option.rect.width() + cTextBlockOffset + 117 - 18,
|
||||
-option.rect.height() / 2 - 3);
|
||||
|
||||
|
||||
double ratio = bcValue.calcMinMaxRatio();
|
||||
qDebug() << " --- paint: " << bcValue.label() << ":" << ratio;
|
||||
if(ratio)
|
||||
{
|
||||
// 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;
|
||||
// ein wert darf näturlich nie über 100% eingestellt werden
|
||||
ratio = qBound(0.0,ratio,1.0);
|
||||
|
||||
fillRect.setWidth(barRect.width() * ratio);
|
||||
painter->setBrush(QColor(0x0078D4));
|
||||
painter->drawRoundedRect(fillRect, 2, 2);
|
||||
}
|
||||
|
||||
painter->restore();
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Startet die Animation für die übergebene Zeile
|
||||
|
||||
Reference in New Issue
Block a user