summaryrefslogtreecommitdiff
path: root/core/apps/textedit
authorllornkcor <llornkcor>2002-08-30 12:16:14 (UTC)
committer llornkcor <llornkcor>2002-08-30 12:16:14 (UTC)
commit73ccaa41947cd22902b96c18f3b96a6f9f3e565c (patch) (side-by-side diff)
treedbddb746c97da59cd0af50e24ac2ef71603ee553 /core/apps/textedit
parent146dfec7bdcac24df009b434d0f4683c53ce7552 (diff)
downloadopie-73ccaa41947cd22902b96c18f3b96a6f9f3e565c.zip
opie-73ccaa41947cd22902b96c18f3b96a6f9f3e565c.tar.gz
opie-73ccaa41947cd22902b96c18f3b96a6f9f3e565c.tar.bz2
fixed canceling saveas dialog return
Diffstat (limited to 'core/apps/textedit') (more/less context) (ignore whitespace changes)
-rw-r--r--core/apps/textedit/textedit.cpp158
1 files changed, 67 insertions, 91 deletions
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp
index 107695a..d61da2a 100644
--- a/core/apps/textedit/textedit.cpp
+++ b/core/apps/textedit/textedit.cpp
@@ -364,6 +364,12 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
nAdvanced->setToggleAction(TRUE);
nAdvanced->addTo( font );
- if(cfg.readBoolEntry("AdvancedFeatures"))
- nAdvanced->setOn(TRUE);
+
+ if(cfg.readBoolEntry("AdvancedFeatures")) {
+ qDebug("using advanced features");
+ useAdvancedFeatures = true;
+ nAdvanced->setOn(TRUE);
+ } else
+ useAdvancedFeatures = false;
+
font->insertSeparator();
@@ -435,6 +441,8 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
}
-void TextEdit::cleanUp()
-{
+TextEdit::~TextEdit() {
+}
+
+void TextEdit::cleanUp() {
// save();
Config cfg("TextEdit");
@@ -446,24 +454,23 @@ void TextEdit::cleanUp()
cfg.writeEntry("Wrap",editor->wordWrap() == QMultiLineEdit::WidgetWidth);
cfg.writeEntry( "FileView", viewSelection );
-
}
-TextEdit::~TextEdit()
-{
+
+void TextEdit::accept() {
+ if(edited1)
+ saveAs();
+ exit(0);
}
-void TextEdit::zoomIn()
-{
+void TextEdit::zoomIn() {
setFontSize(editor->font().pointSize()+1,FALSE);
}
-void TextEdit::zoomOut()
-{
+void TextEdit::zoomOut() {
setFontSize(editor->font().pointSize()-1,TRUE);
}
-void TextEdit::setFontSize(int sz, bool round_down_not_up)
-{
+void TextEdit::setFontSize(int sz, bool round_down_not_up) {
int s=10;
for (int i=0; i<nfontsizes; i++) {
@@ -490,6 +497,5 @@ void TextEdit::setFontSize(int sz, bool round_down_not_up)
}
-void TextEdit::setBold(bool y)
-{
+void TextEdit::setBold(bool y) {
QFont f = editor->font();
f.setBold(y);
@@ -497,6 +503,5 @@ void TextEdit::setBold(bool y)
}
-void TextEdit::setItalic(bool y)
-{
+void TextEdit::setItalic(bool y) {
QFont f = editor->font();
f.setItalic(y);
@@ -504,6 +509,5 @@ void TextEdit::setItalic(bool y)
}
-void TextEdit::setWordWrap(bool y)
-{
+void TextEdit::setWordWrap(bool y) {
bool state = editor->edited();
editor->setWordWrap(y ? QMultiLineEdit::WidgetWidth : QMultiLineEdit::NoWrap );
@@ -511,6 +515,5 @@ void TextEdit::setWordWrap(bool y)
}
-void TextEdit::fileNew()
-{
+void TextEdit::fileNew() {
// if( !bFromDocView ) {
// saveAs();
@@ -519,6 +522,5 @@ void TextEdit::fileNew()
}
-void TextEdit::fileOpen()
-{
+void TextEdit::fileOpen() {
Config cfg("TextEdit");
cfg.setGroup("View");
@@ -538,6 +540,5 @@ void TextEdit::fileOpen()
}
-void TextEdit::doSearchBar()
-{
+void TextEdit::doSearchBar() {
Config cfg("TextEdit");
cfg.setGroup("View");
@@ -547,6 +548,5 @@ void TextEdit::doSearchBar()
#if 0
-void TextEdit::slotFind()
-{
+void TextEdit::slotFind() {
FindDialog frmFind( tr("Text Editor"), this );
connect( &frmFind, SIGNAL(signalFindClicked(const QString &, bool, bool, int)),
@@ -566,12 +566,10 @@ void TextEdit::slotFind()
#endif
-void TextEdit::fileRevert()
-{
+void TextEdit::fileRevert() {
clear();
fileOpen();
}
-void TextEdit::editCut()
-{
+void TextEdit::editCut() {
#ifndef QT_NO_CLIPBOARD
editor->cut();
@@ -579,6 +577,5 @@ void TextEdit::editCut()
}
-void TextEdit::editCopy()
-{
+void TextEdit::editCopy() {
#ifndef QT_NO_CLIPBOARD
editor->copy();
@@ -586,6 +583,5 @@ void TextEdit::editCopy()
}
-void TextEdit::editPaste()
-{
+void TextEdit::editPaste() {
#ifndef QT_NO_CLIPBOARD
editor->paste();
@@ -593,6 +589,5 @@ void TextEdit::editPaste()
}
-void TextEdit::editFind()
-{
+void TextEdit::editFind() {
searchBar->show();
searchVisible = TRUE;
@@ -604,12 +599,10 @@ void TextEdit::editFind()
}
-void TextEdit::findNext()
-{
+void TextEdit::findNext() {
editor->find( searchEdit->text(), FALSE, FALSE );
}
-void TextEdit::findClose()
-{
+void TextEdit::findClose() {
searchVisible = FALSE;
searchBar->hide();
@@ -620,11 +613,9 @@ void TextEdit::findClose()
}
-void TextEdit::search()
-{
+void TextEdit::search() {
editor->find( searchEdit->text(), FALSE, FALSE );
}
-void TextEdit::newFile( const DocLnk &f )
-{
+void TextEdit::newFile( const DocLnk &f ) {
DocLnk nf = f;
nf.setType("text/plain");
@@ -639,6 +630,5 @@ void TextEdit::newFile( const DocLnk &f )
}
-void TextEdit::openFile( const QString &f )
-{
+void TextEdit::openFile( const QString &f ) {
qDebug("filename is "+ f);
QString filer;
@@ -679,6 +669,5 @@ void TextEdit::openFile( const QString &f )
}
-void TextEdit::openFile( const DocLnk &f )
-{
+void TextEdit::openFile( const DocLnk &f ) {
// clear();
// bFromDocView = TRUE;
@@ -704,6 +693,5 @@ void TextEdit::openFile( const DocLnk &f )
}
-void TextEdit::showEditTools()
-{
+void TextEdit::showEditTools() {
// if ( !doc )
// close();
@@ -719,6 +707,5 @@ void TextEdit::showEditTools()
/*!
unprompted save */
-bool TextEdit::save()
-{
+bool TextEdit::save() {
QString file = doc->file();
qDebug("saver file "+file);
@@ -772,13 +759,12 @@ bool TextEdit::save()
/*!
prompted save */
-bool TextEdit::saveAs()
-{
-// qDebug("saveAsFile "+currentFileName);
- // case of nothing to save...
- if ( !doc )//|| !bFromDocView)
- {
- qDebug("no doc");
- return true;
- }
+bool TextEdit::saveAs() {
+ qDebug("saveAsFile "+currentFileName);
+ // case of nothing to save...
+ if ( !doc ) {
+//|| !bFromDocView)
+ qDebug("no doc");
+ return true;
+ }
if ( !editor->edited() ) {
delete doc;
@@ -791,5 +777,5 @@ bool TextEdit::saveAs()
if( currentFileName.isEmpty() || currentFileName == tr("Unnamed") || currentFileName == tr("Text Editor")) {
- qDebug("do silly TT filename thing");
+// qDebug("do silly TT filename thing");
if ( doc->name().isEmpty() ) {
QString pt = rt.simplifyWhiteSpace();
@@ -819,5 +805,7 @@ bool TextEdit::saveAs()
text << "*";
map.insert(tr("All"), text );
+
QString str = OFileDialog::getSaveFileName( 2,"/", QString::null, map);
+
if(!str.isEmpty() ) {
QString fileNm=str;
@@ -849,20 +837,21 @@ bool TextEdit::saveAs()
filePerm->exec();
- if( filePerm)
- delete filePerm;
+ if( filePerm)
+ delete filePerm;
}
}
+ editor->setEdited( false);
+ edited1 = false;
+ edited = false;
+ if(caption().left(1)=="*")
+ setCaption(caption().right(caption().length()-1));
+
+ return true;
}
- editor->setEdited(TRUE);
- edited1=FALSE;
- edited=TRUE;
- if(caption().left(1)=="*")
- setCaption(caption().right(caption().length()-1));
-
- return true;
+ qDebug("returning false");
+ return false;
} //end saveAs
-void TextEdit::clear()
-{
+void TextEdit::clear() {
delete doc;
doc = 0;
@@ -870,6 +859,5 @@ void TextEdit::clear()
}
-void TextEdit::updateCaption( const QString &name )
-{
+void TextEdit::updateCaption( const QString &name ) {
if ( !doc )
setCaption( tr("Text Editor") );
@@ -888,6 +876,5 @@ void TextEdit::updateCaption( const QString &name )
}
-void TextEdit::setDocument(const QString& fileref)
-{
+void TextEdit::setDocument(const QString& fileref) {
bFromDocView = TRUE;
openFile(fileref);
@@ -898,19 +885,9 @@ void TextEdit::setDocument(const QString& fileref)
}
-void TextEdit::closeEvent( QCloseEvent *e )
-{
+void TextEdit::closeEvent( QCloseEvent *e ) {
bFromDocView = FALSE;
e->accept();
}
-void TextEdit::accept()
- {
- //if(caption() !="Unnamed")
- if(edited1)
- saveAs();
- exit(0);
-
-}
-
void TextEdit::changeFont() {
FontDatabase fdb;
@@ -937,6 +914,5 @@ void TextEdit::changeFont() {
}
-void TextEdit::editDelete()
-{
+void TextEdit::editDelete() {
switch ( QMessageBox::warning(this,tr("Text Editor"),tr("Do you really want\nto delete the current file\nfrom the disk?\nThis is irreversable!!"),tr("Yes"),tr("No"),0,0,1) ) {
case 0: