summaryrefslogtreecommitdiff
path: root/noncore/apps/advancedfm/advancedfm.cpp
Unidiff
Diffstat (limited to 'noncore/apps/advancedfm/advancedfm.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/advancedfm/advancedfm.cpp27
1 files changed, 11 insertions, 16 deletions
diff --git a/noncore/apps/advancedfm/advancedfm.cpp b/noncore/apps/advancedfm/advancedfm.cpp
index 979549d..828f5a1 100644
--- a/noncore/apps/advancedfm/advancedfm.cpp
+++ b/noncore/apps/advancedfm/advancedfm.cpp
@@ -1,71 +1,70 @@
1/*************************************************************************** 1/***************************************************************************
2 AdvancedFm.cpp 2 AdvancedFm.cpp
3 ------------------- 3 -------------------
4 ** Created: Sat Mar 9 23:33:09 2002 4 ** Created: Sat Mar 9 23:33:09 2002
5 copyright : (C) 2002 by ljp 5 copyright : (C) 2002 by ljp
6 email : ljp@llornkcor.com 6 email : ljp@llornkcor.com
7 * This program is free software; you can redistribute it and/or modify * 7 * This program is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by * 8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation; either version 2 of the License, or * 9 * the Free Software Foundation; either version 2 of the License, or *
10 * (at your option) any later version. * 10 * (at your option) any later version. *
11 ***************************************************************************/ 11 ***************************************************************************/
12#define DEVELOPERS_VERSION 12#define DEVELOPERS_VERSION
13#include "advancedfm.h" 13#include "advancedfm.h"
14 14
15#include <opie2/odebug.h> 15#include <opie2/odebug.h>
16 16#include <opie2/oresource.h>
17#include <opie2/ostorageinfo.h> 17#include <opie2/ostorageinfo.h>
18 18
19#include <qpe/qpeapplication.h> 19#include <qpe/qpeapplication.h>
20#include <qpe/config.h> 20#include <qpe/config.h>
21#include <qpe/mimetype.h> 21#include <qpe/mimetype.h>
22#include <qpe/applnk.h> 22#include <qpe/applnk.h>
23#include <qpe/resource.h>
24#include <qpe/menubutton.h> 23#include <qpe/menubutton.h>
25 24
26#include <qcombobox.h> 25#include <qcombobox.h>
27#include <qpopupmenu.h> 26#include <qpopupmenu.h>
28#include <qlistview.h> 27#include <qlistview.h>
29#include <qmessagebox.h> 28#include <qmessagebox.h>
30#include <qlineedit.h> 29#include <qlineedit.h>
31 30
32 31
33#include <sys/stat.h> 32#include <sys/stat.h>
34#include <time.h> 33#include <time.h>
35#include <dirent.h> 34#include <dirent.h>
36#include <fcntl.h> 35#include <fcntl.h>
37#include <sys/vfs.h> 36#include <sys/vfs.h>
38#include <mntent.h> 37#include <mntent.h>
39 38
40using namespace Opie::Ui; 39using namespace Opie::Ui;
41 40
42AdvancedFm::AdvancedFm(QWidget *,const char*, WFlags ) 41AdvancedFm::AdvancedFm(QWidget *,const char*, WFlags )
43 : QMainWindow( ) { 42 : QMainWindow( ) {
44 init(); 43 init();
45 renameBox = 0; 44 renameBox = 0;
46 whichTab = 1; 45 whichTab = 1;
47 unknownXpm = Resource::loadImage("UnknownDocument").smoothScale(AppLnk::smallIconSize(),AppLnk::smallIconSize() ); 46 unknownXpm = Opie::Core::OResource::loadImage("UnknownDocument", Opie::Core::OResource::SmallIcon);
48 47
49 initConnections(); 48 initConnections();
50 rePopulate(); 49 rePopulate();
51 channel = new QCopChannel( "QPE/Application/advancedfm", this ); 50 channel = new QCopChannel( "QPE/Application/advancedfm", this );
52 connect(channel,SIGNAL(received(const QCString&,const QByteArray&)),this,SLOT(qcopReceive(const QCString&,const QByteArray&))); 51 connect(channel,SIGNAL(received(const QCString&,const QByteArray&)),this,SLOT(qcopReceive(const QCString&,const QByteArray&)));
53 switchToLocalTab(); 52 switchToLocalTab();
54} 53}
55 54
56AdvancedFm::~AdvancedFm() { 55AdvancedFm::~AdvancedFm() {
57} 56}
58 57
59 58
60void AdvancedFm::cleanUp() { 59void AdvancedFm::cleanUp() {
61 QString sfile=QDir::homeDirPath(); 60 QString sfile=QDir::homeDirPath();
62 if(sfile.right(1) != "/") 61 if(sfile.right(1) != "/")
63 sfile+="/._temp"; 62 sfile+="/._temp";
64 else 63 else
65 sfile+="._temp"; 64 sfile+="._temp";
66 QFile file( sfile); 65 QFile file( sfile);
67 if(file.exists()) 66 if(file.exists())
68 file.remove(); 67 file.remove();
69} 68}
70 69
71void AdvancedFm::tabChanged(QWidget *wd) { 70void AdvancedFm::tabChanged(QWidget *wd) {
@@ -115,78 +114,73 @@ void AdvancedFm::populateView() {
115 if (fi->isSymLink() ) { 114 if (fi->isSymLink() ) {
116 QString symLink = fi->readLink(); 115 QString symLink = fi->readLink();
117 QFileInfo sym( symLink); 116 QFileInfo sym( symLink);
118 fileS.sprintf( "%10i", sym.size() ); 117 fileS.sprintf( "%10i", sym.size() );
119 fileL = fi->fileName() +" -> " + sym.filePath().data(); 118 fileL = fi->fileName() +" -> " + sym.filePath().data();
120 fileDate = sym.lastModified().toString(); 119 fileDate = sym.lastModified().toString();
121 } else { 120 } else {
122 fileS.sprintf( "%10i", fi->size() ); 121 fileS.sprintf( "%10i", fi->size() );
123 fileL = fi->fileName(); 122 fileL = fi->fileName();
124 fileDate= fi->lastModified().toString(); 123 fileDate= fi->lastModified().toString();
125 if( QDir(QDir::cleanDirPath( path +"/"+fileL)).exists() ) { 124 if( QDir(QDir::cleanDirPath( path +"/"+fileL)).exists() ) {
126// if(fileL == "..") 125// if(fileL == "..")
127 fileL += "/"; 126 fileL += "/";
128 isDir=TRUE; 127 isDir=TRUE;
129 } 128 }
130 } 129 }
131 QFileInfo fileInfo( path + "/" + fileL); 130 QFileInfo fileInfo( path + "/" + fileL);
132 131
133 if(fileL !="./" && fi->exists()) { 132 if(fileL !="./" && fi->exists()) {
134 item = new QListViewItem( thisView, fileL, fileS , fileDate); 133 item = new QListViewItem( thisView, fileL, fileS , fileDate);
135 134
136 if(isDir || fileL.find("/",0,TRUE) != -1) { 135 if(isDir || fileL.find("/",0,TRUE) != -1) {
137 136
138 if( !QDir( fi->filePath() ).isReadable()) //is directory 137 if( !QDir( fi->filePath() ).isReadable()) //is directory
139 pm.convertFromImage( Resource::loadImage( "lockedfolder" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); 138 pm = Opie::Core::OResource::loadPixmap( "lockedfolder", Opie::Core::OResource::SmallIcon );
140 else 139 else
141 pm.convertFromImage( Resource::loadImage( "folder" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); 140 pm = Opie::Core::OResource::loadPixmap( "folder", Opie::Core::OResource::SmallIcon );
142 } 141 }
143 else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) { 142 else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) {
144 pm.convertFromImage( Resource::loadImage( "exec" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); 143 pm = Opie::Core::OResource::loadPixmap( "exec", Opie::Core::OResource::SmallIcon );
145 } 144 }
146 else if( (fileInfo.permission( QFileInfo::ExeUser) 145 else if( (fileInfo.permission( QFileInfo::ExeUser)
147 | fileInfo.permission( QFileInfo::ExeGroup) 146 | fileInfo.permission( QFileInfo::ExeGroup)
148 | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) { 147 | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) {
149 pm.convertFromImage( Resource::loadImage( "exec" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); 148 pm = Opie::Core::OResource::loadPixmap( "exec", Opie::Core::OResource::SmallIcon );
150 } 149 }
151 else if( !fi->isReadable() ) { 150 else if( !fi->isReadable() ) {
152 pm.convertFromImage( Resource::loadImage( "locked" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); 151 pm = Opie::Core::OResource::loadPixmap( "locked", Opie::Core::OResource::SmallIcon );
153 } 152 }
154 else { //everything else goes by mimetype 153 else { //everything else goes by mimetype
155 MimeType mt(fi->filePath()); 154 MimeType mt(fi->filePath());
156 pm=mt.pixmap(); //sets the correct pixmap for mimetype 155 pm=mt.pixmap(); //sets the correct pixmap for mimetype
157 if(pm.isNull()) { 156 if(pm.isNull()) {
158 pm = unknownXpm; 157 pm = unknownXpm;
159 } 158 }
160 } 159 }
161 if( fi->isSymLink() || fileL.find("->",0,TRUE) != -1) { 160 if( fi->isSymLink() || fileL.find("->",0,TRUE) != -1) {
162 // odebug << " overlay link image" << oendl; 161 // odebug << " overlay link image" << oendl;
163 pm.convertFromImage( Resource::loadImage( "advancedfm/symlink" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); 162 pm = Opie::Core::OResource::loadPixmap( "advancedfm/symlink", Opie::Core::OResource::SmallIcon );
164 // pm= Resource::loadPixmap( "folder" );
165// QPixmap lnk = Resource::loadPixmap( "opie/symlink" );
166// QPainter painter( &pm );
167// painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk );
168// pm.setMask( pm.createHeuristicMask( FALSE ) );
169 } 163 }
170 item->setPixmap( 0, pm ); 164 item->setPixmap( 0, pm );
171 165
172 } 166 }
173 isDir=FALSE; 167 isDir=FALSE;
174 ++it; 168 ++it;
175 } 169 }
176 170
177 if( path.find("dev",0,TRUE) != -1) { 171 if( path.find("dev",0,TRUE) != -1) {
178 struct stat buf; 172 struct stat buf;
179 dev_t devT; 173 dev_t devT;
180 DIR *dir; 174 DIR *dir;
181 struct dirent *mydirent; 175 struct dirent *mydirent;
182 176
183 if((dir = opendir( path.latin1())) != NULL) 177 if((dir = opendir( path.latin1())) != NULL)
184 while ((mydirent = readdir(dir)) != NULL) { 178 while ((mydirent = readdir(dir)) != NULL) {
185 lstat( mydirent->d_name, &buf); 179 lstat( mydirent->d_name, &buf);
186// odebug << mydirent->d_name << oendl; 180// odebug << mydirent->d_name << oendl;
187 fileL.sprintf("%s", mydirent->d_name); 181 fileL.sprintf("%s", mydirent->d_name);
188 devT = buf.st_dev; 182 devT = buf.st_dev;
189 fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF); 183 fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF);
190 fileDate.sprintf("%s", ctime( &buf.st_mtime)); 184 fileDate.sprintf("%s", ctime( &buf.st_mtime));
191 if( fileL.find(".") == -1 ) { 185 if( fileL.find(".") == -1 ) {
192 item= new QListViewItem( thisView, fileL, fileS, fileDate); 186 item= new QListViewItem( thisView, fileL, fileS, fileDate);
@@ -439,49 +433,50 @@ QString AdvancedFm::getDiskSpace( const QString &path) {
439} 433}
440 434
441 435
442void AdvancedFm::showFileMenu() { 436void AdvancedFm::showFileMenu() {
443 QString curApp; 437 QString curApp;
444 curApp = CurrentView()->currentItem()->text(0); 438 curApp = CurrentView()->currentItem()->text(0);
445 439
446 MimeType mt(curApp); 440 MimeType mt(curApp);
447 const AppLnk* app = mt.application(); 441 const AppLnk* app = mt.application();
448 QFile fi(curApp); 442 QFile fi(curApp);
449 QPopupMenu *m = new QPopupMenu(0); 443 QPopupMenu *m = new QPopupMenu(0);
450 QPopupMenu *n = new QPopupMenu(0); 444 QPopupMenu *n = new QPopupMenu(0);
451 // QPopupMenu *o = new QPopupMenu(0); 445 // QPopupMenu *o = new QPopupMenu(0);
452 m->insertItem(tr("Show Hidden Files"),this,SLOT(showHidden())); 446 m->insertItem(tr("Show Hidden Files"),this,SLOT(showHidden()));
453 447
454 if ( QFileInfo(fi).isDir()) { 448 if ( QFileInfo(fi).isDir()) {
455 m->insertSeparator(); 449 m->insertSeparator();
456 m->insertItem(tr("Change Directory"),this,SLOT(doDirChange())); 450 m->insertItem(tr("Change Directory"),this,SLOT(doDirChange()));
457 } else { 451 } else {
458 452
459 if (app) 453 if (app)
460 m->insertItem(app->pixmap(),tr("Open in " + app->name()),this,SLOT(runThis())); 454 m->insertItem(app->pixmap(),tr("Open in " + app->name()),this,SLOT(runThis()));
461 else if(QFileInfo(fi).isExecutable() ) //damn opie doesnt like this 455 else if(QFileInfo(fi).isExecutable() ) //damn opie doesnt like this
462 m->insertItem(tr("Execute"),this,SLOT(runThis())); 456 m->insertItem(tr("Execute"),this,SLOT(runThis()));
463 m->insertItem(Resource::loadPixmap("txt"),tr("Open as text"),this,SLOT(runText())); 457 m->insertItem( Opie::Core::OResource::loadPixmap( "txt", Opie::Core::OResource::SmallIcon ),
458 tr("Open as text"),this,SLOT(runText()));
464 } 459 }
465 460
466 m->insertItem(tr("Actions"),n); 461 m->insertItem(tr("Actions"),n);
467 n->insertItem(tr("Make Directory"),this,SLOT(makeDir())); 462 n->insertItem(tr("Make Directory"),this,SLOT(makeDir()));
468 463
469 n->insertItem(tr("Make Symlink"),this,SLOT(mkSym())); 464 n->insertItem(tr("Make Symlink"),this,SLOT(mkSym()));
470 465
471 n->insertSeparator(); 466 n->insertSeparator();
472 n->insertItem(tr("Rename"),this,SLOT(renameIt())); 467 n->insertItem(tr("Rename"),this,SLOT(renameIt()));
473 468
474 n->insertItem(tr("Copy"),this,SLOT(copyTimer())); 469 n->insertItem(tr("Copy"),this,SLOT(copyTimer()));
475 n->insertItem(tr("Copy As"),this,SLOT(copyAsTimer())); 470 n->insertItem(tr("Copy As"),this,SLOT(copyAsTimer()));
476 n->insertItem(tr("Copy Same Dir"),this,SLOT(copySameDirTimer())); 471 n->insertItem(tr("Copy Same Dir"),this,SLOT(copySameDirTimer()));
477 n->insertItem(tr("Move"),this,SLOT(moveTimer())); 472 n->insertItem(tr("Move"),this,SLOT(moveTimer()));
478 473
479 n->insertSeparator(); 474 n->insertSeparator();
480 n->insertItem(tr("Delete"),this,SLOT(doDelete())); 475 n->insertItem(tr("Delete"),this,SLOT(doDelete()));
481 m->insertItem(tr("Add To Documents"),this,SLOT(addToDocs())); 476 m->insertItem(tr("Add To Documents"),this,SLOT(addToDocs()));
482 477
483 m->insertItem(tr("Run Command"),this,SLOT(runCommand())); 478 m->insertItem(tr("Run Command"),this,SLOT(runCommand()));
484 m->insertItem(tr("File Info"),this,SLOT(fileStatus())); 479 m->insertItem(tr("File Info"),this,SLOT(fileStatus()));
485 480
486 m->insertSeparator(); 481 m->insertSeparator();
487 m->insertItem(tr("Set Permissions"),this,SLOT(filePerms())); 482 m->insertItem(tr("Set Permissions"),this,SLOT(filePerms()));