mirror of
https://github.com/fralx/LimeReport.git
synced 2024-12-24 00:33:02 +03:00
Preview scale type has been added
This commit is contained in:
parent
aec5dceea3
commit
b4d6ed76c8
@ -62,7 +62,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}\"
|
||||
|
@ -103,6 +103,7 @@ namespace Const{
|
||||
enum ExpandType {EscapeSymbols, NoEscapeSymbols, ReplaceHTMLSymbols};
|
||||
enum RenderPass {FirstPass, SecondPass};
|
||||
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 {
|
||||
@ -22,6 +23,9 @@ class LIMEREPORT_EXPORT PreviewReportWidget : public QWidget
|
||||
public:
|
||||
explicit PreviewReportWidget(ReportEnginePrivate *report, QWidget *parent = 0);
|
||||
~PreviewReportWidget();
|
||||
ScaleType scaleType() const;
|
||||
int scalePercent() const;
|
||||
void setScaleType(const ScaleType &scaleType, int percent = 0);
|
||||
public slots:
|
||||
void refreshPages();
|
||||
void zoomIn();
|
||||
@ -39,6 +43,8 @@ public slots:
|
||||
void setScalePercent(int percent);
|
||||
void fitWidth();
|
||||
void fitPage();
|
||||
protected:
|
||||
void resizeEvent(QResizeEvent *);
|
||||
signals:
|
||||
void pageChanged(int page);
|
||||
void scalePercentChanged(int percent);
|
||||
@ -47,6 +53,7 @@ private slots:
|
||||
void slotSliderMoved(int value);
|
||||
void reportEngineDestroyed(QObject* object);
|
||||
void slotZoomed(double);
|
||||
void resizeDone();
|
||||
private:
|
||||
void initPreview();
|
||||
void setErrorsMesagesVisible(bool visible);
|
||||
@ -55,6 +62,9 @@ private:
|
||||
private:
|
||||
Ui::PreviewReportWidget *ui;
|
||||
PreviewReportWidgetPrivate* d_ptr;
|
||||
ScaleType m_scaleType;
|
||||
int m_scalePercent;
|
||||
QTimer m_resizeTimer;
|
||||
};
|
||||
|
||||
} // namespace LimeReport
|
||||
|
@ -104,6 +104,9 @@ public:
|
||||
void setPassPharse(QString& passPharse);
|
||||
Qt::LayoutDirection previewLayoutDirection();
|
||||
void setPreviewLayoutDirection(const Qt::LayoutDirection& previewLayoutDirection);
|
||||
ScaleType previewScaleType();
|
||||
int previewScalePercent();
|
||||
void setPreviewScaleType(const ScaleType &previewScaleType, int percent = 0);
|
||||
signals:
|
||||
void renderStarted();
|
||||
void renderFinished();
|
||||
|
@ -103,6 +103,7 @@ namespace Const{
|
||||
enum ExpandType {EscapeSymbols, NoEscapeSymbols, ReplaceHTMLSymbols};
|
||||
enum RenderPass {FirstPass, SecondPass};
|
||||
enum ArrangeType {AsNeeded, Force};
|
||||
enum ScaleType {FitWidth, FitPage, OneToOne, Percents};
|
||||
enum PreviewHint{ShowAllPreviewBars = 0,
|
||||
HidePreviewToolBar = 1,
|
||||
HidePreviewMenuBar = 2,
|
||||
|
@ -61,18 +61,21 @@ PageItemDesignIntf::Ptr PreviewReportWidgetPrivate::currentPage()
|
||||
|
||||
PreviewReportWidget::PreviewReportWidget(ReportEnginePrivate *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_previewPage = report->createPreviewPage();
|
||||
d_ptr->m_previewPage->setItemMode( LimeReport::PreviewMode );
|
||||
d_ptr->m_report = report;
|
||||
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()
|
||||
@ -221,6 +224,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()
|
||||
@ -228,6 +236,7 @@ void PreviewReportWidget::fitWidth()
|
||||
if (d_ptr->currentPage()){
|
||||
qreal scalePercent = ui->graphicsView->viewport()->width() / ui->graphicsView->scene()->width();
|
||||
setScalePercent(scalePercent*100);
|
||||
m_scaleType = FitWidth;
|
||||
}
|
||||
}
|
||||
|
||||
@ -237,9 +246,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) {
|
||||
@ -252,6 +267,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){
|
||||
@ -305,6 +336,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 {
|
||||
@ -22,6 +23,9 @@ class LIMEREPORT_EXPORT PreviewReportWidget : public QWidget
|
||||
public:
|
||||
explicit PreviewReportWidget(ReportEnginePrivate *report, QWidget *parent = 0);
|
||||
~PreviewReportWidget();
|
||||
ScaleType scaleType() const;
|
||||
int scalePercent() const;
|
||||
void setScaleType(const ScaleType &scaleType, int percent = 0);
|
||||
public slots:
|
||||
void refreshPages();
|
||||
void zoomIn();
|
||||
@ -39,6 +43,8 @@ public slots:
|
||||
void setScalePercent(int percent);
|
||||
void fitWidth();
|
||||
void fitPage();
|
||||
protected:
|
||||
void resizeEvent(QResizeEvent *);
|
||||
signals:
|
||||
void pageChanged(int page);
|
||||
void scalePercentChanged(int percent);
|
||||
@ -47,6 +53,7 @@ private slots:
|
||||
void slotSliderMoved(int value);
|
||||
void reportEngineDestroyed(QObject* object);
|
||||
void slotZoomed(double);
|
||||
void resizeDone();
|
||||
private:
|
||||
void initPreview();
|
||||
void setErrorsMesagesVisible(bool visible);
|
||||
@ -55,6 +62,9 @@ private:
|
||||
private:
|
||||
Ui::PreviewReportWidget *ui;
|
||||
PreviewReportWidgetPrivate* d_ptr;
|
||||
ScaleType m_scaleType;
|
||||
int m_scalePercent;
|
||||
QTimer m_resizeTimer;
|
||||
};
|
||||
|
||||
} // namespace LimeReport
|
||||
|
@ -253,7 +253,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()){
|
||||
@ -333,6 +348,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();
|
||||
|
@ -68,6 +68,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();
|
||||
@ -115,6 +118,9 @@ private:
|
||||
int m_priorScrolValue;
|
||||
PreviewReportWidget* m_previewReportWidget;
|
||||
QComboBox* m_scalePercent;
|
||||
ScaleType m_previewScaleType;
|
||||
int m_previewScalePercent;
|
||||
|
||||
};
|
||||
} //namespace LimeReport
|
||||
#endif // LRPREVIEWREPORTWINDOW_H
|
||||
|
@ -63,7 +63,8 @@ ReportEnginePrivate::ReportEnginePrivate(QObject *parent) :
|
||||
m_showProgressDialog(true), m_reportName(""), m_activePreview(0),
|
||||
m_previewWindowIcon(":/report/images/logo32"), m_previewWindowTitle(tr("Preview")),
|
||||
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
|
||||
initResources();
|
||||
@ -381,6 +382,7 @@ void ReportEnginePrivate::previewReport(PreviewHints hints)
|
||||
w->setSettings(settings());
|
||||
w->setPages(pages);
|
||||
w->setLayoutDirection(m_previewLayoutDirection);
|
||||
|
||||
if (!dataManager()->errorsList().isEmpty()){
|
||||
w->setErrorMessages(dataManager()->errorsList());
|
||||
}
|
||||
@ -394,6 +396,9 @@ void ReportEnginePrivate::previewReport(PreviewHints hints)
|
||||
w->setHideResultEditButton(resultIsEditable());
|
||||
|
||||
m_activePreview = w;
|
||||
|
||||
w->setPreviewScaleType(m_previewScaleType, m_previewScalePercent);
|
||||
|
||||
connect(w,SIGNAL(destroyed(QObject*)), this, SLOT(slotPreviewWindowDestroyed(QObject*)));
|
||||
w->exec();
|
||||
}
|
||||
@ -714,7 +719,23 @@ QString ReportEnginePrivate::renderToString()
|
||||
render.setDatasources(dataManager());
|
||||
render.setScriptContext(scriptContext());
|
||||
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()
|
||||
@ -945,6 +966,25 @@ void ReportEngine::setPreviewLayoutDirection(const Qt::LayoutDirection& layoutDi
|
||||
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)
|
||||
{
|
||||
Q_D(ReportEngine);
|
||||
|
@ -104,6 +104,9 @@ public:
|
||||
void setPassPharse(QString& passPharse);
|
||||
Qt::LayoutDirection previewLayoutDirection();
|
||||
void setPreviewLayoutDirection(const Qt::LayoutDirection& previewLayoutDirection);
|
||||
ScaleType previewScaleType();
|
||||
int previewScalePercent();
|
||||
void setPreviewScaleType(const ScaleType &previewScaleType, int percent = 0);
|
||||
signals:
|
||||
void renderStarted();
|
||||
void renderFinished();
|
||||
|
@ -132,6 +132,10 @@ public:
|
||||
void clearSelection();
|
||||
Qt::LayoutDirection previewLayoutDirection();
|
||||
void setPreviewLayoutDirection(const Qt::LayoutDirection& previewLayoutDirection);
|
||||
ScaleType previewScaleType();
|
||||
int previewScalePercent();
|
||||
void setPreviewScaleType(const ScaleType &previewScaleType, int percent = 0);
|
||||
|
||||
signals:
|
||||
void pagesLoadFinished();
|
||||
void datasourceCollectionLoadFinished(const QString& collectionName);
|
||||
@ -186,6 +190,8 @@ private:
|
||||
QString m_passPhrase;
|
||||
QFileSystemWatcher *m_fileWatcher;
|
||||
Qt::LayoutDirection m_previewLayoutDirection;
|
||||
ScaleType m_previewScaleType;
|
||||
int m_previewScalePercent;
|
||||
};
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user