0
0
mirror of https://github.com/fralx/LimeReport.git synced 2025-11-25 08:28:06 +03:00

getPageFreeSpace(page) has been added to script function manager

This commit is contained in:
Arin Alexander
2021-04-12 20:22:34 +03:00
parent 3376ea7c08
commit 03963f3685
4 changed files with 59 additions and 33 deletions

View File

@@ -547,14 +547,13 @@ QVariant ScriptEngineManager::evaluateScript(const QString& script){
void ScriptEngineManager::addBookMark(const QString& uniqKey, const QString& content){
Q_ASSERT(m_context != 0);
if (m_context){
BandDesignIntf* currentBand = m_context->getCurrentBand();
BandDesignIntf* currentBand = m_context->currentBand();
if (currentBand)
currentBand->addBookmark(uniqKey, content);
else if (m_context->getCurrentPage()) {
m_context->getCurrentPage()->addBookmark(uniqKey, content);
else if (m_context->currentPage()) {
m_context->currentPage()->addBookmark(uniqKey, content);
}
}
}
int ScriptEngineManager::findPageIndexByBookmark(const QString &uniqKey)
@@ -570,6 +569,16 @@ int ScriptEngineManager::findPageIndexByBookmark(const QString &uniqKey)
return -1;
}
int ScriptEngineManager::getPageFreeSpace(PageItemDesignIntf* page){
if (page){
int height = 0;
foreach(BandDesignIntf* band, page->bands()){
height += band->height();
}
return page->height() - height;
} else return -1;
}
void ScriptEngineManager::addTableOfContentsItem(const QString& uniqKey, const QString& content, int indent)
{
Q_ASSERT(m_context != 0);
@@ -1306,7 +1315,7 @@ void ScriptEngineContext::setTableOfContents(TableOfContents* tableOfContents)
m_tableOfContents = tableOfContents;
}
PageItemDesignIntf* ScriptEngineContext::getCurrentPage() const
PageItemDesignIntf* ScriptEngineContext::currentPage() const
{
return m_currentPage;
}
@@ -1317,7 +1326,7 @@ void ScriptEngineContext::setCurrentPage(PageItemDesignIntf* currentPage)
m_currentBand = 0;
}
BandDesignIntf* ScriptEngineContext::getCurrentBand() const
BandDesignIntf* ScriptEngineContext::currentBand() const
{
return m_currentBand;
}
@@ -1693,6 +1702,10 @@ int ScriptFunctionsManager::findPageIndexByBookmark(const QString &uniqKey)
return scriptEngineManager()->findPageIndexByBookmark(uniqKey);
}
int ScriptFunctionsManager::getPageFreeSpace(QObject* page){
return scriptEngineManager()->getPageFreeSpace(dynamic_cast<PageItemDesignIntf*>(page));
}
void ScriptFunctionsManager::addTableOfContentsItem(const QString& uniqKey, const QString& content, int indent)
{
scriptEngineManager()->addTableOfContentsItem(uniqKey, content, indent);