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

View File

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