Finish 1.4.132

# Conflicts:
#	include/lrpreviewreportwidget.h
#	include/lrreportengine.h
#	limereport/limereport.pri
#	limereport/limereport.pro
#	limereport/lrpreviewreportwidget.h
#	limereport/lrpreviewreportwindow.h
#	limereport/lrreportengine.cpp
#	limereport/lrreportengine.h
#	limereport/lrreportengine_p.h
This commit is contained in:
Arin Alexander 2019-05-29 18:10:26 +03:00
commit 0245f5993a
15 changed files with 188 additions and 131 deletions

View File

@ -120,7 +120,7 @@ RCC_DIR = $${ARCH_DIR}/$${BUILD_TYPE}/rcc
LIMEREPORT_VERSION_MAJOR = 1
LIMEREPORT_VERSION_MINOR = 4
LIMEREPORT_VERSION_RELEASE = 129
LIMEREPORT_VERSION_RELEASE = 132
LIMEREPORT_VERSION = '$${LIMEREPORT_VERSION_MAJOR}.$${LIMEREPORT_VERSION_MINOR}.$${LIMEREPORT_VERSION_RELEASE}'
DEFINES *= LIMEREPORT_VERSION_STR=\\\"$${LIMEREPORT_VERSION}\\\"

View File

@ -5,6 +5,7 @@
#include <QTimer>
#include <QPrinter>
#include "lrglobal.h"
#include "lrpreparedpagesintf.h"
namespace LimeReport {
@ -64,6 +65,7 @@ signals:
void scalePercentChanged(int percent);
void pagesSet(int pageCount);
void itemInserted(LimeReport::PageDesignIntf* report, QPointF pos, const QString& ItemType);
void onSave(bool& saved, LimeReport::IPreparedPages* pages);
private slots:
void slotSliderMoved(int value);
void reportEngineDestroyed(QObject* object);

View File

@ -40,6 +40,7 @@
#include "lrscriptenginemanagerintf.h"
#include "lrpreviewreportwidget.h"
#include "lrreportdesignwindowintrerface.h"
#include "lrpreparedpagesintf.h"
class QPrinter;
class QGraphicsScene;
@ -137,20 +138,10 @@ class PageDesignIntf;
class PageItemDesignIntf;
class ReportDesignWidget;
class PreviewReportWidget;
class PreparedPages;
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{
Q_OBJECT
friend class ReportDesignWidget;
@ -223,6 +214,7 @@ signals:
void onSave(bool& saved);
void onSaveAs(bool& saved);
void onLoad(bool& loaded);
void onSavePreview(bool& saved, LimeReport::IPreparedPages* pages);
void saveFinished();
void loadFinished();
void printedToPDF(QString fileName);

View File

@ -67,7 +67,9 @@ SOURCES += \
$$REPORT_PATH/items/lrchartitem.cpp \
$$REPORT_PATH/items/lrchartitemeditor.cpp \
$$REPORT_PATH/lrreporttranslation.cpp \
$$REPORT_PATH/exporters/lrpdfexporter.cpp
$$REPORT_PATH/exporters/lrpdfexporter.cpp \
$$REPORT_PATH/lrpreparedpages.cpp
contains(CONFIG, staticlib){
SOURCES += $$REPORT_PATH/lrfactoryinitializer.cpp
@ -149,7 +151,10 @@ HEADERS += \
$$REPORT_PATH/lrreportdesignwindowintrerface.h \
$$REPORT_PATH/lrexporterintf.h \
$$REPORT_PATH/lrexportersfactory.h \
$$REPORT_PATH/exporters/lrpdfexporter.h
$$REPORT_PATH/exporters/lrpdfexporter.h \
$$REPORT_PATH/lrpreparedpages.h \
$$REPORT_PATH/lrpreparedpagesintf.h
contains(CONFIG, staticlib){
HEADERS += $$REPORT_PATH/lrfactoryinitializer.h

View File

@ -40,7 +40,8 @@ EXTRA_FILES += \
$$PWD/lrscriptenginemanagerintf.h \
$$PWD/lrcallbackdatasourceintf.h \
$$PWD/lrpreviewreportwidget.h \
$$PWD/lrreportdesignwindowintrerface.h
$$PWD/lrreportdesignwindowintrerface.h \
$$PWD/lrpreparedpagesintf.h
include(limereport.pri)

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

View 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

View 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

View File

@ -12,6 +12,7 @@
#include "lrreportengine_p.h"
#include "lrpreviewreportwidget_p.h"
#include "serializators/lrxmlwriter.h"
#include "lrpreparedpages.h"
#include "lrexportersfactory.h"
@ -281,6 +282,10 @@ void PreviewReportWidget::pageNavigatorChanged(int value)
void PreviewReportWidget::saveToFile()
{
bool saved = false;
PreparedPages pagesManager = PreparedPages(&d_ptr->m_reportPages);
emit onSave(saved, &pagesManager);
if (!saved){
QString fileName = QFileDialog::getSaveFileName(this,tr("Report file name"));
if (!fileName.isEmpty()){
QScopedPointer< ItemsWriterIntf > writer(new XMLWriter());
@ -289,6 +294,7 @@ void PreviewReportWidget::saveToFile()
}
writer->saveToFile(fileName);
}
}
}
void PreviewReportWidget::setScalePercent(int percent)

View File

@ -5,6 +5,7 @@
#include <QTimer>
#include <QPrinter>
#include "lrglobal.h"
#include "lrpreparedpagesintf.h"
namespace LimeReport {
@ -64,6 +65,7 @@ signals:
void scalePercentChanged(int percent);
void pagesSet(int pageCount);
void itemInserted(LimeReport::PageDesignIntf* report, QPointF pos, const QString& ItemType);
void onSave(bool& saved, LimeReport::IPreparedPages* pages);
private slots:
void slotSliderMoved(int value);
void reportEngineDestroyed(QObject* object);

View File

@ -64,9 +64,14 @@ PreviewReportWindow::PreviewReportWindow(ReportEngine *report, QWidget *parent,
m_previewReportWidget = new PreviewReportWidget(report,this);
setCentralWidget(m_previewReportWidget);
layout()->setContentsMargins(1,1,1,1);
connect(m_previewReportWidget,SIGNAL(pageChanged(int)), this,SLOT(slotPageChanged(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(pageChanged(int)),
this, SLOT(slotPageChanged(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 FontEditorWidgetForPage(m_previewReportWidget->d_ptr->m_previewPage,tr("Font"),this);
m_fontEditor->setObjectName("fontTools");

View File

@ -39,6 +39,7 @@
#include <QPrinter>
#include "serializators/lrxmlreader.h"
#include "lrpreparedpagesintf.h"
namespace LimeReport {
@ -117,6 +118,8 @@ private slots:
void on_actionShow_Toolbar_triggered();
void slotCurrentPageChanged(int page);
void slotItemInserted(LimeReport::PageDesignIntf* report, QPointF pos, const QString& ItemType);
signals:
void onSave(bool& saved, LimeReport::IPreparedPages* pages);
private:
ItemsReaderIntf* reader();
void initPercentCombobox();

View File

@ -66,6 +66,7 @@
# define EASY_BLOCK(...)
# define EASY_END_BLOCK
#endif
#include "lrpreparedpages.h"
#ifdef HAVE_STATIC_BUILD
#include "lrfactoryinitializer.h"
@ -76,7 +77,7 @@ namespace LimeReport{
QSettings* ReportEngine::m_settings = 0;
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_showProgressDialog(true), m_reportName(""), m_activePreview(0),
m_previewWindowIcon(":/report/images/logo32"), m_previewWindowTitle(tr("Preview")),
@ -146,6 +147,7 @@ ReportEnginePrivate::~ReportEnginePrivate()
m_translations.clear();
if (m_ownedSettings&&m_settings) delete m_settings;
delete m_preparedPagesManager;
}
QObject* ReportEnginePrivate::createElement(const QString &, const QString &)
@ -534,6 +536,8 @@ bool ReportEnginePrivate::showPreviewWindow(ReportPages pages, PreviewHints hint
w->setPreviewScaleType(m_previewScaleType, m_previewScalePercent);
connect(w,SIGNAL(destroyed(QObject*)), this, SLOT(slotPreviewWindowDestroyed(QObject*)));
connect(w, SIGNAL(onSave(bool&, LimeReport::IPreparedPages*)),
this, SIGNAL(onSavePreview(bool&, LimeReport::IPreparedPages*)));
w->exec();
return true;
}
@ -969,6 +973,10 @@ PageItemDesignIntf* ReportEnginePrivate::getPageByName(const QString& pageName)
return 0;
}
IPreparedPages *ReportEnginePrivate::preparedPages(){
return m_preparedPagesManager;
}
bool ReportEnginePrivate::showPreparedPages(PreviewHints hints)
{
return showPreviewWindow(m_preparedPages, hints);
@ -1383,7 +1391,8 @@ ReportEngine::ReportEngine(QObject *parent)
connect(d, SIGNAL(externalPaint(const QString&, QPainter*, const QStyleOptionGraphicsItem*)),
this, SIGNAL(externalPaint(const QString&, QPainter*, const QStyleOptionGraphicsItem*)));
connect(d, SIGNAL(onSavePreview(bool&, LimeReport::IPreparedPages*)),
this, SIGNAL(onSavePreview(bool&, LimeReport::IPreparedPages*)));
}
ReportEngine::~ReportEngine()
@ -1788,80 +1797,6 @@ bool PrintProcessor::printPage(PageItemDesignIntf::Ptr page)
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)
{
if (page->oldPrintMode()){

View File

@ -40,6 +40,7 @@
#include "lrscriptenginemanagerintf.h"
#include "lrpreviewreportwidget.h"
#include "lrreportdesignwindowintrerface.h"
#include "lrpreparedpagesintf.h"
class QPrinter;
class QGraphicsScene;
@ -137,20 +138,10 @@ class PageDesignIntf;
class PageItemDesignIntf;
class ReportDesignWidget;
class PreviewReportWidget;
class PreparedPages;
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{
Q_OBJECT
friend class ReportDesignWidget;
@ -223,6 +214,7 @@ signals:
void onSave(bool& saved);
void onSaveAs(bool& saved);
void onLoad(bool& loaded);
void onSavePreview(bool& saved, LimeReport::IPreparedPages* pages);
void saveFinished();
void loadFinished();
void printedToPDF(QString fileName);

View File

@ -112,24 +112,6 @@ public:
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{
public:
explicit PrintProcessor(QPrinter* printer);
@ -262,7 +244,7 @@ public:
void setPreviewScaleType(const ScaleType &previewScaleType, int percent = 0);
void addWatermark(const WatermarkSetting& watermarkSetting);
void clearWatermarks();
IPreparedPages* preparedPages(){return &m_preparedPagesManager;}
IPreparedPages* preparedPages();
bool showPreparedPages(PreviewHints hints);
bool prepareReportPages();
signals:
@ -274,6 +256,7 @@ signals:
void renderPageFinished(int renderedPageCount);
void onSave(bool& saved);
void onSaveAs(bool& saved);
void onSavePreview(bool& saved, LimeReport::IPreparedPages* pages);
void onLoad(bool& loaded);
void saveFinished();
void loadFinished();
@ -320,7 +303,7 @@ private:
QList<PageDesignIntf*> m_pages;
QList<PageItemDesignIntf*> m_renderingPages;
ReportPages m_preparedPages;
PreparedPages m_preparedPagesManager;
PreparedPages* m_preparedPagesManager;
DataSourceManager* m_datasources;
ScriptEngineContext* m_scriptEngineContext;
ReportRender::Ptr m_reportRender;