From d97e7e9abe2ab190da5dc4e914400fce29401e41 Mon Sep 17 00:00:00 2001 From: Arin Alex Date: Wed, 24 Jul 2024 22:44:58 +0300 Subject: [PATCH] Default item paddings have been added to report settings. --- CMakeLists.txt | 3 +- include/lrglobal.h | 19 +++++++- limereport/limereport.pro | 2 + limereport/lrbasedesignintf.h | 6 ++- limereport/lrglobal.cpp | 10 +++++ limereport/lrglobal.h | 19 +++++++- limereport/lrpagedesignintf.cpp | 1 + limereport/lrreportdesignwidget.cpp | 2 + limereport/lrreportdesignwindow.cpp | 4 +- limereport/lrreportengine.cpp | 10 +++++ limereport/lrreportengine_p.h | 5 +++ limereport/lrsettingdialog.cpp | 10 +++++ limereport/lrsettingdialog.h | 2 + limereport/lrsettingdialog.ui | 70 ++++++++++++++++++++++++----- 14 files changed, 142 insertions(+), 21 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 33f2345..e36701e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,7 @@ cmake_minimum_required(VERSION 3.14) project(limereport) +set(DEFAULT_ITEM_PADDING 0) set(LIMEREPORT_VERSION_MAJOR 1) set(LIMEREPORT_VERSION_MINOR 7) set(LIMEREPORT_VERSION_RELEASE 9) @@ -391,7 +392,7 @@ if(ENABLE_ZINT) target_link_libraries( ${PROJECT_NAME} PRIVATE QZint) endif(ENABLE_ZINT) -target_compile_definitions( ${PROJECT_NAME} PRIVATE -DHAVE_QT${QT_VERSION_MAJOR} -DHAVE_REPORT_DESIGNER -DUSE_QJSENGINE -D_CRT_SECURE_NO_WARNINGS) +target_compile_definitions( ${PROJECT_NAME} PRIVATE -DDEFAULT_ITEM_PADDING=${DEFAULT_ITEM_PADDING} -DHAVE_QT${QT_VERSION_MAJOR} -DHAVE_REPORT_DESIGNER -DUSE_QJSENGINE -D_CRT_SECURE_NO_WARNINGS) target_include_directories( ${PROJECT_NAME} PRIVATE limereport/ diff --git a/include/lrglobal.h b/include/lrglobal.h index 95f9801..ed8b86a 100644 --- a/include/lrglobal.h +++ b/include/lrglobal.h @@ -132,12 +132,27 @@ namespace Const{ class LIMEREPORT_EXPORT ReportSettings{ public: - ReportSettings():m_suppressAbsentFieldsAndVarsWarnings(false){} - void setDefaultValues(){m_suppressAbsentFieldsAndVarsWarnings = false;} +#ifdef DEFAULT_ITEM_PADDING + ReportSettings():m_suppressAbsentFieldsAndVarsWarnings(false), m_baseItemPadding(DEFAULT_ITEM_PADDING){} +#else + ReportSettings():m_suppressAbsentFieldsAndVarsWarnings(false), m_baseItemPadding(0){} +#endif + void setDefaultValues(){ + m_suppressAbsentFieldsAndVarsWarnings = false; +#ifdef DEFAULT_ITEM_PADDING + m_baseItemPadding = DEFAULT_ITEM_PADDING; +#else + m_baseItemPadding = 0; +#endif + + } bool suppressAbsentFieldsAndVarsWarnings() const; void setSuppressAbsentFieldsAndVarsWarnings(bool suppressAbsentFieldsAndVarsWarnings); + int baseItemPadding() const; + void setBaseItemPadding(int newBaseTextItemPadding); private: bool m_suppressAbsentFieldsAndVarsWarnings; + int m_baseItemPadding; }; class LIMEREPORT_EXPORT IExternalPainter{ diff --git a/limereport/limereport.pro b/limereport/limereport.pro index 90016a1..61764ae 100644 --- a/limereport/limereport.pro +++ b/limereport/limereport.pro @@ -1,3 +1,5 @@ +DEFINES += DEFAULT_ITEM_PADDING=0 + CONFIG(debug, debug|release) { TARGET = limereportd } else { diff --git a/limereport/lrbasedesignintf.h b/limereport/lrbasedesignintf.h index 1c9d828..22be951 100644 --- a/limereport/lrbasedesignintf.h +++ b/limereport/lrbasedesignintf.h @@ -295,7 +295,9 @@ public: int possibleMoveDirectionFlags() const; void setPossibleMoveFlags(int directionsFlags); - int marginSize() const {return m_margin;} + int marginSize() const { + return m_margin + m_reportSettings != 0 ? m_reportSettings->baseItemPadding() : 0; + } void setMarginSize(int value); QString itemTypeName() const; @@ -494,7 +496,7 @@ private: bool m_itemGeometryLocked; bool m_isChangingPos; bool m_isMoveable; - bool m_shadow; + bool m_shadow; signals: void geometryChanged(QObject* object, QRectF newGeometry, QRectF oldGeometry); diff --git a/limereport/lrglobal.cpp b/limereport/lrglobal.cpp index ac78588..b90f6bb 100644 --- a/limereport/lrglobal.cpp +++ b/limereport/lrglobal.cpp @@ -51,6 +51,16 @@ void ReportSettings::setSuppressAbsentFieldsAndVarsWarnings(bool suppressAbsentF m_suppressAbsentFieldsAndVarsWarnings = suppressAbsentFieldsAndVarsWarnings; } +int ReportSettings::baseItemPadding() const +{ + return m_baseItemPadding; +} + +void ReportSettings::setBaseItemPadding(int newBaseTextItemPadding) +{ + m_baseItemPadding = newBaseTextItemPadding; +} + QString escapeSimbols(const QString &value) { QString result = value; diff --git a/limereport/lrglobal.h b/limereport/lrglobal.h index 95f9801..ed8b86a 100644 --- a/limereport/lrglobal.h +++ b/limereport/lrglobal.h @@ -132,12 +132,27 @@ namespace Const{ class LIMEREPORT_EXPORT ReportSettings{ public: - ReportSettings():m_suppressAbsentFieldsAndVarsWarnings(false){} - void setDefaultValues(){m_suppressAbsentFieldsAndVarsWarnings = false;} +#ifdef DEFAULT_ITEM_PADDING + ReportSettings():m_suppressAbsentFieldsAndVarsWarnings(false), m_baseItemPadding(DEFAULT_ITEM_PADDING){} +#else + ReportSettings():m_suppressAbsentFieldsAndVarsWarnings(false), m_baseItemPadding(0){} +#endif + void setDefaultValues(){ + m_suppressAbsentFieldsAndVarsWarnings = false; +#ifdef DEFAULT_ITEM_PADDING + m_baseItemPadding = DEFAULT_ITEM_PADDING; +#else + m_baseItemPadding = 0; +#endif + + } bool suppressAbsentFieldsAndVarsWarnings() const; void setSuppressAbsentFieldsAndVarsWarnings(bool suppressAbsentFieldsAndVarsWarnings); + int baseItemPadding() const; + void setBaseItemPadding(int newBaseTextItemPadding); private: bool m_suppressAbsentFieldsAndVarsWarnings; + int m_baseItemPadding; }; class LIMEREPORT_EXPORT IExternalPainter{ diff --git a/limereport/lrpagedesignintf.cpp b/limereport/lrpagedesignintf.cpp index 383ec8d..8119bc4 100644 --- a/limereport/lrpagedesignintf.cpp +++ b/limereport/lrpagedesignintf.cpp @@ -531,6 +531,7 @@ BaseDesignIntf *PageDesignIntf::addReportItem(const QString &itemType, QPointF p PageItemDesignIntf* page = pageItem() ? pageItem() : m_currentPage; if (page){ BaseDesignIntf *reportItem = addReportItem(itemType, page, page); + reportItem->setReportSettings(m_reportSettings); reportItem->setPos(placePosOnGrid(page->mapFromScene(pos))); reportItem->setSize(placeSizeOnGrid(size)); reportItem->setUnitType(pageItem()->unitType()); diff --git a/limereport/lrreportdesignwidget.cpp b/limereport/lrreportdesignwidget.cpp index 47b1832..929a76d 100644 --- a/limereport/lrreportdesignwidget.cpp +++ b/limereport/lrreportdesignwidget.cpp @@ -801,6 +801,7 @@ void ReportDesignWidget::editSetting() setting.setHorizontalGridStep(m_horizontalGridStep); setting.setDefaultFont(m_defaultFont); setting.setSuppressAbsentFieldsAndVarsWarnings(m_report->suppressFieldAndVarError()); + setting.setBaseItemPadding(m_report->baseItemPadding()); QStringList themes; themes.append(QObject::tr("Default")); @@ -833,6 +834,7 @@ void ReportDesignWidget::editSetting() m_theme = "Default"; } m_report->setSuppressFieldAndVarError(setting.suppressAbsentFieldsAndVarsWarnings()); + m_report->setBaseItemPadding(setting.baseItemPadding()); if (m_report->currentDesignerLanguage() != setting.designerLanguage() ){ m_report->setCurrentDesignerLanguage(setting.designerLanguage()); } diff --git a/limereport/lrreportdesignwindow.cpp b/limereport/lrreportdesignwindow.cpp index ccf7a93..4564ea0 100644 --- a/limereport/lrreportdesignwindow.cpp +++ b/limereport/lrreportdesignwindow.cpp @@ -1167,9 +1167,9 @@ void ReportDesignWindow::slotSaveReportAs() void ReportDesignWindow::slotLoadReport() { - if (!checkNeedToSave()) return; // don't need to save + if (!checkNeedToSave()) return; - if (m_reportDesignWidget->emitLoadReport()) return; // report loaded via signal + if (m_reportDesignWidget->emitLoadReport()) return; QString fileName = QFileDialog::getOpenFileName( this,tr("Report file name"), diff --git a/limereport/lrreportengine.cpp b/limereport/lrreportengine.cpp index 0c00103..6e5d2b4 100644 --- a/limereport/lrreportengine.cpp +++ b/limereport/lrreportengine.cpp @@ -1174,6 +1174,16 @@ void ReportEnginePrivate::setSuppressFieldAndVarError(bool suppressFieldAndVarEr m_reportSettings.setSuppressAbsentFieldsAndVarsWarnings(suppressFieldAndVarError); } +int ReportEnginePrivate::baseItemPadding() const +{ + return m_reportSettings.baseItemPadding(); +} + +void ReportEnginePrivate::setBaseItemPadding(int baseTextItemPadding) +{ + m_reportSettings.setBaseItemPadding(baseTextItemPadding); +} + bool ReportEnginePrivate::isBusy() { return m_reportRendering; diff --git a/limereport/lrreportengine_p.h b/limereport/lrreportengine_p.h index b2ef220..6b6a04b 100644 --- a/limereport/lrreportengine_p.h +++ b/limereport/lrreportengine_p.h @@ -114,6 +114,8 @@ public: virtual void setShowProgressDialog(bool value) = 0; virtual bool isShowProgressDialog() const = 0; virtual bool isBusy() = 0; + virtual int baseItemPadding() const = 0; + virtual void setBaseItemPadding(int baseTextItemPadding) = 0; }; class PrintProcessor{ @@ -142,6 +144,7 @@ class ReportEnginePrivate : public QObject, Q_PROPERTY(QObject* datasourcesManager READ dataManager) Q_PROPERTY(QObject* scriptContext READ scriptContext) Q_PROPERTY(bool suppressFieldAndVarError READ suppressFieldAndVarError WRITE setSuppressFieldAndVarError) + Q_PROPERTY(int baseItemPadding READ baseItemPadding WRITE setBaseItemPadding) Q_PROPERTY(ATranslationProperty translation READ fakeTranslationReader) enum AppendType{MixPages, AppendPages}; @@ -221,6 +224,8 @@ public: bool suppressFieldAndVarError() const; void setSuppressFieldAndVarError(bool suppressFieldAndVarError); + int baseItemPadding() const; + void setBaseItemPadding(int baseTextItemPadding); bool isBusy(); bool resultIsEditable() const; void setResultEditable(bool value); diff --git a/limereport/lrsettingdialog.cpp b/limereport/lrsettingdialog.cpp index 6568e0e..8da15ac 100644 --- a/limereport/lrsettingdialog.cpp +++ b/limereport/lrsettingdialog.cpp @@ -73,10 +73,20 @@ QString SettingDialog::reportUnits() return ui->reportUnits->currentText(); } +int SettingDialog::baseItemPadding() +{ + return ui->neBaseItemPadding->value(); +} + void SettingDialog::setSuppressAbsentFieldsAndVarsWarnings(bool value){ ui->cbSuppressWarnings->setChecked(value); } +void SettingDialog::setBaseItemPadding(int value) +{ + ui->neBaseItemPadding->setValue(value); +} + void SettingDialog::setHorizontalGridStep(int value) { ui->horizontalGridStep->setValue(value); diff --git a/limereport/lrsettingdialog.h b/limereport/lrsettingdialog.h index b10139f..173cdcc 100644 --- a/limereport/lrsettingdialog.h +++ b/limereport/lrsettingdialog.h @@ -27,7 +27,9 @@ public: bool suppressAbsentFieldsAndVarsWarnings(); QLocale::Language designerLanguage(); QString reportUnits(); + int baseItemPadding(); void setSuppressAbsentFieldsAndVarsWarnings(bool value); + void setBaseItemPadding(int value); void setHorizontalGridStep(int value); void setVerticalGridStep(int value); void setDefaultFont(const QFont& value); diff --git a/limereport/lrsettingdialog.ui b/limereport/lrsettingdialog.ui index 6664f63..e333305 100644 --- a/limereport/lrsettingdialog.ui +++ b/limereport/lrsettingdialog.ui @@ -7,7 +7,7 @@ 0 0 521 - 445 + 506 @@ -23,15 +23,15 @@ - 0 + 2 0 0 - 503 - 301 + 499 + 339 @@ -215,8 +215,8 @@ 0 0 - 503 - 301 + 499 + 339 @@ -304,8 +304,8 @@ 0 0 - 503 - 301 + 499 + 339 @@ -319,6 +319,52 @@ + + + + + + Base Item Padding: + + + + + + + + 46 + 0 + + + + + 100 + 0 + + + + + 44 + 0 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + @@ -374,8 +420,8 @@ accept() - 221 - 307 + 485 + 493 157 @@ -390,8 +436,8 @@ reject() - 221 - 307 + 485 + 493 286