diff --git a/.travis.yml b/.travis.yml index 39dedbc..f879261 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,27 +1,548 @@ -language: cpp +matrix: + include: + - env: Qt4.8.5_Ubuntu_14.04 + os: linux + dist: trusty + language: cpp + compiler: gcc + cache: ccache + addons: + apt: + packages: + - qt4-default + + script: + - qmake -r limereport.pro + - make + - make check -compiler: - - gcc + - env: Qt4.8.5_Ubuntu_14.04 + os: linux + dist: trusty + language: cpp + compiler: clang + cache: ccache + addons: + apt: + packages: + - qt4-default + + script: + - qmake -r limereport.pro + - make + - make check + + - env: Qt5.1.1_Ubuntu_14.04 + os: linux + dist: trusty + language: cpp + compiler: gcc + cache: ccache + addons: + apt: + sources: + - sourceline: 'ppa:beineri/opt-qt511-trusty' + packages: + - qt51base + - qt51script + - qt51tools + + script: + - source /opt/qt51/bin/qt51-env.sh + - /opt/qt51/bin/qmake -r limereport.pro + - make + - make check + + - env: Qt5.1.1_Ubuntu_14.04 + os: linux + dist: trusty + language: cpp + compiler: clang + cache: ccache + addons: + apt: + sources: + - sourceline: 'ppa:beineri/opt-qt511-trusty' + packages: + - qt51base + - qt51script + - qt51tools + + script: + - source /opt/qt51/bin/qt51-env.sh + - /opt/qt51/bin/qmake -r limereport.pro + - make + - make check -sudo: required -dist: trusty + - env: Qt5.2.1_Ubuntu_14.04 + os: linux + dist: trusty + language: cpp + compiler: gcc + cache: ccache + addons: + apt: + sources: + - sourceline: 'ppa:beineri/opt-qt521-trusty' + packages: + - qt52base + - qt52script + - qt52tools + + script: + - source /opt/qt52/bin/qt52-env.sh + - /opt/qt52/bin/qmake -r limereport.pro + - make + - make check -env: - - QT_BASE=56 + - env: Qt5.2.1_Ubuntu_14.04 + os: linux + dist: trusty + language: cpp + compiler: clang + cache: ccache + addons: + apt: + sources: + - sourceline: 'ppa:beineri/opt-qt521-trusty' + packages: + - qt52base + - qt52script + - qt52tools + + script: + - source /opt/qt52/bin/qt52-env.sh + - /opt/qt52/bin/qmake -r limereport.pro + - make + - make check + + - env: Qt5.3.2_Ubuntu_14.04 + os: linux + dist: trusty + language: cpp + compiler: gcc + cache: ccache + addons: + apt: + sources: + - sourceline: 'ppa:beineri/opt-qt532-trusty' + packages: + - qt53base + - qt53script + - qt53tools + + script: + - source /opt/qt53/bin/qt53-env.sh + - /opt/qt53/bin/qmake -r limereport.pro + - make + - make check -before_install: - - if [ "$QT_BASE" = "56" ]; then sudo add-apt-repository ppa:beineri/opt-qt562-trusty -y; fi - - sudo apt-get update -qq + - env: Qt5.3.2_Ubuntu_14.04 + os: linux + dist: trusty + language: cpp + compiler: clang + cache: ccache + addons: + apt: + sources: + - sourceline: 'ppa:beineri/opt-qt532-trusty' + packages: + - qt53base + - qt53script + - qt53tools + + script: + - source /opt/qt53/bin/qt53-env.sh + - /opt/qt53/bin/qmake -r limereport.pro + - make + - make check + + - env: Qt5.4.2_Ubuntu_14.04 + os: linux + dist: trusty + language: cpp + compiler: gcc + cache: ccache + addons: + apt: + sources: + - sourceline: 'ppa:beineri/opt-qt542-trusty' + packages: + - qt54base + - qt54script + - qt54tools + + script: + - source /opt/qt54/bin/qt54-env.sh + - /opt/qt54/bin/qmake -r limereport.pro + - make + - make check -install: - - if [ "$QT_BASE" = "56" ]; then sudo apt-get install -qq qt56base qt56script qt56tools ; source /opt/qt56/bin/qt56-env.sh; fi - + - env: Qt5.4.2_Ubuntu_14.04 + os: linux + dist: trusty + language: cpp + compiler: clang + cache: ccache + addons: + apt: + sources: + - sourceline: 'ppa:beineri/opt-qt542-trusty' + packages: + - qt54base + - qt54script + - qt54tools + + script: + - source /opt/qt54/bin/qt54-env.sh + - /opt/qt54/bin/qmake -r limereport.pro + - make + - make check + + - env: Qt5.5.1_Ubuntu_14.04 + os: linux + dist: trusty + language: cpp + compiler: gcc + cache: ccache + addons: + apt: + sources: + - sourceline: 'ppa:beineri/opt-qt551-trusty' + packages: + - qt55base + - qt55script + - qt55tools + + script: + - source /opt/qt55/bin/qt55-env.sh + - /opt/qt55/bin/qmake -r limereport.pro + - make + - make check -script: - - qmake -r limereport.pro - - make - - make check + - env: Qt5.5.1_Ubuntu_14.04 + os: linux + dist: trusty + language: cpp + compiler: clang + cache: ccache + addons: + apt: + sources: + - sourceline: 'ppa:beineri/opt-qt551-trusty' + packages: + - qt55base + - qt55script + - qt55tools + + script: + - source /opt/qt55/bin/qt55-env.sh + - /opt/qt55/bin/qmake -r limereport.pro + - make + - make check + + - env: Qt5.6.3_Ubuntu_14.04 + os: linux + dist: trusty + language: cpp + compiler: gcc + cache: ccache + addons: + apt: + sources: + - sourceline: 'ppa:beineri/opt-qt563-trusty' + packages: + - qt56base + - qt56script + - qt56tools + + script: + - source /opt/qt56/bin/qt56-env.sh + - /opt/qt56/bin/qmake -r limereport.pro + - make + - make check + - env: Qt5.6.3_Ubuntu_14.04 + os: linux + dist: trusty + language: cpp + compiler: clang + cache: ccache + addons: + apt: + sources: + - sourceline: 'ppa:beineri/opt-qt563-trusty' + packages: + - qt56base + - qt56script + - qt56tools + + script: + - source /opt/qt56/bin/qt56-env.sh + - /opt/qt56/bin/qmake -r limereport.pro + - make + - make check + + - env: Qt5.7.1_Ubuntu_14.04 + os: linux + dist: trusty + language: cpp + compiler: gcc + cache: ccache + addons: + apt: + sources: + - sourceline: 'ppa:beineri/opt-qt571-trusty' + packages: + - qt57base + - qt57script + - qt57tools + + script: + - source /opt/qt57/bin/qt57-env.sh + - /opt/qt57/bin/qmake -r limereport.pro + - make + - make check + + - env: Qt5.7.1_Ubuntu_14.04 + os: linux + dist: trusty + language: cpp + compiler: clang + cache: ccache + addons: + apt: + sources: + - sourceline: 'ppa:beineri/opt-qt571-trusty' + packages: + - qt57base + - qt57script + - qt57tools + + script: + - source /opt/qt57/bin/qt57-env.sh + - /opt/qt57/bin/qmake -r limereport.pro + - make + - make check + + - env: Qt5.8.0_Ubuntu_14.04 + os: linux + dist: trusty + language: cpp + compiler: gcc + cache: ccache + addons: + apt: + sources: + - sourceline: 'ppa:beineri/opt-qt58-trusty' + packages: + - qt58base + - qt58script + - qt58tools + + script: + - source /opt/qt58/bin/qt58-env.sh + - /opt/qt58/bin/qmake -r limereport.pro + - make + - make check + + - env: Qt5.8.0_Ubuntu_14.04 + os: linux + dist: trusty + language: cpp + compiler: clang + cache: ccache + addons: + apt: + sources: + - sourceline: 'ppa:beineri/opt-qt58-trusty' + packages: + - qt58base + - qt58script + - qt58tools + + script: + - source /opt/qt58/bin/qt58-env.sh + - /opt/qt58/bin/qmake -r limereport.pro + - make + - make check + + - env: Qt5.9.7_Ubuntu_14.04 + os: linux + dist: trusty + language: cpp + compiler: gcc + cache: ccache + addons: + apt: + sources: + - sourceline: 'ppa:beineri/opt-qt597-trusty' + packages: + - qt59base + - qt59script + - qt59tools + + script: + - source /opt/qt59/bin/qt59-env.sh + - /opt/qt59/bin/qmake -r limereport.pro + - make + - make check + + - env: Qt5.9.7_Ubuntu_14.04 + os: linux + dist: trusty + language: cpp + compiler: clang + cache: ccache + addons: + apt: + sources: + - sourceline: 'ppa:beineri/opt-qt597-trusty' + packages: + - qt59base + - qt59script + - qt59tools + + script: + - source /opt/qt59/bin/qt59-env.sh + - /opt/qt59/bin/qmake -r limereport.pro + - make + - make check + + - env: Qt5.10.1_Ubuntu_14.04 + os: linux + dist: trusty + language: cpp + compiler: gcc + cache: ccache + addons: + apt: + sources: + - sourceline: 'ppa:beineri/opt-qt-5.10.1-trusty' + packages: + - qt510base + - qt510script + - qt510tools + + script: + - source /opt/qt510/bin/qt510-env.sh + - /opt/qt510/bin/qmake -r limereport.pro + - make + - make check + + - env: Qt5.10.1_Ubuntu_14.04 + os: linux + dist: trusty + language: cpp + compiler: clang + cache: ccache + addons: + apt: + sources: + - sourceline: 'ppa:beineri/opt-qt-5.10.1-trusty' + packages: + - qt510base + - qt510script + - qt510tools + + script: + - source /opt/qt510/bin/qt510-env.sh + - /opt/qt510/bin/qmake -r limereport.pro + - make + - make check + + - env: Qt5.11.3_Ubuntu_18.04 + os: linux + dist: bionic + language: cpp + compiler: gcc + cache: ccache + addons: + apt: + sources: + - sourceline: 'ppa:beineri/opt-qt-5.11.3-bionic' + packages: + - qt511base + - qt511script + - qt511tools + - mesa-common-dev + - libgl1-mesa-dev + + script: + - source /opt/qt511/bin/qt511-env.sh + - /opt/qt511/bin/qmake -r limereport.pro + - make + - make check + + - env: Qt5.11.3_Ubuntu_18.04 + os: linux + dist: bionic + language: cpp + compiler: clang + cache: ccache + addons: + apt: + sources: + - sourceline: 'ppa:beineri/opt-qt-5.11.3-bionic' + packages: + - qt511base + - qt511script + - qt511tools + - mesa-common-dev + - libgl1-mesa-dev + + script: + - source /opt/qt511/bin/qt511-env.sh + - /opt/qt511/bin/qmake -r limereport.pro + - make + - make check + + - env: Qt5.12.3_Ubuntu_18.04 + os: linux + dist: bionic + language: cpp + compiler: gcc + cache: ccache + addons: + apt: + sources: + - sourceline: 'ppa:beineri/opt-qt-5.12.3-bionic' + packages: + - qt512base + - qt512script + - qt512tools + - mesa-common-dev + - libgl1-mesa-dev + + script: + - source /opt/qt512/bin/qt512-env.sh + - /opt/qt512/bin/qmake -r limereport.pro + - make + - make check + + - env: Qt5.12.3_Ubuntu_18.04 + os: linux + dist: bionic + language: cpp + compiler: clang + cache: ccache + addons: + apt: + sources: + - sourceline: 'ppa:beineri/opt-qt-5.12.3-bionic' + packages: + - qt512base + - qt512script + - qt512tools + - mesa-common-dev + - libgl1-mesa-dev + + script: + - source /opt/qt512/bin/qt512-env.sh + - /opt/qt512/bin/qmake -r limereport.pro + - make + - make check + notifications: - email: false - + email: false \ No newline at end of file diff --git a/3rdparty/zint-2.6.1/backend_qt/backend_qt.pro b/3rdparty/zint-2.6.1/backend_qt/backend_qt.pro index 63eadfd..2af6b7d 100644 --- a/3rdparty/zint-2.6.1/backend_qt/backend_qt.pro +++ b/3rdparty/zint-2.6.1/backend_qt/backend_qt.pro @@ -66,7 +66,8 @@ HEADERS += $$PWD/../backend/aztec.h \ $$PWD/../backend/sjis.h \ $$PWD/../backend/stdint_msvc.h \ $$PWD/../backend/zint.h \ - $$PWD/qzint.h + $$PWD/qzint.h \ + $$PWD/qzint_global.h SOURCES += $$PWD/../backend/2of5.c \ $$PWD/../backend/auspost.c \ diff --git a/3rdparty/zint-2.6.1/backend_qt/qzint_global.h b/3rdparty/zint-2.6.1/backend_qt/qzint_global.h index 025b16e..ea46fe2 100644 --- a/3rdparty/zint-2.6.1/backend_qt/qzint_global.h +++ b/3rdparty/zint-2.6.1/backend_qt/qzint_global.h @@ -3,10 +3,14 @@ #include +#ifdef HAVE_STATIC_BUILD +# define QZINTSHARED_EXPORT /**/ +#else #if defined(QZINT_LIBRARY) # define QZINTSHARED_EXPORT Q_DECL_EXPORT #else # define QZINTSHARED_EXPORT Q_DECL_IMPORT #endif +#endif #endif // QZINT_GLOBAL_H diff --git a/README.md b/README.md index b1eafc3..aedcaa1 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,11 @@ + # LimeReport v1.5.0 [![Build Status](https://api.travis-ci.org/fralx/LimeReport.svg?branch=master)](https://travis-ci.org/fralx/LimeReport) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/bc31412ea4814f30825b5ed3723e9a70)](https://app.codacy.com/app/fralx/LimeReport?utm_source=github.com&utm_medium=referral&utm_content=fralx/LimeReport&utm_campaign=Badge_Grade_Dashboard) ## Official LimeReport web site [http://limereport.ru](http://limereport.ru) -### Features +## Donation [![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.me/arinalex) + +## Features * Multi-platform support * Pure Qt4/Qt5 compatible code diff --git a/common.pri b/common.pri index 367a666..7913e8e 100644 --- a/common.pri +++ b/common.pri @@ -127,7 +127,7 @@ RCC_DIR = $${ARCH_DIR}/$${BUILD_TYPE}/rcc LIMEREPORT_VERSION_MAJOR = 1 LIMEREPORT_VERSION_MINOR = 5 -LIMEREPORT_VERSION_RELEASE = 4 +LIMEREPORT_VERSION_RELEASE = 13 LIMEREPORT_VERSION = '$${LIMEREPORT_VERSION_MAJOR}.$${LIMEREPORT_VERSION_MINOR}.$${LIMEREPORT_VERSION_RELEASE}' DEFINES *= LIMEREPORT_VERSION_STR=\\\"$${LIMEREPORT_VERSION}\\\" diff --git a/include/lrglobal.h b/include/lrglobal.h index b0b462f..5541a1b 100644 --- a/include/lrglobal.h +++ b/include/lrglobal.h @@ -92,6 +92,10 @@ namespace Const{ const QString EOW("~!@#$%^&*()+{}|:\"<>?,/;'[]\\-="); const int DEFAULT_TAB_INDENTION = 4; const int DOCKWIDGET_MARGINS = 4; + + const char SCRIPT_SIGN = 'S'; + const char FIELD_SIGN = 'D'; + const char VARIABLE_SIGN = 'V'; } QString extractClassName(QString className); QString escapeSimbols(const QString& value); diff --git a/limereport.pro b/limereport.pro index 9e33bcc..9bc801f 100644 --- a/limereport.pro +++ b/limereport.pro @@ -16,9 +16,14 @@ SUBDIRS += \ limereport \ demo_r1 \ demo_r2 \ - console \ designer +greaterThan(QT_MAJOR_VERSION, 4){ +greaterThan(QT_MINOR_VERSION, 1){ + SUBDIRS += console + } +} + !contains(CONFIG, embedded_designer){ !contains(CONFIG, static_build){ SUBDIRS += designer_plugin diff --git a/limereport/exporters/lrpdfexporter.h b/limereport/exporters/lrpdfexporter.h index 225c80b..d758ff1 100644 --- a/limereport/exporters/lrpdfexporter.h +++ b/limereport/exporters/lrpdfexporter.h @@ -11,7 +11,7 @@ class PDFExporter : public QObject, public ReportExporterInterface { Q_OBJECT public: - explicit PDFExporter(ReportEnginePrivate *parent = nullptr); + explicit PDFExporter(ReportEnginePrivate *parent = NULL); // ReportExporterInterface interface bool exportPages(ReportPages pages, const QString &fileName, const QMap ¶ms); QString exporterName() diff --git a/limereport/items/lrabstractlayout.h b/limereport/items/lrabstractlayout.h index 1324ff7..07a1d9f 100644 --- a/limereport/items/lrabstractlayout.h +++ b/limereport/items/lrabstractlayout.h @@ -34,7 +34,7 @@ public: int childrenCount(); int layoutSpacing() const; void setLayoutSpacing(int layoutSpacing); - qreal layoutSpacingMM(){ return m_layoutSpacing * unitFactor();} + qreal layoutSpacingMM(){ return m_layoutSpacing * Const::mmFACTOR;} protected: void beforeDelete(); void childAddedEvent(BaseDesignIntf *child); diff --git a/limereport/items/lrimageitem.cpp b/limereport/items/lrimageitem.cpp index c3fce2f..76542d3 100644 --- a/limereport/items/lrimageitem.cpp +++ b/limereport/items/lrimageitem.cpp @@ -32,6 +32,7 @@ #include "lrglobal.h" #include "lrdatasourcemanager.h" #include "lrpagedesignintf.h" +#include "lrimageitemeditor.h" namespace{ @@ -83,9 +84,15 @@ void ImageItem::loadPictureFromVariant(QVariant& data){ void ImageItem::preparePopUpMenu(QMenu &menu) { + QAction* editAction = menu.addAction(QIcon(":/report/images/edit_pecil2.png"),tr("Edit")); + menu.insertAction(menu.actions().at(0),editAction); + menu.insertSeparator(menu.actions().at(1)); + + menu.addSeparator(); QAction* action = menu.addAction(tr("Watermark")); action->setCheckable(true); action->setChecked(isWatermark()); + } void ImageItem::processPopUpAction(QAction *action) @@ -93,9 +100,26 @@ void ImageItem::processPopUpAction(QAction *action) if (action->text().compare(tr("Watermark")) == 0){ page()->setPropertyToSelectedItems("watermark",action->isChecked()); } + if (action->text().compare(tr("Edit")) == 0){ + this->showEditorDialog(); + } ItemDesignIntf::processPopUpAction(action); } +QImage getFileByResourcePath(QString resourcePath){ + QFileInfo resourceFile(resourcePath); + if (resourceFile.exists()) + return QImage(resourcePath); + return QImage(); +} + +QImage ImageItem::drawImage() +{ + if (image().isNull()) + return getFileByResourcePath(m_resourcePath); + return image(); +} + bool ImageItem::useExternalPainter() const { return m_useExternalPainter; @@ -110,6 +134,13 @@ void ImageItem::setUseExternalPainter(bool value) } } +QWidget *ImageItem::defaultEditor() +{ + ImageItemEditor* editor = new ImageItemEditor(this); + editor->setAttribute(Qt::WA_DeleteOnClose); + return editor; +} + void ImageItem::updateItemSize(DataSourceManager* dataManager, RenderPass pass, int maxHeight) { @@ -220,8 +251,8 @@ void ImageItem::setAutoSize(bool autoSize) if (m_autoSize != autoSize){ m_autoSize = autoSize; if (m_autoSize && !m_picture.isNull()){ - setWidth(image().width()); - setHeight(image().height()); + setWidth(drawImage().width()); + setHeight(drawImage().height()); setPossibleResizeDirectionFlags(Fixed); } else { setPossibleResizeDirectionFlags(AllDirections); @@ -271,10 +302,10 @@ void ImageItem::paint(QPainter *ppainter, const QStyleOptionGraphicsItem *option QPointF point = rect().topLeft(); QImage img; - if (m_scale && !image().isNull()){ - img = image().scaled(rect().width(), rect().height(), keepAspectRatio() ? Qt::KeepAspectRatio : Qt::IgnoreAspectRatio, Qt::SmoothTransformation); + if (m_scale && !drawImage().isNull()){ + img = drawImage().scaled(rect().width(), rect().height(), keepAspectRatio() ? Qt::KeepAspectRatio : Qt::IgnoreAspectRatio, Qt::SmoothTransformation); } else { - img = image(); + img = drawImage(); } qreal shiftHeight = rect().height() - img.height(); @@ -328,9 +359,9 @@ void ImageItem::paint(QPainter *ppainter, const QStyleOptionGraphicsItem *option void ImageItem::setImage(QImage value) { - if (m_picture!=value){ + if (m_picture != value){ QImage oldValue = m_picture; - m_picture=value; + m_picture = value; if (m_autoSize){ setWidth(m_picture.width()); setHeight(m_picture.height()); @@ -340,6 +371,19 @@ void ImageItem::setImage(QImage value) } } +QImage ImageItem::image(){ + return m_picture; +} + +void ImageItem::setResourcePath(const QString &value){ + if (m_resourcePath != value){ + QString oldValue = m_resourcePath; + m_resourcePath = value; + update(); + notify("resourcePath", oldValue, value); + } +} + ImageItem::Format ImageItem::format() const { return m_format; diff --git a/limereport/items/lrimageitem.h b/limereport/items/lrimageitem.h index 5d474e2..587d39d 100644 --- a/limereport/items/lrimageitem.h +++ b/limereport/items/lrimageitem.h @@ -61,8 +61,8 @@ public: ImageItem(QObject *owner, QGraphicsItem *parent); virtual void paint(QPainter *ppainter, const QStyleOptionGraphicsItem *option, QWidget *widget); void setImage(QImage value); - QImage image(){return m_picture;} - void setResourcePath(const QString &value){m_resourcePath=value;} + QImage image(); + void setResourcePath(const QString &value); QString resourcePath() const; QString datasource() const; void setDatasource(const QString &datasource); @@ -89,6 +89,7 @@ public: bool useExternalPainter() const; void setUseExternalPainter(bool value); + QWidget* defaultEditor(); protected: BaseDesignIntf* createSameTypeItem(QObject *owner, QGraphicsItem *parent); void updateItemSize(DataSourceManager *dataManager, RenderPass pass, int maxHeight); @@ -97,6 +98,7 @@ protected: void loadPictureFromVariant(QVariant& data); void preparePopUpMenu(QMenu &menu); void processPopUpAction(QAction *action); + QImage drawImage(); private: QImage m_picture; bool m_useExternalPainter; @@ -109,8 +111,7 @@ private: bool m_keepAspectRatio; bool m_center; Format m_format; - QString m_variable; - + QString m_variable; }; } diff --git a/limereport/items/lrimageitemeditor.cpp b/limereport/items/lrimageitemeditor.cpp new file mode 100644 index 0000000..9e34df9 --- /dev/null +++ b/limereport/items/lrimageitemeditor.cpp @@ -0,0 +1,70 @@ +#include "lrimageitemeditor.h" +#include "ui_lrimageitemeditor.h" +#include "lrimageitem.h" + +#include +#include + +ImageItemEditor::ImageItemEditor(LimeReport::ImageItem *item, QWidget *parent) : + QWidget(parent), + ui(new Ui::ImageItemEditor), m_item(item) +{ + ui->setupUi(this); + m_image = QPixmap::fromImage(m_item->image()); + ui->resourcePath->setText(m_item->resourcePath()); + updateImage(); +} + +ImageItemEditor::~ImageItemEditor() +{ + delete ui; +} + +void ImageItemEditor::updateImage() +{ + ui->imageViewer->setPixmap(m_image); + if (m_image.isNull() && !ui->resourcePath->text().isEmpty()){ + if (m_resourcePathImage.isNull()) + m_resourcePathImage = QPixmap(ui->resourcePath->text()); + ui->imageViewer->setPixmap(m_resourcePathImage); + } +} + +void ImageItemEditor::on_tbLoadImage_clicked() +{ + QString fileName = QFileDialog::getOpenFileName(this, tr("Select image file")); + m_image = QPixmap(fileName); + updateImage(); +} + +void ImageItemEditor::on_tbClearImage_clicked() +{ + m_image = QPixmap(); + updateImage(); +} + +void ImageItemEditor::on_buttonBox_accepted() +{ + m_item->setImage(m_image.toImage()); + m_item->setResourcePath(ui->resourcePath->text()); + this->close(); +} + +void ImageItemEditor::on_buttonBox_rejected() +{ + this->close(); +} + +void ImageItemEditor::on_toolButton_clicked() +{ + ui->resourcePath->setText(QFileDialog::getOpenFileName(this, tr("Select image file"))); + m_resourcePathImage = QPixmap(ui->resourcePath->text()); + if (!m_resourcePathImage.isNull() && m_image.isNull()) + ui->imageViewer->setPixmap(m_resourcePathImage); +} + +void ImageItemEditor::on_tbResourcePath_clicked() +{ + ui->resourcePath->setText(""); + updateImage(); +} diff --git a/limereport/items/lrimageitemeditor.h b/limereport/items/lrimageitemeditor.h new file mode 100644 index 0000000..551baae --- /dev/null +++ b/limereport/items/lrimageitemeditor.h @@ -0,0 +1,37 @@ +#ifndef LRIMAGEITEMEDITOR_H +#define LRIMAGEITEMEDITOR_H + +#include + +namespace Ui { +class ImageItemEditor; +} + +namespace LimeReport { +class ImageItem; +} + +class ImageItemEditor : public QWidget +{ + Q_OBJECT + +public: + explicit ImageItemEditor(LimeReport::ImageItem* item, QWidget *parent = NULL); + ~ImageItemEditor(); +private: + void updateImage(); +private: + Ui::ImageItemEditor *ui; + LimeReport::ImageItem* m_item; + QPixmap m_image; + QPixmap m_resourcePathImage; +private slots: + void on_tbLoadImage_clicked(); + void on_tbClearImage_clicked(); + void on_buttonBox_accepted(); + void on_buttonBox_rejected(); + void on_toolButton_clicked(); + void on_tbResourcePath_clicked(); +}; + +#endif // LRIMAGEITEMEDITOR_H diff --git a/limereport/items/lrimageitemeditor.ui b/limereport/items/lrimageitemeditor.ui new file mode 100644 index 0000000..12152d4 --- /dev/null +++ b/limereport/items/lrimageitemeditor.ui @@ -0,0 +1,170 @@ + + + ImageItemEditor + + + + 0 + 0 + 358 + 403 + + + + + 0 + 0 + + + + Image Item Editor + + + + :/items/images/imageItem3.png:/items/images/imageItem3.png + + + + + + + 0 + 0 + + + + Image + + + + + + + + ... + + + + :/report/images/folder:/report/images/folder + + + true + + + + + + + ... + + + + :/items/clear.png:/items/clear.png + + + true + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + 0 + 0 + + + + + + + :/images/images/logo.png + + + true + + + + + + + + + + + + Resource path + + + + + + + + + + ... + + + + :/report/images/folder:/report/images/folder + + + true + + + + + + + ... + + + + :/items/clear.png:/items/clear.png + + + true + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + + + + + + + + diff --git a/limereport/limereport.pri b/limereport/limereport.pri index e039138..0918890 100644 --- a/limereport/limereport.pri +++ b/limereport/limereport.pri @@ -36,6 +36,7 @@ SOURCES += \ $$REPORT_PATH/items/editors/lritemsborderseditorwidget.cpp \ $$REPORT_PATH/items/lrsimpletagparser.cpp \ $$REPORT_PATH/items/lrimageitem.cpp \ + $$REPORT_PATH/items/lrimageitemeditor.cpp \ $$REPORT_PATH/items/lrtextitemeditor.cpp \ $$REPORT_PATH/items/lrshapeitem.cpp \ $$REPORT_PATH/items/lrtextitem.cpp \ @@ -108,6 +109,7 @@ HEADERS += \ $$REPORT_PATH/items/lrtextitemeditor.h \ $$REPORT_PATH/items/lrshapeitem.h \ $$REPORT_PATH/items/lrimageitem.h \ + $$REPORT_PATH/items/lrimageitemeditor.h \ $$REPORT_PATH/items/lrsimpletagparser.h \ $$REPORT_PATH/items/lrverticallayout.h \ $$REPORT_PATH/items/lrlayoutmarker.h \ @@ -171,6 +173,7 @@ FORMS += \ $$REPORT_PATH/lraboutdialog.ui \ $$REPORT_PATH/lrsettingdialog.ui \ $$REPORT_PATH/items/lrchartitemeditor.ui \ + $$REPORT_PATH/items/lrimageitemeditor.ui \ $$REPORT_PATH/scripteditor/lrscripteditor.ui RESOURCES += \ diff --git a/limereport/lrbanddesignintf.cpp b/limereport/lrbanddesignintf.cpp index f4db01d..6881440 100644 --- a/limereport/lrbanddesignintf.cpp +++ b/limereport/lrbanddesignintf.cpp @@ -177,7 +177,7 @@ BandDesignIntf::BandDesignIntf(BandsType bandType, const QString &xmlTypeName, Q if (parentItem) setWidth(parentItem->width()); } - setBackgroundMode(BGMode::TransparentMode); + setBackgroundMode(BaseDesignIntf::TransparentMode); setFillTransparentInDesignMode(false); setHeight(100); setFixedPos(true); @@ -362,7 +362,7 @@ void BandDesignIntf::setDataSourceName(const QString &datasource){ m_dataSourceName=datasource; } -void BandDesignIntf::setKeepBottomSpaceOption(bool value){ +void BandDesignIntf::setKeepBottomSpace(bool value){ if (m_keepBottomSpace!=value){ m_keepBottomSpace=value; if (!isLoading()) @@ -594,7 +594,11 @@ void BandDesignIntf::preparePopUpMenu(QMenu &menu) currAction = menu.addAction(tr("Keep bottom space")); currAction->setCheckable(true); - currAction->setChecked(keepBottomSpaceOption()); + currAction->setChecked(keepBottomSpace()); + + currAction = menu.addAction(tr("Keep top space")); + currAction->setCheckable(true); + currAction->setChecked(keepTopSpace()); currAction = menu.addAction(tr("Print if empty")); currAction->setCheckable(true); @@ -619,6 +623,9 @@ void BandDesignIntf::processPopUpAction(QAction *action) if (action->text().compare(tr("Keep bottom space")) == 0){ setProperty("keepBottomSpace", action->isChecked()); } + if (action->text().compare(tr("Keep top space")) == 0){ + setProperty("keepTopSpace",action->isChecked()); + } if (action->text().compare(tr("Print if empty")) == 0){ setProperty("printIfEmpty", action->isChecked()); @@ -1116,10 +1123,10 @@ void BandDesignIntf::setKeepFooterTogether(bool value) void BandDesignIntf::updateItemSize(DataSourceManager* dataManager, RenderPass pass, int maxHeight) { - qreal spaceBorder=0; - if (keepBottomSpaceOption()) spaceBorder = bottomSpace(); + qreal spaceBorder = 0; + if (keepBottomSpace()) spaceBorder = bottomSpace(); spaceBorder = spaceBorder > 0 ? spaceBorder : 0; - if (borderLines()!=0){ + if (borderLines() != 0){ spaceBorder += borderLineSize(); } @@ -1131,14 +1138,14 @@ void BandDesignIntf::updateItemSize(DataSourceManager* dataManager, RenderPass p arrangeSubItems(pass, dataManager); if (autoHeight()){ if (!keepTopSpace()) { - qreal minTop = findMinTop() + m_shiftItems; + qreal minTop = findMinTop() + m_shiftItems - spaceBorder; foreach (BaseDesignIntf* item, childBaseItems()) { item->setY(item->y() - minTop); } } - setHeight(findMaxBottom()+spaceBorder); + setHeight(findMaxBottom() + spaceBorder); } - if ((maxHeight>0)&&(height()>maxHeight)){ + if ((maxHeight > 0) && (height() > maxHeight)){ trimToMaxHeight(maxHeight); setHeight(maxHeight); } diff --git a/limereport/lrbanddesignintf.h b/limereport/lrbanddesignintf.h index 8da77ed..7f1d3f0 100644 --- a/limereport/lrbanddesignintf.h +++ b/limereport/lrbanddesignintf.h @@ -105,7 +105,7 @@ class BandDesignIntf : public ItemsContainerDesignInft Q_OBJECT Q_PROPERTY(bool autoHeight READ autoHeight WRITE setAutoHeight ) Q_PROPERTY(int bandIndex READ bandIndex WRITE setBandIndex DESIGNABLE false ) - Q_PROPERTY(bool keepBottomSpace READ keepBottomSpaceOption WRITE setKeepBottomSpaceOption ) + Q_PROPERTY(bool keepBottomSpace READ keepBottomSpace WRITE setKeepBottomSpace ) Q_PROPERTY(bool keepTopSpace READ keepTopSpace WRITE setKeepTopSpace) Q_PROPERTY(QString parentBand READ parentBandName WRITE setParentBandName DESIGNABLE false ) Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor) @@ -164,8 +164,8 @@ public: QString datasourceName(); void setDataSourceName(const QString& datasourceName); - void setKeepBottomSpaceOption(bool value); - bool keepBottomSpaceOption() const {return m_keepBottomSpace;} + void setKeepBottomSpace(bool value); + bool keepBottomSpace() const {return m_keepBottomSpace;} bool keepTopSpace() const; void setKeepTopSpace(bool value); diff --git a/limereport/lrbasedesignintf.cpp b/limereport/lrbasedesignintf.cpp index 71f2f94..1555aaf 100644 --- a/limereport/lrbasedesignintf.cpp +++ b/limereport/lrbasedesignintf.cpp @@ -97,7 +97,9 @@ BaseDesignIntf::BaseDesignIntf(const QString &storageTypeName, QObject *owner, Q QRectF BaseDesignIntf::boundingRect() const { - return rect(); + qreal halfpw = pen().widthF() / 2; + halfpw += 2; + return rect().adjusted(-halfpw, -halfpw, halfpw, halfpw); } BaseDesignIntf::~BaseDesignIntf(void) { diff --git a/limereport/lrbasedesignintf.h b/limereport/lrbasedesignintf.h index 40c4761..b7fbbbb 100644 --- a/limereport/lrbasedesignintf.h +++ b/limereport/lrbasedesignintf.h @@ -262,7 +262,7 @@ public: QString itemTypeName() const; void setItemTypeName(const QString &itemTypeName); - void emitObjectNamePropertyChanged(const QString& oldName, const QString& newName); + int borderLineSize() const; void setBorderLineSize(int value); void showEditorDialog(); @@ -303,7 +303,9 @@ public: bool fillTransparentInDesignMode() const; void setFillTransparentInDesignMode(bool fillTransparentInDesignMode); + void emitPosChanged(QPointF oldPos, QPointF newPos); + void emitObjectNamePropertyChanged(const QString& oldName, const QString& newName); bool isGeometryLocked() const; void setGeometryLocked(bool itemLocked); diff --git a/limereport/lrglobal.h b/limereport/lrglobal.h index b0b462f..5541a1b 100644 --- a/limereport/lrglobal.h +++ b/limereport/lrglobal.h @@ -92,6 +92,10 @@ namespace Const{ const QString EOW("~!@#$%^&*()+{}|:\"<>?,/;'[]\\-="); const int DEFAULT_TAB_INDENTION = 4; const int DOCKWIDGET_MARGINS = 4; + + const char SCRIPT_SIGN = 'S'; + const char FIELD_SIGN = 'D'; + const char VARIABLE_SIGN = 'V'; } QString extractClassName(QString className); QString escapeSimbols(const QString& value); diff --git a/limereport/lrpagedesignintf.cpp b/limereport/lrpagedesignintf.cpp index c28bdcf..09e6574 100644 --- a/limereport/lrpagedesignintf.cpp +++ b/limereport/lrpagedesignintf.cpp @@ -278,6 +278,7 @@ void PageDesignIntf::setPageItem(PageItemDesignIntf::Ptr pageItem) void PageDesignIntf::setPageItems(QList pages) { + m_currentPage = 0; if (!m_pageItem.isNull()) { removeItem(m_pageItem.data()); m_pageItem.clear(); @@ -1459,15 +1460,24 @@ void PageDesignIntf::sendToBack() } } +bool PageDesignIntf::selectionContainsBand(){ + foreach(QGraphicsItem * item,selectedItems()){ + BandDesignIntf *band = dynamic_cast(item); + if (band) return true; + } + return false; +} + void PageDesignIntf::alignToLeft() { if ((selectedItems().count() > 0) && m_firstSelectedItem) { CommandGroup::Ptr cm = CommandGroup::create(); + bool moveInBand = selectionContainsBand(); foreach(QGraphicsItem * item, selectedItems()) { BaseDesignIntf *bdItem = dynamic_cast(item); if (bdItem && !bdItem->isGeometryLocked()) { QRectF oldGeometry = bdItem->geometry(); - bdItem->setPos(QPoint(m_firstSelectedItem->pos().x(), item->pos().y())); + bdItem->setPos(QPointF(moveInBand ? 0 : m_firstSelectedItem->pos().x(), item->pos().y())); CommandIf::Ptr command = PropertyChangedCommand::create(this, bdItem->objectName(), "geometry", oldGeometry, bdItem->geometry()); cm->addCommand(command, false); } @@ -1480,11 +1490,19 @@ void PageDesignIntf::alignToRigth() { if ((selectedItems().count() > 0) && m_firstSelectedItem) { CommandGroup::Ptr cm = CommandGroup::create(); + bool moveInBand = selectionContainsBand(); foreach(QGraphicsItem * item, selectedItems()) { BaseDesignIntf *bdItem = dynamic_cast(item); - if (bdItem && !bdItem->isGeometryLocked()) { + if (bdItem && !bdItem->isGeometryLocked() && !bdItem->isBand()) { QRectF oldGeometry = bdItem->geometry(); - bdItem->setPos(QPoint(m_firstSelectedItem->geometry().right() - bdItem->width(), bdItem->pos().y())); + if (moveInBand && dynamic_cast(bdItem->parent())) + { + bdItem->setPos(QPointF(dynamic_cast(bdItem->parent())->geometry().width() - bdItem->width(), + bdItem->pos().y())); + } else { + qreal x = m_firstSelectedItem->geometry().right() - bdItem->width(); + bdItem->setPos(QPointF(x+1, bdItem->pos().y())); + } CommandIf::Ptr command = PropertyChangedCommand::create(this, bdItem->objectName(), "geometry", oldGeometry, bdItem->geometry()); cm->addCommand(command, false); } @@ -1497,11 +1515,18 @@ void PageDesignIntf::alignToVCenter() { if ((selectedItems().count() > 0) && m_firstSelectedItem) { CommandGroup::Ptr cm = CommandGroup::create(); + bool moveInBand = selectionContainsBand(); foreach(QGraphicsItem * item, selectedItems()) { BaseDesignIntf *bdItem = dynamic_cast(item); - if (bdItem && !bdItem->isGeometryLocked()) { + if (bdItem && !bdItem->isGeometryLocked() && !bdItem->isBand()) { QRectF oldGeometry = bdItem->geometry(); - bdItem->setPos(QPoint((m_firstSelectedItem->geometry().right() - m_firstSelectedItem->width() / 2) - bdItem->width() / 2, bdItem->pos().y())); + if (moveInBand && dynamic_cast(bdItem->parent())){ + bdItem->setPos(QPointF((dynamic_cast(bdItem->parent())->geometry().width() / 2) - bdItem->width() / 2, + bdItem->pos().y())); + } else { + qreal x = (m_firstSelectedItem->geometry().right() - m_firstSelectedItem->width() / 2) - bdItem->width() / 2; + bdItem->setPos(QPointF(x+1, bdItem->pos().y())); + } CommandIf::Ptr command = PropertyChangedCommand::create(this, bdItem->objectName(), "geometry", oldGeometry, bdItem->geometry()); cm->addCommand(command, false); } @@ -1514,11 +1539,16 @@ void PageDesignIntf::alignToTop() { if ((selectedItems().count() > 0) && m_firstSelectedItem) { CommandGroup::Ptr cm = CommandGroup::create(); + bool moveInBand = selectionContainsBand(); foreach(QGraphicsItem * item, selectedItems()) { BaseDesignIntf *bdItem = dynamic_cast(item); - if (bdItem && !bdItem->isGeometryLocked()) { + if (bdItem && !bdItem->isGeometryLocked() && !bdItem->isBand()) { QRectF oldGeometry = bdItem->geometry(); - bdItem->setPos(QPoint(bdItem->pos().x(), m_firstSelectedItem->pos().y())); + if (moveInBand){ + bdItem->setPos(QPointF(0, m_firstSelectedItem->pos().y())); + } else { + bdItem->setPos(QPointF(bdItem->pos().x(), m_firstSelectedItem->pos().y())); + } CommandIf::Ptr command = PropertyChangedCommand::create(this, bdItem->objectName(), "geometry", oldGeometry, bdItem->geometry()); cm->addCommand(command, false); } @@ -1531,11 +1561,17 @@ void PageDesignIntf::alignToBottom() { if ((selectedItems().count() > 0) && m_firstSelectedItem) { CommandGroup::Ptr cm = CommandGroup::create(); + bool moveInBand = selectionContainsBand(); foreach(QGraphicsItem * item, selectedItems()) { BaseDesignIntf *bdItem = dynamic_cast(item); - if (bdItem && !bdItem->isGeometryLocked()) { + if (bdItem && !bdItem->isGeometryLocked() && !bdItem->isBand()) { QRectF oldGeometry = bdItem->geometry(); - bdItem->setPos(QPoint(bdItem->pos().x(), m_firstSelectedItem->geometry().bottom() - bdItem->height())); + if (moveInBand && dynamic_cast(bdItem->parent())){ + bdItem->setPos(QPointF(bdItem->pos().x(), dynamic_cast(bdItem->parent())->height() - bdItem->height())); + } else { + qreal y = m_firstSelectedItem->geometry().bottom() - bdItem->height(); + bdItem->setPos(QPointF(bdItem->pos().x(), y+1)); + } CommandIf::Ptr command = PropertyChangedCommand::create(this, bdItem->objectName(), "geometry", oldGeometry, bdItem->geometry()); cm->addCommand(command, false); } @@ -1548,11 +1584,17 @@ void PageDesignIntf::alignToHCenter() { if ((selectedItems().count() > 0) && m_firstSelectedItem) { CommandGroup::Ptr cm = CommandGroup::create(); + bool moveInBand = selectionContainsBand(); foreach(QGraphicsItem * item, selectedItems()) { BaseDesignIntf *bdItem = dynamic_cast(item); - if (bdItem && !bdItem->isGeometryLocked()) { + if (bdItem && !bdItem->isGeometryLocked() && !bdItem->isBand()) { QRectF oldGeometry = bdItem->geometry(); - bdItem->setPos(QPoint(bdItem->pos().x(), (m_firstSelectedItem->geometry().bottom() - m_firstSelectedItem->height() / 2) - bdItem->height() / 2)); + if (moveInBand && dynamic_cast(bdItem->parent())){ + bdItem->setPos(QPointF(bdItem->pos().x(), (dynamic_cast(bdItem->parent())->height() / 2) - bdItem->height() / 2)); + } else { + qreal y = (m_firstSelectedItem->geometry().bottom() - m_firstSelectedItem->height() / 2) - bdItem->height() / 2; + bdItem->setPos(QPointF(bdItem->pos().x(), y+1)); + } CommandIf::Ptr command = PropertyChangedCommand::create(this, bdItem->objectName(), "geometry", oldGeometry, bdItem->geometry()); cm->addCommand(command, false); } @@ -2136,7 +2178,7 @@ bool PosChangedCommand::doIt() if (reportItem && (reportItem->pos() != m_newPos[i].pos)){ QPointF oldValue = reportItem->pos(); reportItem->setPos(m_newPos[i].pos); - emit reportItem->posChanged(reportItem, oldValue, reportItem->pos()); + reportItem->emitPosChanged(oldValue, reportItem->pos()); } } diff --git a/limereport/lrpagedesignintf.h b/limereport/lrpagedesignintf.h index d94abfe..b02a2de 100644 --- a/limereport/lrpagedesignintf.h +++ b/limereport/lrpagedesignintf.h @@ -282,6 +282,7 @@ namespace LimeReport { void changeSelectedGroupProperty(const QString& name,const QVariant& value); void activateItemToJoin(QRectF itemRect, QList& items); void selectAllChildren(BaseDesignIntf* item); + bool selectionContainsBand(); private: enum JoinType{Width, Height}; LimeReport::PageItemDesignIntf::Ptr m_pageItem; @@ -322,6 +323,7 @@ namespace LimeReport { bool m_magneticMovement; ReportSettings* m_reportSettings; PageItemDesignIntf* m_currentPage; + }; class AbstractPageCommand : public CommandIf{ diff --git a/limereport/lrreportdesignwidget.h b/limereport/lrreportdesignwidget.h index 4b7248e..ef3b81b 100644 --- a/limereport/lrreportdesignwidget.h +++ b/limereport/lrreportdesignwidget.h @@ -82,12 +82,12 @@ private: class PageView: public QGraphicsView{ public: - PageView(QWidget *parent = nullptr): QGraphicsView(parent), + PageView(QWidget *parent = NULL): QGraphicsView(parent), m_horizontalRuller(0), m_verticalRuller(0) { setViewportMargins(20,20,0,0); } - PageView(QGraphicsScene *scene, QWidget *parent = nullptr): + PageView(QGraphicsScene *scene, QWidget *parent = NULL): QGraphicsView(scene, parent), m_horizontalRuller(0), m_verticalRuller(0) { diff --git a/limereport/lrreportengine.cpp b/limereport/lrreportengine.cpp index fc1b4c2..9ff1f52 100644 --- a/limereport/lrreportengine.cpp +++ b/limereport/lrreportengine.cpp @@ -304,7 +304,7 @@ void ReportEnginePrivate::internalPrintPages(ReportPages pages, QPrinter &printe { m_cancelPrinting = false; int currenPage = 1; - QMap> printProcessors; + QMap > printProcessors; printProcessors.insert("default",QSharedPointer(new PrintProcessor(&printer))); emit printingStarted(printer.toPage() - printer.fromPage()); foreach(PageItemDesignIntf::Ptr page, pages){ diff --git a/limereport/lrscriptenginemanager.cpp b/limereport/lrscriptenginemanager.cpp index cb6e219..91bc9bc 100644 --- a/limereport/lrscriptenginemanager.cpp +++ b/limereport/lrscriptenginemanager.cpp @@ -465,15 +465,13 @@ QString ScriptEngineManager::expandScripts(QString context, QVariant& varValue, if (context.contains(rx)){ - if (ScriptEngineManager::instance().dataManager()!=dataManager()) + if (ScriptEngineManager::instance().dataManager() != dataManager()) ScriptEngineManager::instance().setDataManager(dataManager()); ScriptEngineType* se = ScriptEngineManager::instance().scriptEngine(); if (reportItem){ - ScriptValueType svThis; - #ifdef USE_QJSENGINE svThis = getJSValue(*se, reportItem); se->globalObject().setProperty("THIS",svThis); @@ -490,29 +488,37 @@ QString ScriptEngineManager::expandScripts(QString context, QVariant& varValue, ScriptExtractor scriptExtractor(context); if (scriptExtractor.parse()){ - for(int i=0; ievaluate(scriptBody); -#ifdef USE_QJSENGINE - if (!value.isError()){ - varValue = value.toVariant(); - context.replace(scriptExtractor.scriptAt(i),value.toString()); - } else { - context.replace(scriptExtractor.scriptAt(i),value.toString()); - } -#else - if (!se->hasUncaughtException()) { - varValue = value.toVariant(); - context.replace(scriptExtractor.scriptAt(i),value.toString()); - } else { - context.replace(scriptExtractor.scriptAt(i),se->uncaughtException().toString()); - } -#endif - } + context = replaceScripts(context, varValue, reportItem, se, scriptExtractor.scriptTree()); } - } + } + return context; +} + +QString ScriptEngineManager::replaceScripts(QString context, QVariant &varValue, QObject *reportItem, ScriptEngineType* se, ScriptNode *scriptTree) +{ + foreach(ScriptNode* item, scriptTree->children()){ + QString scriptBody = expandDataFields(item->body(), EscapeSymbols, varValue, reportItem); + if (item->children().size() > 0) + scriptBody = replaceScripts(scriptBody, varValue, reportItem, se, item); + scriptBody = expandUserVariables(scriptBody, FirstPass, EscapeSymbols, varValue); + ScriptValueType value = se->evaluate(scriptBody); +#ifdef USE_QJSENGINE + if (!value.isError()){ + varValue = value.toVariant(); + context.replace(item->script(), value.toString()); + } else { + context.replace(item->script(), value.toString()); + } +#else + if (!se->hasUncaughtException()) { + varValue = value.toVariant(); + context.replace(item->script(), value.toString()); + } else { + context.replace(item->script(), se->uncaughtException().toString()); + } +#endif + } return context; } @@ -530,7 +536,7 @@ QVariant ScriptEngineManager::evaluateScript(const QString& script){ ScriptExtractor scriptExtractor(script); if (scriptExtractor.parse()){ - QString scriptBody = expandDataFields(scriptExtractor.bodyAt(0),EscapeSymbols, varValue, 0); + QString scriptBody = expandDataFields(scriptExtractor.scriptTree()[0].body(), EscapeSymbols, varValue, 0); scriptBody = expandUserVariables(scriptBody, FirstPass, EscapeSymbols, varValue); ScriptValueType value = se->evaluate(scriptBody); #ifdef USE_QJSENGINE @@ -976,12 +982,11 @@ ScriptEngineManager::ScriptEngineManager() bool ScriptExtractor::parse() { int currentPos = 0; - parse(currentPos,None); - return m_scriptsBody.count()>0; - + parse(currentPos, None, m_scriptTree); + return m_scriptTree->children().count() > 0; } -bool ScriptExtractor::parse(int &curPos,const State& state) +bool ScriptExtractor::parse(int &curPos, const State& state, ScriptNode* scriptNode) { while (curPoscreateChildNode()); if (isStartFieldLexem(curPos) || isStartVariableLexem(curPos)) skipField(curPos); } @@ -1008,13 +1013,13 @@ bool ScriptExtractor::parse(int &curPos,const State& state) return false; } -void ScriptExtractor::extractScript(int &curPos, const QString& startStr) +void ScriptExtractor::extractScript(int &curPos, const QString& startStr, ScriptNode* scriptNode) { int startPos = curPos; - if (extractBracket(curPos)){ + if (extractBracket(curPos, scriptNode)){ QString scriptBody = substring(m_context,startPos+1,curPos); - m_scriptsBody.push_back(scriptBody); - m_scriptsStartLex.push_back(startStr+'{'); + scriptNode->setBody(scriptBody); + scriptNode->setStartLex(startStr+'{'); } } @@ -1028,10 +1033,10 @@ void ScriptExtractor::skipField(int &curPos){ } } -bool ScriptExtractor::extractBracket(int &curPos) +bool ScriptExtractor::extractBracket(int &curPos, ScriptNode* scriptNode) { curPos++; - return parse(curPos,OpenBracketFound); + return parse(curPos,OpenBracketFound, scriptNode); } bool ScriptExtractor::isStartLexem(int& curPos, QChar value){ @@ -1064,16 +1069,16 @@ bool ScriptExtractor::isStartLexem(int& curPos, QChar value){ bool ScriptExtractor::isStartScriptLexem(int& curPos) { - return isStartLexem(curPos, SCRIPT_SIGN); + return isStartLexem(curPos, Const::SCRIPT_SIGN); } bool ScriptExtractor::isStartFieldLexem(int& curPos){ - return isStartLexem(curPos, FIELD_SIGN); + return isStartLexem(curPos, Const::FIELD_SIGN); } bool ScriptExtractor::isStartVariableLexem(int &curPos) { - return isStartLexem(curPos, VARIABLE_SIGN); + return isStartLexem(curPos, Const::VARIABLE_SIGN); } @@ -1930,7 +1935,7 @@ bool DatasourceFunctions::isEOF(const QString &datasourceName) bool DatasourceFunctions::invalidate(const QString& datasourceName) { if (m_dataManager && m_dataManager->dataSource(datasourceName)){ - m_dataManager->dataSourceHolder(datasourceName)->invalidate(IDataSource::DatasourceMode::RENDER_MODE); + m_dataManager->dataSourceHolder(datasourceName)->invalidate(IDataSource::RENDER_MODE); return true; } return false; diff --git a/limereport/lrscriptenginemanager.h b/limereport/lrscriptenginemanager.h index f59405c..784253d 100644 --- a/limereport/lrscriptenginemanager.h +++ b/limereport/lrscriptenginemanager.h @@ -396,6 +396,47 @@ private: QMap m_wrappersFactory; }; +class ScriptNode{ +public: + QString body(){return m_body;} + void setBody(const QString& body){ m_body = body;} + void setStartLex(const QString startLex){ m_startLex = startLex;} + QString script(){return m_startLex + m_body + '}';} + ScriptNode* createChildNode(){ + ScriptNode* result = new ScriptNode(); + m_children.append(result); + return result; + } + QVector children() const {return m_children;} +private: + QVector m_children; + QString m_body; + QString m_startLex; +}; + +class ScriptExtractor +{ +public: + enum State{None,BuksFound,SFound,StartScriptFound,OpenBracketFound,CloseBracketFound,DFound,VFound, SignFound}; + explicit ScriptExtractor(const QString& value): + m_context(value), m_scriptTree(new ScriptNode()){} + bool parse(); + ScriptNode* scriptTree(){return m_scriptTree;} +private: + bool isStartLexem(int &curPos, QChar value); + bool parse(int& curPos, const State &state, ScriptNode *scriptNode); + void skipField(int &curPos); + void extractScript(int& curPos, const QString &startStr, ScriptNode *scriptNode); + bool extractBracket(int& curPos, ScriptNode *scriptNode); + bool isStartScriptLexem(int &curPos); + bool isStartFieldLexem(int &curPos); + bool isStartVariableLexem(int &curPos); + QString substring(const QString& value, int start, int end); +private: + QString m_context; + ScriptNode* m_scriptTree; +}; + class ScriptEngineManager : public QObject, public Singleton, public IScriptEngineManager { Q_OBJECT @@ -423,6 +464,9 @@ public: QString expandUserVariables(QString context, RenderPass pass, ExpandType expandType, QVariant &varValue); QString expandDataFields(QString context, ExpandType expandType, QVariant &varValue, QObject* reportItem); QString expandScripts(QString context, QVariant &varValue, QObject* reportItem); + + QString replaceScripts(QString context, QVariant& varValue, QObject *reportItem, ScriptEngineType *se, ScriptNode* scriptTree); + QVariant evaluateScript(const QString &script); void addBookMark(const QString &uniqKey, const QString &content); int findPageIndexByBookmark(const QString& uniqKey); @@ -466,36 +510,6 @@ private: ScriptFunctionsManager* m_functionManager; }; -class ScriptExtractor -{ -public: - enum State{None,BuksFound,SFound,StartScriptFound,OpenBracketFound,CloseBracketFound,DFound,VFound, SignFound}; - explicit ScriptExtractor(const QString& value):m_context(value){} - bool parse(); - int count(){return m_scriptsBody.count();} - QString bodyAt(int index){return m_scriptsBody[index];} - QString scriptAt(int index){return m_scriptsStartLex[index]+m_scriptsBody[index]+'}';} - -private: - static const char SCRIPT_SIGN = 'S'; - static const char FIELD_SIGN = 'D'; - static const char VARIABLE_SIGN = 'V'; - - bool isStartLexem(int &curPos, QChar value); - bool parse(int& curPos, const State &state); - void skipField(int &curPos); - void extractScript(int& curPos, const QString &startStr); - bool extractBracket(int& curPos); - bool isStartScriptLexem(int &curPos); - bool isStartFieldLexem(int &curPos); - bool isStartVariableLexem(int &curPos); - QString substring(const QString& value, int start, int end); -private: - QString m_context; - QVector m_scriptsBody; - QVector m_scriptsStartLex; - -}; #ifdef USE_QTSCRIPTENGINE class QFontPrototype : public QObject, public QScriptable { diff --git a/limereport/objectinspector/lrobjectpropitem.h b/limereport/objectinspector/lrobjectpropitem.h index 46392fc..f765213 100644 --- a/limereport/objectinspector/lrobjectpropitem.h +++ b/limereport/objectinspector/lrobjectpropitem.h @@ -99,7 +99,7 @@ namespace LimeReport{ #endif private: bool m_valid; - void invalidate(){m_object=0; m_objects=0; m_valid = false; m_name = ""; m_value=QVariant(), m_isClass=false;} + void invalidate(){m_object=0; m_objects=0; m_valid = false; m_name = ""; m_value=QVariant(); m_isClass=false;} protected: void beginChangeValue(){ m_changingValue = true; } @@ -140,4 +140,7 @@ namespace LimeReport{ }; } + +Q_DECLARE_METATYPE(LimeReport::ObjectPropItem*) + #endif // LROBJECTPROPITEM_H diff --git a/translations/limereport_ru.qm b/translations/limereport_ru.qm index 12ec753..3a14c7e 100644 Binary files a/translations/limereport_ru.qm and b/translations/limereport_ru.qm differ diff --git a/translations/limereport_ru.ts b/translations/limereport_ru.ts index 4329fe8..adf4c0e 100644 --- a/translations/limereport_ru.ts +++ b/translations/limereport_ru.ts @@ -55,6 +55,29 @@ Название ряда + + ImageItemEditor + + Image Item Editor + Редакор изображения + + + Image + Изображение + + + ... + ... + + + Resource path + Путь к русурсам + + + Select image file + Выбрать файл изображения + + LRVariableDialog @@ -392,6 +415,10 @@ p, li { white-space: pre-wrap; } Copy Копировать + + Keep top space + Сохранять отступ сверху + LimeReport::BaseDesignIntf @@ -433,7 +460,7 @@ p, li { white-space: pre-wrap; } Lock item geometry - Блокировать изменения геометрии + Заблокировать геометрию элемента @@ -1003,11 +1030,11 @@ p, li { white-space: pre-wrap; } Scale - Масштабировать + Масштаб Split - Разделять на части + Разделить @@ -1130,6 +1157,10 @@ p, li { white-space: pre-wrap; } Watermark Водный знак + + Edit + Правка + LimeReport::ItemLocationPropItem @@ -1249,7 +1280,7 @@ p, li { white-space: pre-wrap; } Translate properties - Переводить имена свойств + Свойства перевода @@ -1329,10 +1360,6 @@ p, li { white-space: pre-wrap; } Report Отчет - - toolBar - Панель инструментов - Print Печать @@ -1433,10 +1460,6 @@ p, li { white-space: pre-wrap; } Show toolbar Показать панель инструментов - - toolBar_2 - Редактирование - InsertTextItem Вставить текстовый элемент @@ -1457,6 +1480,14 @@ p, li { white-space: pre-wrap; } Del Удалить + + MainToolBar + Основная панель инструментов + + + EditModeTools + Панель инструментов редактирования + LimeReport::ProxyHolder @@ -1881,7 +1912,7 @@ p, li { white-space: pre-wrap; } setPageSizeToPrinter - Отправить параметры страницы в принтер + Оправитьпараметры страницы в принтер fillInSecondPass @@ -1961,11 +1992,11 @@ p, li { white-space: pre-wrap; } option3 - + Опция 3 units - Единицы измерения + Еденицы измерения geometryLocked @@ -1973,7 +2004,7 @@ p, li { white-space: pre-wrap; } printBehavior - Режим печати + Поведение при печати @@ -2301,15 +2332,15 @@ p, li { white-space: pre-wrap; } Lock selected items - Заблокировать выбранные элементы + Заблокировать выделенные элементы Unlock selected items - Разблокировать выбранные элементы + Разблокировать выделенные элементы Select one level items - Выбрать все элементы одного уровня + Выделить элементы одного уровня @@ -2482,7 +2513,7 @@ This preview is no longer valid. CSV - + CSV Separator @@ -2494,7 +2525,7 @@ This preview is no longer valid. Use first row as header - Первая строка как заголовок + Использовать первую строку в качестве заголовка @@ -2729,7 +2760,7 @@ This preview is no longer valid. Report units - Единицы измерения + Еденицы измерения @@ -3146,18 +3177,18 @@ This preview is no longer valid. Export to PDF Экспортировать в PDF + + Dark + Темная + + + Light + Светаля + Default По умолчанию - - margin - Поля - - - '' - - Millimeters Миллиметры @@ -3167,12 +3198,12 @@ This preview is no longer valid. Дюймы - Dark - Темная + margin + Поля - Light - Светлая + '' + ''