diff --git a/core/libs/database/dbjobs/dbjob.cpp b/core/libs/database/dbjobs/dbjob.cpp index 605be68274..0af8c5a4a4 100644 --- a/core/libs/database/dbjobs/dbjob.cpp +++ b/core/libs/database/dbjobs/dbjob.cpp @@ -1,331 +1,331 @@ /* ============================================================ * * This file is a part of digiKam project * http://www.digikam.org * * Date : 2015-06-01 * Description : DB Jobs for listing and scanning * * Copyright (C) 2015 by Mohamed_Anwer * * This program is free software; you can redistribute it * and/or modify it under the terms of the GNU General * Public License as published by the Free Software Foundation; * either version 2, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * ============================================================ */ #include "dbjob.h" // Local includes #include "coredbaccess.h" #include "dbengineparameters.h" #include "coredb.h" #include "imagelister.h" #include "digikam_export.h" #include "digikam_debug.h" #include "dbjobsthread.h" namespace Digikam { DBJob::DBJob() : ActionJob() { } DBJob::~DBJob() { this->cancel(); } // ---------------------------------------------- AlbumsJob::AlbumsJob(const AlbumsDBJobInfo& jobInfo) : DBJob(), m_jobInfo(jobInfo) { } AlbumsJob::~AlbumsJob() { } void AlbumsJob::run() { if (m_jobInfo.isFoldersJob()) { QMap albumNumberMap = CoreDbAccess().db()->getNumberOfImagesInAlbums(); emit foldersData(albumNumberMap); } else { ImageLister lister; lister.setRecursive(m_jobInfo.isRecursive()); lister.setListOnlyAvailable(m_jobInfo.isListAvailableImagesOnly()); // Send data every 200 images to be more responsive - Digikam::ImageListerJobGrowingPartsSendingReceiver receiver(this, 200, 2000, 100); + ImageListerJobGrowingPartsSendingReceiver receiver(this, 200, 2000, 100); lister.listAlbum(&receiver, m_jobInfo.albumRootId(), m_jobInfo.album()); receiver.sendData(); } emit signalDone(); } // ---------------------------------------------- DatesJob::DatesJob(const DatesDBJobInfo& jobInfo) : DBJob(), m_jobInfo(jobInfo) { } DatesJob::~DatesJob() { } void DatesJob::run() { if (m_jobInfo.isFoldersJob()) { QMap dateNumberMap = CoreDbAccess().db()->getAllCreationDatesAndNumberOfImages(); emit foldersData(dateNumberMap); } else { ImageLister lister; lister.setListOnlyAvailable(true); // Send data every 200 images to be more responsive ImageListerJobPartsSendingReceiver receiver(this, 200); lister.listDateRange(&receiver, m_jobInfo.startDate(), m_jobInfo.endDate()); // Send rest receiver.sendData(); } emit signalDone(); } // ---------------------------------------------- GPSJob::GPSJob(const GPSDBJobInfo& jobInfo) : DBJob(), m_jobInfo(jobInfo) { } GPSJob::~GPSJob() { } void GPSJob::run() { if (m_jobInfo.isDirectQuery()) { QList imagesInfoFromArea = CoreDbAccess().db()->getImageIdsFromArea(m_jobInfo.lat1(), m_jobInfo.lat2(), m_jobInfo.lng1(), m_jobInfo.lng2(), 0, QLatin1String("rating")); emit directQueryData(imagesInfoFromArea); } else { ImageLister lister; lister.setAllowExtraValues(true); lister.setListOnlyAvailable(m_jobInfo.isListAvailableImagesOnly()); // Send data every 200 images to be more responsive ImageListerJobPartsSendingReceiver receiver(this, 200); lister.listAreaRange(&receiver, m_jobInfo.lat1(), m_jobInfo.lat2(), m_jobInfo.lng1(), m_jobInfo.lng2()); // send rest receiver.sendData(); } emit signalDone(); } // ---------------------------------------------- TagsJob::TagsJob(const TagsDBJobInfo& jobInfo) : DBJob(), m_jobInfo(jobInfo) { } TagsJob::~TagsJob() { } void TagsJob::run() { if (m_jobInfo.isFoldersJob()) { QMap tagNumberMap = CoreDbAccess().db()->getNumberOfImagesInTags(); //qCDebug(DIGIKAM_DBJOB_LOG) << tagNumberMap; emit foldersData(tagNumberMap); } else if (m_jobInfo.isFaceFoldersJob()) { QMap > facesNumberMap; facesNumberMap[ImageTagPropertyName::autodetectedFace()] = CoreDbAccess().db()->getNumberOfImagesInTagProperties(Digikam::ImageTagPropertyName::autodetectedFace()); facesNumberMap[ImageTagPropertyName::tagRegion()] = CoreDbAccess().db()->getNumberOfImagesInTagProperties(Digikam::ImageTagPropertyName::tagRegion()); facesNumberMap[ImageTagPropertyName::autodetectedPerson()] = CoreDbAccess().db()->getNumberOfImagesInTagProperties(Digikam::ImageTagPropertyName::autodetectedPerson()); emit faceFoldersData(facesNumberMap); } else { ImageLister lister; lister.setRecursive(m_jobInfo.isRecursive()); lister.setListOnlyAvailable(m_jobInfo.isListAvailableImagesOnly()); // Send data every 200 images to be more responsive ImageListerJobPartsSendingReceiver receiver(this, 200); if (!m_jobInfo.specialTag().isNull()) { QString searchXml = lister.tagSearchXml(m_jobInfo.tagsIds().first(), m_jobInfo.specialTag(), m_jobInfo.isRecursive()); lister.setAllowExtraValues(true); // pass property value as extra value, different binary protocol lister.listImageTagPropertySearch(&receiver, searchXml); } else { lister.listTag(&receiver, m_jobInfo.tagsIds()); } // Finish sending receiver.sendData(); } emit signalDone(); } // ---------------------------------------------- SearchesJob::SearchesJob(const SearchesDBJobInfo& jobInfo) : DBJob(), m_jobInfo(jobInfo) { } SearchesJob::~SearchesJob() { } void SearchesJob::run() { if (!m_jobInfo.isDuplicatesJob()) { QList infos; foreach(int id, m_jobInfo.searchIds()) { infos << CoreDbAccess().db()->getSearchInfo(id); } ImageLister lister; lister.setListOnlyAvailable(m_jobInfo.isListAvailableImagesOnly()); // Send data every 200 images to be more responsive ImageListerJobPartsSendingReceiver receiver(this, 200); - foreach(SearchInfo info, infos) + foreach(const SearchInfo& info, infos) { if (info.type == DatabaseSearch::HaarSearch) { lister.listHaarSearch(&receiver, info.query); } else { bool ok; qlonglong referenceImageId = info.name.toLongLong(&ok); if (ok) { lister.listSearch(&receiver, info.query, 0, referenceImageId); } else { lister.listSearch(&receiver, info.query, 0, -1); } } if (!receiver.hasError) { receiver.sendData(); } } } else { if (m_jobInfo.albumsIds().isEmpty() && m_jobInfo.tagsIds().isEmpty() && m_jobInfo.imageIds().isEmpty()) { qCDebug(DIGIKAM_DBJOB_LOG) << "No album, tag or image ids passed for duplicates search"; return; } if (m_jobInfo.minThreshold() == 0) { m_jobInfo.setMinThreshold(0.4); } DuplicatesProgressObserver observer(this); // Rebuild the duplicate albums HaarIface iface; if (m_jobInfo.isAlbumUpdate()) { iface.rebuildDuplicatesAlbums(m_jobInfo.imageIds(), m_jobInfo.minThreshold(), m_jobInfo.maxThreshold(), static_cast(m_jobInfo.searchResultRestriction()), &observer); } else { iface.rebuildDuplicatesAlbums(m_jobInfo.albumsIds(), m_jobInfo.tagsIds(), static_cast(m_jobInfo.albumTagRelation()), m_jobInfo.minThreshold(), m_jobInfo.maxThreshold(), static_cast(m_jobInfo.searchResultRestriction()), &observer); } } emit signalDone(); } bool SearchesJob::isCanceled() { return m_cancel; } } // namespace Digikam diff --git a/core/libs/database/dbjobs/dbjobsthread.cpp b/core/libs/database/dbjobs/dbjobsthread.cpp index 840f80abb0..2607a57391 100644 --- a/core/libs/database/dbjobs/dbjobsthread.cpp +++ b/core/libs/database/dbjobs/dbjobsthread.cpp @@ -1,247 +1,246 @@ /* ============================================================ * * This file is a part of digiKam project * http://www.digikam.org * * Date : 2015-06-01 * Description : DB Jobs thread for listing and scanning * * Copyright (C) 2015 by Mohamed_Anwer * * This program is free software; you can redistribute it * and/or modify it under the terms of the GNU General * Public License as published by the Free Software Foundation; * either version 2, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * ============================================================ */ #include "dbjobsthread.h" #include "coredbaccess.h" #include "dbjobinfo.h" #include "dbjob.h" #include "duplicatesprogressobserver.h" #include "digikam_debug.h" namespace Digikam { DBJobsThread::DBJobsThread(QObject* const parent) : ActionThreadBase(parent) { setObjectName(QLatin1String("DBJobsThread")); } DBJobsThread::~DBJobsThread() { } bool DBJobsThread::hasErrors() { return !m_errorsList.isEmpty(); } QList &DBJobsThread::errorsList() { return m_errorsList; } void DBJobsThread::connectFinishAndErrorSignals(DBJob* const j) { connect(j, SIGNAL(signalDone()), this, SIGNAL(finished())); connect(j, SIGNAL(error(QString)), this, SLOT(error(QString))); } void DBJobsThread::error(const QString& errString) { m_errorsList.append(errString); } // ------------------------------------------------- AlbumsDBJobsThread::AlbumsDBJobsThread(QObject* const parent) : DBJobsThread(parent) { } AlbumsDBJobsThread::~AlbumsDBJobsThread() { } void AlbumsDBJobsThread::albumsListing(const AlbumsDBJobInfo& info) { AlbumsJob* const j = new AlbumsJob(info); connectFinishAndErrorSignals(j); if (info.isFoldersJob()) { connect(j, SIGNAL(foldersData(QMap)), this, SIGNAL(foldersData(QMap))); } else { connect(j, SIGNAL(data(QList)), this, SIGNAL(data(QList))); } ActionJobCollection collection; collection.insert(j, 0); appendJobs(collection); } // ------------------------------------------------- TagsDBJobsThread::TagsDBJobsThread(QObject* const parent) : DBJobsThread(parent) { } TagsDBJobsThread::~TagsDBJobsThread() { } void TagsDBJobsThread::tagsListing(const TagsDBJobInfo& info) { TagsJob* const j = new TagsJob(info); connectFinishAndErrorSignals(j); if (info.isFoldersJob()) { connect(j, SIGNAL(foldersData(QMap)), this, SIGNAL(foldersData(QMap))); } else if (info.isFaceFoldersJob()) { connect(j, SIGNAL(faceFoldersData(QMap >)), // krazy:exclude=normalize this, SIGNAL(faceFoldersData(QMap >))); // krazy:exclude=normalize } else { connect(j, SIGNAL(data(QList)), this, SIGNAL(data(QList))); } ActionJobCollection collection; collection.insert(j, 0); appendJobs(collection); } // ------------------------------------------------- DatesDBJobsThread::DatesDBJobsThread(QObject* const parent) : DBJobsThread(parent) { } DatesDBJobsThread::~DatesDBJobsThread() { } void DatesDBJobsThread::datesListing(const DatesDBJobInfo& info) { DatesJob* const j = new DatesJob(info); connectFinishAndErrorSignals(j); if (info.isFoldersJob()) { connect(j, SIGNAL(foldersData(QMap)), this, SIGNAL(foldersData(QMap))); } else { connect(j, SIGNAL(data(QList)), this, SIGNAL(data(QList))); } ActionJobCollection collection; collection.insert(j, 0); appendJobs(collection); } // ------------------------------------------------- GPSDBJobsThread::GPSDBJobsThread(QObject* const parent) : DBJobsThread(parent) { } GPSDBJobsThread::~GPSDBJobsThread() { } void GPSDBJobsThread::GPSListing(const GPSDBJobInfo& info) { GPSJob* const j = new GPSJob(info); connectFinishAndErrorSignals(j); if (info.isDirectQuery()) { connect(j, SIGNAL(directQueryData(QList)), this, SIGNAL(directQueryData(QList))); } else { connect(j, SIGNAL(data(QList)), this, SIGNAL(data(QList))); } ActionJobCollection collection; collection.insert(j, 0); appendJobs(collection); } // ------------------------------------------------- SearchesDBJobsThread::SearchesDBJobsThread(QObject* const parent) : DBJobsThread(parent) { } SearchesDBJobsThread::~SearchesDBJobsThread() { } void SearchesDBJobsThread::searchesListing(const SearchesDBJobInfo& info) { SearchesJob* const j = new SearchesJob(info); connectFinishAndErrorSignals(j); if (info.isDuplicatesJob()) { - connect(j, SIGNAL(totalSize(int)), this, SIGNAL(totalSize(int))); connect(j, SIGNAL(processedSize(int)), this, SIGNAL(processedSize(int))); } else { connect(j, SIGNAL(data(QList)), this, SIGNAL(data(QList))); } ActionJobCollection collection; collection.insert(j, 0); appendJobs(collection); } } // namespace Digikam