diff --git a/limereport/objectinspector/lrpropertydelegate.cpp b/limereport/objectinspector/lrpropertydelegate.cpp index db44400..bdfff23 100644 --- a/limereport/objectinspector/lrpropertydelegate.cpp +++ b/limereport/objectinspector/lrpropertydelegate.cpp @@ -86,6 +86,20 @@ void LimeReport::PropertyDelegate::paint(QPainter *painter, const QStyleOptionVi if ((node->isValueReadonly())&&(!node->isHaveChildren())) { so.palette.setColor(QPalette::Text,so.palette.color(QPalette::Dark)); } + + QColor backgroundColor = (so.features & StyleOptionViewItem::Alternate) ? + so.palette.alternateBase().color() : + so.palette.base().color(); + + qreal luma = 0.2126 * backgroundColor.red() + + 0.7152 * backgroundColor.green() + + 0.0722 * backgroundColor.blue(); + + if (luma<128) + so.palette.setColor(QPalette::Text,Qt::white); + else + so.palette.setColor(QPalette::Text,Qt::black); + drawBackground(painter,option,index); if (!node->paint(painter,so,index)) QItemDelegate::paint(painter, so, index); diff --git a/limereport/objectinspector/propertyItems/lrintpropitem.cpp b/limereport/objectinspector/propertyItems/lrintpropitem.cpp index bbbf801..58cfbaa 100644 --- a/limereport/objectinspector/propertyItems/lrintpropitem.cpp +++ b/limereport/objectinspector/propertyItems/lrintpropitem.cpp @@ -30,6 +30,7 @@ #include "lrintpropitem.h" #include #include +#include namespace{ LimeReport::ObjectPropItem * createIntPropItem( @@ -44,21 +45,27 @@ namespace LimeReport{ QWidget *IntPropItem::createProperyEditor(QWidget *parent) const { - QSpinBox *editor= new QSpinBox(parent); - editor->setMaximum(std::numeric_limits::max()); - editor->setMinimum(std::numeric_limits::min()); - return editor; +// QWidget* base = new QWidget(parent); +// QHBoxLayout* layout = new QHBoxLayout(); +// base->setLayout(layout); + +// QSpinBox *editor = new QSpinBox(parent); +// editor->setMaximum(std::numeric_limits::max()); +// editor->setMinimum(std::numeric_limits::min()); + +// layout->addWidget(editor); + return new SpinBoxEditor(parent); } void IntPropItem::setPropertyEditorData(QWidget *propertyEditor, const QModelIndex &) const { - QSpinBox *editor =qobject_cast(propertyEditor); + SpinBoxEditor *editor =qobject_cast(propertyEditor); editor->setValue(propertyValue().toInt()); } void IntPropItem::setModelData(QWidget *propertyEditor, QAbstractItemModel *model, const QModelIndex &index) { - model->setData(index,qobject_cast(propertyEditor)->value()); + model->setData(index,qobject_cast(propertyEditor)->value()); object()->setProperty(propertyName().toLatin1(),propertyValue()); foreach(QObject* item, *objects()){ if (item->metaObject()->indexOfProperty(propertyName().toLatin1())!=-1){ @@ -67,4 +74,29 @@ void IntPropItem::setModelData(QWidget *propertyEditor, QAbstractItemModel *mode } } +SpinBoxEditor::SpinBoxEditor(QWidget *parent) + :QWidget(parent) +{ + m_valueEditor = new QSpinBox(this); + m_valueEditor->setMinimum(std::numeric_limits::min()); + m_valueEditor->setMaximum(std::numeric_limits::max()); + setFocusProxy(m_valueEditor); + QHBoxLayout* hLayout = new QHBoxLayout(this); + hLayout->addWidget(m_valueEditor); + hLayout->setContentsMargins(1,1,1,1); + hLayout->setSpacing(0); + setAutoFillBackground(true); + connect(m_valueEditor, SIGNAL(editingFinished()), this, SIGNAL(editingFinished())); +} + +int SpinBoxEditor::value() +{ + return m_valueEditor->value(); +} + +void SpinBoxEditor::setValue(int value) +{ + m_valueEditor->setValue(value); +} + } // namespace LimeReport diff --git a/limereport/objectinspector/propertyItems/lrintpropitem.h b/limereport/objectinspector/propertyItems/lrintpropitem.h index 2373cab..2d49f21 100644 --- a/limereport/objectinspector/propertyItems/lrintpropitem.h +++ b/limereport/objectinspector/propertyItems/lrintpropitem.h @@ -31,8 +31,22 @@ #define LRINTPROPITEM_H #include "lrobjectpropitem.h" +#include namespace LimeReport { + +class SpinBoxEditor : public QWidget{ + Q_OBJECT +public: + SpinBoxEditor(QWidget* parent); + int value(); + void setValue(int value); +signals: + void editingFinished(); +private: + QSpinBox* m_valueEditor; +}; + class IntPropItem : public ObjectPropItem { Q_OBJECT