summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--core/apps/textedit/textedit.cpp23
-rw-r--r--core/apps/textedit/textedit.h2
2 files changed, 23 insertions, 2 deletions
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp
index 429c195..834971a 100644
--- a/core/apps/textedit/textedit.cpp
+++ b/core/apps/textedit/textedit.cpp
@@ -266,24 +266,28 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
a = new QAction( tr( "Browse" ), Resource::loadPixmap( "fileopen" ), QString::null, 0, this, 0 );
connect( a, SIGNAL( activated() ), this, SLOT( newFileOpen() ) );
a->addTo( bar );
a->addTo( file );
//
a = new QAction( tr( "Save" ), QPixmap(( const char** ) filesave_xpm ) , QString::null, 0, this, 0 );
connect( a, SIGNAL( activated() ), this, SLOT( save() ) );
// a->addTo( bar );
file->insertSeparator();
a->addTo( file );
+ a = new QAction( tr( "Save As" ), QPixmap(( const char** ) filesave_xpm ) , QString::null, 0, this, 0 );
+ connect( a, SIGNAL( activated() ), this, SLOT( saveAs() ) );
+ a->addTo( file );
+
a = new QAction( tr( "Cut" ), Resource::loadPixmap( "cut" ), QString::null, 0, this, 0 );
connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) );
a->addTo( editBar );
a->addTo( edit );
a = new QAction( tr( "Copy" ), Resource::loadPixmap( "copy" ), QString::null, 0, this, 0 );
connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) );
a->addTo( editBar );
a->addTo( edit );
a = new QAction( tr( "Paste" ), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 );
connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) );
@@ -405,25 +409,25 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
QString tmp;
currentFileName = tmp.sprintf("%s",qApp->argv()[i]);
qDebug(currentFileName);
setDocument( currentFileName );
}
}
else
fileNew();
}
TextEdit::~TextEdit()
{
- save();
+ saveAs();
Config cfg("TextEdit");
cfg.setGroup("View");
QFont f = editor->font();
cfg.writeEntry("FontSize",f.pointSize());
cfg.writeEntry("Bold",f.bold());
cfg.writeEntry("Italic",f.italic());
cfg.writeEntry("Wrap",editor->wordWrap() == QMultiLineEdit::WidgetWidth);
}
void TextEdit::zoomIn()
{
@@ -477,25 +481,25 @@ void TextEdit::setItalic(bool y)
}
void TextEdit::setWordWrap(bool y)
{
bool state = editor->edited();
editor->setWordWrap(y ? QMultiLineEdit::WidgetWidth : QMultiLineEdit::NoWrap );
editor->setEdited( state );
}
void TextEdit::fileNew()
{
if( !bFromDocView ) {
- save();
+ saveAs();
}
newFile(DocLnk());
}
void TextEdit::fileOpen()
{
// if ( !save() ) {
// if ( QMessageBox::critical( this, tr( "Out of space" ),
// tr( "Text Editor was unable to\n"
// "save your changes.\n"
// "Free some space and try again.\n"
// "\nContinue anyway?" ),
@@ -671,24 +675,39 @@ void TextEdit::showEditTools()
fileSelector->hide();
menu->show();
editBar->show();
if ( searchVisible )
searchBar->show();
// updateCaption();
editorStack->raiseWidget( editor );
setWState (WState_Reserved1 );
}
bool TextEdit::save()
{
+ QString rt = editor->text();
+ doc->setName( currentFileName);
+ FileManager fm;
+ if ( !fm.saveFile( *doc, rt ) ) {
+ return false;
+ }
+ delete doc;
+ doc = 0;
+ editor->setEdited( false );
+ return true;
+
+}
+
+bool TextEdit::saveAs()
+{
// case of nothing to save...
if ( !doc || !bFromDocView)
return true;
if ( !editor->edited() ) {
delete doc;
doc = 0;
return true;
}
QString rt = editor->text();
qDebug(currentFileName);
diff --git a/core/apps/textedit/textedit.h b/core/apps/textedit/textedit.h
index 4bfb260..f9eb241 100644
--- a/core/apps/textedit/textedit.h
+++ b/core/apps/textedit/textedit.h
@@ -52,24 +52,26 @@ public:
protected:
void closeEvent( QCloseEvent *e );
private slots:
void setDocument(const QString&);
void changeFont();
void fileNew();
void fileRevert();
void fileOpen();
void newFileOpen();
bool save();
+ bool saveAs();
+
void editCut();
void editCopy();
void editPaste();
void editFind();
void findNext();
void findClose();
void search();
void accept();