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:
@@ -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))
|
||||
|
Reference in New Issue
Block a user