KIO

kfilefiltercombo.h
1/*
2 This file is part of the KDE libraries
3 SPDX-FileCopyrightText: Stephan Kulow <coolo@kde.org>
4
5 SPDX-License-Identifier: LGPL-2.0-or-later
6*/
7
8#ifndef KFILEFILTERCOMBO_H
9#define KFILEFILTERCOMBO_H
10
11#include "kiofilewidgets_export.h"
12
13#include <QStringList>
14
15#include <KComboBox>
16#include <KFileFilter>
17
18class KFileFilterComboPrivate;
19
20/**
21 * @class KFileFilterCombo kfilefiltercombo.h <KFileFilterCombo>
22 *
23 * File filter combo box.
24 */
25class KIOFILEWIDGETS_EXPORT KFileFilterCombo : public KComboBox
26{
27 Q_OBJECT
28
29public:
30 /**
31 * Creates a new filter combo box.
32 *
33 * @param parent The parent widget.
34 */
35 explicit KFileFilterCombo(QWidget *parent = nullptr);
36
37 /**
38 * Destroys the filter combo box.
39 */
41
42 /**
43 * Sets the filters to be used.
44 *
45 * @param filters each item in the list corresponds to one item in the combobox.
46 * Entries for "All files" and "All supported files" are added automatically as needed.
47 *
48 * @param defaultFilter if not empty this will be the by default active filter
49 *
50 * @since 6.0
51 *
52 */
53 void setFilters(const QList<KFileFilter> &filters, const KFileFilter &defaultFilter = KFileFilter());
54
55 /**
56 * The currently selected/active filter.
57 *
58 * @since 6.0
59 */
60 KFileFilter currentFilter() const;
61
62 /**
63 * The current filters.
64 *
65 * This is not necessarily the same as the list set by setFileFilters() since
66 * entries for "All files" and "All supported files" are added automatically as needed.
67 *
68 * @since 6.0
69 */
70 QList<KFileFilter> filters() const;
71
72 /**
73 * This method allows to set a default-filter, that is used when an
74 * empty filter is set. Make sure you call this before calling
75 * setFileFilter().
76 *
77 * By default, this is set to match all files.
78 * @see defaultFileFilter
79 *
80 * @since 6.0
81 */
82 void setDefaultFilter(const KFileFilter &filter);
83
84 /**
85 * @return the default filter, used when an empty filter is set.
86 * @see setDefaultFileFilter
87 *
88 * @since 6.0
89 */
90 KFileFilter defaultFilter() const;
91
92 /**
93 * Sets the current filter. Filter must match one of the filter items
94 * passed before to this widget.
95 *
96 * @since 6.0
97 */
98 void setCurrentFilter(const KFileFilter &filter);
99
100 /**
101 * @return true if the filter's first item is the list of all MIME types
102 */
103 bool showsAllTypes() const;
104
105protected:
106 bool eventFilter(QObject *, QEvent *) override;
107
109 /**
110 * This signal is emitted whenever the filter has been changed.
111 */
113
114private:
115 std::unique_ptr<KFileFilterComboPrivate> const d;
116};
117
118#endif
File filter combo box.
void filterChanged()
This signal is emitted whenever the filter has been changed.
~KFileFilterCombo() override
Destroys the filter combo box.
Encapsulates rules to filter a list of files.
Definition kfilefilter.h:29
Q_SIGNALSQ_SIGNALS
virtual bool eventFilter(QObject *watched, QEvent *event)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Dec 20 2024 11:49:55 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.