-rw-r--r-- | core/apps/textedit/fileBrowser.cpp | 117 | ||||
-rw-r--r-- | core/apps/textedit/fileBrowser.h | 2 | ||||
-rw-r--r-- | core/apps/textedit/fileSaver.cpp | 45 |
3 files changed, 104 insertions, 60 deletions
diff --git a/core/apps/textedit/fileBrowser.cpp b/core/apps/textedit/fileBrowser.cpp index 8c942a1..8ea8067 100644 --- a/core/apps/textedit/fileBrowser.cpp +++ b/core/apps/textedit/fileBrowser.cpp @@ -122,5 +122,5 @@ fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags QPEApplication::setStylusOperation( ListView->viewport(),QPEApplication::RightOnHold); connect( ListView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), - this,SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) ); + this, SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) ); connect( ListView, SIGNAL( clicked( QListViewItem*)), SLOT(listClicked(QListViewItem *)) ); @@ -172,4 +172,5 @@ void fileBrowser::populateList() { ListView->clear(); + QListViewItem * item; bool isDir=FALSE; //qDebug(currentDir.canonicalPath()); @@ -183,56 +184,56 @@ void fileBrowser::populateList() QFileInfo *fi; while ( (fi=it.current()) ) { - - if (fi->isSymLink() ){ - QString symLink=fi->readLink(); + 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() ); - fileDate = sym.lastModified().toString(); - } else { + QFileInfo sym( symLink); + fileS.sprintf( "%10li", sym.size() ); + fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() ); + fileDate = sym.lastModified().toString(); + } else { // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); - fileS.sprintf( "%10li", fi->size() ); - fileL.sprintf( "%s",fi->fileName().data() ); - fileDate= fi->lastModified().toString(); - if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) { - fileL+="/"; - isDir=TRUE; + fileS.sprintf( "%10li", fi->size() ); + fileL.sprintf( "%s",fi->fileName().data() ); + fileDate= fi->lastModified().toString(); + if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) { + fileL+="/"; + isDir=TRUE; // qDebug( fileL); + } } - } - if(fileL !="./") { - item= new QListViewItem( ListView,fileL,fileS , fileDate); - QPixmap pm; + if(fileL !="./" && fi->exists()) { + item= new QListViewItem( ListView,fileL,fileS , fileDate); + QPixmap pm; - if(isDir || fileL.find("/",0,TRUE) != -1) { - if( !QDir( fi->filePath() ).isReadable()) - pm = Resource::loadPixmap( "lockedfolder" ); - else + if(isDir || fileL.find("/",0,TRUE) != -1) { + if( !QDir( fi->filePath() ).isReadable()) + pm = Resource::loadPixmap( "lockedfolder" ); + else + pm= Resource::loadPixmap( "folder" ); + item->setPixmap( 0,pm ); + } else { + if( !fi->isReadable() ) + pm = Resource::loadPixmap( "locked" ); + else { + MimeType mt(fi->filePath()); + pm=mt.pixmap(); + if(pm.isNull()) + pm = Resource::loadPixmap( "UnknownDocument-14" ); + item->setPixmap( 0,pm); + } + } + if( fileL.find("->",0,TRUE) != -1) { + // overlay link image pm= Resource::loadPixmap( "folder" ); - item->setPixmap( 0,pm ); - } else { - if( !fi->isReadable() ) - pm = Resource::loadPixmap( "locked" ); - else { - MimeType mt(fi->filePath()); - pm=mt.pixmap(); - if(pm.isNull()) - pm = Resource::loadPixmap( "UnknownDocument-14" ); - item->setPixmap( 0,pm); + QPixmap lnk = Resource::loadPixmap( "symlink" ); + QPainter painter( &pm ); + painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); + pm.setMask( pm.createHeuristicMask( FALSE ) ); + item->setPixmap( 0, pm); } } - if( fileL.find("->",0,TRUE) != -1) { - // overlay link image - pm= Resource::loadPixmap( "folder" ); - QPixmap lnk = Resource::loadPixmap( "symlink" ); - QPainter painter( &pm ); - painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); - pm.setMask( pm.createHeuristicMask( FALSE ) ); - item->setPixmap( 0, pm); - } - } - isDir=FALSE; - ++it; + isDir=FALSE; + ++it; +// } } ListView->setSorting( 3, FALSE); @@ -264,4 +265,5 @@ void fileBrowser::upDir() void fileBrowser::listClicked(QListViewItem *selectedItem) { + if(selectedItem) { QString strItem=selectedItem->text(0); QString strSize=selectedItem->text(1); @@ -303,4 +305,5 @@ void fileBrowser::listClicked(QListViewItem *selectedItem) chdir(strItem.latin1()); } + } } @@ -379,14 +382,18 @@ void fileBrowser::showListMenu(QListViewItem *item) { QPopupMenu m;// = new QPopupMenu( Local_View ); - if( item->text(0).find("/",0,TRUE)) - m.insertItem( tr( "Change Directory" ), this, SLOT( doCd() )); - else - m.insertItem( tr( "Make Directory" ), this, SLOT( makDir() )); - m.insertItem( tr( "Rescan" ), this, SLOT( populateList() )); - m.insertItem( tr( "Rename" ), this, SLOT( localRename() )); - m.insertSeparator(); - m.insertItem( tr( "Delete" ), this, SLOT( localDelete() )); + if(item) { + if( item->text(0).find("/",0,TRUE)) + m.insertItem( tr( "Change Directory" ), this, SLOT( doCd() )); + m.insertItem( tr( "Make Directory" ), this, SLOT( makDir() )); + m.insertItem( tr( "Rescan" ), this, SLOT( populateList() )); + m.insertItem( tr( "Rename" ), this, SLOT( localRename() )); + m.insertSeparator(); + m.insertItem( tr( "Delete" ), this, SLOT( localDelete() )); + } else { + m.insertItem( tr( "Make Directory" ), this, SLOT( makDir() )); + m.insertItem( tr( "Rescan" ), this, SLOT( populateList() )); + + } m.exec( QCursor::pos() ); - } @@ -401,4 +408,5 @@ void fileBrowser::makDir() { if( fileDlg->result() == 1 ) { QString filename = fileDlg->LineEdit1->text(); + qDebug("Make dir"); currentDir.mkdir( currentDir.canonicalPath()+"/"+filename); } @@ -437,5 +445,4 @@ void fileBrowser::localDelete() { break; }; - } else { switch ( QMessageBox::warning(this,"Delete","Do you really want to delete\n"+f diff --git a/core/apps/textedit/fileBrowser.h b/core/apps/textedit/fileBrowser.h index 339483f..e76c7df 100644 --- a/core/apps/textedit/fileBrowser.h +++ b/core/apps/textedit/fileBrowser.h @@ -68,5 +68,5 @@ private: QDir currentDir; QStringList dirPathStringList, mimetypes; - QListViewItem * item; +/* QListViewItem * item; */ QComboBox *dirPathCombo; MenuButton *typemb; diff --git a/core/apps/textedit/fileSaver.cpp b/core/apps/textedit/fileSaver.cpp index 07fb5ba..f2a5355 100644 --- a/core/apps/textedit/fileSaver.cpp +++ b/core/apps/textedit/fileSaver.cpp @@ -15,4 +15,5 @@ #include <qpe/config.h> #include <qpe/resource.h> +#include <qpe/mimetype.h> #include <qpe/qpeapplication.h> @@ -48,4 +49,5 @@ fileSaver::fileSaver( QWidget* parent, const char* name, bool modal, WFlags fl docButton->setGeometry(170,4,25,25); connect( docButton,SIGNAL(released()),this,SLOT( docButtonPushed()) ); + docButton->setFlat(TRUE); @@ -58,8 +60,10 @@ fileSaver::fileSaver( QWidget* parent, const char* name, bool modal, WFlags fl ListView = new QListView( this, "ListView" ); ListView->addColumn( tr( "Name" ) ); - ListView->setColumnWidth(0,140); + ListView->setColumnWidth(0,120); ListView->setSorting( 2, FALSE); ListView->addColumn( tr( "Size" ) ); - ListView->setColumnWidth(1,59); + ListView->setColumnWidth(1,-1); + ListView->addColumn( "Date",-1); + ListView->setColumnWidthMode(0,QListView::Manual); ListView->setColumnAlignment(1,QListView::AlignRight); @@ -98,9 +102,10 @@ void fileSaver::populateList() { ListView->clear(); + bool isDir=FALSE; currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); currentDir.setMatchAllDirs(TRUE); currentDir.setNameFilter("*"); - QString fileL, fileS; + QString fileL, fileS, fileDate; const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); QFileInfoListIterator it(*list); @@ -121,8 +126,40 @@ void fileSaver::populateList() if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) { fileL+="/"; + isDir=TRUE; // qDebug(currentDir.canonicalPath()+fileL); } } - item= new QListViewItem( ListView,fileL,fileS ); + if(fileL !="./") { + item= new QListViewItem( ListView,fileL,fileS , fileDate); + QPixmap pm; + + if(isDir || fileL.find("/",0,TRUE) != -1) { + if( !QDir( fi->filePath() ).isReadable()) + pm = Resource::loadPixmap( "lockedfolder" ); + else + pm= Resource::loadPixmap( "folder" ); + item->setPixmap( 0,pm ); + } else { + if( !fi->isReadable() ) + pm = Resource::loadPixmap( "locked" ); + else { + MimeType mt(fi->filePath()); + pm=mt.pixmap(); + if(pm.isNull()) + pm = Resource::loadPixmap( "UnknownDocument-14" ); + item->setPixmap( 0,pm); + } + } + if( fileL.find("->",0,TRUE) != -1) { + // overlay link image + pm= Resource::loadPixmap( "folder" ); + QPixmap lnk = Resource::loadPixmap( "symlink" ); + QPainter painter( &pm ); + painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); + pm.setMask( pm.createHeuristicMask( FALSE ) ); + item->setPixmap( 0, pm); + } + } + isDir=FALSE; ++it; } |