libkipi from trunk (KDE 4.3) : add support of kipi host settings "file timestamp...
[kdegraphics.git] / gwenview / lib / semanticinfo / sorteddirmodel.h
blob3b77b999a01863de7bc7d809a361bb4852549339
1 /*
2 Gwenview: an image viewer
3 Copyright 2007 Aurélien Gâteau <aurelien.gateau@free.fr>
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 as published by the Free Software Foundation; either version 2
8 of the License, or (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 #ifndef SORTEDDIRMODEL_H
21 #define SORTEDDIRMODEL_H
23 #include <config-gwenview.h>
25 // Qt
26 #include <QPointer>
28 // KDE
29 #include <kdirsortfilterproxymodel.h>
31 // Local
32 #include <lib/gwenviewlib_export.h>
35 class KDateTime;
36 class KDirLister;
37 class KFileItem;
38 class KUrl;
40 namespace Gwenview {
42 class AbstractSemanticInfoBackEnd;
43 class SortedDirModelPrivate;
44 class TagSet;
46 #ifndef GWENVIEW_SEMANTICINFO_BACKEND_NONE
47 class SemanticInfo;
48 #endif
50 class SortedDirModel;
51 class GWENVIEWLIB_EXPORT AbstractSortedDirModelFilter : public QObject {
52 public:
53 AbstractSortedDirModelFilter(SortedDirModel* model);
54 ~AbstractSortedDirModelFilter();
55 SortedDirModel* model() const { return mModel; }
57 virtual bool needsSemanticInfo() const = 0;
58 /**
59 * Returns true if index should be accepted.
60 * Warning: index is a source index of SortedDirModel
62 virtual bool acceptsIndex(const QModelIndex& index) const = 0;
64 private:
65 QPointer<SortedDirModel> mModel;
68 /**
69 * This model makes it possible to show all images in a folder.
70 * It can filter images based on name and metadata.
72 class GWENVIEWLIB_EXPORT SortedDirModel : public KDirSortFilterProxyModel {
73 Q_OBJECT
74 public:
75 SortedDirModel(QObject* parent);
76 ~SortedDirModel();
77 KDirLister* dirLister();
78 KFileItem itemForIndex(const QModelIndex& index) const;
79 KFileItem itemForSourceIndex(const QModelIndex& sourceIndex) const;
80 QModelIndex indexForItem(const KFileItem& item) const;
81 QModelIndex indexForUrl(const KUrl& url) const;
83 /**
84 * A list of file extensions we should skip
86 void setBlackListedExtensions(const QStringList& list);
88 virtual void setMimeExcludeFilter(const QStringList &mimeList);
90 void addFilter(AbstractSortedDirModelFilter*);
92 void removeFilter(AbstractSortedDirModelFilter*);
94 void reload();
96 AbstractSemanticInfoBackEnd* semanticInfoBackEnd() const;
98 #ifndef GWENVIEW_SEMANTICINFO_BACKEND_NONE
99 SemanticInfo semanticInfoForSourceIndex(const QModelIndex& sourceIndex) const;
100 #endif
102 public Q_SLOTS:
103 void applyFilters();
105 protected:
106 bool filterAcceptsRow(int row, const QModelIndex& parent) const;
107 bool lessThan(const QModelIndex& left, const QModelIndex& right) const;
109 private Q_SLOTS:
110 void doApplyFilters();
112 private:
113 friend class SortedDirModelPrivate;
114 SortedDirModelPrivate * const d;
117 } // namespace
119 #endif /* SORTEDDIRMODEL_H */