Merge branch 'master' into 1.4

Conflicts:
	limereport/items/lrtextitem.cpp
	limereport/lrreportdesignwidget.cpp
This commit is contained in:
Arin Alex 2016-08-02 01:43:05 +03:00
commit 06e5b1f29a
8 changed files with 66 additions and 33 deletions

View File

@ -45,6 +45,9 @@ QMimeData *DataBrowserTree::mimeData(const QList<QTreeWidgetItem *> items) const
if (items.at(0)->type()==Variable){ if (items.at(0)->type()==Variable){
result->setText("variable:$V{"+items.at(0)->text(0)+"}"); 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; return result;
} }

View File

@ -557,7 +557,7 @@ void TextItem::expandContent(DataSourceManager* dataManager, RenderPass pass)
context=expandScripts(context, dataManager); context=expandScripts(context, dataManager);
} }
if (expandType == NoEscapeSymbols) { if (expandType == NoEscapeSymbols && !m_varValue.isNull() &&m_valueType!=Default) {
setContent(formatFieldValue()); setContent(formatFieldValue());
} else { } else {
setContent(context); setContent(context);
@ -601,7 +601,6 @@ bool TextItem::canBeSplitted(int height) const
BaseDesignIntf *TextItem::cloneUpperPart(int height, QObject *owner, QGraphicsItem *parent) BaseDesignIntf *TextItem::cloneUpperPart(int height, QObject *owner, QGraphicsItem *parent)
{ {
int linesHeight=0; int linesHeight=0;
initText();
QString tmpText=""; QString tmpText="";
TextItem* upperPart = dynamic_cast<TextItem*>(cloneItem(itemMode(),owner,parent)); TextItem* upperPart = dynamic_cast<TextItem*>(cloneItem(itemMode(),owner,parent));
@ -609,16 +608,19 @@ BaseDesignIntf *TextItem::cloneUpperPart(int height, QObject *owner, QGraphicsIt
for (int i=0;i<it.layout()->lineCount();i++){ for (int i=0;i<it.layout()->lineCount();i++){
linesHeight+=it.layout()->lineAt(i).height()+lineSpacing(); linesHeight+=it.layout()->lineAt(i).height()+lineSpacing();
if (linesHeight>(height-(fakeMarginSize()*2+borderLineSize()*2))) { if (linesHeight>(height-(fakeMarginSize()*2+borderLineSize()*2))) {
linesHeight-=it.layout()->lineAt(i).height(); goto loop_exit; linesHeight-=it.layout()->lineAt(i).height();
goto loop_exit;
} }
tmpText+=it.text().mid(it.layout()->lineAt(i).textStart(),it.layout()->lineAt(i).textLength())+'\n'; tmpText+=it.text().mid(it.layout()->lineAt(i).textStart(),it.layout()->lineAt(i).textLength())+'\n';
} }
} }
loop_exit: loop_exit:
tmpText = tmpText.trimmed(); tmpText.chop(1);
upperPart->setHeight(linesHeight+fakeMarginSize()*2+borderLineSize()*2); upperPart->setHeight(linesHeight+fakeMarginSize()*2+borderLineSize()*2);
QScopedPointer<HtmlContext> context(new HtmlContext(m_strText)); QScopedPointer<HtmlContext> context(new HtmlContext(m_strText));
upperPart->setContent(context->extendTextByTags(tmpText,0)); upperPart->setContent(context->extendTextByTags(tmpText,0));
upperPart->initText();
return upperPart; return upperPart;
} }
@ -638,19 +640,20 @@ BaseDesignIntf *TextItem::cloneBottomPart(int height, QObject *owner, QGraphicsI
} }
} }
loop_exit:; loop_exit:;
int textPos=0; int textPos=0;
for (;curBlock!=m_text->end();curBlock=curBlock.next()){ for (;curBlock!=m_text->end();curBlock=curBlock.next()){
for (;curLine<curBlock.layout()->lineCount();curLine++){ for (curLine=0;curLine<curBlock.layout()->lineCount();curLine++){
if (tmpText=="") textPos= curBlock.layout()->lineAt(curLine).textStart(); if (tmpText=="") textPos= curBlock.layout()->lineAt(curLine).textStart();
tmpText+=curBlock.text().mid(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";
} }
} }
tmpText.chop(1);
if (!m_strText.endsWith("\n")) tmpText = tmpText.trimmed();
QScopedPointer<HtmlContext> context(new HtmlContext(m_strText)); QScopedPointer<HtmlContext> context(new HtmlContext(m_strText));
bottomPart->setContent(context->extendTextByTags(tmpText,textPos)); bottomPart->setContent(context->extendTextByTags(tmpText,textPos));
bottomPart->initText();
bottomPart->setHeight(bottomPart->m_textSize.height()+borderLineSize()*2); bottomPart->setHeight(bottomPart->m_textSize.height()+borderLineSize()*2);
return bottomPart; return bottomPart;
} }

View File

@ -248,6 +248,7 @@ public:
virtual bool canContainChildren(){ return false;} virtual bool canContainChildren(){ return false;}
ReportSettings* reportSettings() const; ReportSettings* reportSettings() const;
void setReportSettings(ReportSettings *reportSettings); void setReportSettings(ReportSettings *reportSettings);
void setZValueProperty(qreal value);
Q_INVOKABLE QString setItemWidth(qreal width); Q_INVOKABLE QString setItemWidth(qreal width);
Q_INVOKABLE QString setItemHeight(qreal height); Q_INVOKABLE QString setItemHeight(qreal height);
@ -309,7 +310,6 @@ private:
int resizeDirectionFlags(QPointF position); int resizeDirectionFlags(QPointF position);
void moveSelectedItems(QPointF delta); void moveSelectedItems(QPointF delta);
Qt::CursorShape getPosibleCursor(int cursorFlags); Qt::CursorShape getPosibleCursor(int cursorFlags);
void setZValueProperty(qreal value);
void updatePosibleDirectionFlags(); void updatePosibleDirectionFlags();
void turnOnSelectionMarker(bool value); void turnOnSelectionMarker(bool value);
private: private:

View File

@ -208,6 +208,11 @@ void DataSourceModel::updateModel()
foreach (QString name, m_dataManager->variableNames()){ foreach (QString name, m_dataManager->variableNames()){
vars->addChild(name,DataNode::Variable,QIcon(":/report/images/value")); 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) : DataSourceManager::DataSourceManager(QObject *parent) :
@ -1217,8 +1222,9 @@ QVariant DataSourceManager::variable(const QString &variableName)
RenderPass DataSourceManager::variablePass(const QString &name) RenderPass DataSourceManager::variablePass(const QString &name)
{ {
if (m_userVariables.containsVariable(name))
return (m_reportVariables.variablePass(name)==FirstPass)?FirstPass:SecondPass; return m_userVariables.variablePass(name);
return m_reportVariables.variablePass(name);
} }
bool DataSourceManager::variableIsSystem(const QString &name) bool DataSourceManager::variableIsSystem(const QString &name)

View File

@ -172,20 +172,28 @@ QString ContentItemDesignIntf::expandUserVariables(QString context, RenderPass p
QString variable=rx.cap(1); QString variable=rx.cap(1);
pos += rx.matchedLength(); pos += rx.matchedLength();
if (dataManager->containsVariable(variable) ){ if (dataManager->containsVariable(variable) ){
if (pass==dataManager->variablePass(variable)){ try {
m_varValue = dataManager->variable(variable); if (pass==dataManager->variablePass(variable)){
switch (expandType){ m_varValue = dataManager->variable(variable);
case EscapeSymbols: switch (expandType){
context.replace(rx.cap(0),escapeSimbols(m_varValue.toString())); case EscapeSymbols:
break; context.replace(rx.cap(0),escapeSimbols(m_varValue.toString()));
case NoEscapeSymbols: break;
context.replace(rx.cap(0),m_varValue.toString()); case NoEscapeSymbols:
break; context.replace(rx.cap(0),m_varValue.toString());
case ReplaceHTMLSymbols: break;
context.replace(rx.cap(0),replaceHTMLSymbols(m_varValue.toString())); case ReplaceHTMLSymbols:
break; 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 { } else {
QString error; QString error;

View File

@ -1304,10 +1304,15 @@ void PageDesignIntf::bringToFront()
} }
BaseDesignIntf *bdItem = dynamic_cast<BaseDesignIntf *>(item); BaseDesignIntf *bdItem = dynamic_cast<BaseDesignIntf *>(item);
if (bdItem) if (bdItem){
saveChangeProppertyCommand(bdItem->objectName(), "zOrder", bdItem->zValue(), zOrder); saveChangeProppertyCommand(bdItem->objectName(), "zOrder", bdItem->zValue(), zOrder);
BandDesignIntf* band = dynamic_cast<BandDesignIntf*>(item);
item->setZValue(zOrder); PageItemDesignIntf* page = dynamic_cast<PageItemDesignIntf*>(item);
if (!band && !page)
bdItem->setZValueProperty(zOrder);
} else {
item->setZValue(zOrder);
}
} }
} }
@ -1320,11 +1325,15 @@ void PageDesignIntf::sendToBack()
zOrder = colItem->zValue() - 0.1; zOrder = colItem->zValue() - 0.1;
} }
BaseDesignIntf *bdItem = dynamic_cast<BaseDesignIntf *>(item); BaseDesignIntf *bdItem = dynamic_cast<BaseDesignIntf *>(item);
if (bdItem){
if (bdItem)
saveChangeProppertyCommand(bdItem->objectName(), "zOrder", bdItem->zValue(), zOrder); saveChangeProppertyCommand(bdItem->objectName(), "zOrder", bdItem->zValue(), zOrder);
BandDesignIntf* band = dynamic_cast<BandDesignIntf*>(item);
item->setZValue(zOrder); PageItemDesignIntf* page = dynamic_cast<PageItemDesignIntf*>(item);
if (!band && !page)
bdItem->setZValueProperty(zOrder);
} else {
item->setZValue(zOrder);
}
} }
} }

View File

@ -258,7 +258,9 @@ void ReportDesignWidget::slotItemSelected(BaseDesignIntf *item){
void ReportDesignWidget::saveToFile(const QString &fileName){ void ReportDesignWidget::saveToFile(const QString &fileName){
m_report->scriptContext()->setInitScript(m_scriptEditor->toPlainText()); m_report->scriptContext()->setInitScript(m_scriptEditor->toPlainText());
m_report->saveToFile(fileName); if (m_report->saveToFile(fileName)) {
m_report->emitSaveFinished();
}
} }
bool ReportDesignWidget::save() bool ReportDesignWidget::save()

View File

@ -812,7 +812,9 @@ BandDesignIntf* ReportRender::sliceBand(BandDesignIntf *band, BandDesignIntf* pa
band = saveUppperPartReturnBottom(band,m_maxHeightByColumn[m_currentColumn],patternBand); band = saveUppperPartReturnBottom(band,m_maxHeightByColumn[m_currentColumn],patternBand);
if (!band->isEmpty()) { if (!band->isEmpty()) {
if (band->autoHeight()){ if (band->autoHeight()){
band->setHeight(0); if (band->isNeedUpdateSize(FirstPass)){
band->setHeight(0);
}
band->updateItemSize(m_datasources); band->updateItemSize(m_datasources);
} }
DataBandDesignIntf* data = dynamic_cast<DataBandDesignIntf*>(band); DataBandDesignIntf* data = dynamic_cast<DataBandDesignIntf*>(band);