workaround occasional read past buffer end in the scanner.
[kdelibs.git] / kfile / kfilefiltercombo.h
blobd799d7831dc06ae601af131445e1d5b9959f0d49
1 /* This file is part of the KDE libraries
2 Copyright (C) Stephan Kulow <coolo@kde.org>
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.
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.
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.
20 #ifndef KFILEFILTERCOMBO_H
21 #define KFILEFILTERCOMBO_H
23 #include <kfile_export.h>
25 #include <QtCore/QStringList>
27 #include <kcombobox.h>
29 class KFILE_EXPORT KFileFilterCombo : public KComboBox
31 Q_OBJECT
33 public:
34 /**
35 * Creates a new filter combo box.
37 * @param parent The parent widget.
39 KFileFilterCombo(QWidget *parent=0);
41 /**
42 * Destroys the filter combo box.
44 ~KFileFilterCombo();
46 /**
47 * Sets the @p filter string.
49 void setFilter(const QString& filter);
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.
56 QString currentFilter() const;
58 /**
59 * Sets the current filter. Filter must match one of the filter items
60 * passed before to this widget.
62 void setCurrentFilter( const QString& filter );
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.
69 void setMimeFilter( const QStringList& types, const QString& defaultType );
71 /**
72 * @return true if the filter's first item is the list of all mimetypes
74 bool showsAllTypes() const;
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().
81 * By default, this is set to i18n("*|All Files")
82 * @see defaultFilter
84 void setDefaultFilter( const QString& filter );
86 /**
87 * @return the default filter, used when an empty filter is set.
88 * @see setDefaultFilter
90 QString defaultFilter() const;
92 /**
93 * @return all filters (this can be a list of patterns or a list of mimetypes)
95 QStringList filters() const;
97 protected:
98 virtual bool eventFilter( QObject*, QEvent* );
100 Q_SIGNALS:
102 * This signal is emitted whenever the filter has been changed.
104 void filterChanged();
106 private:
107 class Private;
108 Private* const d;
110 Q_PRIVATE_SLOT( d, void _k_slotFilterChanged() )
113 #endif