You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
1.1 KiB
C++
51 lines
1.1 KiB
C++
#include "reportdialog.h"
|
|
#include "ui_reportdialog.h"
|
|
|
|
#include <QStandardItemModel>
|
|
#include <QIcon>
|
|
|
|
#include "reportviewer.h"
|
|
|
|
ReportDialog::ReportDialog(QWidget *parent) :
|
|
QDialog(parent),
|
|
ui(new Ui::ReportDialog)
|
|
{
|
|
ui->setupUi(this);
|
|
}
|
|
|
|
ReportDialog::~ReportDialog()
|
|
{
|
|
delete ui;
|
|
}
|
|
|
|
void ReportDialog::setReports(ReportList reports)
|
|
{
|
|
QStandardItemModel *model = qobject_cast<QStandardItemModel*>(ui->listReports->model());
|
|
|
|
if (model == NULL)
|
|
{
|
|
model = new QStandardItemModel(0, 1);
|
|
}
|
|
else
|
|
{
|
|
model->clear();
|
|
}
|
|
|
|
foreach (ReportPtr report, reports) {
|
|
QStandardItem *item = new QStandardItem((report->listReport() ? QIcon(":/icons/list.svg") : QIcon(":/icons/report.svg")), report->name());
|
|
model->appendRow(item);
|
|
}
|
|
|
|
ui->listReports->setModel(model);
|
|
m_reports = reports;
|
|
}
|
|
|
|
void ReportDialog::on_btnPreview_clicked()
|
|
{
|
|
ReportViewer *viewer = new ReportViewer(this);
|
|
viewer->setAttribute(Qt::WA_DeleteOnClose);
|
|
|
|
viewer->setReport(m_reports[ui->listReports->currentIndex().row()]);
|
|
viewer->openPreview();
|
|
}
|