Merge branch 'master' into 1.4

This commit is contained in:
Arin Alexander 2016-10-19 17:33:39 +03:00
commit a6d17858cf
3 changed files with 66 additions and 6 deletions

View File

@ -86,6 +86,20 @@ void LimeReport::PropertyDelegate::paint(QPainter *painter, const QStyleOptionVi
if ((node->isValueReadonly())&&(!node->isHaveChildren())) { if ((node->isValueReadonly())&&(!node->isHaveChildren())) {
so.palette.setColor(QPalette::Text,so.palette.color(QPalette::Dark)); 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); drawBackground(painter,option,index);
if (!node->paint(painter,so,index)) if (!node->paint(painter,so,index))
QItemDelegate::paint(painter, so, index); QItemDelegate::paint(painter, so, index);

View File

@ -30,6 +30,7 @@
#include "lrintpropitem.h" #include "lrintpropitem.h"
#include <limits> #include <limits>
#include <QDoubleSpinBox> #include <QDoubleSpinBox>
#include <QHBoxLayout>
namespace{ namespace{
LimeReport::ObjectPropItem * createIntPropItem( LimeReport::ObjectPropItem * createIntPropItem(
@ -44,21 +45,27 @@ namespace LimeReport{
QWidget *IntPropItem::createProperyEditor(QWidget *parent) const QWidget *IntPropItem::createProperyEditor(QWidget *parent) const
{ {
QSpinBox *editor= new QSpinBox(parent); // QWidget* base = new QWidget(parent);
editor->setMaximum(std::numeric_limits<int>::max()); // QHBoxLayout* layout = new QHBoxLayout();
editor->setMinimum(std::numeric_limits<int>::min()); // base->setLayout(layout);
return editor;
// QSpinBox *editor = new QSpinBox(parent);
// editor->setMaximum(std::numeric_limits<int>::max());
// editor->setMinimum(std::numeric_limits<int>::min());
// layout->addWidget(editor);
return new SpinBoxEditor(parent);
} }
void IntPropItem::setPropertyEditorData(QWidget *propertyEditor, const QModelIndex &) const void IntPropItem::setPropertyEditorData(QWidget *propertyEditor, const QModelIndex &) const
{ {
QSpinBox *editor =qobject_cast<QSpinBox *>(propertyEditor); SpinBoxEditor *editor =qobject_cast<SpinBoxEditor *>(propertyEditor);
editor->setValue(propertyValue().toInt()); editor->setValue(propertyValue().toInt());
} }
void IntPropItem::setModelData(QWidget *propertyEditor, QAbstractItemModel *model, const QModelIndex &index) void IntPropItem::setModelData(QWidget *propertyEditor, QAbstractItemModel *model, const QModelIndex &index)
{ {
model->setData(index,qobject_cast<QSpinBox*>(propertyEditor)->value()); model->setData(index,qobject_cast<SpinBoxEditor*>(propertyEditor)->value());
object()->setProperty(propertyName().toLatin1(),propertyValue()); object()->setProperty(propertyName().toLatin1(),propertyValue());
foreach(QObject* item, *objects()){ foreach(QObject* item, *objects()){
if (item->metaObject()->indexOfProperty(propertyName().toLatin1())!=-1){ 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<int>::min());
m_valueEditor->setMaximum(std::numeric_limits<int>::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 } // namespace LimeReport

View File

@ -31,8 +31,22 @@
#define LRINTPROPITEM_H #define LRINTPROPITEM_H
#include "lrobjectpropitem.h" #include "lrobjectpropitem.h"
#include <QSpinBox>
namespace LimeReport { 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 class IntPropItem : public ObjectPropItem
{ {
Q_OBJECT Q_OBJECT