digiKam
collectionmanager.h
Go to the documentation of this file.
1 /* ============================================================
2  *
3  * This file is a part of digiKam project
4  * https://www.digikam.org
5  *
6  * Date : 2007-04-09
7  * Description : Collection location management
8  *
9  * Copyright (C) 2007-2009 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
10  *
11  * This program is free software; you can redistribute it
12  * and/or modify it under the terms of the GNU General
13  * Public License as published by the Free Software Foundation;
14  * either version 2, or (at your option)
15  * any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU General Public License for more details.
21  *
22  * ============================================================ */
23 
24 #ifndef DIGIKAM_COLLECTION_MANAGER_H
25 #define DIGIKAM_COLLECTION_MANAGER_H
26 
27 // Qt includes
28 
29 #include <QString>
30 #include <QStringList>
31 #include <QUrl>
32 #include <QObject>
33 
34 // Local includes
35 
36 #include "digikam_export.h"
37 
38 namespace Digikam
39 {
40 
41 class CollectionLocation;
42 class AlbumRootChangeset;
43 
44 class DIGIKAM_DATABASE_EXPORT CollectionManager : public QObject
45 {
46  Q_OBJECT
47 
48 public:
49 
51  {
54 
57 
60 
62  LocationNotAllowed
63  };
64 
65 public:
66 
67  static CollectionManager* instance();
68  static void cleanUp();
69 
75  void setWatchDisabled();
76 
81  void refresh();
82 
83 private Q_SLOTS:
84 
85  void deviceAdded(const QString&);
86  void deviceRemoved(const QString&);
87  void accessibilityChanged(bool, const QString&);
88 
89 private:
90 
91  // Disabled
93  explicit CollectionManager(QObject*) = delete;
94  ~CollectionManager() override;
95 
96  void clearLocations();
97 
98  Q_PRIVATE_SLOT(d, void slotTriggerUpdateVolumesList())
99 
100 Q_SIGNALS: // internal use only with slotTriggerUpdateVolumesList()
101 
102  void triggerUpdateVolumesList();
103 
104  // -----------------------------------------------------------------------------
105 
110 
111 public:
112 
126  CollectionLocation addLocation(const QUrl& fileUrl, const QString& label = QString());
127  CollectionLocation addNetworkLocation(const QUrl& fileUrl, const QString& label = QString());
128  CollectionLocation refreshLocation(const CollectionLocation& location, int newType,
129  const QUrl& fileUrl, const QString& label = QString());
130 
137  LocationCheckResult checkLocation(const QUrl& fileUrl, QList<CollectionLocation>& assumeDeleted,
138  QString* message = nullptr, QString* suggestedMessageIconName = nullptr);
139  LocationCheckResult checkNetworkLocation(const QUrl& fileUrl, QList<CollectionLocation>& assumeDeleted,
140  QString* message = nullptr, QString* suggestedMessageIconName = nullptr);
141 
146  void removeLocation(const CollectionLocation& location);
147 
151  void setLabel(const CollectionLocation& location, const QString& label);
152 
156  void changeType(const CollectionLocation& location, int type);
157 
168  QList<CollectionLocation> checkHardWiredLocations();
169 
176  void migrationCandidates(const CollectionLocation& disappearedLocation,
177  QString* const technicalDescription,
178  QStringList* const candidateIdentifiers,
179  QStringList* const candidateDescriptions);
180 
187  void migrateToVolume(const CollectionLocation& location, const QString& identifier);
188 
192  QList<CollectionLocation> allLocations();
193 
197  QList<CollectionLocation> allAvailableLocations();
198 
202  CollectionLocation locationForAlbumRootId(int id);
203 
210  CollectionLocation locationForAlbumRoot(const QUrl& fileUrl);
211  CollectionLocation locationForAlbumRootPath(const QString& albumRootPath);
212 
218  CollectionLocation locationForUrl(const QUrl& fileUrl);
219  CollectionLocation locationForPath(const QString& filePath);
220 
221 private:
222 
223  void updateLocations();
224 
225 Q_SIGNALS:
226 
241  void locationStatusChanged(const CollectionLocation& location, int oldStatus);
242 
246  void locationPropertiesChanged(const CollectionLocation& location);
247 
249 
250  // -----------------------------------------------------------------------------
251 
256 
257 public:
258 
262  QStringList allAvailableAlbumRootPaths();
263 
268  QString albumRootPath(int id);
269 
274  QString albumRootLabel(int id);
275 
277 
282  QUrl albumRoot(const QUrl& fileUrl);
283  QString albumRootPath(const QUrl& fileUrl);
284  QString albumRootPath(const QString& filePath);
286 
295  bool isAlbumRoot(const QUrl& fileUrl);
296 
300  bool isAlbumRoot(const QString& filePath);
301 
303 
314  QString album(const QUrl& fileUrl);
315  QString album(const QString& filePath);
316  QString album(const CollectionLocation& location, const QUrl& fileUrl);
317  QString album(const CollectionLocation& location, const QString& filePath);
319 
321 
326  QUrl oneAlbumRoot();
327  QString oneAlbumRootPath();
329 
330 private Q_SLOTS:
331 
332  void slotAlbumRootChange(const AlbumRootChangeset& changeset);
333 
335 
336 public:
337 
338  class Private;
339 
340 private:
341 
342  static CollectionManager* m_instance;
343 
344  Private* const d;
345 
346  friend class Private;
347  friend class CoreDbWatch;
348  friend class CoreDbAccess;
349 };
350 
351 } // namespace Digikam
352 
353 #endif // DIGIKAM_COLLECTION_MANAGER_H
Definition: coredbchangesets.h:337
Definition: collectionlocation.h:41
Definition: collectionmanager_p.h:214
Definition: collectionmanager.h:45
LocationCheckResult
Definition: collectionmanager.h:51
@ LocationHasProblems
Location can be added, but the user should be aware of a problem.
Definition: collectionmanager.h:59
@ LocationAllRight
All right. The accompanying message may be empty.
Definition: collectionmanager.h:56
@ LocationInvalidCheck
The check did not succeed, status unknown.
Definition: collectionmanager.h:53
Definition: coredbaccess.h:56
Definition: coredbwatch.h:44
Definition: piwigotalker.h:48
std::vector< T > location(const std::vector< T > &shape, unsigned long idx)
Definition: shapepredictor.h:109
Definition: datefolderview.cpp:43