0
0
mirror of https://github.com/fralx/LimeReport.git synced 2024-12-25 00:54:39 +03:00

Invalidating data sources have been improved

This commit is contained in:
Arin Alexander 2019-10-16 02:05:25 +03:00
parent b67c483fe2
commit ccec7b4164
2 changed files with 26 additions and 6 deletions

View File

@ -525,6 +525,7 @@ void DataSourceManager::addQuery(const QString &name, const QString &sqlText, co
putQueryDesc(queryDecs); putQueryDesc(queryDecs);
putHolder(name,new QueryHolder(sqlText, connectionName, this)); putHolder(name,new QueryHolder(sqlText, connectionName, this));
m_hasChanges = true; m_hasChanges = true;
m_varToDataSource.clear();
emit datasourcesChanged(); emit datasourcesChanged();
} }
@ -534,6 +535,7 @@ void DataSourceManager::addSubQuery(const QString &name, const QString &sqlText,
putSubQueryDesc(subQueryDesc); putSubQueryDesc(subQueryDesc);
putHolder(name,new SubQueryHolder(sqlText, connectionName, masterDatasource, this)); putHolder(name,new SubQueryHolder(sqlText, connectionName, masterDatasource, this));
m_hasChanges = true; m_hasChanges = true;
m_varToDataSource.clear();
emit datasourcesChanged(); emit datasourcesChanged();
} }
@ -1373,20 +1375,33 @@ void DataSourceManager::slotQueryTextChanged(const QString &queryName, const QSt
if (holder){ if (holder){
holder->setQueryText(queryText); holder->setQueryText(queryText);
} }
m_varToDataSource.clear();
} }
void DataSourceManager::invalidateQueriesContainsVariable(const QString& variableName) void DataSourceManager::invalidateQueriesContainsVariable(const QString& variableName)
{ {
if (!variableIsSystem(variableName)){ if (!variableIsSystem(variableName)){
if (m_varToDataSource.contains(variableName)){
foreach(QString datasourceName, m_varToDataSource.value(variableName)){
QueryHolder* holder = dynamic_cast<QueryHolder*>(m_datasources.value(datasourceName));
if (holder) holder->invalidate(designTime() ? IDataSource::DESIGN_MODE : IDataSource::RENDER_MODE);
}
} else {
QVector<QString> datasources;
foreach (const QString& datasourceName, dataSourceNames()){ foreach (const QString& datasourceName, dataSourceNames()){
QueryHolder* holder = dynamic_cast<QueryHolder*>(m_datasources.value(datasourceName)); QueryHolder* holder = dynamic_cast<QueryHolder*>(m_datasources.value(datasourceName));
if (holder){ if (holder){
QRegExp rx(QString(Const::NAMED_VARIABLE_RX).arg(variableName)); QRegExp rx(QString(Const::NAMED_VARIABLE_RX).arg(variableName));
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);
datasources.append(datasourceName);
} }
} }
} }
m_varToDataSource.insert(variableName, datasources);
}
}
} }
void DataSourceManager::slotVariableHasBeenAdded(const QString& variableName) void DataSourceManager::slotVariableHasBeenAdded(const QString& variableName)
@ -1413,6 +1428,8 @@ void DataSourceManager::slotCSVTextChanged(const QString &csvName, const QString
void DataSourceManager::clear(ClearMethod method) void DataSourceManager::clear(ClearMethod method)
{ {
m_varToDataSource.clear();
DataSourcesMap::iterator dit; DataSourcesMap::iterator dit;
for( dit = m_datasources.begin(); dit != m_datasources.end(); ){ for( dit = m_datasources.begin(); dit != m_datasources.end(); ){
bool owned = (*dit)->isOwned() && (*dit)->isRemovable(); bool owned = (*dit)->isOwned() && (*dit)->isRemovable();

View File

@ -280,6 +280,9 @@ private:
QHash<QString,int> m_groupFunctionsExpressionsMap; QHash<QString,int> m_groupFunctionsExpressionsMap;
QVector<QString> m_groupFunctionsExpressions; QVector<QString> m_groupFunctionsExpressions;
IDbCredentialsProvider* m_dbCredentialsProvider; IDbCredentialsProvider* m_dbCredentialsProvider;
QMap<QString, QVector<QString>> m_varToDataSource;
bool m_hasChanges; bool m_hasChanges;
}; };