QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
qgsexternalstorageregistry.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgsexternalstorageregistry.cpp
3  --------------------------------------
4  Date : March 2021
5  Copyright : (C) 2021 by Julien Cabieces
6  Email : julien dot cabieces at oslandia dot com
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 
17 
18 #include "qgsexternalstorage.h"
21 
23 {
24  registerExternalStorage( new QgsSimpleCopyExternalStorage() );
25  registerExternalStorage( new QgsWebDAVExternalStorage() );
26 }
27 
29 {
30  qDeleteAll( mBackends );
31 }
32 
34 {
35  auto it = std::find_if( mBackends.begin(), mBackends.end(), [ = ]( QgsExternalStorage * storage )
36  {
37  return storage->type() == type;
38  } );
39 
40  return it != mBackends.end() ? *it : nullptr;
41 }
42 
43 QList<QgsExternalStorage *> QgsExternalStorageRegistry::externalStorages() const
44 {
45  return mBackends;
46 }
47 
49 {
50  if ( !mBackends.contains( storage ) )
51  mBackends.append( storage );
52 }
53 
55 {
56  const int index = mBackends.indexOf( storage );
57  if ( index >= 0 )
58  {
59  delete mBackends.takeAt( index );
60  }
61 }
QgsExternalStorageRegistry::externalStorageFromType
QgsExternalStorage * externalStorageFromType(const QString &type) const
Returns external storage implementation if the storage type matches one.
Definition: qgsexternalstorageregistry.cpp:33
QgsExternalStorageRegistry::~QgsExternalStorageRegistry
~QgsExternalStorageRegistry()
Destructor.
Definition: qgsexternalstorageregistry.cpp:28
qgssimplecopyexternalstorage_p.h
qgswebdavexternalstorage_p.h
qgsexternalstorageregistry.h
QgsExternalStorageRegistry::QgsExternalStorageRegistry
QgsExternalStorageRegistry()
Constructor - creates a registry of external storage backends.
Definition: qgsexternalstorageregistry.cpp:22
qgsexternalstorage.h
QgsExternalStorageRegistry::externalStorages
QList< QgsExternalStorage * > externalStorages() const
Returns a list of registered project storage implementations.
Definition: qgsexternalstorageregistry.cpp:43
QgsExternalStorage
Abstract interface for external storage - to be implemented by various backends and registered in Qgs...
Definition: qgsexternalstorage.h:36
QgsExternalStorageRegistry::registerExternalStorage
void registerExternalStorage(QgsExternalStorage *storage)
Registers a storage backend and takes ownership of it.
Definition: qgsexternalstorageregistry.cpp:48
QgsExternalStorageRegistry::unregisterExternalStorage
void unregisterExternalStorage(QgsExternalStorage *storage)
Unregisters a storage backend and destroys its instance.
Definition: qgsexternalstorageregistry.cpp:54