diff --git a/limereport/lrbanddesignintf.cpp b/limereport/lrbanddesignintf.cpp index a0a73fe..c77f86c 100644 --- a/limereport/lrbanddesignintf.cpp +++ b/limereport/lrbanddesignintf.cpp @@ -184,13 +184,6 @@ QString BandDesignIntf::translateBandName(const BaseDesignIntf* item) const{ } } -void BandDesignIntf::copyBookmarks(BandDesignIntf* sourceBand) -{ - foreach(QString key, sourceBand->bookmarks()){ - addBookmark(key,sourceBand->getBookMark(key)); - } -} - void BandDesignIntf::setBackgroundModeProperty(BaseDesignIntf::BGMode value) { if (value!=backgroundMode()){ @@ -843,12 +836,6 @@ qreal BandDesignIntf::bottomSpace() const return height()-findMaxBottom(); } -QVariant BandDesignIntf::getBookMark(const QString& key){ - if (m_bookmarks.contains(key)) - return m_bookmarks.value(key); - else return QVariant(); -} - void BandDesignIntf::slotPropertyObjectNameChanged(const QString &, const QString& newName) { update(); diff --git a/limereport/lrbanddesignintf.h b/limereport/lrbanddesignintf.h index dcdeac8..16009a5 100644 --- a/limereport/lrbanddesignintf.h +++ b/limereport/lrbanddesignintf.h @@ -248,12 +248,6 @@ public: qreal bottomSpace() const; void setBackgroundModeProperty(BGMode value); void setBackgroundOpacity(int value); - - void addBookmark(const QString& key, const QVariant& value){ m_bookmarks.insert(key, value);} - QList bookmarks(){ return m_bookmarks.keys();} - QVariant getBookMark(const QString& key); - void copyBookmarks(BandDesignIntf* sourceBand); - int bootomSpace() const; void setBootomSpace(int bootomSpace); signals: diff --git a/limereport/lrbasedesignintf.cpp b/limereport/lrbasedesignintf.cpp index cb8cdac..0cb6c09 100644 --- a/limereport/lrbasedesignintf.cpp +++ b/limereport/lrbasedesignintf.cpp @@ -1639,4 +1639,18 @@ QMap BaseDesignIntf::getStringForTranslation(){ return QMap(); } +QVariant BookmarkContainerDesignIntf::getBookMark(const QString& key) +{ + if (m_bookmarks.contains(key)) + return m_bookmarks.value(key); + else return QVariant(); +} + +void BookmarkContainerDesignIntf::copyBookmarks(BookmarkContainerDesignIntf* source) +{ + foreach(QString key, source->bookmarks()){ + addBookmark(key,source->getBookMark(key)); + } +} + } //namespace LimeReport diff --git a/limereport/lrbasedesignintf.h b/limereport/lrbasedesignintf.h index 1c00f0e..9bfb288 100644 --- a/limereport/lrbasedesignintf.h +++ b/limereport/lrbasedesignintf.h @@ -356,6 +356,7 @@ protected: void addChildItems(QList* list); qreal calcAbsolutePosY(qreal currentOffset, BaseDesignIntf* item); qreal calcAbsolutePosX(qreal currentOffset, BaseDesignIntf* item); + private: void updateSelectionMarker(); int resizeDirectionFlags(QPointF position); @@ -414,7 +415,7 @@ private: BaseDesignIntf* m_patternItem; bool m_fillInSecondPass; bool m_watermark; - + signals: void geometryChanged(QObject* object, QRectF newGeometry, QRectF oldGeometry); void posChanging(QObject* object, QPointF newPos, QPointF oldPos); @@ -434,6 +435,19 @@ signals: void afterRender(); }; +class BookmarkContainerDesignIntf: public BaseDesignIntf{ + Q_OBJECT +public: + BookmarkContainerDesignIntf(const QString& storageTypeName, QObject* owner = 0, QGraphicsItem* parent = 0) + :BaseDesignIntf(storageTypeName, owner, parent){} + void addBookmark(const QString& key, const QVariant& value){ m_bookmarks.insert(key, value);} + QList bookmarks(){ return m_bookmarks.keys();} + QVariant getBookMark(const QString& key); + void copyBookmarks(BookmarkContainerDesignIntf* source); +private: + QMap m_bookmarks; +}; + } //namespace LimeReport #endif // LRBASEDESIGNINTF_H diff --git a/limereport/lritemscontainerdesignitf.h b/limereport/lritemscontainerdesignitf.h index ff5c2e2..b9aa421 100644 --- a/limereport/lritemscontainerdesignitf.h +++ b/limereport/lritemscontainerdesignitf.h @@ -37,10 +37,11 @@ struct ItemSortContainer { typedef QSharedPointer< ItemSortContainer > PItemSortContainer; bool itemSortContainerLessThen(const PItemSortContainer c1, const PItemSortContainer c2); -class ItemsContainerDesignInft : public BaseDesignIntf{ +class ItemsContainerDesignInft : public BookmarkContainerDesignIntf{ + Q_OBJECT public: ItemsContainerDesignInft(const QString& xmlTypeName, QObject* owner = 0, QGraphicsItem* parent=0): - BaseDesignIntf(xmlTypeName, owner, parent){} + BookmarkContainerDesignIntf(xmlTypeName, owner, parent){} protected: void snapshotItemsLayout(); void arrangeSubItems(RenderPass pass, DataSourceManager *dataManager, ArrangeType type = AsNeeded); diff --git a/limereport/lrreportrender.cpp b/limereport/lrreportrender.cpp index 6f01c71..7c3ed0a 100644 --- a/limereport/lrreportrender.cpp +++ b/limereport/lrreportrender.cpp @@ -1112,21 +1112,21 @@ BandDesignIntf* ReportRender::sliceBand(BandDesignIntf *band, BandDesignIntf* pa } void ReportRender::updateTOC(BaseDesignIntf* item, int pageNumber){ - BandDesignIntf* band = dynamic_cast(item); - if (band){ + BookmarkContainerDesignIntf* bookmarkContainer = dynamic_cast(item); + if (bookmarkContainer){ TableOfContents* toc = m_scriptEngineContext->tableOfContents(); - foreach (QString key, band->bookmarks()){ - toc->setItem(key, band->getBookMark(key).toString(), pageNumber); + foreach (QString key, bookmarkContainer->bookmarks()){ + toc->setItem(key, bookmarkContainer->getBookMark(key).toString(), pageNumber); } } } void ReportRender::secondRenderPass(ReportPages renderedPages) { - if (!m_scriptEngineContext->tableOfContents()->isEmpty()){ for(int i=0; ichildBaseItems()){ updateTOC(item, m_pagesRanges.findPageNumber(i)); } diff --git a/limereport/lrscriptenginemanager.cpp b/limereport/lrscriptenginemanager.cpp index 9079b71..18f113b 100644 --- a/limereport/lrscriptenginemanager.cpp +++ b/limereport/lrscriptenginemanager.cpp @@ -553,6 +553,9 @@ void ScriptEngineManager::addTableOfContentsItem(const QString& uniqKey, const Q m_context->tableOfContents()->setItem(uniqKey, content, 0, indent); if (currentBand) currentBand->addBookmark(uniqKey, content); + else if (m_context->getCurrentPage()) { + m_context->getCurrentPage()->addBookmark(uniqKey, content); + } } } @@ -1236,6 +1239,7 @@ PageItemDesignIntf* ScriptEngineContext::getCurrentPage() const void ScriptEngineContext::setCurrentPage(PageItemDesignIntf* currentPage) { m_currentPage = currentPage; + m_currentBand = 0; } BandDesignIntf* ScriptEngineContext::getCurrentBand() const diff --git a/limereport/lrscriptenginemanager.h b/limereport/lrscriptenginemanager.h index 0295055..bb60dee 100644 --- a/limereport/lrscriptenginemanager.h +++ b/limereport/lrscriptenginemanager.h @@ -175,7 +175,7 @@ public: typedef QSharedPointer DialogPtr; #endif explicit ScriptEngineContext(QObject* parent=0): - QObject(parent), + QObject(parent), m_currentBand(0), m_currentPage(0), m_tableOfContents(new TableOfContents(this)), m_hasChanges(false) {} #ifdef HAVE_UI_LOADER void addDialog(const QString& name, const QByteArray& description);