#include "reportdialog.h" #include "ui_reportdialog.h" #include #include #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(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(); }