1 /***************************************************************************
2  *   Copyright (C) 2011-2013 by Ilya Kotov                                 *
3  *   forkotov02@ya.ru                                                      *
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 KEYBOARDMANAGER_H
22 #define KEYBOARDMANAGER_H
23 
24 #include <QObject>
25 #include <QList>
26 
27 class QAction;
28 class ListWidget;
29 
30 /**
31     @author Ilya Kotov <forkotov02@ya.ru>
32 */
33 class KeyboardManager : public QObject
34 {
35     Q_OBJECT
36 public:
37     explicit KeyboardManager(QObject *parent = nullptr);
38 
39     QList<QAction*> actions();
40     void setListWidget(ListWidget *listWidget);
41 
42 private slots:
43     void processUp();
44     void processDown();
45     void processEnter();
46     void processPgUp();
47     void processPgDown();
48     void processHome();
49     void processEnd();
50 
51 private:
52     QList<QAction*> m_actions;
53     ListWidget *m_listWidget = nullptr;
54     void addAction(int keys, const char * method);
55 
56     enum SelectMode
57     {
58         SELECT_TOP = 0,
59         SELECT_BOTTOM,
60         SELECT_NEXT
61     };
62 
63 };
64 
65 #endif // KEYBOARDMANAGER_H
66