Merge branch 'develop' into feature/Translate

This commit is contained in:
Arin Alexander 2017-08-15 20:20:28 +03:00
commit c085944ac9
9 changed files with 101 additions and 32 deletions

View File

@ -69,7 +69,7 @@ RCC_DIR = $${ARCH_DIR}/$${BUILD_TYPE}/rcc
LIMEREPORT_VERSION_MAJOR = 1 LIMEREPORT_VERSION_MAJOR = 1
LIMEREPORT_VERSION_MINOR = 4 LIMEREPORT_VERSION_MINOR = 4
LIMEREPORT_VERSION_RELEASE = 34 LIMEREPORT_VERSION_RELEASE = 38
LIMEREPORT_VERSION = '\\"$${LIMEREPORT_VERSION_MAJOR}.$${LIMEREPORT_VERSION_MINOR}.$${LIMEREPORT_VERSION_RELEASE}\\"' LIMEREPORT_VERSION = '\\"$${LIMEREPORT_VERSION_MAJOR}.$${LIMEREPORT_VERSION_MINOR}.$${LIMEREPORT_VERSION_RELEASE}\\"'
DEFINES += LIMEREPORT_VERSION_STR=\"$${LIMEREPORT_VERSION}\" DEFINES += LIMEREPORT_VERSION_STR=\"$${LIMEREPORT_VERSION}\"

View File

@ -74,6 +74,7 @@ public:
bool isEmpty() const; bool isEmpty() const;
LayoutType layoutType() const; LayoutType layoutType() const;
void setLayoutType(const LayoutType &layoutType); void setLayoutType(const LayoutType &layoutType);
bool isSplittable() const { return true;}
protected: protected:
void collectionLoadFinished(const QString &collectionName); void collectionLoadFinished(const QString &collectionName);
void objectLoadFinished(); void objectLoadFinished();

View File

@ -117,16 +117,16 @@ void TextItem::processPopUpAction(QAction *action)
this->showEditorDialog(); this->showEditorDialog();
} }
if (action->text().compare(tr("Auto height")) == 0){ if (action->text().compare(tr("Auto height")) == 0){
setProperty("autoHeight",action->isChecked()); page()->setPropertyToSelectedItems("autoHeight",action->isChecked());
} }
if (action->text().compare(tr("Allow HTML")) == 0){ if (action->text().compare(tr("Allow HTML")) == 0){
setProperty("allowHTML",action->isChecked()); page()->setPropertyToSelectedItems("allowHTML",action->isChecked());
} }
if (action->text().compare(tr("Allow HTML in fields")) == 0){ if (action->text().compare(tr("Allow HTML in fields")) == 0){
setProperty("allowHTMLInFields",action->isChecked()); page()->setPropertyToSelectedItems("allowHTMLInFields",action->isChecked());
} }
if (action->text().compare(tr("Stretch to max height")) == 0){ if (action->text().compare(tr("Stretch to max height")) == 0){
setProperty("stretchToMaxHeight",action->isChecked()); page()->setPropertyToSelectedItems("stretchToMaxHeight",action->isChecked());
} }
if (action->text().compare(tr("Transparent")) == 0){ if (action->text().compare(tr("Transparent")) == 0){
if (action->isChecked()){ if (action->isChecked()){
@ -794,7 +794,7 @@ QString TextItem::getTextPart(int height, int skipHeight){
int textPos = 0; int textPos = 0;
TextPtr text = textDocument(); TextPtr text = textDocument();
text->documentLayout();
QTextBlock curBlock = text->begin(); QTextBlock curBlock = text->begin();
QString resultText = ""; QString resultText = "";

View File

@ -123,7 +123,8 @@ BandDesignIntf::BandDesignIntf(BandsType bandType, const QString &xmlTypeName, Q
m_startFromNewPage(false), m_startFromNewPage(false),
m_printAlways(false), m_printAlways(false),
m_repeatOnEachRow(false), m_repeatOnEachRow(false),
m_useAlternateBackgroundColor(false) m_useAlternateBackgroundColor(false),
m_bottomSpace()
{ {
setPossibleResizeDirectionFlags(ResizeBottom); setPossibleResizeDirectionFlags(ResizeBottom);
setPossibleMoveFlags(TopBotom); setPossibleMoveFlags(TopBotom);
@ -292,6 +293,14 @@ void BandDesignIntf::setDataSourceName(const QString &datasource){
m_dataSourceName=datasource; m_dataSourceName=datasource;
} }
void BandDesignIntf::setKeepBottomSpaceOption(bool value){
if (m_keepBottomSpace!=value){
m_keepBottomSpace=value;
if (!isLoading())
notify("keepBottomSpace",!value,value);
}
}
void BandDesignIntf::addChildBand(BandDesignIntf *band) void BandDesignIntf::addChildBand(BandDesignIntf *band)
{ {
m_childBands.append(band); m_childBands.append(band);
@ -466,13 +475,25 @@ void BandDesignIntf::preparePopUpMenu(QMenu &menu)
} }
menu.addSeparator(); menu.addSeparator();
QAction* autoHeightAction = menu.addAction(tr("Auto height")); QAction* currAction = menu.addAction(tr("Auto height"));
autoHeightAction->setCheckable(true); currAction->setCheckable(true);
autoHeightAction->setChecked(autoHeight()); currAction->setChecked(autoHeight());
QAction* autoSplittableAction = menu.addAction(tr("Splittable")); currAction = menu.addAction(tr("Splittable"));
autoSplittableAction->setCheckable(true); currAction->setCheckable(true);
autoSplittableAction->setChecked(isSplittable()); currAction->setChecked(isSplittable());
currAction = menu.addAction(tr("Keep bottom space"));
currAction->setCheckable(true);
currAction->setChecked(keepBottomSpaceOption());
currAction = menu.addAction(tr("Start from new page"));
currAction->setCheckable(true);
currAction->setChecked(startFromNewPage());
currAction = menu.addAction(tr("Start new page"));
currAction->setCheckable(true);
currAction->setChecked(startNewPage());
} }
void BandDesignIntf::processPopUpAction(QAction *action) void BandDesignIntf::processPopUpAction(QAction *action)
@ -483,6 +504,15 @@ void BandDesignIntf::processPopUpAction(QAction *action)
if (action->text().compare(tr("Splittable")) == 0){ if (action->text().compare(tr("Splittable")) == 0){
setProperty("splittable",action->isChecked()); setProperty("splittable",action->isChecked());
} }
if (action->text().compare(tr("Keep bottom space")) == 0){
setProperty("keepBottomSpace",action->isChecked());
}
if (action->text().compare(tr("Start new page")) == 0){
setProperty("startNewPage",action->isChecked());
}
if (action->text().compare(tr("Start from new page")) == 0){
setProperty("startFromNewPage",action->isChecked());
}
} }
void BandDesignIntf::recalcItems(DataSourceManager* dataManager) void BandDesignIntf::recalcItems(DataSourceManager* dataManager)
@ -502,7 +532,8 @@ BaseDesignIntf* BandDesignIntf::cloneUpperPart(int height, QObject *owner, QGrap
{ {
int maxBottom = 0; int maxBottom = 0;
BandDesignIntf* upperPart = dynamic_cast<BandDesignIntf*>(createSameTypeItem(owner,parent)); BandDesignIntf* upperPart = dynamic_cast<BandDesignIntf*>(createSameTypeItem(owner,parent));
BaseDesignIntf* upperItem; upperPart->m_bottomSpace = this->bottomSpace();
BaseDesignIntf* upperItem = 0;
upperPart->initFromItem(this); upperPart->initFromItem(this);
@ -548,6 +579,7 @@ bool itemLessThen(QGraphicsItem* i1, QGraphicsItem* i2){
BaseDesignIntf *BandDesignIntf::cloneBottomPart(int height, QObject *owner, QGraphicsItem *parent) BaseDesignIntf *BandDesignIntf::cloneBottomPart(int height, QObject *owner, QGraphicsItem *parent)
{ {
BandDesignIntf* bottomPart = dynamic_cast<BandDesignIntf*>(createSameTypeItem(owner,parent)); BandDesignIntf* bottomPart = dynamic_cast<BandDesignIntf*>(createSameTypeItem(owner,parent));
bottomPart->m_bottomSpace = this->bottomSpace();
bottomPart->initFromItem(this); bottomPart->initFromItem(this);
QList<QGraphicsItem*> bandItems; QList<QGraphicsItem*> bandItems;
@ -564,17 +596,16 @@ BaseDesignIntf *BandDesignIntf::cloneBottomPart(int height, QObject *owner, QGra
} }
else if ((item->geometry().top()<height) && (item->geometry().bottom()>height)){ else if ((item->geometry().top()<height) && (item->geometry().bottom()>height)){
int sliceHeight = height-item->geometry().top(); int sliceHeight = height-item->geometry().top();
if (item->canBeSplitted(sliceHeight)) { if (item->isSplittable() && item->canBeSplitted(sliceHeight)) {
BaseDesignIntf* tmpItem=item->cloneBottomPart(sliceHeight,bottomPart,bottomPart); BaseDesignIntf* tmpItem=item->cloneBottomPart(sliceHeight,bottomPart,bottomPart);
tmpItem->setPos(tmpItem->pos().x(),0); tmpItem->setPos(tmpItem->pos().x(),0);
if (tmpItem->pos().y()<0) tmpItem->setPos(tmpItem->pos().x(),0); if (tmpItem->pos().y()<0) tmpItem->setPos(tmpItem->pos().x(),0);
qreal sizeOffset = (m_slicedItems.value(tmpItem->objectName())->height()+tmpItem->height()) - item->height(); BaseDesignIntf* slicedItem = m_slicedItems.value(tmpItem->objectName());
qreal bottomOffset = (height - m_slicedItems.value(tmpItem->objectName())->pos().y())-m_slicedItems.value(tmpItem->objectName())->height(); if (slicedItem){
qreal sizeOffset = (slicedItem->height()+tmpItem->height()) - item->height();
qreal bottomOffset = (height - slicedItem->pos().y())-m_slicedItems.value(tmpItem->objectName())->height();
moveItemsDown(item->pos().y()+item->height(), sizeOffset + bottomOffset); moveItemsDown(item->pos().y()+item->height(), sizeOffset + bottomOffset);
} }
else if (item->isSplittable()){
BaseDesignIntf* tmpItem = item->cloneItem(item->itemMode(),bottomPart,bottomPart);
tmpItem->setPos(tmpItem->pos().x(),0);
} else { } else {
if ((item->geometry().bottom()-height)>height){ if ((item->geometry().bottom()-height)>height){
BaseDesignIntf* tmpItem = item->cloneItem(item->itemMode(),bottomPart,bottomPart); BaseDesignIntf* tmpItem = item->cloneItem(item->itemMode(),bottomPart,bottomPart);
@ -765,6 +796,11 @@ void BandDesignIntf::setAlternateBackgroundColor(const QColor &alternateBackgrou
} }
} }
qreal BandDesignIntf::bottomSpace() const
{
return m_bottomSpace.isValid() ? m_bottomSpace.value() : height()-findMaxBottom();
}
void BandDesignIntf::slotPropertyObjectNameChanged(const QString &, const QString& newName) void BandDesignIntf::slotPropertyObjectNameChanged(const QString &, const QString& newName)
{ {
update(); update();
@ -799,7 +835,11 @@ bool BandDesignIntf::startFromNewPage() const
void BandDesignIntf::setStartFromNewPage(bool startWithNewPage) void BandDesignIntf::setStartFromNewPage(bool startWithNewPage)
{ {
if (m_startFromNewPage != startWithNewPage){
m_startFromNewPage = startWithNewPage; m_startFromNewPage = startWithNewPage;
if (!isLoading())
notify("startFromNewPage", !startWithNewPage, startWithNewPage);
}
} }
bool BandDesignIntf::startNewPage() const bool BandDesignIntf::startNewPage() const
@ -809,7 +849,11 @@ bool BandDesignIntf::startNewPage() const
void BandDesignIntf::setStartNewPage(bool startNewPage) void BandDesignIntf::setStartNewPage(bool startNewPage)
{ {
if (m_startNewPage != startNewPage){
m_startNewPage = startNewPage; m_startNewPage = startNewPage;
if (!isLoading())
notify("startNewPage", !startNewPage, startNewPage);
}
} }
void BandDesignIntf::setAutoHeight(bool value){ void BandDesignIntf::setAutoHeight(bool value){
@ -906,7 +950,7 @@ void BandDesignIntf::setKeepFooterTogether(bool value)
void BandDesignIntf::updateItemSize(DataSourceManager* dataManager, RenderPass pass, int maxHeight) void BandDesignIntf::updateItemSize(DataSourceManager* dataManager, RenderPass pass, int maxHeight)
{ {
qreal spaceBorder=0; qreal spaceBorder=0;
if (keepBottomSpaceOption()) spaceBorder=height()-findMaxBottom(); if (keepBottomSpaceOption()) spaceBorder = bottomSpace();
if (borderLines()!=0){ if (borderLines()!=0){
spaceBorder += borderLineSize(); spaceBorder += borderLineSize();
} }

View File

@ -82,6 +82,18 @@ private:
BandDesignIntf* m_band; BandDesignIntf* m_band;
}; };
class InitializedValue{
public:
InitializedValue(): m_value(-1), m_isInitialized(false){}
InitializedValue(qreal value): m_value(value), m_isInitialized(true){}
qreal value() const { return m_value;}
void setValue( qreal value){ m_value = value; m_isInitialized = true;}
bool isValid() const{ return m_isInitialized;}
private:
qreal m_value;
bool m_isInitialized;
};
class BandDesignIntf : public ItemsContainerDesignInft class BandDesignIntf : public ItemsContainerDesignInft
{ {
Q_OBJECT Q_OBJECT
@ -140,7 +152,7 @@ public:
QString datasourceName(); QString datasourceName();
void setDataSourceName(const QString& datasourceName); void setDataSourceName(const QString& datasourceName);
void setKeepBottomSpaceOption(bool value){m_keepBottomSpace=value;} void setKeepBottomSpaceOption(bool value);
bool keepBottomSpaceOption() const {return m_keepBottomSpace;} bool keepBottomSpaceOption() const {return m_keepBottomSpace;}
void addChildBand(BandDesignIntf* band); void addChildBand(BandDesignIntf* band);
@ -225,6 +237,7 @@ public:
bool useAlternateBackgroundColor() const; bool useAlternateBackgroundColor() const;
void setUseAlternateBackgroundColor(bool useAlternateBackgroundColor); void setUseAlternateBackgroundColor(bool useAlternateBackgroundColor);
void replaceGroupsFunction(BandDesignIntf *band); void replaceGroupsFunction(BandDesignIntf *band);
qreal bottomSpace() const;
signals: signals:
void bandRendered(BandDesignIntf* band); void bandRendered(BandDesignIntf* band);
protected: protected:
@ -281,6 +294,7 @@ private:
QMap<QString,BaseDesignIntf*> m_slicedItems; QMap<QString,BaseDesignIntf*> m_slicedItems;
QColor m_alternateBackgroundColor; QColor m_alternateBackgroundColor;
bool m_useAlternateBackgroundColor; bool m_useAlternateBackgroundColor;
InitializedValue m_bottomSpace;
}; };
class DataBandDesignIntf : public BandDesignIntf{ class DataBandDesignIntf : public BandDesignIntf{

View File

@ -91,7 +91,7 @@ void ItemsContainerDesignInft::arrangeSubItems(RenderPass pass, DataSourceManage
} }
} }
qreal ItemsContainerDesignInft::findMaxBottom() qreal ItemsContainerDesignInft::findMaxBottom() const
{ {
qreal maxBottom=0; qreal maxBottom=0;
foreach(QGraphicsItem* item,childItems()){ foreach(QGraphicsItem* item,childItems()){
@ -103,7 +103,7 @@ qreal ItemsContainerDesignInft::findMaxBottom()
return maxBottom; return maxBottom;
} }
qreal ItemsContainerDesignInft::findMaxHeight() qreal ItemsContainerDesignInft::findMaxHeight() const
{ {
qreal maxHeight=0; qreal maxHeight=0;
foreach(QGraphicsItem* item,childItems()){ foreach(QGraphicsItem* item,childItems()){

View File

@ -44,8 +44,8 @@ public:
protected: protected:
void snapshotItemsLayout(); void snapshotItemsLayout();
void arrangeSubItems(RenderPass pass, DataSourceManager *dataManager, ArrangeType type = AsNeeded); void arrangeSubItems(RenderPass pass, DataSourceManager *dataManager, ArrangeType type = AsNeeded);
qreal findMaxBottom(); qreal findMaxBottom() const;
qreal findMaxHeight(); qreal findMaxHeight() const;
private: private:
QVector<PItemSortContainer> m_containerItems; QVector<PItemSortContainer> m_containerItems;

View File

@ -1071,6 +1071,14 @@ void PageDesignIntf::setReportSettings(ReportSettings *reportSettings)
m_pageItem->setReportSettings(m_reportSettings); m_pageItem->setReportSettings(m_reportSettings);
} }
void PageDesignIntf::setPropertyToSelectedItems(const char* name, const QVariant& value)
{
foreach(QGraphicsItem* gi, selectedItems()){
BaseDesignIntf* item = dynamic_cast<BaseDesignIntf*>(gi);
if(item && item->metaObject()->indexOfProperty(name) != -1 ) item->setProperty(name,value);
}
}
bool PageDesignIntf::magneticMovement() const bool PageDesignIntf::magneticMovement() const
{ {
return m_magneticMovement; return m_magneticMovement;

View File

@ -182,6 +182,8 @@ namespace LimeReport {
ReportSettings *getReportSettings() const; ReportSettings *getReportSettings() const;
void setReportSettings(ReportSettings *reportSettings); void setReportSettings(ReportSettings *reportSettings);
void setPropertyToSelectedItems(const char *name, const QVariant &value);
protected: protected:
virtual void keyPressEvent(QKeyEvent *event); virtual void keyPressEvent(QKeyEvent *event);