mirror of
https://github.com/python-LimeReport/LimeReport.git
synced 2024-12-24 04:33:03 +03:00
Prepared pages processing has been refactored
This commit is contained in:
parent
fc04af2c89
commit
536a409393
@ -77,7 +77,7 @@ RCC_DIR = $${ARCH_DIR}/$${BUILD_TYPE}/rcc
|
|||||||
|
|
||||||
LIMEREPORT_VERSION_MAJOR = 1
|
LIMEREPORT_VERSION_MAJOR = 1
|
||||||
LIMEREPORT_VERSION_MINOR = 4
|
LIMEREPORT_VERSION_MINOR = 4
|
||||||
LIMEREPORT_VERSION_RELEASE = 129
|
LIMEREPORT_VERSION_RELEASE = 132
|
||||||
|
|
||||||
LIMEREPORT_VERSION = '\\"$${LIMEREPORT_VERSION_MAJOR}.$${LIMEREPORT_VERSION_MINOR}.$${LIMEREPORT_VERSION_RELEASE}\\"'
|
LIMEREPORT_VERSION = '\\"$${LIMEREPORT_VERSION_MAJOR}.$${LIMEREPORT_VERSION_MINOR}.$${LIMEREPORT_VERSION_RELEASE}\\"'
|
||||||
DEFINES += LIMEREPORT_VERSION_STR=\"$${LIMEREPORT_VERSION}\"
|
DEFINES += LIMEREPORT_VERSION_STR=\"$${LIMEREPORT_VERSION}\"
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include "lrglobal.h"
|
#include "lrglobal.h"
|
||||||
|
#include "lrpreparedpagesintf.h"
|
||||||
|
|
||||||
namespace LimeReport {
|
namespace LimeReport {
|
||||||
|
|
||||||
@ -49,6 +50,7 @@ signals:
|
|||||||
void pageChanged(int page);
|
void pageChanged(int page);
|
||||||
void scalePercentChanged(int percent);
|
void scalePercentChanged(int percent);
|
||||||
void pagesSet(int pageCount);
|
void pagesSet(int pageCount);
|
||||||
|
void onSave(bool& saved, LimeReport::IPreparedPages* pages);
|
||||||
private slots:
|
private slots:
|
||||||
void slotSliderMoved(int value);
|
void slotSliderMoved(int value);
|
||||||
void reportEngineDestroyed(QObject* object);
|
void reportEngineDestroyed(QObject* object);
|
||||||
|
@ -38,6 +38,7 @@
|
|||||||
#include "lrdatasourcemanagerintf.h"
|
#include "lrdatasourcemanagerintf.h"
|
||||||
#include "lrscriptenginemanagerintf.h"
|
#include "lrscriptenginemanagerintf.h"
|
||||||
#include "lrpreviewreportwidget.h"
|
#include "lrpreviewreportwidget.h"
|
||||||
|
#include "lrpreparedpagesintf.h"
|
||||||
|
|
||||||
class QPrinter;
|
class QPrinter;
|
||||||
|
|
||||||
@ -62,20 +63,10 @@ class DataSourceManager;
|
|||||||
class ReportEnginePrivate;
|
class ReportEnginePrivate;
|
||||||
class PageDesignIntf;
|
class PageDesignIntf;
|
||||||
class PageItemDesignIntf;
|
class PageItemDesignIntf;
|
||||||
|
class PreparedPages;
|
||||||
|
|
||||||
typedef QList< QSharedPointer<PageItemDesignIntf> > ReportPages;
|
typedef QList< QSharedPointer<PageItemDesignIntf> > ReportPages;
|
||||||
|
|
||||||
class LIMEREPORT_EXPORT IPreparedPages{
|
|
||||||
public:
|
|
||||||
virtual ~IPreparedPages();
|
|
||||||
virtual bool loadFromFile(const QString& fileName) = 0;
|
|
||||||
virtual bool loadFromString(const QString data) = 0;
|
|
||||||
virtual bool loadFromByteArray(QByteArray* data) = 0;
|
|
||||||
virtual bool saveToFile(const QString& fileName) = 0;
|
|
||||||
virtual QString saveToString() = 0;
|
|
||||||
virtual QByteArray saveToByteArray() = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
class LIMEREPORT_EXPORT ReportEngine : public QObject{
|
class LIMEREPORT_EXPORT ReportEngine : public QObject{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
@ -133,6 +124,7 @@ signals:
|
|||||||
void renderPageFinished(int renderedPageCount);
|
void renderPageFinished(int renderedPageCount);
|
||||||
void onLoad(bool& loaded);
|
void onLoad(bool& loaded);
|
||||||
void onSave();
|
void onSave();
|
||||||
|
void onSavePreview(bool& saved, LimeReport::IPreparedPages* pages);
|
||||||
void saveFinished();
|
void saveFinished();
|
||||||
public slots:
|
public slots:
|
||||||
void cancelRender();
|
void cancelRender();
|
||||||
|
@ -90,6 +90,7 @@ SOURCES += \
|
|||||||
$$REPORT_PATH/lraboutdialog.cpp \
|
$$REPORT_PATH/lraboutdialog.cpp \
|
||||||
$$REPORT_PATH/lrsettingdialog.cpp \
|
$$REPORT_PATH/lrsettingdialog.cpp \
|
||||||
$$REPORT_PATH/scriptbrowser/lrscriptbrowser.cpp \
|
$$REPORT_PATH/scriptbrowser/lrscriptbrowser.cpp \
|
||||||
|
$$REPORT_PATH/lrpreparedpages.cpp \
|
||||||
$$REPORT_PATH/lritemscontainerdesignitf.cpp
|
$$REPORT_PATH/lritemscontainerdesignitf.cpp
|
||||||
|
|
||||||
contains(CONFIG, staticlib){
|
contains(CONFIG, staticlib){
|
||||||
@ -195,6 +196,8 @@ HEADERS += \
|
|||||||
$$REPORT_PATH/lrsettingdialog.h \
|
$$REPORT_PATH/lrsettingdialog.h \
|
||||||
$$REPORT_PATH/lrpreviewreportwidget_p.h \
|
$$REPORT_PATH/lrpreviewreportwidget_p.h \
|
||||||
$$REPORT_PATH/scriptbrowser/lrscriptbrowser.h \
|
$$REPORT_PATH/scriptbrowser/lrscriptbrowser.h \
|
||||||
|
$$REPORT_PATH/lrpreparedpages.h \
|
||||||
|
$$REPORT_PATH/lrpreparedpagesintf.h \
|
||||||
$$REPORT_PATH/lritemscontainerdesignitf.h
|
$$REPORT_PATH/lritemscontainerdesignitf.h
|
||||||
|
|
||||||
contains(CONFIG, staticlib){
|
contains(CONFIG, staticlib){
|
||||||
|
@ -42,6 +42,7 @@ EXTRA_FILES += \
|
|||||||
$$PWD/lrreportengine.h \
|
$$PWD/lrreportengine.h \
|
||||||
$$PWD/lrscriptenginemanagerintf.h \
|
$$PWD/lrscriptenginemanagerintf.h \
|
||||||
$$PWD/lrcallbackdatasourceintf.h \
|
$$PWD/lrcallbackdatasourceintf.h \
|
||||||
|
$$PWD/lrpreparedpagesintf.h \
|
||||||
$$PWD/lrpreviewreportwidget.h
|
$$PWD/lrpreviewreportwidget.h
|
||||||
|
|
||||||
include(limereport.pri)
|
include(limereport.pri)
|
||||||
|
85
limereport/lrpreparedpages.cpp
Normal file
85
limereport/lrpreparedpages.cpp
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
#include "lrpreparedpages.h"
|
||||||
|
|
||||||
|
#include "serializators/lrxmlreader.h"
|
||||||
|
#include "serializators/lrxmlwriter.h"
|
||||||
|
|
||||||
|
namespace LimeReport {
|
||||||
|
|
||||||
|
bool PreparedPages::loadFromFile(const QString &fileName)
|
||||||
|
{
|
||||||
|
ItemsReaderIntf::Ptr reader = FileXMLReader::create(fileName);
|
||||||
|
return readPages(reader);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool PreparedPages::loadFromString(const QString data)
|
||||||
|
{
|
||||||
|
ItemsReaderIntf::Ptr reader = StringXMLreader::create(data);
|
||||||
|
return readPages(reader);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool PreparedPages::loadFromByteArray(QByteArray *data)
|
||||||
|
{
|
||||||
|
ItemsReaderIntf::Ptr reader = ByteArrayXMLReader::create(data);
|
||||||
|
return readPages(reader);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool PreparedPages::saveToFile(const QString &fileName)
|
||||||
|
{
|
||||||
|
if (!fileName.isEmpty()){
|
||||||
|
QScopedPointer< ItemsWriterIntf > writer(new XMLWriter());
|
||||||
|
foreach (PageItemDesignIntf::Ptr page, *m_pages){
|
||||||
|
writer->putItem(page.data());
|
||||||
|
}
|
||||||
|
return writer->saveToFile(fileName);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString PreparedPages::saveToString()
|
||||||
|
{
|
||||||
|
QScopedPointer< ItemsWriterIntf > writer(new XMLWriter());
|
||||||
|
foreach (PageItemDesignIntf::Ptr page, *m_pages){
|
||||||
|
writer->putItem(page.data());
|
||||||
|
}
|
||||||
|
return writer->saveToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
QByteArray PreparedPages::saveToByteArray()
|
||||||
|
{
|
||||||
|
QScopedPointer< ItemsWriterIntf > writer(new XMLWriter());
|
||||||
|
foreach (PageItemDesignIntf::Ptr page, *m_pages){
|
||||||
|
writer->putItem(page.data());
|
||||||
|
}
|
||||||
|
return writer->saveToByteArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
void PreparedPages::clear()
|
||||||
|
{
|
||||||
|
m_pages->clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool PreparedPages::readPages(ItemsReaderIntf::Ptr reader)
|
||||||
|
{
|
||||||
|
if (reader->first()){
|
||||||
|
PageItemDesignIntf::Ptr page = PageItemDesignIntf::create(0);
|
||||||
|
if (!reader->readItem(page.data()))
|
||||||
|
return false;
|
||||||
|
else {
|
||||||
|
m_pages->append(page);
|
||||||
|
while (reader->next()){
|
||||||
|
page = PageItemDesignIntf::create(0);
|
||||||
|
if (!reader->readItem(page.data())){
|
||||||
|
m_pages->clear();
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
m_pages->append(page);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
29
limereport/lrpreparedpages.h
Normal file
29
limereport/lrpreparedpages.h
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
#ifndef LRPREPAREDPAGES_H
|
||||||
|
#define LRPREPAREDPAGES_H
|
||||||
|
|
||||||
|
#include "lrpagedesignintf.h"
|
||||||
|
#include "lrpreparedpagesintf.h"
|
||||||
|
|
||||||
|
namespace LimeReport {
|
||||||
|
|
||||||
|
class PreparedPages: public IPreparedPages{
|
||||||
|
public:
|
||||||
|
PreparedPages(ReportPages* pages):m_pages(pages){}
|
||||||
|
~PreparedPages(){}
|
||||||
|
// IPreviewPages interface
|
||||||
|
private:
|
||||||
|
bool loadFromFile(const QString &fileName);
|
||||||
|
bool loadFromString(const QString data);
|
||||||
|
bool loadFromByteArray(QByteArray *data);
|
||||||
|
bool saveToFile(const QString &fileName);
|
||||||
|
QString saveToString();
|
||||||
|
QByteArray saveToByteArray();
|
||||||
|
void clear();
|
||||||
|
private:
|
||||||
|
bool readPages(ItemsReaderIntf::Ptr reader);
|
||||||
|
ReportPages* m_pages;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace LimeReport
|
||||||
|
|
||||||
|
#endif // LRPREPAREDPAGES_H
|
17
limereport/lrpreparedpagesintf.h
Normal file
17
limereport/lrpreparedpagesintf.h
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
#ifndef LRPREPAREDPAGESINTF_H
|
||||||
|
#define LRPREPAREDPAGESINTF_H
|
||||||
|
#include "lrglobal.h"
|
||||||
|
namespace LimeReport {
|
||||||
|
class LIMEREPORT_EXPORT IPreparedPages{
|
||||||
|
public:
|
||||||
|
virtual ~IPreparedPages(){};
|
||||||
|
virtual bool loadFromFile(const QString& fileName) = 0;
|
||||||
|
virtual bool loadFromString(const QString data) = 0;
|
||||||
|
virtual bool loadFromByteArray(QByteArray* data) = 0;
|
||||||
|
virtual bool saveToFile(const QString& fileName) = 0;
|
||||||
|
virtual QString saveToString() = 0;
|
||||||
|
virtual QByteArray saveToByteArray() = 0;
|
||||||
|
virtual void clear() = 0;
|
||||||
|
};
|
||||||
|
} //namespace LimeReport
|
||||||
|
#endif // LRPREPAREDPAGESINTF_H
|
@ -11,6 +11,7 @@
|
|||||||
#include "lrreportengine_p.h"
|
#include "lrreportengine_p.h"
|
||||||
#include "lrpreviewreportwidget_p.h"
|
#include "lrpreviewreportwidget_p.h"
|
||||||
#include "serializators/lrxmlwriter.h"
|
#include "serializators/lrxmlwriter.h"
|
||||||
|
#include "lrpreparedpages.h"
|
||||||
|
|
||||||
namespace LimeReport {
|
namespace LimeReport {
|
||||||
|
|
||||||
@ -207,13 +208,18 @@ void PreviewReportWidget::pageNavigatorChanged(int value)
|
|||||||
|
|
||||||
void PreviewReportWidget::saveToFile()
|
void PreviewReportWidget::saveToFile()
|
||||||
{
|
{
|
||||||
QString fileName = QFileDialog::getSaveFileName(this,tr("Report file name"));
|
bool saved = false;
|
||||||
if (!fileName.isEmpty()){
|
PreparedPages pagesManager = PreparedPages(&d_ptr->m_reportPages);
|
||||||
QScopedPointer< ItemsWriterIntf > writer(new XMLWriter());
|
emit onSave(saved, &pagesManager);
|
||||||
foreach (PageItemDesignIntf::Ptr page, d_ptr->m_reportPages){
|
if (!saved){
|
||||||
writer->putItem(page.data());
|
QString fileName = QFileDialog::getSaveFileName(this,tr("Report file name"));
|
||||||
|
if (!fileName.isEmpty()){
|
||||||
|
QScopedPointer< ItemsWriterIntf > writer(new XMLWriter());
|
||||||
|
foreach (PageItemDesignIntf::Ptr page, d_ptr->m_reportPages){
|
||||||
|
writer->putItem(page.data());
|
||||||
|
}
|
||||||
|
writer->saveToFile(fileName);
|
||||||
}
|
}
|
||||||
writer->saveToFile(fileName);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include "lrglobal.h"
|
#include "lrglobal.h"
|
||||||
|
#include "lrpreparedpagesintf.h"
|
||||||
|
|
||||||
namespace LimeReport {
|
namespace LimeReport {
|
||||||
|
|
||||||
@ -49,6 +50,7 @@ signals:
|
|||||||
void pageChanged(int page);
|
void pageChanged(int page);
|
||||||
void scalePercentChanged(int percent);
|
void scalePercentChanged(int percent);
|
||||||
void pagesSet(int pageCount);
|
void pagesSet(int pageCount);
|
||||||
|
void onSave(bool& saved, LimeReport::IPreparedPages* pages);
|
||||||
private slots:
|
private slots:
|
||||||
void slotSliderMoved(int value);
|
void slotSliderMoved(int value);
|
||||||
void reportEngineDestroyed(QObject* object);
|
void reportEngineDestroyed(QObject* object);
|
||||||
|
@ -60,9 +60,14 @@ PreviewReportWindow::PreviewReportWindow(ReportEnginePrivate *report,QWidget *pa
|
|||||||
m_previewReportWidget = new PreviewReportWidget(report,this);
|
m_previewReportWidget = new PreviewReportWidget(report,this);
|
||||||
setCentralWidget(m_previewReportWidget);
|
setCentralWidget(m_previewReportWidget);
|
||||||
layout()->setContentsMargins(1,1,1,1);
|
layout()->setContentsMargins(1,1,1,1);
|
||||||
connect(m_previewReportWidget,SIGNAL(pageChanged(int)), this,SLOT(slotPageChanged(int)) );
|
connect(m_previewReportWidget, SIGNAL(pageChanged(int)),
|
||||||
connect(m_previewReportWidget->d_ptr->m_previewPage,SIGNAL(selectionChanged()),this,SLOT(slotSelectionChanged()));
|
this, SLOT(slotPageChanged(int)) );
|
||||||
connect(m_pagesNavigator,SIGNAL(valueChanged(int)),this,SLOT(slotPageNavigatorChanged(int)));
|
connect(m_previewReportWidget->d_ptr->m_previewPage, SIGNAL(selectionChanged()),
|
||||||
|
this, SLOT(slotSelectionChanged()));
|
||||||
|
connect(m_pagesNavigator, SIGNAL(valueChanged(int)),
|
||||||
|
this, SLOT(slotPageNavigatorChanged(int)));
|
||||||
|
connect(m_previewReportWidget, SIGNAL(onSave(bool&, LimeReport::IPreparedPages*)),
|
||||||
|
this, SIGNAL(onSave(bool&, LimeReport::IPreparedPages*)));
|
||||||
|
|
||||||
m_fontEditor = new FontEditorWidget(m_previewReportWidget->d_ptr->m_previewPage,tr("Font"),this);
|
m_fontEditor = new FontEditorWidget(m_previewReportWidget->d_ptr->m_previewPage,tr("Font"),this);
|
||||||
m_fontEditor->setObjectName("fontTools");
|
m_fontEditor->setObjectName("fontTools");
|
||||||
|
@ -40,6 +40,7 @@
|
|||||||
#include "serializators/lrstorageintf.h"
|
#include "serializators/lrstorageintf.h"
|
||||||
#include "serializators/lrxmlreader.h"
|
#include "serializators/lrxmlreader.h"
|
||||||
#include "lrpreviewreportwidget.h"
|
#include "lrpreviewreportwidget.h"
|
||||||
|
#include "lrpreparedpagesintf.h"
|
||||||
|
|
||||||
#include "items/editors/lrfonteditorwidget.h"
|
#include "items/editors/lrfonteditorwidget.h"
|
||||||
#include "items/editors/lrtextalignmenteditorwidget.h"
|
#include "items/editors/lrtextalignmenteditorwidget.h"
|
||||||
@ -106,6 +107,8 @@ private slots:
|
|||||||
void slotScalePercentChanged(int percent);
|
void slotScalePercentChanged(int percent);
|
||||||
void on_actionShowMessages_toggled(bool value);
|
void on_actionShowMessages_toggled(bool value);
|
||||||
void on_actionShow_Toolbar_triggered();
|
void on_actionShow_Toolbar_triggered();
|
||||||
|
signals:
|
||||||
|
void onSave(bool& saved, LimeReport::IPreparedPages* pages);
|
||||||
private:
|
private:
|
||||||
ItemsReaderIntf* reader();
|
ItemsReaderIntf* reader();
|
||||||
void initPercentCombobox();
|
void initPercentCombobox();
|
||||||
|
@ -50,6 +50,8 @@
|
|||||||
#include "lrpreviewreportwindow.h"
|
#include "lrpreviewreportwindow.h"
|
||||||
#include "lrpreviewreportwidget.h"
|
#include "lrpreviewreportwidget.h"
|
||||||
#include "lrpreviewreportwidget_p.h"
|
#include "lrpreviewreportwidget_p.h"
|
||||||
|
#include "lrpreparedpages.h"
|
||||||
|
|
||||||
#ifdef HAVE_STATIC_BUILD
|
#ifdef HAVE_STATIC_BUILD
|
||||||
#include "lrfactoryinitializer.h"
|
#include "lrfactoryinitializer.h"
|
||||||
#endif
|
#endif
|
||||||
@ -58,12 +60,12 @@ namespace LimeReport{
|
|||||||
QSettings* ReportEngine::m_settings = 0;
|
QSettings* ReportEngine::m_settings = 0;
|
||||||
|
|
||||||
ReportEnginePrivate::ReportEnginePrivate(QObject *parent) :
|
ReportEnginePrivate::ReportEnginePrivate(QObject *parent) :
|
||||||
QObject(parent), m_preparedPagesManager(PreparedPages(&m_preparedPages)), m_fileName(""), m_settings(0), m_ownedSettings(false),
|
QObject(parent), m_preparedPagesManager(new PreparedPages(&m_preparedPages)), m_fileName(""), m_settings(0), m_ownedSettings(false),
|
||||||
m_printer(new QPrinter(QPrinter::HighResolution)), m_printerSelected(false),
|
m_printer(new QPrinter(QPrinter::HighResolution)), m_printerSelected(false),
|
||||||
m_showProgressDialog(true), m_reportName(""), m_activePreview(0),
|
m_showProgressDialog(true), m_reportName(""), m_activePreview(0),
|
||||||
m_previewWindowIcon(":/report/images/logo32"), m_previewWindowTitle(tr("Preview")),
|
m_previewWindowIcon(":/report/images/logo32"), m_previewWindowTitle(tr("Preview")),
|
||||||
m_reportRendering(false), m_resultIsEditable(true), m_passPhrase("HjccbzHjlbyfCkjy"),
|
m_reportRendering(false), m_resultIsEditable(true), m_passPhrase("HjccbzHjlbyfCkjy"),
|
||||||
m_fileWatcher( new QFileSystemWatcher( this ) ), m_previewLayoutDirection(Qt::LayoutDirectionAuto),
|
m_fileWatcher( new QFileSystemWatcher(this) ), m_previewLayoutDirection(Qt::LayoutDirectionAuto),
|
||||||
m_previewScaleType(FitWidth), m_previewScalePercent(0), m_saveToFileVisible(true), m_printToPdfVisible(true),
|
m_previewScaleType(FitWidth), m_previewScalePercent(0), m_saveToFileVisible(true), m_printToPdfVisible(true),
|
||||||
m_printVisible(true)
|
m_printVisible(true)
|
||||||
{
|
{
|
||||||
@ -93,6 +95,7 @@ ReportEnginePrivate::~ReportEnginePrivate()
|
|||||||
foreach(PageDesignIntf* page,m_pages) delete page;
|
foreach(PageDesignIntf* page,m_pages) delete page;
|
||||||
m_pages.clear();
|
m_pages.clear();
|
||||||
if (m_ownedSettings&&m_settings) delete m_settings;
|
if (m_ownedSettings&&m_settings) delete m_settings;
|
||||||
|
delete m_preparedPagesManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
QObject* ReportEnginePrivate::createElement(const QString &, const QString &)
|
QObject* ReportEnginePrivate::createElement(const QString &, const QString &)
|
||||||
@ -400,6 +403,8 @@ bool ReportEnginePrivate::showPreviewWindow(ReportPages pages, PreviewHints hint
|
|||||||
w->setPreviewScaleType(m_previewScaleType, m_previewScalePercent);
|
w->setPreviewScaleType(m_previewScaleType, m_previewScalePercent);
|
||||||
|
|
||||||
connect(w,SIGNAL(destroyed(QObject*)), this, SLOT(slotPreviewWindowDestroyed(QObject*)));
|
connect(w,SIGNAL(destroyed(QObject*)), this, SLOT(slotPreviewWindowDestroyed(QObject*)));
|
||||||
|
connect(w, SIGNAL(onSave(bool&, LimeReport::IPreparedPages*)),
|
||||||
|
this, SIGNAL(onSavePreview(bool&, LimeReport::IPreparedPages*)));
|
||||||
w->exec();
|
w->exec();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -756,6 +761,10 @@ void ReportEnginePrivate::setPreviewScaleType(const ScaleType &scaleType, int pe
|
|||||||
m_previewScalePercent = percent;
|
m_previewScalePercent = percent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IPreparedPages *ReportEnginePrivate::preparedPages(){
|
||||||
|
return m_preparedPagesManager;
|
||||||
|
}
|
||||||
|
|
||||||
bool ReportEnginePrivate::showPreparedPages(PreviewHints hints)
|
bool ReportEnginePrivate::showPreparedPages(PreviewHints hints)
|
||||||
{
|
{
|
||||||
return showPreviewWindow(m_preparedPages, hints);
|
return showPreviewWindow(m_preparedPages, hints);
|
||||||
@ -903,7 +912,7 @@ ReportPages ReportEnginePrivate::renderToPages()
|
|||||||
|
|
||||||
foreach(PageDesignIntf* page , m_pages){
|
foreach(PageDesignIntf* page , m_pages){
|
||||||
m_pages.at(0)->setReportSettings(&m_reportSettings);
|
m_pages.at(0)->setReportSettings(&m_reportSettings);
|
||||||
result.append(m_reportRender->renderPageToPages(page));
|
result.append(m_reportRender->renderPageToPages(page));
|
||||||
}
|
}
|
||||||
|
|
||||||
m_reportRender->secondRenderPass(result);
|
m_reportRender->secondRenderPass(result);
|
||||||
@ -933,6 +942,8 @@ ReportEngine::ReportEngine(QObject *parent)
|
|||||||
connect(d, SIGNAL(onSave()), this, SIGNAL(onSave()));
|
connect(d, SIGNAL(onSave()), this, SIGNAL(onSave()));
|
||||||
connect(d, SIGNAL(onLoad(bool&)), this, SIGNAL(onLoad(bool&)));
|
connect(d, SIGNAL(onLoad(bool&)), this, SIGNAL(onLoad(bool&)));
|
||||||
connect(d, SIGNAL(saveFinished()), this, SIGNAL(saveFinished()));
|
connect(d, SIGNAL(saveFinished()), this, SIGNAL(saveFinished()));
|
||||||
|
connect(d, SIGNAL(onSavePreview(bool&, LimeReport::IPreparedPages*)),
|
||||||
|
this, SIGNAL(onSavePreview(bool&, LimeReport::IPreparedPages*)));
|
||||||
}
|
}
|
||||||
|
|
||||||
ReportEngine::~ReportEngine()
|
ReportEngine::~ReportEngine()
|
||||||
@ -1218,78 +1229,4 @@ ReportEngine::ReportEngine(ReportEnginePrivate &dd, QObject *parent)
|
|||||||
connect(d, SIGNAL(renderFinished()), this, SIGNAL(renderFinished()));
|
connect(d, SIGNAL(renderFinished()), this, SIGNAL(renderFinished()));
|
||||||
}
|
}
|
||||||
|
|
||||||
IPreparedPages::~IPreparedPages(){}
|
|
||||||
|
|
||||||
bool PreparedPages::loadFromFile(const QString &fileName)
|
|
||||||
{
|
|
||||||
ItemsReaderIntf::Ptr reader = FileXMLReader::create(fileName);
|
|
||||||
return readPages(reader);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool PreparedPages::loadFromString(const QString data)
|
|
||||||
{
|
|
||||||
ItemsReaderIntf::Ptr reader = StringXMLreader::create(data);
|
|
||||||
return readPages(reader);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool PreparedPages::loadFromByteArray(QByteArray *data)
|
|
||||||
{
|
|
||||||
ItemsReaderIntf::Ptr reader = ByteArrayXMLReader::create(data);
|
|
||||||
return readPages(reader);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool PreparedPages::saveToFile(const QString &fileName)
|
|
||||||
{
|
|
||||||
if (!fileName.isEmpty()){
|
|
||||||
QScopedPointer< ItemsWriterIntf > writer(new XMLWriter());
|
|
||||||
foreach (PageItemDesignIntf::Ptr page, *m_pages){
|
|
||||||
writer->putItem(page.data());
|
|
||||||
}
|
|
||||||
return writer->saveToFile(fileName);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString PreparedPages::saveToString()
|
|
||||||
{
|
|
||||||
QScopedPointer< ItemsWriterIntf > writer(new XMLWriter());
|
|
||||||
foreach (PageItemDesignIntf::Ptr page, *m_pages){
|
|
||||||
writer->putItem(page.data());
|
|
||||||
}
|
|
||||||
return writer->saveToString();
|
|
||||||
}
|
|
||||||
|
|
||||||
QByteArray PreparedPages::saveToByteArray()
|
|
||||||
{
|
|
||||||
QScopedPointer< ItemsWriterIntf > writer(new XMLWriter());
|
|
||||||
foreach (PageItemDesignIntf::Ptr page, *m_pages){
|
|
||||||
writer->putItem(page.data());
|
|
||||||
}
|
|
||||||
return writer->saveToByteArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool PreparedPages::readPages(ItemsReaderIntf::Ptr reader)
|
|
||||||
{
|
|
||||||
if (reader->first()){
|
|
||||||
PageItemDesignIntf::Ptr page = PageItemDesignIntf::create(0);
|
|
||||||
if (!reader->readItem(page.data()))
|
|
||||||
return false;
|
|
||||||
else {
|
|
||||||
m_pages->append(page);
|
|
||||||
while (reader->next()){
|
|
||||||
page = PageItemDesignIntf::create(0);
|
|
||||||
if (!reader->readItem(page.data())){
|
|
||||||
m_pages->clear();
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
m_pages->append(page);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -38,6 +38,7 @@
|
|||||||
#include "lrdatasourcemanagerintf.h"
|
#include "lrdatasourcemanagerintf.h"
|
||||||
#include "lrscriptenginemanagerintf.h"
|
#include "lrscriptenginemanagerintf.h"
|
||||||
#include "lrpreviewreportwidget.h"
|
#include "lrpreviewreportwidget.h"
|
||||||
|
#include "lrpreparedpagesintf.h"
|
||||||
|
|
||||||
class QPrinter;
|
class QPrinter;
|
||||||
|
|
||||||
@ -62,20 +63,10 @@ class DataSourceManager;
|
|||||||
class ReportEnginePrivate;
|
class ReportEnginePrivate;
|
||||||
class PageDesignIntf;
|
class PageDesignIntf;
|
||||||
class PageItemDesignIntf;
|
class PageItemDesignIntf;
|
||||||
|
class PreparedPages;
|
||||||
|
|
||||||
typedef QList< QSharedPointer<PageItemDesignIntf> > ReportPages;
|
typedef QList< QSharedPointer<PageItemDesignIntf> > ReportPages;
|
||||||
|
|
||||||
class LIMEREPORT_EXPORT IPreparedPages{
|
|
||||||
public:
|
|
||||||
virtual ~IPreparedPages();
|
|
||||||
virtual bool loadFromFile(const QString& fileName) = 0;
|
|
||||||
virtual bool loadFromString(const QString data) = 0;
|
|
||||||
virtual bool loadFromByteArray(QByteArray* data) = 0;
|
|
||||||
virtual bool saveToFile(const QString& fileName) = 0;
|
|
||||||
virtual QString saveToString() = 0;
|
|
||||||
virtual QByteArray saveToByteArray() = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
class LIMEREPORT_EXPORT ReportEngine : public QObject{
|
class LIMEREPORT_EXPORT ReportEngine : public QObject{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
@ -133,6 +124,7 @@ signals:
|
|||||||
void renderPageFinished(int renderedPageCount);
|
void renderPageFinished(int renderedPageCount);
|
||||||
void onLoad(bool& loaded);
|
void onLoad(bool& loaded);
|
||||||
void onSave();
|
void onSave();
|
||||||
|
void onSavePreview(bool& saved, LimeReport::IPreparedPages* pages);
|
||||||
void saveFinished();
|
void saveFinished();
|
||||||
public slots:
|
public slots:
|
||||||
void cancelRender();
|
void cancelRender();
|
||||||
|
@ -50,23 +50,6 @@ class PageDesignIntf;
|
|||||||
class PrintRange;
|
class PrintRange;
|
||||||
class ReportDesignWindow;
|
class ReportDesignWindow;
|
||||||
|
|
||||||
class PreparedPages: public IPreparedPages{
|
|
||||||
public:
|
|
||||||
PreparedPages(ReportPages* pages):m_pages(pages){}
|
|
||||||
~PreparedPages(){}
|
|
||||||
// IPreviewPages interface
|
|
||||||
private:
|
|
||||||
bool loadFromFile(const QString &fileName);
|
|
||||||
bool loadFromString(const QString data);
|
|
||||||
bool loadFromByteArray(QByteArray *data);
|
|
||||||
bool saveToFile(const QString &fileName);
|
|
||||||
QString saveToString();
|
|
||||||
QByteArray saveToByteArray();
|
|
||||||
private:
|
|
||||||
bool readPages(ItemsReaderIntf::Ptr reader);
|
|
||||||
ReportPages* m_pages;
|
|
||||||
};
|
|
||||||
|
|
||||||
class ReportEnginePrivate : public QObject, public ICollectionContainer
|
class ReportEnginePrivate : public QObject, public ICollectionContainer
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -156,7 +139,7 @@ public:
|
|||||||
ScaleType previewScaleType();
|
ScaleType previewScaleType();
|
||||||
int previewScalePercent();
|
int previewScalePercent();
|
||||||
void setPreviewScaleType(const ScaleType &previewScaleType, int percent = 0);
|
void setPreviewScaleType(const ScaleType &previewScaleType, int percent = 0);
|
||||||
IPreparedPages* preparedPages(){return &m_preparedPagesManager;}
|
IPreparedPages* preparedPages();
|
||||||
bool showPreparedPages(PreviewHints hints);
|
bool showPreparedPages(PreviewHints hints);
|
||||||
bool prepareReportPages();
|
bool prepareReportPages();
|
||||||
signals:
|
signals:
|
||||||
@ -169,6 +152,7 @@ signals:
|
|||||||
void onLoad(bool& loaded);
|
void onLoad(bool& loaded);
|
||||||
void onSave();
|
void onSave();
|
||||||
void saveFinished();
|
void saveFinished();
|
||||||
|
void onSavePreview(bool& saved, LimeReport::IPreparedPages* pages);
|
||||||
public slots:
|
public slots:
|
||||||
bool slotLoadFromFile(const QString& fileName);
|
bool slotLoadFromFile(const QString& fileName);
|
||||||
void cancelRender();
|
void cancelRender();
|
||||||
@ -193,7 +177,7 @@ private:
|
|||||||
private:
|
private:
|
||||||
QList<PageDesignIntf*> m_pages;
|
QList<PageDesignIntf*> m_pages;
|
||||||
ReportPages m_preparedPages;
|
ReportPages m_preparedPages;
|
||||||
PreparedPages m_preparedPagesManager;
|
PreparedPages* m_preparedPagesManager;
|
||||||
DataSourceManager* m_datasources;
|
DataSourceManager* m_datasources;
|
||||||
ScriptEngineContext* m_scriptEngineContext;
|
ScriptEngineContext* m_scriptEngineContext;
|
||||||
ReportRender::Ptr m_reportRender;
|
ReportRender::Ptr m_reportRender;
|
||||||
|
Loading…
Reference in New Issue
Block a user