From 97bd5e458438a990a1fdaa7aac18304339d55ec9 Mon Sep 17 00:00:00 2001 From: Arin Alexander Date: Tue, 13 Dec 2016 12:47:46 +0300 Subject: [PATCH] Fix #56 isBusy has been added to ReportEngine --- demo_r2/mainwindow.cpp | 7 ++++--- include/lrreportengine.h | 1 + limereport/lrreportengine.cpp | 17 ++++++++++++++++- limereport/lrreportengine.h | 1 + limereport/lrreportengine_p.h | 3 ++- 5 files changed, 24 insertions(+), 5 deletions(-) diff --git a/demo_r2/mainwindow.cpp b/demo_r2/mainwindow.cpp index 23c4d35..5ad3ac4 100644 --- a/demo_r2/mainwindow.cpp +++ b/demo_r2/mainwindow.cpp @@ -107,7 +107,6 @@ void MainWindow::slotPagesSet(int pagesCount) void MainWindow::slotPageChanged(int page) { -// ui->sbPageNavigator->setValue(page); m_pageNavigator->setValue(page); } @@ -118,8 +117,10 @@ void MainWindow::slotPageNavigatorChanged(int page) void MainWindow::on_treeWidget_itemClicked(QTreeWidgetItem *item, int ) { - m_report.loadFromFile(item->data(0,Qt::UserRole).toString()); - m_preview->refreshPages(); + if (!m_report.isBusy()){ + m_report.loadFromFile(item->data(0,Qt::UserRole).toString()); + m_preview->refreshPages(); + } } void MainWindow::initPercentCombobox() diff --git a/include/lrreportengine.h b/include/lrreportengine.h index 48ce408..ca6d153 100644 --- a/include/lrreportengine.h +++ b/include/lrreportengine.h @@ -92,6 +92,7 @@ public: PreviewReportWidget *createPreviewWidget(QWidget *parent = 0); void setPreviewWindowTitle(const QString& title); void setPreviewWindowIcon(const QIcon& icon); + bool isBusy(); signals: void renderStarted(); void renderFinished(); diff --git a/limereport/lrreportengine.cpp b/limereport/lrreportengine.cpp index b924f43..fca8f82 100644 --- a/limereport/lrreportengine.cpp +++ b/limereport/lrreportengine.cpp @@ -58,7 +58,7 @@ ReportEnginePrivate::ReportEnginePrivate(QObject *parent) : QObject(parent), m_fileName(""), m_settings(0), m_ownedSettings(false), m_printer(new QPrinter(QPrinter::HighResolution)), m_printerSelected(false), m_showProgressDialog(true), m_reportName(""), m_activePreview(0), - m_previewWindowIcon(":/report/images/logo32"), m_previewWindowTitle(tr("Preview")) + m_previewWindowIcon(":/report/images/logo32"), m_previewWindowTitle(tr("Preview")), m_reportRendering(false) { m_datasources= new DataSourceManager(this); m_datasources->setObjectName("datasources"); @@ -409,6 +409,7 @@ void ReportEnginePrivate::cancelRender() { if (m_reportRender) m_reportRender->cancelRender(); + m_reportRendering = false; } void ReportEnginePrivate::designReport() @@ -579,6 +580,11 @@ void ReportEnginePrivate::setSuppressFieldAndVarError(bool suppressFieldAndVarEr m_reportSettings.setSuppressAbsentFieldsAndVarsWarnings(suppressFieldAndVarError); } +bool ReportEnginePrivate::isBusy() +{ + return m_reportRendering; +} + QString ReportEnginePrivate::previewWindowTitle() const { return m_previewWindowTitle; @@ -601,6 +607,7 @@ void ReportEnginePrivate::setPreviewWindowIcon(const QIcon &previewWindowIcon) ReportPages ReportEnginePrivate::renderToPages() { + if (m_reportRendering) return ReportPages(); m_reportRender = ReportRender::Ptr(new ReportRender); dataManager()->clearErrors(); dataManager()->connectAllDatabases(); @@ -608,11 +615,13 @@ ReportPages ReportEnginePrivate::renderToPages() connect(m_reportRender.data(),SIGNAL(pageRendered(int)), this, SIGNAL(renderPageFinished(int))); if (m_pages.count()){ + m_reportRendering = true; emit renderStarted(); m_reportRender->setDatasources(dataManager()); m_pages.at(0)->setReportSettings(&m_reportSettings); ReportPages result = m_reportRender->renderPageToPages(m_pages.at(0)); emit renderFinished(); + m_reportRendering = false; return result; }else { return ReportPages(); @@ -695,6 +704,12 @@ void ReportEngine::setPreviewWindowIcon(const QIcon &icon) d->setPreviewWindowIcon(icon); } +bool ReportEngine::isBusy() +{ + Q_D(ReportEngine); + return d->isBusy(); +} + void ReportEngine::setShowProgressDialog(bool value) { Q_D(ReportEngine); diff --git a/limereport/lrreportengine.h b/limereport/lrreportengine.h index 48ce408..ca6d153 100644 --- a/limereport/lrreportengine.h +++ b/limereport/lrreportengine.h @@ -92,6 +92,7 @@ public: PreviewReportWidget *createPreviewWidget(QWidget *parent = 0); void setPreviewWindowTitle(const QString& title); void setPreviewWindowIcon(const QIcon& icon); + bool isBusy(); signals: void renderStarted(); void renderFinished(); diff --git a/limereport/lrreportengine_p.h b/limereport/lrreportengine_p.h index ecadd87..42a10af 100644 --- a/limereport/lrreportengine_p.h +++ b/limereport/lrreportengine_p.h @@ -115,7 +115,7 @@ public: bool suppressFieldAndVarError() const; void setSuppressFieldAndVarError(bool suppressFieldAndVarError); - + bool isBusy(); signals: void pagesLoadFinished(); void datasourceCollectionLoadFinished(const QString& collectionName); @@ -163,6 +163,7 @@ private: QString m_previewWindowTitle; QPointer m_designerWindow; ReportSettings m_reportSettings; + bool m_reportRendering; }; }