Implemented reporting support via LimeReport

print
Josef Rokos 8 years ago
parent 37c9ee15af
commit 031e399320

@ -178,9 +178,26 @@ else:unix: LIBS += -L$$OUT_PWD/../qdecimal/lib/ -lqdecimal -ldecnumber
INCLUDEPATH += $$PWD/../qdecimal/src
INCLUDEPATH += $$PWD/../qdecimal/decnumber
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../LimeReport/build/5.5.1/win32/release/lib/ -llimereport
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../LimeReport/build/5.5.1/win32/debug/lib/ -llimereport
else:unix: LIBS += -L$$PWD/../../LimeReport/build/5.5.1/win32/debug/lib/ -llimereport
unix{
ARCH_TYPE = unix
macx{
ARCH_TYPE = macx
}
linux{
!contains(QT_ARCH, x86_64){
ARCH_TYPE = linux32
}else{
ARCH_TYPE = linux64
}
}
}
win32 {
ARCH_TYPE = win32
}
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../LimeReport/build/$${QT_VERSION}/$${ARCH_TYPE}/release/lib/ -llimereport
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../LimeReport/build/$${QT_VERSION}/$${ARCH_TYPE}/debug/lib/ -llimereport
else:unix: LIBS += -L$$PWD/../../LimeReport/build/$${QT_VERSION}/$${ARCH_TYPE}/debug/lib/ -llimereport
INCLUDEPATH += $$PWD/../../LimeReport/include
DEPENDPATH += $$PWD/../../LimeReport/include

@ -134,7 +134,7 @@ void IGridForm::on_btnFilter_toggled(bool checked)
}
}
void IGridForm::on_tableView_clicked(const QModelIndex &index)
void IGridForm::on_tableView_clicked(const QModelIndex &)
{
if (ui->tableView->currentIndex().isValid())
{
@ -145,10 +145,6 @@ void IGridForm::on_tableView_clicked(const QModelIndex &index)
void IGridForm::on_btnPrint_clicked()
{
/*ReportViewer *viewer = new ReportViewer(this);
viewer->setAttribute(Qt::WA_DeleteOnClose);
viewer->showMaximized();*/
ReportDialog *dialog = new ReportDialog(this);
dialog->setAttribute(Qt::WA_DeleteOnClose);
dialog->setReports(Context::instance().plugin(pluginId())->reports());

@ -38,6 +38,19 @@ void ReportDialog::setReports(ReportList reports)
ui->listReports->setModel(model);
m_reports = reports;
connect(ui->listReports->selectionModel(), &QItemSelectionModel::currentRowChanged, [this](const QModelIndex, QModelIndex){
ui->textDescription->setText(m_reports[ui->listReports->currentIndex().row()]->description());
});
if (!reports.isEmpty())
{
ui->btnPreview->setEnabled(true);
ui->btnPrint->setEnabled(true);
ui->listReports->setCurrentIndex(model->index(0, 0));
}
}
void ReportDialog::on_btnPreview_clicked()
@ -48,3 +61,15 @@ void ReportDialog::on_btnPreview_clicked()
viewer->setReport(m_reports[ui->listReports->currentIndex().row()]);
viewer->openPreview();
}
void ReportDialog::on_btnPrint_clicked()
{
ReportViewer viever;
viever.setReport(m_reports[ui->listReports->currentIndex().row()]);
viever.directPrint();
}
void ReportDialog::on_btnClose_clicked()
{
close();
}

@ -21,6 +21,10 @@ public:
private slots:
void on_btnPreview_clicked();
void on_btnPrint_clicked();
void on_btnClose_clicked();
private:
Ui::ReportDialog *ui;
ReportList m_reports;

@ -96,7 +96,11 @@
<number>0</number>
</property>
<item>
<widget class="QListView" name="listReports"/>
<widget class="QListView" name="listReports">
<property name="selectionBehavior">
<enum>QAbstractItemView::SelectRows</enum>
</property>
</widget>
</item>
</layout>
</widget>
@ -141,6 +145,9 @@
</item>
<item>
<widget class="QPushButton" name="btnPreview">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Preview</string>
</property>
@ -152,6 +159,9 @@
</item>
<item>
<widget class="QPushButton" name="btnPrint">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Print</string>
</property>

@ -4,6 +4,7 @@
#include "../context.h"
#include <QFile>
#include <QPrinter>
#include <LimeReport>
ReportViewer::ReportViewer(QWidget *parent) :
@ -11,6 +12,7 @@ ReportViewer::ReportViewer(QWidget *parent) :
ui(new Ui::ReportViewer)
{
ui->setupUi(this);
m_report = NULL;
}
ReportViewer::~ReportViewer()
@ -33,6 +35,8 @@ void ReportViewer::setReport(ReportPtr report)
void ReportViewer::openPreview()
{
Q_ASSERT(m_report != NULL);
showMaximized();
m_prevWidget = m_report->createPreviewWidget(this);
@ -52,6 +56,22 @@ void ReportViewer::openPreview()
m_prevWidget->refreshPages();
}
void ReportViewer::directPrint(bool dialog)
{
Q_ASSERT(m_report != NULL);
QPrinter printer(QPrinter::HighResolution);
if (dialog || !printer.isValid())
{
m_report->printReport();
}
else
{
m_report->printReport(&printer);
}
}
void ReportViewer::on_btnClose_clicked()
{
close();

@ -22,6 +22,7 @@ public:
~ReportViewer();
void setReport(ReportPtr report);
void openPreview();
void directPrint(bool dialog = true);
private slots:
void on_btnClose_clicked();

Loading…
Cancel
Save