-----------------------------------------------------------------------------
| 18 | |
| 19 | //----------------------------------------------------------------------------- |
| 20 | void pqPythonUndoCommand::swapImpl(const pqPythonTextHistoryEntry& h) |
| 21 | { |
| 22 | // We block all text signals (this is done to avoid pushing twice |
| 23 | // the text in the undo stack) |
| 24 | const bool oldState = this->Text.blockSignals(true); |
| 25 | |
| 26 | const QString highlightedText = this->Highlighter->Highlight(h.content); |
| 27 | if (!highlightedText.isEmpty()) |
| 28 | { |
| 29 | this->Text.setHtml(highlightedText); |
| 30 | } |
| 31 | else |
| 32 | { |
| 33 | this->Text.setText(h.content); |
| 34 | } |
| 35 | |
| 36 | // Move the cursor |
| 37 | if (!h.isEmpty()) |
| 38 | { |
| 39 | QTextCursor cursor = this->Text.textCursor(); |
| 40 | cursor.setPosition(h.cursorPosition); |
| 41 | this->Text.setTextCursor(cursor); |
| 42 | } |
| 43 | |
| 44 | // re-enable the signals |
| 45 | this->Text.blockSignals(oldState); |
| 46 | }; |
| 47 | |
| 48 | //----------------------------------------------------------------------------- |
| 49 | void pqPythonUndoCommand::undo() |