GNU Octave  4.0.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
KeyMap.cc
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 2011-2015 Michael Goffioul
4 
5 This file is part of Octave.
6 
7 Octave is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation; either version 3 of the License, or (at your
10 option) any later version.
11 
12 Octave is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
16 
17 You should have received a copy of the GNU General Public License
18 along with Octave; see the file COPYING. If not, see
19 <http://www.gnu.org/licenses/>.
20 
21 */
22 
23 #ifdef HAVE_CONFIG_H
24 #include <config.h>
25 #endif
26 
27 #include <QMap>
28 #include <Qt>
29 
30 #include "KeyMap.h"
31 
32 namespace QtHandles
33 {
34 
35 namespace KeyMap
36 {
37 
38 std::string
39 qKeyToKeyString (int key)
40 {
41  static QMap<int, std::string> keyMapper;
42 
43  if (keyMapper.isEmpty ())
44  {
45  keyMapper[Qt::Key_Escape] = "escape";
46  keyMapper[Qt::Key_Tab] = "tab";
47  keyMapper[Qt::Key_Backtab] = "backtab";
48  keyMapper[Qt::Key_Backspace] = "backspace";
49  keyMapper[Qt::Key_Return] = "return";
50  keyMapper[Qt::Key_Enter] = "enter";
51  keyMapper[Qt::Key_Insert] = "insert";
52  keyMapper[Qt::Key_Delete] = "delete";
53  keyMapper[Qt::Key_Pause] = "pause";
54  keyMapper[Qt::Key_Print] = "print";
55  keyMapper[Qt::Key_SysReq] = "sysreq";
56  keyMapper[Qt::Key_Clear] = "clear";
57  keyMapper[Qt::Key_Home] = "home";
58  keyMapper[Qt::Key_End] = "end";
59  keyMapper[Qt::Key_Left] = "left";
60  keyMapper[Qt::Key_Up] = "up";
61  keyMapper[Qt::Key_Right] = "right";
62  keyMapper[Qt::Key_Down] = "down";
63  keyMapper[Qt::Key_PageUp] = "pageup";
64  keyMapper[Qt::Key_PageDown] = "pagedown";
65  keyMapper[Qt::Key_Shift] = "shift";
66  keyMapper[Qt::Key_Control] = "control";
67  keyMapper[Qt::Key_Meta] = "meta";
68  keyMapper[Qt::Key_Alt] = "alt";
69  keyMapper[Qt::Key_CapsLock] = "capslock";
70  keyMapper[Qt::Key_NumLock] = "numlock";
71  keyMapper[Qt::Key_ScrollLock] = "scrolllock";
72  keyMapper[Qt::Key_F1] = "f1";
73  keyMapper[Qt::Key_F2] = "f2";
74  keyMapper[Qt::Key_F3] = "f3";
75  keyMapper[Qt::Key_F4] = "f4";
76  keyMapper[Qt::Key_F5] = "f5";
77  keyMapper[Qt::Key_F6] = "f6";
78  keyMapper[Qt::Key_F7] = "f7";
79  keyMapper[Qt::Key_F8] = "f8";
80  keyMapper[Qt::Key_F9] = "f9";
81  keyMapper[Qt::Key_F10] = "f10";
82  keyMapper[Qt::Key_F11] = "f11";
83  keyMapper[Qt::Key_F12] = "f12";
84  keyMapper[Qt::Key_F13] = "f13";
85  keyMapper[Qt::Key_F14] = "f14";
86  keyMapper[Qt::Key_F15] = "f15";
87  keyMapper[Qt::Key_F16] = "f16";
88  keyMapper[Qt::Key_F17] = "f17";
89  keyMapper[Qt::Key_F18] = "f18";
90  keyMapper[Qt::Key_F19] = "f19";
91  keyMapper[Qt::Key_F20] = "f20";
92  keyMapper[Qt::Key_F21] = "f21";
93  keyMapper[Qt::Key_F22] = "f22";
94  keyMapper[Qt::Key_F23] = "f23";
95  keyMapper[Qt::Key_F24] = "f24";
96  keyMapper[Qt::Key_F25] = "f25";
97  keyMapper[Qt::Key_F26] = "f26";
98  keyMapper[Qt::Key_F27] = "f27";
99  keyMapper[Qt::Key_F28] = "f28";
100  keyMapper[Qt::Key_F29] = "f29";
101  keyMapper[Qt::Key_F30] = "f30";
102  keyMapper[Qt::Key_F31] = "f31";
103  keyMapper[Qt::Key_F32] = "f32";
104  keyMapper[Qt::Key_F33] = "f33";
105  keyMapper[Qt::Key_F34] = "f34";
106  keyMapper[Qt::Key_F35] = "f35";
107  keyMapper[Qt::Key_Super_L] = "super_l";
108  keyMapper[Qt::Key_Super_R] = "super_r";
109  keyMapper[Qt::Key_Menu] = "menu";
110  keyMapper[Qt::Key_Hyper_L] = "hyper_l";
111  keyMapper[Qt::Key_Hyper_R] = "hyper_r";
112  keyMapper[Qt::Key_Help] = "help";
113  keyMapper[Qt::Key_Direction_L] = "direction_l";
114  keyMapper[Qt::Key_Direction_R] = "direction_r";
115  keyMapper[Qt::Key_Space] = "space";
116  keyMapper[Qt::Key_Any] = "any";
117  keyMapper[Qt::Key_Exclam] = "exclam";
118  keyMapper[Qt::Key_QuoteDbl] = "quotedbl";
119  keyMapper[Qt::Key_NumberSign] = "numbersign";
120  keyMapper[Qt::Key_Dollar] = "dollar";
121  keyMapper[Qt::Key_Percent] = "percent";
122  keyMapper[Qt::Key_Ampersand] = "ampersand";
123  keyMapper[Qt::Key_Apostrophe] = "apostrophe";
124  keyMapper[Qt::Key_ParenLeft] = "parenleft";
125  keyMapper[Qt::Key_ParenRight] = "parenright";
126  keyMapper[Qt::Key_Asterisk] = "asterisk";
127  keyMapper[Qt::Key_Plus] = "plus";
128  keyMapper[Qt::Key_Comma] = "comma";
129  keyMapper[Qt::Key_Minus] = "minus";
130  keyMapper[Qt::Key_Period] = "period";
131  keyMapper[Qt::Key_Slash] = "slash";
132  keyMapper[Qt::Key_0] = "0";
133  keyMapper[Qt::Key_1] = "1";
134  keyMapper[Qt::Key_2] = "2";
135  keyMapper[Qt::Key_3] = "3";
136  keyMapper[Qt::Key_4] = "4";
137  keyMapper[Qt::Key_5] = "5";
138  keyMapper[Qt::Key_6] = "6";
139  keyMapper[Qt::Key_7] = "7";
140  keyMapper[Qt::Key_8] = "8";
141  keyMapper[Qt::Key_9] = "9";
142  keyMapper[Qt::Key_Colon] = "colon";
143  keyMapper[Qt::Key_Semicolon] = "semicolon";
144  keyMapper[Qt::Key_Less] = "less";
145  keyMapper[Qt::Key_Equal] = "equal";
146  keyMapper[Qt::Key_Greater] = "greater";
147  keyMapper[Qt::Key_Question] = "question";
148  keyMapper[Qt::Key_At] = "at";
149  keyMapper[Qt::Key_A] = "a";
150  keyMapper[Qt::Key_B] = "b";
151  keyMapper[Qt::Key_C] = "c";
152  keyMapper[Qt::Key_D] = "d";
153  keyMapper[Qt::Key_E] = "e";
154  keyMapper[Qt::Key_F] = "f";
155  keyMapper[Qt::Key_G] = "g";
156  keyMapper[Qt::Key_H] = "h";
157  keyMapper[Qt::Key_I] = "i";
158  keyMapper[Qt::Key_J] = "j";
159  keyMapper[Qt::Key_K] = "k";
160  keyMapper[Qt::Key_L] = "l";
161  keyMapper[Qt::Key_M] = "m";
162  keyMapper[Qt::Key_N] = "n";
163  keyMapper[Qt::Key_O] = "o";
164  keyMapper[Qt::Key_P] = "p";
165  keyMapper[Qt::Key_Q] = "q";
166  keyMapper[Qt::Key_R] = "r";
167  keyMapper[Qt::Key_S] = "s";
168  keyMapper[Qt::Key_T] = "t";
169  keyMapper[Qt::Key_U] = "u";
170  keyMapper[Qt::Key_V] = "v";
171  keyMapper[Qt::Key_W] = "w";
172  keyMapper[Qt::Key_X] = "x";
173  keyMapper[Qt::Key_Y] = "y";
174  keyMapper[Qt::Key_Z] = "z";
175  keyMapper[Qt::Key_BracketLeft] = "bracketleft";
176  keyMapper[Qt::Key_Backslash] = "backslash";
177  keyMapper[Qt::Key_BracketRight] = "bracketright";
178  keyMapper[Qt::Key_AsciiCircum] = "asciicircum";
179  keyMapper[Qt::Key_Underscore] = "underscore";
180  keyMapper[Qt::Key_QuoteLeft] = "quoteleft";
181  keyMapper[Qt::Key_BraceLeft] = "braceleft";
182  keyMapper[Qt::Key_Bar] = "bar";
183  keyMapper[Qt::Key_BraceRight] = "braceright";
184  keyMapper[Qt::Key_AsciiTilde] = "asciitilde";
185 
186  keyMapper[Qt::Key_nobreakspace] = "nobreakspace";
187  keyMapper[Qt::Key_exclamdown] = "exclamdown";
188  keyMapper[Qt::Key_cent] = "cent";
189  keyMapper[Qt::Key_sterling] = "sterling";
190  keyMapper[Qt::Key_currency] = "currency";
191  keyMapper[Qt::Key_yen] = "yen";
192  keyMapper[Qt::Key_brokenbar] = "brokenbar";
193  keyMapper[Qt::Key_section] = "section";
194  keyMapper[Qt::Key_diaeresis] = "diaeresis";
195  keyMapper[Qt::Key_copyright] = "copyright";
196  keyMapper[Qt::Key_ordfeminine] = "ordfeminine";
197  keyMapper[Qt::Key_guillemotleft] = "guillemotleft";
198  keyMapper[Qt::Key_notsign] = "notsign";
199  keyMapper[Qt::Key_hyphen] = "hyphen";
200  keyMapper[Qt::Key_registered] = "registered";
201  keyMapper[Qt::Key_macron] = "macron";
202  keyMapper[Qt::Key_degree] = "degree";
203  keyMapper[Qt::Key_plusminus] = "plusminus";
204  keyMapper[Qt::Key_twosuperior] = "twosuperior";
205  keyMapper[Qt::Key_threesuperior] = "threesuperior";
206  keyMapper[Qt::Key_acute] = "acute";
207  keyMapper[Qt::Key_mu] = "mu";
208  keyMapper[Qt::Key_paragraph] = "paragraph";
209  keyMapper[Qt::Key_periodcentered] = "periodcentered";
210  keyMapper[Qt::Key_cedilla] = "cedilla";
211  keyMapper[Qt::Key_onesuperior] = "onesuperior";
212  keyMapper[Qt::Key_masculine] = "masculine";
213  keyMapper[Qt::Key_guillemotright] = "guillemotright";
214  keyMapper[Qt::Key_onequarter] = "onequarter";
215  keyMapper[Qt::Key_onehalf] = "onehalf";
216  keyMapper[Qt::Key_threequarters] = "threequarters";
217  keyMapper[Qt::Key_questiondown] = "questiondown";
218  keyMapper[Qt::Key_Agrave] = "agrave";
219  keyMapper[Qt::Key_Aacute] = "aacute";
220  keyMapper[Qt::Key_Acircumflex] = "acircumflex";
221  keyMapper[Qt::Key_Atilde] = "atilde";
222  keyMapper[Qt::Key_Adiaeresis] = "adiaeresis";
223  keyMapper[Qt::Key_Aring] = "aring";
224  keyMapper[Qt::Key_AE] = "ae";
225  keyMapper[Qt::Key_Ccedilla] = "ccedilla";
226  keyMapper[Qt::Key_Egrave] = "egrave";
227  keyMapper[Qt::Key_Eacute] = "eacute";
228  keyMapper[Qt::Key_Ecircumflex] = "ecircumflex";
229  keyMapper[Qt::Key_Ediaeresis] = "ediaeresis";
230  keyMapper[Qt::Key_Igrave] = "igrave";
231  keyMapper[Qt::Key_Iacute] = "iacute";
232  keyMapper[Qt::Key_Icircumflex] = "icircumflex";
233  keyMapper[Qt::Key_Idiaeresis] = "idiaeresis";
234  keyMapper[Qt::Key_ETH] = "eth";
235  keyMapper[Qt::Key_Ntilde] = "ntilde";
236  keyMapper[Qt::Key_Ograve] = "ograve";
237  keyMapper[Qt::Key_Oacute] = "oacute";
238  keyMapper[Qt::Key_Ocircumflex] = "ocircumflex";
239  keyMapper[Qt::Key_Otilde] = "otilde";
240  keyMapper[Qt::Key_Odiaeresis] = "odiaeresis";
241  keyMapper[Qt::Key_multiply] = "multiply";
242  keyMapper[Qt::Key_Ooblique] = "ooblique";
243  keyMapper[Qt::Key_Ugrave] = "ugrave";
244  keyMapper[Qt::Key_Uacute] = "uacute";
245  keyMapper[Qt::Key_Ucircumflex] = "ucircumflex";
246  keyMapper[Qt::Key_Udiaeresis] = "udiaeresis";
247  keyMapper[Qt::Key_Yacute] = "yacute";
248  keyMapper[Qt::Key_THORN] = "thorn";
249  keyMapper[Qt::Key_ssharp] = "ssharp";
250  keyMapper[Qt::Key_division] = "division";
251  keyMapper[Qt::Key_ydiaeresis] = "ydiaeresis";
252  }
253 
254  return keyMapper.value (key, std::string ("<unknown key>"));
255 }
256 
257 }; //namespace KeyMap
258 
259 }; // namespace QtHandles
std::string qKeyToKeyString(int key)
Definition: KeyMap.cc:39