mirror of
https://github.com/fralx/LimeReport.git
synced 2024-12-23 16:22:58 +03:00
Merge branch 'master' into 1.4
This commit is contained in:
commit
a6d17858cf
@ -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);
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include "lrintpropitem.h"
|
||||
#include <limits>
|
||||
#include <QDoubleSpinBox>
|
||||
#include <QHBoxLayout>
|
||||
|
||||
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<int>::max());
|
||||
editor->setMinimum(std::numeric_limits<int>::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<int>::max());
|
||||
// editor->setMinimum(std::numeric_limits<int>::min());
|
||||
|
||||
// layout->addWidget(editor);
|
||||
return new SpinBoxEditor(parent);
|
||||
}
|
||||
|
||||
void IntPropItem::setPropertyEditorData(QWidget *propertyEditor, const QModelIndex &) const
|
||||
{
|
||||
QSpinBox *editor =qobject_cast<QSpinBox *>(propertyEditor);
|
||||
SpinBoxEditor *editor =qobject_cast<SpinBoxEditor *>(propertyEditor);
|
||||
editor->setValue(propertyValue().toInt());
|
||||
}
|
||||
|
||||
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());
|
||||
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<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
|
||||
|
@ -31,8 +31,22 @@
|
||||
#define LRINTPROPITEM_H
|
||||
|
||||
#include "lrobjectpropitem.h"
|
||||
#include <QSpinBox>
|
||||
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user