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,8 +95,6 @@ public:
}
void setPageItem(PageItemDesignIntf* pageItem);
protected:
// void mouseMoveEvent(QMouseEvent *event);
// void resizeEvent(QResizeEvent *event);
bool viewportEvent(QEvent *event);
private:
PageItemDesignIntf* m_pageItem;

View File

@ -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");

View File

@ -44,7 +44,7 @@ VariablesHolder::~VariablesHolder()
QMap<QString,VarDesc*>::iterator it = m_varNames.begin();
while(it!=m_varNames.end()){
delete *it;
it++;
++it;
}
m_varNames.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 alias="checked.png">images/check_w.png</file>
<file alias="unchecked.png">images/uncheck_w.png</file>
<file>images/settings.png</file>
</qresource>
</RCC>

View File

@ -34,6 +34,7 @@
#include <QHBoxLayout>
#include <QLineEdit>
#include <QToolButton>
#include <QMenu>
#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

View File

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

View File

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

View File

@ -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:
@ -89,6 +92,7 @@ private:
bool m_dataChanging;
bool m_subclassesAsLevel;
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)
: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<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)
{
foreach(ObjectPropItem* item,m_childItems){

View File

@ -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<QString,QString> APropIdent;

View File

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

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 (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));
}
}

Binary file not shown.

View File

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