mirror of
https://github.com/python-LimeReport/LimeReport.git
synced 2024-12-24 12:34:39 +03:00
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:
commit
7064f911e6
@ -105,7 +105,7 @@ RCC_DIR = $${ARCH_DIR}/$${BUILD_TYPE}/rcc
|
||||
|
||||
LIMEREPORT_VERSION_MAJOR = 1
|
||||
LIMEREPORT_VERSION_MINOR = 4
|
||||
LIMEREPORT_VERSION_RELEASE = 85
|
||||
LIMEREPORT_VERSION_RELEASE = 86
|
||||
|
||||
LIMEREPORT_VERSION = '$${LIMEREPORT_VERSION_MAJOR}.$${LIMEREPORT_VERSION_MINOR}.$${LIMEREPORT_VERSION_RELEASE}'
|
||||
DEFINES *= LIMEREPORT_VERSION_STR=\\\"$${LIMEREPORT_VERSION}\\\"
|
||||
|
@ -106,6 +106,7 @@ namespace Const{
|
||||
enum ExpandType {EscapeSymbols, NoEscapeSymbols, ReplaceHTMLSymbols};
|
||||
enum RenderPass {FirstPass = 1, SecondPass = 2};
|
||||
enum ArrangeType {AsNeeded, Force};
|
||||
enum ScaleType {FitWidth, FitPage, OneToOne, Percents};
|
||||
enum PreviewHint{ShowAllPreviewBars = 0,
|
||||
HidePreviewToolBar = 1,
|
||||
HidePreviewMenuBar = 2,
|
||||
|
@ -2,6 +2,7 @@
|
||||
#define LRPREVIEWREPORTWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QTimer>
|
||||
#include "lrglobal.h"
|
||||
|
||||
namespace LimeReport {
|
||||
@ -25,6 +26,9 @@ public:
|
||||
~PreviewReportWidget();
|
||||
QList<QString> aviableExporters();
|
||||
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:
|
||||
void refreshPages();
|
||||
void zoomIn();
|
||||
@ -42,6 +46,8 @@ public slots:
|
||||
void setScalePercent(int percent);
|
||||
void fitWidth();
|
||||
void fitPage();
|
||||
protected:
|
||||
void resizeEvent(QResizeEvent *);
|
||||
signals:
|
||||
void pageChanged(int page);
|
||||
void scalePercentChanged(int percent);
|
||||
@ -50,6 +56,7 @@ private slots:
|
||||
void slotSliderMoved(int value);
|
||||
void reportEngineDestroyed(QObject* object);
|
||||
void slotZoomed(double);
|
||||
void resizeDone();
|
||||
private:
|
||||
void initPreview();
|
||||
void setErrorsMesagesVisible(bool visible);
|
||||
@ -58,6 +65,9 @@ private:
|
||||
private:
|
||||
Ui::PreviewReportWidget *ui;
|
||||
PreviewReportWidgetPrivate* d_ptr;
|
||||
ScaleType m_scaleType;
|
||||
int m_scalePercent;
|
||||
QTimer m_resizeTimer;
|
||||
};
|
||||
|
||||
} // namespace LimeReport
|
||||
|
@ -116,6 +116,9 @@ public:
|
||||
void setPreviewLayoutDirection(const Qt::LayoutDirection& previewLayoutDirection);
|
||||
QList<QLocale::Language> designerLanguages();
|
||||
QLocale::Language currentDesignerLanguage();
|
||||
ScaleType previewScaleType();
|
||||
int previewScalePercent();
|
||||
void setPreviewScaleType(const ScaleType &previewScaleType, int percent = 0);
|
||||
signals:
|
||||
void cleared();
|
||||
void renderStarted();
|
||||
|
@ -106,6 +106,7 @@ namespace Const{
|
||||
enum ExpandType {EscapeSymbols, NoEscapeSymbols, ReplaceHTMLSymbols};
|
||||
enum RenderPass {FirstPass = 1, SecondPass = 2};
|
||||
enum ArrangeType {AsNeeded, Force};
|
||||
enum ScaleType {FitWidth, FitPage, OneToOne, Percents};
|
||||
enum PreviewHint{ShowAllPreviewBars = 0,
|
||||
HidePreviewToolBar = 1,
|
||||
HidePreviewMenuBar = 2,
|
||||
|
@ -70,19 +70,21 @@ QList<QString> PreviewReportWidgetPrivate::aviableExporters()
|
||||
|
||||
PreviewReportWidget::PreviewReportWidget(ReportEngine *report, 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);
|
||||
d_ptr->m_report = report->d_ptr;
|
||||
d_ptr->m_previewPage = d_ptr->m_report->createPreviewPage();
|
||||
d_ptr->m_previewPage->setItemMode( LimeReport::PreviewMode );
|
||||
|
||||
m_resizeTimer.setSingleShot(true);
|
||||
|
||||
ui->errorsView->setVisible(false);
|
||||
connect(ui->graphicsView->verticalScrollBar(),SIGNAL(valueChanged(int)), this, SLOT(slotSliderMoved(int)));
|
||||
connect(d_ptr->m_report, SIGNAL(destroyed(QObject*)), this, SLOT(reportEngineDestroyed(QObject*)));
|
||||
d_ptr->m_zoomer = new GraphicsViewZoomer(ui->graphicsView);
|
||||
connect(d_ptr->m_zoomer, SIGNAL(zoomed(double)), this, SLOT(slotZoomed(double)));
|
||||
connect(&m_resizeTimer, SIGNAL(timeout()), this, SLOT(resizeDone()));
|
||||
}
|
||||
|
||||
PreviewReportWidget::~PreviewReportWidget()
|
||||
@ -256,6 +258,11 @@ void PreviewReportWidget::setScalePercent(int percent)
|
||||
qreal scaleSize = percent/100.0;
|
||||
ui->graphicsView->scale(scaleSize, scaleSize);
|
||||
emit scalePercentChanged(percent);
|
||||
if (percent == 100){
|
||||
m_scaleType = OneToOne;
|
||||
} else {
|
||||
m_scaleType = Percents;
|
||||
}
|
||||
}
|
||||
|
||||
void PreviewReportWidget::fitWidth()
|
||||
@ -263,6 +270,7 @@ void PreviewReportWidget::fitWidth()
|
||||
if (d_ptr->currentPage()){
|
||||
qreal scalePercent = ui->graphicsView->viewport()->width() / ui->graphicsView->scene()->width();
|
||||
setScalePercent(scalePercent*100);
|
||||
m_scaleType = FitWidth;
|
||||
}
|
||||
}
|
||||
|
||||
@ -272,9 +280,15 @@ void PreviewReportWidget::fitPage()
|
||||
qreal vScale = ui->graphicsView->viewport()->width() / ui->graphicsView->scene()->width();
|
||||
qreal hScale = ui->graphicsView->viewport()->height() / d_ptr->currentPage()->height();
|
||||
setScalePercent(qMin(vScale,hScale)*100);
|
||||
m_scaleType = FitPage;
|
||||
}
|
||||
}
|
||||
|
||||
void PreviewReportWidget::resizeEvent(QResizeEvent *)
|
||||
{
|
||||
m_resizeTimer.start(100);
|
||||
}
|
||||
|
||||
void PreviewReportWidget::setErrorMessages(const QStringList &value)
|
||||
{
|
||||
foreach (QString line, value) {
|
||||
@ -287,6 +301,22 @@ void PreviewReportWidget::emitPageSet()
|
||||
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()
|
||||
{
|
||||
if (d_ptr->m_report){
|
||||
@ -340,6 +370,23 @@ void PreviewReportWidget::slotZoomed(double )
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
#define LRPREVIEWREPORTWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QTimer>
|
||||
#include "lrglobal.h"
|
||||
|
||||
namespace LimeReport {
|
||||
@ -25,6 +26,9 @@ public:
|
||||
~PreviewReportWidget();
|
||||
QList<QString> aviableExporters();
|
||||
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:
|
||||
void refreshPages();
|
||||
void zoomIn();
|
||||
@ -42,6 +46,8 @@ public slots:
|
||||
void setScalePercent(int percent);
|
||||
void fitWidth();
|
||||
void fitPage();
|
||||
protected:
|
||||
void resizeEvent(QResizeEvent *);
|
||||
signals:
|
||||
void pageChanged(int page);
|
||||
void scalePercentChanged(int percent);
|
||||
@ -50,6 +56,7 @@ private slots:
|
||||
void slotSliderMoved(int value);
|
||||
void reportEngineDestroyed(QObject* object);
|
||||
void slotZoomed(double);
|
||||
void resizeDone();
|
||||
private:
|
||||
void initPreview();
|
||||
void setErrorsMesagesVisible(bool visible);
|
||||
@ -58,6 +65,9 @@ private:
|
||||
private:
|
||||
Ui::PreviewReportWidget *ui;
|
||||
PreviewReportWidgetPrivate* d_ptr;
|
||||
ScaleType m_scaleType;
|
||||
int m_scalePercent;
|
||||
QTimer m_resizeTimer;
|
||||
};
|
||||
|
||||
} // namespace LimeReport
|
||||
|
@ -255,7 +255,22 @@ void PreviewReportWindow::showEvent(QShowEvent *)
|
||||
{
|
||||
m_fontEditor->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()
|
||||
{
|
||||
if (ui->toolBar->isHidden()){
|
||||
@ -335,6 +350,18 @@ void PreviewReportWindow::initPercentCombobox()
|
||||
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()
|
||||
{
|
||||
m_previewReportWidget->saveToFile();
|
||||
|
@ -71,6 +71,9 @@ public:
|
||||
void setMenuVisible(bool value);
|
||||
void setHideResultEditButton(bool value);
|
||||
QSettings* settings();
|
||||
ScaleType previewScaleType() const;
|
||||
void setPreviewScaleType(const ScaleType &previewScaleType, int percent = 0);
|
||||
|
||||
protected:
|
||||
void writeSetting();
|
||||
void restoreSetting();
|
||||
@ -118,6 +121,9 @@ private:
|
||||
int m_priorScrolValue;
|
||||
PreviewReportWidget* m_previewReportWidget;
|
||||
QComboBox* m_scalePercent;
|
||||
ScaleType m_previewScaleType;
|
||||
int m_previewScalePercent;
|
||||
|
||||
};
|
||||
} //namespace LimeReport
|
||||
#endif // LRPREVIEWREPORTWINDOW_H
|
||||
|
@ -81,7 +81,8 @@ ReportEnginePrivate::ReportEnginePrivate(QObject *parent) :
|
||||
m_previewWindowIcon(":/report/images/logo32"), m_previewWindowTitle(tr("Preview")),
|
||||
m_reportRendering(false), m_resultIsEditable(true), m_passPhrase("HjccbzHjlbyfCkjy"),
|
||||
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
|
||||
initResources();
|
||||
@ -527,6 +528,7 @@ void ReportEnginePrivate::previewReport(PreviewHints hints)
|
||||
w->setSettings(settings());
|
||||
w->setPages(pages);
|
||||
w->setLayoutDirection(m_previewLayoutDirection);
|
||||
|
||||
if (!dataManager()->errorsList().isEmpty()){
|
||||
w->setErrorMessages(dataManager()->errorsList());
|
||||
}
|
||||
@ -540,6 +542,9 @@ void ReportEnginePrivate::previewReport(PreviewHints hints)
|
||||
w->setHideResultEditButton(resultIsEditable());
|
||||
w->setStyleSheet(m_styleSheet);
|
||||
m_activePreview = w;
|
||||
|
||||
w->setPreviewScaleType(m_previewScaleType, m_previewScalePercent);
|
||||
|
||||
connect(w,SIGNAL(destroyed(QObject*)), this, SLOT(slotPreviewWindowDestroyed(QObject*)));
|
||||
w->exec();
|
||||
}
|
||||
@ -910,6 +915,23 @@ QString ReportEnginePrivate::renderToString()
|
||||
render.setScriptContext(scriptContext());
|
||||
return render.renderPageToString(m_pages.at(0)->pageItem());
|
||||
} 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)
|
||||
@ -1344,6 +1366,25 @@ QLocale::Language ReportEngine::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)
|
||||
{
|
||||
Q_D(ReportEngine);
|
||||
|
@ -116,6 +116,9 @@ public:
|
||||
void setPreviewLayoutDirection(const Qt::LayoutDirection& previewLayoutDirection);
|
||||
QList<QLocale::Language> designerLanguages();
|
||||
QLocale::Language currentDesignerLanguage();
|
||||
ScaleType previewScaleType();
|
||||
int previewScalePercent();
|
||||
void setPreviewScaleType(const ScaleType &previewScaleType, int percent = 0);
|
||||
signals:
|
||||
void cleared();
|
||||
void renderStarted();
|
||||
|
@ -193,6 +193,9 @@ public:
|
||||
QList<QLocale::Language> designerLanguages();
|
||||
QLocale::Language currentDesignerLanguage();
|
||||
void setCurrentDesignerLanguage(QLocale::Language language);
|
||||
ScaleType previewScaleType();
|
||||
int previewScalePercent();
|
||||
void setPreviewScaleType(const ScaleType &previewScaleType, int percent = 0);
|
||||
signals:
|
||||
void pagesLoadFinished();
|
||||
void datasourceCollectionLoadFinished(const QString& collectionName);
|
||||
@ -271,6 +274,8 @@ private:
|
||||
QString m_styleSheet;
|
||||
QLocale::Language m_currentDesignerLanguage;
|
||||
QMap<QString, ReportExporterInterface*> exporters;
|
||||
ScaleType m_previewScaleType;
|
||||
int m_previewScalePercent;
|
||||
};
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user