0
0
mirror of https://github.com/fralx/LimeReport.git synced 2024-12-24 16:44:39 +03:00

Fix #56 isBusy has been added to ReportEngine

This commit is contained in:
Arin Alexander 2016-12-13 12:47:46 +03:00
parent 86ccf6868c
commit 97bd5e4584
5 changed files with 24 additions and 5 deletions

View File

@ -107,7 +107,6 @@ void MainWindow::slotPagesSet(int pagesCount)
void MainWindow::slotPageChanged(int page) void MainWindow::slotPageChanged(int page)
{ {
// ui->sbPageNavigator->setValue(page);
m_pageNavigator->setValue(page); m_pageNavigator->setValue(page);
} }
@ -118,8 +117,10 @@ void MainWindow::slotPageNavigatorChanged(int page)
void MainWindow::on_treeWidget_itemClicked(QTreeWidgetItem *item, int ) void MainWindow::on_treeWidget_itemClicked(QTreeWidgetItem *item, int )
{ {
if (!m_report.isBusy()){
m_report.loadFromFile(item->data(0,Qt::UserRole).toString()); m_report.loadFromFile(item->data(0,Qt::UserRole).toString());
m_preview->refreshPages(); m_preview->refreshPages();
}
} }
void MainWindow::initPercentCombobox() void MainWindow::initPercentCombobox()

View File

@ -92,6 +92,7 @@ public:
PreviewReportWidget *createPreviewWidget(QWidget *parent = 0); PreviewReportWidget *createPreviewWidget(QWidget *parent = 0);
void setPreviewWindowTitle(const QString& title); void setPreviewWindowTitle(const QString& title);
void setPreviewWindowIcon(const QIcon& icon); void setPreviewWindowIcon(const QIcon& icon);
bool isBusy();
signals: signals:
void renderStarted(); void renderStarted();
void renderFinished(); void renderFinished();

View File

@ -58,7 +58,7 @@ ReportEnginePrivate::ReportEnginePrivate(QObject *parent) :
QObject(parent), m_fileName(""), m_settings(0), m_ownedSettings(false), QObject(parent), m_fileName(""), m_settings(0), m_ownedSettings(false),
m_printer(new QPrinter(QPrinter::HighResolution)), m_printerSelected(false), m_printer(new QPrinter(QPrinter::HighResolution)), m_printerSelected(false),
m_showProgressDialog(true), m_reportName(""), m_activePreview(0), 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= new DataSourceManager(this);
m_datasources->setObjectName("datasources"); m_datasources->setObjectName("datasources");
@ -409,6 +409,7 @@ void ReportEnginePrivate::cancelRender()
{ {
if (m_reportRender) if (m_reportRender)
m_reportRender->cancelRender(); m_reportRender->cancelRender();
m_reportRendering = false;
} }
void ReportEnginePrivate::designReport() void ReportEnginePrivate::designReport()
@ -579,6 +580,11 @@ void ReportEnginePrivate::setSuppressFieldAndVarError(bool suppressFieldAndVarEr
m_reportSettings.setSuppressAbsentFieldsAndVarsWarnings(suppressFieldAndVarError); m_reportSettings.setSuppressAbsentFieldsAndVarsWarnings(suppressFieldAndVarError);
} }
bool ReportEnginePrivate::isBusy()
{
return m_reportRendering;
}
QString ReportEnginePrivate::previewWindowTitle() const QString ReportEnginePrivate::previewWindowTitle() const
{ {
return m_previewWindowTitle; return m_previewWindowTitle;
@ -601,6 +607,7 @@ void ReportEnginePrivate::setPreviewWindowIcon(const QIcon &previewWindowIcon)
ReportPages ReportEnginePrivate::renderToPages() ReportPages ReportEnginePrivate::renderToPages()
{ {
if (m_reportRendering) return ReportPages();
m_reportRender = ReportRender::Ptr(new ReportRender); m_reportRender = ReportRender::Ptr(new ReportRender);
dataManager()->clearErrors(); dataManager()->clearErrors();
dataManager()->connectAllDatabases(); dataManager()->connectAllDatabases();
@ -608,11 +615,13 @@ ReportPages ReportEnginePrivate::renderToPages()
connect(m_reportRender.data(),SIGNAL(pageRendered(int)), connect(m_reportRender.data(),SIGNAL(pageRendered(int)),
this, SIGNAL(renderPageFinished(int))); this, SIGNAL(renderPageFinished(int)));
if (m_pages.count()){ if (m_pages.count()){
m_reportRendering = true;
emit renderStarted(); emit renderStarted();
m_reportRender->setDatasources(dataManager()); m_reportRender->setDatasources(dataManager());
m_pages.at(0)->setReportSettings(&m_reportSettings); m_pages.at(0)->setReportSettings(&m_reportSettings);
ReportPages result = m_reportRender->renderPageToPages(m_pages.at(0)); ReportPages result = m_reportRender->renderPageToPages(m_pages.at(0));
emit renderFinished(); emit renderFinished();
m_reportRendering = false;
return result; return result;
}else { }else {
return ReportPages(); return ReportPages();
@ -695,6 +704,12 @@ void ReportEngine::setPreviewWindowIcon(const QIcon &icon)
d->setPreviewWindowIcon(icon); d->setPreviewWindowIcon(icon);
} }
bool ReportEngine::isBusy()
{
Q_D(ReportEngine);
return d->isBusy();
}
void ReportEngine::setShowProgressDialog(bool value) void ReportEngine::setShowProgressDialog(bool value)
{ {
Q_D(ReportEngine); Q_D(ReportEngine);

View File

@ -92,6 +92,7 @@ public:
PreviewReportWidget *createPreviewWidget(QWidget *parent = 0); PreviewReportWidget *createPreviewWidget(QWidget *parent = 0);
void setPreviewWindowTitle(const QString& title); void setPreviewWindowTitle(const QString& title);
void setPreviewWindowIcon(const QIcon& icon); void setPreviewWindowIcon(const QIcon& icon);
bool isBusy();
signals: signals:
void renderStarted(); void renderStarted();
void renderFinished(); void renderFinished();

View File

@ -115,7 +115,7 @@ public:
bool suppressFieldAndVarError() const; bool suppressFieldAndVarError() const;
void setSuppressFieldAndVarError(bool suppressFieldAndVarError); void setSuppressFieldAndVarError(bool suppressFieldAndVarError);
bool isBusy();
signals: signals:
void pagesLoadFinished(); void pagesLoadFinished();
void datasourceCollectionLoadFinished(const QString& collectionName); void datasourceCollectionLoadFinished(const QString& collectionName);
@ -163,6 +163,7 @@ private:
QString m_previewWindowTitle; QString m_previewWindowTitle;
QPointer<ReportDesignWindow> m_designerWindow; QPointer<ReportDesignWindow> m_designerWindow;
ReportSettings m_reportSettings; ReportSettings m_reportSettings;
bool m_reportRendering;
}; };
} }