summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-04-10 19:08:30 (UTC)
committer llornkcor <llornkcor>2002-04-10 19:08:30 (UTC)
commit11d754ffa429875b526c49f125d8a844c5cda3d8 (patch) (side-by-side diff)
tree4b2fa1f980e62dad5a0ae465c95eb627df32cdd9
parent5504a71f3e65673a3eea23051d0043f2b483276b (diff)
downloadopie-11d754ffa429875b526c49f125d8a844c5cda3d8.zip
opie-11d754ffa429875b526c49f125d8a844c5cda3d8.tar.gz
opie-11d754ffa429875b526c49f125d8a844c5cda3d8.tar.bz2
bug fix
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--core/apps/textedit/fileBrowser.cpp28
-rw-r--r--core/apps/textedit/textedit.cpp69
-rw-r--r--core/apps/textedit/textedit.h7
3 files changed, 58 insertions, 46 deletions
diff --git a/core/apps/textedit/fileBrowser.cpp b/core/apps/textedit/fileBrowser.cpp
index bc99348..f322513 100644
--- a/core/apps/textedit/fileBrowser.cpp
+++ b/core/apps/textedit/fileBrowser.cpp
@@ -47,9 +47,9 @@ static int get_unique_id()
fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags fl , const QString mimeFilter )
: QDialog( parent, name, modal, fl )
{
if ( !name )
- setName( tr("fileBrowser") );
+ setName( "fileBrowser" );
setCaption(tr( name ) );
// mimeType = mimeFilter;
// MimeType mt( mimeType);
// if( mt.extension().isEmpty())
@@ -119,9 +119,9 @@ fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags
ListView->setColumnWidth(0,120);
ListView->setSorting( 2, FALSE);
ListView->addColumn( tr( "Size" ) );
ListView->setColumnWidth(1,-1);
- ListView->addColumn( tr("Date"),-1);
+ ListView->addColumn( "Date",-1);
ListView->setColumnWidthMode(0,QListView::Manual);
ListView->setColumnAlignment(1,QListView::AlignRight);
ListView->setColumnAlignment(2,QListView::AlignRight);
@@ -133,9 +133,9 @@ fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags
connect( ListView, SIGNAL( clicked( QListViewItem*)), SLOT(listClicked(QListViewItem *)) );
FileStack->addWidget( ListView, get_unique_id() );
-
+mimeType="text/plain";
fileSelector = new FileSelector( mimeType, FileStack, "fileselector" , FALSE, FALSE); //buggy
// connect( fileSelector, SIGNAL( closeMe() ), this, SLOT( showEditTools() ) );
// connect( fileSelector, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) );
connect( fileSelector, SIGNAL( fileSelected( const DocLnk &) ),
@@ -347,16 +347,16 @@ void fileBrowser::docButtonPushed() {
}
void fileBrowser::selectionChanged( const QString &select )
{
- if ( select == tr("Documents")) {
+ if ( select == "Documents") {
FileStack->raiseWidget( fileSelector );
dirPathCombo->hide();
cdUpButton->hide();
docButton->hide();
homeButton->hide();
} else {
- if ( select == tr("All files") )
+ if ( select == "All files" )
currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::All);
else
currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
@@ -411,9 +411,9 @@ void fileBrowser::doCd() {
}
void fileBrowser::makDir() {
InputDialog *fileDlg;
- fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0);
+ fileDlg = new InputDialog(this,"Make Directory",TRUE, 0);
fileDlg->exec();
if( fileDlg->result() == 1 ) {
QString filename = fileDlg->LineEdit1->text();
qDebug("Make dir");
@@ -424,25 +424,25 @@ void fileBrowser::makDir() {
void fileBrowser::localRename() {
QString curFile = ListView->currentItem()->text(0);
InputDialog *fileDlg;
- fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0);
+ fileDlg = new InputDialog(this,"Rename",TRUE, 0);
fileDlg->setTextEdit((const QString &) curFile);
fileDlg->exec();
if( fileDlg->result() == 1 ) {
QString oldname = currentDir.canonicalPath() + "/" + curFile;
QString newName = currentDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();//+".playlist";
if( rename(oldname.latin1(), newName.latin1())== -1)
- QMessageBox::message(tr("Note"),tr("Could not rename"));
+ QMessageBox::message("Note","Could not rename");
}
populateList();
}
void fileBrowser::localDelete() {
QString f = ListView->currentItem()->text(0);
if(QDir(f).exists() ) {
- switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+
- tr(" ?\nIt must be empty"),tr("Yes"),tr("No"),0,0,1) ) {
+ switch ( QMessageBox::warning(this,"Delete","Do you really want to delete\n"+f+
+ " ?\nIt must be empty","Yes","No",0,0,1) ) {
case 0: {
f=currentDir.canonicalPath()+"/"+f;
QString cmd="rmdir "+f;
system( cmd.latin1());
@@ -453,10 +453,10 @@ void fileBrowser::localDelete() {
// exit
break;
};
} else {
- switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f
- +" ?",tr("Yes"),tr("No"),0,0,1) ) {
+ switch ( QMessageBox::warning(this,"Delete","Do you really want to delete\n"+f
+ +" ?","Yes","No",0,0,1) ) {
case 0: {
f=currentDir.canonicalPath()+"/"+f;
QString cmd="rm "+f;
system( cmd.latin1());
@@ -492,9 +492,9 @@ void fileBrowser::updateMimeTypeMenu() {
void fileBrowser::showType(const QString &t) {
qDebug(t);
- if(t.find(tr("All"),0,TRUE) != -1) {
+ if(t.find("All",0,TRUE) != -1) {
filterStr = "*";
} else {
QStringList list = mimetypes.grep( t,TRUE);
QString ext;
@@ -604,9 +604,9 @@ void fileBrowser::fillCombo(const QString &currentPath) {
InputDialog::InputDialog( QWidget* parent, const char* name, bool modal, WFlags fl )
: QDialog( parent, name, modal, fl )
{
if ( !name )
- setName( tr("InputDialog") );
+ setName( "InputDialog" );
resize( 234, 50 );
setMaximumSize( QSize( 240, 50 ) );
setCaption( tr(name ) );
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp
index 6804918..943fecd 100644
--- a/core/apps/textedit/textedit.cpp
+++ b/core/apps/textedit/textedit.cpp
@@ -34,8 +34,9 @@
#include <qpe/config.h>
#include <qpe/qpeapplication.h>
#include <qpe/qpemenubar.h>
#include <qpe/qpetoolbar.h>
+#include <qpe/qcopenvelope_qws.h>
//#include <qpe/finddialog.h>
#include <qstringlist.h>
#include <qaction.h>
@@ -237,8 +238,12 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
edited1=FALSE;
setToolBarsMovable( FALSE );
connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) );
+ channel = new QCopChannel( "QPE/Application/textedit", this );
+ connect( channel, SIGNAL(received(const QCString&, const QByteArray&)),
+ this, SLOT(receive(const QCString&, const QByteArray&)) );
+
setIcon( Resource::loadPixmap( "TextEditor" ) );
QPEToolBar *bar = new QPEToolBar( this );
bar->setHorizontalStretchable( TRUE );
@@ -484,19 +489,21 @@ void TextEdit::setWordWrap(bool y)
}
void TextEdit::fileNew()
{
- if( !bFromDocView ) {
- saveAs();
- }
+// if( !bFromDocView ) {
+// saveAs();
+// }
newFile(DocLnk());
}
void TextEdit::fileOpen()
{
browseForFiles=new fileBrowser(this,tr("Open File"),TRUE,0, "text/*"); //
browseForFiles->setFileView( viewSelection );
browseForFiles->showMaximized();
+// if( result != -1 )
+
if( browseForFiles->exec() != -1 ) {
QString selFile = browseForFiles->selectedFileName;
QStringList fileList = browseForFiles->fileList;
qDebug(selFile);
@@ -617,16 +624,18 @@ void TextEdit::newFile( const DocLnk &f )
clear();
setWState (WState_Reserved1 );
editor->setFocus();
doc = new DocLnk(nf);
+ currentFileName = "Unnamed";
qDebug("newFile "+currentFileName);
updateCaption(currentFileName);
+// editor->setEdited( FALSE);
}
void TextEdit::openFile( const QString &f )
{
- bFromDocView = TRUE;
+// bFromDocView = TRUE;
DocLnk nf;
nf.setType("text/plain");
nf.setFile(f);
currentFileName=f;
@@ -646,30 +655,26 @@ void TextEdit::openFile( const QString &f )
void TextEdit::openFile( const DocLnk &f )
{
// clear();
- bFromDocView = TRUE;
+// bFromDocView = TRUE;
FileManager fm;
QString txt;
currentFileName=f.name();
qDebug("openFile doclnk " + currentFileName);
if ( !fm.loadFile( f, txt ) ) {
// ####### could be a new file
qDebug( "Cannot open file" );
-
- //return;
}
-
- fileNew();
+// fileNew();
if ( doc )
delete doc;
doc = new DocLnk(f);
editor->setText(txt);
editor->setEdited( FALSE);
edited1=FALSE;
edited=FALSE;
- qDebug("openFile doclnk "+currentFileName);
doc->setName(currentFileName);
updateCaption();
}
@@ -690,11 +695,11 @@ void TextEdit::showEditTools()
unprompted save */
bool TextEdit::save()
{
QString file = doc->file();
- qDebug(file);
+ qDebug("saver file "+file);
QString name= doc->name();
- qDebug(name);
+ qDebug("File named "+name);
QString rt = editor->text();
if( !rt.isEmpty() ) {
if(name.isEmpty()) {
saveAs();
@@ -730,15 +735,14 @@ bool TextEdit::save()
prompted save */
bool TextEdit::saveAs()
{
// qDebug("saveAsFile "+currentFileName);
-
- // case of nothing to save... /// there's always something to save
-// if ( !doc )//|| !bFromDocView)
-// {
-// qDebug("no doc");
-// return true;
-// }
+ // case of nothing to save...
+ if ( !doc )//|| !bFromDocView)
+ {
+ qDebug("no doc");
+ return true;
+ }
if ( !editor->edited() ) {
delete doc;
doc = 0;
return true;
@@ -746,9 +750,9 @@ bool TextEdit::saveAs()
QString rt = editor->text();
qDebug(currentFileName);
- if( currentFileName.isEmpty() || currentFileName == tr("Unnamed")) {
+ if( currentFileName.isEmpty() || currentFileName == tr("Unnamed") || currentFileName == tr("Text Editor")) {
qDebug("do silly TT filename thing");
if ( doc->name().isEmpty() ) {
QString pt = rt.simplifyWhiteSpace();
int i = pt.find( ' ' );
@@ -813,9 +817,9 @@ bool TextEdit::saveAs()
if(fileSaveDlg)
delete fileSaveDlg;
return true;
-}
+} //end saveAs
void TextEdit::clear()
{
delete doc;
@@ -834,21 +838,21 @@ void TextEdit::updateCaption( const QString &name )
if ( s.isEmpty() ) {
s = tr( "Unnamed" );
currentFileName=s;
}
-
+ if(s.left(1) == "/")
+ s = s.right(s.length()-1);
setCaption( s + " - " + tr("Text Editor") );
}
}
void TextEdit::setDocument(const QString& fileref)
{
bFromDocView = TRUE;
- qDebug("setDocument "+fileref);
- bFromDocView = TRUE;
if(fileref.find(".desktop",0,TRUE) == -1) {
openFile(fileref);
} else {
+ qDebug("is desktop file");
openFile(DocLnk(fileref));
}
editor->setEdited(TRUE);
edited1=FALSE;
@@ -863,14 +867,11 @@ void TextEdit::closeEvent( QCloseEvent *e )
}
void TextEdit::accept()
{
- QString file = doc->file();
- if (file.find("_.txt",0,TRUE) ==-1)
- save();
- else {
- QFile(file).remove();
- }
+ //if(caption() !="Unnamed")
+ if(edited1)
+ saveAs();
exit(0);
}
@@ -933,4 +934,12 @@ void TextEdit::editorChanged() {
edited1=TRUE;
}
edited=TRUE;
}
+
+void TextEdit::receive(const QCString&msg, const QByteArray&) {
+ qDebug("QCop "+msg);
+ if ( msg == "setDocument(QString)" ) {
+ qDebug("bugger all");
+ }
+
+}
diff --git a/core/apps/textedit/textedit.h b/core/apps/textedit/textedit.h
index af69518..61fa2a0 100644
--- a/core/apps/textedit/textedit.h
+++ b/core/apps/textedit/textedit.h
@@ -27,8 +27,11 @@
#include "fileBrowser.h"
#include "fileSaver.h"
#include <qpe/filemanager.h>
+#include <qpe/qcopenvelope_qws.h>
+
+#include <opie/ofileselector.h>
#include <qmainwindow.h>
#include <qmultilineedit.h>
#include <qlist.h>
@@ -56,11 +59,12 @@ public:
QPopupMenu *font;
QAction *nStart;
bool edited, edited1;
void openFile( const QString & );
+ QCopChannel * channel;
public slots:
void editorChanged();
-
+void receive(const QCString&, const QByteArray&);
protected:
void closeEvent( QCloseEvent *e );
void doSearchBar();
private slots:
@@ -105,9 +109,8 @@ private:
private:
fileSaver *fileSaveDlg;
fileBrowser *browseForFiles;
-
QpeEditor* editor;
QToolBar *menu, *editBar, *searchBar;
QLineEdit *searchEdit;
DocLnk *doc;