1.0.1.7
170
demo/r1/demo_reports/categories.lrxml
Normal file
@@ -0,0 +1,170 @@
|
||||
<Report>
|
||||
<object Type="Object" ClassName="LimeReport::ReportEnginePrivate">
|
||||
<objectName Type="QString"></objectName>
|
||||
<pages Type="Collection">
|
||||
<item Type="Object" ClassName="LimeReport::PageDesignIntf">
|
||||
<objectName Type="QString">page1</objectName>
|
||||
<sceneRect Type="QRect" x="-50" height="3070" y="-50" width="2200"/>
|
||||
<bspTreeDepth Value="5" Type="int"/>
|
||||
<font Type="QFont" pointSize="9" undeline="0" italic="0" family="Sans Serif" bold="0"/>
|
||||
<sortCacheEnabled Value="0" Type="bool"/>
|
||||
<stickyFocus Value="0" Type="bool"/>
|
||||
<minimumRenderSize Value="0" Type="qreal"/>
|
||||
<pageItem Type="Object" ClassName="PageItem">
|
||||
<objectName Type="QString">ReportPage1</objectName>
|
||||
<geometry Type="QRect" x="0" height="2970" y="0" width="2100"/>
|
||||
<children Type="Collection">
|
||||
<item Type="Object" ClassName="Data">
|
||||
<objectName Type="QString">DataBand1</objectName>
|
||||
<geometry Type="QRect" x="50" height="100" y="50" width="2000"/>
|
||||
<children Type="Collection">
|
||||
<item Type="Object" ClassName="ImageItem">
|
||||
<objectName Type="QString">ImageItem1</objectName>
|
||||
<geometry Type="QRect" x="54" height="50" y="22" width="200"/>
|
||||
<children Type="Collection"/>
|
||||
<zOrder Value="0" Type="qreal"/>
|
||||
<borders Value="0" Type="enumAndFlags"/>
|
||||
<parentName Type="QString">DataBand1</parentName>
|
||||
<itemLocation Value="0" Type="enumAndFlags"/>
|
||||
<stretchToMaxHeight Value="0" Type="bool"/>
|
||||
<image Type="QImage"></image>
|
||||
<opacity Value="100" Type="int"/>
|
||||
<content Type="QString"></content>
|
||||
<datasource Type="QString">category</datasource>
|
||||
<field Type="QString">Picture</field>
|
||||
<autoSize Value="1" Type="bool"/>
|
||||
</item>
|
||||
</children>
|
||||
<zOrder Value="0" Type="qreal"/>
|
||||
<borders Value="0" Type="enumAndFlags"/>
|
||||
<parentName Type="QString">ReportPage1</parentName>
|
||||
<autoHeight Value="1" Type="bool"/>
|
||||
<bandIndex Value="0" Type="int"/>
|
||||
<keepBottomSpace Value="0" Type="bool"/>
|
||||
<parentBand Type="QString"></parentBand>
|
||||
<backgroundColor Value="#ffffff" Type="QColor"/>
|
||||
<printIfEmpty Value="0" Type="bool"/>
|
||||
<datasource Type="QString">category</datasource>
|
||||
<keepSubdetailTogether Value="0" Type="bool"/>
|
||||
<splittable Value="0" Type="bool"/>
|
||||
<keepFooterTogether Value="0" Type="bool"/>
|
||||
<sliceLastRow Value="0" Type="bool"/>
|
||||
</item>
|
||||
<item Type="Object" ClassName="SubDetail">
|
||||
<objectName Type="QString">SubDetailBand1</objectName>
|
||||
<geometry Type="QRect" x="50" height="100" y="154" width="2000"/>
|
||||
<children Type="Collection">
|
||||
<item Type="Object" ClassName="TextItem">
|
||||
<objectName Type="QString">TextItem1</objectName>
|
||||
<geometry Type="QRect" x="66" height="50" y="22" width="614"/>
|
||||
<children Type="Collection"/>
|
||||
<zOrder Value="0" Type="qreal"/>
|
||||
<borders Value="0" Type="enumAndFlags"/>
|
||||
<parentName Type="QString">SubDetailBand1</parentName>
|
||||
<itemLocation Value="0" Type="enumAndFlags"/>
|
||||
<stretchToMaxHeight Value="0" Type="bool"/>
|
||||
<content Type="QString">$D{products.ProductName}</content>
|
||||
<margin Value="4" Type="int"/>
|
||||
<alignment Value="33" Type="enumAndFlags"/>
|
||||
<autoWidth Value="0" Type="enumAndFlags"/>
|
||||
<autoHeight Value="1" Type="bool"/>
|
||||
<font Type="QFont" pointSize="10" undeline="0" italic="0" family="Arial" bold="0"/>
|
||||
<backgroundOpacity Value="100" Type="int"/>
|
||||
<backgroundMode Value="1" Type="enumAndFlags"/>
|
||||
<backgroundColor Value="#ffffff" Type="QColor"/>
|
||||
<fontColor Value="#000000" Type="QColor"/>
|
||||
<angle Value="0" Type="enumAndFlags"/>
|
||||
<foregroundOpacity Value="100" Type="int"/>
|
||||
<trimValue Value="1" Type="bool"/>
|
||||
</item>
|
||||
<item Type="Object" ClassName="TextItem">
|
||||
<objectName Type="QString">TextItem2</objectName>
|
||||
<geometry Type="QRect" x="688" height="50" y="22" width="250"/>
|
||||
<children Type="Collection"/>
|
||||
<zOrder Value="0" Type="qreal"/>
|
||||
<borders Value="0" Type="enumAndFlags"/>
|
||||
<parentName Type="QString">SubDetailBand1</parentName>
|
||||
<itemLocation Value="0" Type="enumAndFlags"/>
|
||||
<stretchToMaxHeight Value="0" Type="bool"/>
|
||||
<content Type="QString">$D{products.UnitPrice}</content>
|
||||
<margin Value="4" Type="int"/>
|
||||
<alignment Value="33" Type="enumAndFlags"/>
|
||||
<autoWidth Value="0" Type="enumAndFlags"/>
|
||||
<autoHeight Value="0" Type="bool"/>
|
||||
<font Type="QFont" pointSize="10" undeline="0" italic="0" family="Arial" bold="0"/>
|
||||
<backgroundOpacity Value="100" Type="int"/>
|
||||
<backgroundMode Value="1" Type="enumAndFlags"/>
|
||||
<backgroundColor Value="#ffffff" Type="QColor"/>
|
||||
<fontColor Value="#000000" Type="QColor"/>
|
||||
<angle Value="0" Type="enumAndFlags"/>
|
||||
<foregroundOpacity Value="100" Type="int"/>
|
||||
<trimValue Value="1" Type="bool"/>
|
||||
</item>
|
||||
</children>
|
||||
<zOrder Value="0" Type="qreal"/>
|
||||
<borders Value="0" Type="enumAndFlags"/>
|
||||
<parentName Type="QString">ReportPage1</parentName>
|
||||
<autoHeight Value="1" Type="bool"/>
|
||||
<bandIndex Value="1" Type="int"/>
|
||||
<keepBottomSpace Value="0" Type="bool"/>
|
||||
<parentBand Type="QString">DataBand1</parentBand>
|
||||
<backgroundColor Value="#ffffff" Type="QColor"/>
|
||||
<printIfEmpty Value="0" Type="bool"/>
|
||||
<datasource Type="QString">products</datasource>
|
||||
<splittable Value="0" Type="bool"/>
|
||||
</item>
|
||||
</children>
|
||||
<zOrder Value="0" Type="qreal"/>
|
||||
<borders Value="0" Type="enumAndFlags"/>
|
||||
<parentName Type="QString"></parentName>
|
||||
<topMargin Value="5" Type="int"/>
|
||||
<bottomMargin Value="5" Type="int"/>
|
||||
<rightMargin Value="5" Type="int"/>
|
||||
<leftMargin Value="5" Type="int"/>
|
||||
<pageOrientation Value="0" Type="enumAndFlags"/>
|
||||
<pageSize Value="0" Type="enumAndFlags"/>
|
||||
</pageItem>
|
||||
</item>
|
||||
</pages>
|
||||
<datasourcesManager Type="Object" ClassName="LimeReport::DataSourceManager">
|
||||
<objectName Type="QString">datasources</objectName>
|
||||
<connections Type="Collection">
|
||||
<item Type="Object" ClassName="LimeReport::ConnectionDesc">
|
||||
<objectName Type="QString"></objectName>
|
||||
<name Type="QString">northwind</name>
|
||||
<driver Type="QString">QSQLITE</driver>
|
||||
<databaseName Type="QString">./demo_reports/northwind.db</databaseName>
|
||||
<userName Type="QString"></userName>
|
||||
<password Value="" Type="QString"/>
|
||||
<host Type="QString"></host>
|
||||
<autoconnect Value="1" Type="bool"/>
|
||||
</item>
|
||||
</connections>
|
||||
<queries Type="Collection">
|
||||
<item Type="Object" ClassName="LimeReport::QueryDesc">
|
||||
<objectName Type="QString"></objectName>
|
||||
<queryName Type="QString">category</queryName>
|
||||
<queryText Type="QString">Select * from categories</queryText>
|
||||
<connectionName Type="QString">northwind</connectionName>
|
||||
</item>
|
||||
</queries>
|
||||
<subqueries Type="Collection">
|
||||
<item Type="Object" ClassName="LimeReport::SubQueryDesc">
|
||||
<objectName Type="QString"></objectName>
|
||||
<queryName Type="QString">products</queryName>
|
||||
<queryText Type="QString">Select * from products where CategoryID = $D{category.CategoryID}</queryText>
|
||||
<connectionName Type="QString">northwind</connectionName>
|
||||
<master Type="QString">category</master>
|
||||
</item>
|
||||
</subqueries>
|
||||
<subproxies Type="Collection"/>
|
||||
<variables Type="Collection">
|
||||
<item Type="Object" ClassName="LimeReport::VarDesc">
|
||||
<objectName Type="QString"></objectName>
|
||||
<name Type="QString">TestName</name>
|
||||
<value Type="QString">TestValue</value>
|
||||
</item>
|
||||
</variables>
|
||||
</datasourcesManager>
|
||||
</object>
|
||||
</Report>
|
BIN
demo/r1/demo_reports/northwind.db
Normal file
BIN
demo/r1/demo_reports/png/Beverage.png
Normal file
After Width: | Height: | Size: 71 KiB |
BIN
demo/r1/demo_reports/png/Condiments.png
Normal file
After Width: | Height: | Size: 51 KiB |
BIN
demo/r1/demo_reports/png/Confections.png
Normal file
After Width: | Height: | Size: 92 KiB |
BIN
demo/r1/demo_reports/png/Confections1.png
Normal file
After Width: | Height: | Size: 62 KiB |
BIN
demo/r1/demo_reports/png/Confections2.png
Normal file
After Width: | Height: | Size: 36 KiB |
BIN
demo/r1/demo_reports/png/Dairy_Products.png
Normal file
After Width: | Height: | Size: 36 KiB |
BIN
demo/r1/demo_reports/png/Grains_Cereals.png
Normal file
After Width: | Height: | Size: 59 KiB |
BIN
demo/r1/demo_reports/png/Grains_Cereals1.png
Normal file
After Width: | Height: | Size: 65 KiB |
BIN
demo/r1/demo_reports/png/Meat_Poultry.png
Normal file
After Width: | Height: | Size: 69 KiB |
BIN
demo/r1/demo_reports/png/Produce.png
Normal file
After Width: | Height: | Size: 66 KiB |
BIN
demo/r1/demo_reports/png/Seafood.png
Normal file
After Width: | Height: | Size: 66 KiB |
BIN
demo/r1/images/logo.png
Normal file
After Width: | Height: | Size: 18 KiB |
BIN
demo/r1/images/lr.png
Normal file
After Width: | Height: | Size: 328 B |
BIN
demo/r1/lr1.ico
Normal file
After Width: | Height: | Size: 316 KiB |
BIN
demo/r1/lr2.ico
Normal file
After Width: | Height: | Size: 316 KiB |
BIN
demo/r1/lr3.ico
Normal file
After Width: | Height: | Size: 316 KiB |
BIN
demo/r1/lr4.ico
Normal file
After Width: | Height: | Size: 316 KiB |
BIN
demo/r1/lr5.ico
Normal file
After Width: | Height: | Size: 316 KiB |
BIN
demo/r1/lr6.ico
Normal file
After Width: | Height: | Size: 316 KiB |
42
demo/r1/main.cpp
Normal file
@@ -0,0 +1,42 @@
|
||||
/***************************************************************************
|
||||
* This file is part of the Lime Report project *
|
||||
* Copyright (C) 2015 by Alexander Arin *
|
||||
* arin_a@bk.ru *
|
||||
* *
|
||||
** GNU General Public License Usage **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
** GNU Lesser General Public License **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#include "mainwindow.h"
|
||||
#include <QApplication>
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication a(argc, argv);
|
||||
MainWindow w;
|
||||
w.setWindowIcon(QIcon(":/images/main_ico"));
|
||||
w.show();
|
||||
|
||||
return a.exec();
|
||||
}
|
BIN
demo/r1/main.ico
Normal file
After Width: | Height: | Size: 316 KiB |
1
demo/r1/mainicon.rc
Normal file
@@ -0,0 +1 @@
|
||||
DI_ICON1 ICON "main.ico"
|
196
demo/r1/mainwindow.cpp
Normal file
@@ -0,0 +1,196 @@
|
||||
/***************************************************************************
|
||||
* This file is part of the Lime Report project *
|
||||
* Copyright (C) 2015 by Alexander Arin *
|
||||
* arin_a@bk.ru *
|
||||
* *
|
||||
** GNU General Public License Usage **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
** GNU Lesser General Public License **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#include "mainwindow.h"
|
||||
#include "ui_mainwindow.h"
|
||||
#include <QFileDialog>
|
||||
#include <QMessageBox>
|
||||
#include <QtSql/QSqlQuery>
|
||||
#include <QtSql/QSqlRecord>
|
||||
#include "lrreportengine.h"
|
||||
#include "lrcallbackdatasourceintf.h"
|
||||
#include <QDebug>
|
||||
#include <QStringListModel>
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent) :
|
||||
QMainWindow(parent),
|
||||
ui(new Ui::MainWindow), m_progressDialog(0), m_customers(0), m_orders(0)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
report = new LimeReport::ReportEngine(this);
|
||||
|
||||
connect(report, SIGNAL(renderStarted()), this, SLOT(renderStarted()));
|
||||
connect(report, SIGNAL(renderPageFinished(int)),
|
||||
this, SLOT(renderPageFinished(int)));
|
||||
connect(report, SIGNAL(renderFinished()), this, SLOT(renderFinished()));
|
||||
|
||||
QFile dbFile(QApplication::applicationDirPath()+"/demo_reports/northwind.db");
|
||||
if (dbFile.exists()){
|
||||
m_db = QSqlDatabase::addDatabase("QSQLITE");
|
||||
m_db.setDatabaseName(dbFile.fileName());
|
||||
if (m_db.open()){
|
||||
QSqlQueryModel* customersModel = new QSqlQueryModel();
|
||||
customersModel->setQuery("select * from customers", m_db);
|
||||
report->dataManager()->addModel("external_customers_data",customersModel,true);
|
||||
QSqlQueryModel* ordersModel = new QSqlQueryModel();
|
||||
ordersModel->setQuery("Select * from orders",m_db);
|
||||
report->dataManager()->addModel("external_orders_data",ordersModel,true);
|
||||
m_customers = new QSqlQuery("Select * from customers limit 10",m_db);
|
||||
m_customers->first();
|
||||
m_orders = new QSqlQuery(m_db);
|
||||
m_orders->prepare("Select * from orders where CustomerID = :id");
|
||||
m_orders->bindValue(":id",m_customers->value("CustomerID"));
|
||||
m_orders->exec();
|
||||
};
|
||||
}
|
||||
|
||||
LimeReport::ICallbackDatasource * callbackDatasource = report->dataManager()->createCallbackDatasouce("master");
|
||||
connect(callbackDatasource, SIGNAL(getCallbackData(LimeReport::CallbackInfo,QVariant&)),
|
||||
this, SLOT(slotGetCallbackData(LimeReport::CallbackInfo,QVariant&)));
|
||||
connect(callbackDatasource, SIGNAL(changePos(const LimeReport::CallbackInfo::ChangePosType&,bool&)),
|
||||
this, SLOT(slotChangePos(const LimeReport::CallbackInfo::ChangePosType&,bool&)));
|
||||
//report->dataManager()->addCallbackDatasource(callbackDatasource,"master");
|
||||
|
||||
callbackDatasource = report->dataManager()->createCallbackDatasouce("detail");
|
||||
connect(callbackDatasource, SIGNAL(getCallbackData(LimeReport::CallbackInfo,QVariant&)),
|
||||
this, SLOT(slotGetCallbackChildData(LimeReport::CallbackInfo,QVariant&)));
|
||||
connect(callbackDatasource, SIGNAL(changePos(const LimeReport::CallbackInfo::ChangePosType&,bool&)),
|
||||
this, SLOT(slotChangeChildPos(const LimeReport::CallbackInfo::ChangePosType&,bool&)));
|
||||
//report->dataManager()->addCallbackDatasource(callbackDatasource,"detail");
|
||||
|
||||
QStringList simpleData;
|
||||
simpleData << "value1" << "value2" << "value3";
|
||||
QStringListModel* stringListModel = new QStringListModel();
|
||||
stringListModel->setStringList(simpleData);
|
||||
|
||||
report->dataManager()->addModel("string_list",stringListModel,true);
|
||||
|
||||
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void MainWindow::on_pushButton_clicked()
|
||||
{
|
||||
report->dataManager()->clearUserVariables();
|
||||
if (!ui->leVariableName->text().isEmpty() && !ui->leVariableValue->text().isEmpty()){
|
||||
report->dataManager()->setReportVariable(ui->leVariableName->text(), ui->leVariableValue->text());
|
||||
}
|
||||
report->setShowProgressDialog(false);
|
||||
report->designReport();
|
||||
}
|
||||
|
||||
void MainWindow::on_pushButton_2_clicked()
|
||||
{
|
||||
QString fileName = QFileDialog::getOpenFileName(this,"Select report file",QApplication::applicationDirPath()+"/demo_reports/","*.lrxml");
|
||||
if (!fileName.isEmpty()) {
|
||||
report->loadFromFile(fileName);
|
||||
report->previewReport();
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::renderStarted()
|
||||
{
|
||||
m_currentPage = 0;
|
||||
m_progressDialog = new QProgressDialog(tr("Start render"),tr("Cancel"),0,0,this);
|
||||
m_progressDialog->setWindowModality(Qt::WindowModal);
|
||||
connect(m_progressDialog, SIGNAL(canceled()), report, SLOT(cancelRender()));
|
||||
m_progressDialog->show();
|
||||
QApplication::processEvents();
|
||||
}
|
||||
|
||||
void MainWindow::renderPageFinished(int renderedPageCount)
|
||||
{
|
||||
if (m_progressDialog){
|
||||
m_progressDialog->setLabelText(QString::number(renderedPageCount)+tr(" page rendered"));
|
||||
m_progressDialog->setValue(renderedPageCount);
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::renderFinished()
|
||||
{
|
||||
if (m_progressDialog){
|
||||
m_progressDialog->close();
|
||||
delete m_progressDialog;
|
||||
}
|
||||
m_progressDialog = 0;
|
||||
}
|
||||
|
||||
void MainWindow::prepareData(QSqlQuery* ds, LimeReport::CallbackInfo info, QVariant &data)
|
||||
{
|
||||
switch (info.dataType) {
|
||||
case LimeReport::CallbackInfo::IsEmpty:
|
||||
data = !ds->first();
|
||||
break;
|
||||
case LimeReport::CallbackInfo::HasNext:
|
||||
data = ds->next();
|
||||
if (data.toBool()) ds->previous();
|
||||
break;
|
||||
case LimeReport::CallbackInfo::ColumnHeaderData:
|
||||
if (info.index < ds->record().count())
|
||||
data = ds->record().fieldName(info.index);
|
||||
break;
|
||||
case LimeReport::CallbackInfo::ColumnData:
|
||||
data = ds->value(info.columnName);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::slotGetCallbackData(LimeReport::CallbackInfo info, QVariant &data)
|
||||
{
|
||||
if (!m_customers) return;
|
||||
prepareData(m_customers, info, data);
|
||||
}
|
||||
|
||||
void MainWindow::slotChangePos(const LimeReport::CallbackInfo::ChangePosType &type, bool &result)
|
||||
{
|
||||
QSqlQuery* ds = m_customers;
|
||||
if (!ds) return;
|
||||
if (type == LimeReport::CallbackInfo::First) result = ds->first();
|
||||
else result = ds->next();
|
||||
m_orders->bindValue(":id",m_customers->value("CustomerID"));
|
||||
m_orders->exec();
|
||||
}
|
||||
|
||||
void MainWindow::slotGetCallbackChildData(LimeReport::CallbackInfo info, QVariant &data)
|
||||
{
|
||||
if (!m_orders) return ;
|
||||
prepareData(m_orders, info, data);
|
||||
}
|
||||
|
||||
void MainWindow::slotChangeChildPos(const LimeReport::CallbackInfo::ChangePosType &type, bool &result)
|
||||
{
|
||||
QSqlQuery* ds = m_orders;
|
||||
if (!ds) return;
|
||||
if (type == LimeReport::CallbackInfo::First) result = ds->first();
|
||||
else result = ds->next();
|
||||
}
|
80
demo/r1/mainwindow.h
Normal file
@@ -0,0 +1,80 @@
|
||||
/***************************************************************************
|
||||
* This file is part of the Lime Report project *
|
||||
* Copyright (C) 2015 by Alexander Arin *
|
||||
* arin_a@bk.ru *
|
||||
* *
|
||||
** GNU General Public License Usage **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
** GNU Lesser General Public License **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#ifndef MAINWINDOW_H
|
||||
#define MAINWINDOW_H
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <QProgressDialog>
|
||||
#include <QtSql/QSqlDatabase>
|
||||
#include <QtSql/QSqlQueryModel>
|
||||
#include "lrreportengine.h"
|
||||
|
||||
namespace Ui {
|
||||
class MainWindow;
|
||||
}
|
||||
|
||||
class MainWindow : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MainWindow(QWidget *parent = 0);
|
||||
~MainWindow();
|
||||
private slots:
|
||||
void on_pushButton_clicked();
|
||||
void on_pushButton_2_clicked();
|
||||
void renderStarted();
|
||||
void renderPageFinished(int renderedPageCount);
|
||||
void renderFinished();
|
||||
void slotGetCallbackData(LimeReport::CallbackInfo info, QVariant& data);
|
||||
void slotChangePos(const LimeReport::CallbackInfo::ChangePosType& type, bool& result);
|
||||
void slotGetCallbackChildData(LimeReport::CallbackInfo info, QVariant& data);
|
||||
void slotChangeChildPos(const LimeReport::CallbackInfo::ChangePosType& type, bool& result);
|
||||
private:
|
||||
void prepareData(QSqlQuery* ds, LimeReport::CallbackInfo info, QVariant &data);
|
||||
private:
|
||||
Ui::MainWindow *ui;
|
||||
LimeReport::ReportEngine *report;
|
||||
QProgressDialog* m_progressDialog;
|
||||
int m_currentPage;
|
||||
QSqlDatabase m_db;
|
||||
int m_currentMasterRecord;
|
||||
QVector<QString> m_childData;
|
||||
|
||||
int m_currentCustomerRecord;
|
||||
int m_currentOrderRecord;
|
||||
QSqlQuery* m_customers;
|
||||
QSqlQuery* m_orders;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif // MAINWINDOW_H
|
213
demo/r1/mainwindow.ui
Normal file
@@ -0,0 +1,213 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>MainWindow</class>
|
||||
<widget class="QMainWindow" name="MainWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>369</width>
|
||||
<height>192</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>DEMO</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralWidget">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>100</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="pixmap">
|
||||
<pixmap resource="r1.qrc">:/images/logo</pixmap>
|
||||
</property>
|
||||
<property name="scaledContents">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>Report setting</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<property name="fieldGrowthPolicy">
|
||||
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
|
||||
</property>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="leVariableName">
|
||||
<property name="text">
|
||||
<string>TestName</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Variable Value</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="leVariableValue">
|
||||
<property name="text">
|
||||
<string>TestValue</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Variable Name</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>160</width>
|
||||
<height>23</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<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>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_2">
|
||||
<property name="text">
|
||||
<string>Run Report Preview </string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<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>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton">
|
||||
<property name="text">
|
||||
<string>Run Report Designer</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_4">
|
||||
<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>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>160</width>
|
||||
<height>28</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<resources>
|
||||
<include location="r1.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
44
demo/r1/r1.pro
Normal file
@@ -0,0 +1,44 @@
|
||||
QT += core gui script sql
|
||||
|
||||
EXTRA_DIR += $$PWD/demo_reports/*
|
||||
|
||||
win32:CONFIG(release, debug|release): DEST_DIR = $$OUT_PWD/demo_reports/
|
||||
win32:CONFIG(debug, debug|release): DEST_DIR = $$OUT_PWD/demo_reports/
|
||||
|
||||
unix{
|
||||
DEST_DIR = $$OUT_PWD/demo_reports/
|
||||
QMAKE_POST_LINK += mkdir -p $$quote($$DEST_DIR) | $$QMAKE_COPY_DIR $$quote($$EXTRA_DIR) $$quote($$DEST_DIR) $$escape_expand(\n\t)
|
||||
}
|
||||
|
||||
win32 {
|
||||
EXTRA_DIR ~= s,/,\\,g
|
||||
DEST_DIR ~= s,/,\\,g
|
||||
QMAKE_POST_LINK += $$QMAKE_COPY_DIR $$quote($$EXTRA_DIR) $$quote($$DEST_DIR) $$escape_expand(\\n\\t)
|
||||
}
|
||||
|
||||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets printsupport
|
||||
|
||||
TARGET = r1
|
||||
TEMPLATE = app
|
||||
|
||||
SOURCES += main.cpp\
|
||||
mainwindow.cpp
|
||||
|
||||
HEADERS += mainwindow.h
|
||||
|
||||
FORMS += mainwindow.ui
|
||||
|
||||
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../lib/release -llimereport
|
||||
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../lib/debug -llimereport
|
||||
else:unix:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../lib/debug -llimereport
|
||||
else:unix:CONFIG(release, debug|release): LIBS += -L$$PWD/../../lib/release -llimereport
|
||||
|
||||
INCLUDEPATH += $$PWD/../../include
|
||||
DEPENDPATH += $$PWD/../../include
|
||||
|
||||
RESOURCES += \
|
||||
r1.qrc
|
||||
|
||||
win32 {
|
||||
RC_FILE += mainicon.rc
|
||||
}
|
9
demo/r1/r1.qrc
Normal file
@@ -0,0 +1,9 @@
|
||||
<RCC>
|
||||
<qresource prefix="/images">
|
||||
<file alias="logo">images/logo.png</file>
|
||||
<file>main.ico</file>
|
||||
<file>images/lr.png</file>
|
||||
<file>lr1.ico</file>
|
||||
<file alias="main_ico">lr6.ico</file>
|
||||
</qresource>
|
||||
</RCC>
|