diff options
author | nils <nils@34ebc366-c3a9-4b3c-9f84-69acf7962910> | 2011-01-29 20:30:59 +0000 |
---|---|---|
committer | nils <nils@34ebc366-c3a9-4b3c-9f84-69acf7962910> | 2011-01-29 20:30:59 +0000 |
commit | d904227bfe0a5aea25fc24274ad86f2f886645a0 (patch) | |
tree | 44b77f673c2663c10dc3efd5d13bcc8f3619a331 /gpgwin.cpp | |
parent | show keys to delete in deletion dialog (diff) | |
download | gpg4usb-d904227bfe0a5aea25fc24274ad86f2f886645a0.tar.gz gpg4usb-d904227bfe0a5aea25fc24274ad86f2f886645a0.zip |
undoable encrypt and decrypt
git-svn-id: http://cpunk.de/svn/src/gpg4usb/trunk@454 34ebc366-c3a9-4b3c-9f84-69acf7962910
Diffstat (limited to 'gpgwin.cpp')
-rw-r--r-- | gpgwin.cpp | 16 |
1 files changed, 13 insertions, 3 deletions
@@ -479,10 +479,15 @@ void GpgWin::encrypt() QStringList *uidList = mKeyList->getChecked(); QByteArray *tmp = new QByteArray(); -// if (mCtx->encrypt(uidList, edit.curTextPage.toPlainText().toUtf8(), tmp)) { if (mCtx->encrypt(uidList, edit->curTextPage()->toPlainText().toUtf8(), tmp)) { QString *tmp2 = new QString(*tmp); - edit->curTextPage()->setPlainText(*tmp2); + + // beginEditBlock and endEditBlock() let operation look like single undo/redo operation + QTextCursor cursor(edit->curTextPage()->document()); + cursor.beginEditBlock(); + edit->curTextPage()->selectAll(); + edit->curTextPage()->insertPlainText(*tmp2); + cursor.endEditBlock(); } } @@ -516,7 +521,12 @@ void GpgWin::decrypt() } } } - edit->curTextPage()->setPlainText(QString::fromUtf8(*decrypted)); + // beginEditBlock and endEditBlock() let operation look like single undo/redo operation + QTextCursor cursor(edit->curTextPage()->document()); + cursor.beginEditBlock(); + edit->curTextPage()->selectAll(); + edit->curTextPage()->insertPlainText(QString::fromUtf8(*decrypted)); + cursor.endEditBlock(); } } |