SVN_SILENT shhh.
[kdelibs.git] / kfile / kdirsortfilterproxymodel.h
blobe97826be6c8d507472fd2e6ea2eea7f5210f655d
1 /*
2 Copyright (C) 2006 by Peter Penz <peter.penz@gmx.at>
3 Copyright (C) 2006 by Dominic Battre <dominic@battre.de>
4 Copyright (C) 2006 by Martin Pool <mbp@canonical.com>
6 Separated from Dolphin by Nick Shaforostoff <shafff@ukr.net>
8 This library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Library General Public
10 License version 2 as published by the Free Software Foundation.
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Library General Public License for more details.
17 You should have received a copy of the GNU Library General Public License
18 along with this library; see the file COPYING.LIB. If not, write to
19 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 Boston, MA 02110-1301, USA.
23 #ifndef KDIRSORTFILTERPROXYMODEL_H
24 #define KDIRSORTFILTERPROXYMODEL_H
26 #include <QtCore/QFileInfo>
28 #include <kcategorizedsortfilterproxymodel.h>
30 #include <kfile_export.h>
32 /**
33 * @brief Acts as proxy model for KDirModel to sort and filter
34 * KFileItems.
36 * A natural sorting is done. This means that items like:
37 * - item_10.png
38 * - item_1.png
39 * - item_2.png
41 * are sorted like
42 * - item_1.png
43 * - item_2.png
44 * - item_10.png
46 * It is assured that directories are always sorted before files.
47 * Don't use it with non-KDirModel derivatives.
49 * @author Dominic Battre, Martin Pool and Peter Penz
51 class KFILE_EXPORT KDirSortFilterProxyModel
52 : public KCategorizedSortFilterProxyModel
54 public:
55 KDirSortFilterProxyModel(QObject* parent = 0);
56 virtual ~KDirSortFilterProxyModel();
58 /** Reimplemented from QAbstractItemModel. Returns true for directories. */
59 virtual bool hasChildren(const QModelIndex& parent = QModelIndex()) const;
61 /**
62 * Reimplemented from QAbstractItemModel.
63 * Returns true for 'empty' directories so they can be populated later.
65 virtual bool canFetchMore(const QModelIndex& parent) const;
67 /**
68 * Returns the permissions in "points". This is useful for sorting by
69 * permissions.
71 static int pointsForPermissions(const QFileInfo &info);
73 protected:
74 /**
75 * Reimplemented from KCategorizedSortFilterProxyModel.
77 virtual bool subSortLessThan(const QModelIndex& left,
78 const QModelIndex& right) const;
80 private:
81 class KDirSortFilterProxyModelPrivate;
82 KDirSortFilterProxyModelPrivate* const d;
86 #endif