File indexing completed on 2025-01-05 03:54:17
0001 /* ============================================================ 0002 * 0003 * This file is a part of digiKam project 0004 * https://www.digikam.org 0005 * 0006 * Date : 2005-10-28 0007 * Description : scan item controller - private containers. 0008 * 0009 * SPDX-FileCopyrightText: 2005-2006 by Tom Albers <tomalbers at kde dot nl> 0010 * SPDX-FileCopyrightText: 2006-2024 by Gilles Caulier <caulier dot gilles at gmail dot com> 0011 * SPDX-FileCopyrightText: 2007-2013 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de> 0012 * 0013 * SPDX-License-Identifier: GPL-2.0-or-later 0014 * 0015 * ============================================================ */ 0016 0017 #include "scancontroller_p.h" 0018 0019 namespace Digikam 0020 { 0021 0022 SimpleCollectionScannerObserver::SimpleCollectionScannerObserver(bool* const var) 0023 : m_continue(var) 0024 { 0025 *m_continue = true; 0026 } 0027 0028 bool SimpleCollectionScannerObserver::continueQuery() 0029 { 0030 return *m_continue; 0031 } 0032 0033 // ------------------------------------------------------------------------------ 0034 0035 ScanController::Private::Private() 0036 : running (false), 0037 needsInitialization (false), 0038 needsCompleteScan (false), 0039 needsUpdateUniqueHash (false), 0040 idle (false), 0041 scanSuspended (0), 0042 deferFileScanning (false), 0043 finishScanAllowed (true), 0044 continueInitialization(false), 0045 continueScan (false), 0046 continuePartialScan (false), 0047 fileWatchInstalled (false), 0048 eventLoop (nullptr), 0049 showTimer (nullptr), 0050 relaxedTimer (nullptr), 0051 externalTimer (nullptr), 0052 hints (CollectionScanner::createHintContainer()), 0053 progressDialog (nullptr), 0054 advice (ScanController::Success), 0055 needTotalFiles (false), 0056 performFastScan (true), 0057 totalFilesToScan (0) 0058 { 0059 } 0060 0061 QPixmap ScanController::Private::albumPixmap() 0062 { 0063 if (albumPix.isNull()) 0064 { 0065 albumPix = QIcon::fromTheme(QLatin1String("folder-pictures")).pixmap(32); 0066 } 0067 0068 return albumPix; 0069 } 0070 0071 QPixmap ScanController::Private::rootPixmap() 0072 { 0073 if (rootPix.isNull()) 0074 { 0075 rootPix = QIcon::fromTheme(QLatin1String("folder-open")).pixmap(32); 0076 } 0077 0078 return rootPix; 0079 } 0080 0081 QPixmap ScanController::Private::actionPixmap() 0082 { 0083 if (actionPix.isNull()) 0084 { 0085 actionPix = QIcon::fromTheme(QLatin1String("system-run")).pixmap(32); 0086 } 0087 0088 return actionPix; 0089 } 0090 0091 QPixmap ScanController::Private::errorPixmap() 0092 { 0093 if (errorPix.isNull()) 0094 { 0095 errorPix = QIcon::fromTheme(QLatin1String("dialog-error")).pixmap(32); 0096 } 0097 0098 return errorPix; 0099 } 0100 0101 QPixmap ScanController::Private::restartPixmap() 0102 { 0103 if (errorPix.isNull()) 0104 { 0105 errorPix = QIcon::fromTheme(QLatin1String("view-refresh")).pixmap(32); 0106 } 0107 0108 return errorPix; 0109 } 0110 0111 void ScanController::Private::garbageCollectHints(bool setAccessTime) 0112 { 0113 QDateTime current = QDateTime::currentDateTime(); 0114 0115 if (idle && 0116 lastHintAdded.isValid() && 0117 (lastHintAdded.secsTo(current) > (5*60))) 0118 { 0119 hints->clear(); 0120 } 0121 0122 if (setAccessTime) 0123 { 0124 lastHintAdded = current; 0125 } 0126 } 0127 0128 // -------------------------------------------------------------------------------------------- 0129 0130 ScanControllerLoadingCacheFileWatch::ScanControllerLoadingCacheFileWatch() 0131 { 0132 CoreDbWatch* const dbwatch = CoreDbAccess::databaseWatch(); 0133 0134 // we opt for a queued connection to make stuff a bit relaxed 0135 0136 connect(dbwatch, SIGNAL(imageChange(ImageChangeset)), 0137 this, SLOT(slotImageChanged(ImageChangeset)), 0138 Qt::QueuedConnection); 0139 } 0140 0141 void ScanControllerLoadingCacheFileWatch::slotImageChanged(const ImageChangeset& changeset) 0142 { 0143 Q_FOREACH (const qlonglong& imageId, changeset.ids()) 0144 { 0145 DatabaseFields::Set changes = changeset.changes(); 0146 0147 if ((changes & DatabaseFields::ModificationDate) || (changes & DatabaseFields::Orientation)) 0148 { 0149 ItemInfo info(imageId); 0150 /* 0151 qCDebug(DIGIKAM_DATABASE_LOG) << imageId << info.filePath(); 0152 */ 0153 notifyFileChanged(info.filePath()); 0154 } 0155 } 0156 } 0157 0158 } // namespace Digikam 0159 0160 #include "moc_scancontroller_p.cpp"