digiKam
Digikam::CollectionManager Class Reference
+ Inheritance diagram for Digikam::CollectionManager:

Classes

class  Private
 

Public Types

enum  LocationCheckResult { LocationInvalidCheck , LocationAllRight , LocationHasProblems , LocationNotAllowed }
 

Signals

void triggerUpdateVolumesList ()
 

Public Member Functions

void refresh ()
 
void setWatchDisabled ()
 

Static Public Member Functions

static void cleanUp ()
 
static CollectionManagerinstance ()
 

Operations on Albums

class Private
 
class CoreDbWatch
 
class CoreDbAccess
 
QStringList allAvailableAlbumRootPaths ()
 
QString albumRootPath (int id)
 
QString albumRootLabel (int id)
 
QUrl albumRoot (const QUrl &fileUrl)
 
QString albumRootPath (const QUrl &fileUrl)
 
QString albumRootPath (const QString &filePath)
 
bool isAlbumRoot (const QUrl &fileUrl)
 
bool isAlbumRoot (const QString &filePath)
 
QString album (const QUrl &fileUrl)
 
QString album (const QString &filePath)
 
QString album (const CollectionLocation &location, const QUrl &fileUrl)
 
QString album (const CollectionLocation &location, const QString &filePath)
 
QUrl oneAlbumRoot ()
 
QString oneAlbumRootPath ()
 

Operations on Collection Location

CollectionLocation addLocation (const QUrl &fileUrl, const QString &label=QString())
 
CollectionLocation addNetworkLocation (const QUrl &fileUrl, const QString &label=QString())
 
CollectionLocation refreshLocation (const CollectionLocation &location, int newType, const QUrl &fileUrl, const QString &label=QString())
 
LocationCheckResult checkLocation (const QUrl &fileUrl, QList< CollectionLocation > &assumeDeleted, QString *message=nullptr, QString *suggestedMessageIconName=nullptr)
 
LocationCheckResult checkNetworkLocation (const QUrl &fileUrl, QList< CollectionLocation > &assumeDeleted, QString *message=nullptr, QString *suggestedMessageIconName=nullptr)
 
void removeLocation (const CollectionLocation &location)
 
void setLabel (const CollectionLocation &location, const QString &label)
 
void changeType (const CollectionLocation &location, int type)
 
QList< CollectionLocationcheckHardWiredLocations ()
 
void migrationCandidates (const CollectionLocation &disappearedLocation, QString *const technicalDescription, QStringList *const candidateIdentifiers, QStringList *const candidateDescriptions)
 
void migrateToVolume (const CollectionLocation &location, const QString &identifier)
 
QList< CollectionLocationallLocations ()
 
QList< CollectionLocationallAvailableLocations ()
 
CollectionLocation locationForAlbumRootId (int id)
 
CollectionLocation locationForAlbumRoot (const QUrl &fileUrl)
 
CollectionLocation locationForAlbumRootPath (const QString &albumRootPath)
 
CollectionLocation locationForUrl (const QUrl &fileUrl)
 
CollectionLocation locationForPath (const QString &filePath)
 
void locationStatusChanged (const CollectionLocation &location, int oldStatus)
 
void locationPropertiesChanged (const CollectionLocation &location)
 

Member Enumeration Documentation

◆ LocationCheckResult

Enumerator
LocationInvalidCheck 

The check did not succeed, status unknown.

LocationAllRight 

All right. The accompanying message may be empty.

LocationHasProblems 

Location can be added, but the user should be aware of a problem.

LocationNotAllowed 

Adding the location will fail (e.g. there is already a location for the path)

Member Function Documentation

◆ addLocation()

CollectionLocation Digikam::CollectionManager::addLocation ( const QUrl &  fileUrl,
const QString &  label = QString() 
)

Add the given file system location as new collection location. Type and availability will be detected. On failure returns null. This would be the case if the given url is already contained in another collection location. You may pass an optional user-visible label that will be stored in the database. The label has no further meaning and can be freely chosen.

CollectionLocation objects returned are simple data containers. If the corresponding location is returned, the data is still safe to access, but does not represent anything. Therefore, do not store returned objects, but prefer to retrieve them freshly.

References CoreDbAccess, Digikam::CollectionManager::Private::findVolumeForUrl(), Digikam::SolidVolumeInfo::isNull(), Digikam::SolidVolumeInfo::isRemovable, Digikam::CollectionManager::Private::listVolumes(), locationForPath(), Digikam::SolidVolumeInfo::path, Digikam::AlbumRoot::VolumeHardWired, Digikam::CollectionManager::Private::volumeIdentifier(), and Digikam::AlbumRoot::VolumeRemovable.

Referenced by Digikam::SetupCollectionModel::apply(), and Digikam::AlbumManager::setDatabase().

◆ addNetworkLocation()

CollectionLocation Digikam::CollectionManager::addNetworkLocation ( const QUrl &  fileUrl,
const QString &  label = QString() 
)

◆ album() [1/4]

QString Digikam::CollectionManager::album ( const CollectionLocation location,
const QString &  filePath 
)

◆ album() [2/4]

QString Digikam::CollectionManager::album ( const CollectionLocation location,
const QUrl &  fileUrl 
)

◆ album() [3/4]

QString Digikam::CollectionManager::album ( const QString &  filePath)

◆ album() [4/4]

QString Digikam::CollectionManager::album ( const QUrl &  fileUrl)

Returns the album part of the given file path, i.e. the album root path at the beginning is removed and the second part, starting with "/", ending without a slash, is returned. Example: "/media/fotos/Paris 2007" gives "/Paris 2007" Returns a null QString if the file path is not located in an album root. Returns "/" if the file path is an album root. Note that trailing slashes are removed in the return value, regardless if there was one or not. Note that you have to feed a path/url pointing to a directory. File names cannot be recognized as such by this method, and will be treated as a directory.

Referenced by album(), Digikam::CollectionScanner::countItemsInFolder(), Digikam::AlbumManager::findPAlbum(), Digikam::CollectionScanner::finishCompleteScan(), Digikam::ItemInfo::fromLocalFile(), Digikam::ScanController::hintAtMoveOrCopyOfAlbum(), Digikam::CollectionScanner::partialScan(), Digikam::ItemScanner::resolveHistoryImageId(), and Digikam::CollectionScanner::scanFile().

◆ albumRoot()

QUrl Digikam::CollectionManager::albumRoot ( const QUrl &  fileUrl)

For a given path, the part of the path that forms the album root is returned, ending without a slash. Example: "/media/fotos/Paris 2007" gives "/media/fotos". Only available (or hidden, but available) album roots are guaranteed to be found.

References albumRootPath().

◆ albumRootLabel()

QString Digikam::CollectionManager::albumRootLabel ( int  id)

Returns the album root label with the given id. Returns a null QString if the root path does not exist or is not available.

References Digikam::RedEye::location(), Digikam::CollectionLocation::LocationAvailable, Digikam::CollectionManager::Private::locations, and Digikam::CollectionManager::Private::lock.

Referenced by Digikam::PAlbum::albumRootLabel().

◆ albumRootPath() [1/3]

QString Digikam::CollectionManager::albumRootPath ( const QString &  filePath)

◆ albumRootPath() [2/3]

QString Digikam::CollectionManager::albumRootPath ( const QUrl &  fileUrl)

References albumRootPath().

◆ albumRootPath() [3/3]

◆ allAvailableAlbumRootPaths()

QStringList Digikam::CollectionManager::allAvailableAlbumRootPaths ( )

◆ allAvailableLocations()

QList< CollectionLocation > Digikam::CollectionManager::allAvailableLocations ( )

◆ allLocations()

QList< CollectionLocation > Digikam::CollectionManager::allLocations ( )

◆ changeType()

◆ checkHardWiredLocations()

QList< CollectionLocation > Digikam::CollectionManager::checkHardWiredLocations ( )

Checks the locations of type HardWired. If one of these is not available currently, it is added to the list of disappeared locations. This case may happen if a file system is changed, a backup restored or other actions taken that change the UUID, although the data may still be available and mounted. If there are hard-wired volumes available which are candidates for a newly appeared volume (in fact those that do not contain any collections currently), they are added to the map, identifier -> i18n'ed user presentable description. The identifier can be used for changeVolume.

References Digikam::CollectionManager::Private::listVolumes(), Digikam::RedEye::location(), Digikam::CollectionManager::Private::locations, Digikam::CollectionLocation::LocationUnavailable, Digikam::CollectionManager::Private::lock, and Digikam::CollectionLocation::TypeVolumeHardWired.

Referenced by Digikam::AlbumManager::setDatabase().

◆ checkLocation()

CollectionManager::LocationCheckResult Digikam::CollectionManager::checkLocation ( const QUrl &  fileUrl,
QList< CollectionLocation > &  assumeDeleted,
QString *  message = nullptr,
QString *  suggestedMessageIconName = nullptr 
)

◆ checkNetworkLocation()

CollectionManager::LocationCheckResult Digikam::CollectionManager::checkNetworkLocation ( const QUrl &  fileUrl,
QList< CollectionLocation > &  assumeDeleted,
QString *  message = nullptr,
QString *  suggestedMessageIconName = nullptr 
)

◆ cleanUp()

void Digikam::CollectionManager::cleanUp ( )
static

◆ instance()

CollectionManager * Digikam::CollectionManager::instance ( )
static

Referenced by Digikam::PAlbum::albumRootLabel(), Digikam::PAlbum::albumRootPath(), Digikam::ToolTipFiller::albumTipContents(), Digikam::SetupCollectionModel::apply(), Digikam::SetupCollectionModel::askForNewCollectionPath(), Digikam::CoreDbAccess::checkReadyForUse(), Digikam::CollectionScanner::completeScan(), Digikam::CoreDbAccess::CoreDbAccess(), Digikam::CollectionScanner::countItemsInFolder(), Digikam::AlbumManager::createPAlbum(), Digikam::DBInfoIface::defaultUploadUrl(), Digikam::DTrash::deleteImage(), Digikam::ItemInfo::filePath(), Digikam::AlbumManager::findPAlbum(), Digikam::CollectionScanner::finishCompleteScan(), Digikam::CoreDbUrl::fromAlbumAndName(), Digikam::CoreDbUrl::fromFileUrl(), Digikam::ItemInfo::fromLocalFile(), Digikam::CoreDB::getDirtyOrMissingFaceImageUrls(), Digikam::CoreDB::getItemIDsAndURLsInAlbum(), Digikam::CoreDB::getItemsURLsWithTag(), Digikam::CoreDB::getItemURLsInAlbum(), Digikam::CoreDB::getItemURLsInTag(), Digikam::ScanController::hintAtMoveOrCopyOfAlbum(), Digikam::CoreDbWatch::initializeRemote(), Digikam::ItemInfo::isLocationAvailable(), Digikam::ItemScanner::ItemScanner(), Digikam::ItemLister::listPAlbum(), Digikam::SetupCollectionModel::loadCollections(), Digikam::CollectionScanner::partialScan(), Digikam::ItemScanner::resolvedImageHistory(), Digikam::ItemScanner::resolveHistoryImageId(), Digikam::CollectionScanner::scanFile(), Digikam::CollectionScanner::scanForStaleAlbums(), Digikam::AlbumManager::setDatabase(), Digikam::CoreDbAccess::setParameters(), Digikam::AlbumManager::setShowOnlyAvailableAlbums(), Digikam::AlbumWatch::slotAlbumAdded(), Digikam::AlbumModificationHelper::slotAlbumNew(), Digikam::ImportUI::slotDownload(), Digikam::AlbumManager::startScan(), Digikam::ItemInfo::thumbnailInfo(), and Digikam::DatabaseVersionManager::toplevelDirectory().

◆ isAlbumRoot() [1/2]

bool Digikam::CollectionManager::isAlbumRoot ( const QString &  filePath)

The file path should not end with the directory slash. Using CoreDbUrl's method is fine.

References Digikam::RedEye::location(), Digikam::CollectionManager::Private::locations, and Digikam::CollectionManager::Private::lock.

◆ isAlbumRoot() [2/2]

bool Digikam::CollectionManager::isAlbumRoot ( const QUrl &  fileUrl)

Returns true if the given path forms an album root. It will return false if the path is a path below an album root, or if the path does not belong to an album root. Example: "/media/fotos/Paris 2007" is an album with album root "/media/fotos". "/media/fotos" returns true, "/media/fotos/Paris 2007" and "/media" return false. Only available (or hidden, but available) album roots are guaranteed to be found.

◆ locationForAlbumRoot()

CollectionLocation Digikam::CollectionManager::locationForAlbumRoot ( const QUrl &  fileUrl)

Returns the CollectionLocation that contains the given album root. The path must be an album root with isAlbumRoot() == true. Returns 0 if no collection location matches. Only available (or hidden, but available) locations are guaranteed to be found.

References locationForAlbumRootPath().

Referenced by Digikam::CoreDbUrl::fromAlbumAndName(), and Digikam::CoreDbUrl::fromFileUrl().

◆ locationForAlbumRootId()

◆ locationForAlbumRootPath()

◆ locationForPath()

◆ locationForUrl()

CollectionLocation Digikam::CollectionManager::locationForUrl ( const QUrl &  fileUrl)

Returns the CollectionLocation that contains the given path. Equivalent to calling locationForAlbumRoot(albumRoot(fileUrl)). Only available (or hidden, but available) locations are guaranteed to be found.

References locationForPath().

Referenced by Digikam::AlbumManager::findPAlbum().

◆ locationPropertiesChanged

void Digikam::CollectionManager::locationPropertiesChanged ( const CollectionLocation location)
signal

Emitted when the label of a collection location is changed

Referenced by changeType(), refreshLocation(), and setLabel().

◆ locationStatusChanged

void Digikam::CollectionManager::locationStatusChanged ( const CollectionLocation location,
int  oldStatus 
)
signal

Emitted when the status of a collection location changed. This means that the location became available, hidden or unavailable.

An added location will change its status after addition, from Null to Available, Hidden or Unavailable.

A removed location will change its status to Deleted during the removal; in this case, you shall not use the object passed with this signal with any method of CollectionManager.

The second signal argument is of type CollectionLocation::Status and describes the status before the state change occurred

◆ migrateToVolume()

void Digikam::CollectionManager::migrateToVolume ( const CollectionLocation location,
const QString &  identifier 
)

Migrates the existing collection to a new volume, identified by an internal identifier as returned by checkHardWiredLocations(). Use this only to react to changes like those detailed for checkHardWiredLocations; the actual data pointed to shall be unchanged.

References CoreDbAccess, Digikam::CollectionLocation::id(), Digikam::AlbumRootLocation::identifier, Digikam::RedEye::location(), Digikam::CollectionManager::Private::locations, and Digikam::CollectionManager::Private::lock.

Referenced by Digikam::AlbumManager::setDatabase().

◆ migrationCandidates()

void Digikam::CollectionManager::migrationCandidates ( const CollectionLocation disappearedLocation,
QString *const  technicalDescription,
QStringList *const  candidateIdentifiers,
QStringList *const  candidateDescriptions 
)

For a given disappeared location (retrieved from checkHardWiredLocations()) retrieve a user-presentable technical description (excluding the CollectionLocation's label) and a list of identifiers and corresponding user presentable strings of candidates to where the given location may have been moved.

References Digikam::SolidVolumeInfo::isMounted, Digikam::CollectionManager::Private::listVolumes(), Digikam::RedEye::location(), Digikam::CollectionManager::Private::locations, Digikam::CollectionManager::Private::lock, Digikam::SolidVolumeInfo::path, Digikam::AlbumRootLocation::specificPath, Digikam::CollectionManager::Private::technicalDescription(), and Digikam::CollectionManager::Private::volumeIdentifier().

Referenced by Digikam::AlbumManager::setDatabase().

◆ oneAlbumRoot()

QUrl Digikam::CollectionManager::oneAlbumRoot ( )

Returns just one album root, out of the list of available location, the one that is most suitable to serve as a default, e.g. to suggest as default place when the user wants to add files.

References oneAlbumRootPath().

◆ oneAlbumRootPath()

◆ refresh()

void Digikam::CollectionManager::refresh ( )

Clears all locations and re-reads the lists of collection locations. Enables the watch.

Referenced by Digikam::CoreDbAccess::checkReadyForUse(), and Digikam::CoreDbAccess::CoreDbAccess().

◆ refreshLocation()

◆ removeLocation()

void Digikam::CollectionManager::removeLocation ( const CollectionLocation location)

◆ setLabel()

◆ setWatchDisabled()

void Digikam::CollectionManager::setWatchDisabled ( )

Disables the collection watch. It will be reenabled as soon as refresh() is called or any other action triggered.

References Digikam::CollectionManager::Private::watchEnabled.

Referenced by Digikam::AlbumManager::setDatabase().

◆ triggerUpdateVolumesList

void Digikam::CollectionManager::triggerUpdateVolumesList ( )
signal

Friends And Related Function Documentation

◆ CoreDbAccess

◆ CoreDbWatch

friend class CoreDbWatch
friend

◆ Private

friend class Private
friend

The documentation for this class was generated from the following files: