From 6a1b244104954dee6a7c8d22d0aac807c5084718 Mon Sep 17 00:00:00 2001 From: Arin Alex Date: Tue, 2 Aug 2016 00:35:57 +0300 Subject: [PATCH 1/4] zOrder fixed for Page and Band --- limereport/lrbasedesignintf.h | 2 +- limereport/lrpagedesignintf.cpp | 23 ++++++++++++++++------- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/limereport/lrbasedesignintf.h b/limereport/lrbasedesignintf.h index 0a8bfcd..5492f78 100644 --- a/limereport/lrbasedesignintf.h +++ b/limereport/lrbasedesignintf.h @@ -248,6 +248,7 @@ public: virtual bool canContainChildren(){ return false;} ReportSettings* reportSettings() const; void setReportSettings(ReportSettings *reportSettings); + void setZValueProperty(qreal value); Q_INVOKABLE QString setItemWidth(qreal width); Q_INVOKABLE QString setItemHeight(qreal height); @@ -309,7 +310,6 @@ private: int resizeDirectionFlags(QPointF position); void moveSelectedItems(QPointF delta); Qt::CursorShape getPosibleCursor(int cursorFlags); - void setZValueProperty(qreal value); void updatePosibleDirectionFlags(); void turnOnSelectionMarker(bool value); private: diff --git a/limereport/lrpagedesignintf.cpp b/limereport/lrpagedesignintf.cpp index bb3f2b0..c77b92f 100644 --- a/limereport/lrpagedesignintf.cpp +++ b/limereport/lrpagedesignintf.cpp @@ -1304,10 +1304,15 @@ void PageDesignIntf::bringToFront() } BaseDesignIntf *bdItem = dynamic_cast(item); - if (bdItem) + if (bdItem){ saveChangeProppertyCommand(bdItem->objectName(), "zOrder", bdItem->zValue(), zOrder); - - item->setZValue(zOrder); + BandDesignIntf* band = dynamic_cast(item); + PageItemDesignIntf* page = dynamic_cast(item); + if (!band && !page) + bdItem->setZValueProperty(zOrder); + } else { + item->setZValue(zOrder); + } } } @@ -1320,11 +1325,15 @@ void PageDesignIntf::sendToBack() zOrder = colItem->zValue() - 0.1; } BaseDesignIntf *bdItem = dynamic_cast(item); - - if (bdItem) + if (bdItem){ saveChangeProppertyCommand(bdItem->objectName(), "zOrder", bdItem->zValue(), zOrder); - - item->setZValue(zOrder); + BandDesignIntf* band = dynamic_cast(item); + PageItemDesignIntf* page = dynamic_cast(item); + if (!band && !page) + bdItem->setZValueProperty(zOrder); + } else { + item->setZValue(zOrder); + } } } From 019d213882519fdd84aa2e4005ffaa4245a446cb Mon Sep 17 00:00:00 2001 From: Arin Alex Date: Tue, 2 Aug 2016 00:38:10 +0300 Subject: [PATCH 2/4] Spliting TextItem and multi variables output have been fixed --- limereport/items/lrtextitem.cpp | 21 +++++++++++++-------- limereport/lrreportrender.cpp | 4 +++- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/limereport/items/lrtextitem.cpp b/limereport/items/lrtextitem.cpp index d0b699d..20ce271 100644 --- a/limereport/items/lrtextitem.cpp +++ b/limereport/items/lrtextitem.cpp @@ -457,7 +457,7 @@ void TextItem::expandContent(DataSourceManager* dataManager, RenderPass pass) context=expandScripts(context, dataManager); } - if (expandType == NoEscapeSymbols) { + if (expandType == NoEscapeSymbols && !m_varValue.isNull() &&m_valueType!=Default) { setContent(formatFieldValue()); } else { setContent(context); @@ -490,22 +490,26 @@ bool TextItem::canBeSplitted(int height) const BaseDesignIntf *TextItem::cloneUpperPart(int height, QObject *owner, QGraphicsItem *parent) { int linesHeight=0; - initText(); QString tmpText=""; TextItem* upperPart = dynamic_cast(cloneItem(itemMode(),owner,parent)); for (QTextBlock it=m_text->begin();it!=m_text->end();it=it.next()){ for (int i=0;ilineCount();i++){ linesHeight+=it.layout()->lineAt(i).height(); - if (linesHeight>(height-(fakeMarginSize()*2+borderLineSize()*2))) {linesHeight-=it.layout()->lineAt(i).height(); goto loop_exit;} + if (linesHeight>(height-(fakeMarginSize()*2+borderLineSize()*2))) { + linesHeight-=it.layout()->lineAt(i).height(); + goto loop_exit; + } tmpText+=it.text().mid(it.layout()->lineAt(i).textStart(),it.layout()->lineAt(i).textLength())+'\n'; } } loop_exit: - tmpText = tmpText.trimmed(); + tmpText.chop(1); + upperPart->setHeight(linesHeight+fakeMarginSize()*2+borderLineSize()*2); QScopedPointer context(new HtmlContext(m_strText)); upperPart->setContent(context->extendTextByTags(tmpText,0)); + upperPart->initText(); return upperPart; } @@ -525,19 +529,20 @@ BaseDesignIntf *TextItem::cloneBottomPart(int height, QObject *owner, QGraphicsI } } loop_exit:; + int textPos=0; for (;curBlock!=m_text->end();curBlock=curBlock.next()){ - for (;curLinelineCount();curLine++){ + for (curLine=0;curLinelineCount();curLine++){ if (tmpText=="") textPos= curBlock.layout()->lineAt(curLine).textStart(); tmpText+=curBlock.text().mid(curBlock.layout()->lineAt(curLine).textStart(), - curBlock.layout()->lineAt(curLine).textLength()) +"\n"; + curBlock.layout()->lineAt(curLine).textLength()) + "\n"; } } - - if (!m_strText.endsWith("\n")) tmpText = tmpText.trimmed(); + tmpText.chop(1); QScopedPointer context(new HtmlContext(m_strText)); bottomPart->setContent(context->extendTextByTags(tmpText,textPos)); + bottomPart->initText(); bottomPart->setHeight(bottomPart->m_textSize.height()+borderLineSize()*2); return bottomPart; } diff --git a/limereport/lrreportrender.cpp b/limereport/lrreportrender.cpp index 768f6aa..b39518a 100644 --- a/limereport/lrreportrender.cpp +++ b/limereport/lrreportrender.cpp @@ -768,7 +768,9 @@ BandDesignIntf* ReportRender::sliceBand(BandDesignIntf *band, BandDesignIntf* pa band = saveUppperPartReturnBottom(band,m_maxHeightByColumn[m_currentColumn],patternBand); if (!band->isEmpty()) { if (band->autoHeight()){ - band->setHeight(0); + if (band->isNeedUpdateSize(FirstPass)){ + band->setHeight(0); + } band->updateItemSize(m_datasources); } DataBandDesignIntf* data = dynamic_cast(band); From f7d8a5050a7d60b371348706e799a2c745ee1752 Mon Sep 17 00:00:00 2001 From: Arin Alex Date: Tue, 2 Aug 2016 01:33:26 +0300 Subject: [PATCH 3/4] Variables access has been fixed --- limereport/databrowser/lrdatabrowsertree.cpp | 3 ++ limereport/lrdatasourcemanager.cpp | 10 ++++-- limereport/lritemdesignintf.cpp | 34 ++++++++++++-------- 3 files changed, 32 insertions(+), 15 deletions(-) diff --git a/limereport/databrowser/lrdatabrowsertree.cpp b/limereport/databrowser/lrdatabrowsertree.cpp index e5d8d79..9128bf4 100644 --- a/limereport/databrowser/lrdatabrowsertree.cpp +++ b/limereport/databrowser/lrdatabrowsertree.cpp @@ -45,6 +45,9 @@ QMimeData *DataBrowserTree::mimeData(const QList items) const if (items.at(0)->type()==Variable){ result->setText("variable:$V{"+items.at(0)->text(0)+"}"); } + if (items.at(0)->type()==ExternalVariable){ + result->setText("variable:$V{"+items.at(0)->text(0)+"}"); + } return result; } diff --git a/limereport/lrdatasourcemanager.cpp b/limereport/lrdatasourcemanager.cpp index 0c07121..1b228ea 100644 --- a/limereport/lrdatasourcemanager.cpp +++ b/limereport/lrdatasourcemanager.cpp @@ -208,6 +208,11 @@ void DataSourceModel::updateModel() foreach (QString name, m_dataManager->variableNames()){ vars->addChild(name,DataNode::Variable,QIcon(":/report/images/value")); } + + vars = m_rootNode->addChild(tr("External variables"),DataNode::Variables,QIcon(":/report/images/folder")); + foreach (QString name, m_dataManager->namesOfUserVariables()){ + vars->addChild(name,DataNode::Variable,QIcon(":/report/images/value")); + } } DataSourceManager::DataSourceManager(QObject *parent) : @@ -1217,8 +1222,9 @@ QVariant DataSourceManager::variable(const QString &variableName) RenderPass DataSourceManager::variablePass(const QString &name) { - - return (m_reportVariables.variablePass(name)==FirstPass)?FirstPass:SecondPass; + if (m_userVariables.containsVariable(name)) + return m_userVariables.variablePass(name); + return m_reportVariables.variablePass(name); } bool DataSourceManager::variableIsSystem(const QString &name) diff --git a/limereport/lritemdesignintf.cpp b/limereport/lritemdesignintf.cpp index 424c569..2a83bc3 100644 --- a/limereport/lritemdesignintf.cpp +++ b/limereport/lritemdesignintf.cpp @@ -172,20 +172,28 @@ QString ContentItemDesignIntf::expandUserVariables(QString context, RenderPass p QString variable=rx.cap(1); pos += rx.matchedLength(); if (dataManager->containsVariable(variable) ){ - if (pass==dataManager->variablePass(variable)){ - m_varValue = dataManager->variable(variable); - switch (expandType){ - case EscapeSymbols: - context.replace(rx.cap(0),escapeSimbols(m_varValue.toString())); - break; - case NoEscapeSymbols: - context.replace(rx.cap(0),m_varValue.toString()); - break; - case ReplaceHTMLSymbols: - context.replace(rx.cap(0),replaceHTMLSymbols(m_varValue.toString())); - break; + try { + if (pass==dataManager->variablePass(variable)){ + m_varValue = dataManager->variable(variable); + switch (expandType){ + case EscapeSymbols: + context.replace(rx.cap(0),escapeSimbols(m_varValue.toString())); + break; + case NoEscapeSymbols: + context.replace(rx.cap(0),m_varValue.toString()); + break; + case ReplaceHTMLSymbols: + context.replace(rx.cap(0),replaceHTMLSymbols(m_varValue.toString())); + break; + } + pos=0; } - pos=0; + } catch (ReportError e){ + dataManager->putError(e.what()); + if (!reportSettings() || reportSettings()->suppressAbsentFieldsAndVarsWarnings()) + context.replace(rx.cap(0),e.what()); + else + context.replace(rx.cap(0),""); } } else { QString error; From da3eb52563b4317a5eff88edbca2ea3e8d3f90d5 Mon Sep 17 00:00:00 2001 From: Arin Alex Date: Tue, 2 Aug 2016 01:39:52 +0300 Subject: [PATCH 4/4] Fix #44 'File > Save As' does not emit saveFinished --- limereport/lrreportdesignwidget.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/limereport/lrreportdesignwidget.cpp b/limereport/lrreportdesignwidget.cpp index 1b590c3..610f294 100644 --- a/limereport/lrreportdesignwidget.cpp +++ b/limereport/lrreportdesignwidget.cpp @@ -227,7 +227,9 @@ void ReportDesignWidget::slotItemSelected(BaseDesignIntf *item){ } void ReportDesignWidget::saveToFile(const QString &fileName){ - m_report->saveToFile(fileName); + if (m_report->saveToFile(fileName)) { + m_report->emitSaveFinished(); + } } bool ReportDesignWidget::save()