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

Turn off translation for object properties ability has been added to the object inspector

This commit is contained in:
Arin Alexander 2019-06-28 13:08:33 +03:00
parent 9a3af52cd7
commit 99757097cc
16 changed files with 121 additions and 21 deletions

View File

@ -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

View File

@ -95,9 +95,7 @@ public:
} }
void setPageItem(PageItemDesignIntf* pageItem); void setPageItem(PageItemDesignIntf* pageItem);
protected: protected:
// void mouseMoveEvent(QMouseEvent *event); bool viewportEvent(QEvent *event);
// void resizeEvent(QResizeEvent *event);
bool viewportEvent(QEvent *event);
private: private:
PageItemDesignIntf* m_pageItem; PageItemDesignIntf* m_pageItem;
Ruler* m_horizontalRuller; Ruler* m_horizontalRuller;

View File

@ -506,6 +506,7 @@ void ReportDesignWindow::createObjectInspector()
m_validator = new ObjectNameValidator(); m_validator = new ObjectNameValidator();
m_objectInspector->setValidator(m_validator); m_objectInspector->setValidator(m_validator);
m_objectInspector->setSubclassesAsLevel(false); m_objectInspector->setSubclassesAsLevel(false);
m_objectInspector->setTranslateProperties(true);
m_objectInspector->setAlternatingRowColors(true); m_objectInspector->setAlternatingRowColors(true);
m_objectInspector->setRootIsDecorated(!m_objectInspector->subclassesAsLevel()); m_objectInspector->setRootIsDecorated(!m_objectInspector->subclassesAsLevel());
QDockWidget *objectDoc = new QDockWidget(this); QDockWidget *objectDoc = new QDockWidget(this);
@ -696,6 +697,7 @@ void ReportDesignWindow::writeState()
settings()->setValue("ScriptEditorsState", m_editorsStates[ReportDesignWidget::Script]); settings()->setValue("ScriptEditorsState", m_editorsStates[ReportDesignWidget::Script]);
settings()->setValue("TranslationEditorsState", m_editorsStates[ReportDesignWidget::Translations]); settings()->setValue("TranslationEditorsState", m_editorsStates[ReportDesignWidget::Translations]);
settings()->setValue("InspectorFirsColumnWidth", m_objectInspector->columnWidth(0)); settings()->setValue("InspectorFirsColumnWidth", m_objectInspector->columnWidth(0));
settings()->setValue("InspectorTranslateProperties", m_objectInspector->translateProperties());
settings()->endGroup(); settings()->endGroup();
settings()->beginGroup("RecentFiles"); settings()->beginGroup("RecentFiles");
settings()->setValue("filesCount",m_recentFiles.count()); settings()->setValue("filesCount",m_recentFiles.count());
@ -811,6 +813,11 @@ void ReportDesignWindow::restoreSetting()
m_objectInspector->setColumnWidth(0,v.toInt()); m_objectInspector->setColumnWidth(0,v.toInt());
} }
v = settings()->value("InspectorTranslateProperties");
if (v.isValid()){
m_objectInspector->setTranslateProperties(v.toBool());
}
settings()->endGroup(); settings()->endGroup();
settings()->beginGroup("RecentFiles"); settings()->beginGroup("RecentFiles");

View File

@ -44,7 +44,7 @@ VariablesHolder::~VariablesHolder()
QMap<QString,VarDesc*>::iterator it = m_varNames.begin(); QMap<QString,VarDesc*>::iterator it = m_varNames.begin();
while(it!=m_varNames.end()){ while(it!=m_varNames.end()){
delete *it; delete *it;
it++; ++it;
} }
m_varNames.clear(); m_varNames.clear();
m_userVariables.clear(); m_userVariables.clear();

Binary file not shown.

After

Width:  |  Height:  |  Size: 643 B

View File

@ -6,5 +6,6 @@
<file>images/uncheck.png</file> <file>images/uncheck.png</file>
<file alias="checked.png">images/check_w.png</file> <file alias="checked.png">images/check_w.png</file>
<file alias="unchecked.png">images/uncheck_w.png</file> <file alias="unchecked.png">images/uncheck_w.png</file>
<file>images/settings.png</file>
</qresource> </qresource>
</RCC> </RCC>

View File

@ -34,6 +34,7 @@
#include <QHBoxLayout> #include <QHBoxLayout>
#include <QLineEdit> #include <QLineEdit>
#include <QToolButton> #include <QToolButton>
#include <QMenu>
#include "lrglobal.h" #include "lrglobal.h"
#include "lrobjectinspectorwidget.h" #include "lrobjectinspectorwidget.h"
@ -183,10 +184,25 @@ ObjectInspectorWidget::ObjectInspectorWidget(QWidget *parent)
connect(pbClear, SIGNAL(clicked()), le, SLOT(clear())); connect(pbClear, SIGNAL(clicked()), le, SLOT(clear()));
le->setPlaceholderText(tr("Filter")); le->setPlaceholderText(tr("Filter"));
connect(le, SIGNAL(textChanged(const QString&)), this, SLOT(slotFilterTextChanged(const QString&))); 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(); QHBoxLayout* h = new QHBoxLayout();
h->setSpacing(2); h->setSpacing(2);
h->addWidget(le); h->addWidget(le);
h->addWidget(pbClear); h->addWidget(pbClear);
h->addWidget(settingButton);
l->addLayout(h); l->addLayout(h);
l->addWidget(m_objectInspectorView); l->addWidget(m_objectInspectorView);
l->setMargin(Const::DOCKWIDGET_MARGINS); l->setMargin(Const::DOCKWIDGET_MARGINS);
@ -246,6 +262,18 @@ void ObjectInspectorWidget::setSubclassesAsLevel(bool value)
m_propertyModel->setSubclassesAsLevel(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(){ const QObject *ObjectInspectorWidget::object(){
return m_propertyModel->currentObject(); return m_propertyModel->currentObject();
} }
@ -276,4 +304,9 @@ void ObjectInspectorWidget::slotFilterTextChanged(const QString &filter)
m_filterModel->setFilterRegExp(QRegExp(filter, Qt::CaseInsensitive, QRegExp::FixedString)); m_filterModel->setFilterRegExp(QRegExp(filter, Qt::CaseInsensitive, QRegExp::FixedString));
} }
void ObjectInspectorWidget::slotTranslatePropertiesChecked(bool value)
{
setTranslateProperties(value);
}
} //namespace LimeReport } //namespace LimeReport

View File

@ -83,6 +83,8 @@ public:
void setValidator(ValidatorIntf *validator); void setValidator(ValidatorIntf *validator);
bool subclassesAsLevel(); bool subclassesAsLevel();
void setSubclassesAsLevel(bool value); void setSubclassesAsLevel(bool value);
bool translateProperties();
void setTranslateProperties(bool value);
void setObject(QObject* setObject); void setObject(QObject* setObject);
const QObject* object(); const QObject* object();
void setMultiObjects(QList<QObject *>* list); void setMultiObjects(QList<QObject *>* list);
@ -90,10 +92,13 @@ public:
void updateProperty(const QString &propertyName); void updateProperty(const QString &propertyName);
private slots: private slots:
void slotFilterTextChanged(const QString& filter); void slotFilterTextChanged(const QString& filter);
void slotTranslatePropertiesChecked(bool value);
private: private:
ObjectInspectorTreeView* m_objectInspectorView; ObjectInspectorTreeView* m_objectInspectorView;
QSortFilterProxyModel* m_filterModel; QSortFilterProxyModel* m_filterModel;
BaseDesignPropertyModel* m_propertyModel; BaseDesignPropertyModel* m_propertyModel;
QAction* m_translateProperties;
}; };
} //namespace LimeReport } //namespace LimeReport

View File

@ -169,7 +169,8 @@ void QObjectPropertyModel::clearObjectsList()
} }
QObjectPropertyModel::QObjectPropertyModel(QObject *parent/*=0*/) 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() QObjectPropertyModel::~QObjectPropertyModel()
@ -297,16 +298,17 @@ QVariant QObjectPropertyModel::data(const QModelIndex &index, int role) const
switch (role) { switch (role) {
case Qt::DisplayRole: case Qt::DisplayRole:
if (!node) return QVariant(); if (!node) return QVariant();
node->setTranslateProperty(isTranslateProperties());
if (index.column()==0){ if (index.column()==0){
return node->displayName(); return node->displayName();
} else return node->displayValue(); } else {
break; return node->displayValue();
}
case Qt::DecorationRole : case Qt::DecorationRole :
if (!node) return QIcon(); if (!node) return QIcon();
if (index.column()==1){ if (index.column()==1){
return node->iconValue(); return node->iconValue();
}else return QIcon(); } else return QIcon();
break;
case Qt::UserRole: case Qt::UserRole:
return QVariant::fromValue(node); return QVariant::fromValue(node);
default: default:
@ -418,6 +420,16 @@ ObjectPropItem * QObjectPropertyModel::createPropertyItem(QMetaProperty prop, QO
} }
return propertyItem; return propertyItem;
} }
bool QObjectPropertyModel::isTranslateProperties() const
{
return m_translateProperties;
}
void QObjectPropertyModel::setTranslateProperties(bool translateProperties)
{
m_translateProperties = translateProperties;
}
ValidatorIntf *QObjectPropertyModel::validator() const ValidatorIntf *QObjectPropertyModel::validator() const
{ {
return m_validator; return m_validator;

View File

@ -72,6 +72,9 @@ public:
void setValidator(ValidatorIntf* validator); void setValidator(ValidatorIntf* validator);
void translatePropertyName(); void translatePropertyName();
void clearObjectsList(); void clearObjectsList();
bool isTranslateProperties() const;
void setTranslateProperties(bool isTranslateProperties);
signals: signals:
void objectPropetyChanged(const QString& , const QVariant&, const QVariant&); void objectPropetyChanged(const QString& , const QVariant&, const QVariant&);
private slots: private slots:
@ -83,12 +86,13 @@ private:
LimeReport::CreatePropItem propertyItemCreator(QMetaProperty prop); LimeReport::CreatePropItem propertyItemCreator(QMetaProperty prop);
LimeReport::ObjectPropItem* createPropertyItem(QMetaProperty prop, QObject *object, ObjectPropItem::ObjectsList* objects, ObjectPropItem* parent); LimeReport::ObjectPropItem* createPropertyItem(QMetaProperty prop, QObject *object, ObjectPropItem::ObjectsList* objects, ObjectPropItem* parent);
private: private:
LimeReport::ObjectPropItem* m_rootNode; LimeReport::ObjectPropItem* m_rootNode;
QObject* m_object; QObject* m_object;
QList<QObject*> m_objects; QList<QObject*> m_objects;
bool m_dataChanging; bool m_dataChanging;
bool m_subclassesAsLevel; bool m_subclassesAsLevel;
ValidatorIntf* m_validator; ValidatorIntf* m_validator;
bool m_translateProperties;
}; };
} }

View File

@ -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) 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_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()); if (parent) setModel(parent->model());
m_index=QModelIndex(); 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) 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_object(object), m_name(name), m_displayName(displayName), m_value(value),
m_haveValue(true), m_parent(parent), m_colorIndex(-1), 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()); if (parent) setModel(parent->model());
m_index=QModelIndex(); m_index=QModelIndex();
@ -109,6 +111,10 @@ void ObjectPropItem::setPropertyValue(QVariant value){
} }
} }
QString ObjectPropItem::displayName() const {
return isTranslateProperty() ? m_displayName : propertyName();
}
int ObjectPropItem::row(){ int ObjectPropItem::row(){
if (m_parent) if (m_parent)
return m_parent->m_childItems.indexOf(const_cast<ObjectPropItem*>(this)); return m_parent->m_childItems.indexOf(const_cast<ObjectPropItem*>(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) ObjectPropItem * ObjectPropItem::findChild(const QString &name)
{ {
foreach(ObjectPropItem* item,m_childItems){ foreach(ObjectPropItem* item,m_childItems){

View File

@ -56,7 +56,7 @@ namespace LimeReport{
virtual QVariant propertyValue() const; virtual QVariant propertyValue() const;
virtual void setPropertyValue(QVariant value); virtual void setPropertyValue(QVariant value);
virtual QString propertyName() const {return m_name;} virtual QString propertyName() const {return m_name;}
virtual QString displayName() const {return m_displayName;} virtual QString displayName() const;
virtual QString displayValue() const; virtual QString displayValue() const;
virtual QIcon iconValue() const{return QIcon();} virtual QIcon iconValue() const{return QIcon();}
virtual bool isHaveChildren() const {return m_childItems.count()>0;} virtual bool isHaveChildren() const {return m_childItems.count()>0;}
@ -90,6 +90,8 @@ namespace LimeReport{
void setModelIndex(const QModelIndex& index){m_index=index;} void setModelIndex(const QModelIndex& index){m_index=index;}
QModelIndex modelIndex(){return m_index;} QModelIndex modelIndex(){return m_index;}
bool isClass(){return m_isClass;} bool isClass(){return m_isClass;}
bool isTranslateProperty() const;
void setTranslateProperty(bool translatePropperty);
#ifdef INSPECT_BASEDESIGN #ifdef INSPECT_BASEDESIGN
private slots: private slots:
void slotPropertyChanged(const QString& name, QVariant, QVariant newValue); void slotPropertyChanged(const QString& name, QVariant, QVariant newValue);
@ -120,6 +122,7 @@ namespace LimeReport{
QModelIndex m_index; QModelIndex m_index;
bool m_isClass; bool m_isClass;
bool m_changingValue; bool m_changingValue;
bool m_translatePropperty;
}; };
typedef QPair<QString,QString> APropIdent; typedef QPair<QString,QString> APropIdent;

View File

@ -162,7 +162,7 @@ void EnumPropItem::setModelData(QWidget *propertyEditor, QAbstractItemModel *mod
QString EnumPropItem::nameByType(int value) const QString EnumPropItem::nameByType(int value) const
{ {
QMetaEnum propEnum = object()->metaObject()->property(object()->metaObject()->indexOfProperty(propertyName().toLatin1())).enumerator(); 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 int EnumPropItem::typeByName(const QString &value) const

View File

@ -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 ((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)); if (result.isEmpty()) result+= isTranslateProperty() ? tr(propEnum.key(i)) : propEnum.key(i);
else result=result+" | "+tr(propEnum.key(i)); else result=result+" | "+ (isTranslateProperty() ? tr(propEnum.key(i)) : propEnum.key(i));
} }
} }

Binary file not shown.

View File

@ -1235,6 +1235,10 @@ p, li { white-space: pre-wrap; }
<source>Filter</source> <source>Filter</source>
<translation>Фильтр</translation> <translation>Фильтр</translation>
</message> </message>
<message>
<source>Translate properties</source>
<translation>Переводить имена свойств</translation>
</message>
</context> </context>
<context> <context>
<name>LimeReport::PDFExporter</name> <name>LimeReport::PDFExporter</name>