0
0
mirror of https://github.com/fralx/LimeReport.git synced 2024-12-24 16:44:39 +03:00

Object inspector has been fixed

This commit is contained in:
Arin Alexander 2016-11-01 14:56:06 +03:00
parent b8ecc89ff0
commit c623932afb
9 changed files with 75 additions and 20 deletions

View File

@ -109,7 +109,8 @@ void AlignmentItemEditor::setModelData(QWidget *propertyEditor, QAbstractItemMod
int align = m_acceptableValues.value(qobject_cast<ComboBoxEditor*>(propertyEditor)->text()); int align = m_acceptableValues.value(qobject_cast<ComboBoxEditor*>(propertyEditor)->text());
flags=clearAcceptableValues(flags) | align; flags=clearAcceptableValues(flags) | align;
object()->setProperty(propertyName().toLatin1(),flags); object()->setProperty(propertyName().toLatin1(),flags);
foreach(QObject* item,*objects()){item->setProperty(propertyName().toLatin1(),flags);} if (objects())
foreach(QObject* item,*objects()){item->setProperty(propertyName().toLatin1(),flags);}
parent()->setPropertyValue(flags); parent()->setPropertyValue(flags);
model->setData(index,align); model->setData(index,align);
} }

View File

@ -60,6 +60,18 @@ TextItem::TextItem(QObject *owner, QGraphicsItem *parent)
m_allowHTMLInFields(false) m_allowHTMLInFields(false)
{ {
m_text = new QTextDocument(); m_text = new QTextDocument();
PageItemDesignIntf* pageItem = dynamic_cast<PageItemDesignIntf*>(parent);
BaseDesignIntf* parentItem = dynamic_cast<BaseDesignIntf*>(parent);
while (!pageItem){
parentItem = dynamic_cast<BaseDesignIntf*>(parentItem->parentItem());
pageItem = dynamic_cast<PageItemDesignIntf*>(parentItem);
}
if (pageItem){
QFont defaultFont = pageItem->font();
setFont(defaultFont);
}
Init(); Init();
} }

View File

@ -321,7 +321,7 @@ ObjectPropItem * QObjectPropertyModel::createPropertyItem(QMetaProperty prop, QO
object, object,
objects, objects,
QString(prop.name()), QString(prop.name()),
QString(tr(prop.name())), //сделать перевод значений на другие языки QString(tr(prop.name())),
object->property(prop.name()), object->property(prop.name()),
parent, parent,
!(prop.isWritable()&&prop.isDesignable()) !(prop.isWritable()&&prop.isDesignable())

View File

@ -147,9 +147,11 @@ void ObjectPropItem::slotPropertyObjectName(const QString &oldValue, const QStri
void ObjectPropItem::setValueToObject(const QString &propertyName, QVariant propertyValue) void ObjectPropItem::setValueToObject(const QString &propertyName, QVariant propertyValue)
{ {
object()->setProperty(propertyName.toLatin1(),propertyValue); object()->setProperty(propertyName.toLatin1(),propertyValue);
foreach (QObject* item, *objects()) { if (objects()){
if (item->metaObject()->indexOfProperty(propertyName.toLatin1())!=-1) foreach (QObject* item, *objects()) {
item->setProperty(propertyName.toLatin1(), propertyValue); if (item->metaObject()->indexOfProperty(propertyName.toLatin1())!=-1)
item->setProperty(propertyName.toLatin1(), propertyValue);
}
} }
} }

View File

@ -97,7 +97,7 @@ namespace LimeReport{
#endif #endif
private: private:
bool m_valid; bool m_valid;
void invalidate(){m_object=0; m_valid = false; m_name = ""; m_value=QVariant(), m_isClass=false;} void invalidate(){m_object=0; m_objects=0; m_valid = false; m_name = ""; m_value=QVariant(), m_isClass=false;}
protected: protected:
void beginChangeValue(){ m_changingValue = true; } void beginChangeValue(){ m_changingValue = true; }

View File

@ -37,10 +37,7 @@
LimeReport::PropertyDelegate::PropertyDelegate(QObject *parent) LimeReport::PropertyDelegate::PropertyDelegate(QObject *parent)
:QItemDelegate(parent), m_editingItem(0), m_isEditing(false) :QItemDelegate(parent), m_editingItem(0), m_isEditing(false)
//:QStyledItemDelegate(parent), m_editingItem(0) {}
{
//setClipping(false);
}
void LimeReport::PropertyDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const void LimeReport::PropertyDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{ {

View File

@ -28,8 +28,6 @@
* GNU General Public License for more details. * * GNU General Public License for more details. *
****************************************************************************/ ****************************************************************************/
#include <QFontDialog> #include <QFontDialog>
#include <QSpinBox>
#include <QFontComboBox>
#include "lrfontpropitem.h" #include "lrfontpropitem.h"
#include "editors/lrbuttonlineeditor.h" #include "editors/lrbuttonlineeditor.h"
@ -52,6 +50,7 @@ namespace LimeReport{
FontPropItem::FontPropItem(QObject *object, ObjectPropItem::ObjectsList *objects, const QString &name, const QString &displayName, const QVariant &value, ObjectPropItem *parent, bool readonly) FontPropItem::FontPropItem(QObject *object, ObjectPropItem::ObjectsList *objects, const QString &name, const QString &displayName, const QVariant &value, ObjectPropItem *parent, bool readonly)
:ObjectPropItem(object, objects, name, displayName, value, parent, readonly) :ObjectPropItem(object, objects, name, displayName, value, parent, readonly)
{ {
m_bold = new FontAttribPropItem(object,objects,"bold",tr("bold"),propertyValue().value<QFont>().bold(),this,false); m_bold = new FontAttribPropItem(object,objects,"bold",tr("bold"),propertyValue().value<QFont>().bold(),this,false);
m_italic = new FontAttribPropItem(object,objects,"italic",tr("italic"),propertyValue().value<QFont>().italic(),this,false); m_italic = new FontAttribPropItem(object,objects,"italic",tr("italic"),propertyValue().value<QFont>().italic(),this,false);
m_underline = new FontAttribPropItem(object,objects,"underline",tr("underline"),propertyValue().value<QFont>().underline(),this,false); m_underline = new FontAttribPropItem(object,objects,"underline",tr("underline"),propertyValue().value<QFont>().underline(),this,false);
@ -114,21 +113,25 @@ QString FontFamilyPropItem::displayValue() const
QWidget *FontFamilyPropItem::createProperyEditor(QWidget *parent) const QWidget *FontFamilyPropItem::createProperyEditor(QWidget *parent) const
{ {
QFontComboBox* editor = new QFontComboBox(parent); FontFamilyEditor* editor = new FontFamilyEditor(parent);
// QFontComboBox* editor = new QFontComboBox(parent);
editor->setAutoFillBackground(true);
editor->setFont(propertyValue().value<QFont>()); editor->setFont(propertyValue().value<QFont>());
return editor; return editor;
} }
void FontFamilyPropItem::setPropertyEditorData(QWidget *propertyEditor, const QModelIndex &) const void FontFamilyPropItem::setPropertyEditorData(QWidget *propertyEditor, const QModelIndex &) const
{ {
QFontComboBox* editor = qobject_cast<QFontComboBox*>(propertyEditor); FontFamilyEditor* editor = qobject_cast<FontFamilyEditor*>(propertyEditor);
editor->setCurrentFont(propertyValue().value<QFont>()); // QFontComboBox* editor = qobject_cast<QFontComboBox*>(propertyEditor);
editor->setFont(propertyValue().value<QFont>());
} }
void FontFamilyPropItem::setModelData(QWidget *propertyEditor, QAbstractItemModel *model, const QModelIndex &index) void FontFamilyPropItem::setModelData(QWidget *propertyEditor, QAbstractItemModel *model, const QModelIndex &index)
{ {
QFont font = object()->property(parent()->propertyName().toLatin1()).value<QFont>(); QFont font = object()->property(parent()->propertyName().toLatin1()).value<QFont>();
font.setFamily(qobject_cast<QFontComboBox*>(propertyEditor)->currentFont().family()); // font.setFamily(qobject_cast<QFontComboBox*>(propertyEditor)->currentFont().family());
font.setFamily(qobject_cast<FontFamilyEditor*>(propertyEditor)->currentFont().family());
model->setData(index,font); model->setData(index,font);
setValueToObject(parent()->propertyName(),font); setValueToObject(parent()->propertyName(),font);
} }
@ -151,10 +154,33 @@ void FontAttribPropItem::setModelData(QWidget *propertyEditor , QAbstractItemMod
void FontPointSizePropItem::setModelData(QWidget *propertyEditor, QAbstractItemModel *model, const QModelIndex &index) void FontPointSizePropItem::setModelData(QWidget *propertyEditor, QAbstractItemModel *model, const QModelIndex &index)
{ {
model->setData(index,qobject_cast<QSpinBox*>(propertyEditor)->value()); model->setData(index,qobject_cast<SpinBoxEditor*>(propertyEditor)->value());
QFont font = object()->property(parent()->propertyName().toLatin1()).value<QFont>(); QFont font = object()->property(parent()->propertyName().toLatin1()).value<QFont>();
font.setPointSize(propertyValue().toInt()); font.setPointSize(propertyValue().toInt());
setValueToObject(parent()->propertyName(),font); setValueToObject(parent()->propertyName(),font);
} }
FontFamilyEditor::FontFamilyEditor(QWidget *parent)
:QWidget(parent)
{
m_valueEditor = new QFontComboBox(this);
setFocusProxy(m_valueEditor);
QHBoxLayout* hLayout = new QHBoxLayout(this);
hLayout->addWidget(m_valueEditor);
hLayout->setContentsMargins(1,1,1,1);
hLayout->setSpacing(0);
setAutoFillBackground(true);
}
QFont FontFamilyEditor::currentFont()
{
return m_valueEditor->currentFont();
}
void FontFamilyEditor::setFont(QFont font)
{
m_valueEditor->setCurrentFont(font);
m_valueEditor->setFont(font);
}
} }

View File

@ -29,12 +29,27 @@
****************************************************************************/ ****************************************************************************/
#ifndef LRFONTPROPITEM_H #ifndef LRFONTPROPITEM_H
#define LRFONTPROPITEM_H #define LRFONTPROPITEM_H
#include <QFontComboBox>
#include "lrobjectpropitem.h" #include "lrobjectpropitem.h"
#include "lrboolpropitem.h" #include "lrboolpropitem.h"
#include "lrintpropitem.h" #include "lrintpropitem.h"
namespace LimeReport{ namespace LimeReport{
class FontFamilyEditor : public QWidget{
Q_OBJECT
public:
FontFamilyEditor(QWidget* parent);
QFont currentFont();
void setFont(QFont font);
signals:
void editingFinished();
private:
QFontComboBox* m_valueEditor;
};
class FontFamilyPropItem : public ObjectPropItem class FontFamilyPropItem : public ObjectPropItem
{ {
Q_OBJECT Q_OBJECT

View File

@ -67,9 +67,11 @@ void IntPropItem::setModelData(QWidget *propertyEditor, QAbstractItemModel *mode
{ {
model->setData(index,qobject_cast<SpinBoxEditor*>(propertyEditor)->value()); model->setData(index,qobject_cast<SpinBoxEditor*>(propertyEditor)->value());
object()->setProperty(propertyName().toLatin1(),propertyValue()); object()->setProperty(propertyName().toLatin1(),propertyValue());
foreach(QObject* item, *objects()){ if (objects()){
if (item->metaObject()->indexOfProperty(propertyName().toLatin1())!=-1){ foreach(QObject* item, *objects()){
item->setProperty(propertyName().toLatin1(),propertyValue()); if (item->metaObject()->indexOfProperty(propertyName().toLatin1())!=-1){
item->setProperty(propertyName().toLatin1(),propertyValue());
}
} }
} }
} }