1 /* ============================================================
2  *
3  * This file is a part of digiKam project
4  * https://www.digikam.org
5  *
6  * Date        : 2010-06-24
7  * Description : manager for filters (registering, creating etc)
8  *
9  * Copyright (C) 2010-2011 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
10  * Copyright (C) 2010      by Martin Klapetek <martin dot klapetek at gmail dot com>
11  *
12  * This program is free software; you can redistribute it
13  * and/or modify it under the terms of the GNU General
14  * Public License as published by the Free Software Foundation;
15  * either version 2, or (at your option)
16  * any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21  * GNU General Public License for more details.
22  *
23  * ============================================================ */
24 
25 #ifndef DIGIKAM_DIMG_FILTER_MANAGER_H
26 #define DIGIKAM_DIMG_FILTER_MANAGER_H
27 
28 // Qt includes
29 
30 #include <QStringList>
31 #include <QList>
32 #include <QString>
33 
34 // Local includes
35 
36 #include "dimgfiltergenerator.h"
37 #include "digikam_export.h"
38 
39 namespace Digikam
40 {
41 
42 class FilterAction;
43 
44 class DIGIKAM_EXPORT DImgFilterManager : public DImgFilterGenerator
45 {
46 public:
47 
48     static DImgFilterManager* instance();
49 
50     /**
51      * Returns a list of the supported filter identifiers
52      */
53     QStringList supportedFilters()                                  override;
54 
55     /**
56      * Returns a list of supported versions of the given filter
57      */
58     QList<int> supportedVersions(const QString& filterIdentifier)   override;
59 
60     /**
61      * Returns the (untranslated) displayable name for the given identifier.
62      * This is only possible for supported filters. If you have a FilterAction,
63      * it may already contain a displayable name.
64      */
65     QString displayableName(const QString& filterIdentifier)        override;
66 
67     /**
68      * Returns the translated displayable name
69      */
70     QString i18nDisplayableName(const QString& filterIdentifier);
71     QString i18nDisplayableName(const FilterAction& action);
72 
73     /**
74      * Returns an icon for the given filter.
75      * If no icon is known, returns a null string.
76      */
77     QString filterIcon(const QString& filterIdentifier);
78     QString filterIcon(const FilterAction& action);
79 
80     /**
81      * Returns true if the given filter, or, more specifically,
82      * the given filter in the given version is supported.
83      */
84     bool isSupported(const QString& filterIdentifier)               override;
85     bool isSupported(const QString& filterIdentifier, int version)  override;
86 
87     /**
88      * Returns true if the given filter is to be considered
89      * as a step converting a RAW image to a normal image.
90      */
91     bool isRawConversion(const QString& filterIdentifier);
92 
93     /**
94      * Create a filter from an installed manager.
95      * Returns 0 if no filter could be created. This is true
96      * if identifier/version is not supported, or the filter is builtin.
97      * Note: You probably want to use FilterActionFilter.
98      */
99     DImgThreadedFilter* createFilter(const QString& filterIdentifier,
100                                      int version)                   override;
101 
102     /**
103      * Registers all filter provided by this generator.
104      */
105     void addGenerator(DImgFilterGenerator* const generator);
106     void removeGenerator(DImgFilterGenerator* const generator);
107 
108 private:
109 
110     // Disable
111     DImgFilterManager();
112     ~DImgFilterManager()                                            override;
113     DImgFilterManager(const DImgFilterManager&)            = delete;
114     DImgFilterManager& operator=(const DImgFilterManager&) = delete;
115 
116 private:
117 
118     friend class DImgFilterManagerCreator;
119 
120     class Private;
121     Private* const d;
122 };
123 
124 } // namespace Digikam
125 
126 #endif // DIGIKAM_DIMG_FILTER_MANAGER_H
127