Finish 1.4.86

# Conflicts:
#	include/lrpreviewreportwidget.h
#	include/lrreportengine.h
#	limereport/lrpreviewreportwidget.cpp
#	limereport/lrpreviewreportwidget.h
#	limereport/lrreportengine.cpp
#	limereport/lrreportengine.h
#	limereport/lrreportengine_p.h
This commit is contained in:
Arin Alexander 2018-07-11 03:05:55 +03:00
commit 7064f911e6
12 changed files with 159 additions and 5 deletions

View File

@ -105,7 +105,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 = 85 LIMEREPORT_VERSION_RELEASE = 86
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}\\\"

View File

@ -106,6 +106,7 @@ namespace Const{
enum ExpandType {EscapeSymbols, NoEscapeSymbols, ReplaceHTMLSymbols}; enum ExpandType {EscapeSymbols, NoEscapeSymbols, ReplaceHTMLSymbols};
enum RenderPass {FirstPass = 1, SecondPass = 2}; enum RenderPass {FirstPass = 1, SecondPass = 2};
enum ArrangeType {AsNeeded, Force}; enum ArrangeType {AsNeeded, Force};
enum ScaleType {FitWidth, FitPage, OneToOne, Percents};
enum PreviewHint{ShowAllPreviewBars = 0, enum PreviewHint{ShowAllPreviewBars = 0,
HidePreviewToolBar = 1, HidePreviewToolBar = 1,
HidePreviewMenuBar = 2, HidePreviewMenuBar = 2,

View File

@ -2,6 +2,7 @@
#define LRPREVIEWREPORTWIDGET_H #define LRPREVIEWREPORTWIDGET_H
#include <QWidget> #include <QWidget>
#include <QTimer>
#include "lrglobal.h" #include "lrglobal.h"
namespace LimeReport { namespace LimeReport {
@ -25,6 +26,9 @@ public:
~PreviewReportWidget(); ~PreviewReportWidget();
QList<QString> aviableExporters(); QList<QString> aviableExporters();
bool exportReport(QString exporterName, const QMap<QString, QVariant>& params = QMap<QString, QVariant>()); bool exportReport(QString exporterName, const QMap<QString, QVariant>& params = QMap<QString, QVariant>());
ScaleType scaleType() const;
int scalePercent() const;
void setScaleType(const ScaleType &scaleType, int percent = 0);
public slots: public slots:
void refreshPages(); void refreshPages();
void zoomIn(); void zoomIn();
@ -42,6 +46,8 @@ public slots:
void setScalePercent(int percent); void setScalePercent(int percent);
void fitWidth(); void fitWidth();
void fitPage(); void fitPage();
protected:
void resizeEvent(QResizeEvent *);
signals: signals:
void pageChanged(int page); void pageChanged(int page);
void scalePercentChanged(int percent); void scalePercentChanged(int percent);
@ -50,6 +56,7 @@ private slots:
void slotSliderMoved(int value); void slotSliderMoved(int value);
void reportEngineDestroyed(QObject* object); void reportEngineDestroyed(QObject* object);
void slotZoomed(double); void slotZoomed(double);
void resizeDone();
private: private:
void initPreview(); void initPreview();
void setErrorsMesagesVisible(bool visible); void setErrorsMesagesVisible(bool visible);
@ -58,6 +65,9 @@ private:
private: private:
Ui::PreviewReportWidget *ui; Ui::PreviewReportWidget *ui;
PreviewReportWidgetPrivate* d_ptr; PreviewReportWidgetPrivate* d_ptr;
ScaleType m_scaleType;
int m_scalePercent;
QTimer m_resizeTimer;
}; };
} // namespace LimeReport } // namespace LimeReport

View File

@ -116,6 +116,9 @@ public:
void setPreviewLayoutDirection(const Qt::LayoutDirection& previewLayoutDirection); void setPreviewLayoutDirection(const Qt::LayoutDirection& previewLayoutDirection);
QList<QLocale::Language> designerLanguages(); QList<QLocale::Language> designerLanguages();
QLocale::Language currentDesignerLanguage(); QLocale::Language currentDesignerLanguage();
ScaleType previewScaleType();
int previewScalePercent();
void setPreviewScaleType(const ScaleType &previewScaleType, int percent = 0);
signals: signals:
void cleared(); void cleared();
void renderStarted(); void renderStarted();

View File

@ -106,6 +106,7 @@ namespace Const{
enum ExpandType {EscapeSymbols, NoEscapeSymbols, ReplaceHTMLSymbols}; enum ExpandType {EscapeSymbols, NoEscapeSymbols, ReplaceHTMLSymbols};
enum RenderPass {FirstPass = 1, SecondPass = 2}; enum RenderPass {FirstPass = 1, SecondPass = 2};
enum ArrangeType {AsNeeded, Force}; enum ArrangeType {AsNeeded, Force};
enum ScaleType {FitWidth, FitPage, OneToOne, Percents};
enum PreviewHint{ShowAllPreviewBars = 0, enum PreviewHint{ShowAllPreviewBars = 0,
HidePreviewToolBar = 1, HidePreviewToolBar = 1,
HidePreviewMenuBar = 2, HidePreviewMenuBar = 2,

View File

@ -70,19 +70,21 @@ QList<QString> PreviewReportWidgetPrivate::aviableExporters()
PreviewReportWidget::PreviewReportWidget(ReportEngine *report, QWidget *parent) : PreviewReportWidget::PreviewReportWidget(ReportEngine *report, QWidget *parent) :
QWidget(parent), QWidget(parent),
ui(new Ui::PreviewReportWidget), d_ptr(new PreviewReportWidgetPrivate(this)) ui(new Ui::PreviewReportWidget), d_ptr(new PreviewReportWidgetPrivate(this)),
m_scaleType(FitWidth), m_scalePercent(0)
{ {
ui->setupUi(this); ui->setupUi(this);
d_ptr->m_report = report->d_ptr; d_ptr->m_report = report->d_ptr;
d_ptr->m_previewPage = d_ptr->m_report->createPreviewPage(); d_ptr->m_previewPage = d_ptr->m_report->createPreviewPage();
d_ptr->m_previewPage->setItemMode( LimeReport::PreviewMode ); d_ptr->m_previewPage->setItemMode( LimeReport::PreviewMode );
m_resizeTimer.setSingleShot(true);
ui->errorsView->setVisible(false); ui->errorsView->setVisible(false);
connect(ui->graphicsView->verticalScrollBar(),SIGNAL(valueChanged(int)), this, SLOT(slotSliderMoved(int))); connect(ui->graphicsView->verticalScrollBar(),SIGNAL(valueChanged(int)), this, SLOT(slotSliderMoved(int)));
connect(d_ptr->m_report, SIGNAL(destroyed(QObject*)), this, SLOT(reportEngineDestroyed(QObject*))); connect(d_ptr->m_report, SIGNAL(destroyed(QObject*)), this, SLOT(reportEngineDestroyed(QObject*)));
d_ptr->m_zoomer = new GraphicsViewZoomer(ui->graphicsView); d_ptr->m_zoomer = new GraphicsViewZoomer(ui->graphicsView);
connect(d_ptr->m_zoomer, SIGNAL(zoomed(double)), this, SLOT(slotZoomed(double))); connect(d_ptr->m_zoomer, SIGNAL(zoomed(double)), this, SLOT(slotZoomed(double)));
connect(&m_resizeTimer, SIGNAL(timeout()), this, SLOT(resizeDone()));
} }
PreviewReportWidget::~PreviewReportWidget() PreviewReportWidget::~PreviewReportWidget()
@ -256,6 +258,11 @@ void PreviewReportWidget::setScalePercent(int percent)
qreal scaleSize = percent/100.0; qreal scaleSize = percent/100.0;
ui->graphicsView->scale(scaleSize, scaleSize); ui->graphicsView->scale(scaleSize, scaleSize);
emit scalePercentChanged(percent); emit scalePercentChanged(percent);
if (percent == 100){
m_scaleType = OneToOne;
} else {
m_scaleType = Percents;
}
} }
void PreviewReportWidget::fitWidth() void PreviewReportWidget::fitWidth()
@ -263,6 +270,7 @@ void PreviewReportWidget::fitWidth()
if (d_ptr->currentPage()){ if (d_ptr->currentPage()){
qreal scalePercent = ui->graphicsView->viewport()->width() / ui->graphicsView->scene()->width(); qreal scalePercent = ui->graphicsView->viewport()->width() / ui->graphicsView->scene()->width();
setScalePercent(scalePercent*100); setScalePercent(scalePercent*100);
m_scaleType = FitWidth;
} }
} }
@ -272,9 +280,15 @@ void PreviewReportWidget::fitPage()
qreal vScale = ui->graphicsView->viewport()->width() / ui->graphicsView->scene()->width(); qreal vScale = ui->graphicsView->viewport()->width() / ui->graphicsView->scene()->width();
qreal hScale = ui->graphicsView->viewport()->height() / d_ptr->currentPage()->height(); qreal hScale = ui->graphicsView->viewport()->height() / d_ptr->currentPage()->height();
setScalePercent(qMin(vScale,hScale)*100); setScalePercent(qMin(vScale,hScale)*100);
m_scaleType = FitPage;
} }
} }
void PreviewReportWidget::resizeEvent(QResizeEvent *)
{
m_resizeTimer.start(100);
}
void PreviewReportWidget::setErrorMessages(const QStringList &value) void PreviewReportWidget::setErrorMessages(const QStringList &value)
{ {
foreach (QString line, value) { foreach (QString line, value) {
@ -287,6 +301,22 @@ void PreviewReportWidget::emitPageSet()
emit pagesSet(d_ptr->m_reportPages.count()); emit pagesSet(d_ptr->m_reportPages.count());
} }
ScaleType PreviewReportWidget::scaleType() const
{
return m_scaleType;
}
int PreviewReportWidget::scalePercent() const
{
return m_scalePercent;
}
void PreviewReportWidget::setScaleType(const ScaleType &scaleType, int percent)
{
m_scaleType = scaleType;
m_scalePercent = percent;
}
void PreviewReportWidget::refreshPages() void PreviewReportWidget::refreshPages()
{ {
if (d_ptr->m_report){ if (d_ptr->m_report){
@ -340,6 +370,23 @@ void PreviewReportWidget::slotZoomed(double )
emit scalePercentChanged(d_ptr->m_scalePercent); emit scalePercentChanged(d_ptr->m_scalePercent);
} }
void PreviewReportWidget::resizeDone()
{
switch (m_scaleType) {
case FitPage:
fitPage();
break;
case FitWidth:
fitWidth();
break;
case OneToOne:
setScalePercent(100);
break;
case Percents:
setScalePercent(m_scalePercent);
break;
}
}
} }

View File

@ -2,6 +2,7 @@
#define LRPREVIEWREPORTWIDGET_H #define LRPREVIEWREPORTWIDGET_H
#include <QWidget> #include <QWidget>
#include <QTimer>
#include "lrglobal.h" #include "lrglobal.h"
namespace LimeReport { namespace LimeReport {
@ -25,6 +26,9 @@ public:
~PreviewReportWidget(); ~PreviewReportWidget();
QList<QString> aviableExporters(); QList<QString> aviableExporters();
bool exportReport(QString exporterName, const QMap<QString, QVariant>& params = QMap<QString, QVariant>()); bool exportReport(QString exporterName, const QMap<QString, QVariant>& params = QMap<QString, QVariant>());
ScaleType scaleType() const;
int scalePercent() const;
void setScaleType(const ScaleType &scaleType, int percent = 0);
public slots: public slots:
void refreshPages(); void refreshPages();
void zoomIn(); void zoomIn();
@ -42,6 +46,8 @@ public slots:
void setScalePercent(int percent); void setScalePercent(int percent);
void fitWidth(); void fitWidth();
void fitPage(); void fitPage();
protected:
void resizeEvent(QResizeEvent *);
signals: signals:
void pageChanged(int page); void pageChanged(int page);
void scalePercentChanged(int percent); void scalePercentChanged(int percent);
@ -50,6 +56,7 @@ private slots:
void slotSliderMoved(int value); void slotSliderMoved(int value);
void reportEngineDestroyed(QObject* object); void reportEngineDestroyed(QObject* object);
void slotZoomed(double); void slotZoomed(double);
void resizeDone();
private: private:
void initPreview(); void initPreview();
void setErrorsMesagesVisible(bool visible); void setErrorsMesagesVisible(bool visible);
@ -58,6 +65,9 @@ private:
private: private:
Ui::PreviewReportWidget *ui; Ui::PreviewReportWidget *ui;
PreviewReportWidgetPrivate* d_ptr; PreviewReportWidgetPrivate* d_ptr;
ScaleType m_scaleType;
int m_scalePercent;
QTimer m_resizeTimer;
}; };
} // namespace LimeReport } // namespace LimeReport

View File

@ -255,7 +255,22 @@ void PreviewReportWindow::showEvent(QShowEvent *)
{ {
m_fontEditor->setVisible(ui->actionEdit_Mode->isChecked()); m_fontEditor->setVisible(ui->actionEdit_Mode->isChecked());
m_textAlignmentEditor->setVisible(ui->actionEdit_Mode->isChecked()); m_textAlignmentEditor->setVisible(ui->actionEdit_Mode->isChecked());
switch (m_previewScaleType) {
case FitWidth:
m_previewReportWidget->fitWidth();
break;
case FitPage:
m_previewReportWidget->fitPage();
break;
case OneToOne:
m_previewReportWidget->setScalePercent(100);
break;
case Percents:
m_previewReportWidget->setScalePercent(m_previewScalePercent);
} }
}
void PreviewReportWindow::selectStateIcon() void PreviewReportWindow::selectStateIcon()
{ {
if (ui->toolBar->isHidden()){ if (ui->toolBar->isHidden()){
@ -335,6 +350,18 @@ void PreviewReportWindow::initPercentCombobox()
m_scalePercent->setCurrentIndex(4); m_scalePercent->setCurrentIndex(4);
} }
ScaleType PreviewReportWindow::previewScaleType() const
{
return m_previewScaleType;
}
void PreviewReportWindow::setPreviewScaleType(const ScaleType &previewScaleType, int percent)
{
m_previewScaleType = previewScaleType;
m_previewScalePercent = percent;
m_previewReportWidget->setScaleType(previewScaleType, percent);
}
void PreviewReportWindow::on_actionSaveToFile_triggered() void PreviewReportWindow::on_actionSaveToFile_triggered()
{ {
m_previewReportWidget->saveToFile(); m_previewReportWidget->saveToFile();

View File

@ -71,6 +71,9 @@ public:
void setMenuVisible(bool value); void setMenuVisible(bool value);
void setHideResultEditButton(bool value); void setHideResultEditButton(bool value);
QSettings* settings(); QSettings* settings();
ScaleType previewScaleType() const;
void setPreviewScaleType(const ScaleType &previewScaleType, int percent = 0);
protected: protected:
void writeSetting(); void writeSetting();
void restoreSetting(); void restoreSetting();
@ -118,6 +121,9 @@ private:
int m_priorScrolValue; int m_priorScrolValue;
PreviewReportWidget* m_previewReportWidget; PreviewReportWidget* m_previewReportWidget;
QComboBox* m_scalePercent; QComboBox* m_scalePercent;
ScaleType m_previewScaleType;
int m_previewScalePercent;
}; };
} //namespace LimeReport } //namespace LimeReport
#endif // LRPREVIEWREPORTWINDOW_H #endif // LRPREVIEWREPORTWINDOW_H

View File

@ -81,7 +81,8 @@ ReportEnginePrivate::ReportEnginePrivate(QObject *parent) :
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_reportLanguage(QLocale::AnyLanguage), m_fileWatcher( new QFileSystemWatcher( this ) ), m_reportLanguage(QLocale::AnyLanguage),
m_previewLayoutDirection(Qt::LeftToRight), m_designerFactory(0) m_previewLayoutDirection(Qt::LeftToRight), m_designerFactory(0),
m_previewScaleType(FitWidth), m_previewScalePercent(0)
{ {
#ifdef HAVE_STATIC_BUILD #ifdef HAVE_STATIC_BUILD
initResources(); initResources();
@ -527,6 +528,7 @@ void ReportEnginePrivate::previewReport(PreviewHints hints)
w->setSettings(settings()); w->setSettings(settings());
w->setPages(pages); w->setPages(pages);
w->setLayoutDirection(m_previewLayoutDirection); w->setLayoutDirection(m_previewLayoutDirection);
if (!dataManager()->errorsList().isEmpty()){ if (!dataManager()->errorsList().isEmpty()){
w->setErrorMessages(dataManager()->errorsList()); w->setErrorMessages(dataManager()->errorsList());
} }
@ -540,6 +542,9 @@ void ReportEnginePrivate::previewReport(PreviewHints hints)
w->setHideResultEditButton(resultIsEditable()); w->setHideResultEditButton(resultIsEditable());
w->setStyleSheet(m_styleSheet); w->setStyleSheet(m_styleSheet);
m_activePreview = w; m_activePreview = w;
w->setPreviewScaleType(m_previewScaleType, m_previewScalePercent);
connect(w,SIGNAL(destroyed(QObject*)), this, SLOT(slotPreviewWindowDestroyed(QObject*))); connect(w,SIGNAL(destroyed(QObject*)), this, SLOT(slotPreviewWindowDestroyed(QObject*)));
w->exec(); w->exec();
} }
@ -910,6 +915,23 @@ QString ReportEnginePrivate::renderToString()
render.setScriptContext(scriptContext()); render.setScriptContext(scriptContext());
return render.renderPageToString(m_pages.at(0)->pageItem()); return render.renderPageToString(m_pages.at(0)->pageItem());
} else return QString(); } else return QString();
}
ScaleType ReportEnginePrivate::previewScaleType()
{
return m_previewScaleType;
}
int ReportEnginePrivate::previewScalePercent()
{
return m_previewScalePercent;
}
void ReportEnginePrivate::setPreviewScaleType(const ScaleType &scaleType, int percent)
{
m_previewScaleType = scaleType;
m_previewScalePercent = percent;
} }
PageItemDesignIntf* ReportEnginePrivate::getPageByName(const QString& pageName) PageItemDesignIntf* ReportEnginePrivate::getPageByName(const QString& pageName)
@ -1344,6 +1366,25 @@ QLocale::Language ReportEngine::currentDesignerLanguage()
return d->currentDesignerLanguage(); return d->currentDesignerLanguage();
} }
ScaleType ReportEngine::previewScaleType()
{
Q_D(ReportEngine);
return d->previewScaleType();
}
int ReportEngine::previewScalePercent()
{
Q_D(ReportEngine);
return d->previewScalePercent();
}
void ReportEngine::setPreviewScaleType(const ScaleType &previewScaleType, int percent)
{
Q_D(ReportEngine);
d->setPreviewScaleType(previewScaleType, percent);
}
void ReportEngine::setShowProgressDialog(bool value) void ReportEngine::setShowProgressDialog(bool value)
{ {
Q_D(ReportEngine); Q_D(ReportEngine);

View File

@ -116,6 +116,9 @@ public:
void setPreviewLayoutDirection(const Qt::LayoutDirection& previewLayoutDirection); void setPreviewLayoutDirection(const Qt::LayoutDirection& previewLayoutDirection);
QList<QLocale::Language> designerLanguages(); QList<QLocale::Language> designerLanguages();
QLocale::Language currentDesignerLanguage(); QLocale::Language currentDesignerLanguage();
ScaleType previewScaleType();
int previewScalePercent();
void setPreviewScaleType(const ScaleType &previewScaleType, int percent = 0);
signals: signals:
void cleared(); void cleared();
void renderStarted(); void renderStarted();

View File

@ -193,6 +193,9 @@ public:
QList<QLocale::Language> designerLanguages(); QList<QLocale::Language> designerLanguages();
QLocale::Language currentDesignerLanguage(); QLocale::Language currentDesignerLanguage();
void setCurrentDesignerLanguage(QLocale::Language language); void setCurrentDesignerLanguage(QLocale::Language language);
ScaleType previewScaleType();
int previewScalePercent();
void setPreviewScaleType(const ScaleType &previewScaleType, int percent = 0);
signals: signals:
void pagesLoadFinished(); void pagesLoadFinished();
void datasourceCollectionLoadFinished(const QString& collectionName); void datasourceCollectionLoadFinished(const QString& collectionName);
@ -271,6 +274,8 @@ private:
QString m_styleSheet; QString m_styleSheet;
QLocale::Language m_currentDesignerLanguage; QLocale::Language m_currentDesignerLanguage;
QMap<QString, ReportExporterInterface*> exporters; QMap<QString, ReportExporterInterface*> exporters;
ScaleType m_previewScaleType;
int m_previewScalePercent;
}; };
} }