0
0
mirror of https://github.com/fralx/LimeReport.git synced 2025-10-09 14:04:43 +03:00

The update of data sources was added if they contain changed variables

This commit is contained in:
Arin Alexander
2017-09-19 21:02:55 +03:00
parent c9b6078fa8
commit 1af031f19c
6 changed files with 82 additions and 3 deletions

View File

@@ -229,6 +229,17 @@ DataSourceManager::DataSourceManager(QObject *parent) :
setSystemVariable(QLatin1String("#IS_LAST_PAGEFOOTER"),false,FirstPass);
setSystemVariable(QLatin1String("#IS_FIRST_PAGEFOOTER"),false,FirstPass);
m_datasourcesModel.setDataSourceManager(this);
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)));
}
QString DataSourceManager::defaultDatabasePath() const
@@ -1188,6 +1199,7 @@ void DataSourceManager::changeVariable(const QString& name,const QVariant& value
if (m_reportVariables.containsVariable(name)){
m_reportVariables.changeVariable(name,value);
}
}
void DataSourceManager::setSystemVariable(const QString &name, const QVariant &value, RenderPass pass)
@@ -1236,6 +1248,30 @@ void DataSourceManager::slotQueryTextChanged(const QString &queryName, const QSt
}
}
void DataSourceManager::invalidateQueriesContainsVariable(const QString& 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;
@@ -1386,6 +1422,15 @@ QVariant DataSourceManager::fieldDataByKey(const QString& datasourceName, const
return QVariant();
}
void DataSourceManager::reopenDatasource(const QString& datasourceName)
{
QueryHolder* qh = dynamic_cast<QueryHolder*>(dataSourceHolder(datasourceName));
if (qh){
qh->invalidate(designTime()?IDataSource::DESIGN_MODE:IDataSource::RENDER_MODE);
invalidateChildren(datasourceName);
}
}
QVariant DataSourceManager::variable(const QString &variableName)
{
if (m_userVariables.containsVariable(variableName))