diff --git a/common.pri b/common.pri index 9f5663f..cb2b698 100644 --- a/common.pri +++ b/common.pri @@ -97,7 +97,7 @@ RCC_DIR = $${ARCH_DIR}/$${BUILD_TYPE}/rcc LIMEREPORT_VERSION_MAJOR = 1 LIMEREPORT_VERSION_MINOR = 4 -LIMEREPORT_VERSION_RELEASE = 73 +LIMEREPORT_VERSION_RELEASE = 74 LIMEREPORT_VERSION = '$${LIMEREPORT_VERSION_MAJOR}.$${LIMEREPORT_VERSION_MINOR}.$${LIMEREPORT_VERSION_RELEASE}' DEFINES *= LIMEREPORT_VERSION_STR=\\\"$${LIMEREPORT_VERSION}\\\" diff --git a/limereport/objectinspector/propertyItems/lrboolpropitem.cpp b/limereport/objectinspector/propertyItems/lrboolpropitem.cpp index 7e3cc5f..6e462a2 100644 --- a/limereport/objectinspector/propertyItems/lrboolpropitem.cpp +++ b/limereport/objectinspector/propertyItems/lrboolpropitem.cpp @@ -67,19 +67,39 @@ void BoolPropItem::setModelData(QWidget *propertyEditor, QAbstractItemModel *mod setValueToObject(propertyName(),propertyValue()); } +QPixmap BoolPropItem::getIndicatorImage(const StyleOptionViewItem &option){ + QStyleOptionButton so; + so.state = option.state; + if (!isValueReadonly()) + so.state = QStyle::State_Enabled; + else + so.state &= ~QStyle::State_Enabled; + so.state |= propertyValue().toBool() ? QStyle::State_On : QStyle::State_Off; + so.rect = QRect(0,0, + QApplication::style()->pixelMetric(QStyle::PM_IndicatorWidth), + QApplication::style()->pixelMetric(QStyle::PM_IndicatorHeight)); + + QPixmap pixmap(so.rect.width(),so.rect.height()); + pixmap.fill(Qt::transparent); + QPainter p(&pixmap); + option.widget->style()->drawPrimitive(QStyle::PE_IndicatorItemViewItemCheck,&so, &p); + return pixmap; +} + bool BoolPropItem::paint(QPainter *painter, const StyleOptionViewItem &option, const QModelIndex &index) { QStyle* style = option.widget ? option.widget->style() : QApplication::style(); if (index.column()==1){ - QStyleOptionButton so; int border = (option.rect.height() - style->pixelMetric(QStyle::PM_IndicatorWidth))/2; - so.rect = option.rect.adjusted(border,border,0,-border); - so.rect.setWidth(style->pixelMetric(QStyle::PM_IndicatorWidth)); - so.rect.setHeight(style->pixelMetric(QStyle::PM_IndicatorHeight)); - so.state |= propertyValue().toBool() ? QStyle::State_On : QStyle::State_Off; - style->drawPrimitive(QStyle::PE_IndicatorItemViewItemCheck,&so,painter); +// QStyleOptionButton so; +// so.rect = option.rect.adjusted(border,border,0,-border); +// so.rect.setWidth(style->pixelMetric(QStyle::PM_IndicatorWidth)); +// so.rect.setHeight(style->pixelMetric(QStyle::PM_IndicatorHeight)); +// so.state |= propertyValue().toBool() ? QStyle::State_On : QStyle::State_Off; +// style->drawPrimitive(QStyle::PE_IndicatorItemViewItemCheck,&so,painter); + painter->drawPixmap(option.rect.x()+border,option.rect.y()+border, getIndicatorImage(option)); return true; } else return false; } diff --git a/limereport/objectinspector/propertyItems/lrboolpropitem.h b/limereport/objectinspector/propertyItems/lrboolpropitem.h index 3407925..9331c3d 100644 --- a/limereport/objectinspector/propertyItems/lrboolpropitem.h +++ b/limereport/objectinspector/propertyItems/lrboolpropitem.h @@ -45,6 +45,8 @@ public: virtual void setPropertyEditorData(QWidget * propertyEditor, const QModelIndex &) const; virtual void setModelData(QWidget * propertyEditor, QAbstractItemModel * model, const QModelIndex & index); bool paint(QPainter *painter, const StyleOptionViewItem &option, const QModelIndex &index); +protected: + QPixmap getIndicatorImage(const StyleOptionViewItem &option); }; } // namespace LimeReport