Changeset View
Changeset View
Standalone View
Standalone View
tools/selection/kpAbstractSelectionTool_Move.cpp
Show First 20 Lines • Show All 165 Lines • ▼ Show 20 Line(s) | |||||
166 | void kpAbstractSelectionTool::slotRMBMoveUpdateGUI () | 166 | void kpAbstractSelectionTool::slotRMBMoveUpdateGUI () | ||
167 | { | 167 | { | ||
168 | // (just in case not called from single shot) | 168 | // (just in case not called from single shot) | ||
169 | d->RMBMoveUpdateGUITimer->stop (); | 169 | d->RMBMoveUpdateGUITimer->stop (); | ||
170 | 170 | | |||
171 | /*virtual*/setSelectionBorderForBeginDrawMove (); | 171 | /*virtual*/setSelectionBorderForBeginDrawMove (); | ||
172 | 172 | | |||
173 | kpAbstractSelection * const sel = document ()->selection (); | 173 | kpAbstractSelection * const sel = document ()->selection (); | ||
174 | if (sel) | 174 | if (sel) { | ||
175 | setUserShapePoints (sel->topLeft ()); | 175 | setUserShapePoints (sel->topLeft ()); | ||
176 | } | 176 | } | ||
177 | } | ||||
177 | 178 | | |||
178 | //--------------------------------------------------------------------- | 179 | //--------------------------------------------------------------------- | ||
179 | 180 | | |||
180 | // private | 181 | // private | ||
181 | void kpAbstractSelectionTool::drawMove (const QPoint &thisPoint, const QRect &/*normalizedRect*/) | 182 | void kpAbstractSelectionTool::drawMove (const QPoint &thisPoint, const QRect &/*normalizedRect*/) | ||
182 | { | 183 | { | ||
183 | #if DEBUG_KP_TOOL_SELECTION && 1 | 184 | #if DEBUG_KP_TOOL_SELECTION && 1 | ||
184 | qCDebug(kpLogTools) << "\tmoving selection"; | 185 | qCDebug(kpLogTools) << "\tmoving selection"; | ||
185 | #endif | 186 | #endif | ||
186 | 187 | | |||
187 | kpAbstractSelection *sel = document ()->selection (); | 188 | kpAbstractSelection *sel = document ()->selection (); | ||
188 | 189 | | |||
189 | QRect targetSelRect (thisPoint.x () - d->startMoveDragFromSelectionTopLeft.x (), | 190 | QRect targetSelRect (thisPoint.x () - d->startMoveDragFromSelectionTopLeft.x (), | ||
190 | thisPoint.y () - d->startMoveDragFromSelectionTopLeft.y (), | 191 | thisPoint.y () - d->startMoveDragFromSelectionTopLeft.y (), | ||
191 | sel->width (), | 192 | sel->width (), | ||
192 | sel->height ()); | 193 | sel->height ()); | ||
193 | 194 | | |||
194 | #if DEBUG_KP_TOOL_SELECTION && 1 | 195 | #if DEBUG_KP_TOOL_SELECTION && 1 | ||
195 | qCDebug(kpLogTools) << "\t\tstartPoint=" << startPoint () | 196 | qCDebug(kpLogTools) << "\t\tstartPoint=" << startPoint () | ||
196 | << " thisPoint=" << thisPoint | 197 | << " thisPoint=" << thisPoint | ||
197 | << " startDragFromSel=" << d->startMoveDragFromSelectionTopLeft | 198 | << " startDragFromSel=" << d->startMoveDragFromSelectionTopLeft | ||
198 | << " targetSelRect=" << targetSelRect | 199 | << " targetSelRect=" << targetSelRect; | ||
199 | << endl; | | |||
200 | #endif | 200 | #endif | ||
201 | 201 | | |||
202 | // Try to make sure selection still intersects document so that it's | 202 | // Try to make sure selection still intersects document so that it's | ||
203 | // reachable. | 203 | // reachable. | ||
204 | 204 | | |||
205 | if (targetSelRect.right () < 0) | 205 | if (targetSelRect.right () < 0) { | ||
206 | targetSelRect.translate (-targetSelRect.right (), 0); | 206 | targetSelRect.translate (-targetSelRect.right (), 0); | ||
207 | else if (targetSelRect.left () >= document ()->width ()) | 207 | } | ||
208 | else if (targetSelRect.left () >= document ()->width ()) { | ||||
208 | targetSelRect.translate (document ()->width () - targetSelRect.left () - 1, 0); | 209 | targetSelRect.translate (document ()->width () - targetSelRect.left () - 1, 0); | ||
210 | } | ||||
209 | 211 | | |||
210 | if (targetSelRect.bottom () < 0) | 212 | if (targetSelRect.bottom () < 0) { | ||
211 | targetSelRect.translate (0, -targetSelRect.bottom ()); | 213 | targetSelRect.translate (0, -targetSelRect.bottom ()); | ||
212 | else if (targetSelRect.top () >= document ()->height ()) | 214 | } | ||
215 | else if (targetSelRect.top () >= document ()->height ()) { | ||||
213 | targetSelRect.translate (0, document ()->height () - targetSelRect.top () - 1); | 216 | targetSelRect.translate (0, document ()->height () - targetSelRect.top () - 1); | ||
217 | } | ||||
214 | 218 | | |||
215 | #if DEBUG_KP_TOOL_SELECTION && 1 | 219 | #if DEBUG_KP_TOOL_SELECTION && 1 | ||
216 | qCDebug(kpLogTools) << "\t\t\tafter ensure sel rect clickable=" << targetSelRect; | 220 | qCDebug(kpLogTools) << "\t\t\tafter ensure sel rect clickable=" << targetSelRect; | ||
217 | #endif | 221 | #endif | ||
218 | 222 | | |||
219 | 223 | | |||
220 | if (!d->dragAccepted && | 224 | if (!d->dragAccepted && | ||
221 | targetSelRect.topLeft () + d->startMoveDragFromSelectionTopLeft == startPoint ()) | 225 | targetSelRect.topLeft () + d->startMoveDragFromSelectionTopLeft == startPoint ()) | ||
Show All 31 Lines | 255 | d->currentMoveCommand = new kpToolSelectionMoveCommand ( | |||
253 | environ ()->commandEnvironment ()); | 257 | environ ()->commandEnvironment ()); | ||
254 | d->currentMoveCommandIsSmear = false; | 258 | d->currentMoveCommandIsSmear = false; | ||
255 | } | 259 | } | ||
256 | 260 | | |||
257 | 261 | | |||
258 | //viewManager ()->setQueueUpdates (); | 262 | //viewManager ()->setQueueUpdates (); | ||
259 | //viewManager ()->setFastUpdates (); | 263 | //viewManager ()->setFastUpdates (); | ||
260 | 264 | | |||
261 | if (shiftPressed ()) | 265 | if (shiftPressed ()) { | ||
262 | d->currentMoveCommandIsSmear = true; | 266 | d->currentMoveCommandIsSmear = true; | ||
267 | } | ||||
263 | 268 | | |||
264 | if (!d->dragAccepted && (controlPressed () || shiftPressed ())) | 269 | if (!d->dragAccepted && (controlPressed () || shiftPressed ())) { | ||
265 | d->currentMoveCommand->copyOntoDocument (); | 270 | d->currentMoveCommand->copyOntoDocument (); | ||
271 | } | ||||
266 | 272 | | |||
267 | d->currentMoveCommand->moveTo (targetSelRect.topLeft ()); | 273 | d->currentMoveCommand->moveTo (targetSelRect.topLeft ()); | ||
268 | 274 | | |||
269 | if (shiftPressed ()) | 275 | if (shiftPressed ()) { | ||
270 | d->currentMoveCommand->copyOntoDocument (); | 276 | d->currentMoveCommand->copyOntoDocument (); | ||
277 | } | ||||
271 | 278 | | |||
272 | //viewManager ()->restoreFastUpdates (); | 279 | //viewManager ()->restoreFastUpdates (); | ||
273 | //viewManager ()->restoreQueueUpdates (); | 280 | //viewManager ()->restoreQueueUpdates (); | ||
274 | 281 | | |||
275 | // REFACTOR: yuck, yuck | 282 | // REFACTOR: yuck, yuck | ||
276 | kpAbstractSelection *orgSel = d->currentMoveCommand->originalSelectionClone (); | 283 | kpAbstractSelection *orgSel = d->currentMoveCommand->originalSelectionClone (); | ||
277 | QPoint start = orgSel->topLeft (); | 284 | QPoint start = orgSel->topLeft (); | ||
278 | delete orgSel; | 285 | delete orgSel; | ||
Show All 12 Lines | |||||
291 | { | 298 | { | ||
292 | #if DEBUG_KP_TOOL_SELECTION | 299 | #if DEBUG_KP_TOOL_SELECTION | ||
293 | qCDebug(kpLogTools) << "\twas drag moving - undo drag and undo acquire"; | 300 | qCDebug(kpLogTools) << "\twas drag moving - undo drag and undo acquire"; | ||
294 | #endif | 301 | #endif | ||
295 | 302 | | |||
296 | d->RMBMoveUpdateGUITimer->stop (); | 303 | d->RMBMoveUpdateGUITimer->stop (); | ||
297 | 304 | | |||
298 | // NOP drag? | 305 | // NOP drag? | ||
299 | if (!d->currentMoveCommand) | 306 | if (!d->currentMoveCommand) { | ||
300 | return; | 307 | return; | ||
308 | } | ||||
301 | 309 | | |||
302 | #if DEBUG_KP_TOOL_SELECTION | 310 | #if DEBUG_KP_TOOL_SELECTION | ||
303 | qCDebug(kpLogTools) << "\t\tundo currentMoveCommand"; | 311 | qCDebug(kpLogTools) << "\t\tundo currentMoveCommand"; | ||
304 | #endif | 312 | #endif | ||
305 | d->currentMoveCommand->finalize (); | 313 | d->currentMoveCommand->finalize (); | ||
306 | d->currentMoveCommand->unexecute (); | 314 | d->currentMoveCommand->unexecute (); | ||
307 | delete d->currentMoveCommand; | 315 | delete d->currentMoveCommand; | ||
308 | d->currentMoveCommand = nullptr; | 316 | d->currentMoveCommand = nullptr; | ||
Show All 10 Lines | |||||
319 | //--------------------------------------------------------------------- | 327 | //--------------------------------------------------------------------- | ||
320 | 328 | | |||
321 | // private | 329 | // private | ||
322 | void kpAbstractSelectionTool::endDrawMove () | 330 | void kpAbstractSelectionTool::endDrawMove () | ||
323 | { | 331 | { | ||
324 | d->RMBMoveUpdateGUITimer->stop (); | 332 | d->RMBMoveUpdateGUITimer->stop (); | ||
325 | 333 | | |||
326 | // NOP drag? | 334 | // NOP drag? | ||
327 | if (!d->currentMoveCommand) | 335 | if (!d->currentMoveCommand) { | ||
328 | return; | 336 | return; | ||
337 | } | ||||
329 | 338 | | |||
330 | d->currentMoveCommand->finalize (); | 339 | d->currentMoveCommand->finalize (); | ||
331 | 340 | | |||
332 | kpMacroCommand *renamedCmd = nullptr; | 341 | kpMacroCommand *renamedCmd = nullptr; | ||
333 | #if DEBUG_KP_TOOL_SELECTION | 342 | #if DEBUG_KP_TOOL_SELECTION | ||
334 | qCDebug(kpLogTools) << "\thave moveCommand"; | 343 | qCDebug(kpLogTools) << "\thave moveCommand"; | ||
335 | #endif | 344 | #endif | ||
336 | if (d->currentMoveCommandIsSmear) | 345 | if (d->currentMoveCommandIsSmear) | ||
▲ Show 20 Lines • Show All 62 Lines • Show Last 20 Lines |