0
0
mirror of https://github.com/fralx/LimeReport.git synced 2025-11-25 08:28:06 +03:00

Define code style and format all source file using clang-format-14

except those placed in 3rdparty directories.
This commit is contained in:
Андрей Лухнов
2024-09-04 17:31:16 +03:00
parent c5b9ac265d
commit 0fca7169d3
285 changed files with 19120 additions and 17875 deletions

View File

@@ -28,35 +28,43 @@
* GNU General Public License for more details. *
****************************************************************************/
#include "lrenumpropitem.h"
#include "../editors/lrcomboboxeditor.h"
#include "lrbanddesignintf.h"
namespace {
LimeReport::ObjectPropItem * createEnumPropItem(
QObject *object, LimeReport::ObjectPropItem::ObjectsList* objects, const QString& name, const QString& displayName, const QVariant& data, LimeReport::ObjectPropItem* parent, bool readonly)
LimeReport::ObjectPropItem* createEnumPropItem(QObject* object,
LimeReport::ObjectPropItem::ObjectsList* objects,
const QString& name, const QString& displayName,
const QVariant& data,
LimeReport::ObjectPropItem* parent, bool readonly)
{
return new LimeReport::EnumPropItem(object, objects, name, displayName, data, parent, readonly);
}
bool VARIABLE_IS_NOT_USED registred = LimeReport::ObjectPropFactory::instance().registerCreator(
LimeReport::APropIdent("enum",""),QObject::tr("enum"),createEnumPropItem
);
LimeReport::APropIdent("enum", ""), QObject::tr("enum"), createEnumPropItem);
}
} // namespace
namespace LimeReport {
QWidget *EnumPropItem::createProperyEditor(QWidget *parent) const
QWidget* EnumPropItem::createProperyEditor(QWidget* parent) const
{
ComboBoxEditor *editor = new ComboBoxEditor(parent,false);
connect(editor,SIGNAL(currentIndexChanged(QString)),this,SLOT(slotEnumChanged(QString)));
ComboBoxEditor* editor = new ComboBoxEditor(parent, false);
connect(editor, SIGNAL(currentIndexChanged(QString)), this, SLOT(slotEnumChanged(QString)));
QStringList enumValues;
QMetaEnum propEnum = object()->metaObject()->property(object()->metaObject()->indexOfProperty(propertyName().toLatin1())).enumerator();
for (int i=0;i<propEnum.keyCount();i++){
if (m_acceptableValues.isEmpty()) enumValues.append(tr(propEnum.key(i)));
QMetaEnum propEnum
= object()
->metaObject()
->property(object()->metaObject()->indexOfProperty(propertyName().toLatin1()))
.enumerator();
for (int i = 0; i < propEnum.keyCount(); i++) {
if (m_acceptableValues.isEmpty())
enumValues.append(tr(propEnum.key(i)));
else {
if (m_acceptableValues.contains(propEnum.value(i))){
if (m_acceptableValues.contains(propEnum.value(i))) {
enumValues.append(tr(propEnum.key(i)));
}
}
@@ -65,20 +73,24 @@ QWidget *EnumPropItem::createProperyEditor(QWidget *parent) const
return editor;
}
void EnumPropItem::slotEnumChanged(const QString &text)
void EnumPropItem::slotEnumChanged(const QString& text)
{
if ( nameByType(object()->property(propertyName().toLatin1()).toInt())!=text){
if (nameByType(object()->property(propertyName().toLatin1()).toInt()) != text) {
beginChangeValue();
setPropertyValue(typeByName(text));
setValueToObject(propertyName(),typeByName(text));
setValueToObject(propertyName(), typeByName(text));
endChangeValue();
}
}
void EnumPropItem::initTranslation()
{
QMetaEnum propEnum = object()->metaObject()->property(object()->metaObject()->indexOfProperty(propertyName().toLatin1())).enumerator();
for (int i=0;i<propEnum.keyCount();i++){
QMetaEnum propEnum
= object()
->metaObject()
->property(object()->metaObject()->indexOfProperty(propertyName().toLatin1()))
.enumerator();
for (int i = 0; i < propEnum.keyCount(); i++) {
m_translation.insert(QString(tr(propEnum.key(i))), QString(propEnum.key(i)));
}
}
@@ -168,36 +180,42 @@ void EnumPropItem::translateEnumItemName()
tr("DashDotLine");
tr("DashDotDotLine");
tr("CustomDashLine");
}
void EnumPropItem::setPropertyEditorData(QWidget *propertyEditor, const QModelIndex &) const
void EnumPropItem::setPropertyEditorData(QWidget* propertyEditor, const QModelIndex&) const
{
ComboBoxEditor *editor=qobject_cast<ComboBoxEditor *>(propertyEditor);
ComboBoxEditor* editor = qobject_cast<ComboBoxEditor*>(propertyEditor);
editor->setTextValue(nameByType(propertyValue().toInt()));
}
void EnumPropItem::setModelData(QWidget *propertyEditor, QAbstractItemModel *model, const QModelIndex &index)
void EnumPropItem::setModelData(QWidget* propertyEditor, QAbstractItemModel* model,
const QModelIndex& index)
{
setValueToObject(propertyName(),typeByName(qobject_cast<ComboBoxEditor*>(propertyEditor)->text()));
model->setData(index,object()->property(propertyName().toLatin1()));
setValueToObject(propertyName(),
typeByName(qobject_cast<ComboBoxEditor*>(propertyEditor)->text()));
model->setData(index, object()->property(propertyName().toLatin1()));
}
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 isTranslateProperty() ? tr(propEnum.valueToKey(value)) : propEnum.valueToKey(value);
}
int EnumPropItem::typeByName(const QString &value) const
int EnumPropItem::typeByName(const QString& 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 propEnum.keyToValue(m_translation.value(value).toLatin1());
}
QString EnumPropItem::displayValue() const
{
return nameByType((propertyValue().toInt()));
}
QString EnumPropItem::displayValue() const { return nameByType((propertyValue().toInt())); }
}
} // namespace LimeReport