1 /***************************************************************************
2  *   Copyright (C) 2006-2021 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 
22 #ifndef _KEYBOARDMANAGER_H
23 #define _KEYBOARDMANAGER_H
24 
25 class ListWidget;
26 class QKeyEvent;
27 
28 
29 /*!
30  * Class \b KeyboardManager represents key handler object that processes
31  * all key events passed to the \b PlayList
32  * @author Vladimir Kuznetsov <vovanec@gmail.com>
33  */
34 class KeyboardManager
35 {
36 public:
37     /*!
38      * Constructor. Takes \b PlayList object as an argument.
39      */
40     explicit KeyboardManager (ListWidget *l);
41     /*!
42      * Handles key press events from \b PlayList object. Returns \b true
43      * if the key was handled, otherwise \b false.
44      */
45     bool handleKeyPress (QKeyEvent*);
46     /*!
47      * Handles key release events from \b PlayList object. Returns \b true
48      * if the key was handled, otherwise \b false.
49      */
50     bool handleKeyRelease (QKeyEvent*);
51 
52 private:
53     void keyUp (QKeyEvent* ke);
54     void keyDown (QKeyEvent* ke);
55     void keyPgUp (QKeyEvent* ke);
56     void keyPgDown (QKeyEvent* ke);
57     void keyEnter (QKeyEvent* ke);
58     void keyHome(QKeyEvent* ke);
59     void keyEnd(QKeyEvent* ke);
60 
61     ListWidget* m_listWidget;
62 
63     enum SelectMode
64     {
65         SELECT_TOP = 0,
66         SELECT_BOTTOM,
67         SELECT_NEXT
68     };
69 };
70 
71 #endif
72