mirror of
https://github.com/fralx/LimeReport.git
synced 2024-12-24 16:44:39 +03:00
COUNT function can be called with only one databand argument
This commit is contained in:
parent
658a6e7e09
commit
081b422468
@ -77,9 +77,16 @@ namespace Const{
|
|||||||
const QString FIELD_RX = "\\$D\\s*\\{\\s*([^{}]*)\\s*\\}";
|
const QString FIELD_RX = "\\$D\\s*\\{\\s*([^{}]*)\\s*\\}";
|
||||||
const QString VARIABLE_RX = "\\$V\\s*\\{\\s*([^{}]*)\\s*\\}";
|
const QString VARIABLE_RX = "\\$V\\s*\\{\\s*([^{}]*)\\s*\\}";
|
||||||
const QString SCRIPT_RX = "\\$S\\s*\\{(.*)\\}";
|
const QString SCRIPT_RX = "\\$S\\s*\\{(.*)\\}";
|
||||||
const QString GROUP_FUNCTION_PARAM_RX = "\\(\\s*(((?:\\\"?\\$D\\s*\\{\\s*)|(?:\\\"?\\$V\\s*\\{\\s*)|(?:\\\"))(\\w+\\.?\\w+)((?:\\\")|(?:\\s*\\}\\\"?\\s*)))\\s*,\\s*\\\"(\\w+)\\\"\\s*\\)";
|
|
||||||
const int DATASOURCE_INDEX = 6;
|
//const QString GROUP_FUNCTION_PARAM_RX = "\\(\\s*(((?:\\\"?\\$D\\s*\\{\\s*)|(?:\\\"?\\$V\\s*\\{\\s*)|(?:\\\"))(\\w+\\.?\\w+)((?:\\\")|(?:\\s*\\}\\\"?\\s*)))\\s*,\\s*\\\"(\\w+)\\\"\\s*\\)";
|
||||||
|
//const int DATASOURCE_INDEX = 6;
|
||||||
|
//const int VALUE_INDEX = 2;
|
||||||
|
|
||||||
|
const QString GROUP_FUNCTION_PARAM_RX = "\\(\\s*(?:(?:((?:(?:\\\"?\\$D\\s*\\{\\s*)|(?:\\\"?\\$V\\s*\\{\\s*)|(?:\\\"))((?:\\w+\\.?\\w+)|(?:\\w+))(?:(?:\\\")|(?:\\s*\\}\\\"?\\s*)))\\s*,)|(?:))\\s*\\\"(\\w+)\\\"\\s*\\)";
|
||||||
|
const int DATASOURCE_INDEX = 4;
|
||||||
const int VALUE_INDEX = 2;
|
const int VALUE_INDEX = 2;
|
||||||
|
const int EXPRESSION_ARGUMENT_INDEX = 3;
|
||||||
|
|
||||||
const QString GROUP_FUNCTION_RX = "(%1\\s*"+GROUP_FUNCTION_PARAM_RX+")";
|
const QString GROUP_FUNCTION_RX = "(%1\\s*"+GROUP_FUNCTION_PARAM_RX+")";
|
||||||
const QString GROUP_FUNCTION_NAME_RX = "%1\\s*\\((.*[^\\)])\\)";
|
const QString GROUP_FUNCTION_NAME_RX = "%1\\s*\\((.*[^\\)])\\)";
|
||||||
const int SCENE_MARGIN = 50;
|
const int SCENE_MARGIN = 50;
|
||||||
|
@ -77,9 +77,16 @@ namespace Const{
|
|||||||
const QString FIELD_RX = "\\$D\\s*\\{\\s*([^{}]*)\\s*\\}";
|
const QString FIELD_RX = "\\$D\\s*\\{\\s*([^{}]*)\\s*\\}";
|
||||||
const QString VARIABLE_RX = "\\$V\\s*\\{\\s*([^{}]*)\\s*\\}";
|
const QString VARIABLE_RX = "\\$V\\s*\\{\\s*([^{}]*)\\s*\\}";
|
||||||
const QString SCRIPT_RX = "\\$S\\s*\\{(.*)\\}";
|
const QString SCRIPT_RX = "\\$S\\s*\\{(.*)\\}";
|
||||||
const QString GROUP_FUNCTION_PARAM_RX = "\\(\\s*(((?:\\\"?\\$D\\s*\\{\\s*)|(?:\\\"?\\$V\\s*\\{\\s*)|(?:\\\"))(\\w+\\.?\\w+)((?:\\\")|(?:\\s*\\}\\\"?\\s*)))\\s*,\\s*\\\"(\\w+)\\\"\\s*\\)";
|
|
||||||
const int DATASOURCE_INDEX = 6;
|
//const QString GROUP_FUNCTION_PARAM_RX = "\\(\\s*(((?:\\\"?\\$D\\s*\\{\\s*)|(?:\\\"?\\$V\\s*\\{\\s*)|(?:\\\"))(\\w+\\.?\\w+)((?:\\\")|(?:\\s*\\}\\\"?\\s*)))\\s*,\\s*\\\"(\\w+)\\\"\\s*\\)";
|
||||||
|
//const int DATASOURCE_INDEX = 6;
|
||||||
|
//const int VALUE_INDEX = 2;
|
||||||
|
|
||||||
|
const QString GROUP_FUNCTION_PARAM_RX = "\\(\\s*(?:(?:((?:(?:\\\"?\\$D\\s*\\{\\s*)|(?:\\\"?\\$V\\s*\\{\\s*)|(?:\\\"))((?:\\w+\\.?\\w+)|(?:\\w+))(?:(?:\\\")|(?:\\s*\\}\\\"?\\s*)))\\s*,)|(?:))\\s*\\\"(\\w+)\\\"\\s*\\)";
|
||||||
|
const int DATASOURCE_INDEX = 4;
|
||||||
const int VALUE_INDEX = 2;
|
const int VALUE_INDEX = 2;
|
||||||
|
const int EXPRESSION_ARGUMENT_INDEX = 3;
|
||||||
|
|
||||||
const QString GROUP_FUNCTION_RX = "(%1\\s*"+GROUP_FUNCTION_PARAM_RX+")";
|
const QString GROUP_FUNCTION_RX = "(%1\\s*"+GROUP_FUNCTION_PARAM_RX+")";
|
||||||
const QString GROUP_FUNCTION_NAME_RX = "%1\\s*\\((.*[^\\)])\\)";
|
const QString GROUP_FUNCTION_NAME_RX = "%1\\s*\\((.*[^\\)])\\)";
|
||||||
const int SCENE_MARGIN = 50;
|
const int SCENE_MARGIN = 50;
|
||||||
|
@ -57,7 +57,10 @@ void GroupFunction::slotBandRendered(BandDesignIntf *band)
|
|||||||
ContentItemDesignIntf* item = dynamic_cast<ContentItemDesignIntf*>(band->childByName(m_data));
|
ContentItemDesignIntf* item = dynamic_cast<ContentItemDesignIntf*>(band->childByName(m_data));
|
||||||
if (item)
|
if (item)
|
||||||
m_values.push_back(item->content());
|
m_values.push_back(item->content());
|
||||||
else setInvalid(tr("Item \"%1\" not found").arg(m_data));
|
else if (m_name.compare("COUNT",Qt::CaseInsensitive) == 0) {
|
||||||
|
m_values.push_back(1);
|
||||||
|
} else setInvalid(tr("Item \"%1\" not found").arg(m_data));
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
@ -368,7 +368,7 @@ void ReportRender::replaceGroupsFunction(BandDesignIntf *band)
|
|||||||
if (rx.indexIn(content)>=0){
|
if (rx.indexIn(content)>=0){
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
while ( (pos = rx.indexIn(content,pos))!= -1 ){
|
while ( (pos = rx.indexIn(content,pos))!= -1 ){
|
||||||
content.replace(rx.capturedTexts().at(0),QString("%1(%2,%3)").arg(functionName).arg('"'+rx.cap(4)+'"').arg('"'+band->objectName()+'"'));
|
content.replace(rx.capturedTexts().at(0),QString("%1(%2,%3)").arg(functionName).arg('"'+rx.cap(Const::EXPRESSION_ARGUMENT_INDEX)+'"').arg('"'+band->objectName()+'"'));
|
||||||
pos += rx.matchedLength();
|
pos += rx.matchedLength();
|
||||||
}
|
}
|
||||||
contentItem->setContent(content);
|
contentItem->setContent(content);
|
||||||
|
@ -302,8 +302,17 @@ QScriptValue callGroupFunction(const QString& functionName, QScriptContext* pcon
|
|||||||
ScriptEngineManager* sm = qscriptvalue_cast<ScriptEngineManager*>(pcontext->callee().data());
|
ScriptEngineManager* sm = qscriptvalue_cast<ScriptEngineManager*>(pcontext->callee().data());
|
||||||
DataSourceManager* dm = sm->dataManager();
|
DataSourceManager* dm = sm->dataManager();
|
||||||
|
|
||||||
QString expression = pcontext->argument(0).toString();
|
QString expression;
|
||||||
QString band = pcontext->argument(1).toString();
|
QString band;
|
||||||
|
|
||||||
|
if (functionName.compare("COUNT",Qt::CaseInsensitive) == 0 && pcontext->argumentCount()==1){
|
||||||
|
expression = " ";
|
||||||
|
band = pcontext->argument(0).toString();
|
||||||
|
} else {
|
||||||
|
expression = pcontext->argument(0).toString();
|
||||||
|
band = pcontext->argument(1).toString();
|
||||||
|
}
|
||||||
|
|
||||||
QScriptValue res;
|
QScriptValue res;
|
||||||
GroupFunction* gf = dm->groupFunction(functionName,expression,band);
|
GroupFunction* gf = dm->groupFunction(functionName,expression,band);
|
||||||
if (gf){
|
if (gf){
|
||||||
|
Loading…
Reference in New Issue
Block a user