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>
29 #include <kdirsortfilterproxymodel.h>
32 #include <lib/gwenviewlib_export.h>
42 class AbstractSemanticInfoBackEnd
;
43 class SortedDirModelPrivate
;
46 #ifndef GWENVIEW_SEMANTICINFO_BACKEND_NONE
51 class GWENVIEWLIB_EXPORT AbstractSortedDirModelFilter
: public QObject
{
53 AbstractSortedDirModelFilter(SortedDirModel
* model
);
54 ~AbstractSortedDirModelFilter();
55 SortedDirModel
* model() const { return mModel
; }
57 virtual bool needsSemanticInfo() const = 0;
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;
65 QPointer
<SortedDirModel
> mModel
;
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
{
75 SortedDirModel(QObject
* parent
);
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;
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
*);
96 AbstractSemanticInfoBackEnd
* semanticInfoBackEnd() const;
98 #ifndef GWENVIEW_SEMANTICINFO_BACKEND_NONE
99 SemanticInfo
semanticInfoForSourceIndex(const QModelIndex
& sourceIndex
) const;
106 bool filterAcceptsRow(int row
, const QModelIndex
& parent
) const;
107 bool lessThan(const QModelIndex
& left
, const QModelIndex
& right
) const;
110 void doApplyFilters();
113 friend class SortedDirModelPrivate
;
114 SortedDirModelPrivate
* const d
;
119 #endif /* SORTEDDIRMODEL_H */