20 #include <QCoreApplication> 24 QObject::connect( &mFileSystemWatcher, &QFileSystemWatcher::fileChanged,
this, &QgsCapabilitiesCache::removeChangedEntry );
29 QCoreApplication::processEvents();
31 if ( mCachedCapabilities.contains( configFilePath ) && mCachedCapabilities[ configFilePath ].contains( key ) )
33 return &mCachedCapabilities[ configFilePath ][ key ];
43 if ( mCachedCapabilities.size() > 40 )
46 QHash<QString, QHash<QString, QDomDocument> >::iterator capIt = mCachedCapabilities.begin();
47 mFileSystemWatcher.removePath( capIt.key() );
48 mCachedCapabilities.erase( capIt );
51 if ( !mCachedCapabilities.contains( configFilePath ) )
53 mFileSystemWatcher.addPath( configFilePath );
54 mCachedCapabilities.insert( configFilePath, QHash<QString, QDomDocument>() );
57 mCachedCapabilities[ configFilePath ].insert( key, doc->cloneNode().toDocument() );
62 mCachedCapabilities.remove( path );
63 mFileSystemWatcher.removePath( path );
66 void QgsCapabilitiesCache::removeChangedEntry(
const QString &path )
68 QgsDebugMsg( QStringLiteral(
"Remove capabilities cache entry because file changed" ) );
69 mCachedCapabilities.remove( path );
70 mFileSystemWatcher.removePath( path );
void insertCapabilitiesDocument(const QString &configFilePath, const QString &key, const QDomDocument *doc)
Inserts new capabilities document (creates a copy of the document, does not take ownership) ...
const QDomDocument * searchCapabilitiesDocument(const QString &configFilePath, const QString &key)
Returns cached capabilities document (or 0 if document for configuration file not in cache) ...
void removeCapabilitiesDocument(const QString &path)
Remove capabilities document.