aboutsummaryrefslogtreecommitdiffstats
path: root/textedit.cpp
diff options
context:
space:
mode:
authornils <nils@34ebc366-c3a9-4b3c-9f84-69acf7962910>2011-11-06 22:03:58 +0000
committernils <nils@34ebc366-c3a9-4b3c-9f84-69acf7962910>2011-11-06 22:03:58 +0000
commiteaa4e699ebe9739cb353751286006480413d5594 (patch)
tree81e4dc2b368db42aa569a6fe51c969de45494328 /textedit.cpp
parentshow keyring files in importkeyfromfile-dialog (diff)
downloadgpg4usb-eaa4e699ebe9739cb353751286006480413d5594.tar.gz
gpg4usb-eaa4e699ebe9739cb353751286006480413d5594.zip
fixed a lot of bugs, where app crached, when no tab is opened (liek save as, quote, undo, copy...) or when no key is selected (keydetails)
git-svn-id: http://cpunk.de/svn/src/gpg4usb/trunk@602 34ebc366-c3a9-4b3c-9f84-69acf7962910
Diffstat (limited to 'textedit.cpp')
-rw-r--r--textedit.cpp45
1 files changed, 45 insertions, 0 deletions
diff --git a/textedit.cpp b/textedit.cpp
index 57a91e9..b60c28d 100644
--- a/textedit.cpp
+++ b/textedit.cpp
@@ -89,6 +89,10 @@ void TextEdit::open()
void TextEdit::save()
{
+ if (tabWidget->count() == 0) {
+ return;
+ }
+
QString fileName = curPage()->getFilePath();
if (fileName.isEmpty()) {
@@ -137,6 +141,10 @@ bool TextEdit::saveFile(const QString &fileName)
bool TextEdit::saveAs()
{
+ if (tabWidget->count() == 0) {
+ return true;
+ }
+
EditorPage *page = curPage();
QString path;
if(page->getFilePath() != "") {
@@ -296,6 +304,11 @@ QPlainTextEdit* TextEdit::curTextPage()
}
+int TextEdit::tabCount()
+{
+ return tabWidget->count();
+}
+
EditorPage* TextEdit::curPage()
{
EditorPage *curPage = qobject_cast<EditorPage *>(tabWidget->currentWidget());
@@ -304,6 +317,10 @@ EditorPage* TextEdit::curPage()
void TextEdit::quote()
{
+ if (tabWidget->count() == 0) {
+ return;
+ }
+
QTextCursor cursor(curTextPage()->document());
// beginEditBlock and endEditBlock() let operation look like single undo/redo operation
@@ -355,6 +372,10 @@ QString TextEdit::strippedName(const QString &fullFileName)
void TextEdit::print()
{
+ if (tabWidget->count() == 0) {
+ return;
+ }
+
#ifndef QT_NO_PRINTER
QTextDocument *document = curTextPage()->document();
QPrinter printer;
@@ -415,31 +436,55 @@ QHash<int, QString> TextEdit::unsavedDocuments() {
void TextEdit::cut()
{
+ if (tabWidget->count() == 0) {
+ return;
+ }
+
curTextPage()->cut();
}
void TextEdit::copy()
{
+ if (tabWidget->count() == 0) {
+ return;
+ }
+
curTextPage()->copy();
}
void TextEdit::paste()
{
+ if (tabWidget->count() == 0) {
+ return;
+ }
+
curTextPage()->paste();
}
void TextEdit::undo()
{
+ if (tabWidget->count() == 0) {
+ return;
+ }
+
curTextPage()->undo();
}
void TextEdit::redo()
{
+ if (tabWidget->count() == 0) {
+ return;
+ }
+
curTextPage()->redo();
}
void TextEdit::selectAll()
{
+ if (tabWidget->count() == 0) {
+ return;
+ }
+
curTextPage()->selectAll();
}