1 | /* This file is part of the KDE libraries |
2 | Copyright (C) Stephan Kulow <coolo@kde.org> |
3 | |
4 | This library is free software; you can redistribute it and/or |
5 | modify it under the terms of the GNU Library General Public |
6 | License as published by the Free Software Foundation; either |
7 | version 2 of the License, or (at your option) any later version. |
8 | |
9 | This library is distributed in the hope that it will be useful, |
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12 | Library General Public License for more details. |
13 | |
14 | You should have received a copy of the GNU Library General Public License |
15 | along with this library; see the file COPYING.LIB. If not, write to |
16 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
17 | Boston, MA 02110-1301, USA. |
18 | */ |
19 | |
20 | #ifndef KFILEFILTERCOMBO_H |
21 | #define KFILEFILTERCOMBO_H |
22 | |
23 | #include <kfile_export.h> |
24 | |
25 | #include <QtCore/QStringList> |
26 | |
27 | #include <kcombobox.h> |
28 | |
29 | class KFILE_EXPORT KFileFilterCombo : public KComboBox |
30 | { |
31 | Q_OBJECT |
32 | |
33 | public: |
34 | /** |
35 | * Creates a new filter combo box. |
36 | * |
37 | * @param parent The parent widget. |
38 | */ |
39 | KFileFilterCombo(QWidget *parent=0); |
40 | |
41 | /** |
42 | * Destroys the filter combo box. |
43 | */ |
44 | ~KFileFilterCombo(); |
45 | |
46 | /** |
47 | * Sets the @p filter string. |
48 | */ |
49 | void setFilter(const QString& filter); |
50 | |
51 | /** |
52 | * @returns the current filter, either something like "*.cpp *.h" |
53 | * or the current mimetype, like "text/html", or a list of those, like |
54 | " "text/html text/plain image/png", all separated with one space. |
55 | */ |
56 | QString currentFilter() const; |
57 | |
58 | /** |
59 | * Sets the current filter. Filter must match one of the filter items |
60 | * passed before to this widget. |
61 | */ |
62 | void setCurrentFilter( const QString& filter ); |
63 | |
64 | /** |
65 | * Sets a list of mimetypes. |
66 | * If @p defaultType is set, it will be set as the current item. |
67 | * Otherwise, a first item showing all the mimetypes will be created. |
68 | */ |
69 | void setMimeFilter( const QStringList& types, const QString& defaultType ); |
70 | |
71 | /** |
72 | * @return true if the filter's first item is the list of all mimetypes |
73 | */ |
74 | bool showsAllTypes() const; |
75 | |
76 | /** |
77 | * This method allows you to set a default-filter, that is used when an |
78 | * empty filter is set. Make sure you call this before calling |
79 | * setFilter(). |
80 | * |
81 | * By default, this is set to i18n("*|All Files") |
82 | * @see defaultFilter |
83 | */ |
84 | void setDefaultFilter( const QString& filter ); |
85 | |
86 | /** |
87 | * @return the default filter, used when an empty filter is set. |
88 | * @see setDefaultFilter |
89 | */ |
90 | QString defaultFilter() const; |
91 | |
92 | /** |
93 | * @return all filters (this can be a list of patterns or a list of mimetypes) |
94 | */ |
95 | QStringList filters() const; |
96 | |
97 | /** |
98 | * Returns true if the filter has been set using setMimeFilter(). |
99 | * @since 4.6.1 |
100 | */ |
101 | bool isMimeFilter() const; |
102 | |
103 | protected: |
104 | virtual bool eventFilter( QObject*, QEvent* ); |
105 | |
106 | Q_SIGNALS: |
107 | /** |
108 | * This signal is emitted whenever the filter has been changed. |
109 | */ |
110 | void filterChanged(); |
111 | |
112 | private: |
113 | class Private; |
114 | Private* const d; |
115 | |
116 | Q_PRIVATE_SLOT( d, void _k_slotFilterChanged() ) |
117 | }; |
118 | |
119 | #endif |
120 | |