1 /*
2  * %kadu copyright begin%
3  * Copyright 2011 Piotr Galiszewski (piotr.galiszewski@kadu.im)
4  * Copyright 2010 Tomasz Rostanski (rozteck@interia.pl)
5  * Copyright 2012 Wojciech Treter (juzefwt@gmail.com)
6  * Copyright 2010 Tomasz Rostański (rozteck@interia.pl)
7  * Copyright 2014 Bartosz Brachaczek (b.brachaczek@gmail.com)
8  * Copyright 2010, 2011, 2012, 2013, 2014 Rafał Przemysław Malinowski (rafal.przemyslaw.malinowski@gmail.com)
9  * %kadu copyright end%
10  *
11  * This program is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU General Public License as
13  * published by the Free Software Foundation; either version 2 of
14  * the License, or (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program. If not, see <http://www.gnu.org/licenses/>.
23  */
24 
25 #pragma once
26 
27 #include "exports.h"
28 
29 #include <QtCore/QPointer>
30 #include <QtWidgets/QWidget>
31 #include <injeqt/injeqt.h>
32 
33 class InjectedFactory;
34 
35 class QAbstractItemView;
36 class QLabel;
37 class QLineEdit;
38 
39 class KADUAPI FilterWidget : public QWidget
40 {
41 	Q_OBJECT
42 
43 	QPointer<InjectedFactory> m_injectedFactory;
44 
45 	QLabel *Label;
46 	QLineEdit *NameFilterEdit;
47 
48 	QAbstractItemView *View;
49 	bool AutoVisibility;
50 
51 	void updateVisibility();
52 	bool sendKeyEventToView(QKeyEvent *);
53 
54 private slots:
55 	INJEQT_SET void setInjectedFactory(InjectedFactory *injectedFactory);
56 	INJEQT_INIT void init();
57 
58 	void filterTextChanged(const QString &);
59 
60 protected:
61 	virtual void keyPressEvent(QKeyEvent *);
62 
63 public:
64 	explicit FilterWidget(QWidget *parent = nullptr);
65 	virtual ~FilterWidget();
66 
67 	void setLabel(const QString &label);
68 	void setFilter(const QString &filter);
69 	void setView(QAbstractItemView *view);
70 	void setAutoVisibility(bool autoVisibility);
71 
72 	QString filterText() const;
73 
74 signals:
75 	void textChanged(const QString &text);
76 
77 };
78