mirror of
https://github.com/python-LimeReport/LimeReport.git
synced 2024-12-24 12:34:39 +03:00
Finish 1.4.131
# Conflicts: # include/lrreportengine.h # limereport/lrreportengine.cpp # limereport/lrreportengine.h # limereport/lrreportengine_p.h
This commit is contained in:
commit
d9e609e954
@ -140,6 +140,17 @@ class PreviewReportWidget;
|
|||||||
|
|
||||||
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
|
||||||
friend class ReportDesignWidget;
|
friend class ReportDesignWidget;
|
||||||
@ -201,6 +212,9 @@ public:
|
|||||||
void setPreviewScaleType(const ScaleType &previewScaleType, int percent = 0);
|
void setPreviewScaleType(const ScaleType &previewScaleType, int percent = 0);
|
||||||
void addWatermark(const WatermarkSetting& watermarkSetting);
|
void addWatermark(const WatermarkSetting& watermarkSetting);
|
||||||
void clearWatermarks();
|
void clearWatermarks();
|
||||||
|
IPreparedPages* preparedPages();
|
||||||
|
bool showPreparedPages(PreviewHints hints = PreviewBarsUserSetting);
|
||||||
|
bool prepareReportPages();
|
||||||
signals:
|
signals:
|
||||||
void cleared();
|
void cleared();
|
||||||
void renderStarted();
|
void renderStarted();
|
||||||
|
@ -1403,7 +1403,9 @@ QObject *BaseDesignIntf::createElement(const QString& /*collectionName*/, const
|
|||||||
try{
|
try{
|
||||||
if (LimeReport::DesignElementsFactory::instance().objectCreator(elementType)){
|
if (LimeReport::DesignElementsFactory::instance().objectCreator(elementType)){
|
||||||
obj = LimeReport::DesignElementsFactory::instance().objectCreator(elementType)(this, this);
|
obj = LimeReport::DesignElementsFactory::instance().objectCreator(elementType)(this, this);
|
||||||
connect(obj,SIGNAL(propertyChanged(QString,QVariant,QVariant)),page(),SLOT(slotItemPropertyChanged(QString,QVariant,QVariant)));
|
if (page())
|
||||||
|
connect(obj, SIGNAL(propertyChanged(QString,QVariant,QVariant)),
|
||||||
|
page(), SLOT(slotItemPropertyChanged(QString,QVariant,QVariant)));
|
||||||
}
|
}
|
||||||
} catch (ReportError &error){
|
} catch (ReportError &error){
|
||||||
qDebug()<<error.what();
|
qDebug()<<error.what();
|
||||||
|
@ -76,7 +76,7 @@ namespace LimeReport{
|
|||||||
QSettings* ReportEngine::m_settings = 0;
|
QSettings* ReportEngine::m_settings = 0;
|
||||||
|
|
||||||
ReportEnginePrivate::ReportEnginePrivate(QObject *parent) :
|
ReportEnginePrivate::ReportEnginePrivate(QObject *parent) :
|
||||||
QObject(parent), m_fileName(""), m_settings(0), m_ownedSettings(false),
|
QObject(parent), m_preparedPagesManager(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")),
|
||||||
@ -498,6 +498,48 @@ bool ReportEnginePrivate::exportReport(QString exporterName, const QString &file
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ReportEnginePrivate::showPreviewWindow(ReportPages pages, PreviewHints hints)
|
||||||
|
{
|
||||||
|
if (pages.count()>0){
|
||||||
|
Q_Q(ReportEngine);
|
||||||
|
PreviewReportWindow* w = new PreviewReportWindow(q, 0, settings());
|
||||||
|
w->setWindowFlags(Qt::Dialog|Qt::WindowMaximizeButtonHint|Qt::WindowCloseButtonHint| Qt::WindowMinMaxButtonsHint);
|
||||||
|
w->setAttribute(Qt::WA_DeleteOnClose,true);
|
||||||
|
w->setWindowModality(Qt::ApplicationModal);
|
||||||
|
//w->setWindowIcon(QIcon(":/report/images/main.ico"));
|
||||||
|
w->setWindowIcon(m_previewWindowIcon);
|
||||||
|
w->setWindowTitle(m_previewWindowTitle);
|
||||||
|
w->setSettings(settings());
|
||||||
|
w->setPages(pages);
|
||||||
|
w->setLayoutDirection(m_previewLayoutDirection);
|
||||||
|
|
||||||
|
if (!dataManager()->errorsList().isEmpty()){
|
||||||
|
w->setErrorMessages(dataManager()->errorsList());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!hints.testFlag(PreviewBarsUserSetting)){
|
||||||
|
w->setMenuVisible(!hints.testFlag(HidePreviewMenuBar));
|
||||||
|
w->setStatusBarVisible(!hints.testFlag(HidePreviewStatusBar));
|
||||||
|
w->setToolBarVisible(!hints.testFlag(HidePreviewToolBar));
|
||||||
|
}
|
||||||
|
|
||||||
|
w->setHideResultEditButton(resultIsEditable());
|
||||||
|
w->setHidePrintButton(printIsVisible());
|
||||||
|
w->setHideSaveToFileButton(saveToFileIsVisible());
|
||||||
|
w->setHidePrintToPdfButton(printToPdfIsVisible());
|
||||||
|
w->setEnablePrintMenu(printIsVisible() || printToPdfIsVisible());
|
||||||
|
|
||||||
|
m_activePreview = w;
|
||||||
|
|
||||||
|
w->setPreviewScaleType(m_previewScaleType, m_previewScalePercent);
|
||||||
|
|
||||||
|
connect(w,SIGNAL(destroyed(QObject*)), this, SLOT(slotPreviewWindowDestroyed(QObject*)));
|
||||||
|
w->exec();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void ReportEnginePrivate::previewReport(PreviewHints hints)
|
void ReportEnginePrivate::previewReport(PreviewHints hints)
|
||||||
{
|
{
|
||||||
previewReport(0, hints);
|
previewReport(0, hints);
|
||||||
@ -510,45 +552,7 @@ void ReportEnginePrivate::previewReport(QPrinter *printer, PreviewHints hints)
|
|||||||
dataManager()->setDesignTime(false);
|
dataManager()->setDesignTime(false);
|
||||||
ReportPages pages = renderToPages();
|
ReportPages pages = renderToPages();
|
||||||
dataManager()->setDesignTime(true);
|
dataManager()->setDesignTime(true);
|
||||||
if (pages.count()>0){
|
showPreviewWindow(pages, hints);
|
||||||
Q_Q(ReportEngine);
|
|
||||||
PreviewReportWindow* w = new PreviewReportWindow(q,0,settings());
|
|
||||||
w->setPreviewPageBackgroundColor(m_previewPageBackgroundColor);
|
|
||||||
w->setWindowFlags(Qt::Dialog|Qt::WindowMaximizeButtonHint|Qt::WindowCloseButtonHint| Qt::WindowMinMaxButtonsHint);
|
|
||||||
w->setAttribute(Qt::WA_DeleteOnClose,true);
|
|
||||||
w->setWindowModality(Qt::ApplicationModal);
|
|
||||||
w->setDefaultPrinter(printer);
|
|
||||||
//w->setWindowIcon(QIcon(":/report/images/main.ico"));
|
|
||||||
w->setWindowIcon(m_previewWindowIcon);
|
|
||||||
w->setWindowTitle(m_previewWindowTitle);
|
|
||||||
w->setSettings(settings());
|
|
||||||
w->setPages(pages);
|
|
||||||
w->setLayoutDirection(m_previewLayoutDirection);
|
|
||||||
|
|
||||||
if (!dataManager()->errorsList().isEmpty()){
|
|
||||||
w->setErrorMessages(dataManager()->errorsList());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!hints.testFlag(PreviewBarsUserSetting)){
|
|
||||||
w->setMenuVisible(!hints.testFlag(HidePreviewMenuBar));
|
|
||||||
w->setStatusBarVisible(!hints.testFlag(HidePreviewStatusBar));
|
|
||||||
w->setToolBarVisible(!hints.testFlag(HidePreviewToolBar));
|
|
||||||
}
|
|
||||||
|
|
||||||
w->setHideResultEditButton(resultIsEditable());
|
|
||||||
w->setHidePrintButton(printIsVisible());
|
|
||||||
w->setHideSaveToFileButton(saveToFileIsVisible());
|
|
||||||
w->setHidePrintToPdfButton(printToPdfIsVisible());
|
|
||||||
w->setEnablePrintMenu(printIsVisible() || printToPdfIsVisible());
|
|
||||||
|
|
||||||
w->setStyleSheet(m_styleSheet);
|
|
||||||
m_activePreview = w;
|
|
||||||
|
|
||||||
w->setPreviewScaleType(m_previewScaleType, m_previewScalePercent);
|
|
||||||
|
|
||||||
connect(w,SIGNAL(destroyed(QObject*)), this, SLOT(slotPreviewWindowDestroyed(QObject*)));
|
|
||||||
w->exec();
|
|
||||||
}
|
|
||||||
} catch (ReportError &exception){
|
} catch (ReportError &exception){
|
||||||
saveError(exception.what());
|
saveError(exception.what());
|
||||||
showError(exception.what());
|
showError(exception.what());
|
||||||
@ -965,6 +969,25 @@ PageItemDesignIntf* ReportEnginePrivate::getPageByName(const QString& pageName)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ReportEnginePrivate::showPreparedPages(PreviewHints hints)
|
||||||
|
{
|
||||||
|
return showPreviewWindow(m_preparedPages, hints);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ReportEnginePrivate::prepareReportPages()
|
||||||
|
{
|
||||||
|
try{
|
||||||
|
dataManager()->setDesignTime(false);
|
||||||
|
m_preparedPages = renderToPages();
|
||||||
|
dataManager()->setDesignTime(true);
|
||||||
|
} catch (ReportError &exception){
|
||||||
|
saveError(exception.what());
|
||||||
|
showError(exception.what());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return !m_preparedPages.isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
Qt::LayoutDirection ReportEnginePrivate::previewLayoutDirection()
|
Qt::LayoutDirection ReportEnginePrivate::previewLayoutDirection()
|
||||||
{
|
{
|
||||||
return m_previewLayoutDirection;
|
return m_previewLayoutDirection;
|
||||||
@ -1583,6 +1606,23 @@ void ReportEngine::clearWatermarks()
|
|||||||
d->clearWatermarks();
|
d->clearWatermarks();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IPreparedPages *ReportEngine::preparedPages()
|
||||||
|
{
|
||||||
|
Q_D(ReportEngine);
|
||||||
|
return d->preparedPages();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ReportEngine::showPreparedPages(PreviewHints hints)
|
||||||
|
{
|
||||||
|
Q_D(ReportEngine);
|
||||||
|
return d->showPreparedPages(hints);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ReportEngine::prepareReportPages()
|
||||||
|
{
|
||||||
|
Q_D(ReportEngine);
|
||||||
|
return d->prepareReportPages();
|
||||||
|
}
|
||||||
|
|
||||||
void ReportEngine::setShowProgressDialog(bool value)
|
void ReportEngine::setShowProgressDialog(bool value)
|
||||||
{
|
{
|
||||||
@ -1748,6 +1788,80 @@ bool PrintProcessor::printPage(PageItemDesignIntf::Ptr page)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
void PrintProcessor::initPrinter(PageItemDesignIntf* page)
|
void PrintProcessor::initPrinter(PageItemDesignIntf* page)
|
||||||
{
|
{
|
||||||
if (page->oldPrintMode()){
|
if (page->oldPrintMode()){
|
||||||
|
@ -140,6 +140,17 @@ class PreviewReportWidget;
|
|||||||
|
|
||||||
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
|
||||||
friend class ReportDesignWidget;
|
friend class ReportDesignWidget;
|
||||||
@ -201,6 +212,9 @@ public:
|
|||||||
void setPreviewScaleType(const ScaleType &previewScaleType, int percent = 0);
|
void setPreviewScaleType(const ScaleType &previewScaleType, int percent = 0);
|
||||||
void addWatermark(const WatermarkSetting& watermarkSetting);
|
void addWatermark(const WatermarkSetting& watermarkSetting);
|
||||||
void clearWatermarks();
|
void clearWatermarks();
|
||||||
|
IPreparedPages* preparedPages();
|
||||||
|
bool showPreparedPages(PreviewHints hints = PreviewBarsUserSetting);
|
||||||
|
bool prepareReportPages();
|
||||||
signals:
|
signals:
|
||||||
void cleared();
|
void cleared();
|
||||||
void renderStarted();
|
void renderStarted();
|
||||||
|
@ -74,6 +74,7 @@ private:
|
|||||||
const WatermarkSetting& m_watermark;
|
const WatermarkSetting& m_watermark;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class ReportEnginePrivateInterface {
|
class ReportEnginePrivateInterface {
|
||||||
public:
|
public:
|
||||||
virtual PageDesignIntf* appendPage(const QString& pageName="") = 0;
|
virtual PageDesignIntf* appendPage(const QString& pageName="") = 0;
|
||||||
@ -111,6 +112,24 @@ public:
|
|||||||
virtual void setCurrentDesignerLanguage(QLocale::Language language) = 0;
|
virtual void setCurrentDesignerLanguage(QLocale::Language language) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
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 PrintProcessor{
|
class PrintProcessor{
|
||||||
public:
|
public:
|
||||||
explicit PrintProcessor(QPrinter* printer);
|
explicit PrintProcessor(QPrinter* printer);
|
||||||
@ -243,6 +262,9 @@ public:
|
|||||||
void setPreviewScaleType(const ScaleType &previewScaleType, int percent = 0);
|
void setPreviewScaleType(const ScaleType &previewScaleType, int percent = 0);
|
||||||
void addWatermark(const WatermarkSetting& watermarkSetting);
|
void addWatermark(const WatermarkSetting& watermarkSetting);
|
||||||
void clearWatermarks();
|
void clearWatermarks();
|
||||||
|
IPreparedPages* preparedPages(){return &m_preparedPagesManager;}
|
||||||
|
bool showPreparedPages(PreviewHints hints);
|
||||||
|
bool prepareReportPages();
|
||||||
signals:
|
signals:
|
||||||
void pagesLoadFinished();
|
void pagesLoadFinished();
|
||||||
void datasourceCollectionLoadFinished(const QString& collectionName);
|
void datasourceCollectionLoadFinished(const QString& collectionName);
|
||||||
@ -267,6 +289,7 @@ public slots:
|
|||||||
void cancelRender();
|
void cancelRender();
|
||||||
protected:
|
protected:
|
||||||
PageDesignIntf* createPage(const QString& pageName="", bool preview = false);
|
PageDesignIntf* createPage(const QString& pageName="", bool preview = false);
|
||||||
|
bool showPreviewWindow(ReportPages pages, PreviewHints hints);
|
||||||
protected slots:
|
protected slots:
|
||||||
void slotDataSourceCollectionLoaded(const QString& collectionName);
|
void slotDataSourceCollectionLoaded(const QString& collectionName);
|
||||||
private slots:
|
private slots:
|
||||||
@ -296,6 +319,8 @@ private:
|
|||||||
private:
|
private:
|
||||||
QList<PageDesignIntf*> m_pages;
|
QList<PageDesignIntf*> m_pages;
|
||||||
QList<PageItemDesignIntf*> m_renderingPages;
|
QList<PageItemDesignIntf*> m_renderingPages;
|
||||||
|
ReportPages m_preparedPages;
|
||||||
|
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