diff --git a/limereport/lrreportengine.cpp b/limereport/lrreportengine.cpp index 65beee0..e025379 100644 --- a/limereport/lrreportengine.cpp +++ b/limereport/lrreportengine.cpp @@ -858,13 +858,13 @@ QString ReportEnginePrivate::renderToString() if (m_pages.count()){ render.setDatasources(dataManager()); render.setScriptContext(scriptContext()); - return render.renderPageToString(m_pages.at(0)); + return render.renderPageToString(m_pages.at(0)->pageItem()); }else return QString(); } -PageDesignIntf* ReportEnginePrivate::getPageByName(const QString& pageName) +PageItemDesignIntf* ReportEnginePrivate::getPageByName(const QString& pageName) { - foreach(PageDesignIntf* page, m_pages){ + foreach(PageItemDesignIntf* page, m_renderingPages){ if ( page->objectName().compare(pageName, Qt::CaseInsensitive) == 0) return page; } @@ -931,10 +931,10 @@ void ReportEnginePrivate::activateLanguage(QLocale::Language language) ReportTranslation* translation = m_translations.value(language); foreach(PageTranslation* pageTranslation, translation->pagesTranslation()){ - PageDesignIntf* page = getPageByName(pageTranslation->pageName); + PageItemDesignIntf* page = getPageByName(pageTranslation->pageName); if (page){ foreach(ItemTranslation* itemTranslation, pageTranslation->itemsTranslation){ - BaseDesignIntf* item = page->pageItem()->childByName(itemTranslation->itemName); + BaseDesignIntf* item = page->childByName(itemTranslation->itemName); if (item) { foreach(PropertyTranslation* propertyTranslation, itemTranslation->propertyesTranslation){ item->setProperty(propertyTranslation->propertyName.toLatin1(), propertyTranslation->value); @@ -1017,6 +1017,13 @@ void ReportEnginePrivate::setPreviewWindowIcon(const QIcon &previewWindowIcon) m_previewWindowIcon = previewWindowIcon; } +PageItemDesignIntf* ReportEnginePrivate::createRenderingPage(PageItemDesignIntf* page){ + PageItemDesignIntf* result = dynamic_cast(page->cloneItem(page->itemMode())); + ICollectionContainer* co = dynamic_cast(result); + if (co) co->collectionLoadFinished("children"); + return result; +} + ReportPages ReportEnginePrivate::renderToPages() { if (m_reportRendering) return ReportPages(); @@ -1031,6 +1038,7 @@ ReportPages ReportEnginePrivate::renderToPages() this, SIGNAL(renderPageFinished(int))); if (m_pages.count()){ + #ifdef HAVE_UI_LOADER m_scriptEngineContext->initDialogs(); #endif @@ -1041,7 +1049,9 @@ ReportPages ReportEnginePrivate::renderToPages() m_reportRender->setScriptContext(scriptContext()); foreach (PageDesignIntf* page, m_pages) { - scriptContext()->baseDesignIntfToScript(page->pageItem()->objectName(), page->pageItem()); + PageItemDesignIntf* rp = createRenderingPage(page->pageItem()); + m_renderingPages.append(rp); + scriptContext()->baseDesignIntfToScript(rp->objectName(), rp); } scriptContext()->qobjectToScript("engine",this); @@ -1051,27 +1061,25 @@ ReportPages ReportEnginePrivate::renderToPages() activateLanguage(m_reportLanguage); emit renderStarted(); - foreach(PageDesignIntf* page , m_pages){ - if (!page->pageItem()->isTOC()){ + foreach(PageItemDesignIntf* page , m_renderingPages){ + if (!page->isTOC() && page->isPrintable()){ page->setReportSettings(&m_reportSettings); result.append(m_reportRender->renderPageToPages(page)); } } -// m_reportRender->secondRenderPass(result); - - for (int i=0; ipageItem()->isTOC()){ + for (int i=0; iisTOC()){ page->setReportSettings(&m_reportSettings); if (i==0){ - PageDesignIntf* secondPage = 0; - if (m_pages.count()>1) secondPage = m_pages.at(1); + PageItemDesignIntf* secondPage = 0; + if (m_pages.count()>1) secondPage = m_renderingPages.at(1); ReportPages pages = m_reportRender->renderTOC( page, true, - secondPage && secondPage->pageItem()->resetPageNumber() + secondPage && secondPage->resetPageNumber() ); for (int j=0; j m_pages; + QList m_renderingPages; DataSourceManager* m_datasources; ScriptEngineContext* m_scriptEngineContext; ReportRender::Ptr m_reportRender; diff --git a/limereport/lrreportrender.cpp b/limereport/lrreportrender.cpp index 154ab61..d6876b9 100644 --- a/limereport/lrreportrender.cpp +++ b/limereport/lrreportrender.cpp @@ -187,10 +187,10 @@ void ReportRender::initDatasource(const QString& name){ } } -void ReportRender::renderPage(PageDesignIntf* patternPage, bool isTOC, bool isFirst, bool resetPageNumbers) +void ReportRender::renderPage(PageItemDesignIntf* patternPage, bool isTOC, bool isFirst, bool resetPageNumbers) { m_curentNameIndex = 0; - m_patternPageItem = patternPage->pageItem(); + m_patternPageItem = patternPage; m_renderingFirstTOC = isTOC && isFirst; if (m_patternPageItem->resetPageNumber() && m_pageCount>0 && !isTOC) { @@ -269,19 +269,19 @@ PageItemDesignIntf::Ptr ReportRender::pageAt(int index) else return m_renderedPages.at(index); } -QString ReportRender::renderPageToString(PageDesignIntf *patternPage) +QString ReportRender::renderPageToString(PageItemDesignIntf *patternPage) { renderPage(patternPage); return toString(); } -ReportPages ReportRender::renderPageToPages(PageDesignIntf *patternPage) +ReportPages ReportRender::renderPageToPages(PageItemDesignIntf *patternPage) { renderPage(patternPage); return m_renderedPages; } -ReportPages ReportRender::renderTOC(PageDesignIntf* patternPage, bool first, bool resetPages){ +ReportPages ReportRender::renderTOC(PageItemDesignIntf* patternPage, bool first, bool resetPages){ renderPage(patternPage, true, first, resetPages); return m_renderedPages; } @@ -1134,7 +1134,7 @@ BandDesignIntf *ReportRender::renderData(BandDesignIntf *patternBand) { BandDesignIntf* bandClone = dynamic_cast(patternBand->cloneItem(PreviewMode)); - m_scriptEngineContext->baseDesignIntfToScript(patternBand->page()->pageItem()->objectName(), bandClone); + m_scriptEngineContext->baseDesignIntfToScript(patternBand->parent()->objectName(), bandClone); m_scriptEngineContext->setCurrentBand(bandClone); emit(patternBand->beforeRender()); diff --git a/limereport/lrreportrender.h b/limereport/lrreportrender.h index e32d04a..8467656 100644 --- a/limereport/lrreportrender.h +++ b/limereport/lrreportrender.h @@ -80,9 +80,9 @@ public: DataSourceManager* datasources(){return m_datasources;} int pageCount(); PageItemDesignIntf::Ptr pageAt(int index); - QString renderPageToString(PageDesignIntf *patternPage); - ReportPages renderPageToPages(PageDesignIntf *patternPage); - ReportPages renderTOC(PageDesignIntf* patternPage, bool first, bool resetPages); + QString renderPageToString(PageItemDesignIntf *patternPage); + ReportPages renderPageToPages(PageItemDesignIntf *patternPage); + ReportPages renderTOC(PageItemDesignIntf *patternPage, bool first, bool resetPages); void secondRenderPass(ReportPages renderedPages); signals: void pageRendered(int renderedPageCount); @@ -96,7 +96,7 @@ private: void initGroups(); void clearPageMap(); - void renderPage(PageDesignIntf *patternPage, bool isTOC = false, bool isFirst = false, bool resetPageNumbers = false); + void renderPage(PageItemDesignIntf *patternPage, bool isTOC = false, bool isFirst = false, bool resetPageNumbers = false); BandDesignIntf* renderBand(BandDesignIntf *patternBand, BandDesignIntf *bandData, DataRenderMode mode = NotStartNewPage, bool isLast = false); void renderDataBand(BandDesignIntf* dataBand); void renderPageHeader(PageItemDesignIntf* patternPage); diff --git a/limereport/lrreporttranslation.cpp b/limereport/lrreporttranslation.cpp index 2df00eb..5c8fee8 100644 --- a/limereport/lrreporttranslation.cpp +++ b/limereport/lrreporttranslation.cpp @@ -32,7 +32,7 @@ ReportTranslation::~ReportTranslation() PageTranslation* ReportTranslation::createPageTranslation(PageDesignIntf* page) { PageTranslation* pageTranslation = new PageTranslation; - pageTranslation->pageName = page->objectName(); + pageTranslation->pageName = page->pageItem()->objectName(); foreach(BaseDesignIntf* item, page->pageItem()->allChildBaseItems()){ createItemTranslation(item, pageTranslation); } diff --git a/limereport/translationeditor/translationeditor.cpp b/limereport/translationeditor/translationeditor.cpp index 4db0a6a..f4f4ce6 100644 --- a/limereport/translationeditor/translationeditor.cpp +++ b/limereport/translationeditor/translationeditor.cpp @@ -78,8 +78,14 @@ void TranslationEditor::updateUi() ui->lvLanguages->addItem(QLocale::languageToString(language)); } if (!translations->keys().isEmpty()){ - ui->lvLanguages->item(0)->setSelected(true); - activateLanguage(getLanguageByName(ui->lvLanguages->item(0)->text())); + if (ui->lvLanguages->count()!=0){ + ui->lvLanguages->item(0)->setSelected(true); + activateLanguage(getLanguageByName(ui->lvLanguages->item(0)->text())); + } else { + //activateLanguage(QLocale::AnyLanguage); + ui->twPages->clear(); + ui->tbStrings->setRowCount(0); + } } } }