mirror of
https://github.com/python-LimeReport/LimeReport.git
synced 2024-12-24 12:34:39 +03:00
TOC Refactored
This commit is contained in:
parent
9be042819b
commit
3aee2b62d7
@ -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();
|
||||
|
@ -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<QString> bookmarks(){ return m_bookmarks.keys();}
|
||||
QVariant getBookMark(const QString& key);
|
||||
void copyBookmarks(BandDesignIntf* sourceBand);
|
||||
|
||||
int bootomSpace() const;
|
||||
void setBootomSpace(int bootomSpace);
|
||||
signals:
|
||||
|
@ -1639,4 +1639,18 @@ QMap<QString, QString> BaseDesignIntf::getStringForTranslation(){
|
||||
return QMap<QString,QString>();
|
||||
}
|
||||
|
||||
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
|
||||
|
@ -356,6 +356,7 @@ protected:
|
||||
void addChildItems(QList<BaseDesignIntf*>* list);
|
||||
qreal calcAbsolutePosY(qreal currentOffset, BaseDesignIntf* item);
|
||||
qreal calcAbsolutePosX(qreal currentOffset, BaseDesignIntf* item);
|
||||
|
||||
private:
|
||||
void updateSelectionMarker();
|
||||
int resizeDirectionFlags(QPointF position);
|
||||
@ -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<QString> bookmarks(){ return m_bookmarks.keys();}
|
||||
QVariant getBookMark(const QString& key);
|
||||
void copyBookmarks(BookmarkContainerDesignIntf* source);
|
||||
private:
|
||||
QMap<QString,QVariant> m_bookmarks;
|
||||
};
|
||||
|
||||
} //namespace LimeReport
|
||||
|
||||
#endif // LRBASEDESIGNINTF_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);
|
||||
|
@ -1112,21 +1112,21 @@ BandDesignIntf* ReportRender::sliceBand(BandDesignIntf *band, BandDesignIntf* pa
|
||||
}
|
||||
|
||||
void ReportRender::updateTOC(BaseDesignIntf* item, int pageNumber){
|
||||
BandDesignIntf* band = dynamic_cast<BandDesignIntf*>(item);
|
||||
if (band){
|
||||
BookmarkContainerDesignIntf* bookmarkContainer = dynamic_cast<BookmarkContainerDesignIntf*>(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; i<renderedPages.count(); ++i){
|
||||
PageItemDesignIntf::Ptr page = renderedPages.at(i);
|
||||
updateTOC(page.data(), m_pagesRanges.findPageNumber(i));
|
||||
foreach(BaseDesignIntf* item, page->childBaseItems()){
|
||||
updateTOC(item, m_pagesRanges.findPageNumber(i));
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -175,7 +175,7 @@ public:
|
||||
typedef QSharedPointer<QDialog> 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);
|
||||
|
Loading…
Reference in New Issue
Block a user