Expose list of projects in cache to Python

This commit is contained in:
Blottiere Paul 2023-01-16 10:26:55 +01:00
parent 0a1f4332eb
commit 44b8ed25ab
3 changed files with 26 additions and 0 deletions

View File

@ -66,6 +66,13 @@ value is ``False``).
Returns the name of the current strategy
.. versionadded:: 3.26
%End
QMap<QString, QDateTime> projects() const;
%Docstring
Returns projects currently in cache.
.. versionadded:: 3.30
%End
public:

View File

@ -182,6 +182,19 @@ const QgsProject *QgsConfigCache::project( const QString &path, const QgsServerS
return entry ? entry->second.get() : nullptr;
}
QMap<QString, QDateTime> QgsConfigCache::projects() const
{
QMap<QString, QDateTime> projects;
const auto constKeys { mProjectCache.keys() };
for ( const auto &path : std::as_const( constKeys ) )
{
projects[path] = mProjectCache[path]->first;
}
return projects;
}
QDomDocument *QgsConfigCache::xmlDocument( const QString &filePath )
{
//first open file

View File

@ -117,6 +117,12 @@ class SERVER_EXPORT QgsConfigCache : public QObject
*/
QString strategyName() const { return mStrategy->name(); }
/**
* Returns projects currently in cache.
* \since QGIS 3.30
*/
QMap<QString, QDateTime> projects() const;
public:
//! Initialize from settings
QgsConfigCache( QgsServerSettings *settings );