mirror of
https://github.com/fralx/LimeReport.git
synced 2024-12-23 16:22:58 +03:00
page scale refactored
This commit is contained in:
parent
aa3f9d80d3
commit
79feedd360
@ -70,7 +70,7 @@ void MainWindow::enableUI(bool value)
|
||||
|
||||
void MainWindow::slotScalePercentChanged(int percent)
|
||||
{
|
||||
ui->cbScalePercent->setCurrentText(QString("%1%").arg(percent));
|
||||
ui->cbScalePercent->setEditText(QString("%1%").arg(percent));
|
||||
}
|
||||
|
||||
void MainWindow::scaleComboboxChanged(QString text)
|
||||
|
@ -46,6 +46,7 @@ signals:
|
||||
private slots:
|
||||
void slotSliderMoved(int value);
|
||||
void reportEngineDestroyed(QObject* object);
|
||||
void slotZoomed(double);
|
||||
private:
|
||||
void initPreview();
|
||||
void setErrorsMesagesVisible(bool visible);
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include "lrgraphicsviewzoom.h"
|
||||
#include <QMouseEvent>
|
||||
#include <QApplication>
|
||||
#include <QtMath>
|
||||
#include <qmath.h>
|
||||
|
||||
namespace LimeReport{
|
||||
|
||||
@ -11,7 +11,7 @@ GraphicsViewZoomer::GraphicsViewZoomer(QGraphicsView* view)
|
||||
m_view->viewport()->installEventFilter(this);
|
||||
m_view->setMouseTracking(true);
|
||||
m_modifiers = Qt::ControlModifier;
|
||||
m_zoomFactorBase = 1.0015;
|
||||
m_zoomFactorBase = 1.0009;
|
||||
}
|
||||
|
||||
void GraphicsViewZoomer::gentleZoom(double factor) {
|
||||
@ -21,7 +21,7 @@ void GraphicsViewZoomer::gentleZoom(double factor) {
|
||||
m_view->viewport()->height() / 2.0);
|
||||
QPointF viewport_center = m_view->mapFromScene(m_targetScenePos) - delta_viewport_pos;
|
||||
m_view->centerOn(m_view->mapToScene(viewport_center.toPoint()));
|
||||
emit zoomed();
|
||||
emit zoomed(factor);
|
||||
}
|
||||
|
||||
void GraphicsViewZoomer::setModifiers(Qt::KeyboardModifiers modifiers) {
|
||||
|
@ -20,7 +20,7 @@ private:
|
||||
QPointF m_targetScenePos, m_targetViewportPos;
|
||||
bool eventFilter(QObject* object, QEvent* event);
|
||||
signals:
|
||||
void zoomed();
|
||||
void zoomed(double factor);
|
||||
};
|
||||
|
||||
} // namespace LimeReport
|
||||
|
@ -52,7 +52,7 @@ void PreviewReportWidgetPrivate::setPages(ReportPages pages)
|
||||
|
||||
PageItemDesignIntf::Ptr PreviewReportWidgetPrivate::currentPage()
|
||||
{
|
||||
if (m_reportPages.count()>m_currentPage)
|
||||
if (m_reportPages.count()>0 && m_reportPages.count()>=m_currentPage)
|
||||
return m_reportPages.at(m_currentPage-1);
|
||||
else return PageItemDesignIntf::Ptr(0);
|
||||
}
|
||||
@ -70,6 +70,7 @@ PreviewReportWidget::PreviewReportWidget(ReportEnginePrivate *report, QWidget *p
|
||||
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)));
|
||||
}
|
||||
|
||||
PreviewReportWidget::~PreviewReportWidget()
|
||||
@ -97,14 +98,14 @@ void PreviewReportWidget::setErrorsMesagesVisible(bool visible)
|
||||
|
||||
void PreviewReportWidget::zoomIn()
|
||||
{
|
||||
d_ptr->m_scalePercent += 10;
|
||||
d_ptr->m_scalePercent = (d_ptr->m_scalePercent / 10) * 10 + 10;
|
||||
setScalePercent(d_ptr->m_scalePercent);
|
||||
}
|
||||
|
||||
void PreviewReportWidget::zoomOut()
|
||||
{
|
||||
if (d_ptr->m_scalePercent>0)
|
||||
d_ptr->m_scalePercent -= 10;
|
||||
d_ptr->m_scalePercent = (d_ptr->m_scalePercent / 10) * 10 - 10;
|
||||
setScalePercent(d_ptr->m_scalePercent);
|
||||
}
|
||||
|
||||
@ -293,6 +294,12 @@ void PreviewReportWidget::reportEngineDestroyed(QObject *object)
|
||||
}
|
||||
}
|
||||
|
||||
void PreviewReportWidget::slotZoomed(double )
|
||||
{
|
||||
d_ptr->m_scalePercent = ui->graphicsView->matrix().m11()*100;
|
||||
emit scalePercentChanged(d_ptr->m_scalePercent);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -46,6 +46,7 @@ signals:
|
||||
private slots:
|
||||
void slotSliderMoved(int value);
|
||||
void reportEngineDestroyed(QObject* object);
|
||||
void slotZoomed(double);
|
||||
private:
|
||||
void initPreview();
|
||||
void setErrorsMesagesVisible(bool visible);
|
||||
|
@ -64,6 +64,7 @@ PreviewReportWindow::PreviewReportWindow(ReportEnginePrivate *report,QWidget *pa
|
||||
|
||||
|
||||
m_scalePercent = new QComboBox(this);
|
||||
m_scalePercent->setEditable(true);
|
||||
ui->toolBar->insertWidget(ui->actionZoomOut, m_scalePercent);
|
||||
initPercentCombobox();
|
||||
connect(m_previewReportWidget, SIGNAL(scalePercentChanged(int)), this, SLOT(slotScalePercentChanged(int)));
|
||||
@ -303,7 +304,7 @@ void PreviewReportWindow::scaleComboboxChanged(QString text)
|
||||
|
||||
void PreviewReportWindow::slotScalePercentChanged(int percent)
|
||||
{
|
||||
m_scalePercent->setCurrentText(QString("%1%").arg(percent));
|
||||
m_scalePercent->setEditText(QString("%1%").arg(percent));
|
||||
}
|
||||
|
||||
}// namespace LimeReport
|
||||
|
Loading…
Reference in New Issue
Block a user