diff --git a/README.md b/README.md index febeb6d..00a80dd 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,6 @@ -LimeReport v1.3.11 [![Build Status](https://api.travis-ci.org/fralx/LimeReport.svg?branch=master)](https://travis-ci.org/fralx/LimeReport) +LimeReport v1.4.7 [![Build Status](https://api.travis-ci.org/fralx/LimeReport.svg?branch=master)](https://travis-ci.org/fralx/LimeReport) +----------- +Official LimeReport web site [http://limereport.ru](http://limereport.ru) ----------- ##Features @@ -38,6 +40,17 @@ For more samples see a demo ## Change log +###1.4.7 +1. Multipage +2. Dialogs +3. Render events +4. Initscript +5. Memory usage has been reduced +6. Datasource manager has been refactored +7. Report items context menus have been added +8. Editable report +And many others minor fixes and improvements + ###1.3.11 1. LimeReport project structure has been changed 2. Preview widget has been added diff --git a/common.pri b/common.pri index 7d148ef..9f44335 100644 --- a/common.pri +++ b/common.pri @@ -56,7 +56,7 @@ RCC_DIR = $${ARCH_DIR}/$${BUILD_TYPE}/rcc LIMEREPORT_VERSION_MAJOR = 1 LIMEREPORT_VERSION_MINOR = 4 -LIMEREPORT_VERSION_RELEASE = 4 +LIMEREPORT_VERSION_RELEASE = 8 LIMEREPORT_VERSION = '\\"$${LIMEREPORT_VERSION_MAJOR}.$${LIMEREPORT_VERSION_MINOR}.$${LIMEREPORT_VERSION_RELEASE}\\"' DEFINES += LIMEREPORT_VERSION_STR=\"$${LIMEREPORT_VERSION}\" diff --git a/limereport/items/lrtextitem.cpp b/limereport/items/lrtextitem.cpp index b2115bf..de30a44 100644 --- a/limereport/items/lrtextitem.cpp +++ b/limereport/items/lrtextitem.cpp @@ -702,7 +702,7 @@ bool TextItem::isNeedUpdateSize(RenderPass pass) const { Q_UNUSED(pass) - if ((autoHeight() && autoWidth()) || hasFollower()){ + if ((autoHeight() || autoWidth()) || hasFollower()){ initTextSizes(); } diff --git a/limereport/limereport.pri b/limereport/limereport.pri index 7f621e9..605f96a 100644 --- a/limereport/limereport.pri +++ b/limereport/limereport.pri @@ -89,7 +89,8 @@ SOURCES += \ $$REPORT_PATH/lrsimplecrypt.cpp \ $$REPORT_PATH/lraboutdialog.cpp \ $$REPORT_PATH/lrsettingdialog.cpp \ - $$REPORT_PATH/scriptbrowser/lrscriptbrowser.cpp + $$REPORT_PATH/scriptbrowser/lrscriptbrowser.cpp \ + $$REPORT_PATH/lritemscontainerdesignitf.cpp contains(CONFIG, zint){ SOURCES += $$REPORT_PATH/items/lrbarcodeitem.cpp @@ -188,7 +189,8 @@ HEADERS += \ $$REPORT_PATH/lrcallbackdatasourceintf.h \ $$REPORT_PATH/lrsettingdialog.h \ $$REPORT_PATH/lrpreviewreportwidget_p.h \ - $$REPORT_PATH/scriptbrowser/lrscriptbrowser.h + $$REPORT_PATH/scriptbrowser/lrscriptbrowser.h \ + $$REPORT_PATH/lritemscontainerdesignitf.h contains(CONFIG,zint){ HEADERS += $$REPORT_PATH/items/lrbarcodeitem.h diff --git a/limereport/lrbanddesignintf.cpp b/limereport/lrbanddesignintf.cpp index 42342ad..0edc9ab 100644 --- a/limereport/lrbanddesignintf.cpp +++ b/limereport/lrbanddesignintf.cpp @@ -99,33 +99,8 @@ void BandMarker::mousePressEvent(QGraphicsSceneMouseEvent *event) } } -bool Segment::intersect(Segment value) -{ - return ((value.m_end>=m_begin)&&(value.m_end<=m_end)) || - ((value.m_begin>=m_begin)&&(value.m_end>=m_end)) || - ((value.m_begin>=m_begin)&&(value.m_end<=m_end)) || - ((value.m_beginm_end)) ; -} - -qreal Segment::intersectValue(Segment value) -{ - if ((value.m_end>=m_begin)&&(value.m_end<=m_end)){ - return value.m_end-m_begin; - } - if ((value.m_begin>=m_begin)&&(value.m_end>=m_end)){ - return m_end-value.m_begin; - } - if ((value.m_begin>=m_begin)&&(value.m_end<=m_end)){ - return value.m_end-value.m_begin; - } - if ((value.m_beginm_end)){ - return m_end-m_begin; - } - return 0; -} - BandDesignIntf::BandDesignIntf(BandsType bandType, const QString &xmlTypeName, QObject* owner, QGraphicsItem *parent) : - BaseDesignIntf(xmlTypeName, owner,parent), + ItemsContainerDesignInft(xmlTypeName, owner,parent), m_bandType(bandType), m_bandIndex(static_cast(bandType)), m_dataSourceName(""), @@ -595,97 +570,11 @@ void BandDesignIntf::setSplittable(bool value){ } } -bool itemSortContainerLessThen(const PItemSortContainer c1, const PItemSortContainer c2) -{ - VSegment vS1(c1->m_rect),vS2(c2->m_rect); - HSegment hS1(c1->m_rect),hS2(c2->m_rect); - if (vS1.intersectValue(vS2)>hS1.intersectValue(hS2)) - return c1->m_rect.x()m_rect.x(); - else return c1->m_rect.y()m_rect.y(); -} - bool bandIndexLessThen(const BandDesignIntf* b1, const BandDesignIntf* b2) { return b1->bandIndex()bandIndex(); } -void BandDesignIntf::snapshotItemsLayout() -{ - m_bandItems.clear(); - foreach(BaseDesignIntf *childItem,childBaseItems()){ - m_bandItems.append(PItemSortContainer(new ItemSortContainer(childItem))); - } - qSort(m_bandItems.begin(),m_bandItems.end(),itemSortContainerLessThen); -} - -void BandDesignIntf::arrangeSubItems(RenderPass pass, DataSourceManager *dataManager, ArrangeType type) -{ - bool needArrage=(type==Force); - - foreach (PItemSortContainer item, m_bandItems) { - if (item->m_item->isNeedUpdateSize(pass)){ - item->m_item->updateItemSize(dataManager, pass); - needArrage=true; - } - } - - if (needArrage){ - //qSort(m_bandItems.begin(),m_bandItems.end(),itemSortContainerLessThen); - for (int i=0;im_item->collidesWithItem(m_bandItems[j]->m_item))){ - HSegment hS1(m_bandItems[j]->m_rect),hS2(m_bandItems[i]->m_rect); - VSegment vS1(m_bandItems[j]->m_rect),vS2(m_bandItems[i]->m_rect); - if (m_bandItems[i]->m_rect.bottom()m_item->geometry().bottom()){ - if (hS1.intersectValue(hS2)>vS1.intersectValue(vS2)) - m_bandItems[j]->m_item->setY(m_bandItems[i]->m_item->y()+m_bandItems[i]->m_item->height() - +m_bandItems[j]->m_rect.top()-m_bandItems[i]->m_rect.bottom()); - - } - if (m_bandItems[i]->m_rect.right()m_item->geometry().right()){ - if (vS1.intersectValue(vS2)>hS1.intersectValue(hS2)) - m_bandItems[j]->m_item->setX(m_bandItems[i]->m_item->geometry().right()+ - (m_bandItems[j]->m_rect.x()-m_bandItems[i]->m_rect.right())); - } - } - } - } - - if(needArrage||pass==FirstPass){ - int maxBottom = findMaxBottom(); - foreach(BaseDesignIntf* item,childBaseItems()){ - ItemDesignIntf* childItem=dynamic_cast(item); - if (childItem){ - if (childItem->stretchToMaxHeight()) - childItem->setHeight(maxBottom-childItem->geometry().top()); - } - } - } - -} - -qreal BandDesignIntf::findMaxBottom() -{ - qreal maxBottom=0; - foreach(QGraphicsItem* item,childItems()){ - BaseDesignIntf* subItem = dynamic_cast(item); - if(subItem) - if ( subItem->isVisible() && (subItem->geometry().bottom()>maxBottom) ) - maxBottom=subItem->geometry().bottom(); - } - return maxBottom; -} - -qreal BandDesignIntf::findMaxHeight(){ - qreal maxHeight=0; - foreach(QGraphicsItem* item,childItems()){ - BaseDesignIntf* subItem = dynamic_cast(item); - if(subItem) - if (subItem->geometry().height()>maxHeight) maxHeight=subItem->geometry().height(); - } - return maxHeight; -} - void BandDesignIntf::trimToMaxHeight(int maxHeight) { foreach(BaseDesignIntf* item,childBaseItems()){ diff --git a/limereport/lrbanddesignintf.h b/limereport/lrbanddesignintf.h index c440aab..c219c04 100644 --- a/limereport/lrbanddesignintf.h +++ b/limereport/lrbanddesignintf.h @@ -31,6 +31,7 @@ #define LRBANDDESIGNINTF_H #include "lrbasedesignintf.h" #include "lrdatasourcemanager.h" +#include "lritemscontainerdesignitf.h" #include namespace LimeReport { @@ -81,10 +82,7 @@ private: BandDesignIntf* m_band; }; -struct ItemSortContainer; -typedef QSharedPointer< ItemSortContainer > PItemSortContainer; - -class BandDesignIntf : public BaseDesignIntf +class BandDesignIntf : public ItemsContainerDesignInft { Q_OBJECT Q_PROPERTY(bool autoHeight READ autoHeight WRITE setAutoHeight ) @@ -227,10 +225,6 @@ public: signals: void bandRendered(BandDesignIntf* band); protected: - void snapshotItemsLayout(); - void arrangeSubItems(RenderPass pass, DataSourceManager *dataManager, ArrangeType type = AsNeeded); - qreal findMaxBottom(); - qreal findMaxHeight(); void trimToMaxHeight(int maxHeight); void setBandTypeText(const QString& value); QString bandTypeText(){return m_bandTypeText;} @@ -292,37 +286,7 @@ public: DataBandDesignIntf(BandsType bandType, QString xmlTypeName, QObject* owner = 0, QGraphicsItem* parent=0); }; -class Segment{ -public: - Segment(qreal segmentStart,qreal segmentEnd):m_begin(segmentStart),m_end(segmentEnd){} - bool intersect(Segment value); - qreal intersectValue(Segment value); -private: - qreal m_begin; - qreal m_end; -}; - -class VSegment : public Segment{ -public: - VSegment(QRectF rect):Segment(rect.top(),rect.bottom()){} -}; - -struct HSegment :public Segment{ -public: - HSegment(QRectF rect):Segment(rect.left(),rect.right()){} -}; - -struct ItemSortContainer { - QRectF m_rect; - BaseDesignIntf * m_item; - ItemSortContainer(BaseDesignIntf *item){ - m_item=item; - m_rect=item->geometry(); - } -}; - -bool itemSortContainerLessThen(const PItemSortContainer c1, const PItemSortContainer c2); bool bandIndexLessThen(const BandDesignIntf* b1, const BandDesignIntf* b2); -} +} // namespace LimeReport #endif // LRBANDDESIGNINTF_H diff --git a/limereport/lrbasedesignintf.cpp b/limereport/lrbasedesignintf.cpp index 1e02ecf..ddc8db9 100644 --- a/limereport/lrbasedesignintf.cpp +++ b/limereport/lrbasedesignintf.cpp @@ -39,7 +39,6 @@ #include "serializators/lrxmlreader.h" #include - #include #include #include @@ -1537,8 +1536,7 @@ BaseDesignIntf *Marker::object() const return m_object; } - -} +} //namespace LimeReport diff --git a/limereport/lritemscontainerdesignitf.cpp b/limereport/lritemscontainerdesignitf.cpp new file mode 100644 index 0000000..dcad6ee --- /dev/null +++ b/limereport/lritemscontainerdesignitf.cpp @@ -0,0 +1,117 @@ +#include "lritemscontainerdesignitf.h" +#include "lritemdesignintf.h" + +namespace LimeReport { + +bool Segment::intersect(Segment value) +{ + return ((value.m_end>=m_begin)&&(value.m_end<=m_end)) || + ((value.m_begin>=m_begin)&&(value.m_end>=m_end)) || + ((value.m_begin>=m_begin)&&(value.m_end<=m_end)) || + ((value.m_beginm_end)) ; +} + +qreal Segment::intersectValue(Segment value) +{ + if ((value.m_end>=m_begin)&&(value.m_end<=m_end)){ + return value.m_end-m_begin; + } + if ((value.m_begin>=m_begin)&&(value.m_end>=m_end)){ + return m_end-value.m_begin; + } + if ((value.m_begin>=m_begin)&&(value.m_end<=m_end)){ + return value.m_end-value.m_begin; + } + if ((value.m_beginm_end)){ + return m_end-m_begin; + } + return 0; +} + +bool itemSortContainerLessThen(const PItemSortContainer c1, const PItemSortContainer c2) +{ + VSegment vS1(c1->m_rect),vS2(c2->m_rect); + HSegment hS1(c1->m_rect),hS2(c2->m_rect); + if (vS1.intersectValue(vS2)>hS1.intersectValue(hS2)) + return c1->m_rect.x()m_rect.x(); + else return c1->m_rect.y()m_rect.y(); +} + +void ItemsContainerDesignInft::snapshotItemsLayout() +{ + m_containerItems.clear(); + foreach(BaseDesignIntf *childItem,childBaseItems()){ + m_containerItems.append(PItemSortContainer(new ItemSortContainer(childItem))); + } + qSort(m_containerItems.begin(),m_containerItems.end(),itemSortContainerLessThen); +} + +void ItemsContainerDesignInft::arrangeSubItems(RenderPass pass, DataSourceManager *dataManager, ArrangeType type) +{ + bool needArrage=(type==Force); + + foreach (PItemSortContainer item, m_containerItems) { + if (item->m_item->isNeedUpdateSize(pass)){ + item->m_item->updateItemSize(dataManager, pass); + needArrage=true; + } + } + + if (needArrage){ + for (int i=0;im_item->collidesWithItem(m_containerItems[j]->m_item))){ + HSegment hS1(m_containerItems[j]->m_rect),hS2(m_containerItems[i]->m_rect); + VSegment vS1(m_containerItems[j]->m_rect),vS2(m_containerItems[i]->m_rect); + if (m_containerItems[i]->m_rect.bottom()m_item->geometry().bottom()){ + if (hS1.intersectValue(hS2)>vS1.intersectValue(vS2)) + m_containerItems[j]->m_item->setY(m_containerItems[i]->m_item->y()+m_containerItems[i]->m_item->height() + +m_containerItems[j]->m_rect.top()-m_containerItems[i]->m_rect.bottom()); + + } + if (m_containerItems[i]->m_rect.right()m_item->geometry().right()){ + if (vS1.intersectValue(vS2)>hS1.intersectValue(hS2)) + m_containerItems[j]->m_item->setX(m_containerItems[i]->m_item->geometry().right()+ + (m_containerItems[j]->m_rect.x()-m_containerItems[i]->m_rect.right())); + } + } + } + } + } + + if (needArrage||pass==FirstPass){ + int maxBottom = findMaxBottom(); + foreach(BaseDesignIntf* item,childBaseItems()){ + ItemDesignIntf* childItem=dynamic_cast(item); + if (childItem){ + if (childItem->stretchToMaxHeight()) + childItem->setHeight(maxBottom-childItem->geometry().top()); + } + } + } +} + +qreal ItemsContainerDesignInft::findMaxBottom() +{ + qreal maxBottom=0; + foreach(QGraphicsItem* item,childItems()){ + BaseDesignIntf* subItem = dynamic_cast(item); + if(subItem) + if ( subItem->isVisible() && (subItem->geometry().bottom()>maxBottom) ) + maxBottom=subItem->geometry().bottom(); + } + return maxBottom; +} + +qreal ItemsContainerDesignInft::findMaxHeight() +{ + qreal maxHeight=0; + foreach(QGraphicsItem* item,childItems()){ + BaseDesignIntf* subItem = dynamic_cast(item); + if(subItem) + if (subItem->geometry().height()>maxHeight) maxHeight=subItem->geometry().height(); + } + return maxHeight; +} + +} // namespace LimeReport diff --git a/limereport/lritemscontainerdesignitf.h b/limereport/lritemscontainerdesignitf.h new file mode 100644 index 0000000..86b2509 --- /dev/null +++ b/limereport/lritemscontainerdesignitf.h @@ -0,0 +1,56 @@ +#ifndef ITEMSCONTAINERDESIGNITF_H +#define ITEMSCONTAINERDESIGNITF_H + +#include "lrbasedesignintf.h" + +namespace LimeReport{ + +class Segment{ +public: + Segment(qreal segmentStart,qreal segmentEnd):m_begin(segmentStart),m_end(segmentEnd){} + bool intersect(Segment value); + qreal intersectValue(Segment value); +private: + qreal m_begin; + qreal m_end; +}; + +class VSegment : public Segment{ +public: + VSegment(QRectF rect):Segment(rect.top(),rect.bottom()){} +}; + +struct HSegment :public Segment{ +public: + HSegment(QRectF rect):Segment(rect.left(),rect.right()){} +}; + +struct ItemSortContainer { + QRectF m_rect; + BaseDesignIntf * m_item; + ItemSortContainer(BaseDesignIntf *item){ + m_item=item; + m_rect=item->geometry(); + } +}; + +typedef QSharedPointer< ItemSortContainer > PItemSortContainer; +bool itemSortContainerLessThen(const PItemSortContainer c1, const PItemSortContainer c2); + +class ItemsContainerDesignInft : public BaseDesignIntf{ +public: + ItemsContainerDesignInft(const QString& xmlTypeName, QObject* owner = 0, QGraphicsItem* parent=0): + BaseDesignIntf(xmlTypeName, owner, parent){} +protected: + void snapshotItemsLayout(); + void arrangeSubItems(RenderPass pass, DataSourceManager *dataManager, ArrangeType type = AsNeeded); + qreal findMaxBottom(); + qreal findMaxHeight(); +private: + QVector m_containerItems; + +}; + +} // namespace LimeReport + +#endif // ITEMSCONTAINERDESIGNITF_H diff --git a/limereport/lrpageitemdesignintf.cpp b/limereport/lrpageitemdesignintf.cpp index d943a13..150df06 100644 --- a/limereport/lrpageitemdesignintf.cpp +++ b/limereport/lrpageitemdesignintf.cpp @@ -46,24 +46,26 @@ bool bandSortBandLessThenByIndex(const BandDesignIntf *c1, const BandDesignIntf } PageItemDesignIntf::PageItemDesignIntf(QObject *owner, QGraphicsItem *parent) : - BaseDesignIntf("PageItem",owner,parent), + ItemsContainerDesignInft("PageItem",owner,parent), m_topMargin(0), m_bottomMargin(0), m_leftMargin(0), m_rightMargin(0), m_pageOrientaion(Portrait), m_pageSize(A4), m_sizeChainging(false), m_fullPage(false), m_oldPrintMode(false), m_resetPageNumber(false) { setFixedPos(true); setPossibleResizeDirectionFlags(Fixed); + setFlag(QGraphicsItem::ItemClipsChildrenToShape); initPageSize(m_pageSize); } PageItemDesignIntf::PageItemDesignIntf(const PageSize pageSize, const QRectF &rect, QObject *owner, QGraphicsItem *parent) : - BaseDesignIntf("PageItem",owner,parent), + ItemsContainerDesignInft("PageItem",owner,parent), m_topMargin(0), m_bottomMargin(0), m_leftMargin(0), m_rightMargin(0), m_pageOrientaion(Portrait), m_pageSize(pageSize), m_sizeChainging(false), m_fullPage(false), m_oldPrintMode(false), m_resetPageNumber(false) { setFixedPos(true); setPossibleResizeDirectionFlags(Fixed); + setFlag(QGraphicsItem::ItemClipsChildrenToShape); initPageSize(rect.size()); } @@ -316,6 +318,12 @@ void PageItemDesignIntf::setResetPageNumber(bool resetPageNumber) } } +void PageItemDesignIntf::updateSubItemsSize(RenderPass pass, DataSourceManager *dataManager) +{ + snapshotItemsLayout(); + arrangeSubItems(pass, dataManager); +} + bool PageItemDesignIntf::oldPrintMode() const { return m_oldPrintMode; diff --git a/limereport/lrpageitemdesignintf.h b/limereport/lrpageitemdesignintf.h index 2c1fb84..ef9b06d 100644 --- a/limereport/lrpageitemdesignintf.h +++ b/limereport/lrpageitemdesignintf.h @@ -31,13 +31,14 @@ #define LRPAGEITEM_H #include "lrbasedesignintf.h" #include "lrbanddesignintf.h" +#include "lritemscontainerdesignitf.h" #include #include namespace LimeReport{ class ReportRender; -class PageItemDesignIntf : public LimeReport::BaseDesignIntf +class PageItemDesignIntf : public LimeReport::ItemsContainerDesignInft { Q_OBJECT Q_ENUMS(Orientation) @@ -115,6 +116,7 @@ public: bool canContainChildren(){ return true;} bool resetPageNumber() const; void setResetPageNumber(bool resetPageNumber); + void updateSubItemsSize(RenderPass pass, DataSourceManager *dataManager); protected slots: void bandDeleted(QObject* band); diff --git a/limereport/lrreportrender.cpp b/limereport/lrreportrender.cpp index 99d5cf3..46446bb 100644 --- a/limereport/lrreportrender.cpp +++ b/limereport/lrreportrender.cpp @@ -661,9 +661,10 @@ void ReportRender::renderPageItems(PageItemDesignIntf* patternPage) } } m_renderPageItem->restoreLinks(); - foreach(BaseDesignIntf* item, pageItems){ - item->updateItemSize(m_datasources); - } + m_renderPageItem->updateSubItemsSize(FirstPass,m_datasources); +// foreach(BaseDesignIntf* item, pageItems){ +// item->updateItemSize(m_datasources); +// } } qreal ReportRender::calcPageFooterHeight(PageItemDesignIntf *patternPage)