Finish 1.4.86

This commit is contained in:
Arin Alexander 2018-07-11 02:50:17 +03:00
commit 52f34dc9c1
12 changed files with 159 additions and 4 deletions

View File

@ -62,7 +62,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

@ -103,6 +103,7 @@ namespace Const{
enum ExpandType {EscapeSymbols, NoEscapeSymbols, ReplaceHTMLSymbols}; enum ExpandType {EscapeSymbols, NoEscapeSymbols, ReplaceHTMLSymbols};
enum RenderPass {FirstPass, SecondPass}; enum RenderPass {FirstPass, SecondPass};
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 {
@ -22,6 +23,9 @@ class LIMEREPORT_EXPORT PreviewReportWidget : public QWidget
public: public:
explicit PreviewReportWidget(ReportEnginePrivate *report, QWidget *parent = 0); explicit PreviewReportWidget(ReportEnginePrivate *report, QWidget *parent = 0);
~PreviewReportWidget(); ~PreviewReportWidget();
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();
@ -39,6 +43,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);
@ -47,6 +53,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);
@ -55,6 +62,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

@ -104,6 +104,9 @@ public:
void setPassPharse(QString& passPharse); void setPassPharse(QString& passPharse);
Qt::LayoutDirection previewLayoutDirection(); Qt::LayoutDirection previewLayoutDirection();
void setPreviewLayoutDirection(const Qt::LayoutDirection& previewLayoutDirection); void setPreviewLayoutDirection(const Qt::LayoutDirection& previewLayoutDirection);
ScaleType previewScaleType();
int previewScalePercent();
void setPreviewScaleType(const ScaleType &previewScaleType, int percent = 0);
signals: signals:
void renderStarted(); void renderStarted();
void renderFinished(); void renderFinished();

View File

@ -103,6 +103,7 @@ namespace Const{
enum ExpandType {EscapeSymbols, NoEscapeSymbols, ReplaceHTMLSymbols}; enum ExpandType {EscapeSymbols, NoEscapeSymbols, ReplaceHTMLSymbols};
enum RenderPass {FirstPass, SecondPass}; enum RenderPass {FirstPass, SecondPass};
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

@ -61,18 +61,21 @@ PageItemDesignIntf::Ptr PreviewReportWidgetPrivate::currentPage()
PreviewReportWidget::PreviewReportWidget(ReportEnginePrivate *report, QWidget *parent) : PreviewReportWidget::PreviewReportWidget(ReportEnginePrivate *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_previewPage = report->createPreviewPage(); d_ptr->m_previewPage = report->createPreviewPage();
d_ptr->m_previewPage->setItemMode( LimeReport::PreviewMode ); d_ptr->m_previewPage->setItemMode( LimeReport::PreviewMode );
d_ptr->m_report = report; d_ptr->m_report = report;
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()
@ -221,6 +224,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()
@ -228,6 +236,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;
} }
} }
@ -237,9 +246,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) {
@ -252,6 +267,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){
@ -305,6 +336,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 {
@ -22,6 +23,9 @@ class LIMEREPORT_EXPORT PreviewReportWidget : public QWidget
public: public:
explicit PreviewReportWidget(ReportEnginePrivate *report, QWidget *parent = 0); explicit PreviewReportWidget(ReportEnginePrivate *report, QWidget *parent = 0);
~PreviewReportWidget(); ~PreviewReportWidget();
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();
@ -39,6 +43,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);
@ -47,6 +53,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);
@ -55,6 +62,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

@ -253,7 +253,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()){
@ -333,6 +348,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

@ -68,6 +68,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();
@ -115,6 +118,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

@ -63,7 +63,8 @@ ReportEnginePrivate::ReportEnginePrivate(QObject *parent) :
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_fileWatcher( new QFileSystemWatcher( this ) ),
m_previewScaleType(FitWidth), m_previewScalePercent(0)
{ {
#ifdef HAVE_STATIC_BUILD #ifdef HAVE_STATIC_BUILD
initResources(); initResources();
@ -381,6 +382,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());
} }
@ -394,6 +396,9 @@ void ReportEnginePrivate::previewReport(PreviewHints hints)
w->setHideResultEditButton(resultIsEditable()); w->setHideResultEditButton(resultIsEditable());
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();
} }
@ -714,7 +719,23 @@ QString ReportEnginePrivate::renderToString()
render.setDatasources(dataManager()); render.setDatasources(dataManager());
render.setScriptContext(scriptContext()); render.setScriptContext(scriptContext());
return render.renderPageToString(m_pages.at(0)); return render.renderPageToString(m_pages.at(0));
}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;
} }
Qt::LayoutDirection ReportEnginePrivate::previewLayoutDirection() Qt::LayoutDirection ReportEnginePrivate::previewLayoutDirection()
@ -945,6 +966,25 @@ void ReportEngine::setPreviewLayoutDirection(const Qt::LayoutDirection& layoutDi
return d->setPreviewLayoutDirection(layoutDirection); return d->setPreviewLayoutDirection(layoutDirection);
} }
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

@ -104,6 +104,9 @@ public:
void setPassPharse(QString& passPharse); void setPassPharse(QString& passPharse);
Qt::LayoutDirection previewLayoutDirection(); Qt::LayoutDirection previewLayoutDirection();
void setPreviewLayoutDirection(const Qt::LayoutDirection& previewLayoutDirection); void setPreviewLayoutDirection(const Qt::LayoutDirection& previewLayoutDirection);
ScaleType previewScaleType();
int previewScalePercent();
void setPreviewScaleType(const ScaleType &previewScaleType, int percent = 0);
signals: signals:
void renderStarted(); void renderStarted();
void renderFinished(); void renderFinished();

View File

@ -132,6 +132,10 @@ public:
void clearSelection(); void clearSelection();
Qt::LayoutDirection previewLayoutDirection(); Qt::LayoutDirection previewLayoutDirection();
void setPreviewLayoutDirection(const Qt::LayoutDirection& previewLayoutDirection); void setPreviewLayoutDirection(const Qt::LayoutDirection& previewLayoutDirection);
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);
@ -186,6 +190,8 @@ private:
QString m_passPhrase; QString m_passPhrase;
QFileSystemWatcher *m_fileWatcher; QFileSystemWatcher *m_fileWatcher;
Qt::LayoutDirection m_previewLayoutDirection; Qt::LayoutDirection m_previewLayoutDirection;
ScaleType m_previewScaleType;
int m_previewScalePercent;
}; };
} }