Changed styles.
This commit is contained in:
@@ -54,7 +54,6 @@ BCValueDelegate::BCValueDelegate(const BCValueList& valueList, QTableView* view)
|
||||
}
|
||||
|
||||
|
||||
|
||||
QWidget* BCValueDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex& index) const
|
||||
{
|
||||
const BCValue& bcValue = *(_valueList[ index.row()].get());
|
||||
@@ -79,26 +78,10 @@ QWidget* BCValueDelegate::createEditor(QWidget *parent, const QStyleOptionViewIt
|
||||
|
||||
void BCValueDelegate::setEditorData(QWidget *editor, const QModelIndex& index) const
|
||||
{
|
||||
qDebug() << " setEditorData, warum?";
|
||||
/*
|
||||
// Daten vom Model in den Editor laden
|
||||
const BCValue& bc = *index.data(Qt::EditRole).value<BCValue*>();
|
||||
Q_UNUSED(editor)
|
||||
Q_UNUSED(index)
|
||||
|
||||
QSlider *slider = editor->findChild<QSlider*>("slider");
|
||||
QLabel *lblUnit = editor->findChild<QLabel*>("lblUnit");
|
||||
|
||||
if (slider && lblUnit)
|
||||
{
|
||||
bool olDriverState = slider->blockSignals(true);
|
||||
slider->setValue(bc.formattedValue.toInt());
|
||||
slider->blockSignals(olDriverState);
|
||||
lblUnit->setText(QString("%1 %2").arg(bc.formattedValue.toInt()).arg( "mm3"));
|
||||
}
|
||||
else
|
||||
{
|
||||
QStyledItemDelegate::setEditorData(editor, index);
|
||||
}
|
||||
*/
|
||||
// tue nix.
|
||||
|
||||
}
|
||||
|
||||
@@ -121,43 +104,6 @@ void BCValueDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, c
|
||||
QStyledItemDelegate::setModelData(editor, model, index);
|
||||
}
|
||||
|
||||
/*
|
||||
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
|
||||
{
|
||||
@@ -252,6 +198,9 @@ void BCValueDelegate::paintSliderIndicator(QPainter* painter, const QStyleOption
|
||||
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);
|
||||
@@ -259,56 +208,6 @@ void BCValueDelegate::paintSliderIndicator(QPainter* painter, const QStyleOption
|
||||
|
||||
painter->restore();
|
||||
|
||||
|
||||
/// -------
|
||||
|
||||
/*
|
||||
// Hintergrund
|
||||
if (option.state & QStyle::State_Selected)
|
||||
{
|
||||
painter->fillRect(option.rect, option.palette.highlight());
|
||||
}
|
||||
else
|
||||
{
|
||||
QColor bcColor = option.palette.color(QPalette::Base);
|
||||
painter->fillRect(option.rect, bcColor);
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
// baby-Slider-Indikator zeichnen
|
||||
// Anteil zwischen min und max berechnen
|
||||
double ratio = bcValue.calcMinMaxRatio();
|
||||
if( !ratio)
|
||||
return;
|
||||
|
||||
painter->save();
|
||||
painter->setRenderHint(QPainter::Antialiasing);
|
||||
|
||||
QRect barRect = option.rect.adjusted
|
||||
(
|
||||
8,
|
||||
option.rect.height() / 2 - 2,
|
||||
-8,
|
||||
-option.rect.height() / 2 + 2
|
||||
);
|
||||
|
||||
// Mini Progress Bar
|
||||
painter->setPen(Qt::NoPen);
|
||||
QColor disabledText = option.palette.color(QPalette::Disabled, QPalette::Text);
|
||||
painter->setBrush(disabledText);
|
||||
|
||||
painter->drawRoundedRect(barRect, 2, 2);
|
||||
|
||||
barRect.setWidth(barRect.width() * ratio );
|
||||
painter->setBrush(QColor(0x0078D4));
|
||||
//painter->setBrush(Qt::green);
|
||||
//painter->setBrush( );
|
||||
painter->drawRoundedRect(barRect, 2, 2);
|
||||
|
||||
painter->restore();
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user