File indexing completed on 2025-01-05 03:57:13

0001 /* ============================================================
0002  *
0003  * This file is a part of digiKam project
0004  * https://www.digikam.org
0005  *
0006  * Date        : 2003-16-10
0007  * Description : application settings interface
0008  *
0009  * SPDX-FileCopyrightText: 2003-2004 by Renchi Raju <renchi dot raju at gmail dot com>
0010  * SPDX-FileCopyrightText: 2003-2024 by Gilles Caulier <caulier dot gilles at gmail dot com>
0011  * SPDX-FileCopyrightText: 2007      by Arnd Baecker <arnd dot baecker at web dot de>
0012  * SPDX-FileCopyrightText: 2014      by Mohamed_Anwer <m_dot_anwer at gmx dot com>
0013  * SPDX-FileCopyrightText: 2014      by Veaceslav Munteanu <veaceslav dot munteanu90 at gmail dot com>
0014  *
0015  * SPDX-License-Identifier: GPL-2.0-or-later
0016  *
0017  * ============================================================ */
0018 
0019 #include "applicationsettings_p.h"
0020 
0021 namespace Digikam
0022 {
0023 
0024 QString ApplicationSettings::getImageFileFilter() const
0025 {
0026     QStringList imageSettings;
0027     CoreDbAccess().db()->getFilterSettings(&imageSettings, nullptr, nullptr);
0028     QStringList wildcards;
0029 
0030     Q_FOREACH (const QString& suffix, imageSettings)
0031     {
0032         wildcards << QLatin1String("*.") + suffix;
0033     }
0034 
0035     return wildcards.join(QLatin1Char(' '));
0036 }
0037 
0038 QString ApplicationSettings::getMovieFileFilter() const
0039 {
0040     QStringList movieSettings;
0041     CoreDbAccess().db()->getFilterSettings(nullptr, &movieSettings, nullptr);
0042     QStringList wildcards;
0043 
0044     Q_FOREACH (const QString& suffix, movieSettings)
0045     {
0046         wildcards << QLatin1String("*.") + suffix;
0047     }
0048 
0049     return wildcards.join(QLatin1Char(' '));
0050 }
0051 
0052 QString ApplicationSettings::getAudioFileFilter() const
0053 {
0054     QStringList audioSettings;
0055     CoreDbAccess().db()->getFilterSettings(nullptr, nullptr, &audioSettings);
0056     QStringList wildcards;
0057 
0058     Q_FOREACH (const QString& suffix, audioSettings)
0059     {
0060         wildcards << QLatin1String("*.") + suffix;
0061     }
0062 
0063     return wildcards.join(QLatin1Char(' '));
0064 }
0065 
0066 QString ApplicationSettings::getRawFileFilter() const
0067 {
0068     QStringList supportedRaws = DRawDecoder::rawFilesList();
0069     QStringList imageSettings;
0070     CoreDbAccess().db()->getFilterSettings(&imageSettings, nullptr, nullptr);
0071 
0072     // form intersection: those extensions that are supported as RAW as well in the list of allowed extensions
0073 
0074     for (QStringList::iterator it = supportedRaws.begin() ; it != supportedRaws.end() ; )
0075     {
0076         if (imageSettings.contains(*it))
0077         {
0078             ++it;
0079         }
0080         else
0081         {
0082             it = supportedRaws.erase(it);
0083         }
0084     }
0085 
0086     QStringList wildcards;
0087 
0088     Q_FOREACH (const QString& suffix, supportedRaws)
0089     {
0090         wildcards << QLatin1String("*.") + suffix;
0091     }
0092 
0093     return wildcards.join(QLatin1Char(' '));
0094 }
0095 
0096 QString ApplicationSettings::getAllFileFilter() const
0097 {
0098     QStringList imageFilter, audioFilter, videoFilter;
0099     CoreDbAccess().db()->getFilterSettings(&imageFilter, &videoFilter, &audioFilter);
0100     QStringList wildcards;
0101 
0102     Q_FOREACH (const QString& suffix, imageFilter)
0103     {
0104         wildcards << QLatin1String("*.") + suffix;
0105     }
0106 
0107     Q_FOREACH (const QString& suffix, audioFilter)
0108     {
0109         wildcards << QLatin1String("*.") + suffix;
0110     }
0111 
0112     Q_FOREACH (const QString& suffix, videoFilter)
0113     {
0114         wildcards << QLatin1String("*.") + suffix;
0115     }
0116 
0117     return wildcards.join(QLatin1Char(' '));
0118 }
0119 
0120 } // namespace Digikam