aboutsummaryrefslogtreecommitdiffstats
path: root/gpgwin.cpp
diff options
context:
space:
mode:
authornils <nils@34ebc366-c3a9-4b3c-9f84-69acf7962910>2011-01-29 20:30:59 +0000
committernils <nils@34ebc366-c3a9-4b3c-9f84-69acf7962910>2011-01-29 20:30:59 +0000
commitd904227bfe0a5aea25fc24274ad86f2f886645a0 (patch)
tree44b77f673c2663c10dc3efd5d13bcc8f3619a331 /gpgwin.cpp
parentshow keys to delete in deletion dialog (diff)
downloadgpg4usb-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.cpp16
1 files changed, 13 insertions, 3 deletions
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();
}
}