Scale actions have been added to Report Preview Window

This commit is contained in:
Arin Alexander 2016-04-02 16:07:01 +03:00
parent 4e75bae701
commit caa516d6bd
9 changed files with 92 additions and 3 deletions

View File

@ -70,7 +70,7 @@ void MainWindow::enableUI(bool value)
void MainWindow::slotScalePercentChanged(int percent)
{
ui->cbScalePercent->setCurrentText(QString("%1\%").arg(percent));
ui->cbScalePercent->setCurrentText(QString("%1%").arg(percent));
}
void MainWindow::scaleComboboxChanged(QString text)
@ -101,7 +101,7 @@ void MainWindow::on_treeWidget_itemClicked(QTreeWidgetItem *item, int )
void MainWindow::initPercentCombobox()
{
for (int i = 10; i<310; i+=10){
ui->cbScalePercent->addItem(QString("%1\%").arg(i));
ui->cbScalePercent->addItem(QString("%1%").arg(i));
}
ui->cbScalePercent->setCurrentIndex(4);
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

@ -211,6 +211,7 @@ void PreviewReportWidget::saveToFile()
void PreviewReportWidget::setScalePercent(int percent)
{
ui->graphicsView->resetMatrix();
d_ptr->m_scalePercent = percent;
qreal scaleSize = percent/100.0;
ui->graphicsView->scale(scaleSize, scaleSize);
emit scalePercentChanged(percent);

View File

@ -61,6 +61,13 @@ PreviewReportWindow::PreviewReportWindow(ReportEnginePrivate *report,QWidget *pa
setCentralWidget(m_previewReportWidget);
layout()->setContentsMargins(1,1,1,1);
connect(m_previewReportWidget,SIGNAL(pageChanged(int)), this,SLOT(slotPageChanged(int)) );
m_scalePercent = new QComboBox(this);
ui->toolBar->insertWidget(ui->actionZoomOut, m_scalePercent);
initPercentCombobox();
connect(m_previewReportWidget, SIGNAL(scalePercentChanged(int)), this, SLOT(slotScalePercentChanged(int)));
connect(m_scalePercent, SIGNAL(currentIndexChanged(QString)), this, SLOT(scaleComboboxChanged(QString)));
restoreSetting();
}
@ -241,6 +248,14 @@ ItemsReaderIntf *PreviewReportWindow::reader()
return m_reader.data();
}
void PreviewReportWindow::initPercentCombobox()
{
for (int i = 10; i<310; i+=10){
m_scalePercent->addItem(QString("%1%").arg(i));
}
m_scalePercent->setCurrentIndex(4);
}
void PreviewReportWindow::on_actionSaveToFile_triggered()
{
m_previewReportWidget->saveToFile();
@ -266,4 +281,35 @@ void PreviewReportWindow::slotPageChanged(int pageIndex)
m_pagesNavigator->setValue(pageIndex);
}
void PreviewReportWindow::on_actionFit_page_width_triggered()
{
m_previewReportWidget->fitWidth();
}
void PreviewReportWindow::on_actionFit_page_triggered()
{
m_previewReportWidget->fitPage();
}
void PreviewReportWindow::on_actionOne_to_one_triggered()
{
m_previewReportWidget->setScalePercent(100);
}
void PreviewReportWindow::scaleComboboxChanged(QString text)
{
m_previewReportWidget->setScalePercent(text.remove(text.count()-1,1).toInt());
}
void PreviewReportWindow::slotScalePercentChanged(int percent)
{
m_scalePercent->setCurrentText(QString("%1%").arg(percent));
}
}// namespace LimeReport

View File

@ -33,6 +33,7 @@
#include <QMainWindow>
#include <QDomComment>
#include <QSpinBox>
#include <QComboBox>
#include "lrpagedesignintf.h"
#include "lrreportrender.h"
@ -78,8 +79,15 @@ public slots:
void slotLastPage();
void slotPrintToPDF();
void slotPageChanged(int pageIndex);
private slots:
void on_actionFit_page_width_triggered();
void on_actionFit_page_triggered();
void on_actionOne_to_one_triggered();
void scaleComboboxChanged(QString text);
void slotScalePercentChanged(int percent);
private:
ItemsReaderIntf* reader();
void initPercentCombobox();
//bool pageIsVisible(PageItemDesignIntf::Ptr page);
//QRectF calcPageShift(PageItemDesignIntf::Ptr page);
private:
@ -91,6 +99,7 @@ private:
QSettings* m_settings;
bool m_ownedSettings;
PreviewReportWidget* m_previewReportWidget;
QComboBox* m_scalePercent;
};
} //namespace LimeReport
#endif // LRPREVIEWREPORTWINDOW_H

View File

@ -77,6 +77,9 @@
<addaction name="separator"/>
<addaction name="actionZoomIn"/>
<addaction name="actionZoomOut"/>
<addaction name="actionOne_to_one"/>
<addaction name="actionFit_page_width"/>
<addaction name="actionFit_page"/>
<addaction name="separator"/>
<addaction name="actionFirst_Page"/>
<addaction name="actionPriorPage"/>
@ -224,10 +227,37 @@
<string>Print To PDF</string>
</property>
</action>
<action name="actionFit_page_width">
<property name="icon">
<iconset resource="report.qrc">
<normaloff>:/report/images/FitWidth.png</normaloff>:/report/images/FitWidth.png</iconset>
</property>
<property name="text">
<string>Fit page width</string>
</property>
</action>
<action name="actionFit_page">
<property name="icon">
<iconset resource="report.qrc">
<normaloff>:/report/images/FitPage.png</normaloff>:/report/images/FitPage.png</iconset>
</property>
<property name="text">
<string>Fit page</string>
</property>
</action>
<action name="actionOne_to_one">
<property name="icon">
<iconset resource="report.qrc">
<normaloff>:/report/images/OneToOne.png</normaloff>:/report/images/OneToOne.png</iconset>
</property>
<property name="text">
<string>One to one</string>
</property>
</action>
</widget>
<resources>
<include location="databrowser/lrdatabrowser.qrc"/>
<include location="report.qrc"/>
<include location="databrowser/lrdatabrowser.qrc"/>
</resources>
<connections>
<connection>

View File

@ -161,5 +161,8 @@
<file alias="/images/settings">images/settings.png</file>
<file alias="/images/grid">images/grid.png</file>
<file alias="/images/magnet">images/magnet.png</file>
<file>images/FitPage.png</file>
<file>images/FitWidth.png</file>
<file>images/OneToOne.png</file>
</qresource>
</RCC>