diff --git a/CMakeLists.txt b/CMakeLists.txt index 9874801..fb10889 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.14) set(LIMEREPORT_VERSION_MAJOR 1) set(LIMEREPORT_VERSION_MINOR 6) -set(LIMEREPORT_VERSION_RELEASE 6) +set(LIMEREPORT_VERSION_RELEASE 7) option(ENABLE_ZINT "Enable libzint build for barcode support" OFF) option(LIMEREPORT_STATIC "Build LimeReport as static library" OFF) diff --git a/common.pri b/common.pri index ebf1c89..bbdb45d 100644 --- a/common.pri +++ b/common.pri @@ -141,7 +141,7 @@ RCC_DIR = $${ARCH_DIR}/$${BUILD_TYPE}/rcc LIMEREPORT_VERSION_MAJOR = 1 LIMEREPORT_VERSION_MINOR = 6 -LIMEREPORT_VERSION_RELEASE = 0 +LIMEREPORT_VERSION_RELEASE = 7 LIMEREPORT_VERSION = '$${LIMEREPORT_VERSION_MAJOR}.$${LIMEREPORT_VERSION_MINOR}.$${LIMEREPORT_VERSION_RELEASE}' DEFINES *= LIMEREPORT_VERSION_STR=\\\"$${LIMEREPORT_VERSION}\\\" diff --git a/include/lrglobal.h b/include/lrglobal.h index ed0254a..1286a0d 100644 --- a/include/lrglobal.h +++ b/include/lrglobal.h @@ -157,6 +157,16 @@ namespace Const{ #else typedef QStyleOptionViewItem StyleOptionViewItem; #endif +#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 1) + QRegularExpression getRegEx(QString expression); + QRegularExpression getVariableRegEx(); + QRegularExpression getFieldRegEx(); + QRegularExpression getScriptRegEx(); + QRegularExpression getGroupFunctionRegEx(QString functionName); + QRegularExpression getGroupFunctionNameRegEx(QString functionName); + QRegularExpression getNamedVariableRegEx(QString variableName); +#endif + class Enums { diff --git a/limereport/databrowser/lrdatabrowsertree.cpp b/limereport/databrowser/lrdatabrowsertree.cpp index 2625602..53934f3 100644 --- a/limereport/databrowser/lrdatabrowsertree.cpp +++ b/limereport/databrowser/lrdatabrowsertree.cpp @@ -36,7 +36,11 @@ namespace LimeReport { DataBrowserTree::DataBrowserTree(QWidget *parent) : QTreeWidget(parent){} +#if QT_VERSION >= QT_VERSION_CHECK(6,0,0) +QMimeData *DataBrowserTree::mimeData(const QList &items) const +#else QMimeData *DataBrowserTree::mimeData(const QList items) const +#endif { QMimeData* result = QTreeWidget::mimeData(items); if (items.at(0)->type()==Row){ diff --git a/limereport/databrowser/lrdatabrowsertree.h b/limereport/databrowser/lrdatabrowsertree.h index 3cbcdff..eb03791 100644 --- a/limereport/databrowser/lrdatabrowsertree.h +++ b/limereport/databrowser/lrdatabrowsertree.h @@ -42,7 +42,11 @@ public: enum NodeType{Connection, Table, Row, Category, Variable, ExternalVariable}; explicit DataBrowserTree(QWidget *parent = 0); protected: - QMimeData* mimeData(const QList items) const; +#if QT_VERSION >= QT_VERSION_CHECK(6,0,0) + virtual QMimeData *mimeData(const QList &items) const; +#else + virtual QMimeData *mimeData(const QList items) const; +#endif public slots: diff --git a/limereport/items/lrtextitem.cpp b/limereport/items/lrtextitem.cpp index 086adca..4ef3db9 100644 --- a/limereport/items/lrtextitem.cpp +++ b/limereport/items/lrtextitem.cpp @@ -827,7 +827,7 @@ void TextItem::expandContent(DataSourceManager* dataManager, RenderPass pass) #if (QT_VERSION < QT_VERSION_CHECK(5, 15, 1)) QRegExp rx(QString(Const::NAMED_VARIABLE_RX).arg(variableName)); #else - QRegularExpression rx(QString(Const::NAMED_VARIABLE_RX).arg(variableName)); + QRegularExpression rx = getNamedVariableRegEx(variableName); #endif if (context.contains(rx) && pass == FirstPass){ backupContent(); diff --git a/limereport/lrbanddesignintf.h b/limereport/lrbanddesignintf.h index 71d02e1..8960eeb 100644 --- a/limereport/lrbanddesignintf.h +++ b/limereport/lrbanddesignintf.h @@ -261,7 +261,6 @@ public: void setAlternateBackgroundColor(const QColor &alternateBackgroundColor); bool useAlternateBackgroundColor() const; void setUseAlternateBackgroundColor(bool useAlternateBackgroundColor); - void replaceGroupsFunction(BandDesignIntf *band); qreal bottomSpace() const; void setBackgroundModeProperty(BGMode value); void setBackgroundOpacity(int value); diff --git a/limereport/lrdatasourcemanager.cpp b/limereport/lrdatasourcemanager.cpp index b3e3738..fa5e355 100644 --- a/limereport/lrdatasourcemanager.cpp +++ b/limereport/lrdatasourcemanager.cpp @@ -423,8 +423,8 @@ QString DataSourceManager::extractField(QString source) } QString DataSourceManager::replaceVariables(QString value){ -#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3) - QRegularExpression rx(Const::VARIABLE_RX); +#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 1) + QRegularExpression rx = getVariableRegEx(); QRegularExpressionMatchIterator iter = rx.globalMatch(value); qsizetype pos = 0; QString result; @@ -468,8 +468,8 @@ QString DataSourceManager::replaceVariables(QString value){ QString DataSourceManager::replaceVariables(QString query, QMap &aliasesToParam) { -#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3) - QRegularExpression rx(Const::VARIABLE_RX); +#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 1) + QRegularExpression rx = getVariableRegEx(); int curentAliasIndex = 0; if (query.contains(rx)){ int pos = -1; @@ -553,9 +553,8 @@ QString DataSourceManager::replaceVariables(QString query, QMap QString DataSourceManager::replaceFields(QString query, QMap &aliasesToParam, QString masterDatasource) { -#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3) - - QRegularExpression rx(Const::FIELD_RX); +#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 1) + QRegularExpression rx = getFieldRegEx(); int curentAliasIndex = 0; if (query.contains(rx)){ int pos = -1; @@ -1498,7 +1497,7 @@ void DataSourceManager::invalidateQueriesContainsVariable(const QString& variabl #if (QT_VERSION < QT_VERSION_CHECK(5, 15, 1)) QRegExp rx(QString(Const::NAMED_VARIABLE_RX).arg(variableName)); #else - QRegularExpression rx(QString(Const::NAMED_VARIABLE_RX).arg(variableName)); + QRegularExpression rx = getNamedVariableRegEx(variableName); #endif if (holder->queryText().contains(rx)){ holder->invalidate(designTime() ? IDataSource::DESIGN_MODE : IDataSource::RENDER_MODE); diff --git a/limereport/lrglobal.cpp b/limereport/lrglobal.cpp index cd2b6c0..ac78588 100644 --- a/limereport/lrglobal.cpp +++ b/limereport/lrglobal.cpp @@ -67,7 +67,7 @@ QString replaceHTMLSymbols(const QString &value) return result; } -#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3) +#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 1) QVector normalizeCaptures(const QRegularExpressionMatch& reg){ #else QVector normalizeCaptures(const QRegExp& reg){ @@ -93,4 +93,53 @@ ReportError::ReportError(const QString& message):std::runtime_error(message.toSt IExternalPainter::~IExternalPainter(){} IPainterProxy::~IPainterProxy(){} + +#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 1) +QRegularExpression getRegEx(QString expression){ + return QRegularExpression(expression, QRegularExpression::DotMatchesEverythingOption); +} +QRegularExpression getVariableRegEx(){ + return QRegularExpression( + Const::VARIABLE_RX, + QRegularExpression::DotMatchesEverythingOption | + QRegularExpression::CaseInsensitiveOption + ); +} +QRegularExpression getFieldRegEx(){ + return QRegularExpression( + Const::FIELD_RX, + QRegularExpression::DotMatchesEverythingOption | + QRegularExpression::CaseInsensitiveOption + ); +} +QRegularExpression getScriptRegEx(){ + return QRegularExpression( + Const::SCRIPT_RX, + QRegularExpression::DotMatchesEverythingOption | + QRegularExpression::CaseInsensitiveOption + ); +} +QRegularExpression getGroupFunctionRegEx(QString functionName){ + return QRegularExpression( + QString(Const::GROUP_FUNCTION_RX).arg(functionName), + QRegularExpression::DotMatchesEverythingOption | + QRegularExpression::InvertedGreedinessOption + ); +} +QRegularExpression getGroupFunctionNameRegEx(QString functionName){ + return QRegularExpression( + QString(Const::GROUP_FUNCTION_NAME_RX).arg(functionName), + QRegularExpression::DotMatchesEverythingOption | + QRegularExpression::InvertedGreedinessOption + ); +} +QRegularExpression getNamedVariableRegEx(QString variableName){ + return QRegularExpression( + QString(Const::NAMED_VARIABLE_RX).arg(variableName), + QRegularExpression::DotMatchesEverythingOption + ); +} +#endif + + } //namespace LimeReport diff --git a/limereport/lrglobal.h b/limereport/lrglobal.h index ed0254a..1286a0d 100644 --- a/limereport/lrglobal.h +++ b/limereport/lrglobal.h @@ -157,6 +157,16 @@ namespace Const{ #else typedef QStyleOptionViewItem StyleOptionViewItem; #endif +#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 1) + QRegularExpression getRegEx(QString expression); + QRegularExpression getVariableRegEx(); + QRegularExpression getFieldRegEx(); + QRegularExpression getScriptRegEx(); + QRegularExpression getGroupFunctionRegEx(QString functionName); + QRegularExpression getGroupFunctionNameRegEx(QString functionName); + QRegularExpression getNamedVariableRegEx(QString variableName); +#endif + class Enums { diff --git a/limereport/lrgroupfunctions.cpp b/limereport/lrgroupfunctions.cpp index 3130832..f893d12 100644 --- a/limereport/lrgroupfunctions.cpp +++ b/limereport/lrgroupfunctions.cpp @@ -48,8 +48,8 @@ void GroupFunction::slotBandRendered(BandDesignIntf *band) QRegExp rxField(Const::FIELD_RX); QRegExp rxVar(Const::VARIABLE_RX); #else - QRegularExpression rxField(Const::FIELD_RX); - QRegularExpression rxVar(Const::VARIABLE_RX); + QRegularExpression rxField = getFieldRegEx(); + QRegularExpression rxVar = getVariableRegEx(); #endif switch (m_dataType){ @@ -154,9 +154,9 @@ GroupFunction::GroupFunction(const QString &expression, const QString &dataBandN QRegExp rxVariable(Const::VARIABLE_RX,Qt::CaseInsensitive); QRegExp rxScript(Const::SCRIPT_RX,Qt::CaseInsensitive); #else - QRegularExpression rxField(Const::FIELD_RX, QRegularExpression::CaseInsensitiveOption); - QRegularExpression rxVariable(Const::VARIABLE_RX, QRegularExpression::CaseInsensitiveOption); - QRegularExpression rxScript(Const::SCRIPT_RX, QRegularExpression::CaseInsensitiveOption); + QRegularExpression rxField = getFieldRegEx(); + QRegularExpression rxVariable = getVariableRegEx(); + QRegularExpression rxScript = getScriptRegEx(); #endif #if (QT_VERSION < QT_VERSION_CHECK(5, 15, 1)) if (rxScript.indexIn(expression) != -1){ diff --git a/limereport/lrpagedesignintf.cpp b/limereport/lrpagedesignintf.cpp index 6e7477b..659244d 100644 --- a/limereport/lrpagedesignintf.cpp +++ b/limereport/lrpagedesignintf.cpp @@ -726,7 +726,6 @@ ReportEnginePrivate *PageDesignIntf::reportEditor() void PageDesignIntf::dragEnterEvent(QGraphicsSceneDragDropEvent *event) { - if (!event->mimeData()->text().isEmpty()){ event->setDropAction(Qt::CopyAction); event->accept(); @@ -755,7 +754,7 @@ void PageDesignIntf::dropEvent(QGraphicsSceneDragDropEvent* event) #if (QT_VERSION < QT_VERSION_CHECK(5, 15, 1)) if (isVar) data = data.remove(QRegExp(" \\[.*\\]")); #else - if (isVar) data = data.remove(QRegularExpression(" \\[.*\\]")); + if (isVar) data = data.remove(QRegularExpression(" \\[.*\\]", QRegularExpression::DotMatchesEverythingOption)); #endif ti->setContent(data); if (!isVar){ @@ -767,7 +766,7 @@ void PageDesignIntf::dropEvent(QGraphicsSceneDragDropEvent* event) parentBand->setProperty("datasource",dataSource.cap(1)); } #else - QRegularExpression dataSource("(?:\\$D\\{\\s*(.*)\\..*\\})"); + QRegularExpression dataSource("(?:\\$D\\{\\s*(.*)\\..*\\})", QRegularExpression::DotMatchesEverythingOption); QRegularExpressionMatch match = dataSource.match(data); if(match.hasMatch()){ parentBand->setProperty("datasource", match.captured(1)); diff --git a/limereport/lrreportrender.cpp b/limereport/lrreportrender.cpp index 917bf04..d412b19 100644 --- a/limereport/lrreportrender.cpp +++ b/limereport/lrreportrender.cpp @@ -196,13 +196,11 @@ void ReportRender::analizeItem(ContentItemDesignIntf* contentItem, BandDesignInt QString content = contentItem->content(); QVector functions; foreach(const QString &functionName, m_datasources->groupFunctionNames()){ -#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3) - QRegularExpression rx(QString(Const::GROUP_FUNCTION_RX).arg(functionName)); - rx.setPatternOptions(rx.InvertedGreedinessOption); +#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 1) + QRegularExpression rx = getGroupFunctionRegEx(functionName); if(content.indexOf(rx)>=0){ functions.append(functionName); } - // TODO: Qt6 port - done #else QRegExp rx(QString(Const::GROUP_FUNCTION_RX).arg(functionName)); rx.setMinimal(true); @@ -368,13 +366,11 @@ void ReportRender::clearPageMap() bool checkContentItem(ContentItemDesignIntf* item, DataSourceManager* datasources){ QString content = item->content(); foreach(QString functionName, datasources->groupFunctionNames()){ -#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3) - QRegularExpression rx(QString(Const::GROUP_FUNCTION_RX).arg(functionName)); - rx.setPatternOptions(rx.InvertedGreedinessOption); +#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 1) + QRegularExpression rx = getGroupFunctionRegEx(functionName); if(content.indexOf(rx)>=0){ return true; } - // TODO: Qt6 port - done #else QRegExp rx(QString(Const::GROUP_FUNCTION_RX).arg(functionName)); if (rx.indexIn(content)>=0){ @@ -400,16 +396,14 @@ bool ReportRender::containsGroupFunctions(BaseDesignIntf *container){ } void ReportRender::extractGroupFuntionsFromItem(ContentItemDesignIntf* contentItem, BandDesignIntf* band){ -#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3) - - if ( contentItem && contentItem->content().contains(QRegularExpression("\\$S\\s*\\{.*\\}"))){ +#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 1) + if ( contentItem && contentItem->content().contains(getScriptRegEx())){ foreach(const QString &functionName, m_datasources->groupFunctionNames()){ - QRegularExpression rx(QString(Const::GROUP_FUNCTION_RX).arg(functionName)); - rx.setPatternOptions(rx.InvertedGreedinessOption); - QRegularExpression rxName(QString(Const::GROUP_FUNCTION_NAME_RX).arg(functionName)); - rxName.setPatternOptions(rx.InvertedGreedinessOption); + QRegularExpression rx = getGroupFunctionRegEx(functionName); + QRegularExpression rxName = getGroupFunctionNameRegEx(functionName); QRegularExpressionMatch match = rx.match(contentItem->content()); + if (match.hasMatch()){ QRegularExpressionMatchIterator iter = rx.globalMatch(contentItem->content()); @@ -437,31 +431,7 @@ void ReportRender::extractGroupFuntionsFromItem(ContentItemDesignIntf* contentIt } } } -// int pos = 0; -// while ( (pos = match.capturedStart()) != -1){ -// QVector captures = normalizeCaptures(match); -// if (captures.size() >= 3){ -// int dsIndex = captures.size() == 3 ? Const::DATASOURCE_INDEX - 1 : Const::DATASOURCE_INDEX; -// BandDesignIntf* dataBand = m_patternPageItem->bandByName(captures.at(dsIndex)); -// if (dataBand){ -// GroupFunction* gf = datasources()->addGroupFunction( -// functionName, captures.at(Const::VALUE_INDEX), band->objectName(), dataBand->objectName() -// ); -// if (gf){ -// connect(dataBand, SIGNAL(bandRendered(BandDesignIntf*)), -// gf, SLOT(slotBandRendered(BandDesignIntf*))); -// connect(dataBand, SIGNAL(bandReRendered(BandDesignIntf*, BandDesignIntf*)), -// gf, SLOT(slotBandReRendered(BandDesignIntf*, BandDesignIntf*))); -// } -// } else { -// GroupFunction* gf = datasources()->addGroupFunction( -// functionName, captures.at(Const::VALUE_INDEX), band->objectName(), captures.at(dsIndex) -// ); -// gf->setInvalid(tr("Databand \"%1\" not found").arg(captures.at(dsIndex))); -// } -// } -// match = rx.match(contentItem->content(), pos + match.capturedLength()); -// } + } else if (contentItem->content().indexOf(rxName)>=0){ match = rxName.match(contentItem->content()); GroupFunction* gf = datasources()->addGroupFunction(functionName, match.captured(1), band->objectName(), ""); @@ -470,7 +440,6 @@ void ReportRender::extractGroupFuntionsFromItem(ContentItemDesignIntf* contentIt } } - // TODO: Qt6 port - done #else if ( contentItem && contentItem->content().contains(QRegExp("\\$S\\s*\\{.*\\}"))){ foreach(const QString &functionName, m_datasources->groupFunctionNames()){ @@ -529,10 +498,8 @@ void ReportRender::replaceGroupFunctionsInItem(ContentItemDesignIntf* contentIte if (m_groupfunctionItems.contains(contentItem->patternName())){ QString content = contentItem->content(); foreach(QString functionName, m_groupfunctionItems.value(contentItem->patternName())){ -#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3) - - QRegularExpression rx(QString(Const::GROUP_FUNCTION_RX).arg(functionName)); - rx.setPatternOptions(rx.InvertedGreedinessOption); +#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 1) + QRegularExpression rx = getGroupFunctionRegEx(functionName); QRegularExpressionMatch match = rx.match(content); if (match.capturedStart() != -1){ @@ -556,7 +523,6 @@ void ReportRender::replaceGroupFunctionsInItem(ContentItemDesignIntf* contentIte match = rx.match(content, pos + match.capturedLength()); } } - // TODO: Qt6 port - done #else QRegExp rx(QString(Const::GROUP_FUNCTION_RX).arg(functionName)); rx.setMinimal(true); diff --git a/limereport/lrscriptenginemanager.cpp b/limereport/lrscriptenginemanager.cpp index 2abc084..952c8e2 100644 --- a/limereport/lrscriptenginemanager.cpp +++ b/limereport/lrscriptenginemanager.cpp @@ -398,7 +398,7 @@ QString ScriptEngineManager::expandUserVariables(QString context, RenderPass /* } return context; #else - QRegularExpression rx(Const::VARIABLE_RX); + QRegularExpression rx = getVariableRegEx(); if (context.contains(rx)){ int pos = 0; QRegularExpressionMatch match = rx.match(context, pos); @@ -504,8 +504,7 @@ QString ScriptEngineManager::expandDataFields(QString context, ExpandType expand return context; #else - QRegularExpression rx(Const::FIELD_RX); - + QRegularExpression rx = getFieldRegEx(); if (context.contains(rx)){ QRegularExpressionMatch match = rx.match(context); while (match.hasMatch()){ @@ -567,8 +566,7 @@ QString ScriptEngineManager::expandScripts(QString context, QVariant& varValue, if (context.contains(rx)){ #else - QRegularExpression rx(Const::SCRIPT_RX, QRegularExpression::DotMatchesEverythingOption); - + QRegularExpression rx = getScriptRegEx(); if(context.contains(rx)){ #endif @@ -636,8 +634,8 @@ QVariant ScriptEngineManager::evaluateScript(const QString& script){ QVariant varValue; if (script.contains(rx)){ -#else - QRegularExpression rx(Const::SCRIPT_RX); +#else + QRegularExpression rx = getScriptRegEx(); QVariant varValue; if (script.contains(rx)){ @@ -1110,7 +1108,7 @@ bool ScriptExtractor::parse() bool ScriptExtractor::parse(int &curPos, const State& state, ScriptNode::Ptr scriptNode) { - while (curPosisValid()){ return gf->calculate(pageItem); - }else{ + } else{ return gf->error(); } - } - else { + } else { return QString(QObject::tr("Function %1 not found or have wrong arguments").arg(name)); } } else { diff --git a/limereport/lrscriptenginemanager.h b/limereport/lrscriptenginemanager.h index 7c3bccd..59979ae 100644 --- a/limereport/lrscriptenginemanager.h +++ b/limereport/lrscriptenginemanager.h @@ -401,7 +401,11 @@ private: class ScriptNode{ public: typedef QSharedPointer Ptr; - QString body(){return m_body;} + QString body(){ + if (m_body.isEmpty() && m_children.count() > 0) + return m_children.at(0)->body(); + return m_body; + } void setBody(const QString& body){ m_body = body;} void setStartLex(const QString startLex){ m_startLex = startLex;} QString script(){return m_startLex + m_body + '}';}