digiKam
|
Public Types | |
enum | ApplicationStatus { MainApplication , DatabaseSlave } |
Public Member Functions | |
CoreDbBackend * | backend () const |
CoreDbAccess () | |
CoreDB * | db () const |
QString | lastError () |
void | setLastError (const QString &error) |
~CoreDbAccess () | |
Static Public Member Functions | |
static bool | checkReadyForUse (InitializationObserver *const observer=nullptr) |
static void | cleanUpDatabase () |
static CoreDbWatch * | databaseWatch () |
static void | initDbEngineErrorHandler (DbEngineErrorHandler *const errorhandler) |
static DbEngineParameters | parameters () |
static void | setParameters (const DbEngineParameters ¶meters) |
static void | setParameters (const DbEngineParameters ¶meters, ApplicationStatus status) |
Friends | |
class | CoreDbAccessUnlock |
The CoreDbAccess provides access to the database: Create an instance of this class on the stack to retrieve a pointer to the database. While you hold an instance of CoreDbAccess, the database access is locked for other threads, but not for other processes. This is due to the fact that while databases allow concurrent access (of course), their client libs may not be thread-safe.
When initializing your application, you need to call two methods:
|
explicit |
Create a CoreDbAccess object for the default database. Note that when initializing your app, setParameters need to be called (in a not-yet-multithreaded context) for this to work. If the database is not yet opened, it will be opened. The schema will not be checked, use checkReadyForUse() for a full opening process including schema update and error messages.
References Digikam::CollectionManager::instance(), and Digikam::CollectionManager::refresh().
Digikam::CoreDbAccess::~CoreDbAccess | ( | ) |
CoreDbBackend * Digikam::CoreDbAccess::backend | ( | ) | const |
Retrieve a pointer to the database backend
Referenced by checkReadyForUse(), Digikam::CoreDbTransaction::CoreDbTransaction(), Digikam::ItemLister::listAreaRange(), Digikam::ItemLister::listDateRange(), Digikam::ItemLister::listFaces(), Digikam::ItemLister::listImageTagPropertySearch(), Digikam::ItemLister::listPAlbum(), Digikam::ItemLister::listSearch(), Digikam::ItemLister::listTag(), Digikam::ScanController::run(), and Digikam::CoreDbTransaction::~CoreDbTransaction().
|
static |
Method to one-time initialize a database when new parameters have been set: Make sure that the database is open, that the schema has properly been initialized. If the parameters were not changed, this method has no effect.
References backend(), Digikam::DbEngineConfig::checkReadyForUse(), Digikam::DbEngineAccess::checkReadyForUse(), db(), Digikam::DbEngineConfig::errorMessage(), Digikam::InitializationObserver::finishedSchemaUpdate(), Digikam::CoreDbSchemaUpdater::getLastErrorMessage(), Digikam::CollectionManager::instance(), parameters(), Digikam::CollectionManager::refresh(), Digikam::CoreDbSchemaUpdater::setCoreDbAccess(), setLastError(), Digikam::CoreDbSchemaUpdater::setObserver(), and Digikam::InitializationObserver::UpdateErrorMustAbort.
Referenced by Digikam::ScanController::run().
|
static |
Clean up the database access. When this function has been called, the access can be restored by calling setParameters. Construction a database access object otherwise after calling this method will crash.
References Digikam::ItemInfoStatic::destroy().
|
static |
Return the CoreDbWatch.
Referenced by Digikam::GPSMarkerTiler::GPSMarkerTiler(), Digikam::ItemAlbumModel::ItemAlbumModel(), Digikam::ItemInfoCache::ItemInfoCache(), Digikam::ItemListModel::ItemListModel(), Digikam::ItemModel::ItemModel(), Digikam::ItemPropertiesSideBarDB::ItemPropertiesSideBarDB(), Digikam::DisjointMetadata::Private::makeConnections(), Digikam::MapViewModelHelper::MapViewModelHelper(), Digikam::QueueListView::QueueListView(), Digikam::ScanControllerLoadingCacheFileWatch::ScanControllerLoadingCacheFileWatch(), Digikam::AlbumManager::setDatabase(), Digikam::AlbumManager::startScan(), and Digikam::TableViewModel::TableViewModel().
CoreDB * Digikam::CoreDbAccess::db | ( | ) | const |
Retrieve a pointer to the album database
Referenced by Digikam::TaggingActionFactory::actions(), Digikam::ItemTagPair::addProperty(), Digikam::TagProperties::addProperty(), Digikam::ContextMenuHelper::addRemoveTagsMenu(), Digikam::ItemInfo::addTagPaths(), Digikam::ItemInfo::addToGroup(), Digikam::ItemPosition::apply(), Digikam::ItemComments::apply(), Digikam::SetupMime::applySettings(), Digikam::SetupCollections::applySettings(), Digikam::ItemTagPair::availablePairs(), Digikam::ItemQueryBuilder::buildField(), Digikam::ItemInfo::category(), Digikam::CollectionScanner::checkAlbum(), Digikam::CollectionScanner::checkDeleteRemoved(), checkReadyForUse(), Digikam::ItemInfo::clearGroup(), Digikam::ItemTagPair::clearProperties(), Digikam::ItemScanner::commitAddImage(), Digikam::ItemScanner::commitCopyImageAttributes(), Digikam::ItemScanner::commitImageHistory(), Digikam::ItemScanner::commitImageMetadata(), Digikam::ItemScanner::commitItemInformation(), Digikam::ItemScanner::commitItemPosition(), Digikam::ItemScanner::commitTags(), Digikam::ItemScanner::commitUpdateImage(), Digikam::ItemScanner::commitVideoMetadata(), Digikam::CollectionScanner::completeHistoryScanning(), Digikam::CollectionScanner::completeScan(), Digikam::CollectionScanner::completeScanCleanupPart(), Digikam::CollectionScanner::copyFileProperties(), Digikam::ItemScanner::copyFromSource(), Digikam::ItemInfo::copyItem(), Digikam::ItemCopyright::copyrightInfo(), Digikam::ItemCopyright::copyrightInfos(), Digikam::CollectionScanner::countItemsInFolder(), Digikam::SearchField::createField(), Digikam::AlbumManager::createPAlbum(), Digikam::AlbumManager::createSAlbum(), Digikam::TagsCache::createTag(), Digikam::AlbumManager::createTAlbum(), Digikam::CollectionScanner::databaseInitialScanDone(), Digikam::ItemInfo::dateTime(), Digikam::DBStatDlg::DBStatDlg(), Digikam::AlbumManager::deleteSAlbum(), Digikam::AlbumManager::deleteTAlbum(), Digikam::ItemInfo::dimensions(), Digikam::AbstractAlbumTreeView::doLoadState(), Digikam::ImageWindow::dropEvent(), Digikam::FacesDetector::FacesDetector(), Digikam::ItemInfo::fileSize(), Digikam::ItemScanner::fillCommonContainer(), Digikam::ItemScanner::fillVideoMetadataContainer(), Digikam::ItemInfo::format(), Digikam::ItemInfo::fromLocationAlbumAndName(), Digikam::ItemInfo::fromUniqueHash(), Digikam::ApplicationSettings::getAllFileFilter(), Digikam::ApplicationSettings::getAudioFileFilter(), Digikam::ItemInfo::getDatabaseFieldsRaw(), Digikam::ApplicationSettings::getImageFileFilter(), Digikam::ItemInfoCache::getImageGroupedCount(), Digikam::AlbumManager::getItemFromAlbum(), Digikam::ApplicationSettings::getMovieFileFilter(), Digikam::ApplicationSettings::getRawFileFilter(), Digikam::AlbumManager::getRecentlyAssignedTags(), Digikam::ItemInfo::groupImageId(), Digikam::ItemInfo::hasAncestorImages(), Digikam::ItemInfo::hasDerivedImages(), Digikam::ItemInfo::hasImageHistory(), Digikam::ItemInfo::historyImageId(), Digikam::ItemInfo::imageHistory(), Digikam::HaarIface::imagesFromAlbumsAndTags(), Digikam::CollectionScanner::incrementDeleteRemovedCompleteScanCount(), Digikam::ItemInfo::isRemoved(), Digikam::ItemInfo::isVisible(), Digikam::ItemScanner::ItemScanner(), Digikam::CollectionScanner::itemsWereRemoved(), Digikam::ItemLister::listPAlbum(), Digikam::ItemInfoList::loadGroupImageIds(), Digikam::CollectionScanner::loadNameFilters(), Digikam::ItemInfoList::loadTagIds(), Digikam::ItemInfo::manualOrder(), Digikam::CollectionScanner::markDatabaseAsScanned(), Digikam::ItemInfo::markDerivedFrom(), Digikam::AlbumManager::mergeTAlbum(), Digikam::ItemInfo::modDateTime(), Digikam::AlbumManager::moveTAlbum(), Digikam::ItemInfo::orientation(), Digikam::CollectionScanner::partialScan(), Digikam::ItemInfo::rating(), Digikam::ItemExtendedProperties::readFakeListProperty(), Digikam::ItemExtendedProperties::readProperty(), Digikam::SetupMime::readSettings(), Digikam::HaarIface::rebuildDuplicatesAlbums(), Digikam::HaarIface::Private::rebuildSignatureCache(), Digikam::CollectionManager::refreshLocation(), Digikam::ItemInfo::relationCloud(), Digikam::ItemPosition::remove(), Digikam::ItemInfo::removeAllTags(), Digikam::ItemPosition::removeAltitude(), Digikam::ItemInfo::removeFromGroup(), Digikam::ItemCopyright::removeLanguageProperty(), Digikam::CollectionManager::removeLocation(), Digikam::FaceUtils::removeNormalTag(), Digikam::ItemTagPair::removeProperties(), Digikam::TagProperties::removeProperties(), Digikam::ItemCopyright::removeProperties(), Digikam::ItemTagPair::removeProperty(), Digikam::TagProperties::removeProperty(), Digikam::ItemExtendedProperties::removeProperty(), Digikam::ItemInfo::removeTag(), Digikam::AlbumManager::renamePAlbum(), Digikam::AlbumManager::renameTAlbum(), Digikam::ItemCopyright::replaceFrom(), Digikam::CollectionScanner::resetDeleteRemovedSettings(), Digikam::ItemScanner::resolveHistoryImageId(), Digikam::ItemScanner::resolveImageHistory(), Digikam::AlbumsJob::run(), Digikam::DatesJob::run(), Digikam::GPSJob::run(), Digikam::TagsJob::run(), Digikam::ScanController::run(), Digikam::EmptyDTrashItemsJob::run(), Digikam::DatabaseTask::run(), Digikam::CollectionScanner::safelyRemoveAlbums(), Digikam::ItemGPS::saveChanges(), Digikam::CollectionScanner::scanAlbum(), Digikam::CollectionScanner::scanAlbumRoot(), Digikam::CollectionScanner::scanFile(), Digikam::ItemScanner::scanFile(), Digikam::CollectionScanner::scanForStaleAlbums(), Digikam::ItemScanner::scanFromIdenticalFile(), Digikam::ItemScanner::scanImageHistoryIfModified(), Digikam::CollectionScanner::scanNewFile(), Digikam::PAlbum::setCaption(), Digikam::PAlbum::setCategory(), Digikam::ItemCopyright::setCreator(), Digikam::AlbumManager::setDatabase(), Digikam::PAlbum::setDate(), Digikam::ItemInfo::setDateTime(), Digikam::CoreDbDownloadHistory::setDownloaded(), Digikam::ItemExtendedProperties::setFakeListProperty(), Digikam::ItemInfo::setItemHistory(), Digikam::ItemCopyright::setLanguageProperty(), Digikam::ItemInfo::setManualOrder(), Digikam::ItemInfo::setModDateTime(), Digikam::ItemInfo::setName(), Digikam::ItemInfo::setOrientation(), Digikam::ItemTagPair::setProperty(), Digikam::TagProperties::setProperty(), Digikam::ItemExtendedProperties::setProperty(), Digikam::ItemInfo::setRating(), Digikam::ItemCopyright::setSimpleProperty(), Digikam::ItemInfo::setTag(), Digikam::ItemInfo::setUuid(), Digikam::ItemInfo::setVisible(), Digikam::AlbumModificationHelper::slotAlbumDelete(), Digikam::TagModificationHelper::slotMultipleFaceTagDel(), Digikam::TagModificationHelper::slotMultipleTagDel(), Digikam::ItemIconView::slotRemoveTag(), Digikam::TagModificationHelper::slotTagDelete(), Digikam::ItemInfo::tagIds(), Digikam::ItemScanner::tagItemHistoryGraph(), Digikam::TagProperties::TagProperties(), Digikam::ItemInfo::uniqueHash(), Digikam::AlbumManager::updatePAlbumIcon(), Digikam::CollectionScanner::updateRemovedItemsTime(), Digikam::AlbumManager::updateSAlbum(), Digikam::AlbumManager::updateTAlbumIcon(), Digikam::CoreDbSchemaUpdater::updateUniqueHash(), and Digikam::ItemInfo::uuid().
|
static |
Setup the errors handler instance.
Referenced by Digikam::AlbumManager::setDatabase().
QString Digikam::CoreDbAccess::lastError | ( | ) |
Returns the error message for the last error that occurred, or a null QString of no error occurred.
Referenced by Digikam::AlbumManager::setDatabase().
|
static |
Return the default parameters
Referenced by Digikam::FieldQueryBuilder::addStringField(), Digikam::ItemQueryBuilder::buildField(), Digikam::AlbumManager::changeDatabase(), checkReadyForUse(), Digikam::AlbumManager::databaseEqual(), Digikam::FacialRecognitionWrapper::Private::Private(), Digikam::ScanController::run(), Digikam::AlbumManager::setDatabase(), and setParameters().
void Digikam::CoreDbAccess::setLastError | ( | const QString & | error | ) |
Set the "last error" message. This method is not for public use.
Referenced by checkReadyForUse().
|
static |
Set the default parameters. Call this function at least once in the starting phase of your application, when no other threads will yet access the database, to initialize DatabaseAcccess. After this initial call, it is thread-safe to call this function again. In a subsequent call, if the parameters are identical, nothing is done. If the parameters change, the current database will be closed. When parameters have been set or changed, the new one will be opened on-demand, i.e. when the first CoreDbAccess object is constructed.
References DatabaseSlave, and parameters().
Referenced by Digikam::AlbumManager::setDatabase().
|
static |
|
friend |