-rw-r--r-- | core/apps/textedit/textedit.cpp | 4 |
1 files changed, 3 insertions, 1 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 @@ -985,219 +985,221 @@ void TextEdit::setDocument(const QString& fileref) { QFileInfo fi(currentFileName); qDebug("basename:"+fi.baseName()+": current filenmame "+currentFileName); if( (fi.baseName().left(1)).isEmpty() ) { openDotFile(currentFileName); } else { qDebug("setDoc open"); bFromDocView = true; openFile(fileref); editor->setEdited(true); edited1=false; edited=true; // fromSetDocument=false; // doSearchBar(); } } updateCaption( currentFileName); } void TextEdit::changeFont() { QDialog *d = new QDialog ( this, "FontDialog", true ); d-> setCaption ( tr( "Choose font" )); QBoxLayout *lay = new QVBoxLayout ( d ); OFontSelector *ofs = new OFontSelector ( true, d ); lay-> addWidget ( ofs ); ofs-> setSelectedFont ( editor-> font ( )); d-> showMaximized ( ); if ( d-> exec ( ) == QDialog::Accepted ) editor-> setFont ( ofs-> selectedFont ( )); delete d; } void TextEdit::editDelete() { switch ( QMessageBox::warning(this,tr("Text Editor"), tr("Do you really want<BR>to <B>delete</B> " "the current file\nfrom the disk?<BR>This is " "<B>irreversable!!</B>"), tr("Yes"),tr("No"),0,0,1) ) { case 0: if(doc) { doc->removeFiles(); clear(); setCaption( tr("Text Editor") ); } break; case 1: // exit break; }; } void TextEdit::changeStartConfig( bool b ) { startWithNew=b; Config cfg("TextEdit"); cfg.setGroup("View"); cfg.writeEntry("startNew",b); update(); } void TextEdit::editorChanged() { // qDebug("editor changed"); if( /*editor->edited() &&*/ /*edited && */!edited1) { setCaption( "*"+caption()); edited1=true; } edited=true; } void TextEdit::receive(const QCString&msg, const QByteArray &) { qDebug("QCop "+msg); if ( msg == "setDocument(QString)" ) { qDebug("bugger all"); } } void TextEdit::doAbout() { QMessageBox::about(0,tr("Text Edit"),tr("Text Edit is copyright<BR>" "2000 Trolltech AS, and<BR>" "2002 by <B>L. J. Potter <BR>llornkcor@handhelds.org</B><BR>" "and is licensed under the GPL")); } void TextEdit::doPrompt(bool b) { promptExit=b; Config cfg("TextEdit"); cfg.setGroup ( "View" ); cfg.writeEntry ( "PromptExit", b); } void TextEdit::doDesktop(bool b) { openDesktop=b; Config cfg("TextEdit"); cfg.setGroup ( "View" ); cfg.writeEntry ( "OpenDesktop", b); } void TextEdit::doFilePerms(bool b) { filePerms=b; Config cfg("TextEdit"); cfg.setGroup ( "View" ); cfg.writeEntry ( "FilePermissions", b); } void TextEdit::editPasteTimeDate() { #ifndef QT_NO_CLIPBOARD QClipboard *cb = QApplication::clipboard(); QDateTime dt = QDateTime::currentDateTime(); cb->setText( dt.toString()); editor->paste(); #endif } int TextEdit::savePrompt() { switch( QMessageBox::information( 0, (tr("Textedit")), (tr("Textedit detected\n" "you have unsaved changes\n" "Go ahead and save?\n")), (tr("Save")), (tr("Don't Save")), (tr("&Cancel")), 2, 2 ) ) { case 0: { return 1; } break; case 1: { return 2; } break; case 2: { return -1; } break; }; return 0; } void TextEdit::timerCrank() { if(featureAutoSave && edited1) { if(currentFileName.isEmpty()) { currentFileName = QDir::homeDirPath()+"/textedit.tmp"; saveAs(); } else { // qDebug("autosave"); save(); } setTimer(); } } void TextEdit::doTimer(bool b) { Config cfg("TextEdit"); cfg.setGroup ( "View" ); cfg.writeEntry ( "autosave", b); featureAutoSave = b; nAutoSave->setOn(b); if(b) { // qDebug("doTimer true"); setTimer(); } // else // qDebug("doTimer false"); } void TextEdit::setTimer() { if(featureAutoSave) { // qDebug("setting autosave"); QTimer *timer = new QTimer(this ); connect( timer, SIGNAL(timeout()), this, SLOT(timerCrank()) ); timer->start( 300000, true); //5 minutes } } void TextEdit::gotoLine() { - + if( editor->length() < 1) + return; QWidget *d = QApplication::desktop(); gotoEdit = new QLineEdit( 0, "Goto line"); gotoEdit->move( (d->width()/2) - ( gotoEdit->width()/2) , (d->height()/2) - (gotoEdit->height()/2)); gotoEdit->setFrame(true); gotoEdit->show(); connect (gotoEdit,SIGNAL(returnPressed()), this, SLOT(doGoto())); } void TextEdit::doGoto() { QString number = gotoEdit->text(); gotoEdit->hide(); + if(gotoEdit) { delete gotoEdit; gotoEdit = 0; } bool ok; int lineNumber = number.toInt(&ok, 10); if(editor->numLines() < lineNumber) QMessageBox::message(tr("Text Edit"),tr("Not enough lines")); else { editor->setCursorPosition(lineNumber, 0, false); } } |