mirror of
https://github.com/fralx/LimeReport.git
synced 2025-10-06 12:48:21 +03:00
1.1.1
This commit is contained in:
@@ -64,7 +64,7 @@ void BoolPropItem::setPropertyEditorData(QWidget *propertyEditor, const QModelIn
|
||||
void BoolPropItem::setModelData(QWidget *propertyEditor, QAbstractItemModel *model, const QModelIndex &index)
|
||||
{
|
||||
model->setData(index,qobject_cast<CheckBoxEditor*>(propertyEditor)->isChecked());
|
||||
object()->setProperty(propertyName().toLatin1(),propertyValue());
|
||||
setValueToObject(propertyName(),propertyValue());
|
||||
}
|
||||
|
||||
bool BoolPropItem::paint(QPainter *painter, const QStyleOptionViewItemV4 &option, const QModelIndex &index)
|
||||
|
@@ -51,18 +51,28 @@ void ColorPropItem::setPropertyEditorData(QWidget *propertyEditor, const QModelI
|
||||
void ColorPropItem::setModelData(QWidget *propertyEditor, QAbstractItemModel *model, const QModelIndex &index)
|
||||
{
|
||||
model->setData(index,qobject_cast<ColorEditor*>(propertyEditor)->color());
|
||||
object()->setProperty(propertyName().toLatin1(),propertyValue());
|
||||
setValueToObject(propertyName(),propertyValue());
|
||||
}
|
||||
|
||||
bool ColorPropItem::paint(QPainter *painter, const QStyleOptionViewItemV4 &option, const QModelIndex &index)
|
||||
{
|
||||
if (index.column()==1){
|
||||
painter->save();
|
||||
QPen pen;
|
||||
|
||||
if (option.state & QStyle::State_Selected){
|
||||
pen.setColor(option.palette.brightText().color());
|
||||
pen.setWidth(2);
|
||||
painter->setPen(pen);
|
||||
}else
|
||||
pen.setColor(Qt::gray);
|
||||
painter->setPen(pen);
|
||||
|
||||
painter->setBrush(propertyValue().value<QColor>());
|
||||
painter->setPen(Qt::gray);
|
||||
QRect rect = option.rect.adjusted(4,4,-4,-6);
|
||||
rect.setWidth(rect.height());
|
||||
painter->drawRect(rect);
|
||||
painter->setRenderHint(QPainter::Antialiasing);
|
||||
painter->drawEllipse(rect);
|
||||
painter->restore();
|
||||
return true;
|
||||
} else return false;
|
||||
|
38
src/objectinspector/propertyItems/lrcontentpropitem.cpp
Normal file
38
src/objectinspector/propertyItems/lrcontentpropitem.cpp
Normal file
@@ -0,0 +1,38 @@
|
||||
#include "lrcontentpropitem.h"
|
||||
#include "lrtextitem.h"
|
||||
#include "editors/lrbuttonlineeditor.h"
|
||||
#include "items/lrtextitemeditor.h"
|
||||
#include <QApplication>
|
||||
|
||||
namespace{
|
||||
LimeReport::ObjectPropItem * createContentPropItem(
|
||||
QObject *object, LimeReport::ObjectPropItem::ObjectsList* objects, const QString& name, const QString& displayName, const QVariant& data, LimeReport::ObjectPropItem* parent, bool readonly)
|
||||
{
|
||||
return new LimeReport::ContentPropItem(object, objects, name, displayName, data, parent, readonly);
|
||||
}
|
||||
bool registredContentProp = LimeReport::ObjectPropFactory::instance().registerCreator(LimeReport::APropIdent("content","LimeReport::TextItem"),QObject::tr("content"),createContentPropItem);
|
||||
} // namespace
|
||||
|
||||
namespace LimeReport {
|
||||
|
||||
QWidget *ContentPropItem::createProperyEditor(QWidget *parent) const
|
||||
{
|
||||
return new ContentEditor(object(), object()->objectName()+"."+displayName(), parent);
|
||||
}
|
||||
|
||||
void ContentEditor::editButtonClicked()
|
||||
{
|
||||
QDialog* dialog = new QDialog(QApplication::activeWindow());
|
||||
dialog->setLayout(new QVBoxLayout());
|
||||
dialog->layout()->setContentsMargins(1,1,1,1);
|
||||
dialog->setAttribute(Qt::WA_DeleteOnClose);
|
||||
//dialog->setGeometry(QStyle::alignedRect(Qt::LeftToRight, Qt::AlignCenter, dialog->size(), QApplication::desktop()->availableGeometry()));
|
||||
dialog->setWindowTitle(propertyName());
|
||||
QWidget* editor = dynamic_cast<BaseDesignIntf*>(m_object)->defaultEditor();
|
||||
dialog->layout()->addWidget(editor);
|
||||
connect(editor,SIGNAL(destroyed()),dialog,SLOT(close()));
|
||||
connect(editor,SIGNAL(destroyed()),this,SIGNAL(editingFinished()));
|
||||
dialog->exec();
|
||||
}
|
||||
|
||||
} //namespace LimeReport
|
31
src/objectinspector/propertyItems/lrcontentpropitem.h
Normal file
31
src/objectinspector/propertyItems/lrcontentpropitem.h
Normal file
@@ -0,0 +1,31 @@
|
||||
#ifndef CONTENTPROPITEM_H
|
||||
#define CONTENTPROPITEM_H
|
||||
|
||||
#include "lrstringpropitem.h"
|
||||
#include "objectinspector/editors/lrbuttonlineeditor.h"
|
||||
|
||||
namespace LimeReport {
|
||||
|
||||
class ContentEditor : public ButtonLineEditor{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ContentEditor(QObject* object, const QString& propertyName,QWidget *parent = 0)
|
||||
:ButtonLineEditor(propertyName,parent), m_object(object){}
|
||||
public slots:
|
||||
void editButtonClicked();
|
||||
private:
|
||||
QObject* m_object;
|
||||
};
|
||||
|
||||
class ContentPropItem : public StringPropItem{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ContentPropItem():StringPropItem(){}
|
||||
ContentPropItem(QObject* object, ObjectsList* objects, const QString& name, const QString& displayName, const QVariant& value, ObjectPropItem* parent, bool readonly)
|
||||
:StringPropItem(object, objects, name, displayName, value, parent, readonly){}
|
||||
QWidget* createProperyEditor(QWidget *parent) const;
|
||||
};
|
||||
|
||||
} // namespace LimeReport
|
||||
|
||||
#endif // CONTENTPROPITEM_H
|
@@ -69,7 +69,7 @@ void EnumPropItem::slotEnumChanged(const QString &text)
|
||||
{
|
||||
if ( nameByType(object()->property(propertyName().toLatin1()).toInt())!=text){
|
||||
beginChangeValue();
|
||||
object()->setProperty(propertyName().toLatin1(),typeByName(text));
|
||||
setValueToObject(propertyName(),typeByName(text));
|
||||
setPropertyValue(typeByName(text));
|
||||
endChangeValue();
|
||||
}
|
||||
@@ -83,7 +83,7 @@ void EnumPropItem::setPropertyEditorData(QWidget *propertyEditor, const QModelIn
|
||||
|
||||
void EnumPropItem::setModelData(QWidget *propertyEditor, QAbstractItemModel *model, const QModelIndex &index)
|
||||
{
|
||||
object()->setProperty(propertyName().toLatin1(),typeByName(qobject_cast<ComboBoxEditor*>(propertyEditor)->text()));
|
||||
setValueToObject(propertyName(),typeByName(qobject_cast<ComboBoxEditor*>(propertyEditor)->text()));
|
||||
model->setData(index,object()->property(propertyName().toLatin1()));
|
||||
}
|
||||
|
||||
|
@@ -132,7 +132,7 @@ void FlagPropItem::setModelData(QWidget *propertyEditor, QAbstractItemModel *mod
|
||||
int flags = object()->property(parent()->propertyName().toLatin1()).toInt();
|
||||
if (value) flags=flags | valueByName(displayName());
|
||||
else if (flags&valueByName(displayName())) flags=flags ^ valueByName(displayName());
|
||||
object()->setProperty(parent()->propertyName().toLatin1(),flags);
|
||||
setValueToObject(propertyName(),propertyValue());
|
||||
parent()->setPropertyValue(flags);
|
||||
}
|
||||
|
||||
|
@@ -84,7 +84,7 @@ void FontPropItem::setPropertyEditorData(QWidget* propertyEditor, const QModelIn
|
||||
void FontPropItem::setModelData(QWidget* propertyEditor, QAbstractItemModel* model, const QModelIndex &index)
|
||||
{
|
||||
model->setData(index,qobject_cast<FontEditor*>(propertyEditor)->fontValue());
|
||||
object()->setProperty(propertyName().toLatin1(),propertyValue());
|
||||
setValueToObject(propertyName(),propertyValue());
|
||||
}
|
||||
|
||||
void FontPropItem::setPropertyValue(QVariant value)
|
||||
@@ -127,9 +127,10 @@ void FontFamilyPropItem::setPropertyEditorData(QWidget *propertyEditor, const QM
|
||||
|
||||
void FontFamilyPropItem::setModelData(QWidget *propertyEditor, QAbstractItemModel *model, const QModelIndex &index)
|
||||
{
|
||||
QFont font = qobject_cast<QFontComboBox*>(propertyEditor)->currentFont();
|
||||
QFont font = object()->property(parent()->propertyName().toLatin1()).value<QFont>();
|
||||
font.setFamily(qobject_cast<QFontComboBox*>(propertyEditor)->currentFont().family());
|
||||
model->setData(index,font);
|
||||
object()->setProperty(parent()->propertyName().toLatin1(),font);
|
||||
setValueToObject(parent()->propertyName(),font);
|
||||
}
|
||||
|
||||
void FontAttribPropItem::setModelData(QWidget *propertyEditor , QAbstractItemModel *model, const QModelIndex &index)
|
||||
@@ -145,7 +146,7 @@ void FontAttribPropItem::setModelData(QWidget *propertyEditor , QAbstractItemMod
|
||||
if (propertyName()=="underline"){
|
||||
font.setUnderline(propertyValue().toBool());
|
||||
}
|
||||
object()->setProperty(parent()->propertyName().toLatin1(),font);
|
||||
setValueToObject(parent()->propertyName(),font);
|
||||
}
|
||||
|
||||
void FontPointSizePropItem::setModelData(QWidget *propertyEditor, QAbstractItemModel *model, const QModelIndex &index)
|
||||
@@ -153,7 +154,7 @@ void FontPointSizePropItem::setModelData(QWidget *propertyEditor, QAbstractItemM
|
||||
model->setData(index,qobject_cast<QSpinBox*>(propertyEditor)->value());
|
||||
QFont font = object()->property(parent()->propertyName().toLatin1()).value<QFont>();
|
||||
font.setPointSize(propertyValue().toInt());
|
||||
object()->setProperty(parent()->propertyName().toLatin1(),font);
|
||||
setValueToObject(parent()->propertyName(),font);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -60,6 +60,11 @@ void IntPropItem::setModelData(QWidget *propertyEditor, QAbstractItemModel *mode
|
||||
{
|
||||
model->setData(index,qobject_cast<QSpinBox*>(propertyEditor)->value());
|
||||
object()->setProperty(propertyName().toLatin1(),propertyValue());
|
||||
foreach(QObject* item, *objects()){
|
||||
if (item->metaObject()->indexOfProperty(propertyName().toLatin1())!=-1){
|
||||
item->setProperty(propertyName().toLatin1(),propertyValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace LimeReport
|
||||
|
@@ -61,7 +61,8 @@ void QRealPropItem::setPropertyEditorData(QWidget *propertyEditor, const QModelI
|
||||
void QRealPropItem::setModelData(QWidget *propertyEditor, QAbstractItemModel *model, const QModelIndex &index)
|
||||
{
|
||||
model->setData(index,qobject_cast<QDoubleSpinBox*>(propertyEditor)->value());
|
||||
object()->setProperty(propertyName().toLatin1(),propertyValue());
|
||||
//object()->setProperty(propertyName().toLatin1(),propertyValue());
|
||||
setValueToObject(propertyName(),propertyValue());
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user