Changeset View
Changeset View
Standalone View
Standalone View
libs/command/kundo2stack.cpp
Show First 20 Lines • Show All 219 Lines • ▼ Show 20 Line(s) | 219 | { | |||
---|---|---|---|---|---|
220 | Q_UNUSED(command); | 220 | Q_UNUSED(command); | ||
221 | return false; | 221 | return false; | ||
222 | } | 222 | } | ||
223 | 223 | | |||
224 | /*! | 224 | /*! | ||
225 | Applies a change to the document. This function must be implemented in | 225 | Applies a change to the document. This function must be implemented in | ||
226 | the derived class. Calling KUndo2QStack::push(), | 226 | the derived class. Calling KUndo2QStack::push(), | ||
227 | KUndo2QStack::undo() or KUndo2QStack::redo() from this function leads to | 227 | KUndo2QStack::undo() or KUndo2QStack::redo() from this function leads to | ||
228 | undefined beahavior. | 228 | undefined behavior. | ||
229 | 229 | | |||
230 | The default implementation calls redo() on all child commands. | 230 | The default implementation calls redo() on all child commands. | ||
231 | 231 | | |||
232 | \sa undo() | 232 | \sa undo() | ||
233 | */ | 233 | */ | ||
234 | 234 | | |||
235 | void KUndo2Command::redo() | 235 | void KUndo2Command::redo() | ||
236 | { | 236 | { | ||
237 | for (int i = 0; i < d->child_list.size(); ++i) | 237 | for (int i = 0; i < d->child_list.size(); ++i) | ||
238 | d->child_list.at(i)->redo(); | 238 | d->child_list.at(i)->redo(); | ||
239 | } | 239 | } | ||
240 | 240 | | |||
241 | /*! | 241 | /*! | ||
242 | Reverts a change to the document. After undo() is called, the state of | 242 | Reverts a change to the document. After undo() is called, the state of | ||
243 | the document should be the same as before redo() was called. This function must | 243 | the document should be the same as before redo() was called. This function must | ||
244 | be implemented in the derived class. Calling KUndo2QStack::push(), | 244 | be implemented in the derived class. Calling KUndo2QStack::push(), | ||
245 | KUndo2QStack::undo() or KUndo2QStack::redo() from this function leads to | 245 | KUndo2QStack::undo() or KUndo2QStack::redo() from this function leads to | ||
246 | undefined beahavior. | 246 | undefined behavior. | ||
247 | 247 | | |||
248 | The default implementation calls undo() on all child commands in reverse order. | 248 | The default implementation calls undo() on all child commands in reverse order. | ||
249 | 249 | | |||
250 | \sa redo() | 250 | \sa redo() | ||
251 | */ | 251 | */ | ||
252 | 252 | | |||
253 | void KUndo2Command::undo() | 253 | void KUndo2Command::undo() | ||
254 | { | 254 | { | ||
▲ Show 20 Lines • Show All 322 Lines • ▼ Show 20 Line(s) | 557 | { | |||
577 | } | 577 | } | ||
578 | 578 | | |||
579 | if (cleanStateChanged) { | 579 | if (cleanStateChanged) { | ||
580 | emit cleanChanged(isClean()); | 580 | emit cleanChanged(isClean()); | ||
581 | } | 581 | } | ||
582 | } | 582 | } | ||
583 | 583 | | |||
584 | /*! \internal | 584 | /*! \internal | ||
585 | If the number of commands on the stack exceedes the undo limit, deletes commands from | 585 | If the number of commands on the stack exceeds the undo limit, deletes commands from | ||
586 | the bottom of the stack. | 586 | the bottom of the stack. | ||
587 | 587 | | |||
588 | Returns true if commands were deleted. | 588 | Returns true if commands were deleted. | ||
589 | */ | 589 | */ | ||
590 | 590 | | |||
591 | bool KUndo2QStack::checkUndoLimit() | 591 | bool KUndo2QStack::checkUndoLimit() | ||
592 | { | 592 | { | ||
593 | if (m_undo_limit <= 0 || !m_macro_stack.isEmpty() || m_undo_limit >= m_command_list.count()) | 593 | if (m_undo_limit <= 0 || !m_macro_stack.isEmpty() || m_undo_limit >= m_command_list.count()) | ||
▲ Show 20 Lines • Show All 143 Lines • ▼ Show 20 Line(s) | 710 | { | |||
737 | * QVector field in the commands using 3 parameters. | 737 | * QVector field in the commands using 3 parameters. | ||
738 | * | 738 | * | ||
739 | * N : Number of commands that should remain individual at the top of the | 739 | * N : Number of commands that should remain individual at the top of the | ||
740 | * stack. | 740 | * stack. | ||
741 | * | 741 | * | ||
742 | * T1 : Time lapsed between current command and previously merged command | 742 | * T1 : Time lapsed between current command and previously merged command | ||
743 | * -- signal to merge throughout the stack. | 743 | * -- signal to merge throughout the stack. | ||
744 | * | 744 | * | ||
745 | * T2 : Time elapsed between two commands signalling both commands belong | 745 | * T2 : Time elapsed between two commands signaling both commands belong | ||
746 | * of the same set | 746 | * of the same set | ||
747 | * | 747 | * | ||
748 | * Whenever a KUndo2Command is initialized -- it consists of a start-time | 748 | * Whenever a KUndo2Command is initialized -- it consists of a start-time | ||
749 | * and when it is pushed -- an end time. Every time a command is pushed -- | 749 | * and when it is pushed -- an end time. Every time a command is pushed -- | ||
750 | * it checks whether the command pushed was pushed after T1 seconds of the | 750 | * it checks whether the command pushed was pushed after T1 seconds of the | ||
751 | * last merged command Then the merging begins with each group depending on | 751 | * last merged command Then the merging begins with each group depending on | ||
752 | * the time in between each command (T2). | 752 | * the time in between each command (T2). | ||
753 | * | 753 | * | ||
▲ Show 20 Lines • Show All 720 Lines • Show Last 20 Lines |