mirror of
https://github.com/python-LimeReport/LimeReport.git
synced 2024-12-25 04:54:40 +03:00
TOC has been added
This commit is contained in:
parent
0b0185a7f9
commit
54c5bc65ed
@ -240,6 +240,7 @@ public:
|
|||||||
qreal bottomSpace() const;
|
qreal bottomSpace() const;
|
||||||
signals:
|
signals:
|
||||||
void bandRendered(BandDesignIntf* band);
|
void bandRendered(BandDesignIntf* band);
|
||||||
|
void bandRegistred();
|
||||||
protected:
|
protected:
|
||||||
void trimToMaxHeight(int maxHeight);
|
void trimToMaxHeight(int maxHeight);
|
||||||
void setBandTypeText(const QString& value);
|
void setBandTypeText(const QString& value);
|
||||||
|
@ -687,6 +687,7 @@ bool CallbackDatasource::prior(){
|
|||||||
|
|
||||||
void CallbackDatasource::first(){
|
void CallbackDatasource::first(){
|
||||||
m_currentRow = 0;
|
m_currentRow = 0;
|
||||||
|
m_getDataFromCache = false;
|
||||||
m_eof=checkIfEmpty();
|
m_eof=checkIfEmpty();
|
||||||
bool result=false;
|
bool result=false;
|
||||||
|
|
||||||
|
@ -389,6 +389,7 @@ QSharedPointer<QAbstractItemModel>DataSourceManager::previewSQL(const QString &c
|
|||||||
void DataSourceManager::updateDatasourceModel()
|
void DataSourceManager::updateDatasourceModel()
|
||||||
{
|
{
|
||||||
m_datasourcesModel.updateModel();
|
m_datasourcesModel.updateModel();
|
||||||
|
emit datasourcesChanged();
|
||||||
m_needUpdate = false;
|
m_needUpdate = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ PageItemDesignIntf::PageItemDesignIntf(QObject *owner, QGraphicsItem *parent) :
|
|||||||
m_topMargin(0), m_bottomMargin(0), m_leftMargin(0), m_rightMargin(0),
|
m_topMargin(0), m_bottomMargin(0), m_leftMargin(0), m_rightMargin(0),
|
||||||
m_pageOrientaion(Portrait), m_pageSize(A4), m_sizeChainging(false),
|
m_pageOrientaion(Portrait), m_pageSize(A4), m_sizeChainging(false),
|
||||||
m_fullPage(false), m_oldPrintMode(false), m_resetPageNumber(false),
|
m_fullPage(false), m_oldPrintMode(false), m_resetPageNumber(false),
|
||||||
m_isExtendedInDesignMode(false), m_extendedHeight(1000)
|
m_isExtendedInDesignMode(false), m_extendedHeight(1000), m_isTOC(false)
|
||||||
{
|
{
|
||||||
setFixedPos(true);
|
setFixedPos(true);
|
||||||
setPossibleResizeDirectionFlags(Fixed);
|
setPossibleResizeDirectionFlags(Fixed);
|
||||||
@ -63,7 +63,7 @@ PageItemDesignIntf::PageItemDesignIntf(const PageSize pageSize, const QRectF &re
|
|||||||
m_topMargin(0), m_bottomMargin(0), m_leftMargin(0), m_rightMargin(0),
|
m_topMargin(0), m_bottomMargin(0), m_leftMargin(0), m_rightMargin(0),
|
||||||
m_pageOrientaion(Portrait), m_pageSize(pageSize), m_sizeChainging(false),
|
m_pageOrientaion(Portrait), m_pageSize(pageSize), m_sizeChainging(false),
|
||||||
m_fullPage(false), m_oldPrintMode(false), m_resetPageNumber(false),
|
m_fullPage(false), m_oldPrintMode(false), m_resetPageNumber(false),
|
||||||
m_isExtendedInDesignMode(false), m_extendedHeight(1000)
|
m_isExtendedInDesignMode(false), m_extendedHeight(1000), m_isTOC(false)
|
||||||
{
|
{
|
||||||
setFixedPos(true);
|
setFixedPos(true);
|
||||||
setPossibleResizeDirectionFlags(Fixed);
|
setPossibleResizeDirectionFlags(Fixed);
|
||||||
@ -331,6 +331,36 @@ void PageItemDesignIntf::initColumnsPos(QVector<qreal> &posByColumns, qreal pos,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString PageItemDesignIntf::initScript() const
|
||||||
|
{
|
||||||
|
return m_initScript;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PageItemDesignIntf::setInitScript(const QString& value)
|
||||||
|
{
|
||||||
|
if (m_initScript.compare(value) != 0){
|
||||||
|
QString old_value = m_initScript;
|
||||||
|
m_initScript = value;
|
||||||
|
if (!isLoading())
|
||||||
|
notify("initScript", old_value, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool PageItemDesignIntf::getIsTOC() const
|
||||||
|
{
|
||||||
|
return m_isTOC;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PageItemDesignIntf::setIsTOC(bool isTOC)
|
||||||
|
{
|
||||||
|
if (m_isTOC != isTOC){
|
||||||
|
m_isTOC = isTOC;
|
||||||
|
if (!isLoading()){
|
||||||
|
notify("pageIsTOC", !isTOC, isTOC);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int PageItemDesignIntf::extendedHeight() const
|
int PageItemDesignIntf::extendedHeight() const
|
||||||
{
|
{
|
||||||
return m_extendedHeight;
|
return m_extendedHeight;
|
||||||
|
@ -55,6 +55,8 @@ class PageItemDesignIntf : public LimeReport::ItemsContainerDesignInft
|
|||||||
Q_PROPERTY(bool resetPageNumber READ resetPageNumber WRITE setResetPageNumber)
|
Q_PROPERTY(bool resetPageNumber READ resetPageNumber WRITE setResetPageNumber)
|
||||||
Q_PROPERTY(bool isExtendedInDesignMode READ isExtendedInDesignMode WRITE setExtendedInDesignMode)
|
Q_PROPERTY(bool isExtendedInDesignMode READ isExtendedInDesignMode WRITE setExtendedInDesignMode)
|
||||||
Q_PROPERTY(int extendedHeight READ extendedHeight WRITE setExtendedHeight)
|
Q_PROPERTY(int extendedHeight READ extendedHeight WRITE setExtendedHeight)
|
||||||
|
Q_PROPERTY(bool pageIsTOC READ getIsTOC WRITE setIsTOC)
|
||||||
|
Q_PROPERTY(QString initScript READ initScript WRITE setInitScript)
|
||||||
friend class ReportRender;
|
friend class ReportRender;
|
||||||
public:
|
public:
|
||||||
enum Orientation { Portrait, Landscape };
|
enum Orientation { Portrait, Landscape };
|
||||||
@ -126,6 +128,14 @@ public:
|
|||||||
int extendedHeight() const;
|
int extendedHeight() const;
|
||||||
void setExtendedHeight(int extendedHeight);
|
void setExtendedHeight(int extendedHeight);
|
||||||
|
|
||||||
|
bool getIsTOC() const;
|
||||||
|
void setIsTOC(bool isTOC);
|
||||||
|
|
||||||
|
QString initScript() const;
|
||||||
|
void setInitScript(const QString& value);
|
||||||
|
signals:
|
||||||
|
void beforeFirstPageRendered();
|
||||||
|
void afterLastPageRendered();
|
||||||
protected slots:
|
protected slots:
|
||||||
void bandDeleted(QObject* band);
|
void bandDeleted(QObject* band);
|
||||||
void bandGeometryChanged(QObject* object, QRectF newGeometry, QRectF oldGeometry);
|
void bandGeometryChanged(QObject* object, QRectF newGeometry, QRectF oldGeometry);
|
||||||
@ -156,6 +166,8 @@ private:
|
|||||||
bool m_resetPageNumber;
|
bool m_resetPageNumber;
|
||||||
bool m_isExtendedInDesignMode;
|
bool m_isExtendedInDesignMode;
|
||||||
int m_extendedHeight;
|
int m_extendedHeight;
|
||||||
|
bool m_isTOC;
|
||||||
|
QString m_initScript;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef QList<PageItemDesignIntf::Ptr> ReportPages;
|
typedef QList<PageItemDesignIntf::Ptr> ReportPages;
|
||||||
|
@ -574,7 +574,7 @@ void ReportEnginePrivate::designReport()
|
|||||||
m_designerWindow->setWindowIcon(QIcon(":report/images/logo32"));
|
m_designerWindow->setWindowIcon(QIcon(":report/images/logo32"));
|
||||||
m_designerWindow->setShowProgressDialog(m_showProgressDialog);
|
m_designerWindow->setShowProgressDialog(m_showProgressDialog);
|
||||||
}
|
}
|
||||||
|
m_datasources->updateDatasourceModel();
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
m_designerWindow->setWindowModality(Qt::ApplicationModal);
|
m_designerWindow->setWindowModality(Qt::ApplicationModal);
|
||||||
#endif
|
#endif
|
||||||
@ -893,22 +893,41 @@ ReportPages ReportEnginePrivate::renderToPages()
|
|||||||
m_reportRender->setScriptContext(scriptContext());
|
m_reportRender->setScriptContext(scriptContext());
|
||||||
|
|
||||||
foreach (PageDesignIntf* page, m_pages) {
|
foreach (PageDesignIntf* page, m_pages) {
|
||||||
scriptContext()->baseDesignIntfToScript(page->pageItem());
|
scriptContext()->baseDesignIntfToScript(page->pageItem()->objectName(), page->pageItem());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_scriptEngineContext->runInitScript()){
|
if (m_scriptEngineContext->runInitScript()){
|
||||||
emit renderStarted();
|
emit renderStarted();
|
||||||
|
|
||||||
foreach(PageDesignIntf* page , m_pages){
|
foreach(PageDesignIntf* page , m_pages){
|
||||||
page->setReportSettings(&m_reportSettings);
|
if (!page->pageItem()->getIsTOC()){
|
||||||
result.append(m_reportRender->renderPageToPages(page));
|
page->setReportSettings(&m_reportSettings);
|
||||||
|
result.append(m_reportRender->renderPageToPages(page));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isFirst = true;
|
||||||
|
|
||||||
|
foreach(PageDesignIntf* page , m_pages){
|
||||||
|
if (page->pageItem()->getIsTOC()){
|
||||||
|
page->setReportSettings(&m_reportSettings);
|
||||||
|
if (isFirst){
|
||||||
|
ReportPages pages = m_reportRender->renderPageToPages(page);
|
||||||
|
for (int i=0; i<pages.count(); ++i){
|
||||||
|
result.insert(i,pages.at(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
result.append(m_reportRender->renderPageToPages(page));
|
||||||
|
}
|
||||||
|
isFirst = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_reportRender->secondRenderPass(result);
|
m_reportRender->secondRenderPass(result);
|
||||||
emit renderFinished();
|
emit renderFinished();
|
||||||
m_reportRender.clear();
|
m_reportRender.clear();
|
||||||
m_reportRendering = false;
|
|
||||||
}
|
}
|
||||||
|
m_reportRendering = false;
|
||||||
activateLanguage(QLocale::AnyLanguage);
|
activateLanguage(QLocale::AnyLanguage);
|
||||||
return result;
|
return result;
|
||||||
} else {
|
} else {
|
||||||
@ -1145,5 +1164,10 @@ ReportEngine::ReportEngine(ReportEnginePrivate &dd, QObject *parent)
|
|||||||
connect(d, SIGNAL(renderFinished()), this, SIGNAL(renderFinished()));
|
connect(d, SIGNAL(renderFinished()), this, SIGNAL(renderFinished()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ScriptEngineManager*LimeReport::ReportEnginePrivate::scriptManager(){
|
||||||
|
ScriptEngineManager::instance().setDataManager(dataManager());
|
||||||
|
return &ScriptEngineManager::instance();
|
||||||
|
}
|
||||||
|
|
||||||
}// namespace LimeReport
|
}// namespace LimeReport
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ public:
|
|||||||
int pageCount() {return m_pages.count();}
|
int pageCount() {return m_pages.count();}
|
||||||
DataSourceManager* dataManager(){return m_datasources;}
|
DataSourceManager* dataManager(){return m_datasources;}
|
||||||
ScriptEngineContext* scriptContext(){return m_scriptEngineContext;}
|
ScriptEngineContext* scriptContext(){return m_scriptEngineContext;}
|
||||||
ScriptEngineManager* scriptManager(){return &ScriptEngineManager::instance();}
|
ScriptEngineManager* scriptManager();
|
||||||
IDataSourceManager* dataManagerIntf(){return m_datasources;}
|
IDataSourceManager* dataManagerIntf(){return m_datasources;}
|
||||||
|
|
||||||
IScriptEngineManager* scriptManagerIntf(){
|
IScriptEngineManager* scriptManagerIntf(){
|
||||||
|
@ -982,6 +982,8 @@ bool ReportRender::registerBand(BandDesignIntf *band, bool registerInChildren)
|
|||||||
if (band->isData()) m_renderedDataBandCount++;
|
if (band->isData()) m_renderedDataBandCount++;
|
||||||
band->setObjectName(band->objectName()+QString::number(++m_curentNameIndex));
|
band->setObjectName(band->objectName()+QString::number(++m_curentNameIndex));
|
||||||
renameChildItems(band);
|
renameChildItems(band);
|
||||||
|
if (m_lastDataBand)
|
||||||
|
emit m_lastDataBand->bandRegistred();
|
||||||
return true;
|
return true;
|
||||||
} else return false;
|
} else return false;
|
||||||
}
|
}
|
||||||
@ -1065,7 +1067,7 @@ BandDesignIntf *ReportRender::renderData(BandDesignIntf *patternBand)
|
|||||||
{
|
{
|
||||||
BandDesignIntf* bandClone = dynamic_cast<BandDesignIntf*>(patternBand->cloneItem(PreviewMode));
|
BandDesignIntf* bandClone = dynamic_cast<BandDesignIntf*>(patternBand->cloneItem(PreviewMode));
|
||||||
|
|
||||||
m_scriptEngineContext->baseDesignIntfToScript(bandClone);
|
m_scriptEngineContext->baseDesignIntfToScript(patternBand->page()->pageItem()->objectName(), bandClone);
|
||||||
emit(patternBand->beforeRender());
|
emit(patternBand->beforeRender());
|
||||||
|
|
||||||
if (patternBand->isFooter()){
|
if (patternBand->isFooter()){
|
||||||
@ -1078,7 +1080,7 @@ BandDesignIntf *ReportRender::renderData(BandDesignIntf *patternBand)
|
|||||||
|
|
||||||
bandClone->updateItemSize(m_datasources);
|
bandClone->updateItemSize(m_datasources);
|
||||||
|
|
||||||
m_scriptEngineContext->baseDesignIntfToScript(bandClone);
|
//m_scriptEngineContext->baseDesignIntfToScript(bandClone);
|
||||||
emit(patternBand->afterData());
|
emit(patternBand->afterData());
|
||||||
|
|
||||||
return bandClone;
|
return bandClone;
|
||||||
@ -1101,7 +1103,7 @@ void ReportRender::startNewPage(bool isFirst)
|
|||||||
initColumns();
|
initColumns();
|
||||||
initRenderPage();
|
initRenderPage();
|
||||||
|
|
||||||
m_scriptEngineContext->baseDesignIntfToScript(m_renderPageItem);
|
m_scriptEngineContext->baseDesignIntfToScript(m_renderPageItem->patternName(), m_renderPageItem);
|
||||||
|
|
||||||
m_renderPageItem->setObjectName(QLatin1String("ReportPage")+QString::number(m_pageCount));
|
m_renderPageItem->setObjectName(QLatin1String("ReportPage")+QString::number(m_pageCount));
|
||||||
m_maxHeightByColumn[m_currentColumn]=m_renderPageItem->pageRect().height();
|
m_maxHeightByColumn[m_currentColumn]=m_renderPageItem->pageRect().height();
|
||||||
@ -1110,7 +1112,11 @@ void ReportRender::startNewPage(bool isFirst)
|
|||||||
|
|
||||||
emit m_patternPageItem->beforeRender();
|
emit m_patternPageItem->beforeRender();
|
||||||
|
|
||||||
if (isFirst) renderReportHeader(m_patternPageItem, BeforePageHeader);
|
if (isFirst) {
|
||||||
|
renderReportHeader(m_patternPageItem, BeforePageHeader);
|
||||||
|
emit m_patternPageItem->beforeFirstPageRendered();
|
||||||
|
}
|
||||||
|
|
||||||
renderPageHeader(m_patternPageItem);
|
renderPageHeader(m_patternPageItem);
|
||||||
|
|
||||||
m_pageFooterHeight = calcPageFooterHeight(m_patternPageItem);
|
m_pageFooterHeight = calcPageFooterHeight(m_patternPageItem);
|
||||||
@ -1303,6 +1309,7 @@ void ReportRender::savePage(bool isLast)
|
|||||||
|
|
||||||
moveTearOffBand();
|
moveTearOffBand();
|
||||||
emit m_patternPageItem->afterRender();
|
emit m_patternPageItem->afterRender();
|
||||||
|
if (isLast) emit m_patternPageItem->afterLastPageRendered();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -201,6 +201,8 @@ ScriptEngineManager::~ScriptEngineManager()
|
|||||||
{
|
{
|
||||||
delete m_model;
|
delete m_model;
|
||||||
m_model = 0;
|
m_model = 0;
|
||||||
|
delete m_tableOfContens;
|
||||||
|
m_tableOfContens = 0;
|
||||||
delete m_scriptEngine;
|
delete m_scriptEngine;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -342,8 +344,10 @@ void ScriptEngineManager::setDataManager(DataSourceManager *dataManager){
|
|||||||
.arg(LimeReport::Const::FUNCTION_MANAGER_NAME)
|
.arg(LimeReport::Const::FUNCTION_MANAGER_NAME)
|
||||||
);
|
);
|
||||||
addFunction(describer);
|
addFunction(describer);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
ICallbackDatasource* tableOfContens = m_dataManager->createCallbackDatasource("tableofcontens");
|
||||||
|
connect(tableOfContens, SIGNAL(getCallbackData(LimeReport::CallbackInfo,QVariant&)),
|
||||||
|
m_tableOfContens, SLOT(slotOneSlotDS(LimeReport::CallbackInfo,QVariant&)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -534,6 +538,11 @@ QVariant ScriptEngineManager::evaluateScript(const QString& script){
|
|||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ScriptEngineManager::addTableOfContensItem(const QString& content, int pageNumber, int indent)
|
||||||
|
{
|
||||||
|
m_tableOfContens->setItem(content, pageNumber, indent);
|
||||||
|
}
|
||||||
|
|
||||||
void ScriptEngineManager::updateModel()
|
void ScriptEngineManager::updateModel()
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -740,6 +749,36 @@ bool ScriptEngineManager::createGetFieldFunction()
|
|||||||
return addFunction(fd);
|
return addFunction(fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ScriptEngineManager::createAddTableOfContensItemFunction()
|
||||||
|
{
|
||||||
|
JSFunctionDesc fd;
|
||||||
|
fd.setManager(m_functionManager);
|
||||||
|
fd.setManagerName(LimeReport::Const::FUNCTION_MANAGER_NAME);
|
||||||
|
fd.setCategory(tr("GENERAL"));
|
||||||
|
fd.setName("addTableOfContensItem");
|
||||||
|
fd.setDescription("addTableOfContensItem(\""+tr("Content")+"\", \""+tr("Page Number")+", \""+tr("Indent")+"\")");
|
||||||
|
fd.setScriptWrapper(QString("function addTableOfContensItem(content, pageNumber, indent){"
|
||||||
|
"return %1.addTableOfContensItem(content, pageNumber, indent);}"
|
||||||
|
).arg(LimeReport::Const::FUNCTION_MANAGER_NAME)
|
||||||
|
);
|
||||||
|
return addFunction(fd);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ScriptEngineManager::createClearTableOfContensFunction()
|
||||||
|
{
|
||||||
|
JSFunctionDesc fd;
|
||||||
|
fd.setManager(m_functionManager);
|
||||||
|
fd.setManagerName(LimeReport::Const::FUNCTION_MANAGER_NAME);
|
||||||
|
fd.setCategory(tr("GENERAL"));
|
||||||
|
fd.setName("clearTableOfContens");
|
||||||
|
fd.setDescription("clearTableOfContens()");
|
||||||
|
fd.setScriptWrapper(QString("function clearTableOfContens(){"
|
||||||
|
"return %1.clearTableOfContens();}"
|
||||||
|
).arg(LimeReport::Const::FUNCTION_MANAGER_NAME)
|
||||||
|
);
|
||||||
|
return addFunction(fd);
|
||||||
|
}
|
||||||
|
|
||||||
ScriptEngineManager::ScriptEngineManager()
|
ScriptEngineManager::ScriptEngineManager()
|
||||||
:m_model(0), m_dataManager(0)
|
:m_model(0), m_dataManager(0)
|
||||||
{
|
{
|
||||||
@ -770,8 +809,11 @@ ScriptEngineManager::ScriptEngineManager()
|
|||||||
QScriptValue fontConstructor = m_scriptEngine->newFunction(QFontPrototype::constructorQFont, fontProto);
|
QScriptValue fontConstructor = m_scriptEngine->newFunction(QFontPrototype::constructorQFont, fontProto);
|
||||||
m_scriptEngine->globalObject().setProperty("QFont", fontConstructor);
|
m_scriptEngine->globalObject().setProperty("QFont", fontConstructor);
|
||||||
#endif
|
#endif
|
||||||
m_model = new ScriptEngineModel(this);
|
createAddTableOfContensItemFunction();
|
||||||
|
createClearTableOfContensFunction();
|
||||||
|
|
||||||
|
m_model = new ScriptEngineModel(this);
|
||||||
|
m_tableOfContens = new TableOfContens();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ScriptExtractor::parse()
|
bool ScriptExtractor::parse()
|
||||||
@ -1118,10 +1160,9 @@ QString ScriptEngineContext::getNewDialogName()
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void ScriptEngineContext::baseDesignIntfToScript(BaseDesignIntf* item)
|
void ScriptEngineContext::baseDesignIntfToScript(const QString& pageName, BaseDesignIntf* item)
|
||||||
{
|
{
|
||||||
if ( item ) {
|
if ( item ) {
|
||||||
|
|
||||||
if (item->metaObject()->indexOfSignal("beforeRender()")!=-1)
|
if (item->metaObject()->indexOfSignal("beforeRender()")!=-1)
|
||||||
item->disconnect(SIGNAL(beforeRender()));
|
item->disconnect(SIGNAL(beforeRender()));
|
||||||
if (item->metaObject()->indexOfSignal("afterData()")!=-1)
|
if (item->metaObject()->indexOfSignal("afterData()")!=-1)
|
||||||
@ -1134,9 +1175,9 @@ void ScriptEngineContext::baseDesignIntfToScript(BaseDesignIntf* item)
|
|||||||
#ifdef USE_QJSENGINE
|
#ifdef USE_QJSENGINE
|
||||||
//sItem = engine->newQObject(item);
|
//sItem = engine->newQObject(item);
|
||||||
ScriptValueType sItem = getCppOwnedJSValue(*engine, item);
|
ScriptValueType sItem = getCppOwnedJSValue(*engine, item);
|
||||||
engine->globalObject().setProperty(item->patternName(), sItem);
|
engine->globalObject().setProperty(pageName+"_"+item->patternName(), sItem);
|
||||||
#else
|
#else
|
||||||
ScriptValueType sItem = engine->globalObject().property(item->patternName());
|
ScriptValueType sItem = engine->globalObject().property(pageName+"_"+item->patternName());
|
||||||
if (sItem.isValid()){
|
if (sItem.isValid()){
|
||||||
engine->newQObject(sItem, item);
|
engine->newQObject(sItem, item);
|
||||||
} else {
|
} else {
|
||||||
@ -1145,7 +1186,7 @@ void ScriptEngineContext::baseDesignIntfToScript(BaseDesignIntf* item)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
foreach(BaseDesignIntf* child, item->childBaseItems()){
|
foreach(BaseDesignIntf* child, item->childBaseItems()){
|
||||||
baseDesignIntfToScript(child);
|
baseDesignIntfToScript(pageName, child);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1179,6 +1220,7 @@ void ScriptEngineContext::initDialogs(){
|
|||||||
bool ScriptEngineContext::runInitScript(){
|
bool ScriptEngineContext::runInitScript(){
|
||||||
|
|
||||||
ScriptEngineType* engine = ScriptEngineManager::instance().scriptEngine();
|
ScriptEngineType* engine = ScriptEngineManager::instance().scriptEngine();
|
||||||
|
ScriptEngineManager::instance().clearTableOfContens();
|
||||||
#ifndef USE_QJSENGINE
|
#ifndef USE_QJSENGINE
|
||||||
engine->pushContext();
|
engine->pushContext();
|
||||||
#endif
|
#endif
|
||||||
@ -1376,6 +1418,16 @@ QVariant ScriptFunctionsManager::getField(const QString &field)
|
|||||||
return dm->fieldData(field);
|
return dm->fieldData(field);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ScriptFunctionsManager::addTableOfContensItem(const QString& content, int pageNumber, int indent)
|
||||||
|
{
|
||||||
|
scriptEngineManager()->addTableOfContensItem(content, pageNumber, indent);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ScriptFunctionsManager::clearTableOfContens()
|
||||||
|
{
|
||||||
|
scriptEngineManager()->clearTableOfContens();
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef USE_QJSENGINE
|
#ifdef USE_QJSENGINE
|
||||||
QFont ScriptFunctionsManager::font(const QString &family, int pointSize, bool bold, bool italic, bool underLine)
|
QFont ScriptFunctionsManager::font(const QString &family, int pointSize, bool bold, bool italic, bool underLine)
|
||||||
{
|
{
|
||||||
@ -1413,5 +1465,68 @@ void ScriptFunctionsManager::setScriptEngineManager(ScriptEngineManager *scriptE
|
|||||||
m_scriptEngineManager = scriptEngineManager;
|
m_scriptEngineManager = scriptEngineManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TableOfContens::~TableOfContens()
|
||||||
|
{
|
||||||
|
clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void TableOfContens::setItem(const QString& content, int pageNumber, int indent)
|
||||||
|
{
|
||||||
|
ContentItem * item = 0;
|
||||||
|
if (m_hash.contains(content)){
|
||||||
|
ContentItem* item = m_hash.value(content);
|
||||||
|
item->pageNumber = pageNumber;
|
||||||
|
item->indent = indent;
|
||||||
|
} else {
|
||||||
|
ContentItem* item = new ContentItem;
|
||||||
|
item->content = content;
|
||||||
|
item->pageNumber = pageNumber;
|
||||||
|
item->indent = indent;
|
||||||
|
|
||||||
|
m_tableOfContens.append(item);
|
||||||
|
m_hash.insert(content, item);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void TableOfContens::slotOneSlotDS(CallbackInfo info, QVariant& data)
|
||||||
|
{
|
||||||
|
QStringList columns;
|
||||||
|
columns << "Content" << "Page number";
|
||||||
|
|
||||||
|
switch (info.dataType) {
|
||||||
|
case LimeReport::CallbackInfo::RowCount:
|
||||||
|
data = m_tableOfContens.count();
|
||||||
|
break;
|
||||||
|
case LimeReport::CallbackInfo::ColumnCount:
|
||||||
|
data = columns.size();
|
||||||
|
break;
|
||||||
|
case LimeReport::CallbackInfo::ColumnHeaderData: {
|
||||||
|
data = columns.at(info.index);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case LimeReport::CallbackInfo::ColumnData:
|
||||||
|
if (info.index < m_tableOfContens.count()){
|
||||||
|
ContentItem* item = m_tableOfContens.at(info.index);
|
||||||
|
if (info.columnName == "Content")
|
||||||
|
data = item->content.rightJustified(item->indent+item->content.size());
|
||||||
|
else
|
||||||
|
data = QString::number(item->pageNumber);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void LimeReport::TableOfContens::clear(){
|
||||||
|
|
||||||
|
m_hash.clear();
|
||||||
|
foreach(ContentItem* item, m_tableOfContens){
|
||||||
|
delete item;
|
||||||
|
}
|
||||||
|
m_tableOfContens.clear();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
} //namespace LimeReport
|
} //namespace LimeReport
|
||||||
|
|
||||||
|
@ -49,6 +49,7 @@
|
|||||||
#include "base/lrsingleton.h"
|
#include "base/lrsingleton.h"
|
||||||
#include "lrglobal.h"
|
#include "lrglobal.h"
|
||||||
#include "lrscriptenginemanagerintf.h"
|
#include "lrscriptenginemanagerintf.h"
|
||||||
|
#include "lrcallbackdatasourceintf.h"
|
||||||
#include "lrcollection.h"
|
#include "lrcollection.h"
|
||||||
|
|
||||||
namespace LimeReport{
|
namespace LimeReport{
|
||||||
@ -56,6 +57,26 @@ namespace LimeReport{
|
|||||||
class DataSourceManager;
|
class DataSourceManager;
|
||||||
class BaseDesignIntf;
|
class BaseDesignIntf;
|
||||||
|
|
||||||
|
struct ContentItem {
|
||||||
|
QString content;
|
||||||
|
int indent;
|
||||||
|
int pageNumber;
|
||||||
|
};
|
||||||
|
|
||||||
|
class TableOfContens : public QObject{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
~TableOfContens();
|
||||||
|
void setItem(const QString& content, int pageNumber, int indent = 0);
|
||||||
|
void clear();
|
||||||
|
private slots:
|
||||||
|
void slotOneSlotDS(LimeReport::CallbackInfo info, QVariant &data);
|
||||||
|
private:
|
||||||
|
QVector<ContentItem*> m_tableOfContens;
|
||||||
|
QHash<QString, ContentItem* > m_hash;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
struct ScriptFunctionDesc{
|
struct ScriptFunctionDesc{
|
||||||
enum FuncType {Native,Script};
|
enum FuncType {Native,Script};
|
||||||
ScriptValueType scriptValue;
|
ScriptValueType scriptValue;
|
||||||
@ -156,7 +177,7 @@ public:
|
|||||||
QString getNewDialogName();
|
QString getNewDialogName();
|
||||||
void initDialogs();
|
void initDialogs();
|
||||||
#endif
|
#endif
|
||||||
void baseDesignIntfToScript(BaseDesignIntf *item);
|
void baseDesignIntfToScript(const QString& pageName, BaseDesignIntf *item);
|
||||||
void clear();
|
void clear();
|
||||||
QString initScript() const;
|
QString initScript() const;
|
||||||
void setInitScript(const QString& initScript);
|
void setInitScript(const QString& initScript);
|
||||||
@ -243,6 +264,8 @@ public:
|
|||||||
Q_INVOKABLE QVariant getVariable(const QString& name);
|
Q_INVOKABLE QVariant getVariable(const QString& name);
|
||||||
Q_INVOKABLE QVariant getField(const QString& field);
|
Q_INVOKABLE QVariant getField(const QString& field);
|
||||||
Q_INVOKABLE QVariant color(const QString& color){ return QColor(color);}
|
Q_INVOKABLE QVariant color(const QString& color){ return QColor(color);}
|
||||||
|
Q_INVOKABLE void addTableOfContensItem(const QString& content, int pageNumber, int indent = 0);
|
||||||
|
Q_INVOKABLE void clearTableOfContens();
|
||||||
#ifdef USE_QJSENGINE
|
#ifdef USE_QJSENGINE
|
||||||
Q_INVOKABLE QFont font(const QString& family, int pointSize = -1, bool bold = false, bool italic = false, bool underLine = false);
|
Q_INVOKABLE QFont font(const QString& family, int pointSize = -1, bool bold = false, bool italic = false, bool underLine = false);
|
||||||
#endif
|
#endif
|
||||||
@ -282,6 +305,8 @@ public:
|
|||||||
QString expandDataFields(QString context, ExpandType expandType, QVariant &varValue, QObject* reportItem);
|
QString expandDataFields(QString context, ExpandType expandType, QVariant &varValue, QObject* reportItem);
|
||||||
QString expandScripts(QString context, QVariant &varValue, QObject* reportItem);
|
QString expandScripts(QString context, QVariant &varValue, QObject* reportItem);
|
||||||
QVariant evaluateScript(const QString &script);
|
QVariant evaluateScript(const QString &script);
|
||||||
|
void addTableOfContensItem(const QString& content, int pageNumber, int indent);
|
||||||
|
void clearTableOfContens(){ m_tableOfContens->clear(); }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void updateModel();
|
void updateModel();
|
||||||
@ -300,6 +325,8 @@ private:
|
|||||||
bool createSetVariableFunction();
|
bool createSetVariableFunction();
|
||||||
bool createGetVariableFunction();
|
bool createGetVariableFunction();
|
||||||
bool createGetFieldFunction();
|
bool createGetFieldFunction();
|
||||||
|
bool createAddTableOfContensItemFunction();
|
||||||
|
bool createClearTableOfContensFunction();
|
||||||
private:
|
private:
|
||||||
ScriptEngineManager();
|
ScriptEngineManager();
|
||||||
ScriptEngineType* m_scriptEngine;
|
ScriptEngineType* m_scriptEngine;
|
||||||
@ -309,6 +336,7 @@ private:
|
|||||||
ScriptEngineContext* m_context;
|
ScriptEngineContext* m_context;
|
||||||
DataSourceManager* m_dataManager;
|
DataSourceManager* m_dataManager;
|
||||||
ScriptFunctionsManager* m_functionManager;
|
ScriptFunctionsManager* m_functionManager;
|
||||||
|
TableOfContens* m_tableOfContens;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ScriptExtractor
|
class ScriptExtractor
|
||||||
|
@ -131,6 +131,7 @@ void ButtonLineEditor::editingByEditorFinished()
|
|||||||
{
|
{
|
||||||
setText(qobject_cast<TextItemPropertyEditor*>(sender())->text());
|
setText(qobject_cast<TextItemPropertyEditor*>(sender())->text());
|
||||||
m_lineEdit->setFocus();
|
m_lineEdit->setFocus();
|
||||||
|
emit editingFinished();
|
||||||
}
|
}
|
||||||
|
|
||||||
} //namespace LimeReport
|
} //namespace LimeReport
|
||||||
|
Loading…
Reference in New Issue
Block a user