0
0
mirror of https://github.com/fralx/LimeReport.git synced 2024-12-24 00:33:02 +03:00

Demo R2 refactored

This commit is contained in:
Arin Alexander 2016-05-24 01:32:21 +04:00
parent 906fff5911
commit 11a06456b1
3 changed files with 223 additions and 394 deletions

View File

@ -10,23 +10,33 @@ MainWindow::MainWindow(QWidget *parent) :
ui(new Ui::MainWindow)
{
ui->setupUi(this);
m_preview = m_report.createPreviewWidget();
connect(m_preview,SIGNAL(scalePercentChanged(int)), this, SLOT(slotScalePercentChanged(int)));
m_scalePercent = new QComboBox(this);
m_pageNavigator = new QSpinBox(this);
m_pageNavigator->setPrefix(tr("Page :"));
ui->toolBar->insertWidget(ui->actionZoomIn,m_scalePercent);
ui->toolBar->insertWidget(ui->actionNext_Page,m_pageNavigator);
connect(m_scalePercent, SIGNAL(currentIndexChanged(QString)), this, SLOT(scaleComboboxChanged(QString)));
connect(m_pageNavigator, SIGNAL(valueChanged(int)), this, SLOT(slotPageNavigatorChanged(int)));
ui->groupBox_2->layout()->addWidget(m_preview);
buildReportsTree(QApplication::applicationDirPath()+"/demo_reports/", ui->treeWidget);
connect(ui->tbZoomIn, SIGNAL(clicked(bool)), m_preview, SLOT(zoomIn()));
connect(ui->tbZoomOut, SIGNAL(clicked(bool)), m_preview, SLOT(zoomOut()));
connect(ui->tbFirstPage, SIGNAL(clicked(bool)), m_preview, SLOT(firstPage()));
connect(ui->tbPrevPage, SIGNAL(clicked(bool)), m_preview, SLOT(priorPage()));
connect(ui->tbNextPage, SIGNAL(clicked(bool)), m_preview, SLOT(nextPage()));
connect(ui->tbLastPage, SIGNAL(clicked(bool)), m_preview, SLOT(lastPage()));
connect(ui->cbScalePercent, SIGNAL(currentIndexChanged(QString)), this, SLOT(scaleComboboxChanged(QString)));
connect(ui->tbFitWidth, SIGNAL(clicked(bool)), m_preview, SLOT(fitWidth()));
connect(ui->tbFitPage, SIGNAL(clicked(bool)), m_preview, SLOT(fitPage()));
connect(ui->actionZoomIn, SIGNAL(triggered()), m_preview, SLOT(zoomIn()));
connect(ui->actionZoom_Out, SIGNAL(triggered()), m_preview, SLOT(zoomOut()));
connect(ui->actionFirst_Page, SIGNAL(triggered()), m_preview, SLOT(firstPage()));
connect(ui->actionPrior_Page, SIGNAL(triggered()), m_preview, SLOT(priorPage()));
connect(ui->actionNext_Page, SIGNAL(triggered()), m_preview, SLOT(nextPage()));
connect(ui->actionLast_Page, SIGNAL(triggered()), m_preview, SLOT(lastPage()));
connect(m_preview,SIGNAL(scalePercentChanged(int)), this, SLOT(slotScalePercentChanged(int)));
//connect(ui->cbScalePercent, SIGNAL(currentIndexChanged(QString)), this, SLOT(scaleComboboxChanged(QString)));
connect(ui->actionFit_Width, SIGNAL(triggered()), m_preview, SLOT(fitWidth()));
connect(ui->actionFit_Page, SIGNAL(triggered()), m_preview, SLOT(fitPage()));
connect(m_preview, SIGNAL(pagesSet(int)), this, SLOT(slotPagesSet(int)));
connect(m_preview, SIGNAL(pageChanged(int)), this, SLOT(slotPageChanged(int)));
connect(ui->tbPDFExport, SIGNAL(clicked(bool)), m_preview, SLOT(printToPDF()));
connect(ui->tbPrint, SIGNAL(clicked(bool)), m_preview, SLOT(print()));
connect(ui->actionExport_to_PDF, SIGNAL(triggered()), m_preview, SLOT(printToPDF()));
connect(ui->actionPrint_Report, SIGNAL(triggered()), m_preview, SLOT(print()));
connect(ui->actionDesign_Report, SIGNAL(triggered()), this, SLOT(slotDesignReport()));
initPercentCombobox();
enableUI(false);
QDesktopWidget *desktop = QApplication::desktop();
@ -43,6 +53,7 @@ MainWindow::MainWindow(QWidget *parent) :
m_report.loadFromFile(QApplication::applicationDirPath()+"/demo_reports/categories.lrxml");
m_preview->refreshPages();
}
}
MainWindow::~MainWindow()
@ -52,25 +63,26 @@ MainWindow::~MainWindow()
void MainWindow::enableUI(bool value)
{
ui->tbDesign->setEnabled(value);
ui->tbPrint->setEnabled(value);
ui->tbPDFExport->setEnabled(value);
ui->tbFirstPage->setEnabled(value);
ui->tbPrevPage->setEnabled(value);
ui->tbNextPage->setEnabled(value);
ui->tbLastPage->setEnabled(value);
ui->tbZoomIn->setEnabled(value);
ui->tbZoomOut->setEnabled(value);
ui->tbFitWidth->setEnabled(value);
ui->tbFitPage->setEnabled(value);
ui->tbOneToOne->setEnabled(value);
ui->sbPageNavigator->setEnabled(value);
ui->cbScalePercent->setEnabled(value);
ui->actionDesign_Report->setEnabled(value);
ui->actionPrint_Report->setEnabled(value);
ui->actionExport_to_PDF->setEnabled(value);
ui->actionFirst_Page->setEnabled(value);
ui->actionPrior_Page->setEnabled(value);
ui->actionNext_Page->setEnabled(value);
ui->actionLast_Page->setEnabled(value);
ui->actionZoomIn->setEnabled(value);
ui->actionZoom_Out->setEnabled(value);
ui->actionFit_Width->setEnabled(value);
ui->actionFit_Page->setEnabled(value);
ui->actionOne_to_One->setEnabled(value);
m_pageNavigator->setEnabled(value);
m_scalePercent->setEnabled(value);
}
void MainWindow::slotScalePercentChanged(int percent)
{
ui->cbScalePercent->setEditText(QString("%1%").arg(percent));
//ui->cbScalePercent->setEditText(QString("%1%").arg(percent));
m_scalePercent->setEditText(QString("%1%").arg(percent));
}
void MainWindow::scaleComboboxChanged(QString text)
@ -80,16 +92,27 @@ void MainWindow::scaleComboboxChanged(QString text)
void MainWindow::slotPagesSet(int pagesCount)
{
ui->sbPageNavigator->setSuffix(tr(" of %1").arg(pagesCount));
ui->sbPageNavigator->setMinimum(1);
ui->sbPageNavigator->setMaximum(pagesCount);
ui->sbPageNavigator->setValue(1);
// ui->sbPageNavigator->setSuffix(tr(" of %1").arg(pagesCount));
// ui->sbPageNavigator->setMinimum(1);
// ui->sbPageNavigator->setMaximum(pagesCount);
// ui->sbPageNavigator->setValue(1);
m_pageNavigator->setSuffix(tr(" of %1").arg(pagesCount));
m_pageNavigator->setMinimum(1);
m_pageNavigator->setMaximum(pagesCount);
m_pageNavigator->setValue(1);
enableUI(true);
}
void MainWindow::slotPageChanged(int page)
{
ui->sbPageNavigator->setValue(page);
// ui->sbPageNavigator->setValue(page);
m_pageNavigator->setValue(page);
}
void MainWindow::slotPageNavigatorChanged(int page)
{
m_preview->pageNavigatorChanged(page);
}
void MainWindow::on_treeWidget_itemClicked(QTreeWidgetItem *item, int )
@ -101,9 +124,11 @@ 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));
m_scalePercent->addItem(QString("%1%").arg(i));
}
ui->cbScalePercent->setCurrentIndex(4);
// ui->cbScalePercent->setCurrentIndex(4);
m_scalePercent->setCurrentIndex(4);
}
void MainWindow::on_sbPageNavigator_valueChanged(int arg1)
@ -111,7 +136,7 @@ void MainWindow::on_sbPageNavigator_valueChanged(int arg1)
m_preview->pageNavigatorChanged(arg1);
}
void MainWindow::on_tbDesign_clicked()
void MainWindow::slotDesignReport()
{
m_report.designReport();
m_preview->refreshPages();

View File

@ -6,6 +6,8 @@
#include <QTreeWidget>
#include <QDir>
#include <QDebug>
#include <QComboBox>
#include <QSpinBox>
namespace Ui {
class MainWindow;
@ -25,9 +27,10 @@ private slots:
void scaleComboboxChanged(QString text);
void slotPagesSet(int pagesCount);
void slotPageChanged(int page);
void slotPageNavigatorChanged(int page);
void on_treeWidget_itemClicked(QTreeWidgetItem *item, int);
void on_sbPageNavigator_valueChanged(int arg1);
void on_tbDesign_clicked();
void slotDesignReport();
void on_tbOneToOne_clicked();
private:
template< typename T >
@ -56,6 +59,8 @@ private:
Ui::MainWindow *ui;
LimeReport::ReportEngine m_report;
LimeReport::PreviewReportWidget* m_preview;
QComboBox* m_scalePercent;
QSpinBox* m_pageNavigator;
};
#endif // MAINWINDOW_H

View File

@ -18,10 +18,13 @@
<normaloff>:/report/images/logo32</normaloff>:/report/images/logo32</iconset>
</property>
<widget class="QWidget" name="centralWidget">
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QSplitter" name="splitter">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<widget class="QWidget" name="">
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QGroupBox" name="groupBox">
@ -37,18 +40,6 @@
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QTreeWidget" name="treeWidget">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>200</width>
<height>16777215</height>
</size>
</property>
<property name="font">
<font>
<weight>50</weight>
@ -230,8 +221,7 @@
</layout>
</item>
</layout>
</item>
<item>
</widget>
<widget class="QGroupBox" name="groupBox_2">
<property name="font">
<font>
@ -240,344 +230,153 @@
</font>
</property>
<property name="title">
<string>Preview</string>
<string/>
</property>
<layout class="QVBoxLayout" name="verticalLayout_5">
<property name="spacing">
<number>4</number>
</property>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="spacing">
<number>2</number>
</property>
<item>
<widget class="QToolButton" name="tbDesign">
<property name="font">
<font>
<pointsize>6</pointsize>
</font>
</property>
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="demo_r2.qrc">
<normaloff>:/images/images/design.png</normaloff>:/images/images/design.png</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_3">
<property name="frameShape">
<enum>QFrame::VLine</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="tbPrint">
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="demo_r2.qrc">
<normaloff>:/images/images/Print.png</normaloff>:/images/images/Print.png</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="tbPDFExport">
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="demo_r2.qrc">
<normaloff>:/images/images/PDF.png</normaloff>:/images/images/PDF.png</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_4">
<property name="frameShape">
<enum>QFrame::VLine</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="tbZoomIn">
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="demo_r2.qrc">
<normaloff>:/images/images/ZoomIn.png</normaloff>:/images/images/ZoomIn.png</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="tbZoomOut">
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="demo_r2.qrc">
<normaloff>:/images/images/ZoomOut.png</normaloff>:/images/images/ZoomOut.png</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="cbScalePercent">
<property name="editable">
<bool>true</bool>
</property>
<property name="frame">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="tbOneToOne">
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="demo_r2.qrc">
<normaloff>:/images/images/OneToOne.png</normaloff>:/images/images/OneToOne.png</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="tbFitWidth">
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="demo_r2.qrc">
<normaloff>:/images/images/FitWidth.png</normaloff>:/images/images/FitWidth.png</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="tbFitPage">
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="demo_r2.qrc">
<normaloff>:/images/images/FitPage.png</normaloff>:/images/images/FitPage.png</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_5">
<property name="frameShape">
<enum>QFrame::VLine</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="tbFirstPage">
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="demo_r2.qrc">
<normaloff>:/images/images/First.png</normaloff>:/images/images/First.png</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="tbPrevPage">
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="demo_r2.qrc">
<normaloff>:/images/images/Prev.png</normaloff>:/images/images/Prev.png</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="sbPageNavigator">
<property name="prefix">
<string>Page: </string>
</property>
<property name="maximum">
<number>10000000</number>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="tbNextPage">
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="demo_r2.qrc">
<normaloff>:/images/images/Next.png</normaloff>:/images/images/Next.png</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="tbLastPage">
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="demo_r2.qrc">
<normaloff>:/images/images/Last.png</normaloff>:/images/images/Last.png</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<widget class="QStatusBar" name="statusBar"/>
<widget class="QToolBar" name="toolBar">
<property name="windowTitle">
<string>toolBar</string>
</property>
<attribute name="toolBarArea">
<enum>TopToolBarArea</enum>
</attribute>
<attribute name="toolBarBreak">
<bool>false</bool>
</attribute>
<addaction name="actionDesign_Report"/>
<addaction name="separator"/>
<addaction name="actionPrint_Report"/>
<addaction name="actionExport_to_PDF"/>
<addaction name="separator"/>
<addaction name="actionZoomIn"/>
<addaction name="actionZoom_Out"/>
<addaction name="actionOne_to_One"/>
<addaction name="actionFit_Width"/>
<addaction name="actionFit_Page"/>
<addaction name="separator"/>
<addaction name="actionFirst_Page"/>
<addaction name="actionPrior_Page"/>
<addaction name="actionNext_Page"/>
<addaction name="actionLast_Page"/>
</widget>
<action name="actionDesign_Report">
<property name="icon">
<iconset resource="demo_r2.qrc">
<normaloff>:/images/images/design.png</normaloff>:/images/images/design.png</iconset>
</property>
<property name="text">
<string>Design Report</string>
</property>
</action>
<action name="actionPrint_Report">
<property name="icon">
<iconset resource="demo_r2.qrc">
<normaloff>:/images/images/Print.png</normaloff>:/images/images/Print.png</iconset>
</property>
<property name="text">
<string>Print Report</string>
</property>
</action>
<action name="actionExport_to_PDF">
<property name="icon">
<iconset resource="demo_r2.qrc">
<normaloff>:/images/images/PDF.png</normaloff>:/images/images/PDF.png</iconset>
</property>
<property name="text">
<string>Export to PDF</string>
</property>
</action>
<action name="actionZoomIn">
<property name="icon">
<iconset resource="demo_r2.qrc">
<normaloff>:/images/images/ZoomIn.png</normaloff>:/images/images/ZoomIn.png</iconset>
</property>
<property name="text">
<string>Zoom In</string>
</property>
</action>
<action name="actionZoom_Out">
<property name="icon">
<iconset resource="demo_r2.qrc">
<normaloff>:/images/images/ZoomOut.png</normaloff>:/images/images/ZoomOut.png</iconset>
</property>
<property name="text">
<string>Zoom Out</string>
</property>
</action>
<action name="actionOne_to_One">
<property name="icon">
<iconset resource="demo_r2.qrc">
<normaloff>:/images/images/OneToOne.png</normaloff>:/images/images/OneToOne.png</iconset>
</property>
<property name="text">
<string>One to One</string>
</property>
</action>
<action name="actionFit_Width">
<property name="icon">
<iconset resource="demo_r2.qrc">
<normaloff>:/images/images/FitWidth.png</normaloff>:/images/images/FitWidth.png</iconset>
</property>
<property name="text">
<string>Fit Width</string>
</property>
</action>
<action name="actionFit_Page">
<property name="icon">
<iconset resource="demo_r2.qrc">
<normaloff>:/images/images/FitPage.png</normaloff>:/images/images/FitPage.png</iconset>
</property>
<property name="text">
<string>Fit Page</string>
</property>
</action>
<action name="actionFirst_Page">
<property name="icon">
<iconset resource="demo_r2.qrc">
<normaloff>:/images/images/First.png</normaloff>:/images/images/First.png</iconset>
</property>
<property name="text">
<string>First Page</string>
</property>
</action>
<action name="actionPrior_Page">
<property name="icon">
<iconset resource="demo_r2.qrc">
<normaloff>:/images/images/Prev.png</normaloff>:/images/images/Prev.png</iconset>
</property>
<property name="text">
<string>Prior Page</string>
</property>
</action>
<action name="actionNext_Page">
<property name="icon">
<iconset resource="demo_r2.qrc">
<normaloff>:/images/images/Next.png</normaloff>:/images/images/Next.png</iconset>
</property>
<property name="text">
<string>Next Page</string>
</property>
</action>
<action name="actionLast_Page">
<property name="icon">
<iconset resource="demo_r2.qrc">
<normaloff>:/images/images/Last.png</normaloff>:/images/images/Last.png</iconset>
</property>
<property name="text">
<string>Last Page</string>
</property>
</action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources>