summaryrefslogtreecommitdiff
path: root/core
authorllornkcor <llornkcor>2002-03-25 02:46:56 (UTC)
committer llornkcor <llornkcor>2002-03-25 02:46:56 (UTC)
commitb43c59f2f8da6edfa37042e0838b38702636f4d1 (patch) (side-by-side diff)
tree31913b2d26759d404c570c2164949da5b0796027 /core
parentd8820a9f2bdf9bc98c99542e3613ca9b5d2c6e0c (diff)
downloadopie-b43c59f2f8da6edfa37042e0838b38702636f4d1.zip
opie-b43c59f2f8da6edfa37042e0838b38702636f4d1.tar.gz
opie-b43c59f2f8da6edfa37042e0838b38702636f4d1.tar.bz2
added more icon stuff
Diffstat (limited to 'core') (more/less context) (ignore whitespace changes)
-rw-r--r--core/apps/textedit/fileBrowser.cpp53
1 files changed, 30 insertions, 23 deletions
diff --git a/core/apps/textedit/fileBrowser.cpp b/core/apps/textedit/fileBrowser.cpp
index acd50c2..ebb78d1 100644
--- a/core/apps/textedit/fileBrowser.cpp
+++ b/core/apps/textedit/fileBrowser.cpp
@@ -1,45 +1,46 @@
/****************************************************************************
** 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 "inputDialog.h"
#include <qpe/config.h>
#include <qpe/resource.h>
#include <qpe/fileselector.h>
#include <qpe/qpeapplication.h>
#include <qpe/menubutton.h>
+#include <qpe/mimetype.h>
#include <qdict.h>
#include <qwidgetstack.h>
#include <qlistview.h>
#include <qcombo.h>
#include <qpushbutton.h>
#include <qfile.h>
#include <qmessagebox.h>
#include <qlayout.h>
#include <unistd.h>
#include <qpopupmenu.h>
#include <qlineedit.h>
#include <qstringlist.h>
#include <unistd.h>
#include <stdlib.h>
static int u_id = 1;
static int get_unique_id()
{
return u_id++;
}
fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags fl , const QString filter )
@@ -97,49 +98,49 @@ fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags
FileStack = new QWidgetStack( this );
ListView = new QListView( this, "ListView" );
// ListView->setMinimumSize( QSize( 100, 25 ) );
ListView->addColumn( tr( "Name" ) );
ListView->setColumnWidth(0,120);
ListView->setSorting( 2, FALSE);
ListView->addColumn( tr( "Size" ) );
ListView->setColumnWidth(1,-1);
ListView->addColumn( "Date",-1);
ListView->setColumnWidthMode(0,QListView::Manual);
ListView->setColumnAlignment(1,QListView::AlignRight);
ListView->setColumnAlignment(2,QListView::AlignRight);
ListView->setAllColumnsShowFocus( TRUE );
QPEApplication::setStylusOperation( ListView->viewport(),QPEApplication::RightOnHold);
connect( ListView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
this,SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) );
connect( ListView, SIGNAL( clicked( QListViewItem*)), SLOT(listClicked(QListViewItem *)) );
FileStack->addWidget( ListView, get_unique_id() );
- mimeType="text/*";
+mimeType="text/*";
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 &) ), this, SLOT( docOpen( const DocLnk & ) ) );
layout->addMultiCellWidget( FileStack, 1, 1, 0, 7 );
SelectionCombo = new QComboBox( FALSE, this, "SelectionCombo" );
SelectionCombo->insertItem( tr( "Documents" ) );
SelectionCombo->insertItem( tr( "All files" ) );
SelectionCombo->insertItem( tr( "Hidden files" ) );
// SelectionCombo->setMaximumWidth(120);
layout->addMultiCellWidget( SelectionCombo, 2, 2, 0, 3 );
connect( SelectionCombo, SIGNAL( activated( const QString & ) ),
this, SLOT( selectionChanged( const QString & ) ) );
typemb = new MenuButton(this);
typemb->setLabel(tr("Type: %1"));
typemb->setMinimumWidth(110);
typemb->setFixedHeight(22);
layout->addMultiCellWidget( typemb, 2, 2, 4, 7 );
updateMimeTypeMenu() ;
currentDir.setPath(QDir::currentDirPath());
@@ -173,72 +174,78 @@ void fileBrowser::populateList()
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() );
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;
// qDebug( fileL);
}
}
if(fileL !="./") {
- item= new QListViewItem( ListView,fileL,fileS , fileDate);
- QPixmap pm;
- pm= Resource::loadPixmap( "folder" );
+ 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" );
- item->setPixmap( 0,pm );
- } else {
- if( !fi->isReadable() )
- pm = Resource::loadPixmap( "locked" );
- else
- pm = Resource::loadPixmap( "fileopen" );
- item->setPixmap( 0,pm);
- }
- if( fileL.find("->",0,TRUE) != -1) {
- // overlay link image
- 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(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;
}
ListView->setSorting( 3, FALSE);
QString currentPath = currentDir.canonicalPath();
fillCombo( (const QString &)currentPath);
// dirPathCombo->lineEdit()->setText(currentPath);
// if( dirPathStringList.grep(currentPath,TRUE).isEmpty() ) {
// dirPathCombo->clear();
// dirPathStringList.prepend(currentPath );
// dirPathCombo->insertStringList( dirPathStringList,-1);
// }
}
void fileBrowser::upDir()
{
QString current = currentDir.canonicalPath();
QDir dir(current);
dir.cdUp();
current = dir.canonicalPath();
chdir( current.latin1() );
currentDir.cd( current, TRUE);