File indexing completed on 2024-05-12 15:55:34
0001 // SPDX-FileCopyrightText: 2006 Tuomas Suutari <tuomas@nepnep.net> 0002 // SPDX-FileCopyrightText: 2003-2012 Jesper K. Pedersen <jesper.pedersen@kdab.com> 0003 // SPDX-FileCopyrightText: 2007 Dirk Mueller <mueller@kde.org> 0004 // SPDX-FileCopyrightText: 2007-2011 Jan Kundrát <jkt@flaska.net> 0005 // SPDX-FileCopyrightText: 2013-2023 Johannes Zarl-Zierl <johannes@zarl-zierl.at> 0006 0007 // SPDX-License-Identifier: GPL-2.0-or-later 0008 0009 #ifndef KPABASE_FILE_EXTENSIONS_H 0010 #define KPABASE_FILE_EXTENSIONS_H 0011 #include <kpabase/FileName.h> 0012 0013 #include <QSet> 0014 #include <QString> 0015 0016 namespace KPABase 0017 { 0018 0019 enum class FileTypePreference { 0020 NoPreference, ///< Just check the file type 0021 PreferNonRawFile ///< Check if a non-raw image file exists before considering the file type. 0022 }; 0023 0024 /** 0025 * @brief fileCanBeSkipped determines whether the file is of interest to KPhotoAlbum or not. 0026 * It takes into account known skippable suffixes (e.g. thumbnail files) and the 0027 * configuration on when to skip raw files (i.e. `skipRawIfOtherMatches`). 0028 * 0029 * @param loadedFiles a set of file names that are already loaded. 0030 * @param imageFile the image file 0031 * @return \c true, if the file can be skipped, \c false otherwise. 0032 */ 0033 bool fileCanBeSkipped(const DB::FileNameSet &loadedFiles, const DB::FileName &imageFile); 0034 0035 /** 0036 * @brief isUsableRawImage checks if the filename is a raw file by checking its extension. 0037 * If a preference for non-raw image files is given, check if a "normal" image file exists before considering the raw file. 0038 * 0039 * @param imageFile 0040 * @param preference FileTypePreference::NoPreference to check the file type only, or FileTypePreference::PreferNonRawFile to return \c false if a non-raw file exists 0041 * @return \c true, if \c imageFile is a raw file (and no preferrable non-raw image exists), \c false otherwise. 0042 */ 0043 bool isUsableRawImage(const DB::FileName &imageFile, FileTypePreference preference = FileTypePreference::NoPreference); 0044 0045 /** 0046 * @brief isVideo checks if the filename is a video file by checking its extension. 0047 * @param fileName 0048 * @return \c true, if the file extension matches one of the known video extensions. 0049 */ 0050 bool isVideo(const DB::FileName &fileName); 0051 0052 QStringList rawExtensions(); 0053 const QSet<QString> &videoExtensions(); 0054 0055 } 0056 0057 #endif /* KPABASE_FILE_EXTENSIONS_H */ 0058 0059 // vi:expandtab:tabstop=4 shiftwidth=4: