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:
@@ -1,68 +1,77 @@
|
||||
#include "lrmarginpropitem.h"
|
||||
#include <QDoubleSpinBox>
|
||||
#include <limits>
|
||||
|
||||
#include "lrbasedesignintf.h"
|
||||
|
||||
namespace {
|
||||
LimeReport::ObjectPropItem * createMarginPropItem(
|
||||
QObject *object, LimeReport::ObjectPropItem::ObjectsList* objects, const QString& name, const QString& displayName, const QVariant& data, LimeReport::ObjectPropItem* parent, bool readonly)
|
||||
{
|
||||
return new LimeReport::MarginPropItem(object, objects, name, displayName, data, parent, readonly);
|
||||
}
|
||||
bool VARIABLE_IS_NOT_USED registredTopMargin = LimeReport::ObjectPropFactory::instance().registerCreator(
|
||||
LimeReport::APropIdent("topMargin","LimeReport::PageItemDesignIntf"),
|
||||
QObject::tr("margin"),createMarginPropItem
|
||||
);
|
||||
bool VARIABLE_IS_NOT_USED registredRightMargin = LimeReport::ObjectPropFactory::instance().registerCreator(
|
||||
LimeReport::APropIdent("rightMargin","LimeReport::PageItemDesignIntf"),
|
||||
QObject::tr("margin"),createMarginPropItem
|
||||
);
|
||||
bool VARIABLE_IS_NOT_USED registredBottomMargin = LimeReport::ObjectPropFactory::instance().registerCreator(
|
||||
LimeReport::APropIdent("bottomMargin","LimeReport::PageItemDesignIntf"),
|
||||
QObject::tr("margin"),createMarginPropItem
|
||||
);
|
||||
bool VARIABLE_IS_NOT_USED registredLeftMargin = LimeReport::ObjectPropFactory::instance().registerCreator(
|
||||
LimeReport::APropIdent("leftMargin","LimeReport::PageItemDesignIntf"),
|
||||
QObject::tr("margin"),createMarginPropItem
|
||||
);
|
||||
#include <QDoubleSpinBox>
|
||||
|
||||
#include <limits>
|
||||
|
||||
namespace {
|
||||
LimeReport::ObjectPropItem* createMarginPropItem(QObject* object,
|
||||
LimeReport::ObjectPropItem::ObjectsList* objects,
|
||||
const QString& name, const QString& displayName,
|
||||
const QVariant& data,
|
||||
LimeReport::ObjectPropItem* parent, bool readonly)
|
||||
{
|
||||
return new LimeReport::MarginPropItem(object, objects, name, displayName, data, parent,
|
||||
readonly);
|
||||
}
|
||||
bool VARIABLE_IS_NOT_USED registredTopMargin
|
||||
= LimeReport::ObjectPropFactory::instance().registerCreator(
|
||||
LimeReport::APropIdent("topMargin", "LimeReport::PageItemDesignIntf"),
|
||||
QObject::tr("margin"), createMarginPropItem);
|
||||
bool VARIABLE_IS_NOT_USED registredRightMargin
|
||||
= LimeReport::ObjectPropFactory::instance().registerCreator(
|
||||
LimeReport::APropIdent("rightMargin", "LimeReport::PageItemDesignIntf"),
|
||||
QObject::tr("margin"), createMarginPropItem);
|
||||
bool VARIABLE_IS_NOT_USED registredBottomMargin
|
||||
= LimeReport::ObjectPropFactory::instance().registerCreator(
|
||||
LimeReport::APropIdent("bottomMargin", "LimeReport::PageItemDesignIntf"),
|
||||
QObject::tr("margin"), createMarginPropItem);
|
||||
bool VARIABLE_IS_NOT_USED registredLeftMargin
|
||||
= LimeReport::ObjectPropFactory::instance().registerCreator(
|
||||
LimeReport::APropIdent("leftMargin", "LimeReport::PageItemDesignIntf"),
|
||||
QObject::tr("margin"), createMarginPropItem);
|
||||
} // namespace
|
||||
|
||||
namespace LimeReport{
|
||||
|
||||
namespace LimeReport {
|
||||
|
||||
QString MarginPropItem::displayValue() const
|
||||
{
|
||||
LimeReport::BaseDesignIntf * item = dynamic_cast<LimeReport::BaseDesignIntf*>(object());
|
||||
LimeReport::BaseDesignIntf* item = dynamic_cast<LimeReport::BaseDesignIntf*>(object());
|
||||
switch (item->unitType()) {
|
||||
case LimeReport::BaseDesignIntf::Millimeters:
|
||||
|
||||
return QString("%1 %2").arg(propertyValue().toDouble(), 0, 'f', 2)
|
||||
.arg(QObject::tr("mm"));
|
||||
return QString("%1 %2").arg(propertyValue().toDouble(), 0, 'f', 2).arg(QObject::tr("mm"));
|
||||
case LimeReport::BaseDesignIntf::Inches:
|
||||
return QString("%1 %2").arg((propertyValue().toDouble() * Const::mmFACTOR) / (item->unitFactor() * 10), 0, 'f', 2)
|
||||
.arg(QObject::tr("''"));
|
||||
return QString("%1 %2")
|
||||
.arg((propertyValue().toDouble() * Const::mmFACTOR) / (item->unitFactor() * 10), 0, 'f',
|
||||
2)
|
||||
.arg(QObject::tr("''"));
|
||||
}
|
||||
return QString();
|
||||
}
|
||||
|
||||
QWidget *MarginPropItem::createProperyEditor(QWidget *parent) const
|
||||
QWidget* MarginPropItem::createProperyEditor(QWidget* parent) const
|
||||
{
|
||||
QDoubleSpinBox *editor= new QDoubleSpinBox(parent);
|
||||
QDoubleSpinBox* editor = new QDoubleSpinBox(parent);
|
||||
editor->setMaximum(std::numeric_limits<qreal>::max());
|
||||
editor->setMinimum(std::numeric_limits<qreal>::max()*-1);
|
||||
editor->setSuffix(" "+unitShortName());
|
||||
editor->setMinimum(std::numeric_limits<qreal>::max() * -1);
|
||||
editor->setSuffix(" " + unitShortName());
|
||||
return editor;
|
||||
}
|
||||
|
||||
void MarginPropItem::setPropertyEditorData(QWidget *propertyEditor, const QModelIndex &) const
|
||||
void MarginPropItem::setPropertyEditorData(QWidget* propertyEditor, const QModelIndex&) const
|
||||
{
|
||||
QDoubleSpinBox *editor =qobject_cast<QDoubleSpinBox*>(propertyEditor);
|
||||
QDoubleSpinBox* editor = qobject_cast<QDoubleSpinBox*>(propertyEditor);
|
||||
editor->setValue(valueInUnits(propertyValue().toReal()));
|
||||
}
|
||||
|
||||
void MarginPropItem::setModelData(QWidget *propertyEditor, QAbstractItemModel *model, const QModelIndex &index)
|
||||
void MarginPropItem::setModelData(QWidget* propertyEditor, QAbstractItemModel* model,
|
||||
const QModelIndex& index)
|
||||
{
|
||||
model->setData(index, valueInReportUnits(qobject_cast<QDoubleSpinBox*>(propertyEditor)->value()));
|
||||
model->setData(index,
|
||||
valueInReportUnits(qobject_cast<QDoubleSpinBox*>(propertyEditor)->value()));
|
||||
setValueToObject(propertyName(), propertyValue());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user