mirror of
https://github.com/python-LimeReport/LimeReport.git
synced 2024-12-23 20:22:58 +03:00
QRegularExpression usage has been fixed
Qt6 drag&drop has been fixed
This commit is contained in:
parent
3a0a77a2e2
commit
64193a18d0
@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.14)
|
|||||||
|
|
||||||
set(LIMEREPORT_VERSION_MAJOR 1)
|
set(LIMEREPORT_VERSION_MAJOR 1)
|
||||||
set(LIMEREPORT_VERSION_MINOR 6)
|
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(ENABLE_ZINT "Enable libzint build for barcode support" OFF)
|
||||||
option(LIMEREPORT_STATIC "Build LimeReport as static library" OFF)
|
option(LIMEREPORT_STATIC "Build LimeReport as static library" OFF)
|
||||||
|
@ -141,7 +141,7 @@ RCC_DIR = $${ARCH_DIR}/$${BUILD_TYPE}/rcc
|
|||||||
|
|
||||||
LIMEREPORT_VERSION_MAJOR = 1
|
LIMEREPORT_VERSION_MAJOR = 1
|
||||||
LIMEREPORT_VERSION_MINOR = 6
|
LIMEREPORT_VERSION_MINOR = 6
|
||||||
LIMEREPORT_VERSION_RELEASE = 0
|
LIMEREPORT_VERSION_RELEASE = 7
|
||||||
|
|
||||||
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}\\\"
|
||||||
|
@ -157,6 +157,16 @@ namespace Const{
|
|||||||
#else
|
#else
|
||||||
typedef QStyleOptionViewItem StyleOptionViewItem;
|
typedef QStyleOptionViewItem StyleOptionViewItem;
|
||||||
#endif
|
#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
|
class Enums
|
||||||
{
|
{
|
||||||
|
@ -36,7 +36,11 @@ namespace LimeReport {
|
|||||||
DataBrowserTree::DataBrowserTree(QWidget *parent) :
|
DataBrowserTree::DataBrowserTree(QWidget *parent) :
|
||||||
QTreeWidget(parent){}
|
QTreeWidget(parent){}
|
||||||
|
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
|
||||||
|
QMimeData *DataBrowserTree::mimeData(const QList<QTreeWidgetItem *> &items) const
|
||||||
|
#else
|
||||||
QMimeData *DataBrowserTree::mimeData(const QList<QTreeWidgetItem *> items) const
|
QMimeData *DataBrowserTree::mimeData(const QList<QTreeWidgetItem *> items) const
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
QMimeData* result = QTreeWidget::mimeData(items);
|
QMimeData* result = QTreeWidget::mimeData(items);
|
||||||
if (items.at(0)->type()==Row){
|
if (items.at(0)->type()==Row){
|
||||||
|
@ -42,7 +42,11 @@ public:
|
|||||||
enum NodeType{Connection, Table, Row, Category, Variable, ExternalVariable};
|
enum NodeType{Connection, Table, Row, Category, Variable, ExternalVariable};
|
||||||
explicit DataBrowserTree(QWidget *parent = 0);
|
explicit DataBrowserTree(QWidget *parent = 0);
|
||||||
protected:
|
protected:
|
||||||
QMimeData* mimeData(const QList<QTreeWidgetItem *> items) const;
|
#if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
|
||||||
|
virtual QMimeData *mimeData(const QList<QTreeWidgetItem *> &items) const;
|
||||||
|
#else
|
||||||
|
virtual QMimeData *mimeData(const QList<QTreeWidgetItem*> items) const;
|
||||||
|
#endif
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
|
@ -827,7 +827,7 @@ void TextItem::expandContent(DataSourceManager* dataManager, RenderPass pass)
|
|||||||
#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 1))
|
#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 1))
|
||||||
QRegExp rx(QString(Const::NAMED_VARIABLE_RX).arg(variableName));
|
QRegExp rx(QString(Const::NAMED_VARIABLE_RX).arg(variableName));
|
||||||
#else
|
#else
|
||||||
QRegularExpression rx(QString(Const::NAMED_VARIABLE_RX).arg(variableName));
|
QRegularExpression rx = getNamedVariableRegEx(variableName);
|
||||||
#endif
|
#endif
|
||||||
if (context.contains(rx) && pass == FirstPass){
|
if (context.contains(rx) && pass == FirstPass){
|
||||||
backupContent();
|
backupContent();
|
||||||
|
@ -261,7 +261,6 @@ public:
|
|||||||
void setAlternateBackgroundColor(const QColor &alternateBackgroundColor);
|
void setAlternateBackgroundColor(const QColor &alternateBackgroundColor);
|
||||||
bool useAlternateBackgroundColor() const;
|
bool useAlternateBackgroundColor() const;
|
||||||
void setUseAlternateBackgroundColor(bool useAlternateBackgroundColor);
|
void setUseAlternateBackgroundColor(bool useAlternateBackgroundColor);
|
||||||
void replaceGroupsFunction(BandDesignIntf *band);
|
|
||||||
qreal bottomSpace() const;
|
qreal bottomSpace() const;
|
||||||
void setBackgroundModeProperty(BGMode value);
|
void setBackgroundModeProperty(BGMode value);
|
||||||
void setBackgroundOpacity(int value);
|
void setBackgroundOpacity(int value);
|
||||||
|
@ -423,8 +423,8 @@ QString DataSourceManager::extractField(QString source)
|
|||||||
}
|
}
|
||||||
|
|
||||||
QString DataSourceManager::replaceVariables(QString value){
|
QString DataSourceManager::replaceVariables(QString value){
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3)
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 1)
|
||||||
QRegularExpression rx(Const::VARIABLE_RX);
|
QRegularExpression rx = getVariableRegEx();
|
||||||
QRegularExpressionMatchIterator iter = rx.globalMatch(value);
|
QRegularExpressionMatchIterator iter = rx.globalMatch(value);
|
||||||
qsizetype pos = 0;
|
qsizetype pos = 0;
|
||||||
QString result;
|
QString result;
|
||||||
@ -468,8 +468,8 @@ QString DataSourceManager::replaceVariables(QString value){
|
|||||||
|
|
||||||
QString DataSourceManager::replaceVariables(QString query, QMap<QString,QString> &aliasesToParam)
|
QString DataSourceManager::replaceVariables(QString query, QMap<QString,QString> &aliasesToParam)
|
||||||
{
|
{
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3)
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 1)
|
||||||
QRegularExpression rx(Const::VARIABLE_RX);
|
QRegularExpression rx = getVariableRegEx();
|
||||||
int curentAliasIndex = 0;
|
int curentAliasIndex = 0;
|
||||||
if (query.contains(rx)){
|
if (query.contains(rx)){
|
||||||
int pos = -1;
|
int pos = -1;
|
||||||
@ -553,9 +553,8 @@ QString DataSourceManager::replaceVariables(QString query, QMap<QString,QString>
|
|||||||
|
|
||||||
QString DataSourceManager::replaceFields(QString query, QMap<QString,QString> &aliasesToParam, QString masterDatasource)
|
QString DataSourceManager::replaceFields(QString query, QMap<QString,QString> &aliasesToParam, QString masterDatasource)
|
||||||
{
|
{
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3)
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 1)
|
||||||
|
QRegularExpression rx = getFieldRegEx();
|
||||||
QRegularExpression rx(Const::FIELD_RX);
|
|
||||||
int curentAliasIndex = 0;
|
int curentAliasIndex = 0;
|
||||||
if (query.contains(rx)){
|
if (query.contains(rx)){
|
||||||
int pos = -1;
|
int pos = -1;
|
||||||
@ -1498,7 +1497,7 @@ void DataSourceManager::invalidateQueriesContainsVariable(const QString& variabl
|
|||||||
#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 1))
|
#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 1))
|
||||||
QRegExp rx(QString(Const::NAMED_VARIABLE_RX).arg(variableName));
|
QRegExp rx(QString(Const::NAMED_VARIABLE_RX).arg(variableName));
|
||||||
#else
|
#else
|
||||||
QRegularExpression rx(QString(Const::NAMED_VARIABLE_RX).arg(variableName));
|
QRegularExpression rx = getNamedVariableRegEx(variableName);
|
||||||
#endif
|
#endif
|
||||||
if (holder->queryText().contains(rx)){
|
if (holder->queryText().contains(rx)){
|
||||||
holder->invalidate(designTime() ? IDataSource::DESIGN_MODE : IDataSource::RENDER_MODE);
|
holder->invalidate(designTime() ? IDataSource::DESIGN_MODE : IDataSource::RENDER_MODE);
|
||||||
|
@ -67,7 +67,7 @@ QString replaceHTMLSymbols(const QString &value)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3)
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 1)
|
||||||
QVector<QString> normalizeCaptures(const QRegularExpressionMatch& reg){
|
QVector<QString> normalizeCaptures(const QRegularExpressionMatch& reg){
|
||||||
#else
|
#else
|
||||||
QVector<QString> normalizeCaptures(const QRegExp& reg){
|
QVector<QString> normalizeCaptures(const QRegExp& reg){
|
||||||
@ -93,4 +93,53 @@ ReportError::ReportError(const QString& message):std::runtime_error(message.toSt
|
|||||||
IExternalPainter::~IExternalPainter(){}
|
IExternalPainter::~IExternalPainter(){}
|
||||||
IPainterProxy::~IPainterProxy(){}
|
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
|
} //namespace LimeReport
|
||||||
|
@ -157,6 +157,16 @@ namespace Const{
|
|||||||
#else
|
#else
|
||||||
typedef QStyleOptionViewItem StyleOptionViewItem;
|
typedef QStyleOptionViewItem StyleOptionViewItem;
|
||||||
#endif
|
#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
|
class Enums
|
||||||
{
|
{
|
||||||
|
@ -48,8 +48,8 @@ void GroupFunction::slotBandRendered(BandDesignIntf *band)
|
|||||||
QRegExp rxField(Const::FIELD_RX);
|
QRegExp rxField(Const::FIELD_RX);
|
||||||
QRegExp rxVar(Const::VARIABLE_RX);
|
QRegExp rxVar(Const::VARIABLE_RX);
|
||||||
#else
|
#else
|
||||||
QRegularExpression rxField(Const::FIELD_RX);
|
QRegularExpression rxField = getFieldRegEx();
|
||||||
QRegularExpression rxVar(Const::VARIABLE_RX);
|
QRegularExpression rxVar = getVariableRegEx();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
switch (m_dataType){
|
switch (m_dataType){
|
||||||
@ -154,9 +154,9 @@ GroupFunction::GroupFunction(const QString &expression, const QString &dataBandN
|
|||||||
QRegExp rxVariable(Const::VARIABLE_RX,Qt::CaseInsensitive);
|
QRegExp rxVariable(Const::VARIABLE_RX,Qt::CaseInsensitive);
|
||||||
QRegExp rxScript(Const::SCRIPT_RX,Qt::CaseInsensitive);
|
QRegExp rxScript(Const::SCRIPT_RX,Qt::CaseInsensitive);
|
||||||
#else
|
#else
|
||||||
QRegularExpression rxField(Const::FIELD_RX, QRegularExpression::CaseInsensitiveOption);
|
QRegularExpression rxField = getFieldRegEx();
|
||||||
QRegularExpression rxVariable(Const::VARIABLE_RX, QRegularExpression::CaseInsensitiveOption);
|
QRegularExpression rxVariable = getVariableRegEx();
|
||||||
QRegularExpression rxScript(Const::SCRIPT_RX, QRegularExpression::CaseInsensitiveOption);
|
QRegularExpression rxScript = getScriptRegEx();
|
||||||
#endif
|
#endif
|
||||||
#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 1))
|
#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 1))
|
||||||
if (rxScript.indexIn(expression) != -1){
|
if (rxScript.indexIn(expression) != -1){
|
||||||
|
@ -726,7 +726,6 @@ ReportEnginePrivate *PageDesignIntf::reportEditor()
|
|||||||
|
|
||||||
void PageDesignIntf::dragEnterEvent(QGraphicsSceneDragDropEvent *event)
|
void PageDesignIntf::dragEnterEvent(QGraphicsSceneDragDropEvent *event)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (!event->mimeData()->text().isEmpty()){
|
if (!event->mimeData()->text().isEmpty()){
|
||||||
event->setDropAction(Qt::CopyAction);
|
event->setDropAction(Qt::CopyAction);
|
||||||
event->accept();
|
event->accept();
|
||||||
@ -755,7 +754,7 @@ void PageDesignIntf::dropEvent(QGraphicsSceneDragDropEvent* event)
|
|||||||
#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 1))
|
#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 1))
|
||||||
if (isVar) data = data.remove(QRegExp(" \\[.*\\]"));
|
if (isVar) data = data.remove(QRegExp(" \\[.*\\]"));
|
||||||
#else
|
#else
|
||||||
if (isVar) data = data.remove(QRegularExpression(" \\[.*\\]"));
|
if (isVar) data = data.remove(QRegularExpression(" \\[.*\\]", QRegularExpression::DotMatchesEverythingOption));
|
||||||
#endif
|
#endif
|
||||||
ti->setContent(data);
|
ti->setContent(data);
|
||||||
if (!isVar){
|
if (!isVar){
|
||||||
@ -767,7 +766,7 @@ void PageDesignIntf::dropEvent(QGraphicsSceneDragDropEvent* event)
|
|||||||
parentBand->setProperty("datasource",dataSource.cap(1));
|
parentBand->setProperty("datasource",dataSource.cap(1));
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
QRegularExpression dataSource("(?:\\$D\\{\\s*(.*)\\..*\\})");
|
QRegularExpression dataSource("(?:\\$D\\{\\s*(.*)\\..*\\})", QRegularExpression::DotMatchesEverythingOption);
|
||||||
QRegularExpressionMatch match = dataSource.match(data);
|
QRegularExpressionMatch match = dataSource.match(data);
|
||||||
if(match.hasMatch()){
|
if(match.hasMatch()){
|
||||||
parentBand->setProperty("datasource", match.captured(1));
|
parentBand->setProperty("datasource", match.captured(1));
|
||||||
|
@ -196,13 +196,11 @@ void ReportRender::analizeItem(ContentItemDesignIntf* contentItem, BandDesignInt
|
|||||||
QString content = contentItem->content();
|
QString content = contentItem->content();
|
||||||
QVector<QString> functions;
|
QVector<QString> functions;
|
||||||
foreach(const QString &functionName, m_datasources->groupFunctionNames()){
|
foreach(const QString &functionName, m_datasources->groupFunctionNames()){
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3)
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 1)
|
||||||
QRegularExpression rx(QString(Const::GROUP_FUNCTION_RX).arg(functionName));
|
QRegularExpression rx = getGroupFunctionRegEx(functionName);
|
||||||
rx.setPatternOptions(rx.InvertedGreedinessOption);
|
|
||||||
if(content.indexOf(rx)>=0){
|
if(content.indexOf(rx)>=0){
|
||||||
functions.append(functionName);
|
functions.append(functionName);
|
||||||
}
|
}
|
||||||
// TODO: Qt6 port - done
|
|
||||||
#else
|
#else
|
||||||
QRegExp rx(QString(Const::GROUP_FUNCTION_RX).arg(functionName));
|
QRegExp rx(QString(Const::GROUP_FUNCTION_RX).arg(functionName));
|
||||||
rx.setMinimal(true);
|
rx.setMinimal(true);
|
||||||
@ -368,13 +366,11 @@ void ReportRender::clearPageMap()
|
|||||||
bool checkContentItem(ContentItemDesignIntf* item, DataSourceManager* datasources){
|
bool checkContentItem(ContentItemDesignIntf* item, DataSourceManager* datasources){
|
||||||
QString content = item->content();
|
QString content = item->content();
|
||||||
foreach(QString functionName, datasources->groupFunctionNames()){
|
foreach(QString functionName, datasources->groupFunctionNames()){
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3)
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 1)
|
||||||
QRegularExpression rx(QString(Const::GROUP_FUNCTION_RX).arg(functionName));
|
QRegularExpression rx = getGroupFunctionRegEx(functionName);
|
||||||
rx.setPatternOptions(rx.InvertedGreedinessOption);
|
|
||||||
if(content.indexOf(rx)>=0){
|
if(content.indexOf(rx)>=0){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// TODO: Qt6 port - done
|
|
||||||
#else
|
#else
|
||||||
QRegExp rx(QString(Const::GROUP_FUNCTION_RX).arg(functionName));
|
QRegExp rx(QString(Const::GROUP_FUNCTION_RX).arg(functionName));
|
||||||
if (rx.indexIn(content)>=0){
|
if (rx.indexIn(content)>=0){
|
||||||
@ -400,16 +396,14 @@ bool ReportRender::containsGroupFunctions(BaseDesignIntf *container){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ReportRender::extractGroupFuntionsFromItem(ContentItemDesignIntf* contentItem, BandDesignIntf* band){
|
void ReportRender::extractGroupFuntionsFromItem(ContentItemDesignIntf* contentItem, BandDesignIntf* band){
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3)
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 1)
|
||||||
|
if ( contentItem && contentItem->content().contains(getScriptRegEx())){
|
||||||
if ( contentItem && contentItem->content().contains(QRegularExpression("\\$S\\s*\\{.*\\}"))){
|
|
||||||
foreach(const QString &functionName, m_datasources->groupFunctionNames()){
|
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());
|
QRegularExpressionMatch match = rx.match(contentItem->content());
|
||||||
|
|
||||||
if (match.hasMatch()){
|
if (match.hasMatch()){
|
||||||
|
|
||||||
QRegularExpressionMatchIterator iter = rx.globalMatch(contentItem->content());
|
QRegularExpressionMatchIterator iter = rx.globalMatch(contentItem->content());
|
||||||
@ -437,31 +431,7 @@ void ReportRender::extractGroupFuntionsFromItem(ContentItemDesignIntf* contentIt
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// int pos = 0;
|
|
||||||
// while ( (pos = match.capturedStart()) != -1){
|
|
||||||
// QVector<QString> 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){
|
} else if (contentItem->content().indexOf(rxName)>=0){
|
||||||
match = rxName.match(contentItem->content());
|
match = rxName.match(contentItem->content());
|
||||||
GroupFunction* gf = datasources()->addGroupFunction(functionName, match.captured(1), band->objectName(), "");
|
GroupFunction* gf = datasources()->addGroupFunction(functionName, match.captured(1), band->objectName(), "");
|
||||||
@ -470,7 +440,6 @@ void ReportRender::extractGroupFuntionsFromItem(ContentItemDesignIntf* contentIt
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Qt6 port - done
|
|
||||||
#else
|
#else
|
||||||
if ( contentItem && contentItem->content().contains(QRegExp("\\$S\\s*\\{.*\\}"))){
|
if ( contentItem && contentItem->content().contains(QRegExp("\\$S\\s*\\{.*\\}"))){
|
||||||
foreach(const QString &functionName, m_datasources->groupFunctionNames()){
|
foreach(const QString &functionName, m_datasources->groupFunctionNames()){
|
||||||
@ -529,10 +498,8 @@ void ReportRender::replaceGroupFunctionsInItem(ContentItemDesignIntf* contentIte
|
|||||||
if (m_groupfunctionItems.contains(contentItem->patternName())){
|
if (m_groupfunctionItems.contains(contentItem->patternName())){
|
||||||
QString content = contentItem->content();
|
QString content = contentItem->content();
|
||||||
foreach(QString functionName, m_groupfunctionItems.value(contentItem->patternName())){
|
foreach(QString functionName, m_groupfunctionItems.value(contentItem->patternName())){
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3)
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 1)
|
||||||
|
QRegularExpression rx = getGroupFunctionRegEx(functionName);
|
||||||
QRegularExpression rx(QString(Const::GROUP_FUNCTION_RX).arg(functionName));
|
|
||||||
rx.setPatternOptions(rx.InvertedGreedinessOption);
|
|
||||||
QRegularExpressionMatch match = rx.match(content);
|
QRegularExpressionMatch match = rx.match(content);
|
||||||
|
|
||||||
if (match.capturedStart() != -1){
|
if (match.capturedStart() != -1){
|
||||||
@ -556,7 +523,6 @@ void ReportRender::replaceGroupFunctionsInItem(ContentItemDesignIntf* contentIte
|
|||||||
match = rx.match(content, pos + match.capturedLength());
|
match = rx.match(content, pos + match.capturedLength());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// TODO: Qt6 port - done
|
|
||||||
#else
|
#else
|
||||||
QRegExp rx(QString(Const::GROUP_FUNCTION_RX).arg(functionName));
|
QRegExp rx(QString(Const::GROUP_FUNCTION_RX).arg(functionName));
|
||||||
rx.setMinimal(true);
|
rx.setMinimal(true);
|
||||||
|
@ -398,7 +398,7 @@ QString ScriptEngineManager::expandUserVariables(QString context, RenderPass /*
|
|||||||
}
|
}
|
||||||
return context;
|
return context;
|
||||||
#else
|
#else
|
||||||
QRegularExpression rx(Const::VARIABLE_RX);
|
QRegularExpression rx = getVariableRegEx();
|
||||||
if (context.contains(rx)){
|
if (context.contains(rx)){
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
QRegularExpressionMatch match = rx.match(context, pos);
|
QRegularExpressionMatch match = rx.match(context, pos);
|
||||||
@ -504,8 +504,7 @@ QString ScriptEngineManager::expandDataFields(QString context, ExpandType expand
|
|||||||
|
|
||||||
return context;
|
return context;
|
||||||
#else
|
#else
|
||||||
QRegularExpression rx(Const::FIELD_RX);
|
QRegularExpression rx = getFieldRegEx();
|
||||||
|
|
||||||
if (context.contains(rx)){
|
if (context.contains(rx)){
|
||||||
QRegularExpressionMatch match = rx.match(context);
|
QRegularExpressionMatch match = rx.match(context);
|
||||||
while (match.hasMatch()){
|
while (match.hasMatch()){
|
||||||
@ -567,8 +566,7 @@ QString ScriptEngineManager::expandScripts(QString context, QVariant& varValue,
|
|||||||
|
|
||||||
if (context.contains(rx)){
|
if (context.contains(rx)){
|
||||||
#else
|
#else
|
||||||
QRegularExpression rx(Const::SCRIPT_RX, QRegularExpression::DotMatchesEverythingOption);
|
QRegularExpression rx = getScriptRegEx();
|
||||||
|
|
||||||
if(context.contains(rx)){
|
if(context.contains(rx)){
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -636,8 +634,8 @@ QVariant ScriptEngineManager::evaluateScript(const QString& script){
|
|||||||
QVariant varValue;
|
QVariant varValue;
|
||||||
|
|
||||||
if (script.contains(rx)){
|
if (script.contains(rx)){
|
||||||
#else
|
#else
|
||||||
QRegularExpression rx(Const::SCRIPT_RX);
|
QRegularExpression rx = getScriptRegEx();
|
||||||
QVariant varValue;
|
QVariant varValue;
|
||||||
|
|
||||||
if (script.contains(rx)){
|
if (script.contains(rx)){
|
||||||
@ -1110,7 +1108,7 @@ bool ScriptExtractor::parse()
|
|||||||
|
|
||||||
bool ScriptExtractor::parse(int &curPos, const State& state, ScriptNode::Ptr scriptNode)
|
bool ScriptExtractor::parse(int &curPos, const State& state, ScriptNode::Ptr scriptNode)
|
||||||
{
|
{
|
||||||
while (curPos<m_context.length()){
|
while (curPos < m_context.length()){
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case OpenBracketFound:
|
case OpenBracketFound:
|
||||||
if (m_context[curPos]=='}'){
|
if (m_context[curPos]=='}'){
|
||||||
@ -1680,11 +1678,10 @@ QVariant ScriptFunctionsManager::calcGroupFunction(const QString &name, const QS
|
|||||||
if (gf){
|
if (gf){
|
||||||
if (gf->isValid()){
|
if (gf->isValid()){
|
||||||
return gf->calculate(pageItem);
|
return gf->calculate(pageItem);
|
||||||
}else{
|
} else{
|
||||||
return gf->error();
|
return gf->error();
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
return QString(QObject::tr("Function %1 not found or have wrong arguments").arg(name));
|
return QString(QObject::tr("Function %1 not found or have wrong arguments").arg(name));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -401,7 +401,11 @@ private:
|
|||||||
class ScriptNode{
|
class ScriptNode{
|
||||||
public:
|
public:
|
||||||
typedef QSharedPointer<ScriptNode> Ptr;
|
typedef QSharedPointer<ScriptNode> 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 setBody(const QString& body){ m_body = body;}
|
||||||
void setStartLex(const QString startLex){ m_startLex = startLex;}
|
void setStartLex(const QString startLex){ m_startLex = startLex;}
|
||||||
QString script(){return m_startLex + m_body + '}';}
|
QString script(){return m_startLex + m_body + '}';}
|
||||||
|
Loading…
Reference in New Issue
Block a user