mirror of
https://github.com/fralx/LimeReport.git
synced 2024-12-25 00:54:39 +03:00
Merge branch 'develop' into feature/Interface_lang
# Conflicts: # limereport/lrreportengine.cpp # limereport/lrreportengine.h # limereport/lrreportengine_p.h
This commit is contained in:
commit
0bfd8d03bc
11
common.pri
11
common.pri
@ -18,12 +18,13 @@ contains(CONFIG, easy_profiler){
|
|||||||
|
|
||||||
!contains(CONFIG, qtscriptengine){
|
!contains(CONFIG, qtscriptengine){
|
||||||
greaterThan(QT_MAJOR_VERSION, 4){
|
greaterThan(QT_MAJOR_VERSION, 4){
|
||||||
greaterThan(QT_MINOR_VERSION, 5){
|
|
||||||
CONFIG *= qjsengine
|
CONFIG *= qjsengine
|
||||||
}
|
#greaterThan(QT_MINOR_VERSION, 5){
|
||||||
lessThan(QT_MINOR_VERSION, 6){
|
# CONFIG *= qjsengine
|
||||||
CONFIG *= qtscriptengine
|
#}
|
||||||
}
|
#lessThan(QT_MINOR_VERSION, 6){
|
||||||
|
# CONFIG *= qtscriptengine
|
||||||
|
#}
|
||||||
}
|
}
|
||||||
lessThan(QT_MAJOR_VERSION, 5){
|
lessThan(QT_MAJOR_VERSION, 5){
|
||||||
CONFIG *= qtscriptengine
|
CONFIG *= qtscriptengine
|
||||||
|
@ -138,13 +138,12 @@ namespace Const{
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef USE_QJSENGINE
|
#ifdef USE_QJSENGINE
|
||||||
typedef QQmlEngine ScriptEngineType;
|
typedef QJSEngine ScriptEngineType;
|
||||||
typedef QJSValue ScriptValueType;
|
typedef QJSValue ScriptValueType;
|
||||||
template <typename T>
|
template <typename T>
|
||||||
static inline QJSValue getCppOwnedJSValue(QJSEngine &e, T *p)
|
static inline QJSValue getJSValue(QJSEngine &e, T *p)
|
||||||
{
|
{
|
||||||
QJSValue res = e.newQObject(p);
|
QJSValue res = e.newQObject(p);
|
||||||
QQmlEngine::setObjectOwnership(p, QQmlEngine::CppOwnership);
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
@ -138,13 +138,12 @@ namespace Const{
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef USE_QJSENGINE
|
#ifdef USE_QJSENGINE
|
||||||
typedef QQmlEngine ScriptEngineType;
|
typedef QJSEngine ScriptEngineType;
|
||||||
typedef QJSValue ScriptValueType;
|
typedef QJSValue ScriptValueType;
|
||||||
template <typename T>
|
template <typename T>
|
||||||
static inline QJSValue getCppOwnedJSValue(QJSEngine &e, T *p)
|
static inline QJSValue getJSValue(QJSEngine &e, T *p)
|
||||||
{
|
{
|
||||||
QJSValue res = e.newQObject(p);
|
QJSValue res = e.newQObject(p);
|
||||||
QQmlEngine::setObjectOwnership(p, QQmlEngine::CppOwnership);
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
@ -72,20 +72,15 @@ ReportDesignWidget::ReportDesignWidget(ReportEnginePrivateInterface* report, QMa
|
|||||||
mainLayout->addWidget(m_tabWidget);
|
mainLayout->addWidget(m_tabWidget);
|
||||||
setLayout(mainLayout);
|
setLayout(mainLayout);
|
||||||
|
|
||||||
// if (!report) {
|
m_report=report;
|
||||||
// m_report=new ReportEnginePrivate(this);
|
|
||||||
// m_report->setObjectName("report");
|
|
||||||
// m_report->appendPage("page1");
|
|
||||||
// }
|
|
||||||
// else {
|
|
||||||
m_report=report;//report->d_ptr;
|
|
||||||
if (!m_report->pageCount()) m_report->appendPage("page1");
|
if (!m_report->pageCount()) m_report->appendPage("page1");
|
||||||
// }
|
|
||||||
|
|
||||||
createTabs();
|
createTabs();
|
||||||
|
|
||||||
connect(dynamic_cast<QObject*>(m_report), SIGNAL(pagesLoadFinished()),this,SLOT(slotPagesLoadFinished()));
|
connect(dynamic_cast<QObject*>(m_report), SIGNAL(pagesLoadFinished()),this,SLOT(slotPagesLoadFinished()));
|
||||||
connect(dynamic_cast<QObject*>(m_report), SIGNAL(cleared()), this, SIGNAL(cleared()));
|
connect(dynamic_cast<QObject*>(m_report), SIGNAL(cleared()), this, SIGNAL(cleared()));
|
||||||
|
connect(dynamic_cast<QObject*>(m_report), SIGNAL(loaded()), this, SLOT(slotReportLoaded()));
|
||||||
|
|
||||||
connect(m_tabWidget, SIGNAL(currentChanged(int)), this, SLOT(slotCurrentTabChanged(int)));
|
connect(m_tabWidget, SIGNAL(currentChanged(int)), this, SLOT(slotCurrentTabChanged(int)));
|
||||||
#ifdef HAVE_UI_LOADER
|
#ifdef HAVE_UI_LOADER
|
||||||
connect(m_report->scriptContext(), SIGNAL(dialogDeleted(QString)), this, SLOT(slotDialogDeleted(QString)));
|
connect(m_report->scriptContext(), SIGNAL(dialogDeleted(QString)), this, SLOT(slotDialogDeleted(QString)));
|
||||||
@ -250,6 +245,7 @@ void ReportDesignWidget::loadState(QSettings* settings)
|
|||||||
|
|
||||||
|
|
||||||
void ReportDesignWidget::createTabs(){
|
void ReportDesignWidget::createTabs(){
|
||||||
|
m_tabWidget->clear();
|
||||||
int pageIndex = -1;
|
int pageIndex = -1;
|
||||||
for (int i = 0; i<m_report->pageCount();++i){
|
for (int i = 0; i<m_report->pageCount();++i){
|
||||||
QGraphicsView* view = new QGraphicsView(qobject_cast<QWidget*>(this));
|
QGraphicsView* view = new QGraphicsView(qobject_cast<QWidget*>(this));
|
||||||
@ -465,14 +461,13 @@ bool ReportDesignWidget::save()
|
|||||||
bool ReportDesignWidget::loadFromFile(const QString &fileName)
|
bool ReportDesignWidget::loadFromFile(const QString &fileName)
|
||||||
{
|
{
|
||||||
if (m_report->loadFromFile(fileName,false)){
|
if (m_report->loadFromFile(fileName,false)){
|
||||||
QByteArray editorState = m_scriptEditor->saveState();
|
// QByteArray editorState = m_scriptEditor->saveState();
|
||||||
createTabs();
|
// createTabs();
|
||||||
//connectPage(m_report->pageAt(0));
|
// m_scriptEditor->setPlainText(m_report->scriptContext()->initScript());
|
||||||
m_scriptEditor->setPlainText(m_report->scriptContext()->initScript());
|
// m_scriptEditor->restoreState(editorState);
|
||||||
m_scriptEditor->restoreState(editorState);
|
// emit loaded();
|
||||||
emit loaded();
|
// m_dialogChanged = false;
|
||||||
m_dialogChanged = false;
|
// return true;
|
||||||
return true;
|
|
||||||
} else {
|
} else {
|
||||||
QMessageBox::critical(this,tr("Error"),tr("Wrong file format"));
|
QMessageBox::critical(this,tr("Error"),tr("Wrong file format"));
|
||||||
return false;
|
return false;
|
||||||
@ -843,6 +838,16 @@ void ReportDesignWidget::slotCurrentTabChanged(int index)
|
|||||||
if (view) view->centerOn(0,0);
|
if (view) view->centerOn(0,0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ReportDesignWidget::slotReportLoaded()
|
||||||
|
{
|
||||||
|
QByteArray editorState = m_scriptEditor->saveState();
|
||||||
|
createTabs();
|
||||||
|
m_scriptEditor->setPlainText(m_report->scriptContext()->initScript());
|
||||||
|
m_scriptEditor->restoreState(editorState);
|
||||||
|
emit loaded();
|
||||||
|
m_dialogChanged = false;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef HAVE_QTDESIGNER_INTEGRATION
|
#ifdef HAVE_QTDESIGNER_INTEGRATION
|
||||||
|
|
||||||
void ReportDesignWidget::addNewDialog()
|
void ReportDesignWidget::addNewDialog()
|
||||||
|
@ -168,6 +168,7 @@ private slots:
|
|||||||
void slotDatasourceCollectionLoaded(const QString&);
|
void slotDatasourceCollectionLoaded(const QString&);
|
||||||
void slotSceneRectChanged(QRectF);
|
void slotSceneRectChanged(QRectF);
|
||||||
void slotCurrentTabChanged(int index);
|
void slotCurrentTabChanged(int index);
|
||||||
|
void slotReportLoaded();
|
||||||
#ifdef HAVE_QTDESIGNER_INTEGRATION
|
#ifdef HAVE_QTDESIGNER_INTEGRATION
|
||||||
void slotDialogChanged(QString);
|
void slotDialogChanged(QString);
|
||||||
void slotDialogNameChanged(QString oldName, QString newName);
|
void slotDialogNameChanged(QString oldName, QString newName);
|
||||||
|
@ -67,6 +67,7 @@
|
|||||||
#ifdef HAVE_STATIC_BUILD
|
#ifdef HAVE_STATIC_BUILD
|
||||||
#include "lrfactoryinitializer.h"
|
#include "lrfactoryinitializer.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace LimeReport{
|
namespace LimeReport{
|
||||||
|
|
||||||
QSettings* ReportEngine::m_settings = 0;
|
QSettings* ReportEngine::m_settings = 0;
|
||||||
@ -740,7 +741,11 @@ bool ReportEnginePrivate::loadFromFile(const QString &fileName, bool autoLoadPre
|
|||||||
m_fileWatcher->addPath( fileName );
|
m_fileWatcher->addPath( fileName );
|
||||||
}
|
}
|
||||||
|
|
||||||
return slotLoadFromFile( fileName );
|
bool result = slotLoadFromFile( fileName );
|
||||||
|
if (result) {
|
||||||
|
emit loaded();
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ReportEnginePrivate::loadFromByteArray(QByteArray* data, const QString &name){
|
bool ReportEnginePrivate::loadFromByteArray(QByteArray* data, const QString &name){
|
||||||
@ -752,6 +757,7 @@ bool ReportEnginePrivate::loadFromByteArray(QByteArray* data, const QString &nam
|
|||||||
if (reader->readItem(this)){
|
if (reader->readItem(this)){
|
||||||
m_fileName = "";
|
m_fileName = "";
|
||||||
m_reportName = name;
|
m_reportName = name;
|
||||||
|
emit loaded();
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -768,6 +774,7 @@ bool ReportEnginePrivate::loadFromString(const QString &report, const QString &n
|
|||||||
if (reader->readItem(this)){
|
if (reader->readItem(this)){
|
||||||
m_fileName = "";
|
m_fileName = "";
|
||||||
m_reportName = name;
|
m_reportName = name;
|
||||||
|
emit loaded();
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -1152,12 +1159,15 @@ ReportEngine::ReportEngine(QObject *parent)
|
|||||||
connect(d, SIGNAL(onSave()), this, SIGNAL(onSave()));
|
connect(d, SIGNAL(onSave()), this, SIGNAL(onSave()));
|
||||||
connect(d, SIGNAL(onLoad(bool&)), this, SIGNAL(onLoad(bool&)));
|
connect(d, SIGNAL(onLoad(bool&)), this, SIGNAL(onLoad(bool&)));
|
||||||
connect(d, SIGNAL(saveFinished()), this, SIGNAL(saveFinished()));
|
connect(d, SIGNAL(saveFinished()), this, SIGNAL(saveFinished()));
|
||||||
|
connect(d, SIGNAL(loaded()), this, SIGNAL(loaded()));
|
||||||
|
|
||||||
connect(d, SIGNAL(getAviableLanguages(QList<QLocale::Language>*)),
|
connect(d, SIGNAL(getAviableLanguages(QList<QLocale::Language>*)),
|
||||||
this, SIGNAL(getAviableLanguages(QList<QLocale::Language>*)));
|
this, SIGNAL(getAviableLanguages(QList<QLocale::Language>*)));
|
||||||
connect(d, SIGNAL(currentDefaulLanguageChanged(QLocale::Language)),
|
connect(d, SIGNAL(currentDefaulLanguageChanged(QLocale::Language)),
|
||||||
this, SIGNAL(currentDefaulLanguageChanged(QLocale::Language)));
|
this, SIGNAL(currentDefaulLanguageChanged(QLocale::Language)));
|
||||||
connect(d, SIGNAL(getCurrentDefaultLanguage()),
|
connect(d, SIGNAL(getCurrentDefaultLanguage()),
|
||||||
this, SIGNAL(getCurrentDefaultLanguage()));
|
this, SIGNAL(getCurrentDefaultLanguage()));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ReportEngine::~ReportEngine()
|
ReportEngine::~ReportEngine()
|
||||||
|
@ -122,6 +122,7 @@ signals:
|
|||||||
void onLoad(bool& loaded);
|
void onLoad(bool& loaded);
|
||||||
void onSave();
|
void onSave();
|
||||||
void saveFinished();
|
void saveFinished();
|
||||||
|
void loaded();
|
||||||
void getAviableLanguages(QList<QLocale::Language>* languages);
|
void getAviableLanguages(QList<QLocale::Language>* languages);
|
||||||
void currentDefaulLanguageChanged(QLocale::Language);
|
void currentDefaulLanguageChanged(QLocale::Language);
|
||||||
QLocale::Language getCurrentDefaultLanguage();
|
QLocale::Language getCurrentDefaultLanguage();
|
||||||
|
@ -195,6 +195,7 @@ signals:
|
|||||||
void onLoad(bool& loaded);
|
void onLoad(bool& loaded);
|
||||||
void onSave();
|
void onSave();
|
||||||
void saveFinished();
|
void saveFinished();
|
||||||
|
void loaded();
|
||||||
void getAviableLanguages(QList<QLocale::Language>* languages);
|
void getAviableLanguages(QList<QLocale::Language>* languages);
|
||||||
void currentDefaulLanguageChanged(QLocale::Language);
|
void currentDefaulLanguageChanged(QLocale::Language);
|
||||||
QLocale::Language getCurrentDefaultLanguage();
|
QLocale::Language getCurrentDefaultLanguage();
|
||||||
|
@ -299,7 +299,7 @@ void ReportRender::initRenderPage()
|
|||||||
ScriptEngineType* se = ScriptEngineManager::instance().scriptEngine();
|
ScriptEngineType* se = ScriptEngineManager::instance().scriptEngine();
|
||||||
|
|
||||||
#ifdef USE_QJSENGINE
|
#ifdef USE_QJSENGINE
|
||||||
svCurrentPage = getCppOwnedJSValue(*se, m_renderPageItem);
|
svCurrentPage = getJSValue(*se, m_renderPageItem);
|
||||||
se->globalObject().setProperty("currentPage", svCurrentPage);
|
se->globalObject().setProperty("currentPage", svCurrentPage);
|
||||||
#else
|
#else
|
||||||
svCurrentPage = se->globalObject().property("currentPage");
|
svCurrentPage = se->globalObject().property("currentPage");
|
||||||
|
@ -474,7 +474,7 @@ QString ScriptEngineManager::expandScripts(QString context, QVariant& varValue,
|
|||||||
ScriptValueType svThis;
|
ScriptValueType svThis;
|
||||||
|
|
||||||
#ifdef USE_QJSENGINE
|
#ifdef USE_QJSENGINE
|
||||||
svThis = getCppOwnedJSValue(*se, reportItem);
|
svThis = getJSValue(*se, reportItem);
|
||||||
se->globalObject().setProperty("THIS",svThis);
|
se->globalObject().setProperty("THIS",svThis);
|
||||||
#else
|
#else
|
||||||
svThis = se->globalObject().property("THIS");
|
svThis = se->globalObject().property("THIS");
|
||||||
@ -1280,7 +1280,7 @@ void ScriptEngineContext::baseDesignIntfToScript(const QString& pageName, BaseDe
|
|||||||
ScriptEngineType* engine = ScriptEngineManager::instance().scriptEngine();
|
ScriptEngineType* engine = ScriptEngineManager::instance().scriptEngine();
|
||||||
|
|
||||||
#ifdef USE_QJSENGINE
|
#ifdef USE_QJSENGINE
|
||||||
ScriptValueType sItem = getCppOwnedJSValue(*engine, item);
|
ScriptValueType sItem = getJSValue(*engine, item);
|
||||||
QString on = item->patternName().compare(pageName) == 0 ? pageName : pageName+"_"+item->patternName();
|
QString on = item->patternName().compare(pageName) == 0 ? pageName : pageName+"_"+item->patternName();
|
||||||
engine->globalObject().setProperty(on, sItem);
|
engine->globalObject().setProperty(on, sItem);
|
||||||
#else
|
#else
|
||||||
@ -1303,7 +1303,7 @@ void ScriptEngineContext::qobjectToScript(const QString& name, QObject *item)
|
|||||||
{
|
{
|
||||||
ScriptEngineType* engine = ScriptEngineManager::instance().scriptEngine();
|
ScriptEngineType* engine = ScriptEngineManager::instance().scriptEngine();
|
||||||
#ifdef USE_QJSENGINE
|
#ifdef USE_QJSENGINE
|
||||||
ScriptValueType sItem = getCppOwnedJSValue(*engine, item);
|
ScriptValueType sItem = getJSValue(*engine, item);
|
||||||
engine->globalObject().setProperty(name, sItem);
|
engine->globalObject().setProperty(name, sItem);
|
||||||
#else
|
#else
|
||||||
ScriptValueType sItem = engine->globalObject().property(name);
|
ScriptValueType sItem = engine->globalObject().property(name);
|
||||||
|
Loading…
Reference in New Issue
Block a user