File indexing completed on 2024-04-28 15:39:47
0001 // SPDX-FileCopyrightText: 2012-2022 The KPhotoAlbum Development Team 0002 // 0003 // SPDX-License-Identifier: GPL-2.0-or-later 0004 0005 #include "SearchForVideosWithoutLengthInfo.h" 0006 0007 #include "ReadVideoLengthJob.h" 0008 0009 #include <BackgroundTaskManager/JobInfo.h> 0010 #include <BackgroundTaskManager/JobManager.h> 0011 #include <DB/ImageDB.h> 0012 #include <DB/ImageInfo.h> 0013 0014 #include <KLocalizedString> 0015 0016 /** 0017 \class BackgroundJobs::SearchForVideosWithoutLengthInfo 0018 \brief Task for searching the database for videos without length information 0019 */ 0020 0021 BackgroundJobs::SearchForVideosWithoutLengthInfo::SearchForVideosWithoutLengthInfo() 0022 : BackgroundTaskManager::JobInterface(BackgroundTaskManager::BackgroundVideoInfoRequest) 0023 { 0024 } 0025 0026 void BackgroundJobs::SearchForVideosWithoutLengthInfo::execute() 0027 { 0028 const auto images = DB::ImageDB::instance()->images(); 0029 for (const auto &info : images) { 0030 if (!info->isVideo()) 0031 continue; 0032 // silently ignore videos not (currently) on disk: 0033 if (!info->fileName().exists()) 0034 continue; 0035 int length = info->videoLength(); 0036 if (length == -1) { 0037 BackgroundTaskManager::JobManager::instance()->addJob( 0038 new BackgroundJobs::ReadVideoLengthJob(info->fileName(), BackgroundTaskManager::BackgroundVideoPreviewRequest)); 0039 } 0040 } 0041 Q_EMIT completed(); 0042 } 0043 0044 QString BackgroundJobs::SearchForVideosWithoutLengthInfo::title() const 0045 { 0046 return i18n("Search for videos without length information"); 0047 } 0048 0049 QString BackgroundJobs::SearchForVideosWithoutLengthInfo::details() const 0050 { 0051 return QString(); 0052 } 0053 // vi:expandtab:tabstop=4 shiftwidth=4: