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/src
INCLUDEPATH += $$PWD/../qdecimal/decnumber INCLUDEPATH += $$PWD/../qdecimal/decnumber
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../LimeReport/build/5.5.1/win32/release/lib/ -llimereport unix{
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../LimeReport/build/5.5.1/win32/debug/lib/ -llimereport ARCH_TYPE = unix
else:unix: LIBS += -L$$PWD/../../LimeReport/build/5.5.1/win32/debug/lib/ -llimereport 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 INCLUDEPATH += $$PWD/../../LimeReport/include
DEPENDPATH += $$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()) if (ui->tableView->currentIndex().isValid())
{ {
@ -145,10 +145,6 @@ void IGridForm::on_tableView_clicked(const QModelIndex &index)
void IGridForm::on_btnPrint_clicked() void IGridForm::on_btnPrint_clicked()
{ {
/*ReportViewer *viewer = new ReportViewer(this);
viewer->setAttribute(Qt::WA_DeleteOnClose);
viewer->showMaximized();*/
ReportDialog *dialog = new ReportDialog(this); ReportDialog *dialog = new ReportDialog(this);
dialog->setAttribute(Qt::WA_DeleteOnClose); dialog->setAttribute(Qt::WA_DeleteOnClose);
dialog->setReports(Context::instance().plugin(pluginId())->reports()); dialog->setReports(Context::instance().plugin(pluginId())->reports());

@ -38,6 +38,19 @@ void ReportDialog::setReports(ReportList reports)
ui->listReports->setModel(model); ui->listReports->setModel(model);
m_reports = reports; 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() void ReportDialog::on_btnPreview_clicked()
@ -48,3 +61,15 @@ void ReportDialog::on_btnPreview_clicked()
viewer->setReport(m_reports[ui->listReports->currentIndex().row()]); viewer->setReport(m_reports[ui->listReports->currentIndex().row()]);
viewer->openPreview(); 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: private slots:
void on_btnPreview_clicked(); void on_btnPreview_clicked();
void on_btnPrint_clicked();
void on_btnClose_clicked();
private: private:
Ui::ReportDialog *ui; Ui::ReportDialog *ui;
ReportList m_reports; ReportList m_reports;

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

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

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

Loading…
Cancel
Save