]> cloud.milkyroute.net Git - dolphin.git/blob - src/kitemviews/kfileitemmodelfilter_p.h
Make sure that Control+click toggles the selection state
[dolphin.git] / src / kitemviews / kfileitemmodelfilter_p.h
1 /***************************************************************************
2 * Copyright (C) 2011 by Janardhan Reddy *
3 * <annapareddyjanardhanreddy@gmail.com> *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
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. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
19 ***************************************************************************/
20
21 #ifndef KFILEITEMMODELFILTER_H
22 #define KFILEITEMMODELFILTER_H
23
24 #include <libdolphin_export.h>
25 #include <QString>
26
27 class KFileItem;
28 class QRegExp;
29
30 /**
31 * @brief Allows to check whether an item of the KFileItemModel
32 * matches with a set filter-string.
33 *
34 * Currently the filter is only checked for the KFileItem::text()
35 * property of the KFileItem, but this might get extended in
36 * future.
37 */
38 class LIBDOLPHINPRIVATE_EXPORT KFileItemModelFilter
39 {
40
41 public:
42 KFileItemModelFilter();
43 virtual ~KFileItemModelFilter();
44
45 /**
46 * Sets the pattern that is used for a comparison with the item
47 * in KFileItemModelFilter::matches(). Per default the pattern
48 * defines a sub-string. As soon as the pattern contains at least
49 * a '*', '?' or '[' the pattern represents a regular expression.
50 */
51 void setPattern(const QString& pattern);
52 QString pattern() const;
53
54 /**
55 * @return True if the item matches with the pattern defined by
56 * KFileItemModelFilter::setPattern().
57 */
58 bool matches(const KFileItem& item) const;
59
60 private:
61 bool m_useRegExp; // If true, m_regExp is used for filtering,
62 // otherwise m_lowerCaseFilter is used.
63 QRegExp* m_regExp;
64 QString m_lowerCasePattern; // Lowercase version of m_filter for
65 // faster comparison in matches().
66 QString m_pattern; // Property set by setFilter().
67 };
68 #endif
69
70