0
0
mirror of https://github.com/fralx/LimeReport.git synced 2025-11-25 08:28:06 +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:
Arin Alexander
2018-07-11 03:05:55 +03:00
12 changed files with 159 additions and 5 deletions

View File

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