Merge pull request #8 from fralx/master

Update to latest version
This commit is contained in:
wartime 2019-11-23 11:35:30 +08:00 committed by GitHub
commit 797edd541c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
60 changed files with 3871 additions and 1302 deletions

View File

@ -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

View File

@ -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 \

View File

@ -3,10 +3,14 @@
#include <QtCore/qglobal.h>
#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

View File

@ -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)
# LimeReport v1.5.16 [![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

View File

@ -127,7 +127,7 @@ RCC_DIR = $${ARCH_DIR}/$${BUILD_TYPE}/rcc
LIMEREPORT_VERSION_MAJOR = 1
LIMEREPORT_VERSION_MINOR = 5
LIMEREPORT_VERSION_RELEASE = 1
LIMEREPORT_VERSION_RELEASE = 21
LIMEREPORT_VERSION = '$${LIMEREPORT_VERSION_MAJOR}.$${LIMEREPORT_VERSION_MINOR}.$${LIMEREPORT_VERSION_RELEASE}'
DEFINES *= LIMEREPORT_VERSION_STR=\\\"$${LIMEREPORT_VERSION}\\\"

View File

@ -681,7 +681,7 @@
<itemLocation Type="enumAndFlags" Value="0"/>
<stretchToMaxHeight Type="bool" Value="0"/>
<itemAlign Type="enumAndFlags" Value="4"/>
<content Type="QString">Count: $S{COUNT("DataBand1")}</content>
<content Type="QString">Count: $S{COUNT(DataBand1)}</content>
<margin Type="int" Value="4"/>
<alignment Type="enumAndFlags" Value="34"/>
<autoWidth Type="enumAndFlags" Value="0"/>

View File

@ -77,7 +77,7 @@ MainWindow::MainWindow(QWidget *parent) :
int index = m_customers->record().indexOf("CustomerID");
m_orders->bindValue(":id",m_customers->value(index));
m_orders->exec();
};
}
}
LimeReport::ICallbackDatasource * callbackDatasource = report->dataManager()->createCallbackDatasource("master");
@ -156,18 +156,21 @@ void MainWindow::on_pushButton_2_clicked()
// printers.insert("default",printer);
// report->printReport(printers);
// }
report->setShowProgressDialog(true);
report->previewReport();
}
}
void MainWindow::renderStarted()
{
m_currentPage = 0;
m_progressDialog = new QProgressDialog(tr("Start render"),tr("Cancel"),0,0,this);
m_progressDialog->setWindowModality(Qt::WindowModal);
connect(m_progressDialog, SIGNAL(canceled()), report, SLOT(cancelRender()));
m_progressDialog->show();
QApplication::processEvents();
if (report->isShowProgressDialog()){
m_currentPage = 0;
m_progressDialog = new QProgressDialog(tr("Start render"),tr("Cancel"),0,0,this);
//m_progressDialog->setWindowModality(Qt::WindowModal);
connect(m_progressDialog, SIGNAL(canceled()), report, SLOT(cancelRender()));
QApplication::processEvents();
m_progressDialog->show();
}
}
void MainWindow::renderPageFinished(int renderedPageCount)

View File

@ -15,10 +15,11 @@ void DesignerSettingManager::getAvailableLanguages(QList<QLocale::Language>* lan
{
languages->append(QLocale::Russian);
languages->append(QLocale::English);
languages->append(QLocale::Arabic);
// languages->append(QLocale::Arabic);
languages->append(QLocale::French);
languages->append(QLocale::Chinese);
languages->append(QLocale::Spanish);
languages->append(QLocale::Polish);
}
QLocale::Language DesignerSettingManager::getCurrentDefaultLanguage()

View File

@ -12,7 +12,6 @@ class DesignerSettingManager : public QObject
public:
explicit DesignerSettingManager(QObject *parent = 0);
~DesignerSettingManager();
void setApplicationInstance(QApplication* application);
public slots:
void getAvailableLanguages(QList<QLocale::Language>* languages);
QLocale::Language getCurrentDefaultLanguage();

View File

@ -52,6 +52,7 @@ namespace LimeReport {
namespace Const{
int const DEFAULT_GRID_STEP = 1;
int const RESIZE_HANDLE_SIZE = 5;
int const SELECTION_PEN_SIZE = 1;
int const MINIMUM_ITEM_WIDTH = 2*RESIZE_HANDLE_SIZE;
@ -91,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);

View File

@ -164,6 +164,7 @@ public:
void designReport();
ReportDesignWindowInterface* getDesignerWindow();
void setShowProgressDialog(bool value);
bool isShowProgressDialog();
IDataSourceManager* dataManager();
IScriptEngineManager* scriptManager();
bool loadFromFile(const QString& fileName, bool autoLoadPreviewOnChange = false);
@ -212,6 +213,11 @@ signals:
void renderStarted();
void renderFinished();
void renderPageFinished(int renderedPageCount);
void printingStarted(int pageCount);
void printingFinished();
void pagePrintingFinished(int index);
void onSave(bool& saved);
void onSaveAs(bool& saved);
void onLoad(bool& loaded);
@ -228,6 +234,7 @@ signals:
public slots:
void cancelRender();
void cancelPrinting();
protected:
ReportEnginePrivate * const d_ptr;
ReportEngine(ReportEnginePrivate &dd, QObject * parent=0);

View File

@ -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

View File

@ -278,7 +278,8 @@ void SQLEditDialog::initQueryMode()
ui->cbSubdetail->setChecked(false);
ui->leMaster->setVisible(false);
ui->lbMaster->setVisible(false);
ui->tabWidget->removeTab(1);
//ui->tabWidget->removeTab(1);
ui->tabWidget->addTab(ui->csvTab, tr("CSV"));
}
void SQLEditDialog::initSubQueryMode()
@ -314,7 +315,7 @@ void SQLEditDialog::initProxyMode()
void SQLEditDialog::initCSVMode()
{
ui->tabWidget->removeTab(0);
ui->tabWidget->setCurrentWidget(ui->csvTab);
}
void SQLEditDialog::slotPreviewData()

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>422</width>
<height>622</height>
<height>624</height>
</rect>
</property>
<property name="windowTitle">

View File

@ -27,7 +27,7 @@ bool PDFExporter::exportPages(ReportPages pages, const QString &fileName, const
printer.setOutputFileName(fileName);
printer.setOutputFormat(QPrinter::PdfFormat);
if (!pages.isEmpty()){
m_reportEngine->printReport(pages, printer);
m_reportEngine->printPages(pages, &printer);
}
m_reportEngine->emitPrintedToPDF(fileName);
return true;

View File

@ -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<QString, QVariant> &params);
QString exporterName()

View File

@ -158,6 +158,7 @@ void AbstractLayout::beforeDelete()
#endif
BaseDesignIntf *bi = dynamic_cast<BaseDesignIntf*>(item);
if (bi) {
bi->disconnect(this);
bi->setParentItem(parentItem());
bi->setParent(parent());
bi->setVisible(true);

View File

@ -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);

View File

@ -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;

View File

@ -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;
};
}

View File

@ -0,0 +1,70 @@
#include "lrimageitemeditor.h"
#include "ui_lrimageitemeditor.h"
#include "lrimageitem.h"
#include <QFileInfo>
#include <QFileDialog>
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();
}

View File

@ -0,0 +1,37 @@
#ifndef LRIMAGEITEMEDITOR_H
#define LRIMAGEITEMEDITOR_H
#include <QWidget>
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

View File

@ -0,0 +1,170 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ImageItemEditor</class>
<widget class="QWidget" name="ImageItemEditor">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>358</width>
<height>403</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Ignored" vsizetype="Ignored">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>Image Item Editor</string>
</property>
<property name="windowIcon">
<iconset resource="items.qrc">
<normaloff>:/items/images/imageItem3.png</normaloff>:/items/images/imageItem3.png</iconset>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QGroupBox" name="groupBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Image</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QToolButton" name="tbLoadImage">
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../report.qrc">
<normaloff>:/report/images/folder</normaloff>:/report/images/folder</iconset>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="tbClearImage">
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../objectinspector/lobjectinspector.qrc">
<normaloff>:/items/clear.png</normaloff>:/items/clear.png</iconset>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="imageViewer">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="../../demo_r2/demo_r2.qrc">:/images/images/logo.png</pixmap>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Resource path</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="resourcePath"/>
</item>
<item>
<widget class="QToolButton" name="toolButton">
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../report.qrc">
<normaloff>:/report/images/folder</normaloff>:/report/images/folder</iconset>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="tbResourcePath">
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../objectinspector/lobjectinspector.qrc">
<normaloff>:/items/clear.png</normaloff>:/items/clear.png</iconset>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources>
<include location="../../demo_r2/demo_r2.qrc"/>
<include location="../report.qrc"/>
<include location="items.qrc"/>
<include location="../objectinspector/lobjectinspector.qrc"/>
<include location="../report.qrc"/>
<include location="items.qrc"/>
<include location="../objectinspector/lobjectinspector.qrc"/>
</resources>
<connections/>
</ui>

View File

@ -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 += \

View File

@ -166,7 +166,8 @@ BandDesignIntf::BandDesignIntf(BandsType bandType, const QString &xmlTypeName, Q
m_printAlways(false),
m_repeatOnEachRow(false),
m_useAlternateBackgroundColor(false),
m_bottomSpace(0)
m_bottomSpace(0),
m_shiftItems(0)
{
setPossibleResizeDirectionFlags(ResizeBottom);
setPossibleMoveFlags(TopBotom);
@ -176,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);
@ -277,6 +278,11 @@ void BandDesignIntf::paint(QPainter *painter, const QStyleOptionGraphicsItem *op
BaseDesignIntf::paint(painter,option,widget);
}
QRectF BandDesignIntf::boundingRect() const
{
return ItemsContainerDesignInft::boundingRect().adjusted(0,-4,0,4);
}
void BandDesignIntf::translateBandsName()
{
tr("DataBand");
@ -356,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())
@ -582,9 +588,13 @@ void BandDesignIntf::preparePopUpMenu(QMenu &menu)
currAction->setCheckable(true);
currAction->setChecked(isSplittable());
currAction = menu.addAction(tr("Keep top space"));
currAction->setCheckable(true);
currAction->setChecked(keepTopSpace());
currAction = menu.addAction(tr("Keep bottom space"));
currAction->setCheckable(true);
currAction->setChecked(keepBottomSpaceOption());
currAction->setChecked(keepBottomSpace());
currAction = menu.addAction(tr("Print if empty"));
currAction->setCheckable(true);
@ -595,17 +605,26 @@ void BandDesignIntf::preparePopUpMenu(QMenu &menu)
void BandDesignIntf::processPopUpAction(QAction *action)
{
if (action->text().compare(tr("Auto height")) == 0){
setProperty("autoHeight",action->isChecked());
setProperty("autoHeight", action->isChecked());
}
if (action->text().compare(tr("Splittable")) == 0){
setProperty("splittable",action->isChecked());
setProperty("splittable", action->isChecked());
}
if (action->text().compare(tr("Keep top space")) == 0){
setProperty("keepTopSpace", action->isChecked());
}
if (action->text().compare(tr("Keep bottom space")) == 0){
setProperty("keepBottomSpace",action->isChecked());
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());
setProperty("printIfEmpty", action->isChecked());
}
ItemsContainerDesignInft::processPopUpAction(action);
}
@ -903,6 +922,16 @@ void BandDesignIntf::slotPropertyObjectNameChanged(const QString &, const QStrin
m_bandNameLabel->updateLabel(newName);
}
int BandDesignIntf::shiftItems() const
{
return m_shiftItems;
}
void BandDesignIntf::setShiftItems(int shiftItems)
{
m_shiftItems = shiftItems;
}
bool BandDesignIntf::keepTopSpace() const
{
return m_keepTopSpace;
@ -1090,10 +1119,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();
}
@ -1105,14 +1134,14 @@ void BandDesignIntf::updateItemSize(DataSourceManager* dataManager, RenderPass p
arrangeSubItems(pass, dataManager);
if (autoHeight()){
if (!keepTopSpace()) {
qreal minTop = findMinTop();
qreal minTop = findMinTop() + m_shiftItems;
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);
}

View File

@ -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)
@ -113,6 +113,7 @@ class BandDesignIntf : public ItemsContainerDesignInft
Q_PROPERTY(bool printIfEmpty READ printIfEmpty WRITE setPrintIfEmpty)
Q_PROPERTY(BGMode backgroundMode READ backgroundMode WRITE setBackgroundModeProperty)
Q_PROPERTY(int backgroundOpacity READ opacity WRITE setBackgroundOpacity)
Q_PROPERTY(int shiftItems READ shiftItems WRITE setShiftItems)
Q_ENUMS(BandColumnsLayoutType)
friend class BandMarker;
friend class BandNameLabel;
@ -142,6 +143,7 @@ public:
~BandDesignIntf();
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
QRectF boundingRect() const;
void translateBandsName();
virtual BandsType bandType() const;
virtual QString bandTitle() const;
@ -162,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);
@ -260,6 +262,8 @@ public:
int bootomSpace() const;
void setBootomSpace(int bootomSpace);
void updateBandMarkerGeometry();
int shiftItems() const;
void setShiftItems(int shiftItems);
signals:
void bandRendered(BandDesignIntf* band);
@ -323,6 +327,7 @@ private:
bool m_useAlternateBackgroundColor;
int m_bottomSpace;
QMap<QString,QVariant> m_bookmarks;
int m_shiftItems;
};
class DataBandDesignIntf : public BandDesignIntf{

View File

@ -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) {
@ -500,7 +502,7 @@ void BaseDesignIntf::hoverLeaveEvent(QGraphicsSceneHoverEvent *)
update();
}
void BaseDesignIntf::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
void BaseDesignIntf::hoverEnterEvent(QGraphicsSceneHoverEvent /**event*/)
{
m_hovered = true;
update();

View File

@ -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);
@ -320,7 +322,7 @@ protected:
void mousePressEvent(QGraphicsSceneMouseEvent* event);
void hoverMoveEvent(QGraphicsSceneHoverEvent* event);
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
void hoverEnterEvent(QGraphicsSceneHoverEvent);
void mouseMoveEvent(QGraphicsSceneMouseEvent* event);
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event);

View File

@ -176,7 +176,7 @@ public:
bool isOwned() const {return true;}
bool isEditable() const {return true;}
bool isRemovable() const {return true;}
void invalidate(IDataSource::DatasourceMode mode, bool dbWillBeClosed){ updateModel();}
void invalidate(IDataSource::DatasourceMode /*mode*/, bool /*dbWillBeClosed*/){ updateModel();}
void update(){ updateModel(); }
void clearErrors(){}
private:

View File

@ -525,6 +525,7 @@ void DataSourceManager::addQuery(const QString &name, const QString &sqlText, co
putQueryDesc(queryDecs);
putHolder(name,new QueryHolder(sqlText, connectionName, this));
m_hasChanges = true;
m_varToDataSource.clear();
emit datasourcesChanged();
}
@ -534,6 +535,7 @@ void DataSourceManager::addSubQuery(const QString &name, const QString &sqlText,
putSubQueryDesc(subQueryDesc);
putHolder(name,new SubQueryHolder(sqlText, connectionName, masterDatasource, this));
m_hasChanges = true;
m_varToDataSource.clear();
emit datasourcesChanged();
}
@ -1373,18 +1375,31 @@ void DataSourceManager::slotQueryTextChanged(const QString &queryName, const QSt
if (holder){
holder->setQueryText(queryText);
}
m_varToDataSource.clear();
}
void DataSourceManager::invalidateQueriesContainsVariable(const QString& variableName)
{
if (!variableIsSystem(variableName)){
foreach (const QString& datasourceName, dataSourceNames()){
QueryHolder* holder = dynamic_cast<QueryHolder*>(m_datasources.value(datasourceName));
if (holder){
QRegExp rx(QString(Const::NAMED_VARIABLE_RX).arg(variableName));
if (holder->queryText().contains(rx))
holder->invalidate(designTime()?IDataSource::DESIGN_MODE:IDataSource::RENDER_MODE);
if (m_varToDataSource.contains(variableName)){
foreach(QString datasourceName, m_varToDataSource.value(variableName)){
QueryHolder* holder = dynamic_cast<QueryHolder*>(m_datasources.value(datasourceName));
if (holder) holder->invalidate(designTime() ? IDataSource::DESIGN_MODE : IDataSource::RENDER_MODE);
}
} else {
QVector<QString> datasources;
foreach (const QString& datasourceName, dataSourceNames()){
QueryHolder* holder = dynamic_cast<QueryHolder*>(m_datasources.value(datasourceName));
if (holder){
QRegExp rx(QString(Const::NAMED_VARIABLE_RX).arg(variableName));
if (holder->queryText().contains(rx)){
holder->invalidate(designTime() ? IDataSource::DESIGN_MODE : IDataSource::RENDER_MODE);
datasources.append(datasourceName);
}
}
}
m_varToDataSource.insert(variableName, datasources);
}
}
}
@ -1413,6 +1428,8 @@ void DataSourceManager::slotCSVTextChanged(const QString &csvName, const QString
void DataSourceManager::clear(ClearMethod method)
{
m_varToDataSource.clear();
DataSourcesMap::iterator dit;
for( dit = m_datasources.begin(); dit != m_datasources.end(); ){
bool owned = (*dit)->isOwned() && (*dit)->isRemovable();

View File

@ -280,6 +280,9 @@ private:
QHash<QString,int> m_groupFunctionsExpressionsMap;
QVector<QString> m_groupFunctionsExpressions;
IDbCredentialsProvider* m_dbCredentialsProvider;
QMap< QString, QVector<QString> > m_varToDataSource;
bool m_hasChanges;
};

View File

@ -52,6 +52,7 @@ namespace LimeReport {
namespace Const{
int const DEFAULT_GRID_STEP = 1;
int const RESIZE_HANDLE_SIZE = 5;
int const SELECTION_PEN_SIZE = 1;
int const MINIMUM_ITEM_WIDTH = 2*RESIZE_HANDLE_SIZE;
@ -91,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);

View File

@ -83,8 +83,8 @@ PageDesignIntf::PageDesignIntf(QObject *parent):
m_executingGroupCommand(false),
m_settings(0),
m_selectionRect(0),
m_verticalGridStep(2),
m_horizontalGridStep(2),
m_verticalGridStep(Const::DEFAULT_GRID_STEP),
m_horizontalGridStep(Const::DEFAULT_GRID_STEP),
m_updating(false),
m_currentObjectIndex(1),
m_multiSelectStarted(false),
@ -278,8 +278,10 @@ void PageDesignIntf::setPageItem(PageItemDesignIntf::Ptr pageItem)
void PageDesignIntf::setPageItems(QList<PageItemDesignIntf::Ptr> pages)
{
m_currentPage = 0;
if (!m_pageItem.isNull()) {
removeItem(m_pageItem.data());
if (m_pageItem->scene() == this)
removeItem(m_pageItem.data());
m_pageItem.clear();
}
int curHeight = 0;
@ -302,6 +304,14 @@ void PageDesignIntf::setPageItems(QList<PageItemDesignIntf::Ptr> pages)
}
void PageDesignIntf::removePageItem(PageItemDesignIntf::Ptr pageItem)
{
if (m_pageItem == pageItem){
removeItem(m_pageItem.data());
m_pageItem.clear();
}
}
void PageDesignIntf::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
if (m_insertMode) {
@ -816,6 +826,7 @@ void PageDesignIntf::slotItemPropertyObjectNameChanged(const QString &oldName, c
if (oldName.compare(newName)!=0 && !m_executingCommand){
CommandIf::Ptr command = PropertyObjectNameChangedCommand::create(this, oldName, newName);
saveCommand(command, false);
emit itemPropertyObjectNameChanged(oldName, newName);
}
}
@ -1458,15 +1469,24 @@ void PageDesignIntf::sendToBack()
}
}
bool PageDesignIntf::selectionContainsBand(){
foreach(QGraphicsItem * item,selectedItems()){
BandDesignIntf *band = dynamic_cast<BandDesignIntf *>(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<BaseDesignIntf *>(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);
}
@ -1479,11 +1499,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<BaseDesignIntf *>(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<BandDesignIntf*>(bdItem->parent()))
{
bdItem->setPos(QPointF(dynamic_cast<BandDesignIntf*>(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);
}
@ -1496,11 +1524,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<BaseDesignIntf *>(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<BandDesignIntf*>(bdItem->parent())){
bdItem->setPos(QPointF((dynamic_cast<BandDesignIntf*>(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);
}
@ -1513,11 +1548,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<BaseDesignIntf *>(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);
}
@ -1530,11 +1570,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<BaseDesignIntf *>(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<BandDesignIntf*>(bdItem->parent())){
bdItem->setPos(QPointF(bdItem->pos().x(), dynamic_cast<BandDesignIntf*>(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);
}
@ -1547,11 +1593,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<BaseDesignIntf *>(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<BandDesignIntf*>(bdItem->parent())){
bdItem->setPos(QPointF(bdItem->pos().x(), (dynamic_cast<BandDesignIntf*>(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);
}
@ -2135,7 +2187,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());
}
}

View File

@ -113,6 +113,7 @@ namespace LimeReport {
PageItemDesignIntf *pageItem();
void setPageItem(PageItemDesignIntf::Ptr pageItem);
void setPageItems(QList<PageItemDesignIntf::Ptr> pages);
void removePageItem(PageItemDesignIntf::Ptr pageItem);
QList<PageItemDesignIntf::Ptr> pageItems(){return m_reportPages;}
bool isItemInsertMode();
@ -218,6 +219,7 @@ namespace LimeReport {
const QString& propertyName,
const QVariant& oldValue,
const QVariant& newValue);
void itemPropertyObjectNameChanged(const QString& oldName, const QString& newName);
void itemAdded(LimeReport::PageDesignIntf* page, LimeReport::BaseDesignIntf* item);
void itemRemoved(LimeReport::PageDesignIntf* page, LimeReport::BaseDesignIntf* item);
void bandAdded(LimeReport::PageDesignIntf* page, LimeReport::BandDesignIntf* band);
@ -281,6 +283,7 @@ namespace LimeReport {
void changeSelectedGroupProperty(const QString& name,const QVariant& value);
void activateItemToJoin(QRectF itemRect, QList<ItemProjections>& items);
void selectAllChildren(BaseDesignIntf* item);
bool selectionContainsBand();
private:
enum JoinType{Width, Height};
LimeReport::PageItemDesignIntf::Ptr m_pageItem;
@ -321,6 +324,7 @@ namespace LimeReport {
bool m_magneticMovement;
ReportSettings* m_reportSettings;
PageItemDesignIntf* m_currentPage;
};
class AbstractPageCommand : public CommandIf{

View File

@ -1011,7 +1011,7 @@ void PageItemDesignIntf::setGridStep(int value)
int PageItemDesignIntf::gridStep()
{
if (page()) return page()->horizontalGridStep();
else return 2;
else return Const::DEFAULT_GRID_STEP;
}
void PageItemDesignIntf::objectLoadFinished()

View File

@ -222,9 +222,9 @@ void PreviewReportWidget::lastPage()
void PreviewReportWidget::printPages(QPrinter* printer)
{
if (!d_ptr->m_reportPages.isEmpty())
ReportEnginePrivate::printReport(
d_ptr->m_report->printPages(
d_ptr->m_reportPages,
*printer
printer
);
foreach(PageItemDesignIntf::Ptr pageItem, d_ptr->m_reportPages){
d_ptr->m_previewPage->reactivatePageItem(pageItem);

View File

@ -42,6 +42,9 @@
#include <QFileDialog>
#include <QScrollBar>
#include <QDesktopWidget>
#include <QLabel>
#include <QMessageBox>
#include <QToolButton>
namespace LimeReport{
@ -51,6 +54,25 @@ PreviewReportWindow::PreviewReportWindow(ReportEngine *report, QWidget *parent,
m_scalePercentChanging(false)
{
ui->setupUi(this);
m_progressWidget = new QWidget(ui->statusbar);
QHBoxLayout* progressLayout = new QHBoxLayout();
progressLayout->setMargin(0);
progressLayout->addWidget(new QLabel(tr("Printing")));
m_progressBar = new QProgressBar(ui->statusbar);
m_progressBar->setMaximumWidth(100);
m_progressBar->setMaximumHeight(ui->statusbar->fontMetrics().height());
progressLayout->addWidget(m_progressBar);
QToolButton* tbCancel = new QToolButton();
tbCancel->setIcon(QIcon(":/report/images/closebox"));
tbCancel->setAutoRaise(true);
connect(tbCancel, SIGNAL(clicked(bool)), this, SLOT(slotCancelPrinting(bool)));
progressLayout->addWidget(tbCancel);
progressLayout->setSizeConstraint(QLayout::SetFixedSize);
m_progressWidget->setLayout(progressLayout);
m_progressWidget->setVisible(false);
ui->statusbar->addPermanentWidget(m_progressWidget);
setWindowTitle("Lime Report Preview");
m_pagesNavigator = new QSpinBox(this);
m_pagesNavigator->setMaximum(10000000);
@ -73,6 +95,10 @@ PreviewReportWindow::PreviewReportWindow(ReportEngine *report, QWidget *parent,
connect(m_previewReportWidget, SIGNAL(onSave(bool&, LimeReport::IPreparedPages*)),
this, SIGNAL(onSave(bool&, LimeReport::IPreparedPages*)));
connect(m_previewReportWidget->d_ptr->m_report, SIGNAL(printingStarted(int)), this, SLOT(slotPrintingStarted(int)));
connect(m_previewReportWidget->d_ptr->m_report, SIGNAL(pagePrintingFinished(int)), this, SLOT(slotPagePrintingFinished(int)));
connect(m_previewReportWidget->d_ptr->m_report, SIGNAL(printingFinished()), this, SLOT(slotPrintingFinished()));
m_fontEditor = new FontEditorWidgetForPage(m_previewReportWidget->d_ptr->m_previewPage,tr("Font"),this);
m_fontEditor->setObjectName("fontTools");
m_fontEditor->setIconSize(ui->toolBar->iconSize());
@ -189,6 +215,10 @@ void PreviewReportWindow::setMenuVisible(bool value)
void PreviewReportWindow::setHideResultEditButton(bool value)
{
ui->actionEdit_Mode->setVisible(value);
if (!value && ui->editModeTools) {
delete ui->editModeTools;
ui->editModeTools = 0;
}
}
void PreviewReportWindow::setHidePrintButton(bool value)
@ -256,8 +286,12 @@ void PreviewReportWindow::exec()
if (deleteOnClose) delete this;
}
void PreviewReportWindow::closeEvent(QCloseEvent *)
void PreviewReportWindow::closeEvent(QCloseEvent* e)
{
if (m_progressBar->isVisible()){
QMessageBox::critical(this, tr("Attention"), tr("The printing is in process"));
e->setAccepted(false);
}
#ifdef Q_OS_WIN
writeSetting();
#endif
@ -292,7 +326,8 @@ void PreviewReportWindow::moveEvent(QMoveEvent* e)
void PreviewReportWindow::showEvent(QShowEvent *)
{
m_fontEditor->setVisible(ui->actionEdit_Mode->isChecked());
ui->editModeTools->setVisible(false);
if (ui->editModeTools)
ui->editModeTools->setVisible(false);
m_textAlignmentEditor->setVisible(ui->actionEdit_Mode->isChecked());
switch (m_previewScaleType) {
case FitWidth:
@ -500,7 +535,7 @@ void PreviewReportWindow::on_actionShow_Toolbar_triggered()
writeSetting();
}
void PreviewReportWindow::slotCurrentPageChanged(int page)
void PreviewReportWindow::slotCurrentPageChanged(int /*page*/)
{
slotActivateItemSelectionMode();
}
@ -510,5 +545,27 @@ void PreviewReportWindow::slotItemInserted(PageDesignIntf *, QPointF, const QStr
slotActivateItemSelectionMode();
}
void PreviewReportWindow::slotPrintingStarted(int pageCount)
{
m_progressBar->setMinimum(1);
m_progressBar->setMaximum(pageCount);
m_progressWidget->setVisible(true);
}
void PreviewReportWindow::slotPagePrintingFinished(int pageIndex)
{
m_progressBar->setValue(pageIndex);
}
void PreviewReportWindow::slotPrintingFinished()
{
m_progressWidget->setVisible(false);
}
void PreviewReportWindow::slotCancelPrinting(bool)
{
m_previewReportWidget->d_ptr->m_report->cancelPrinting();
}
}// namespace LimeReport

View File

@ -37,6 +37,7 @@
#include <QSettings>
#include <QEventLoop>
#include <QPrinter>
#include <QProgressBar>
#include "serializators/lrxmlreader.h"
#include "lrpreparedpagesintf.h"
@ -118,6 +119,10 @@ private slots:
void on_actionShow_Toolbar_triggered();
void slotCurrentPageChanged(int page);
void slotItemInserted(LimeReport::PageDesignIntf* report, QPointF pos, const QString& ItemType);
void slotPrintingStarted(int pageCount);
void slotPagePrintingFinished(int pageIndex);
void slotPrintingFinished();
void slotCancelPrinting(bool);
signals:
void onSave(bool& saved, LimeReport::IPreparedPages* pages);
private:
@ -139,6 +144,8 @@ private:
ScaleType m_previewScaleType;
int m_previewScalePercent;
bool m_scalePercentChanging;
QProgressBar* m_progressBar;
QWidget* m_progressWidget;
};
} //namespace LimeReport
#endif // LRPREVIEWREPORTWINDOW_H

View File

@ -60,7 +60,7 @@
<widget class="QStatusBar" name="statusbar"/>
<widget class="QToolBar" name="toolBar">
<property name="windowTitle">
<string>toolBar</string>
<string>MainToolBar</string>
</property>
<property name="iconSize">
<size>
@ -98,7 +98,7 @@
<bool>true</bool>
</property>
<property name="windowTitle">
<string>toolBar_2</string>
<string>EditModeTools</string>
</property>
<attribute name="toolBarArea">
<enum>LeftToolBarArea</enum>

View File

@ -287,30 +287,31 @@ void ReportDesignWidget::loadState()
applySettings();
}
PageView* ReportDesignWidget::createPageView(PageDesignIntf* page){
PageView* view = new PageView(this);
view->setBackgroundBrush(QBrush(Qt::gray));
view->setFrameShape(QFrame::NoFrame);
view->setScene(page);
view->setPageItem(page->pageItem());
view->scale(0.5, 0.5);
view->centerOn(0, 0);
return view;
}
void ReportDesignWidget::createTabs(){
m_tabWidget->clear();
int pageIndex = -1;
for (int i = 0; i < m_report->pageCount(); ++i){
PageView* view = new PageView(qobject_cast<QWidget*>(this));
view->setBackgroundBrush(QBrush(Qt::gray));
view->setFrameShape(QFrame::NoFrame);
view->setScene(m_report->pageAt(i));
view->setPageItem(m_report->pageAt(i)->pageItem());
m_report->pageAt(i)->clearSelection();
view->centerOn(0,0);
view->scale(0.5,0.5);
connectPage(m_report->pageAt(i));
pageIndex = m_tabWidget->addTab(view,QIcon(),m_report->pageAt(i)->pageItem()->objectName());
PageDesignIntf* page = m_report->pageAt(i);
page->clearSelection();
connectPage(page);
PageView* view = createPageView(page);
int pageIndex = m_tabWidget->addTab(view, QIcon(), page->pageItem()->objectName());
m_tabWidget->setTabWhatsThis(pageIndex, "page");
connect(m_report->pageAt(i)->pageItem(), SIGNAL(propertyObjectNameChanged(QString,QString)),
this, SLOT(slotPagePropertyObjectNameChanged(QString,QString)));
}
m_scriptEditor = new ScriptEditor(this);
connect(m_scriptEditor, SIGNAL(textChanged()), this, SLOT(slotScriptTextChanged()));
m_scriptEditor->setReportEngine(m_report);
pageIndex = m_tabWidget->addTab(m_scriptEditor,QIcon(),tr("Script"));
@ -359,25 +360,29 @@ QGraphicsView* ReportDesignWidget::activeView(){
void ReportDesignWidget::connectPage(PageDesignIntf *page)
{
connect(page,SIGNAL(itemInserted(LimeReport::PageDesignIntf*,QPointF,QString)),this,SIGNAL(itemInserted(LimeReport::PageDesignIntf*,QPointF,QString)));
connect(page,SIGNAL(itemInsertCanceled(QString)),this,SIGNAL(itemInsertCanceled(QString)));
connect(page,SIGNAL(itemPropertyChanged(QString,QString,QVariant,QVariant)),this,SIGNAL(itemPropertyChanged(QString,QString,QVariant,QVariant)));
connect(page,SIGNAL(selectionChanged()),this,SLOT(slotSelectionChanged()));
connect(page,SIGNAL(insertModeStarted()),this,SIGNAL(insertModeStarted()));
connect(page,SIGNAL(commandHistoryChanged()),this,SIGNAL(commandHistoryChanged()));
connect(page,SIGNAL(sceneRectChanged(QRectF)),this,SLOT(slotSceneRectChanged(QRectF)));
connect(page,SIGNAL(itemAdded(LimeReport::PageDesignIntf*,LimeReport::BaseDesignIntf*)),
this, SIGNAL(itemAdded(LimeReport::PageDesignIntf*,LimeReport::BaseDesignIntf*)));
connect(page,SIGNAL(itemRemoved(LimeReport::PageDesignIntf*,LimeReport::BaseDesignIntf*)),
this,SIGNAL(itemDeleted(LimeReport::PageDesignIntf*,LimeReport::BaseDesignIntf*)));
connect(page,SIGNAL(bandAdded(LimeReport::PageDesignIntf*,LimeReport::BandDesignIntf*)),
this, SIGNAL(bandAdded(LimeReport::PageDesignIntf*,LimeReport::BandDesignIntf*)));
connect(page, SIGNAL(bandRemoved(LimeReport::PageDesignIntf*,LimeReport::BandDesignIntf*)),
this, SIGNAL(bandDeleted(LimeReport::PageDesignIntf*,LimeReport::BandDesignIntf*)));
connect(page, SIGNAL(itemInserted(LimeReport::PageDesignIntf*, QPointF, QString)),
this, SIGNAL(itemInserted(LimeReport::PageDesignIntf*, QPointF, QString)));
connect(page, SIGNAL(itemInsertCanceled(QString)),this,SIGNAL(itemInsertCanceled(QString)));
connect(page, SIGNAL(itemPropertyChanged(QString, QString, QVariant, QVariant)),
this, SIGNAL(itemPropertyChanged(QString, QString, QVariant, QVariant)));
connect(page, SIGNAL(itemPropertyObjectNameChanged(QString, QString)),
this, SLOT(slotItemPropertyObjectNameChanged(QString, QString)));
connect(page, SIGNAL(selectionChanged()), this, SLOT(slotSelectionChanged()));
connect(page, SIGNAL(insertModeStarted()), this, SIGNAL(insertModeStarted()));
connect(page, SIGNAL(commandHistoryChanged()), this, SIGNAL(commandHistoryChanged()));
connect(page, SIGNAL(sceneRectChanged(QRectF)), this, SLOT(slotSceneRectChanged(QRectF)));
connect(page, SIGNAL(itemAdded(LimeReport::PageDesignIntf*, LimeReport::BaseDesignIntf*)),
this, SIGNAL(itemAdded(LimeReport::PageDesignIntf*, LimeReport::BaseDesignIntf*)));
connect(page, SIGNAL(itemRemoved(LimeReport::PageDesignIntf*, LimeReport::BaseDesignIntf*)),
this, SIGNAL(itemDeleted(LimeReport::PageDesignIntf*, LimeReport::BaseDesignIntf*)));
connect(page, SIGNAL(bandAdded(LimeReport::PageDesignIntf*, LimeReport::BandDesignIntf*)),
this, SIGNAL(bandAdded(LimeReport::PageDesignIntf*, LimeReport::BandDesignIntf*)));
connect(page, SIGNAL(bandRemoved(LimeReport::PageDesignIntf*, LimeReport::BandDesignIntf*)),
this, SIGNAL(bandDeleted(LimeReport::PageDesignIntf*, LimeReport::BandDesignIntf*)));
connect(page, SIGNAL(pageUpdateFinished(LimeReport::PageDesignIntf*)),
this, SIGNAL(activePageUpdated(LimeReport::PageDesignIntf*)));
connect(page->pageItem(), SIGNAL(propertyObjectNameChanged(QString, QString)),
this, SLOT(slotPagePropertyObjectNameChanged(QString, QString)));
emit activePageChanged();
}
@ -721,7 +726,10 @@ void ReportDesignWidget::previewReport()
#ifdef HAVE_QTDESIGNER_INTEGRATION
updateDialogs();
#endif
bool showProgressDialog = report()->isShowProgressDialog();
report()->setShowProgressDialog(false);
report()->previewReport();
report()->setShowProgressDialog(showProgressDialog);
}
void ReportDesignWidget::printReport()
@ -737,19 +745,13 @@ void ReportDesignWidget::printReport()
void ReportDesignWidget::addPage()
{
QGraphicsView* view = new QGraphicsView(qobject_cast<QWidget*>(this));
view->setBackgroundBrush(QBrush(Qt::gray));
view->setFrameShape(QFrame::NoFrame);
PageDesignIntf* page = m_report->appendPage("page"+QString::number(m_report->pageCount()+1));
view->setScene(page);
int index = m_report->pageCount()-1;
m_tabWidget->insertTab(index,view,QIcon(),page->pageItem()->objectName());
m_tabWidget->setCurrentIndex(index);
connect(page->pageItem(), SIGNAL(propertyObjectNameChanged(QString,QString)),
this, SLOT(slotPagePropertyObjectNameChanged(QString,QString)));
connectPage(page);
view->scale(0.5,0.5);
view->centerOn(0,0);
PageView* view = createPageView(page);
int index = m_report->pageCount()-1;
m_tabWidget->insertTab(index, view, QIcon(), page->pageItem()->objectName());
m_tabWidget->setTabWhatsThis(index, "page");
m_tabWidget->setCurrentIndex(index);
applyUseGrid();
emit pageAdded(page);
}
@ -821,9 +823,9 @@ void ReportDesignWidget::editSetting()
void ReportDesignWidget::applyUseGrid()
{
int hGridStep = m_useGrid?m_horizontalGridStep:2;
int vGridStep = m_useGrid?m_verticalGridStep:2;
for(int i=0;i<m_report->pageCount();++i){
int hGridStep = m_useGrid ? m_horizontalGridStep : Const::DEFAULT_GRID_STEP;
int vGridStep = m_useGrid ? m_verticalGridStep : Const::DEFAULT_GRID_STEP;
for(int i = 0; i < m_report->pageCount(); ++i){
m_report->pageAt(i)->setVerticalGridStep(hGridStep);
m_report->pageAt(i)->setHorizontalGridStep(vGridStep);
}
@ -968,6 +970,18 @@ void ReportDesignWidget::slotScriptTextChanged()
m_report->scriptContext()->setInitScript(m_scriptEditor->toPlainText());
}
void ReportDesignWidget::slotItemPropertyObjectNameChanged(const QString& oldName, const QString& newName)
{
PageDesignIntf* page = qobject_cast<PageDesignIntf*>(sender());
if (page){
ITranslationContainer* tc = dynamic_cast<ITranslationContainer*>(report());
for (int i = 0; i < tc->translations()->values().count(); ++i){
PageTranslation* pt = tc->translations()->values().at(i)->findPageTranslation(page->pageItem()->objectName());
if (pt) pt->renameItem(oldName, newName);
}
}
}
#ifdef HAVE_QTDESIGNER_INTEGRATION
void ReportDesignWidget::addNewDialog()
@ -999,6 +1013,11 @@ void ReportDesignWidget::slotDialogNameChanged(QString oldName, QString newName)
void ReportDesignWidget::slotPagePropertyObjectNameChanged(const QString &oldValue, const QString &newValue)
{
ITranslationContainer* tc = dynamic_cast<ITranslationContainer*>(report());
foreach(ReportTranslation* translation, tc->translations()->values()){
translation->renamePage(oldValue, newValue);
}
for (int i = 0; i < m_tabWidget->count(); ++i ){
if (m_tabWidget->tabText(i).compare(oldValue) == 0){
QGraphicsView* view = dynamic_cast<QGraphicsView*>(m_tabWidget->widget(i));
@ -1071,14 +1090,16 @@ bool PageView::viewportEvent(QEvent *event)
{
switch (event->type()) {
case QEvent::MouseMove:
m_horizontalRuller->setMousePos(dynamic_cast<QMouseEvent*>(event)->pos());
m_verticalRuller->setMousePos(dynamic_cast<QMouseEvent*>(event)->pos());
m_horizontalRuller->update();
m_verticalRuller->update();
if (m_horizontalRuller && m_verticalRuller){
m_horizontalRuller->setMousePos(dynamic_cast<QMouseEvent*>(event)->pos());
m_verticalRuller->setMousePos(dynamic_cast<QMouseEvent*>(event)->pos());
m_horizontalRuller->update();
m_verticalRuller->update();
}
break;
//case QEvent::Resize:
case QEvent::Paint:
if (m_horizontalRuller){
if (m_horizontalRuller && m_verticalRuller){
int x = mapFromScene(m_pageItem->boundingRect().x(),m_pageItem->boundingRect().y()).x();
int y = mapFromScene(m_pageItem->boundingRect().x(),m_pageItem->boundingRect().y()).y();
int width = mapFromScene(m_pageItem->boundingRect().bottomRight().x(),m_pageItem->boundingRect().bottomRight().y()).x();

View File

@ -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)
{
@ -216,6 +216,7 @@ private slots:
void slotCurrentTabChanged(int index);
void slotReportLoaded();
void slotScriptTextChanged();
void slotItemPropertyObjectNameChanged(const QString& oldName, const QString& newName);
#ifdef HAVE_QTDESIGNER_INTEGRATION
void slotDialogChanged(QString);
void slotDialogNameChanged(QString oldName, QString newName);
@ -241,6 +242,7 @@ signals:
void pageAdded(PageDesignIntf* page);
void pageDeleted();
protected:
PageView *createPageView(PageDesignIntf *page);
#ifdef HAVE_QTDESIGNER_INTEGRATION
void createNewDialogTab(const QString& dialogName,const QByteArray& description);
#endif
@ -275,6 +277,7 @@ private:
QMap<QString, QString> m_themes;
QMap<QString, QString> m_localToEng;
BaseDesignIntf::UnitType m_defaultUnits;
};
} // namespace LimeReport

View File

@ -65,6 +65,38 @@ namespace LimeReport{
ReportDesignWindow* ReportDesignWindow::m_instance=0;
void ReportDesignWindow::createProgressBar()
{
m_progressWidget = new QWidget(m_statusBar);
QHBoxLayout* progressLayout = new QHBoxLayout();
progressLayout->setMargin(0);
m_progressLabel = new QLabel(tr("Rendered %1 pages").arg(0));
progressLayout->addWidget(m_progressLabel);
m_progressBar = new QProgressBar(m_statusBar);
m_progressBar->setFormat("%v pages");
m_progressBar->setAlignment(Qt::AlignCenter);
m_progressBar->setMaximumWidth(100);
m_progressBar->setMaximumHeight(m_statusBar->fontMetrics().height());
m_progressBar->setMinimum(0);
m_progressBar->setMaximum(0);
m_progressBar->setTextVisible(true);
progressLayout->addWidget(m_progressBar);
QToolButton* tbCancel = new QToolButton();
tbCancel->setToolTip(tr("Cancel report rendering"));
tbCancel->setIcon(QIcon(":/report/images/closebox"));
tbCancel->setAutoRaise(true);
connect(tbCancel, SIGNAL(clicked(bool)), this, SLOT(slotCancelRendering(bool)));
progressLayout->addWidget(tbCancel);
progressLayout->setSizeConstraint(QLayout::SetFixedSize);
m_progressWidget->setLayout(progressLayout);
m_progressWidget->setVisible(false);
m_statusBar->addPermanentWidget(m_progressWidget);
connect(dynamic_cast<QObject*>(m_reportDesignWidget->report()), SIGNAL(renderStarted()), this, SLOT(renderStarted()));
connect(dynamic_cast<QObject*>(m_reportDesignWidget->report()), SIGNAL(renderPageFinished(int)), this, SLOT(renderPageFinished(int)));
connect(dynamic_cast<QObject*>(m_reportDesignWidget->report()), SIGNAL(renderFinished()), this, SLOT(renderFinished()));
}
ReportDesignWindow::ReportDesignWindow(ReportEnginePrivateInterface* report, QWidget *parent, QSettings* settings) :
ReportDesignWindowInterface(parent), m_textAttibutesIsChanging(false), m_settings(settings), m_ownedSettings(false),
m_progressDialog(0), m_showProgressDialog(true), m_editorTabType(ReportDesignWidget::Page), m_reportItemIsLocked(false)
@ -77,6 +109,7 @@ ReportDesignWindow::ReportDesignWindow(ReportEnginePrivateInterface* report, QWi
createDataWindow();
createScriptWindow();
createObjectsBrowser();
#ifdef HAVE_QTDESIGNER_INTEGRATION
createDialogWidgetBox();
createDialogPropertyEditor();
@ -100,7 +133,8 @@ ReportDesignWindow::ReportDesignWindow(ReportEnginePrivateInterface* report, QWi
showDefaultToolBars();
restoreSetting();
m_hideLeftPanel->setChecked(isDockAreaVisible(Qt::LeftDockWidgetArea));
m_hideRightPanel->setChecked(isDockAreaVisible(Qt::RightDockWidgetArea));
m_hideRightPanel->setChecked(isDockAreaVisible(Qt::RightDockWidgetArea));
createProgressBar();
}
ReportDesignWindow::~ReportDesignWindow()
@ -515,9 +549,6 @@ void ReportDesignWindow::initReportEditor(ReportEnginePrivateInterface* report)
this, SLOT(slotBandAdded(LimeReport::PageDesignIntf*,LimeReport::BandDesignIntf*)));
connect(m_reportDesignWidget, SIGNAL(bandDeleted(LimeReport::PageDesignIntf*,LimeReport::BandDesignIntf*)),
this, SLOT(slotBandDeleted(LimeReport::PageDesignIntf*,LimeReport::BandDesignIntf*)));
connect(dynamic_cast<QObject*>(report), SIGNAL(renderStarted()), this, SLOT(renderStarted()));
connect(dynamic_cast<QObject*>(report), SIGNAL(renderPageFinished(int)), this, SLOT(renderPageFinished(int)));
connect(dynamic_cast<QObject*>(report), SIGNAL(renderFinished()), this, SLOT(renderFinished()));
connect(m_reportDesignWidget, SIGNAL(pageAdded(PageDesignIntf*)), this, SLOT(slotPageAdded(PageDesignIntf*)));
connect(m_reportDesignWidget, SIGNAL(pageDeleted()), this, SLOT(slotPageDeleted()));
}
@ -1377,26 +1408,17 @@ void ReportDesignWindow::slotActivePageChanged()
void ReportDesignWindow::renderStarted()
{
if (m_showProgressDialog){
m_progressDialog = new QProgressDialog(tr("Rendering report"),tr("Abort"),0,0,this);
m_progressDialog->open(dynamic_cast<QObject*>(m_reportDesignWidget->report()), SLOT(cancelRender()));
QApplication::processEvents();
}
m_progressWidget->setVisible(true);
}
void ReportDesignWindow::renderPageFinished(int renderedPageCount)
{
if (m_progressDialog)
m_progressDialog->setLabelText(QString::number(renderedPageCount)+tr(" page rendered"));
m_progressLabel->setText(tr("Rendered %1 pages").arg(renderedPageCount));
}
void ReportDesignWindow::renderFinished()
{
if (m_progressDialog){
m_progressDialog->close();
delete m_progressDialog;
}
m_progressDialog = 0;
m_progressWidget->setVisible(false);
}
void ReportDesignWindow::slotShowAbout()
@ -1536,8 +1558,18 @@ void ReportDesignWindow::slotSelectOneLevelItems()
m_reportDesignWidget->selectOneLevelItems();
}
void ReportDesignWindow::slotCancelRendering(bool)
{
m_reportDesignWidget->report()->cancelRender();
}
void ReportDesignWindow::closeEvent(QCloseEvent * event)
{
if (m_progressWidget->isVisible()){
QMessageBox::critical(this, tr("Attention"), tr("The rendering is in process"));
event->ignore();
return;
}
if (checkNeedToSave()){
m_dataBrowser->closeAllDataWindows();
writeState();

View File

@ -128,6 +128,8 @@ private slots:
void slotLockSelectedItems();
void slotUnlockSelectedItems();
void slotSelectOneLevelItems();
void slotCancelRendering(bool);
protected:
void closeEvent(QCloseEvent *event);
void resizeEvent(QResizeEvent *);
@ -281,6 +283,12 @@ private:
QMap<QDockWidget*, bool> m_leftDocVisibleState;
QMap<QDockWidget*, bool> m_rightDocVisibleState;
QSortFilterProxyModel* m_filterModel;
QWidget* m_progressWidget;
QProgressBar* m_progressBar;
QLabel* m_progressLabel;
void createProgressBar();
};
class ObjectNameValidator : public ValidatorIntf{

View File

@ -224,9 +224,11 @@ void ReportEnginePrivate::showError(QString message)
void ReportEnginePrivate::updateTranslations()
{
foreach(ReportTranslation* translation, m_translations.values()){
translation->invalidatePages();
foreach(PageDesignIntf* page, m_pages){
translation->updatePageTranslation(page);
}
translation->clearInvalidPages();
}
}
@ -262,63 +264,80 @@ void ReportEnginePrivate::clearReport()
emit cleared();
}
void ReportEnginePrivate::printReport(ItemsReaderIntf::Ptr reader, QPrinter& printer)
bool ReportEnginePrivate::printPages(ReportPages pages, QPrinter *printer)
{
LimeReport::PageDesignIntf renderPage;
renderPage.setItemMode(PrintMode);
if (reader->first()){
reader->readItem(renderPage.pageItem());
printer.setFullPage(renderPage.pageItem()->fullPage());
printer.setOrientation((QPrinter::Orientation)renderPage.pageItem()->pageOrientation());
renderPage.setSceneRect(renderPage.pageItem()->mapToScene(renderPage.pageItem()->rect()).boundingRect());
if (renderPage.pageItem()->pageSize()==PageItemDesignIntf::Custom){
QSizeF pageSize = (renderPage.pageItem()->pageOrientation()==PageItemDesignIntf::Landscape)?
QSizeF(renderPage.pageItem()->sizeMM().height(),renderPage.pageItem()->sizeMM().width()):
renderPage.pageItem()->sizeMM();
printer.setPaperSize(pageSize,QPrinter::Millimeter);
} else {
printer.setPaperSize((QPrinter::PageSize)renderPage.pageItem()->pageSize());
}
QPainter painter(&printer);
renderPage.render(&painter);
while (reader->next()){
printer.newPage();
renderPage.removeAllItems();
reader->readItem(renderPage.pageItem());
renderPage.setSceneRect(renderPage.pageItem()->mapToScene(renderPage.pageItem()->rect()).boundingRect());
renderPage.render(&painter);
}
if (!printer&&!m_printerSelected){
QPrinterInfo pi;
if (!pi.defaultPrinter().isNull())
#ifdef HAVE_QT4
m_printer.data()->setPrinterName(pi.defaultPrinter().printerName());
#endif
#ifdef HAVE_QT5
#if (QT_VERSION >= QT_VERSION_CHECK(5, 3, 0))
m_printer.data()->setPrinterName(pi.defaultPrinterName());
#else
m_printer.data()->setPrinterName(pi.defaultPrinter().printerName());
#endif
#endif
QPrintDialog dialog(m_printer.data(),QApplication::activeWindow());
m_printerSelected = dialog.exec()!=QDialog::Rejected;
}
if (!printer&&!m_printerSelected) return false;
printer =(printer)?printer:m_printer.data();
if (printer&&printer->isValid()){
try{
if (pages.count()>0){
internalPrintPages(
pages,
*printer
);
}
} catch(ReportError &exception){
saveError(exception.what());
}
return true;
} else return false;
}
void ReportEnginePrivate::printReport(ReportPages pages, QPrinter &printer)
void ReportEnginePrivate::internalPrintPages(ReportPages pages, QPrinter &printer)
{
int currenPage = 1;
QMap<QString, QSharedPointer<PrintProcessor>> printProcessors;
m_cancelPrinting = false;
QMap<QString, QSharedPointer<PrintProcessor> > printProcessors;
printProcessors.insert("default",QSharedPointer<PrintProcessor>(new PrintProcessor(&printer)));
int pageCount = (printer.printRange() == QPrinter::AllPages) ?
pages.size() :
printer.toPage() - printer.fromPage();
emit printingStarted(pageCount);
foreach(PageItemDesignIntf::Ptr page, pages){
if (
(printer.printRange() == QPrinter::AllPages) ||
if ( !m_cancelPrinting &&
((printer.printRange() == QPrinter::AllPages) ||
( (printer.printRange()==QPrinter::PageRange) &&
(currenPage>=printer.fromPage()) &&
(currenPage<=printer.toPage())
)
))
)
{
printProcessors["default"]->printPage(page);
currenPage++;
emit pagePrintingFinished(currenPage);
QApplication::processEvents();
}
currenPage++;
}
emit printingFinished();
}
void ReportEnginePrivate::printReport(ReportPages pages, QMap<QString, QPrinter*> printers, bool printToAllPrinters)
void ReportEnginePrivate::printPages(ReportPages pages, QMap<QString, QPrinter*> printers, bool printToAllPrinters)
{
if (printers.values().isEmpty()) return;
int currenPage = 1;
QMap<QString, QSharedPointer<PrintProcessor>> printProcessors;
m_cancelPrinting = false;
QMap<QString, QSharedPointer<PrintProcessor> > printProcessors;
for (int i = 0; i < printers.keys().count(); ++i) {
printProcessors.insert(printers.keys()[i],QSharedPointer<PrintProcessor>(new PrintProcessor(printers[printers.keys()[i]])));
}
@ -327,7 +346,12 @@ void ReportEnginePrivate::printReport(ReportPages pages, QMap<QString, QPrinter*
int currentPrinter = 0;
if (printProcessors.contains("default")) defaultProcessor = printProcessors["default"].data();
else defaultProcessor = printProcessors.values().at(0).data();
foreach(PageItemDesignIntf::Ptr page, pages){
emit printingStarted(pages.size());
for(int i = 0; i < pages.size(); ++i){
if (m_cancelPrinting) break;
PageItemDesignIntf::Ptr page = pages.at(i);
if (!printToAllPrinters){
if (printProcessors.contains(page->printerName()))
printProcessors[page->printerName()]->printPage(page);
@ -338,9 +362,11 @@ void ReportEnginePrivate::printReport(ReportPages pages, QMap<QString, QPrinter*
currentPrinter++;
else currentPrinter = 0;
}
currenPage++;
emit pagePrintingFinished(i+1);
QApplication::processEvents();
}
emit printingFinished();
}
QStringList ReportEnginePrivate::aviableReportTranslations()
@ -389,7 +415,7 @@ bool ReportEnginePrivate::printReport(QPrinter* printer)
ReportPages pages = renderToPages();
dataManager()->setDesignTime(designTime);
if (pages.count()>0){
printReport(pages,*printer);
internalPrintPages(pages, *printer);
}
} catch(ReportError &exception){
saveError(exception.what());
@ -406,7 +432,7 @@ bool ReportEnginePrivate::printReport(QMap<QString, QPrinter*> printers, bool pr
ReportPages pages = renderToPages();
dataManager()->setDesignTime(designTime);
if (pages.count()>0){
printReport(pages, printers, printToAllPrinters);
printPages(pages, printers, printToAllPrinters);
}
} catch(ReportError &exception){
saveError(exception.what());
@ -415,42 +441,6 @@ bool ReportEnginePrivate::printReport(QMap<QString, QPrinter*> printers, bool pr
return true;
}
bool ReportEnginePrivate::printPages(ReportPages pages, QPrinter *printer)
{
if (!printer&&!m_printerSelected){
QPrinterInfo pi;
if (!pi.defaultPrinter().isNull())
#ifdef HAVE_QT4
m_printer.data()->setPrinterName(pi.defaultPrinter().printerName());
#endif
#ifdef HAVE_QT5
#if (QT_VERSION >= QT_VERSION_CHECK(5, 3, 0))
m_printer.data()->setPrinterName(pi.defaultPrinterName());
#else
m_printer.data()->setPrinterName(pi.defaultPrinter().printerName());
#endif
#endif
QPrintDialog dialog(m_printer.data(),QApplication::activeWindow());
m_printerSelected = dialog.exec()!=QDialog::Rejected;
}
if (!printer&&!m_printerSelected) return false;
printer =(printer)?printer:m_printer.data();
if (printer&&printer->isValid()){
try{
if (pages.count()>0){
printReport(
pages,
*printer
);
}
} catch(ReportError &exception){
saveError(exception.what());
}
return true;
} else return false;
}
void ReportEnginePrivate::printToFile(const QString &fileName)
{
if (!fileName.isEmpty()){
@ -500,7 +490,7 @@ bool ReportEnginePrivate::exportReport(QString exporterName, const QString &file
return false;
}
bool ReportEnginePrivate::showPreviewWindow(ReportPages pages, PreviewHints hints)
bool ReportEnginePrivate::showPreviewWindow(ReportPages pages, PreviewHints hints, QPrinter* printer)
{
if (pages.count()>0){
Q_Q(ReportEngine);
@ -515,6 +505,7 @@ bool ReportEnginePrivate::showPreviewWindow(ReportPages pages, PreviewHints hint
w->setPages(pages);
w->setLayoutDirection(m_previewLayoutDirection);
w->setStyleSheet(styleSheet());
// w->setDefaultPrinter()
if (!dataManager()->errorsList().isEmpty()){
w->setErrorMessages(dataManager()->errorsList());
@ -550,14 +541,13 @@ void ReportEnginePrivate::previewReport(PreviewHints hints)
previewReport(0, hints);
}
void ReportEnginePrivate::previewReport(QPrinter *printer, PreviewHints hints)
void ReportEnginePrivate::previewReport(QPrinter* printer, PreviewHints hints)
{
// QTime start = QTime::currentTime();
try{
dataManager()->setDesignTime(false);
ReportPages pages = renderToPages();
dataManager()->setDesignTime(true);
showPreviewWindow(pages, hints);
showPreviewWindow(pages, hints, printer);
} catch (ReportError &exception){
saveError(exception.what());
showError(exception.what());
@ -723,7 +713,7 @@ bool ReportEnginePrivate::slotLoadFromFile(const QString &fileName)
}
EASY_END_BLOCK;
return true;
};
}
}
m_lastError = reader->lastError();
EASY_END_BLOCK;
@ -737,6 +727,11 @@ void ReportEnginePrivate::cancelRender()
m_reportRendering = false;
}
void ReportEnginePrivate::cancelPrinting()
{
m_cancelPrinting = true;
}
QGraphicsScene* ReportEngine::createPreviewScene(QObject* parent){
Q_D(ReportEngine);
return d->createPreviewScene(parent);
@ -980,7 +975,12 @@ IPreparedPages *ReportEnginePrivate::preparedPages(){
bool ReportEnginePrivate::showPreparedPages(PreviewHints hints)
{
return showPreviewWindow(m_preparedPages, hints);
return showPreparedPages(0, hints);
}
bool ReportEnginePrivate::showPreparedPages(QPrinter* defaultPrinter, PreviewHints hints)
{
return showPreviewWindow(m_preparedPages, hints, defaultPrinter);
}
bool ReportEnginePrivate::prepareReportPages()
@ -1380,6 +1380,12 @@ ReportEngine::ReportEngine(QObject *parent)
connect(d, SIGNAL(renderPageFinished(int)),
this, SIGNAL(renderPageFinished(int)));
connect(d, SIGNAL(renderFinished()), this, SIGNAL(renderFinished()));
connect(d, SIGNAL(printingStarted(int)), this, SIGNAL(printingStarted(int)));
connect(d, SIGNAL(pagePrintingFinished(int)),
this, SIGNAL(pagePrintingFinished(int)));
connect(d, SIGNAL(printingFinished()), this, SIGNAL(printingFinished()));
connect(d, SIGNAL(onSave(bool&)), this, SIGNAL(onSave(bool&)));
connect(d, SIGNAL(onSaveAs(bool&)), this, SIGNAL(onSaveAs(bool&)));
connect(d, SIGNAL(onLoad(bool&)), this, SIGNAL(onLoad(bool&)));
@ -1651,6 +1657,12 @@ void ReportEngine::setShowProgressDialog(bool value)
d->setShowProgressDialog(value);
}
bool ReportEngine::isShowProgressDialog()
{
Q_D(ReportEngine);
return d->isShowProgressDialog();
}
IDataSourceManager *ReportEngine::dataManager()
{
Q_D(ReportEngine);
@ -1740,6 +1752,12 @@ void ReportEngine::cancelRender()
d->cancelRender();
}
void ReportEngine::cancelPrinting()
{
Q_D(ReportEngine);
d->cancelPrinting();
}
ReportEngine::ReportEngine(ReportEnginePrivate &dd, QObject *parent)
:QObject(parent),d_ptr(&dd)
{
@ -1759,21 +1777,22 @@ ScriptEngineManager*LimeReport::ReportEnginePrivate::scriptManager(){
PrintProcessor::PrintProcessor(QPrinter* printer)
: m_printer(printer), m_painter(0), m_firstPage(true)
{}
{m_renderPage.setItemMode(PrintMode);}
bool PrintProcessor::printPage(PageItemDesignIntf::Ptr page)
{
if (!m_firstPage && !m_painter->isActive()) return false;
PageDesignIntf* backupPage = dynamic_cast<PageDesignIntf*>(page->scene());
LimeReport::PageDesignIntf renderPage;
renderPage.setItemMode(PrintMode);
//LimeReport::PageDesignIntf m_renderPage;
//m_renderPage.setItemMode(PrintMode);
QPointF backupPagePos = page->pos();
page->setPos(0,0);
renderPage.setPageItem(page);
renderPage.setSceneRect(renderPage.pageItem()->mapToScene(renderPage.pageItem()->rect()).boundingRect());
initPrinter(renderPage.pageItem());
m_renderPage.setPageItem(page);
m_renderPage.setSceneRect(m_renderPage.pageItem()->mapToScene(m_renderPage.pageItem()->rect()).boundingRect());
initPrinter(m_renderPage.pageItem());
if (!m_firstPage){
m_printer->newPage();
@ -1802,7 +1821,7 @@ bool PrintProcessor::printPage(PageItemDesignIntf::Ptr page)
while (pageHeight > 0){
while (curWidth < pageWidth){
if (!first) m_printer->newPage(); else first = false;
renderPage.render(m_painter, m_printer->pageRect(), currentPrintingRect);
m_renderPage.render(m_painter, m_printer->pageRect(), currentPrintingRect);
currentPrintingRect.adjust(printerPageRect.size().width(), 0, printerPageRect.size().width(), 0);
curWidth += printerPageRect.size().width();
@ -1815,9 +1834,11 @@ bool PrintProcessor::printPage(PageItemDesignIntf::Ptr page)
}
} else {
renderPage.render(m_painter);
m_renderPage.render(m_painter);
}
page->setPos(backupPagePos);
m_renderPage.removePageItem(page);
if (backupPage) backupPage->reactivatePageItem(page);
return true;
}

View File

@ -164,6 +164,7 @@ public:
void designReport();
ReportDesignWindowInterface* getDesignerWindow();
void setShowProgressDialog(bool value);
bool isShowProgressDialog();
IDataSourceManager* dataManager();
IScriptEngineManager* scriptManager();
bool loadFromFile(const QString& fileName, bool autoLoadPreviewOnChange = false);
@ -212,6 +213,11 @@ signals:
void renderStarted();
void renderFinished();
void renderPageFinished(int renderedPageCount);
void printingStarted(int pageCount);
void printingFinished();
void pagePrintingFinished(int index);
void onSave(bool& saved);
void onSaveAs(bool& saved);
void onLoad(bool& loaded);
@ -228,6 +234,7 @@ signals:
public slots:
void cancelRender();
void cancelPrinting();
protected:
ReportEnginePrivate * const d_ptr;
ReportEngine(ReportEnginePrivate &dd, QObject * parent=0);

View File

@ -110,6 +110,9 @@ public:
virtual QList<QLocale::Language> designerLanguages() = 0;
virtual QLocale::Language currentDesignerLanguage() = 0;
virtual void setCurrentDesignerLanguage(QLocale::Language language) = 0;
virtual void cancelRender() = 0;
virtual void setShowProgressDialog(bool value) = 0;
virtual bool isShowProgressDialog() const = 0;
};
class PrintProcessor{
@ -122,6 +125,7 @@ private:
private:
QPrinter* m_printer;
QPainter* m_painter;
LimeReport::PageDesignIntf m_renderPage;
bool m_firstPage;
};
@ -141,9 +145,8 @@ class ReportEnginePrivate : public QObject,
friend class PreviewReportWidget;
public:
static void printReport(ItemsReaderIntf::Ptr reader, QPrinter &printer);
static void printReport(ReportPages pages, QPrinter &printer);
static void printReport(ReportPages pages, QMap<QString,QPrinter*>printers, bool printToAllPrinters = false);
bool printPages(ReportPages pages, QPrinter *printer);
void printPages(ReportPages pages, QMap<QString,QPrinter*>printers, bool printToAllPrinters = false);
Q_INVOKABLE QStringList aviableReportTranslations();
Q_INVOKABLE void setReportTranslation(const QString& languageName);
public:
@ -168,7 +171,7 @@ public:
void clearReport();
bool printReport(QPrinter* printer=0);
bool printReport(QMap<QString, QPrinter*>printers, bool printToAllPrinters);
bool printPages(ReportPages pages, QPrinter *printer);
void printToFile(const QString& fileName);
bool printToPDF(const QString& fileName);
bool exportReport(QString exporterName, const QString &fileName = "", const QMap<QString, QVariant>& params = QMap<QString, QVariant>());
@ -179,6 +182,7 @@ public:
void designReport();
void setSettings(QSettings* value);
void setShowProgressDialog(bool value){m_showProgressDialog = value;}
bool isShowProgressDialog() const {return m_showProgressDialog;}
QSettings* settings();
bool loadFromFile(const QString& fileName, bool autoLoadPreviewOnChange);
bool loadFromByteArray(QByteArray *data, const QString& name = "");
@ -246,6 +250,7 @@ public:
void clearWatermarks();
IPreparedPages* preparedPages();
bool showPreparedPages(PreviewHints hints);
bool showPreparedPages(QPrinter *defaultPrinter, PreviewHints hints);
bool prepareReportPages();
bool printPreparedPages();
signals:
@ -267,13 +272,18 @@ signals:
void currentDefaultDesignerLanguageChanged(QLocale::Language);
QLocale::Language getCurrentDefaultDesignerLanguage();
void externalPaint(const QString& objectName, QPainter* painter, const QStyleOptionGraphicsItem*);
void printingStarted(int pageCount);
void printingFinished();
void pagePrintingFinished(int index);
public slots:
bool slotLoadFromFile(const QString& fileName);
void cancelRender();
void cancelPrinting();
protected:
PageDesignIntf* createPage(const QString& pageName="", bool preview = false);
bool showPreviewWindow(ReportPages pages, PreviewHints hints);
bool showPreviewWindow(ReportPages pages, PreviewHints hints, QPrinter *printer);
void internalPrintPages(ReportPages pages, QPrinter &printer);
protected slots:
void slotDataSourceCollectionLoaded(const QString& collectionName);
private slots:
@ -343,6 +353,7 @@ private:
bool m_saveToFileVisible;
bool m_printToPdfVisible;
bool m_printVisible;
bool m_cancelPrinting;
};
}

View File

@ -189,11 +189,46 @@ void ReportRender::initDatasource(const QString& name){
}
}
void ReportRender::renderPage(PageItemDesignIntf* patternPage, bool isTOC, bool isFirst, bool resetPageNumbers)
void ReportRender::analizeItem(ContentItemDesignIntf* contentItem, BandDesignIntf* band){
if (contentItem){
QString content = contentItem->content();
QVector<QString> functions;
foreach(const QString &functionName, m_datasources->groupFunctionNames()){
QRegExp rx(QString(Const::GROUP_FUNCTION_RX).arg(functionName));
rx.setMinimal(true);
if (rx.indexIn(content)>=0){
functions.append(functionName);
}
}
if (functions.size()>0)
m_groupfunctionItems.insert(contentItem->patternName(), functions);
}
}
void ReportRender::analizeContainer(BaseDesignIntf* item, BandDesignIntf* band){
foreach(BaseDesignIntf* child, item->childBaseItems()){
ContentItemDesignIntf* contentItem = dynamic_cast<ContentItemDesignIntf*>(child);
if (contentItem) analizeItem(contentItem, band);
else analizeContainer(child, band);
}
}
void ReportRender::analizePage(PageItemDesignIntf* patternPage){
m_groupfunctionItems.clear();
foreach(BandDesignIntf* band, patternPage->bands()){
if (band->isFooter() || band->isHeader()){
analizeContainer(band,band);
}
}
}
void ReportRender::renderPage(PageItemDesignIntf* patternPage, bool isTOC, bool /*isFirst*/, bool /*resetPageNumbers*/)
{
m_currentNameIndex = 0;
m_patternPageItem = patternPage;
analizePage(patternPage);
if (m_patternPageItem->resetPageNumber() && m_pageCount>0 && !isTOC) {
resetPageNumber(PageReset);
}
@ -380,33 +415,34 @@ void ReportRender::extractGroupFunctions(BandDesignIntf *band)
extractGroupFunctionsFromContainer(band, band);
}
void ReportRender::replaceGroupFunctionsInItem(ContentItemDesignIntf* contentItem, BandDesignIntf* band){
if (contentItem){
QString content = contentItem->content();
foreach(const QString &functionName, m_datasources->groupFunctionNames()){
QRegExp rx(QString(Const::GROUP_FUNCTION_RX).arg(functionName));
rx.setMinimal(true);
if (rx.indexIn(content)>=0){
int pos = 0;
while ( (pos = rx.indexIn(content,pos))!= -1 ){
QVector<QString> captures = normalizeCaptures(rx);
if (captures.size() >= 3){
QString expressionIndex = datasources()->putGroupFunctionsExpressions(captures.at(Const::VALUE_INDEX));
if (captures.size()<5){
content.replace(captures.at(0),QString("%1(%2,%3)").arg(functionName).arg('"'+expressionIndex+'"').arg('"'+band->objectName()+'"'));
} else {
content.replace(captures.at(0),QString("%1(%2,%3,%4)")
.arg(functionName)
.arg('"'+expressionIndex+'"')
.arg('"'+band->objectName()+'"')
.arg(captures.at(4)));
if (m_groupfunctionItems.contains(contentItem->patternName())){
QString content = contentItem->content();
foreach(QString functionName, m_groupfunctionItems.value(contentItem->patternName())){
QRegExp rx(QString(Const::GROUP_FUNCTION_RX).arg(functionName));
rx.setMinimal(true);
if (rx.indexIn(content)>=0){
int pos = 0;
while ( (pos = rx.indexIn(content,pos))!= -1 ){
QVector<QString> captures = normalizeCaptures(rx);
if (captures.size() >= 3){
QString expressionIndex = datasources()->putGroupFunctionsExpressions(captures.at(Const::VALUE_INDEX));
if (captures.size()<5){
content.replace(captures.at(0),QString("%1(%2,%3)").arg(functionName).arg('"'+expressionIndex+'"').arg('"'+band->objectName()+'"'));
} else {
content.replace(captures.at(0),QString("%1(%2,%3,%4)")
.arg(functionName)
.arg('"'+expressionIndex+'"')
.arg('"'+band->objectName()+'"')
.arg(captures.at(4)));
}
}
pos += rx.matchedLength();
}
pos += rx.matchedLength();
}
contentItem->setContent(content);
}
contentItem->setContent(content);
}
}
}

View File

@ -82,6 +82,7 @@ private:
int m_TOCRangeIndex;
};
class ReportRender: public QObject
{
Q_OBJECT
@ -109,6 +110,10 @@ signals:
public slots:
void cancelRender();
private:
void analizeContainer(BaseDesignIntf *item, BandDesignIntf *band);
void analizeItem(ContentItemDesignIntf *item, BandDesignIntf *band);
void analizePage(PageItemDesignIntf *patternPage);
void initDatasources();
void initDatasource(const QString &name);
void initRenderPage();
@ -116,7 +121,7 @@ private:
void initGroups();
void clearPageMap();
void renderPage(PageItemDesignIntf *patternPage, bool isTOC = false, bool isFirst = false, bool resetPageNumbers = false);
void renderPage(PageItemDesignIntf *patternPage, bool isTOC = false, bool isFirst = false, bool = false);
BandDesignIntf* renderBand(BandDesignIntf *patternBand, BandDesignIntf *bandData, DataRenderMode mode = NotStartNewPage, bool isLast = false);
void renderDataBand(BandDesignIntf* dataBand);
void renderPageHeader(PageItemDesignIntf* patternPage);
@ -193,7 +198,7 @@ private:
QMultiMap< BandDesignIntf*, GroupBandsHolder* > m_childBands;
QList<BandDesignIntf*> m_reprintableBands;
QList<BandDesignIntf*> m_recalcBands;
QMap<QString, QVector<QString> > m_groupfunctionItems;
int m_currentIndex;
int m_pageCount;
@ -217,6 +222,7 @@ private:
bool m_newPageStarted;
bool m_lostHeadersMoved;
};
} // namespace LimeReport
#endif // LRREPORTRENDER_H

View File

@ -32,6 +32,7 @@ ReportTranslation::~ReportTranslation()
PageTranslation* ReportTranslation::createPageTranslation(PageDesignIntf* page)
{
PageTranslation* pageTranslation = new PageTranslation;
pageTranslation->checked = true;
pageTranslation->pageName = page->pageItem()->objectName();
foreach(BaseDesignIntf* item, page->pageItem()->allChildBaseItems()){
createItemTranslation(item, pageTranslation);
@ -43,6 +44,7 @@ void ReportTranslation::createItemTranslation(BaseDesignIntf* item, PageTranslat
QMap<QString,QString> stringsForTranslation = item->getStringForTranslation();
if (!stringsForTranslation.isEmpty()){
ItemTranslation* itemTranslation = new ItemTranslation;
itemTranslation->checked = true;
itemTranslation->itemName = item->objectName();
foreach(QString propertyName, stringsForTranslation.keys()){
PropertyTranslation* propertyTranslation = new PropertyTranslation;
@ -57,16 +59,42 @@ void ReportTranslation::createItemTranslation(BaseDesignIntf* item, PageTranslat
}
}
PageTranslation* ReportTranslation::findPageTranslation(const QString& page_name)
PageTranslation* ReportTranslation::findPageTranslation(const QString& pageName)
{
foreach(PageTranslation* page, m_pagesTranslation){
if (page->pageName.compare(page_name) == 0){
if (page->pageName.compare(pageName) == 0){
return page;
}
}
return 0;
}
void ReportTranslation::renamePage(const QString &oldName, const QString &newName)
{
PageTranslation* page = findPageTranslation(oldName);
if (page){
page->pageName = newName;
}
}
void ReportTranslation::invalidatePages()
{
foreach(PageTranslation* page, m_pagesTranslation){
page->checked = false;
}
}
void ReportTranslation::clearInvalidPages()
{
QList<PageTranslation*>::Iterator it = m_pagesTranslation.begin();
while (it != m_pagesTranslation.end()){
if (!(*it)->checked){
delete *it;
it = m_pagesTranslation.erase(it);
} else ++it;
}
}
void ReportTranslation::updatePageTranslation(PageDesignIntf* page)
{
PageTranslation* pageTranslation = findPageTranslation(page->pageItem()->objectName());
@ -75,6 +103,10 @@ void ReportTranslation::updatePageTranslation(PageDesignIntf* page)
m_pagesTranslation.append(pageTranslation);
}
if (pageTranslation){
pageTranslation->checked = true;
foreach(ItemTranslation* item, pageTranslation->itemsTranslation){
item->checked = false;
}
foreach(BaseDesignIntf* item, page->pageItem()->allChildBaseItems()){
QMap<QString,QString> stringsForTranslation = item->getStringForTranslation();
if (!stringsForTranslation.isEmpty()){
@ -90,15 +122,23 @@ void ReportTranslation::updatePageTranslation(PageDesignIntf* page)
propertyTranslation->sourceValue = stringsForTranslation.value(propertyName);
if (!translated) propertyTranslation->value = propertyTranslation->sourceValue;
}
itemTranslation->checked = true;
} else {
createItemTranslation(item, pageTranslation);
}
}
}
QHash<QString, ItemTranslation*>::Iterator it = pageTranslation->itemsTranslation.begin();
while( it != pageTranslation->itemsTranslation.end()){
if (!it.value()->checked) {
delete it.value();
it = pageTranslation->itemsTranslation.erase(it);
} else ++it;
}
}
}
QList<PageTranslation*> ReportTranslation::pagesTranslation() const
QList<PageTranslation*>& ReportTranslation::pagesTranslation()
{
return m_pagesTranslation;
}
@ -139,4 +179,14 @@ PageTranslation::~PageTranslation()
}
}
void PageTranslation::renameItem(const QString &oldName, const QString &newName)
{
ItemTranslation* item = itemsTranslation.value(oldName);
if (item){
itemsTranslation.remove(oldName);
item->itemName = newName;
itemsTranslation[newName] = item;
}
}
} //namespace LimeReport

View File

@ -31,6 +31,7 @@ struct PropertyTranslation{
struct ItemTranslation{
QString itemName;
bool checked;
PropertyTranslation* findProperty(const QString& propertyName);
~ItemTranslation();
QList<PropertyTranslation*> propertyesTranslation;
@ -38,8 +39,10 @@ struct ItemTranslation{
struct PageTranslation{
QString pageName;
bool checked;
~PageTranslation();
QHash<QString,ItemTranslation*> itemsTranslation;
void renameItem(const QString& oldName, const QString& newName);
QHash<QString, ItemTranslation*> itemsTranslation;
};
class ReportTranslation{
@ -49,12 +52,15 @@ public:
ReportTranslation(const ReportTranslation& reportTranslation);
~ReportTranslation();
QLocale::Language language() const;
QList<PageTranslation*> pagesTranslation() const;
QList<PageTranslation *> &pagesTranslation();
PageTranslation* createEmptyPageTranslation();
void updatePageTranslation(PageDesignIntf* page);
PageTranslation* findPageTranslation(const QString& page_name);
void createItemTranslation(BaseDesignIntf* item, PageTranslation* pageTranslation);
PageTranslation* findPageTranslation(const QString& pageName);
void renamePage(const QString& oldName, const QString& newName);
void invalidatePages();
void clearInvalidPages();
private:
void createItemTranslation(BaseDesignIntf* item, PageTranslation* pageTranslation);
PageTranslation* createPageTranslation(PageDesignIntf* page);
private:
QLocale::Language m_language;

View File

@ -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; i<scriptExtractor.count();++i){
QString scriptBody = expandDataFields(scriptExtractor.bodyAt(i),EscapeSymbols, varValue, reportItem);
scriptBody = expandUserVariables(scriptBody, FirstPass, EscapeSymbols, varValue);
ScriptValueType value = se->evaluate(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 (curPos<m_context.length()){
switch (state) {
@ -990,13 +995,13 @@ bool ScriptExtractor::parse(int &curPos,const State& state)
return true;
} else {
if (m_context[curPos]=='{')
extractBracket(curPos);
extractBracket(curPos, scriptNode);
}
case None:
if (m_context[curPos]=='$'){
int startPos = curPos;
if (isStartScriptLexem(curPos))
extractScript(curPos,substring(m_context,startPos,curPos));
extractScript(curPos, substring(m_context,startPos,curPos), scriptNode->createChildNode());
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;

View File

@ -396,6 +396,47 @@ private:
QMap<QString, IWrapperCreator*> 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<ScriptNode*> children() const {return m_children;}
private:
QVector<ScriptNode*> 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<ScriptEngineManager>, 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<QString> m_scriptsBody;
QVector<QString> m_scriptsStartLex;
};
#ifdef USE_QTSCRIPTENGINE
class QFontPrototype : public QObject, public QScriptable {

View File

@ -163,6 +163,7 @@ void QObjectPropertyModel::translatePropertyName()
tr("units");
tr("geometryLocked");
tr("printBehavior");
tr("shiftItems");
}
void QObjectPropertyModel::clearObjectsList()

View File

@ -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

View File

@ -11,7 +11,8 @@ namespace LimeReport {
TranslationEditor::TranslationEditor(QWidget *parent) :
QWidget(parent),
ui(new Ui::TranslationEditor), m_translationContainer(0),
m_currentReportTranslation(0), m_currentPageTranslation(0), m_currentPropertyTranslation(0)
m_currentReportTranslation(0), m_currentPageTranslation(0),
m_currentPropertyTranslation(0), m_translationChanging(false)
{
ui->setupUi(this);
ui->splitter_3->setStretchFactor(1,10);
@ -78,11 +79,10 @@ void TranslationEditor::updateUi()
ui->lvLanguages->addItem(QLocale::languageToString(language));
}
if (!translations->keys().isEmpty()){
if (ui->lvLanguages->count()!=0){
if (ui->lvLanguages->count() != 0){
ui->lvLanguages->item(0)->setSelected(true);
activateLanguage(getLanguageByName(ui->lvLanguages->item(0)->text()));
} else {
//activateLanguage(QLocale::AnyLanguage);
ui->twPages->clear();
ui->tbStrings->setRowCount(0);
}
@ -93,7 +93,9 @@ void TranslationEditor::updateUi()
void TranslationEditor::activateLanguage(QLocale::Language language)
{
m_translationChanging = true;
ui->teTranslation->setEnabled(false);
ui->teTranslation->setPlainText("");
ui->cbChecked->setEnabled(false);
ui->twPages->clear();
Translations* translations = m_translationContainer->translations();
@ -113,6 +115,7 @@ void TranslationEditor::activateLanguage(QLocale::Language language)
activatePage(m_currentReportTranslation->findPageTranslation(ui->twPages->topLevelItem(0)->text(0)));
}
}
m_translationChanging = false;
}
void TranslationEditor::activatePage(PageTranslation* pageTranslation)
@ -171,13 +174,13 @@ void TranslationEditor::activateTranslation(const QString& itemName, const QStri
void TranslationEditor::on_tbStrings_itemSelectionChanged()
{
if (m_currentPageTranslation)
if (m_currentPageTranslation && !m_translationChanging)
activateTranslation(ui->tbStrings->item(ui->tbStrings->currentRow(),1)->text(), ui->tbStrings->item(ui->tbStrings->currentRow(),2)->text());
}
void TranslationEditor::on_teTranslation_textChanged()
{
if (m_currentPropertyTranslation)
if (m_currentPropertyTranslation && !m_translationChanging)
m_currentPropertyTranslation->value = ui->teTranslation->toPlainText();
}
@ -200,16 +203,23 @@ void TranslationEditor::on_tbAddLanguage_clicked()
{
LanguageSelectDialog dialog;
if (dialog.exec()){
m_translationChanging = true;
m_translationContainer->addTranslationLanguage(dialog.getSelectedLanguage());
updateUi();
activateLanguage(dialog.getSelectedLanguage());
foreach (QListWidgetItem* item, ui->lvLanguages->findItems(QLocale::languageToString(dialog.getSelectedLanguage()), Qt::MatchExactly)){
item->setSelected(true);
}
m_translationChanging = false;
}
}
void TranslationEditor::on_tbDeleteLanguage_clicked()
{
m_translationChanging = true;
m_translationContainer->removeTranslationLanguage(m_currentReportTranslation->language());
updateUi();
m_translationChanging = false;
}
void TranslationEditor::slotItemChecked()

View File

@ -45,6 +45,7 @@ private:
ReportTranslation* m_currentReportTranslation;
PageTranslation* m_currentPageTranslation;
PropertyTranslation* m_currentPropertyTranslation;
bool m_translationChanging;
};
} //namespace LimeReport

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

Binary file not shown.

View File

@ -55,6 +55,29 @@
<translation>Название ряда</translation>
</message>
</context>
<context>
<name>ImageItemEditor</name>
<message>
<source>Image Item Editor</source>
<translation>Редакор изображения</translation>
</message>
<message>
<source>Image</source>
<translation>Изображение</translation>
</message>
<message>
<source>...</source>
<translation>...</translation>
</message>
<message>
<source>Resource path</source>
<translation>Путь к русурсам</translation>
</message>
<message>
<source>Select image file</source>
<translation>Выбрать файл изображения</translation>
</message>
</context>
<context>
<name>LRVariableDialog</name>
<message>
@ -392,6 +415,10 @@ p, li { white-space: pre-wrap; }
<source>Copy</source>
<translation>Копировать</translation>
</message>
<message>
<source>Keep top space</source>
<translation>Сохранять отступ сверху</translation>
</message>
</context>
<context>
<name>LimeReport::BaseDesignIntf</name>
@ -433,7 +460,7 @@ p, li { white-space: pre-wrap; }
</message>
<message>
<source>Lock item geometry</source>
<translation>Блокировать изменения геометрии</translation>
<translation>Заблокировать геометрию элемента</translation>
</message>
</context>
<context>
@ -1003,11 +1030,11 @@ p, li { white-space: pre-wrap; }
</message>
<message>
<source>Scale</source>
<translation>Масштабировать</translation>
<translation>Масштаб</translation>
</message>
<message>
<source>Split</source>
<translation>Разделять на части</translation>
<translation>Разделить</translation>
</message>
</context>
<context>
@ -1130,6 +1157,10 @@ p, li { white-space: pre-wrap; }
<source>Watermark</source>
<translation>Водный знак</translation>
</message>
<message>
<source>Edit</source>
<translation>Правка</translation>
</message>
</context>
<context>
<name>LimeReport::ItemLocationPropItem</name>
@ -1249,7 +1280,7 @@ p, li { white-space: pre-wrap; }
</message>
<message>
<source>Translate properties</source>
<translation>Переводить имена свойств</translation>
<translation>Свойства перевода</translation>
</message>
</context>
<context>
@ -1329,10 +1360,6 @@ p, li { white-space: pre-wrap; }
<source>Report</source>
<translation>Отчет</translation>
</message>
<message>
<source>toolBar</source>
<translation>Панель инструментов</translation>
</message>
<message>
<source>Print</source>
<translation>Печать</translation>
@ -1433,10 +1460,6 @@ p, li { white-space: pre-wrap; }
<source>Show toolbar</source>
<translation>Показать панель инструментов</translation>
</message>
<message>
<source>toolBar_2</source>
<translation>Редактирование</translation>
</message>
<message>
<source>InsertTextItem</source>
<translation>Вставить текстовый элемент</translation>
@ -1457,6 +1480,26 @@ p, li { white-space: pre-wrap; }
<source>Del</source>
<translation>Удалить</translation>
</message>
<message>
<source>MainToolBar</source>
<translation>Основная панель инструментов</translation>
</message>
<message>
<source>EditModeTools</source>
<translation>Панель инструментов редактирования</translation>
</message>
<message>
<source>Printing</source>
<translation>Печатается</translation>
</message>
<message>
<source>Attention</source>
<translation>Внимание</translation>
</message>
<message>
<source>The printing is in process</source>
<translation>Отчет находится в процессе печати</translation>
</message>
</context>
<context>
<name>LimeReport::ProxyHolder</name>
@ -1881,7 +1924,7 @@ p, li { white-space: pre-wrap; }
</message>
<message>
<source>setPageSizeToPrinter</source>
<translation>Отправить параметры страницы в принтер</translation>
<translation>Оправитьпараметры страницы в принтер</translation>
</message>
<message>
<source>fillInSecondPass</source>
@ -1961,11 +2004,11 @@ p, li { white-space: pre-wrap; }
</message>
<message>
<source>option3</source>
<translation></translation>
<translation>Опция 3</translation>
</message>
<message>
<source>units</source>
<translation>Единицы измерения</translation>
<translation>Еденицы измерения</translation>
</message>
<message>
<source>geometryLocked</source>
@ -1973,7 +2016,11 @@ p, li { white-space: pre-wrap; }
</message>
<message>
<source>printBehavior</source>
<translation>Режим печати</translation>
<translation>Поведение при печати</translation>
</message>
<message>
<source>shiftItems</source>
<translation>Смещение элементов</translation>
</message>
</context>
<context>
@ -2227,18 +2274,6 @@ p, li { white-space: pre-wrap; }
<source>Report file name</source>
<translation>Файл отчета</translation>
</message>
<message>
<source>Rendering report</source>
<translation>Создается отчет</translation>
</message>
<message>
<source>Abort</source>
<translation>Прервать</translation>
</message>
<message>
<source> page rendered</source>
<translation> создается страница</translation>
</message>
<message>
<source>Warning</source>
<translation>Предупреждение</translation>
@ -2301,15 +2336,31 @@ p, li { white-space: pre-wrap; }
</message>
<message>
<source>Lock selected items</source>
<translation>Заблокировать выбранные элементы</translation>
<translation>Заблокировать выделенные элементы</translation>
</message>
<message>
<source>Unlock selected items</source>
<translation>Разблокировать выбранные элементы</translation>
<translation>Разблокировать выделенные элементы</translation>
</message>
<message>
<source>Select one level items</source>
<translation>Выбрать все элементы одного уровня</translation>
<translation>Выделить элементы одного уровня</translation>
</message>
<message>
<source>Rendered %1 pages</source>
<translation>Сформировано %1 страниц</translation>
</message>
<message>
<source>Cancel report rendering</source>
<translation>Отменить построение отчета</translation>
</message>
<message>
<source>Attention</source>
<translation>Внимание</translation>
</message>
<message>
<source>The rendering is in process</source>
<translation>Отчет находится в процессе создания</translation>
</message>
</context>
<context>
@ -2482,7 +2533,7 @@ This preview is no longer valid.</source>
</message>
<message>
<source>CSV</source>
<translation></translation>
<translation>CSV</translation>
</message>
<message>
<source>Separator</source>
@ -2494,7 +2545,7 @@ This preview is no longer valid.</source>
</message>
<message>
<source>Use first row as header</source>
<translation>Первая строка как заголовок</translation>
<translation>Использовать первую строку в качестве заголовка</translation>
</message>
</context>
<context>
@ -2729,7 +2780,7 @@ This preview is no longer valid.</source>
</message>
<message>
<source>Report units</source>
<translation>Единицы измерения</translation>
<translation>Еденицы измерения</translation>
</message>
</context>
<context>
@ -3146,18 +3197,18 @@ This preview is no longer valid.</source>
<source>Export to PDF</source>
<translation>Экспортировать в PDF</translation>
</message>
<message>
<source>Dark</source>
<translation>Темная</translation>
</message>
<message>
<source>Light</source>
<translation>Светаля</translation>
</message>
<message>
<source>Default</source>
<translation>По умолчанию</translation>
</message>
<message>
<source>margin</source>
<translation>Поля</translation>
</message>
<message>
<source>&apos;&apos;</source>
<translation></translation>
</message>
<message>
<source>Millimeters</source>
<translation>Миллиметры</translation>
@ -3167,12 +3218,12 @@ This preview is no longer valid.</source>
<translation>Дюймы</translation>
</message>
<message>
<source>Dark</source>
<translation>Темная</translation>
<source>margin</source>
<translation>Поля</translation>
</message>
<message>
<source>Light</source>
<translation>Светлая</translation>
<source>&apos;&apos;</source>
<translation>&apos;&apos;</translation>
</message>
</context>
</TS>