0
0
mirror of https://github.com/fralx/LimeReport.git synced 2025-01-11 17:18:10 +03:00
LimeReport/limereport/objectinspector/propertyItems/lrsvgpropitem.cpp
Андрей Лухнов 0fca7169d3 Define code style and format all source file using clang-format-14
except those placed in 3rdparty directories.
2024-09-19 21:09:38 +03:00

48 lines
1.7 KiB
C++

#include "lrsvgpropitem.h"
#include "editors/lrsvgeditor.h"
namespace {
LimeReport::ObjectPropItem* createSvgPropItem(QObject* object,
LimeReport::ObjectPropItem::ObjectsList* objects,
const QString& name, const QString& displayName,
const QVariant& data,
LimeReport::ObjectPropItem* parent, bool readonly)
{
return new LimeReport::SvgPropItem(object, objects, name, displayName, data, parent, readonly);
}
bool VARIABLE_IS_NOT_USED registredImageProp
= LimeReport::ObjectPropFactory::instance().registerCreator(
LimeReport::APropIdent("image", "LimeReport::SVGItem"), QObject::tr("image"),
createSvgPropItem);
} // namespace
namespace LimeReport {
QWidget* SvgPropItem::createProperyEditor(QWidget* parent) const { return new SvgEditor(parent); }
QString SvgPropItem::displayValue() const
{
return (propertyValue().isNull()) ? "" : QObject::tr("image");
}
void SvgPropItem::setPropertyEditorData(QWidget* propertyEditor, const QModelIndex&) const
{
SvgEditor* editor = qobject_cast<SvgEditor*>(propertyEditor);
editor->setImage(propertyValue().value<QByteArray>());
}
void SvgPropItem::setModelData(QWidget* propertyEditor, QAbstractItemModel* model,
const QModelIndex& index)
{
model->setData(index, qobject_cast<SvgEditor*>(propertyEditor)->image());
object()->setProperty(propertyName().toLatin1(), propertyValue());
}
QIcon SvgPropItem::iconValue() const
{
return QIcon(QPixmap::fromImage(propertyValue().value<QImage>()));
}
} // namespace LimeReport