Changeset View
Changeset View
Standalone View
Standalone View
tools/selection/text/kpToolText_KeyboardEvents_HandleArrowKeys.cpp
Show First 20 Lines • Show All 51 Lines • ▼ Show 20 Line(s) | |||||
52 | // protected | 52 | // protected | ||
53 | void kpToolText::handleUpKeyPress (QKeyEvent *e, | 53 | void kpToolText::handleUpKeyPress (QKeyEvent *e, | ||
54 | const QList <QString> &textLines, int cursorRow, int cursorCol) | 54 | const QList <QString> &textLines, int cursorRow, int cursorCol) | ||
55 | { | 55 | { | ||
56 | #if DEBUG_KP_TOOL_TEXT | 56 | #if DEBUG_KP_TOOL_TEXT | ||
57 | qCDebug(kpLogTools) << "\tup pressed"; | 57 | qCDebug(kpLogTools) << "\tup pressed"; | ||
58 | #endif | 58 | #endif | ||
59 | 59 | | |||
60 | if (hasBegunShape ()) | 60 | if (hasBegunShape ()) { | ||
61 | endShape (currentPoint (), normalizedRect ()); | 61 | endShape (currentPoint (), normalizedRect ()); | ||
62 | } | ||||
62 | 63 | | |||
63 | if (!textLines.isEmpty () && cursorRow > 0) | 64 | if (!textLines.isEmpty () && cursorRow > 0) | ||
64 | { | 65 | { | ||
65 | cursorRow--; | 66 | cursorRow--; | ||
66 | cursorCol = qMin (cursorCol, textLines [cursorRow].length ()); | 67 | cursorCol = qMin (cursorCol, textLines [cursorRow].length ()); | ||
67 | viewManager ()->setTextCursorPosition (cursorRow, cursorCol); | 68 | viewManager ()->setTextCursorPosition (cursorRow, cursorCol); | ||
68 | } | 69 | } | ||
69 | 70 | | |||
70 | e->accept (); | 71 | e->accept (); | ||
71 | } | 72 | } | ||
72 | 73 | | |||
73 | // protected | 74 | // protected | ||
74 | void kpToolText::handleDownKeyPress (QKeyEvent *e, | 75 | void kpToolText::handleDownKeyPress (QKeyEvent *e, | ||
75 | const QList <QString> &textLines, int cursorRow, int cursorCol) | 76 | const QList <QString> &textLines, int cursorRow, int cursorCol) | ||
76 | { | 77 | { | ||
77 | #if DEBUG_KP_TOOL_TEXT | 78 | #if DEBUG_KP_TOOL_TEXT | ||
78 | qCDebug(kpLogTools) << "\tdown pressed"; | 79 | qCDebug(kpLogTools) << "\tdown pressed"; | ||
79 | #endif | 80 | #endif | ||
80 | 81 | | |||
81 | if (hasBegunShape ()) | 82 | if (hasBegunShape ()) { | ||
82 | endShape (currentPoint (), normalizedRect ()); | 83 | endShape (currentPoint (), normalizedRect ()); | ||
84 | } | ||||
83 | 85 | | |||
84 | if (!textLines.isEmpty () && cursorRow < textLines.size () - 1) | 86 | if (!textLines.isEmpty () && cursorRow < textLines.size () - 1) | ||
85 | { | 87 | { | ||
86 | cursorRow++; | 88 | cursorRow++; | ||
87 | cursorCol = qMin (cursorCol, textLines [cursorRow].length ()); | 89 | cursorCol = qMin (cursorCol, textLines [cursorRow].length ()); | ||
88 | viewManager ()->setTextCursorPosition (cursorRow, cursorCol); | 90 | viewManager ()->setTextCursorPosition (cursorRow, cursorCol); | ||
89 | } | 91 | } | ||
90 | 92 | | |||
91 | e->accept (); | 93 | e->accept (); | ||
92 | } | 94 | } | ||
93 | 95 | | |||
94 | // protected | 96 | // protected | ||
95 | void kpToolText::handleLeftKeyPress (QKeyEvent *e, | 97 | void kpToolText::handleLeftKeyPress (QKeyEvent *e, | ||
96 | const QList <QString> &textLines, int cursorRow, int cursorCol) | 98 | const QList <QString> &textLines, int cursorRow, int cursorCol) | ||
97 | { | 99 | { | ||
98 | #if DEBUG_KP_TOOL_TEXT | 100 | #if DEBUG_KP_TOOL_TEXT | ||
99 | qCDebug(kpLogTools) << "\tleft pressed"; | 101 | qCDebug(kpLogTools) << "\tleft pressed"; | ||
100 | #endif | 102 | #endif | ||
101 | 103 | | |||
102 | if (hasBegunShape ()) | 104 | if (hasBegunShape ()) { | ||
103 | endShape (currentPoint (), normalizedRect ()); | 105 | endShape (currentPoint (), normalizedRect ()); | ||
106 | } | ||||
104 | 107 | | |||
105 | if (!textLines.isEmpty ()) | 108 | if (!textLines.isEmpty ()) | ||
106 | { | 109 | { | ||
107 | if ((e->modifiers () & Qt::ControlModifier) == 0) | 110 | if ((e->modifiers () & Qt::ControlModifier) == 0) | ||
108 | { | 111 | { | ||
109 | #if DEBUG_KP_TOOL_TEXT | 112 | #if DEBUG_KP_TOOL_TEXT | ||
110 | qCDebug(kpLogTools) << "\tmove single char"; | 113 | qCDebug(kpLogTools) << "\tmove single char"; | ||
111 | #endif | 114 | #endif | ||
Show All 18 Lines | |||||
130 | // protected | 133 | // protected | ||
131 | void kpToolText::handleRightKeyPress (QKeyEvent *e, | 134 | void kpToolText::handleRightKeyPress (QKeyEvent *e, | ||
132 | const QList <QString> &textLines, int cursorRow, int cursorCol) | 135 | const QList <QString> &textLines, int cursorRow, int cursorCol) | ||
133 | { | 136 | { | ||
134 | #if DEBUG_KP_TOOL_TEXT | 137 | #if DEBUG_KP_TOOL_TEXT | ||
135 | qCDebug(kpLogTools) << "\tright pressed"; | 138 | qCDebug(kpLogTools) << "\tright pressed"; | ||
136 | #endif | 139 | #endif | ||
137 | 140 | | |||
138 | if (hasBegunShape ()) | 141 | if (hasBegunShape ()) { | ||
139 | endShape (currentPoint (), normalizedRect ()); | 142 | endShape (currentPoint (), normalizedRect ()); | ||
143 | } | ||||
140 | 144 | | |||
141 | if (!textLines.isEmpty ()) | 145 | if (!textLines.isEmpty ()) | ||
142 | { | 146 | { | ||
143 | if ((e->modifiers () & Qt::ControlModifier) == 0) | 147 | if ((e->modifiers () & Qt::ControlModifier) == 0) | ||
144 | { | 148 | { | ||
145 | #if DEBUG_KP_TOOL_TEXT | 149 | #if DEBUG_KP_TOOL_TEXT | ||
146 | qCDebug(kpLogTools) << "\tmove single char"; | 150 | qCDebug(kpLogTools) << "\tmove single char"; | ||
147 | #endif | 151 | #endif | ||
Show All 19 Lines | |||||
167 | // protected | 171 | // protected | ||
168 | void kpToolText::handleHomeKeyPress (QKeyEvent *e, | 172 | void kpToolText::handleHomeKeyPress (QKeyEvent *e, | ||
169 | const QList <QString> &textLines, int cursorRow, int cursorCol) | 173 | const QList <QString> &textLines, int cursorRow, int cursorCol) | ||
170 | { | 174 | { | ||
171 | #if DEBUG_KP_TOOL_TEXT | 175 | #if DEBUG_KP_TOOL_TEXT | ||
172 | qCDebug(kpLogTools) << "\thome pressed"; | 176 | qCDebug(kpLogTools) << "\thome pressed"; | ||
173 | #endif | 177 | #endif | ||
174 | 178 | | |||
175 | if (hasBegunShape ()) | 179 | if (hasBegunShape ()) { | ||
176 | endShape (currentPoint (), normalizedRect ()); | 180 | endShape (currentPoint (), normalizedRect ()); | ||
181 | } | ||||
177 | 182 | | |||
178 | if (!textLines.isEmpty ()) | 183 | if (!textLines.isEmpty ()) | ||
179 | { | 184 | { | ||
180 | if (e->modifiers () & Qt::ControlModifier) | 185 | if (e->modifiers () & Qt::ControlModifier) { | ||
181 | cursorRow = 0; | 186 | cursorRow = 0; | ||
187 | } | ||||
182 | 188 | | |||
183 | cursorCol = 0; | 189 | cursorCol = 0; | ||
184 | 190 | | |||
185 | viewManager ()->setTextCursorPosition (cursorRow, cursorCol); | 191 | viewManager ()->setTextCursorPosition (cursorRow, cursorCol); | ||
186 | } | 192 | } | ||
187 | 193 | | |||
188 | e->accept (); | 194 | e->accept (); | ||
189 | } | 195 | } | ||
190 | 196 | | |||
191 | // protected | 197 | // protected | ||
192 | void kpToolText::handleEndKeyPress (QKeyEvent *e, | 198 | void kpToolText::handleEndKeyPress (QKeyEvent *e, | ||
193 | const QList <QString> &textLines, int cursorRow, int cursorCol) | 199 | const QList <QString> &textLines, int cursorRow, int cursorCol) | ||
194 | { | 200 | { | ||
195 | #if DEBUG_KP_TOOL_TEXT | 201 | #if DEBUG_KP_TOOL_TEXT | ||
196 | qCDebug(kpLogTools) << "\tend pressed"; | 202 | qCDebug(kpLogTools) << "\tend pressed"; | ||
197 | #endif | 203 | #endif | ||
198 | 204 | | |||
199 | if (hasBegunShape ()) | 205 | if (hasBegunShape ()) { | ||
200 | endShape (currentPoint (), normalizedRect ()); | 206 | endShape (currentPoint (), normalizedRect ()); | ||
207 | } | ||||
201 | 208 | | |||
202 | if (!textLines.isEmpty ()) | 209 | if (!textLines.isEmpty ()) | ||
203 | { | 210 | { | ||
204 | if (e->modifiers () & Qt::ControlModifier) | 211 | if (e->modifiers () & Qt::ControlModifier) { | ||
205 | cursorRow = textLines.size () - 1; | 212 | cursorRow = textLines.size () - 1; | ||
213 | } | ||||
206 | 214 | | |||
207 | cursorCol = textLines [cursorRow].length (); | 215 | cursorCol = textLines [cursorRow].length (); | ||
208 | 216 | | |||
209 | viewManager ()->setTextCursorPosition (cursorRow, cursorCol); | 217 | viewManager ()->setTextCursorPosition (cursorRow, cursorCol); | ||
210 | } | 218 | } | ||
211 | 219 | | |||
212 | e->accept (); | 220 | e->accept (); | ||
213 | } | 221 | } |