mirror of
https://github.com/fralx/LimeReport.git
synced 2024-12-25 00:54:39 +03:00
Finish 1.4.41
This commit is contained in:
commit
2a6fae262b
@ -76,6 +76,7 @@ namespace Const{
|
||||
const qreal SELECTION_OPACITY = 0.3;
|
||||
const QString FIELD_RX = "\\$D\\s*\\{\\s*([^{}]*)\\s*\\}";
|
||||
const QString VARIABLE_RX = "\\$V\\s*\\{\\s*([^{}]*)\\s*\\}";
|
||||
const QString NAMED_VARIABLE_RX = "\\$V\\s*\\{\\s*(%1)\\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*\\)";
|
||||
|
@ -228,6 +228,16 @@ DataSourceManager::DataSourceManager(QObject *parent) :
|
||||
setSystemVariable(QLatin1String("#PAGE_COUNT"),0,SecondPass);
|
||||
setSystemVariable(QLatin1String("#IS_LAST_PAGEFOOTER"),false,FirstPass);
|
||||
setSystemVariable(QLatin1String("#IS_FIRST_PAGEFOOTER"),false,FirstPass);
|
||||
|
||||
connect(&m_reportVariables, SIGNAL(variableHasBeenAdded(QString)),
|
||||
this, SLOT(slotVariableHasBeenAdded(QString)) );
|
||||
connect(&m_reportVariables, SIGNAL(variableHasBeenChanged(QString)),
|
||||
this, SLOT(slotVariableHasBeenChanged(QString)));
|
||||
connect(&m_userVariables, SIGNAL(variableHasBeenAdded(QString)),
|
||||
this, SLOT(slotVariableHasBeenAdded(QString)) );
|
||||
connect(&m_userVariables, SIGNAL(variableHasBeenChanged(QString)),
|
||||
this, SLOT(slotVariableHasBeenChanged(QString)));
|
||||
|
||||
m_datasourcesModel.setDataSourceManager(this);
|
||||
}
|
||||
|
||||
@ -1235,6 +1245,32 @@ void DataSourceManager::slotQueryTextChanged(const QString &queryName, const QSt
|
||||
}
|
||||
}
|
||||
|
||||
void DataSourceManager::invalidateQueriesContainsVariable(const QString& variableName)
|
||||
{
|
||||
if (!variableIsSystem(variableName)){
|
||||
foreach (const QString& datasourceName, dataSourceNames()){
|
||||
QueryHolder* holder = dynamic_cast<QueryHolder*>(m_datasources.value(datasourceName));
|
||||
if (holder){
|
||||
QRegExp rx(QString(Const::NAMED_VARIABLE_RX).arg(variableName));
|
||||
if (holder->queryText().contains(rx))
|
||||
holder->invalidate(designTime()?IDataSource::DESIGN_MODE:IDataSource::RENDER_MODE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DataSourceManager::slotVariableHasBeenAdded(const QString& variableName)
|
||||
{
|
||||
//qDebug()<< "variable has been added"<< variableName;
|
||||
invalidateQueriesContainsVariable(variableName);
|
||||
}
|
||||
|
||||
void DataSourceManager::slotVariableHasBeenChanged(const QString& variableName)
|
||||
{
|
||||
//qDebug()<< "variable has been changed"<< variableName;
|
||||
invalidateQueriesContainsVariable(variableName);
|
||||
}
|
||||
|
||||
void DataSourceManager::clear(ClearMethod method)
|
||||
{
|
||||
DataSourcesMap::iterator dit;
|
||||
|
@ -224,9 +224,12 @@ protected:
|
||||
void setLastError(const QString& value);
|
||||
void invalidateLinkedDatasources(QString datasourceName);
|
||||
bool checkConnection(QSqlDatabase db);
|
||||
void invalidateQueriesContainsVariable(const QString& variableName);
|
||||
private slots:
|
||||
void slotConnectionRenamed(const QString& oldName,const QString& newName);
|
||||
void slotQueryTextChanged(const QString& queryName, const QString& queryText);
|
||||
void slotVariableHasBeenAdded(const QString& variableName);
|
||||
void slotVariableHasBeenChanged(const QString& variableName);
|
||||
private:
|
||||
explicit DataSourceManager(QObject *parent = 0);
|
||||
bool initAndOpenDB(QSqlDatabase &db, ConnectionDesc &connectionDesc);
|
||||
|
@ -76,6 +76,7 @@ namespace Const{
|
||||
const qreal SELECTION_OPACITY = 0.3;
|
||||
const QString FIELD_RX = "\\$D\\s*\\{\\s*([^{}]*)\\s*\\}";
|
||||
const QString VARIABLE_RX = "\\$V\\s*\\{\\s*([^{}]*)\\s*\\}";
|
||||
const QString NAMED_VARIABLE_RX = "\\$V\\s*\\{\\s*(%1)\\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*\\)";
|
||||
|
@ -216,7 +216,11 @@ QScriptValue setVariable(QScriptContext* pcontext, QScriptEngine* /*pengine*/){
|
||||
ScriptEngineManager* sm = qscriptvalue_cast<ScriptEngineManager*>(pcontext->callee().data());
|
||||
DataSourceManager* dm = sm->dataManager();
|
||||
|
||||
if (dm->containsVariable(name))
|
||||
dm->changeVariable(name,value);
|
||||
else
|
||||
dm->addVariable(name, value);
|
||||
|
||||
return QScriptValue();
|
||||
}
|
||||
|
||||
|
@ -61,6 +61,7 @@ void VariablesHolder::addVariable(const QString& name, const QVariant& value, Va
|
||||
m_varNames.insert(name,varValue);
|
||||
if (type==VarDesc::Report)
|
||||
m_userVariables.append(varValue);
|
||||
emit variableHasBeenAdded(name);
|
||||
} else {
|
||||
throw ReportError(tr("variable with name ")+name+tr(" already exists!"));
|
||||
}
|
||||
@ -86,6 +87,7 @@ void VariablesHolder::deleteVariable(const QString &name)
|
||||
m_userVariables.removeOne(m_varNames.value(name));
|
||||
delete m_varNames.value(name);
|
||||
m_varNames.remove(name);
|
||||
emit variableHasBennDeleted(name);
|
||||
}
|
||||
}
|
||||
|
||||
@ -93,6 +95,7 @@ void VariablesHolder::changeVariable(const QString &name, const QVariant &value)
|
||||
{
|
||||
if(m_varNames.contains(name)) {
|
||||
m_varNames.value(name)->setValue(value);
|
||||
emit variableHasBeenChanged(name);
|
||||
} else
|
||||
throw ReportError(tr("variable with name ")+name+tr(" does not exists!"));
|
||||
}
|
||||
|
@ -92,6 +92,9 @@ public:
|
||||
int userVariablesCount();
|
||||
VarDesc* userVariableAt(int index);
|
||||
signals:
|
||||
void variableHasBeenAdded(const QString& variableName);
|
||||
void variableHasBeenChanged(const QString& variableName);
|
||||
void variableHasBennDeleted(const QString& variableName);
|
||||
private:
|
||||
QMap<QString,VarDesc*> m_varNames;
|
||||
QList<VarDesc*> m_userVariables;
|
||||
|
Loading…
Reference in New Issue
Block a user