author | llornkcor <llornkcor> | 2003-02-28 18:13:41 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2003-02-28 18:13:41 (UTC) |
commit | 64423f1852a13178f23365f2bba995ef2c355b3b (patch) (unidiff) | |
tree | 074d12cbd3b762fbcd0eac686c5b7fab3617453d | |
parent | d4db61dbd748040bed740e08a839e01b86af2c87 (diff) | |
download | opie-64423f1852a13178f23365f2bba995ef2c355b3b.zip opie-64423f1852a13178f23365f2bba995ef2c355b3b.tar.gz opie-64423f1852a13178f23365f2bba995ef2c355b3b.tar.bz2 |
no goto for 0 length texts
-rw-r--r-- | core/apps/textedit/textedit.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp index 797c61b..5edf102 100644 --- a/core/apps/textedit/textedit.cpp +++ b/core/apps/textedit/textedit.cpp | |||
@@ -1129,75 +1129,77 @@ int TextEdit::savePrompt() | |||
1129 | } | 1129 | } |
1130 | 1130 | ||
1131 | void TextEdit::timerCrank() | 1131 | void TextEdit::timerCrank() |
1132 | { | 1132 | { |
1133 | if(featureAutoSave && edited1) | 1133 | if(featureAutoSave && edited1) |
1134 | { | 1134 | { |
1135 | if(currentFileName.isEmpty()) | 1135 | if(currentFileName.isEmpty()) |
1136 | { | 1136 | { |
1137 | currentFileName = QDir::homeDirPath()+"/textedit.tmp"; | 1137 | currentFileName = QDir::homeDirPath()+"/textedit.tmp"; |
1138 | saveAs(); | 1138 | saveAs(); |
1139 | } | 1139 | } |
1140 | else | 1140 | else |
1141 | { | 1141 | { |
1142 | // qDebug("autosave"); | 1142 | // qDebug("autosave"); |
1143 | save(); | 1143 | save(); |
1144 | } | 1144 | } |
1145 | setTimer(); | 1145 | setTimer(); |
1146 | } | 1146 | } |
1147 | } | 1147 | } |
1148 | 1148 | ||
1149 | void TextEdit::doTimer(bool b) | 1149 | void TextEdit::doTimer(bool b) |
1150 | { | 1150 | { |
1151 | Config cfg("TextEdit"); | 1151 | Config cfg("TextEdit"); |
1152 | cfg.setGroup ( "View" ); | 1152 | cfg.setGroup ( "View" ); |
1153 | cfg.writeEntry ( "autosave", b); | 1153 | cfg.writeEntry ( "autosave", b); |
1154 | featureAutoSave = b; | 1154 | featureAutoSave = b; |
1155 | nAutoSave->setOn(b); | 1155 | nAutoSave->setOn(b); |
1156 | if(b) | 1156 | if(b) |
1157 | { | 1157 | { |
1158 | // qDebug("doTimer true"); | 1158 | // qDebug("doTimer true"); |
1159 | setTimer(); | 1159 | setTimer(); |
1160 | } | 1160 | } |
1161 | // else | 1161 | // else |
1162 | // qDebug("doTimer false"); | 1162 | // qDebug("doTimer false"); |
1163 | } | 1163 | } |
1164 | 1164 | ||
1165 | void TextEdit::setTimer() | 1165 | void TextEdit::setTimer() |
1166 | { | 1166 | { |
1167 | if(featureAutoSave) | 1167 | if(featureAutoSave) |
1168 | { | 1168 | { |
1169 | // qDebug("setting autosave"); | 1169 | // qDebug("setting autosave"); |
1170 | QTimer *timer = new QTimer(this ); | 1170 | QTimer *timer = new QTimer(this ); |
1171 | connect( timer, SIGNAL(timeout()), this, SLOT(timerCrank()) ); | 1171 | connect( timer, SIGNAL(timeout()), this, SLOT(timerCrank()) ); |
1172 | timer->start( 300000, true); //5 minutes | 1172 | timer->start( 300000, true); //5 minutes |
1173 | } | 1173 | } |
1174 | } | 1174 | } |
1175 | 1175 | ||
1176 | void TextEdit::gotoLine() { | 1176 | void TextEdit::gotoLine() { |
1177 | 1177 | if( editor->length() < 1) | |
1178 | return; | ||
1178 | QWidget *d = QApplication::desktop(); | 1179 | QWidget *d = QApplication::desktop(); |
1179 | gotoEdit = new QLineEdit( 0, "Goto line"); | 1180 | gotoEdit = new QLineEdit( 0, "Goto line"); |
1180 | 1181 | ||
1181 | gotoEdit->move( (d->width()/2) - ( gotoEdit->width()/2) , (d->height()/2) - (gotoEdit->height()/2)); | 1182 | gotoEdit->move( (d->width()/2) - ( gotoEdit->width()/2) , (d->height()/2) - (gotoEdit->height()/2)); |
1182 | gotoEdit->setFrame(true); | 1183 | gotoEdit->setFrame(true); |
1183 | gotoEdit->show(); | 1184 | gotoEdit->show(); |
1184 | connect (gotoEdit,SIGNAL(returnPressed()), this, SLOT(doGoto())); | 1185 | connect (gotoEdit,SIGNAL(returnPressed()), this, SLOT(doGoto())); |
1185 | } | 1186 | } |
1186 | 1187 | ||
1187 | void TextEdit::doGoto() { | 1188 | void TextEdit::doGoto() { |
1188 | QString number = gotoEdit->text(); | 1189 | QString number = gotoEdit->text(); |
1189 | gotoEdit->hide(); | 1190 | gotoEdit->hide(); |
1191 | |||
1190 | if(gotoEdit) { | 1192 | if(gotoEdit) { |
1191 | delete gotoEdit; | 1193 | delete gotoEdit; |
1192 | gotoEdit = 0; | 1194 | gotoEdit = 0; |
1193 | } | 1195 | } |
1194 | 1196 | ||
1195 | bool ok; | 1197 | bool ok; |
1196 | int lineNumber = number.toInt(&ok, 10); | 1198 | int lineNumber = number.toInt(&ok, 10); |
1197 | if(editor->numLines() < lineNumber) | 1199 | if( editor->numLines() < lineNumber) |
1198 | QMessageBox::message(tr("Text Edit"),tr("Not enough lines")); | 1200 | QMessageBox::message(tr("Text Edit"),tr("Not enough lines")); |
1199 | else | 1201 | else |
1200 | { | 1202 | { |
1201 | editor->setCursorPosition(lineNumber, 0, false); | 1203 | editor->setCursorPosition(lineNumber, 0, false); |
1202 | } | 1204 | } |
1203 | } | 1205 | } |