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 814d831..8164036 100644 --- a/include/lrreportengine.h +++ b/include/lrreportengine.h @@ -98,6 +98,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 7ff4095..a7eaa36 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_scriptEngineContext = new ScriptEngineContext(this); @@ -457,6 +457,7 @@ void ReportEnginePrivate::cancelRender() { if (m_reportRender) m_reportRender->cancelRender(); + m_reportRendering = false; } PageDesignIntf* ReportEngine::createPreviewScene(QObject* parent){ @@ -634,6 +635,11 @@ void ReportEnginePrivate::setSuppressFieldAndVarError(bool suppressFieldAndVarEr m_reportSettings.setSuppressAbsentFieldsAndVarsWarnings(suppressFieldAndVarError); } +bool ReportEnginePrivate::isBusy() +{ + return m_reportRendering; +} + QString ReportEnginePrivate::previewWindowTitle() const { return m_previewWindowTitle; @@ -656,6 +662,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(); @@ -664,6 +671,7 @@ ReportPages ReportEnginePrivate::renderToPages() this, SIGNAL(renderPageFinished(int))); if (m_pages.count()){ ReportPages result; + m_reportRendering = true; emit renderStarted(); m_reportRender->setDatasources(dataManager()); m_reportRender->setScriptContext(scriptContext()); @@ -676,6 +684,7 @@ ReportPages ReportEnginePrivate::renderToPages() m_reportRender->secondRenderPass(result); emit renderFinished(); m_reportRender.clear(); + m_reportRendering = false; return result; } else { return ReportPages(); @@ -763,6 +772,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 814d831..8164036 100644 --- a/limereport/lrreportengine.h +++ b/limereport/lrreportengine.h @@ -98,6 +98,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 614bc88..2a6e230 100644 --- a/limereport/lrreportengine_p.h +++ b/limereport/lrreportengine_p.h @@ -121,7 +121,7 @@ public: bool suppressFieldAndVarError() const; void setSuppressFieldAndVarError(bool suppressFieldAndVarError); - + bool isBusy(); signals: void pagesLoadFinished(); void datasourceCollectionLoadFinished(const QString& collectionName); @@ -170,6 +170,7 @@ private: QString m_previewWindowTitle; QPointer m_designerWindow; ReportSettings m_reportSettings; + bool m_reportRendering; }; }