Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
fralx committed Oct 16, 2019
2 parents db16d6a + 40726db commit 315c437
Show file tree
Hide file tree
Showing 14 changed files with 177 additions and 34 deletions.
2 changes: 1 addition & 1 deletion common.pri
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ RCC_DIR = $${ARCH_DIR}/$${BUILD_TYPE}/rcc

LIMEREPORT_VERSION_MAJOR = 1
LIMEREPORT_VERSION_MINOR = 5
LIMEREPORT_VERSION_RELEASE = 19
LIMEREPORT_VERSION_RELEASE = 20

LIMEREPORT_VERSION = '$${LIMEREPORT_VERSION_MAJOR}.$${LIMEREPORT_VERSION_MINOR}.$${LIMEREPORT_VERSION_RELEASE}'
DEFINES *= LIMEREPORT_VERSION_STR=\\\"$${LIMEREPORT_VERSION}\\\"
Expand Down
17 changes: 10 additions & 7 deletions demo_r1/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ MainWindow::MainWindow(QWidget *parent) :
int index = m_customers->record().indexOf("CustomerID");
m_orders->bindValue(":id",m_customers->value(index));
m_orders->exec();
};
}
}

LimeReport::ICallbackDatasource * callbackDatasource = report->dataManager()->createCallbackDatasource("master");
Expand Down Expand Up @@ -156,18 +156,21 @@ void MainWindow::on_pushButton_2_clicked()
// printers.insert("default",printer);
// report->printReport(printers);
// }
report->setShowProgressDialog(true);
report->previewReport();
}
}

void MainWindow::renderStarted()
{
m_currentPage = 0;
m_progressDialog = new QProgressDialog(tr("Start render"),tr("Cancel"),0,0,this);
m_progressDialog->setWindowModality(Qt::WindowModal);
connect(m_progressDialog, SIGNAL(canceled()), report, SLOT(cancelRender()));
m_progressDialog->show();
QApplication::processEvents();
if (report->isShowProgressDialog()){
m_currentPage = 0;
m_progressDialog = new QProgressDialog(tr("Start render"),tr("Cancel"),0,0,this);
//m_progressDialog->setWindowModality(Qt::WindowModal);
connect(m_progressDialog, SIGNAL(canceled()), report, SLOT(cancelRender()));
QApplication::processEvents();
m_progressDialog->show();
}
}

void MainWindow::renderPageFinished(int renderedPageCount)
Expand Down
1 change: 1 addition & 0 deletions include/lrreportengine.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ class LIMEREPORT_EXPORT ReportEngine : public QObject{
void designReport();
ReportDesignWindowInterface* getDesignerWindow();
void setShowProgressDialog(bool value);
bool isShowProgressDialog();
IDataSourceManager* dataManager();
IScriptEngineManager* scriptManager();
bool loadFromFile(const QString& fileName, bool autoLoadPreviewOnChange = false);
Expand Down
1 change: 1 addition & 0 deletions limereport/items/lrabstractlayout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ void AbstractLayout::beforeDelete()
#endif
BaseDesignIntf *bi = dynamic_cast<BaseDesignIntf*>(item);
if (bi) {
bi->disconnect(this);
bi->setParentItem(parentItem());
bi->setParent(parent());
bi->setVisible(true);
Expand Down
29 changes: 23 additions & 6 deletions limereport/lrdatasourcemanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,7 @@ void DataSourceManager::addQuery(const QString &name, const QString &sqlText, co
putQueryDesc(queryDecs);
putHolder(name,new QueryHolder(sqlText, connectionName, this));
m_hasChanges = true;
m_varToDataSource.clear();
emit datasourcesChanged();
}

Expand All @@ -534,6 +535,7 @@ void DataSourceManager::addSubQuery(const QString &name, const QString &sqlText,
putSubQueryDesc(subQueryDesc);
putHolder(name,new SubQueryHolder(sqlText, connectionName, masterDatasource, this));
m_hasChanges = true;
m_varToDataSource.clear();
emit datasourcesChanged();
}

Expand Down Expand Up @@ -1373,18 +1375,31 @@ void DataSourceManager::slotQueryTextChanged(const QString &queryName, const QSt
if (holder){
holder->setQueryText(queryText);
}
m_varToDataSource.clear();
}

void DataSourceManager::invalidateQueriesContainsVariable(const QString& variableName)
{
if (!variableIsSystem(variableName)){
foreach (const QString& datasourceName, dataSourceNames()){
QueryHolder* holder = dynamic_cast<QueryHolder*>(m_datasources.value(datasourceName));
if (holder){
QRegExp rx(QString(Const::NAMED_VARIABLE_RX).arg(variableName));
if (holder->queryText().contains(rx))
holder->invalidate(designTime()?IDataSource::DESIGN_MODE:IDataSource::RENDER_MODE);

if (m_varToDataSource.contains(variableName)){
foreach(QString datasourceName, m_varToDataSource.value(variableName)){
QueryHolder* holder = dynamic_cast<QueryHolder*>(m_datasources.value(datasourceName));
if (holder) holder->invalidate(designTime() ? IDataSource::DESIGN_MODE : IDataSource::RENDER_MODE);
}
} else {
QVector<QString> datasources;
foreach (const QString& datasourceName, dataSourceNames()){
QueryHolder* holder = dynamic_cast<QueryHolder*>(m_datasources.value(datasourceName));
if (holder){
QRegExp rx(QString(Const::NAMED_VARIABLE_RX).arg(variableName));
if (holder->queryText().contains(rx)){
holder->invalidate(designTime() ? IDataSource::DESIGN_MODE : IDataSource::RENDER_MODE);
datasources.append(datasourceName);
}
}
}
m_varToDataSource.insert(variableName, datasources);
}
}
}
Expand Down Expand Up @@ -1413,6 +1428,8 @@ void DataSourceManager::slotCSVTextChanged(const QString &csvName, const QString

void DataSourceManager::clear(ClearMethod method)
{
m_varToDataSource.clear();

DataSourcesMap::iterator dit;
for( dit = m_datasources.begin(); dit != m_datasources.end(); ){
bool owned = (*dit)->isOwned() && (*dit)->isRemovable();
Expand Down
3 changes: 3 additions & 0 deletions limereport/lrdatasourcemanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,9 @@ private slots:
QHash<QString,int> m_groupFunctionsExpressionsMap;
QVector<QString> m_groupFunctionsExpressions;
IDbCredentialsProvider* m_dbCredentialsProvider;

QMap< QString, QVector<QString> > m_varToDataSource;

bool m_hasChanges;
};

Expand Down
54 changes: 53 additions & 1 deletion limereport/lrpreviewreportwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@
#include <QFileDialog>
#include <QScrollBar>
#include <QDesktopWidget>
#include <QLabel>
#include <QMessageBox>
#include <QToolButton>

namespace LimeReport{

Expand All @@ -51,6 +54,25 @@ PreviewReportWindow::PreviewReportWindow(ReportEngine *report, QWidget *parent,
m_scalePercentChanging(false)
{
ui->setupUi(this);

m_progressWidget = new QWidget(ui->statusbar);
QHBoxLayout* progressLayout = new QHBoxLayout();
progressLayout->setMargin(0);
progressLayout->addWidget(new QLabel(tr("Printing")));
m_progressBar = new QProgressBar(ui->statusbar);
m_progressBar->setMaximumWidth(100);
m_progressBar->setMaximumHeight(ui->statusbar->fontMetrics().height());
progressLayout->addWidget(m_progressBar);
QToolButton* tbCancel = new QToolButton();
tbCancel->setIcon(QIcon(":/report/images/closebox"));
tbCancel->setAutoRaise(true);
connect(tbCancel, SIGNAL(clicked(bool)), this, SLOT(slotCancelPrinting(bool)));
progressLayout->addWidget(tbCancel);
progressLayout->setSizeConstraint(QLayout::SetFixedSize);
m_progressWidget->setLayout(progressLayout);
m_progressWidget->setVisible(false);
ui->statusbar->addPermanentWidget(m_progressWidget);

setWindowTitle("Lime Report Preview");
m_pagesNavigator = new QSpinBox(this);
m_pagesNavigator->setMaximum(10000000);
Expand All @@ -73,6 +95,10 @@ PreviewReportWindow::PreviewReportWindow(ReportEngine *report, QWidget *parent,
connect(m_previewReportWidget, SIGNAL(onSave(bool&, LimeReport::IPreparedPages*)),
this, SIGNAL(onSave(bool&, LimeReport::IPreparedPages*)));

connect(m_previewReportWidget->d_ptr->m_report, SIGNAL(printingStarted(int)), this, SLOT(slotPrintingStarted(int)));
connect(m_previewReportWidget->d_ptr->m_report, SIGNAL(pagePrintingFinished(int)), this, SLOT(slotPagePrintingFinished(int)));
connect(m_previewReportWidget->d_ptr->m_report, SIGNAL(printingFinished()), this, SLOT(slotPrintingFinished()));

m_fontEditor = new FontEditorWidgetForPage(m_previewReportWidget->d_ptr->m_previewPage,tr("Font"),this);
m_fontEditor->setObjectName("fontTools");
m_fontEditor->setIconSize(ui->toolBar->iconSize());
Expand Down Expand Up @@ -260,8 +286,12 @@ void PreviewReportWindow::exec()
if (deleteOnClose) delete this;
}

void PreviewReportWindow::closeEvent(QCloseEvent *)
void PreviewReportWindow::closeEvent(QCloseEvent* e)
{
if (m_progressBar->isVisible()){
QMessageBox::critical(this, tr("Attention"), tr("The printing is in process"));
e->setAccepted(false);
}
#ifdef Q_OS_WIN
writeSetting();
#endif
Expand Down Expand Up @@ -515,5 +545,27 @@ void PreviewReportWindow::slotItemInserted(PageDesignIntf *, QPointF, const QStr
slotActivateItemSelectionMode();
}

void PreviewReportWindow::slotPrintingStarted(int pageCount)
{
m_progressBar->setMinimum(1);
m_progressBar->setMaximum(pageCount);
m_progressWidget->setVisible(true);
}

void PreviewReportWindow::slotPagePrintingFinished(int pageIndex)
{
m_progressBar->setValue(pageIndex);
}

void PreviewReportWindow::slotPrintingFinished()
{
m_progressWidget->setVisible(false);
}

void PreviewReportWindow::slotCancelPrinting(bool)
{
m_previewReportWidget->d_ptr->m_report->cancelPrinting();
}

}// namespace LimeReport

7 changes: 7 additions & 0 deletions limereport/lrpreviewreportwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include <QSettings>
#include <QEventLoop>
#include <QPrinter>
#include <QProgressBar>

#include "serializators/lrxmlreader.h"
#include "lrpreparedpagesintf.h"
Expand Down Expand Up @@ -118,6 +119,10 @@ private slots:
void on_actionShow_Toolbar_triggered();
void slotCurrentPageChanged(int page);
void slotItemInserted(LimeReport::PageDesignIntf* report, QPointF pos, const QString& ItemType);
void slotPrintingStarted(int pageCount);
void slotPagePrintingFinished(int pageIndex);
void slotPrintingFinished();
void slotCancelPrinting(bool);
signals:
void onSave(bool& saved, LimeReport::IPreparedPages* pages);
private:
Expand All @@ -139,6 +144,8 @@ private slots:
ScaleType m_previewScaleType;
int m_previewScalePercent;
bool m_scalePercentChanging;
QProgressBar* m_progressBar;
QWidget* m_progressWidget;
};
} //namespace LimeReport
#endif // LRPREVIEWREPORTWINDOW_H
3 changes: 3 additions & 0 deletions limereport/lrreportdesignwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,10 @@ void ReportDesignWidget::previewReport()
#ifdef HAVE_QTDESIGNER_INTEGRATION
updateDialogs();
#endif
bool showProgressDialog = report()->isShowProgressDialog();
report()->setShowProgressDialog(false);
report()->previewReport();
report()->setShowProgressDialog(showProgressDialog);
}

void ReportDesignWidget::printReport()
Expand Down
64 changes: 48 additions & 16 deletions limereport/lrreportdesignwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,38 @@ namespace LimeReport{

ReportDesignWindow* ReportDesignWindow::m_instance=0;

void ReportDesignWindow::createProgressBar()
{
m_progressWidget = new QWidget(m_statusBar);
QHBoxLayout* progressLayout = new QHBoxLayout();
progressLayout->setMargin(0);
m_progressLabel = new QLabel(tr("Rendered %1 pages").arg(0));
progressLayout->addWidget(m_progressLabel);
m_progressBar = new QProgressBar(m_statusBar);
m_progressBar->setFormat("%v pages");
m_progressBar->setAlignment(Qt::AlignCenter);
m_progressBar->setMaximumWidth(100);
m_progressBar->setMaximumHeight(m_statusBar->fontMetrics().height());
m_progressBar->setMinimum(0);
m_progressBar->setMaximum(0);
m_progressBar->setTextVisible(true);
progressLayout->addWidget(m_progressBar);
QToolButton* tbCancel = new QToolButton();
tbCancel->setToolTip(tr("Cancel report rendering"));
tbCancel->setIcon(QIcon(":/report/images/closebox"));
tbCancel->setAutoRaise(true);
connect(tbCancel, SIGNAL(clicked(bool)), this, SLOT(slotCancelRendering(bool)));
progressLayout->addWidget(tbCancel);
progressLayout->setSizeConstraint(QLayout::SetFixedSize);
m_progressWidget->setLayout(progressLayout);
m_progressWidget->setVisible(false);
m_statusBar->addPermanentWidget(m_progressWidget);

connect(dynamic_cast<QObject*>(m_reportDesignWidget->report()), SIGNAL(renderStarted()), this, SLOT(renderStarted()));
connect(dynamic_cast<QObject*>(m_reportDesignWidget->report()), SIGNAL(renderPageFinished(int)), this, SLOT(renderPageFinished(int)));
connect(dynamic_cast<QObject*>(m_reportDesignWidget->report()), SIGNAL(renderFinished()), this, SLOT(renderFinished()));
}

ReportDesignWindow::ReportDesignWindow(ReportEnginePrivateInterface* report, QWidget *parent, QSettings* settings) :
ReportDesignWindowInterface(parent), m_textAttibutesIsChanging(false), m_settings(settings), m_ownedSettings(false),
m_progressDialog(0), m_showProgressDialog(true), m_editorTabType(ReportDesignWidget::Page), m_reportItemIsLocked(false)
Expand All @@ -77,6 +109,7 @@ ReportDesignWindow::ReportDesignWindow(ReportEnginePrivateInterface* report, QWi
createDataWindow();
createScriptWindow();
createObjectsBrowser();

#ifdef HAVE_QTDESIGNER_INTEGRATION
createDialogWidgetBox();
createDialogPropertyEditor();
Expand All @@ -100,7 +133,8 @@ ReportDesignWindow::ReportDesignWindow(ReportEnginePrivateInterface* report, QWi
showDefaultToolBars();
restoreSetting();
m_hideLeftPanel->setChecked(isDockAreaVisible(Qt::LeftDockWidgetArea));
m_hideRightPanel->setChecked(isDockAreaVisible(Qt::RightDockWidgetArea));
m_hideRightPanel->setChecked(isDockAreaVisible(Qt::RightDockWidgetArea));
createProgressBar();
}

ReportDesignWindow::~ReportDesignWindow()
Expand Down Expand Up @@ -515,9 +549,6 @@ void ReportDesignWindow::initReportEditor(ReportEnginePrivateInterface* report)
this, SLOT(slotBandAdded(LimeReport::PageDesignIntf*,LimeReport::BandDesignIntf*)));
connect(m_reportDesignWidget, SIGNAL(bandDeleted(LimeReport::PageDesignIntf*,LimeReport::BandDesignIntf*)),
this, SLOT(slotBandDeleted(LimeReport::PageDesignIntf*,LimeReport::BandDesignIntf*)));
connect(dynamic_cast<QObject*>(report), SIGNAL(renderStarted()), this, SLOT(renderStarted()));
connect(dynamic_cast<QObject*>(report), SIGNAL(renderPageFinished(int)), this, SLOT(renderPageFinished(int)));
connect(dynamic_cast<QObject*>(report), SIGNAL(renderFinished()), this, SLOT(renderFinished()));
connect(m_reportDesignWidget, SIGNAL(pageAdded(PageDesignIntf*)), this, SLOT(slotPageAdded(PageDesignIntf*)));
connect(m_reportDesignWidget, SIGNAL(pageDeleted()), this, SLOT(slotPageDeleted()));
}
Expand Down Expand Up @@ -1377,26 +1408,17 @@ void ReportDesignWindow::slotActivePageChanged()

void ReportDesignWindow::renderStarted()
{
if (m_showProgressDialog){
m_progressDialog = new QProgressDialog(tr("Rendering report"),tr("Abort"),0,0,this);
m_progressDialog->open(dynamic_cast<QObject*>(m_reportDesignWidget->report()), SLOT(cancelRender()));
QApplication::processEvents();
}
m_progressWidget->setVisible(true);
}

void ReportDesignWindow::renderPageFinished(int renderedPageCount)
{
if (m_progressDialog)
m_progressDialog->setLabelText(QString::number(renderedPageCount)+tr(" page rendered"));
m_progressLabel->setText(tr("Rendered %1 pages").arg(renderedPageCount));
}

void ReportDesignWindow::renderFinished()
{
if (m_progressDialog){
m_progressDialog->close();
delete m_progressDialog;
}
m_progressDialog = 0;
m_progressWidget->setVisible(false);
}

void ReportDesignWindow::slotShowAbout()
Expand Down Expand Up @@ -1536,8 +1558,18 @@ void ReportDesignWindow::slotSelectOneLevelItems()
m_reportDesignWidget->selectOneLevelItems();
}

void ReportDesignWindow::slotCancelRendering(bool)
{
m_reportDesignWidget->report()->cancelRender();
}

void ReportDesignWindow::closeEvent(QCloseEvent * event)
{
if (m_progressWidget->isVisible()){
QMessageBox::critical(this, tr("Attention"), tr("The rendering is in process"));
event->ignore();
return;
}
if (checkNeedToSave()){
m_dataBrowser->closeAllDataWindows();
writeState();
Expand Down
Loading

0 comments on commit 315c437

Please sign in to comment.