Skip to content

Commit

Permalink
Expose list of projects in cache to Python
Browse files Browse the repository at this point in the history
  • Loading branch information
pblottiere committed Jan 24, 2023
1 parent 0a1f433 commit 44b8ed2
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
7 changes: 7 additions & 0 deletions python/server/auto_generated/qgsconfigcache.sip.in
Expand Up @@ -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:
Expand Down
13 changes: 13 additions & 0 deletions src/server/qgsconfigcache.cpp
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions src/server/qgsconfigcache.h
Expand Up @@ -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 );
Expand Down

0 comments on commit 44b8ed2

Please sign in to comment.