diff --git a/include/lrpreparedpagesintf.h b/include/lrpreparedpagesintf.h new file mode 100644 index 0000000..a079a9a --- /dev/null +++ b/include/lrpreparedpagesintf.h @@ -0,0 +1,17 @@ +#ifndef LRPREPAREDPAGESINTF_H +#define LRPREPAREDPAGESINTF_H +#include "lrglobal.h" +namespace LimeReport { +class LIMEREPORT_EXPORT IPreparedPages{ +public: + virtual ~IPreparedPages(){}; + virtual bool loadFromFile(const QString& fileName) = 0; + virtual bool loadFromString(const QString data) = 0; + virtual bool loadFromByteArray(QByteArray* data) = 0; + virtual bool saveToFile(const QString& fileName) = 0; + virtual QString saveToString() = 0; + virtual QByteArray saveToByteArray() = 0; + virtual void clear() = 0; +}; +} //namespace LimeReport +#endif // LRPREPAREDPAGESINTF_H diff --git a/limereport/lrreportdesignwidget.h b/limereport/lrreportdesignwidget.h index 3429cae..149dcb5 100644 --- a/limereport/lrreportdesignwidget.h +++ b/limereport/lrreportdesignwidget.h @@ -95,9 +95,7 @@ public: } void setPageItem(PageItemDesignIntf* pageItem); protected: -// void mouseMoveEvent(QMouseEvent *event); -// void resizeEvent(QResizeEvent *event); - bool viewportEvent(QEvent *event); + bool viewportEvent(QEvent *event); private: PageItemDesignIntf* m_pageItem; Ruler* m_horizontalRuller; diff --git a/limereport/lrreportdesignwindow.cpp b/limereport/lrreportdesignwindow.cpp index 1b79168..1fdc9e7 100644 --- a/limereport/lrreportdesignwindow.cpp +++ b/limereport/lrreportdesignwindow.cpp @@ -506,6 +506,7 @@ void ReportDesignWindow::createObjectInspector() m_validator = new ObjectNameValidator(); m_objectInspector->setValidator(m_validator); m_objectInspector->setSubclassesAsLevel(false); + m_objectInspector->setTranslateProperties(true); m_objectInspector->setAlternatingRowColors(true); m_objectInspector->setRootIsDecorated(!m_objectInspector->subclassesAsLevel()); QDockWidget *objectDoc = new QDockWidget(this); @@ -696,6 +697,7 @@ void ReportDesignWindow::writeState() settings()->setValue("ScriptEditorsState", m_editorsStates[ReportDesignWidget::Script]); settings()->setValue("TranslationEditorsState", m_editorsStates[ReportDesignWidget::Translations]); settings()->setValue("InspectorFirsColumnWidth", m_objectInspector->columnWidth(0)); + settings()->setValue("InspectorTranslateProperties", m_objectInspector->translateProperties()); settings()->endGroup(); settings()->beginGroup("RecentFiles"); settings()->setValue("filesCount",m_recentFiles.count()); @@ -811,6 +813,11 @@ void ReportDesignWindow::restoreSetting() m_objectInspector->setColumnWidth(0,v.toInt()); } + v = settings()->value("InspectorTranslateProperties"); + if (v.isValid()){ + m_objectInspector->setTranslateProperties(v.toBool()); + } + settings()->endGroup(); settings()->beginGroup("RecentFiles"); diff --git a/limereport/lrvariablesholder.cpp b/limereport/lrvariablesholder.cpp index c34dc4c..4e79084 100644 --- a/limereport/lrvariablesholder.cpp +++ b/limereport/lrvariablesholder.cpp @@ -44,7 +44,7 @@ VariablesHolder::~VariablesHolder() QMap::iterator it = m_varNames.begin(); while(it!=m_varNames.end()){ delete *it; - it++; + ++it; } m_varNames.clear(); m_userVariables.clear(); diff --git a/limereport/objectinspector/images/settings.png b/limereport/objectinspector/images/settings.png new file mode 100644 index 0000000..226e2f0 Binary files /dev/null and b/limereport/objectinspector/images/settings.png differ diff --git a/limereport/objectinspector/lobjectinspector.qrc b/limereport/objectinspector/lobjectinspector.qrc index 7dd5e48..6b6f10f 100644 --- a/limereport/objectinspector/lobjectinspector.qrc +++ b/limereport/objectinspector/lobjectinspector.qrc @@ -6,5 +6,6 @@ images/uncheck.png images/check_w.png images/uncheck_w.png + images/settings.png diff --git a/limereport/objectinspector/lrobjectinspectorwidget.cpp b/limereport/objectinspector/lrobjectinspectorwidget.cpp index d4158f0..3997e16 100644 --- a/limereport/objectinspector/lrobjectinspectorwidget.cpp +++ b/limereport/objectinspector/lrobjectinspectorwidget.cpp @@ -34,6 +34,7 @@ #include #include #include +#include #include "lrglobal.h" #include "lrobjectinspectorwidget.h" @@ -183,10 +184,25 @@ ObjectInspectorWidget::ObjectInspectorWidget(QWidget *parent) connect(pbClear, SIGNAL(clicked()), le, SLOT(clear())); le->setPlaceholderText(tr("Filter")); connect(le, SIGNAL(textChanged(const QString&)), this, SLOT(slotFilterTextChanged(const QString&))); + + QToolButton* settingButton = new QToolButton(this); + settingButton->setIcon(QIcon(":/items/images/settings.png")); + QMenu* settingMenu = new QMenu(settingButton); + m_translateProperties = settingMenu->addAction(tr("Translate properties")); + m_translateProperties->setCheckable(true); + m_translateProperties->setChecked(translateProperties()); + + connect(m_translateProperties, SIGNAL(toggled(bool)), + this, SLOT(slotTranslatePropertiesChecked(bool))); + + settingButton->setMenu(settingMenu); + settingButton->setPopupMode(QToolButton::InstantPopup); + QHBoxLayout* h = new QHBoxLayout(); h->setSpacing(2); h->addWidget(le); h->addWidget(pbClear); + h->addWidget(settingButton); l->addLayout(h); l->addWidget(m_objectInspectorView); l->setMargin(Const::DOCKWIDGET_MARGINS); @@ -246,6 +262,18 @@ void ObjectInspectorWidget::setSubclassesAsLevel(bool value) m_propertyModel->setSubclassesAsLevel(value); } +bool ObjectInspectorWidget::translateProperties() +{ + return m_propertyModel->isTranslateProperties(); +} + +void ObjectInspectorWidget::setTranslateProperties(bool value) +{ + m_propertyModel->setTranslateProperties(value); + m_translateProperties->setChecked(value); + update(); +} + const QObject *ObjectInspectorWidget::object(){ return m_propertyModel->currentObject(); } @@ -276,4 +304,9 @@ void ObjectInspectorWidget::slotFilterTextChanged(const QString &filter) m_filterModel->setFilterRegExp(QRegExp(filter, Qt::CaseInsensitive, QRegExp::FixedString)); } +void ObjectInspectorWidget::slotTranslatePropertiesChecked(bool value) +{ + setTranslateProperties(value); +} + } //namespace LimeReport diff --git a/limereport/objectinspector/lrobjectinspectorwidget.h b/limereport/objectinspector/lrobjectinspectorwidget.h index 88ef97a..fb1d0a6 100644 --- a/limereport/objectinspector/lrobjectinspectorwidget.h +++ b/limereport/objectinspector/lrobjectinspectorwidget.h @@ -83,6 +83,8 @@ public: void setValidator(ValidatorIntf *validator); bool subclassesAsLevel(); void setSubclassesAsLevel(bool value); + bool translateProperties(); + void setTranslateProperties(bool value); void setObject(QObject* setObject); const QObject* object(); void setMultiObjects(QList* list); @@ -90,10 +92,13 @@ public: void updateProperty(const QString &propertyName); private slots: void slotFilterTextChanged(const QString& filter); + void slotTranslatePropertiesChecked(bool value); private: ObjectInspectorTreeView* m_objectInspectorView; QSortFilterProxyModel* m_filterModel; BaseDesignPropertyModel* m_propertyModel; + QAction* m_translateProperties; + }; } //namespace LimeReport diff --git a/limereport/objectinspector/lrobjectitemmodel.cpp b/limereport/objectinspector/lrobjectitemmodel.cpp index e7bf04f..9aff3a0 100644 --- a/limereport/objectinspector/lrobjectitemmodel.cpp +++ b/limereport/objectinspector/lrobjectitemmodel.cpp @@ -169,7 +169,8 @@ void QObjectPropertyModel::clearObjectsList() } QObjectPropertyModel::QObjectPropertyModel(QObject *parent/*=0*/) - :QAbstractItemModel(parent),m_rootNode(0),m_object(0),m_dataChanging(false), m_subclassesAsLevel(true), m_validator(0) + :QAbstractItemModel(parent),m_rootNode(0), m_object(0), m_dataChanging(false), + m_subclassesAsLevel(true), m_validator(0), m_translateProperties(true) {} QObjectPropertyModel::~QObjectPropertyModel() @@ -297,16 +298,17 @@ QVariant QObjectPropertyModel::data(const QModelIndex &index, int role) const switch (role) { case Qt::DisplayRole: if (!node) return QVariant(); + node->setTranslateProperty(isTranslateProperties()); if (index.column()==0){ return node->displayName(); - } else return node->displayValue(); - break; + } else { + return node->displayValue(); + } case Qt::DecorationRole : if (!node) return QIcon(); if (index.column()==1){ return node->iconValue(); - }else return QIcon(); - break; + } else return QIcon(); case Qt::UserRole: return QVariant::fromValue(node); default: @@ -418,6 +420,16 @@ ObjectPropItem * QObjectPropertyModel::createPropertyItem(QMetaProperty prop, QO } return propertyItem; } + +bool QObjectPropertyModel::isTranslateProperties() const +{ + return m_translateProperties; +} + +void QObjectPropertyModel::setTranslateProperties(bool translateProperties) +{ + m_translateProperties = translateProperties; +} ValidatorIntf *QObjectPropertyModel::validator() const { return m_validator; diff --git a/limereport/objectinspector/lrobjectitemmodel.h b/limereport/objectinspector/lrobjectitemmodel.h index bf01cb2..2aa1f8b 100644 --- a/limereport/objectinspector/lrobjectitemmodel.h +++ b/limereport/objectinspector/lrobjectitemmodel.h @@ -72,6 +72,9 @@ public: void setValidator(ValidatorIntf* validator); void translatePropertyName(); void clearObjectsList(); + bool isTranslateProperties() const; + void setTranslateProperties(bool isTranslateProperties); + signals: void objectPropetyChanged(const QString& , const QVariant&, const QVariant&); private slots: @@ -83,12 +86,13 @@ private: LimeReport::CreatePropItem propertyItemCreator(QMetaProperty prop); LimeReport::ObjectPropItem* createPropertyItem(QMetaProperty prop, QObject *object, ObjectPropItem::ObjectsList* objects, ObjectPropItem* parent); private: - LimeReport::ObjectPropItem* m_rootNode; - QObject* m_object; - QList m_objects; - bool m_dataChanging; - bool m_subclassesAsLevel; - ValidatorIntf* m_validator; + LimeReport::ObjectPropItem* m_rootNode; + QObject* m_object; + QList m_objects; + bool m_dataChanging; + bool m_subclassesAsLevel; + ValidatorIntf* m_validator; + bool m_translateProperties; }; } diff --git a/limereport/objectinspector/lrobjectpropitem.cpp b/limereport/objectinspector/lrobjectpropitem.cpp index 3fc212c..6ef6613 100644 --- a/limereport/objectinspector/lrobjectpropitem.cpp +++ b/limereport/objectinspector/lrobjectpropitem.cpp @@ -42,7 +42,8 @@ bool lesThen(ObjectPropItem* v1, ObjectPropItem* v2){ ObjectPropItem::ObjectPropItem(QObject *object, ObjectsList* objects, const QString &name, const QString &displayName, ObjectPropItem *parent, bool isClass) :m_object(object), m_name(name), m_displayName(displayName), m_haveValue(false), m_parent(parent), m_colorIndex(-1), - m_readonly(true), m_model(0), m_isClass(isClass), m_changingValue(false) + m_readonly(true), m_model(0), m_isClass(isClass), m_changingValue(false), + m_translatePropperty(true) { if (parent) setModel(parent->model()); m_index=QModelIndex(); @@ -60,7 +61,8 @@ ObjectPropItem::ObjectPropItem(QObject *object, ObjectsList* objects, const QStr ObjectPropItem::ObjectPropItem(QObject *object, ObjectsList* objects, const QString &name, const QString &displayName, const QVariant &value, ObjectPropItem *parent, bool readonly) :m_object(object), m_name(name), m_displayName(displayName), m_value(value), m_haveValue(true), m_parent(parent), m_colorIndex(-1), - m_readonly(readonly), m_model(0), m_isClass(false), m_changingValue(false) + m_readonly(readonly), m_model(0), m_isClass(false), m_changingValue(false), + m_translatePropperty(true) { if (parent) setModel(parent->model()); m_index=QModelIndex(); @@ -109,6 +111,10 @@ void ObjectPropItem::setPropertyValue(QVariant value){ } } +QString ObjectPropItem::displayName() const { + return isTranslateProperty() ? m_displayName : propertyName(); +} + int ObjectPropItem::row(){ if (m_parent) return m_parent->m_childItems.indexOf(const_cast(this)); @@ -155,6 +161,16 @@ void ObjectPropItem::setValueToObject(const QString &propertyName, QVariant prop } } +bool ObjectPropItem::isTranslateProperty() const +{ + return m_translatePropperty; +} + +void ObjectPropItem::setTranslateProperty(bool translatePropperty) +{ + m_translatePropperty = translatePropperty; +} + ObjectPropItem * ObjectPropItem::findChild(const QString &name) { foreach(ObjectPropItem* item,m_childItems){ diff --git a/limereport/objectinspector/lrobjectpropitem.h b/limereport/objectinspector/lrobjectpropitem.h index c5403cd..46392fc 100644 --- a/limereport/objectinspector/lrobjectpropitem.h +++ b/limereport/objectinspector/lrobjectpropitem.h @@ -56,7 +56,7 @@ namespace LimeReport{ virtual QVariant propertyValue() const; virtual void setPropertyValue(QVariant value); virtual QString propertyName() const {return m_name;} - virtual QString displayName() const {return m_displayName;} + virtual QString displayName() const; virtual QString displayValue() const; virtual QIcon iconValue() const{return QIcon();} virtual bool isHaveChildren() const {return m_childItems.count()>0;} @@ -90,6 +90,8 @@ namespace LimeReport{ void setModelIndex(const QModelIndex& index){m_index=index;} QModelIndex modelIndex(){return m_index;} bool isClass(){return m_isClass;} + bool isTranslateProperty() const; + void setTranslateProperty(bool translatePropperty); #ifdef INSPECT_BASEDESIGN private slots: void slotPropertyChanged(const QString& name, QVariant, QVariant newValue); @@ -120,6 +122,7 @@ namespace LimeReport{ QModelIndex m_index; bool m_isClass; bool m_changingValue; + bool m_translatePropperty; }; typedef QPair APropIdent; diff --git a/limereport/objectinspector/propertyItems/lrenumpropitem.cpp b/limereport/objectinspector/propertyItems/lrenumpropitem.cpp index 143ba38..d38331d 100644 --- a/limereport/objectinspector/propertyItems/lrenumpropitem.cpp +++ b/limereport/objectinspector/propertyItems/lrenumpropitem.cpp @@ -162,7 +162,7 @@ void EnumPropItem::setModelData(QWidget *propertyEditor, QAbstractItemModel *mod QString EnumPropItem::nameByType(int value) const { QMetaEnum propEnum = object()->metaObject()->property(object()->metaObject()->indexOfProperty(propertyName().toLatin1())).enumerator(); - return tr(propEnum.valueToKey(value)); + return isTranslateProperty() ? tr(propEnum.valueToKey(value)) : propEnum.valueToKey(value); } int EnumPropItem::typeByName(const QString &value) const diff --git a/limereport/objectinspector/propertyItems/lrflagspropitem.cpp b/limereport/objectinspector/propertyItems/lrflagspropitem.cpp index de4af7c..91d142e 100644 --- a/limereport/objectinspector/propertyItems/lrflagspropitem.cpp +++ b/limereport/objectinspector/propertyItems/lrflagspropitem.cpp @@ -97,8 +97,8 @@ QString FlagsPropItem::displayValue() const { if ((propEnum.keyToValue(propEnum.key(i)) == 0) ? propertyValue().toInt() == 0 : (propertyValue().toInt() & propEnum.keyToValue(propEnum.key(i))) == propEnum.keyToValue(propEnum.key(i))) { - if (result.isEmpty()) result+= tr(propEnum.key(i)); - else result=result+" | "+tr(propEnum.key(i)); + if (result.isEmpty()) result+= isTranslateProperty() ? tr(propEnum.key(i)) : propEnum.key(i); + else result=result+" | "+ (isTranslateProperty() ? tr(propEnum.key(i)) : propEnum.key(i)); } } diff --git a/translations/limereport_ru.qm b/translations/limereport_ru.qm index 3ce791a..35a81f9 100644 Binary files a/translations/limereport_ru.qm and b/translations/limereport_ru.qm differ diff --git a/translations/limereport_ru.ts b/translations/limereport_ru.ts index 2bca21d..b6da993 100644 --- a/translations/limereport_ru.ts +++ b/translations/limereport_ru.ts @@ -1235,6 +1235,10 @@ p, li { white-space: pre-wrap; } Filter Фильтр + + Translate properties + Переводить имена свойств + LimeReport::PDFExporter