From d904227bfe0a5aea25fc24274ad86f2f886645a0 Mon Sep 17 00:00:00 2001 From: nils Date: Sat, 29 Jan 2011 20:30:59 +0000 Subject: undoable encrypt and decrypt git-svn-id: http://cpunk.de/svn/src/gpg4usb/trunk@454 34ebc366-c3a9-4b3c-9f84-69acf7962910 --- TODO | 6 +++--- gpgwin.cpp | 16 +++++++++++++--- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/TODO b/TODO index 68b6045..d3e68ea 100644 --- a/TODO +++ b/TODO @@ -33,14 +33,14 @@ attachments: - add tab for editor options, like font-size, line-break, tab-width, line-numbers,.. - update gpgme-library - clean header if quoted printable decoded -- add quote button +- add quote button [DONE] - fix overwrite file bug in file encryption [DONE] - add drag'n'drop features for keys [DONE] - add posibility to change password of key - check and add missing statusbar messages - add editorpage-method setmodified -- tab switching tab down doesn't work right in windows -- list keys to delete in warning dialog +- list keys to delete in warning dialog [DONE] +- undoable encrypt and decrypt [DONE] Release 0.3 - PGP-MIME, find and show inline encrypted files diff --git a/gpgwin.cpp b/gpgwin.cpp index 3da557c..1b1fc18 100644 --- a/gpgwin.cpp +++ b/gpgwin.cpp @@ -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(); } } -- cgit v1.2.3