diff --git a/limereport/objectinspector/lrpropertydelegate.cpp b/limereport/objectinspector/lrpropertydelegate.cpp index 170ccd3..e1808eb 100644 --- a/limereport/objectinspector/lrpropertydelegate.cpp +++ b/limereport/objectinspector/lrpropertydelegate.cpp @@ -36,13 +36,16 @@ #include "lrglobal.h" LimeReport::PropertyDelegate::PropertyDelegate(QObject *parent) - :QItemDelegate(parent), m_objectInspector(NULL), m_editingItem(0), m_isEditing(false) + :QStyledItemDelegate(parent), m_objectInspector(NULL), m_editingItem(0), m_isEditing(false) {} void LimeReport::PropertyDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const { if (!index.isValid()) return; + QStyleOptionViewItemV4 opt = option; + QStyle *style = opt.widget ? opt.widget->style() : QApplication::style(); + LimeReport::ObjectPropItem *node = static_cast(index.internalPointer()); if (node){ if (!node->isHaveValue()){ @@ -54,31 +57,17 @@ void LimeReport::PropertyDelegate::paint(QPainter *painter, const QStyleOptionVi painter->save(); painter->setPen(option.palette.color(QPalette::HighlightedText)); painter->setBackground(QBrush(option.palette.color(QPalette::Highlight))); - drawBackground(painter,option,index); + //drawBackground(painter,option,index); cellOpt.widget->style()->drawPrimitive(QStyle::PE_IndicatorBranch,&primitiveOpt,painter); cellOpt.rect.adjust(primitiveOpt.rect.width(),0,0,0); cellOpt.font.setBold(true); cellOpt.palette.setColor(QPalette::Text,cellOpt.palette.color(QPalette::BrightText)); - drawDisplay(painter,cellOpt,cellOpt.rect,LimeReport::extractClassName(node->propertyName())); + cellOpt.text = LimeReport::extractClassName(node->propertyName()); + style->drawControl(QStyle::CE_ItemViewItem, &cellOpt, painter, cellOpt.widget); + //drawDisplay(painter,cellOpt,cellOpt.rect,LimeReport::extractClassName(node->propertyName())); painter->restore(); } - } else - { - if (index.column()==0){ - QPointF start( - option.rect.x()+option.rect.width()-1, - option.rect.y() - ); - QPointF end( - option.rect.x()+option.rect.width()-1, - option.rect.y()+option.rect.height() - ); - painter->save(); - QColor color = static_cast(QApplication::style()->styleHint(QStyle::SH_Table_GridLineColor, &option)); - painter->setPen(color); - painter->drawLine(start,end); - painter->restore(); - } + } else { StyleOptionViewItem so = option; if ((node->isValueReadonly())&&(!node->isHaveChildren())) { @@ -98,14 +87,36 @@ void LimeReport::PropertyDelegate::paint(QPainter *painter, const QStyleOptionVi else so.palette.setColor(QPalette::Text,Qt::black); - drawBackground(painter,option,index); - if (!node->paint(painter,so,index)) - QItemDelegate::paint(painter, so, index); +// drawBackground(painter,option,index); + + opt.text = ""; + style->drawControl(QStyle::CE_ItemViewItem, &opt, painter, opt.widget); + + if (!node->paint(painter,so,index)){ + so.state &= ~QStyle::State_HasFocus; + QStyledItemDelegate::paint(painter, so, index); + } + + if (index.column()==0){ + QPointF start( + option.rect.x()+option.rect.width()-1, + option.rect.y() + ); + QPointF end( + option.rect.x()+option.rect.width()-1, + option.rect.y()+option.rect.height() + ); + painter->save(); + QColor color = static_cast(QApplication::style()->styleHint(QStyle::SH_Table_GridLineColor, &option)); + painter->setPen(color); + painter->drawLine(start,end); + painter->restore(); + } } } } -QSize LimeReport::PropertyDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &/*index*/) const +QSize LimeReport::PropertyDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const { QSize size=option.rect.size(); size.setHeight(option.fontMetrics.height()+ @@ -113,8 +124,10 @@ QSize LimeReport::PropertyDelegate::sizeHint(const QStyleOptionViewItem &option, #ifdef Q_OS_MAC +QApplication::style()->pixelMetric(QStyle::PM_FocusFrameVMargin) #endif - +2); - return size; + +4); + //return size; + QSize defaultSize = QStyledItemDelegate::sizeHint(option, index); + return size.height() > defaultSize.height() ? size : defaultSize; } QWidget * LimeReport::PropertyDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const diff --git a/limereport/objectinspector/lrpropertydelegate.h b/limereport/objectinspector/lrpropertydelegate.h index f7e2414..d9d9b66 100644 --- a/limereport/objectinspector/lrpropertydelegate.h +++ b/limereport/objectinspector/lrpropertydelegate.h @@ -40,8 +40,8 @@ namespace LimeReport{ class ObjectInspectorWidget; -class PropertyDelegate : public QItemDelegate -//class PropertyDelegate : public QStyledItemDelegate +//class PropertyDelegate : public QItemDelegate +class PropertyDelegate : public QStyledItemDelegate { Q_OBJECT public: