summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/apps/textedit/fileBrowser.cpp22
-rw-r--r--core/apps/textedit/fileBrowser.h2
-rw-r--r--core/apps/textedit/fileSaver.cpp29
-rw-r--r--core/apps/textedit/fileSaver.h2
-rw-r--r--core/apps/textedit/textedit.cpp3
5 files changed, 45 insertions, 13 deletions
diff --git a/core/apps/textedit/fileBrowser.cpp b/core/apps/textedit/fileBrowser.cpp
index 2275388..3e3cc3a 100644
--- a/core/apps/textedit/fileBrowser.cpp
+++ b/core/apps/textedit/fileBrowser.cpp
@@ -1,121 +1,130 @@
/****************************************************************************
** copyright 2001 ljp ljp@llornkcor.com
** Created: Fri Dec 14 08:16:46 2001
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
****************************************************************************/
#include "fileBrowser.h"
#include <qpe/config.h>
+#include <qpe/resource.h>
#include <qlistview.h>
#include <qpushbutton.h>
#include <qfile.h>
#include <qmessagebox.h>
#include <unistd.h>
fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags fl , const QString filter )
: QDialog( parent, name, modal, fl )
{
if ( !name )
setName( "fileBrowser" );
- resize( 236, 280 );
+ resize( 240, 280 );
setCaption(tr( "Browse for file" ) );
filterStr=filter;
+
dirLabel = new QLabel(this, "DirLabel");
dirLabel->setText(currentDir.canonicalPath());
- dirLabel->setGeometry(10,4,230,30);
+ dirLabel->setGeometry(10,20,230,15);
+
+ QPushButton *homeButton;
+ homeButton = new QPushButton(Resource::loadIconSet("home"),"",this,"homeButton");
+ homeButton->setGeometry(200,4,25,25);
+ connect(homeButton,SIGNAL(released()),this,SLOT(homeButtonPushed()) );
+
ListView = new QListView( this, "ListView" );
ListView->addColumn( tr( "Name" ) );
ListView->setColumnWidth(0,140);
ListView->setSorting( 2, FALSE);
ListView->addColumn( tr( "Size" ) );
ListView->setColumnWidth(1,59);
// ListView->addColumn( tr( "" ) );
ListView->setColumnWidthMode(0,QListView::Manual);
ListView->setColumnAlignment(1,QListView::AlignRight);
// ListView->setMultiSelection(true);
// ListView->setSelectionMode(QListView::Extended);
ListView->setAllColumnsShowFocus( TRUE );
ListView->setGeometry( QRect( 10, 35, 220, 240 ) );
// signals and slots connections
connect( ListView, SIGNAL(doubleClicked( QListViewItem*)), SLOT(listDoubleClicked(QListViewItem *)) );
connect( ListView, SIGNAL(pressed( QListViewItem*)), SLOT(listClicked(QListViewItem *)) );
currentDir.setPath(QDir::currentDirPath());
populateList();
+ move(0,15);
}
fileBrowser::~fileBrowser()
{
}
void fileBrowser::populateList()
{
ListView->clear();
//qDebug(currentDir.canonicalPath());
currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden );
currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
currentDir.setMatchAllDirs(TRUE);
currentDir.setNameFilter(filterStr);
// currentDir.setNameFilter("*.txt;*.etx");
QString fileL, fileS;
const QFileInfoList *list = currentDir.entryInfoList(QDir::All /*, QDir::SortByMask*/);
QFileInfoListIterator it(*list);
QFileInfo *fi;
while ( (fi=it.current()) ) {
if (fi->isSymLink() ){
QString symLink=fi->readLink();
// qDebug("Symlink detected "+symLink);
QFileInfo sym( symLink);
fileS.sprintf( "%10li", sym.size() );
fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() );
} else {
// qDebug("Not a dir: "+currentDir.canonicalPath()+fileL);
fileS.sprintf( "%10li", fi->size() );
fileL.sprintf( "%s",fi->fileName().data() );
if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) {
fileL+="/";
// qDebug(currentDir.canonicalPath()+fileL);
}
}
item= new QListViewItem( ListView,fileL,fileS );
++it;
}
ListView->setSorting( 2, FALSE);
- dirLabel->setText("Current Directory:\n"+currentDir.canonicalPath());
+ dirLabel->setText(currentDir.canonicalPath());
}
void fileBrowser::upDir()
{
// qDebug(currentDir.canonicalPath());
}
void fileBrowser::listDoubleClicked(QListViewItem *selectedItem)
{
}
// you may want to switch these 2 functions. I like single clicks
void fileBrowser::listClicked(QListViewItem *selectedItem)
{
QString strItem=selectedItem->text(0);
QString strSize=selectedItem->text(1);
// qDebug("strItem is "+strItem);
strSize.stripWhiteSpace();
// qDebug(strSize);
if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink
// is symlink
QString strItem2=strItem.right( (strItem.length()-strItem.find("->",0,TRUE)) -4);
// qDebug("strItem symlink is "+strItem2);
@@ -141,24 +150,31 @@ void fileBrowser::listClicked(QListViewItem *selectedItem)
} else {
strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem);
if( QFile::exists(strItem ) ) {
//currentDir.canonicalPath()
qDebug("We found our files!!"+strItem);
OnOK();
}
} //end not symlink
chdir(strItem.latin1());
}
}
void fileBrowser::OnOK()
{
QListViewItemIterator it1( ListView);
for ( ; it1.current(); ++it1 ) {
if ( it1.current()->isSelected() ) {
selectedFileName=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+it1.current()->text(0));
qDebug("selected filename is "+selectedFileName);
fileList.append( selectedFileName );
}
}
accept();
}
+
+void fileBrowser::homeButtonPushed() {
+ chdir( QDir::homeDirPath().latin1() );
+ currentDir.cd( QDir::homeDirPath(), TRUE);
+ populateList();
+ update();
+}
diff --git a/core/apps/textedit/fileBrowser.h b/core/apps/textedit/fileBrowser.h
index 17ed862..c0e1d4a 100644
--- a/core/apps/textedit/fileBrowser.h
+++ b/core/apps/textedit/fileBrowser.h
@@ -29,39 +29,39 @@ class QGridLayout;
class QListView;
class QListViewItem;
class QPushButton;
class fileBrowser : public QDialog
{
Q_OBJECT
public:
void populateList();
fileBrowser( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ,const QString filter=0);
~fileBrowser();
QPushButton* buttonOk;
QListView* ListView;
QPushButton* buttonCancel;
QLabel *dirLabel;
QString selectedFileName, filterStr;
QDir currentDir;
QFile file;
QStringList fileList;
QListViewItem * item;
public slots:
-
+void homeButtonPushed();
private:
private slots:
void upDir();
void listDoubleClicked(QListViewItem *);
void listClicked(QListViewItem *);
void OnOK();
protected slots:
protected:
};
#endif // FILEBROWSER_H
diff --git a/core/apps/textedit/fileSaver.cpp b/core/apps/textedit/fileSaver.cpp
index 9e9e863..de594aa 100644
--- a/core/apps/textedit/fileSaver.cpp
+++ b/core/apps/textedit/fileSaver.cpp
@@ -1,136 +1,144 @@
/****************************************************************************
** copyright 2001 ljp ljp@llornkcor.com
** Created: Fri Dec 14 08:16:46 2001 fileSaver.cpp
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
****************************************************************************/
#include "fileSaver.h"
#include <qpe/config.h>
+#include <qpe/resource.h>
+
#include <qpe/qpeapplication.h>
#include <qlistview.h>
#include <qpushbutton.h>
#include <qfile.h>
#include <qmessagebox.h>
#include <qlineedit.h>
#include <qcheckbox.h>
#include <unistd.h>
fileSaver::fileSaver( QWidget* parent, const char* name, bool modal, WFlags fl , const QString currentFileName )
: QDialog( parent, name, modal, fl )
{
if ( !name )
setName( "fileSaver" );
- resize( 236, 280 );
+ resize( 240, 280 );
setCaption(tr( "Save file" ) );
QFileInfo fi(currentFileName);
QString tmpFileName=fi.fileName();
// qDebug( tmpFileName);
-
dirLabel = new QLabel(this, "DirLabel");
dirLabel->setText(currentDir.canonicalPath());
- dirLabel->setGeometry(10,4,230,30);
+ dirLabel->setGeometry(10,20,230,15);
+ QPushButton *homeButton;
+ homeButton = new QPushButton(Resource::loadIconSet("home"),"",this,"homeButton");
+ homeButton->setGeometry(200,4,25,25);
+ connect(homeButton,SIGNAL(released()),this,SLOT(homeButtonPushed()) );
+
ListView = new QListView( this, "ListView" );
ListView->addColumn( tr( "Name" ) );
ListView->setColumnWidth(0,140);
ListView->setSorting( 2, FALSE);
ListView->addColumn( tr( "Size" ) );
ListView->setColumnWidth(1,59);
ListView->setColumnWidthMode(0,QListView::Manual);
ListView->setColumnAlignment(1,QListView::AlignRight);
// ListView->setMultiSelection(true);
// ListView->setSelectionMode(QListView::Extended);
ListView->setAllColumnsShowFocus( TRUE );
- ListView->setGeometry( QRect( 10, 35, 220, 160 ) );
+ ListView->setGeometry( QRect( 10,35,220,125));
fileEdit= new QLineEdit(this);
- fileEdit->setGeometry( QRect( 10, 200, 200, 22));
+ fileEdit->setGeometry( QRect( 10, 162, 205, 17));
fileEdit->setText( tmpFileName);
filePermCheck = new QCheckBox( this, "SetFilePerms" );
filePermCheck->setText("set file permissions");
- filePermCheck->setGeometry(10, 220, 150,22);
+ filePermCheck->setGeometry(10, 178, 150,17);
// signals and slots connections
connect( ListView, SIGNAL(doubleClicked( QListViewItem*)), SLOT(listDoubleClicked(QListViewItem *)) );
connect( ListView, SIGNAL(pressed( QListViewItem*)), SLOT(listClicked(QListViewItem *)) );
// tmpFileName=fi.FilePath();
// qDebug( tmpFileName);
currentDir.setPath( QDir::currentDirPath() );
populateList();
+ move(0,15);
+
}
fileSaver::~fileSaver()
{
}
void fileSaver::populateList()
{
ListView->clear();
currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden );
currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
currentDir.setMatchAllDirs(TRUE);
currentDir.setNameFilter("*");
QString fileL, fileS;
const QFileInfoList *list = currentDir.entryInfoList(QDir::All /*, QDir::SortByMask*/);
QFileInfoListIterator it(*list);
QFileInfo *fi;
while ( (fi=it.current()) ) {
if (fi->isSymLink() ){
QString symLink=fi->readLink();
// qDebug("Symlink detected "+symLink);
QFileInfo sym( symLink);
fileS.sprintf( "%10li", sym.size() );
fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() );
} else {
// // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL);
fileS.sprintf( "%10li", fi->size() );
fileL.sprintf( "%s",fi->fileName().data() );
if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) {
fileL+="/";
// qDebug(currentDir.canonicalPath()+fileL);
}
}
item= new QListViewItem( ListView,fileL,fileS );
++it;
}
ListView->setSorting( 2, FALSE);
- dirLabel->setText("Current Directory:\n"+currentDir.canonicalPath());
+ dirLabel->setText(currentDir.canonicalPath());
}
void fileSaver::upDir()
{
// qDebug(currentDir.canonicalPath());
}
void fileSaver::listDoubleClicked(QListViewItem *selectedItem)
{
}
void fileSaver::listClicked(QListViewItem *selectedItem)
{
QString strItem=selectedItem->text(0);
QString strSize=selectedItem->text(1);
// qDebug("strItem is "+strItem);
strSize.stripWhiteSpace();
// qDebug(strSize);
if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink
QString strItem2=strItem.right( (strItem.length()-strItem.find("->",0,TRUE)) -4);
// qDebug("strItem symlink is "+strItem2);
@@ -165,24 +173,31 @@ void fileSaver::listClicked(QListViewItem *selectedItem)
}
void fileSaver::closeEvent( QCloseEvent *e )
{
if(e->isAccepted()) {
e->accept();
} else {
qDebug("not accepted");
done(-1);
}
}
void fileSaver::accept() {
selectedFileName = fileEdit->text();
QString path = currentDir.canonicalPath()+"/" + selectedFileName;
if( path.find("//",0,TRUE) ==-1 ) {
selectedFileName = path;
} else {
selectedFileName = currentDir.canonicalPath()+selectedFileName;
}
qDebug("going to save "+selectedFileName);
done(1);
}
+
+void fileSaver::homeButtonPushed() {
+ chdir( QDir::homeDirPath().latin1() );
+ currentDir.cd( QDir::homeDirPath(), TRUE);
+ populateList();
+ update();
+}
diff --git a/core/apps/textedit/fileSaver.h b/core/apps/textedit/fileSaver.h
index ce4493e..526085d 100644
--- a/core/apps/textedit/fileSaver.h
+++ b/core/apps/textedit/fileSaver.h
@@ -34,41 +34,41 @@ class QLineEdit;
class QCheckBox;
class fileSaver : public QDialog
{
Q_OBJECT
public:
void populateList();
fileSaver( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ,const QString filter=0);
~fileSaver();
QLineEdit *fileEdit;
QPushButton* buttonOk;
QListView* ListView;
QPushButton* buttonCancel;
QLabel *dirLabel;
QString selectedFileName, filterStr;
QDir currentDir;
QFile file;
QStringList fileList;
QCheckBox *filePermCheck;
QListViewItem * item;
public slots:
-
+void homeButtonPushed();
private:
private slots:
void accept();
void upDir();
void listDoubleClicked(QListViewItem *);
void listClicked(QListViewItem *);
void closeEvent( QCloseEvent * );
protected slots:
protected:
};
#endif // FILESAVER_H
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp
index bc975f3..72cc4d1 100644
--- a/core/apps/textedit/textedit.cpp
+++ b/core/apps/textedit/textedit.cpp
@@ -742,49 +742,49 @@ bool TextEdit::saveAs()
if( currentFileName.isEmpty() || currentFileName == "Unnamed") {
qDebug("do silly TT filename thing");
if ( doc->name().isEmpty() ) {
QString pt = rt.simplifyWhiteSpace();
int i = pt.find( ' ' );
QString docname = pt;
if ( i > 0 )
docname = pt.left( i );
// remove "." at the beginning
while( docname.startsWith( "." ) )
docname = docname.mid( 1 );
docname.replace( QRegExp("/"), "_" );
// cut the length. filenames longer than that don't make sense and something goes wrong when they get too long.
if ( docname.length() > 40 )
docname = docname.left(40);
if ( docname.isEmpty() )
docname = "Unnamed";
doc->setName(docname);
currentFileName=docname;
}
}
- fileSaveDlg=new fileSaver(this,"SaveFile",TRUE,0, currentFileName);
+ fileSaveDlg=new fileSaver(this,"SaveFile",TRUE, 0, currentFileName);
qDebug("wanna save filename "+currentFileName);
fileSaveDlg->exec();
if( fileSaveDlg->result() == 1 ) {
QString fileNm=fileSaveDlg->selectedFileName;
qDebug("saving filename "+fileNm);
QFileInfo fi(fileNm);
currentFileName=fi.fileName();
if(doc) {
qDebug("doclnk exists");
// QString file = doc->file();
// doc->removeFiles();
delete doc;
DocLnk nf;
nf.setType("text/plain");
nf.setFile( fileNm);
doc = new DocLnk(nf);
// editor->setText(rt);
qDebug("openFile doclnk "+currentFileName);
doc->setName( currentFileName);
updateCaption( currentFileName);
FileManager fm;
if ( !fm.saveFile( *doc, rt ) ) {
return false;
@@ -868,31 +868,32 @@ void TextEdit::changeFont() {
QString style = cfg.readEntry("Style", fdb.styleString(defaultFont));
int i_size = cfg.readNumEntry("Size", fontInfo.pointSize()/10);
QString charSet = cfg.readEntry("CharSet", QFont::encodingName( fontInfo.charSet()) );
defaultFont = fdb.font(family,style,i_size,charSet);
FontDialog *fontDlg;
fontDlg=new FontDialog(this,"FontDialog",TRUE);
fontDlg->exec();
QFont myFont=fontDlg->selectedFont;
editor->setFont( myFont);
delete fontDlg;
}
void TextEdit::editDelete()
{
switch ( QMessageBox::warning(this,"Text Editor","Do you really want\nto delete the current file\nfrom the disk?\nThis is irreversable!!","Yes","No",0,0,1) ) {
case 0:
if(doc) {
doc->removeFiles();
clear();
+ setCaption( tr("Text Editor") );
}
break;
case 1:
// exit
break;
};
}