2016-02-17 10:11:00 +03:00
|
|
|
/***************************************************************************
|
|
|
|
* This file is part of the Lime Report project *
|
|
|
|
* Copyright (C) 2015 by Alexander Arin *
|
|
|
|
* arin_a@bk.ru *
|
|
|
|
* *
|
|
|
|
** GNU General Public License Usage **
|
|
|
|
* *
|
|
|
|
* This library is free software: you can redistribute it and/or modify *
|
|
|
|
* it under the terms of the GNU General Public License as published by *
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or *
|
|
|
|
* (at your option) any later version. *
|
|
|
|
* You should have received a copy of the GNU General Public License *
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
|
|
|
* *
|
|
|
|
** GNU Lesser General Public License **
|
|
|
|
* *
|
|
|
|
* This library is free software: you can redistribute it and/or modify *
|
|
|
|
* it under the terms of the GNU Lesser General Public License as *
|
|
|
|
* published by the Free Software Foundation, either version 3 of the *
|
|
|
|
* License, or (at your option) any later version. *
|
|
|
|
* You should have received a copy of the GNU Lesser General Public *
|
|
|
|
* License along with this library. *
|
|
|
|
* If not, see <http://www.gnu.org/licenses/>. *
|
|
|
|
* *
|
|
|
|
* This library is distributed in the hope that it will be useful, *
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
|
* GNU General Public License for more details. *
|
|
|
|
****************************************************************************/
|
|
|
|
#ifndef LRREPORTDESIGNINTF_P_H
|
|
|
|
#define LRREPORTDESIGNINTF_P_H
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
#include <QSharedPointer>
|
2016-02-20 13:37:18 +03:00
|
|
|
#include <QMainWindow>
|
2016-02-17 10:11:00 +03:00
|
|
|
#include "lrreportengine.h"
|
|
|
|
#include "lrcollection.h"
|
|
|
|
#include "lrglobal.h"
|
|
|
|
#include "lrdatasourcemanager.h"
|
|
|
|
#include "lrbanddesignintf.h"
|
|
|
|
#include "lrreportrender.h"
|
|
|
|
#include "serializators/lrstorageintf.h"
|
|
|
|
#include "lrscriptenginemanager.h"
|
|
|
|
|
2017-04-20 05:43:48 +03:00
|
|
|
class QFileSystemWatcher;
|
|
|
|
|
2016-02-17 10:11:00 +03:00
|
|
|
namespace LimeReport{
|
|
|
|
|
|
|
|
class PageDesignIntf;
|
|
|
|
class PrintRange;
|
2016-04-21 17:53:31 +03:00
|
|
|
class ReportDesignWindow;
|
2016-02-17 10:11:00 +03:00
|
|
|
|
|
|
|
//TODO: Add on render callback
|
|
|
|
|
|
|
|
class ReportEnginePrivate : public QObject, public ICollectionContainer
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
Q_DECLARE_PUBLIC(ReportEngine)
|
|
|
|
Q_PROPERTY(ACollectionProperty pages READ fakeCollectionReader())
|
2016-06-10 18:05:18 +03:00
|
|
|
Q_PROPERTY(QObject* datasourcesManager READ dataManager)
|
|
|
|
Q_PROPERTY(QObject* scriptContext READ scriptContext)
|
2016-06-24 23:15:59 +03:00
|
|
|
Q_PROPERTY(bool suppressFieldAndVarError READ suppressFieldAndVarError WRITE setSuppressFieldAndVarError)
|
2016-03-30 23:21:44 +03:00
|
|
|
friend class PreviewReportWidget;
|
2016-02-17 10:11:00 +03:00
|
|
|
public:
|
|
|
|
static void printReport(ItemsReaderIntf::Ptr reader, QPrinter &printer);
|
2017-04-21 23:03:56 +03:00
|
|
|
static void printReport(ReportPages pages, QPrinter &printer);
|
2016-02-17 10:11:00 +03:00
|
|
|
public:
|
|
|
|
explicit ReportEnginePrivate(QObject *parent = 0);
|
|
|
|
virtual ~ReportEnginePrivate();
|
2016-06-10 18:05:18 +03:00
|
|
|
|
|
|
|
PageDesignIntf* appendPage(const QString& pageName="");
|
|
|
|
bool deletePage(PageDesignIntf *page);
|
|
|
|
PageDesignIntf* createPreviewPage();
|
|
|
|
PageDesignIntf* pageAt(int index){return (index<=(m_pages.count()-1)) ? m_pages.at(index):0;}
|
|
|
|
int pageCount() {return m_pages.count();}
|
|
|
|
DataSourceManager* dataManager(){return m_datasources;}
|
|
|
|
ScriptEngineContext* scriptContext(){return m_scriptEngineContext;}
|
|
|
|
ScriptEngineManager* scriptManager(){return &ScriptEngineManager::instance();}
|
|
|
|
IDataSourceManager* dataManagerIntf(){return m_datasources;}
|
2016-02-17 10:28:27 +03:00
|
|
|
|
|
|
|
IScriptEngineManager* scriptManagerIntf(){
|
|
|
|
ScriptEngineManager::instance().setDataManager(dataManager());
|
|
|
|
return &ScriptEngineManager::instance();
|
|
|
|
}
|
2016-02-17 10:11:00 +03:00
|
|
|
|
|
|
|
void clearReport();
|
|
|
|
bool printReport(QPrinter *printer=0);
|
2017-04-21 23:03:56 +03:00
|
|
|
bool printPages(ReportPages pages, QPrinter *printer);
|
2016-02-17 10:11:00 +03:00
|
|
|
void printToFile(const QString& fileName);
|
2016-02-17 10:19:50 +03:00
|
|
|
bool printToPDF(const QString& fileName);
|
2016-08-08 15:50:04 +03:00
|
|
|
void previewReport(PreviewHints hints = PreviewBarsUserSetting);
|
2016-02-17 10:11:00 +03:00
|
|
|
void designReport();
|
|
|
|
void setSettings(QSettings* value);
|
|
|
|
void setShowProgressDialog(bool value){m_showProgressDialog = value;}
|
|
|
|
QSettings* settings();
|
2017-04-20 05:43:48 +03:00
|
|
|
bool loadFromFile(const QString& fileName, bool autoLoadPreviewOnChange);
|
2016-02-17 10:39:17 +03:00
|
|
|
bool loadFromByteArray(QByteArray *data, const QString& name = "");
|
|
|
|
bool loadFromString(const QString& report, const QString& name = "");
|
2016-02-17 10:11:00 +03:00
|
|
|
QString reportFileName(){return m_fileName;}
|
2016-04-21 14:58:21 +03:00
|
|
|
void setReportFileName(const QString& reportFileName){ m_fileName = reportFileName;}
|
2016-02-17 10:11:00 +03:00
|
|
|
bool saveToFile();
|
|
|
|
bool saveToFile(const QString& fileName);
|
2016-02-17 10:39:17 +03:00
|
|
|
QByteArray saveToByteArray();
|
|
|
|
QString saveToString();
|
2016-02-17 10:11:00 +03:00
|
|
|
bool isNeedToSave();
|
|
|
|
QString lastError();
|
|
|
|
ReportEngine * q_ptr;
|
2016-02-17 10:39:17 +03:00
|
|
|
void emitSaveReport();
|
|
|
|
bool emitLoadReport();
|
2016-04-21 17:44:58 +03:00
|
|
|
void emitSaveFinished();
|
2016-02-17 10:39:17 +03:00
|
|
|
bool isSaved();
|
|
|
|
void setCurrentReportsDir(const QString& dirName);
|
|
|
|
QString currentReportsDir(){ return m_reportsDir;}
|
|
|
|
void setReportName(const QString& reportName){ m_reportName=reportName;}
|
|
|
|
QString reportName(){ return m_reportName;}
|
2016-02-20 13:37:18 +03:00
|
|
|
bool hasActivePreview(){return m_activePreview;}
|
2016-03-30 23:21:44 +03:00
|
|
|
PageDesignIntf *createPreviewScene(QObject *parent);
|
|
|
|
PreviewReportWidget *createPreviewWidget(QWidget *parent);
|
2016-04-06 22:03:58 +03:00
|
|
|
QIcon previewWindowIcon() const;
|
|
|
|
void setPreviewWindowIcon(const QIcon &previewWindowIcon);
|
|
|
|
QString previewWindowTitle() const;
|
|
|
|
void setPreviewWindowTitle(const QString &previewWindowTitle);
|
|
|
|
|
2016-06-24 23:15:59 +03:00
|
|
|
bool suppressFieldAndVarError() const;
|
|
|
|
void setSuppressFieldAndVarError(bool suppressFieldAndVarError);
|
2016-12-13 12:47:46 +03:00
|
|
|
bool isBusy();
|
2017-02-03 14:20:30 +03:00
|
|
|
bool resultIsEditable() const;
|
|
|
|
void setResultEditable(bool value);
|
|
|
|
|
2017-02-16 04:11:39 +03:00
|
|
|
void setPassPhrase(const QString &passPhrase);
|
2017-08-19 00:16:55 +03:00
|
|
|
void reorderPages(const QList<PageDesignIntf *> &reorderedPages);
|
2017-09-21 22:02:13 +03:00
|
|
|
void clearSelection();
|
2017-11-01 22:09:19 +03:00
|
|
|
Qt::LayoutDirection previewLayoutDirection();
|
|
|
|
void setPreviewLayoutDirection(const Qt::LayoutDirection& previewLayoutDirection);
|
2018-07-11 02:42:43 +03:00
|
|
|
ScaleType previewScaleType();
|
|
|
|
int previewScalePercent();
|
|
|
|
void setPreviewScaleType(const ScaleType &previewScaleType, int percent = 0);
|
|
|
|
|
2016-02-17 10:11:00 +03:00
|
|
|
signals:
|
|
|
|
void pagesLoadFinished();
|
|
|
|
void datasourceCollectionLoadFinished(const QString& collectionName);
|
|
|
|
void cleared();
|
|
|
|
void renderStarted();
|
|
|
|
void renderFinished();
|
|
|
|
void renderPageFinished(int renderedPageCount);
|
2016-02-17 10:39:17 +03:00
|
|
|
void onLoad(bool& loaded);
|
|
|
|
void onSave();
|
2016-04-21 17:44:58 +03:00
|
|
|
void saveFinished();
|
2016-02-17 10:11:00 +03:00
|
|
|
public slots:
|
2017-04-20 05:43:48 +03:00
|
|
|
bool slotLoadFromFile(const QString& fileName);
|
2016-02-17 10:11:00 +03:00
|
|
|
void cancelRender();
|
|
|
|
protected:
|
|
|
|
PageDesignIntf* createPage(const QString& pageName="");
|
|
|
|
protected slots:
|
|
|
|
void slotDataSourceCollectionLoaded(const QString& collectionName);
|
2016-02-20 13:37:18 +03:00
|
|
|
private slots:
|
2017-04-20 04:48:37 +03:00
|
|
|
void slotPreviewWindowDestroyed(QObject *window);
|
2016-02-17 10:11:00 +03:00
|
|
|
private:
|
|
|
|
//ICollectionContainer
|
|
|
|
virtual QObject* createElement(const QString&,const QString&);
|
|
|
|
virtual int elementsCount(const QString&);
|
|
|
|
virtual QObject* elementAt(const QString&, int index);
|
|
|
|
virtual void collectionLoadFinished(const QString&);
|
|
|
|
void saveError(QString message);
|
|
|
|
void showError(QString message);
|
|
|
|
//ICollectionContainer
|
|
|
|
ReportPages renderToPages();
|
|
|
|
QString renderToString();
|
|
|
|
private:
|
|
|
|
QList<PageDesignIntf*> m_pages;
|
|
|
|
DataSourceManager* m_datasources;
|
2016-06-10 18:05:18 +03:00
|
|
|
ScriptEngineContext* m_scriptEngineContext;
|
2016-02-17 10:11:00 +03:00
|
|
|
ReportRender::Ptr m_reportRender;
|
|
|
|
QString m_fileName;
|
|
|
|
QString m_lastError;
|
|
|
|
QSettings* m_settings;
|
|
|
|
bool m_ownedSettings;
|
|
|
|
QScopedPointer<QPrinter> m_printer;
|
|
|
|
bool m_printerSelected;
|
|
|
|
bool m_showProgressDialog;
|
2016-02-17 10:39:17 +03:00
|
|
|
QString m_reportsDir;
|
|
|
|
QString m_reportName;
|
2016-02-20 13:37:18 +03:00
|
|
|
QMainWindow* m_activePreview;
|
2016-04-06 22:03:58 +03:00
|
|
|
QIcon m_previewWindowIcon;
|
|
|
|
QString m_previewWindowTitle;
|
2016-04-21 17:53:31 +03:00
|
|
|
QPointer<ReportDesignWindow> m_designerWindow;
|
2016-06-24 23:15:59 +03:00
|
|
|
ReportSettings m_reportSettings;
|
2016-12-13 12:47:46 +03:00
|
|
|
bool m_reportRendering;
|
2017-02-03 14:20:30 +03:00
|
|
|
bool m_resultIsEditable;
|
2017-02-16 04:11:39 +03:00
|
|
|
QString m_passPhrase;
|
2017-04-20 05:43:48 +03:00
|
|
|
QFileSystemWatcher *m_fileWatcher;
|
2017-11-01 22:09:19 +03:00
|
|
|
Qt::LayoutDirection m_previewLayoutDirection;
|
2018-07-11 02:42:43 +03:00
|
|
|
ScaleType m_previewScaleType;
|
|
|
|
int m_previewScalePercent;
|
2016-02-17 10:11:00 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
#endif // LRREPORTDESIGNINTF_P_H
|