summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/advancedfm/advancedfm.cpp943
-rw-r--r--noncore/apps/advancedfm/advancedfm.h2
2 files changed, 477 insertions, 468 deletions
diff --git a/noncore/apps/advancedfm/advancedfm.cpp b/noncore/apps/advancedfm/advancedfm.cpp
index bb7f346..1a5e131 100644
--- a/noncore/apps/advancedfm/advancedfm.cpp
+++ b/noncore/apps/advancedfm/advancedfm.cpp
@@ -31,6 +31,7 @@
31#include <qpe/menubutton.h> 31#include <qpe/menubutton.h>
32 32
33 33
34#include <qwmatrix.h>
34#include <qregexp.h> 35#include <qregexp.h>
35#include <qtabwidget.h> 36#include <qtabwidget.h>
36#include <qtextstream.h> 37#include <qtextstream.h>
@@ -69,14 +70,19 @@
69#include <sys/utsname.h> 70#include <sys/utsname.h>
70 71
71AdvancedFm::AdvancedFm( ) 72AdvancedFm::AdvancedFm( )
72 : QMainWindow( ) { 73 : QMainWindow( ) {
73 init(); 74 init();
74 renameBox = 0; 75 renameBox = 0;
75 76
76 initConnections(); 77 QWMatrix matrix;
77 whichTab=1; 78 QPixmap pix(Resource::loadPixmap( "UnknownDocument" ));
78 rePopulate(); 79 matrix.scale( .4, .4);
79 currentPathCombo->setFocus(); 80 unknownXpm = pix.xForm(matrix);
81
82 initConnections();
83 whichTab=1;
84 rePopulate();
85 currentPathCombo->setFocus();
80} 86}
81 87
82AdvancedFm::~AdvancedFm() { 88AdvancedFm::~AdvancedFm() {
@@ -97,33 +103,33 @@ void AdvancedFm::cleanUp()
97 103
98void AdvancedFm::tabChanged(QWidget *w) 104void AdvancedFm::tabChanged(QWidget *w)
99{ 105{
100 if( w == tab) 106 if( w == tab)
101 whichTab = 1; 107 whichTab = 1;
102 else 108 else
103 whichTab = 2; 109 whichTab = 2;
104 110
105 //qDebug("tab changed %d", whichTab ); 111// qDebug("tab changed %d", whichTab );
106 112
107 QString path = CurrentDir()->canonicalPath(); 113 QString path = CurrentDir()->canonicalPath();
108 currentPathCombo->lineEdit()->setText( path ); 114 currentPathCombo->lineEdit()->setText( path );
109 115
110 viewMenu->setItemChecked(viewMenu->idAt(0),TRUE); 116 viewMenu->setItemChecked(viewMenu->idAt(0),TRUE);
111 viewMenu->setItemChecked(viewMenu->idAt(1),FALSE); 117 viewMenu->setItemChecked(viewMenu->idAt(1),FALSE);
112 118
113 QString fs= getFileSystemType( (const QString &) path); 119 QString fs= getFileSystemType( (const QString &) path);
114 120
115 setCaption("AdvancedFm :: "+fs+" :: " 121 setCaption("AdvancedFm :: "+fs+" :: "
116 +checkDiskSpace( (const QString &) path )+ " kB free" ); 122 +checkDiskSpace( (const QString &) path )+ " kB free" );
117 chdir( path.latin1()); 123 chdir( path.latin1());
118} 124}
119 125
120 126
121void AdvancedFm::populateView() 127void AdvancedFm::populateView()
122{ 128{
123 QPixmap pm; 129 QPixmap pm;
124 QListView *thisView = CurrentView(); 130 QListView *thisView = CurrentView();
125 QDir *thisDir = CurrentDir(); 131 QDir *thisDir = CurrentDir();
126 QString path = thisDir->canonicalPath(); 132 QString path = thisDir->canonicalPath();
127 133
128 thisView->clear(); 134 thisView->clear();
129 thisDir->setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 135 thisDir->setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
@@ -138,103 +144,104 @@ void AdvancedFm::populateView()
138 QFileInfoListIterator it(*list); 144 QFileInfoListIterator it(*list);
139 QFileInfo *fi; 145 QFileInfo *fi;
140 while ( (fi=it.current()) ) 146 while ( (fi=it.current()) )
141 { 147 {
142 if (fi->isSymLink() ) 148 if (fi->isSymLink() )
143 { 149 {
144 QString symLink=fi->readLink(); 150 QString symLink=fi->readLink();
145 QFileInfo sym( symLink); 151 QFileInfo sym( symLink);
146 fileS.sprintf( "%10i", sym.size() ); 152 fileS.sprintf( "%10i", sym.size() );
147 fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.filePath().data() ); 153 fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.filePath().data() );
148 fileDate = sym.lastModified().toString(); 154 fileDate = sym.lastModified().toString();
149 } 155 }
150 else 156 else
151 { 157 {
152 fileS.sprintf( "%10i", fi->size() ); 158 fileS.sprintf( "%10i", fi->size() );
153 fileL.sprintf( "%s",fi->fileName().data() ); 159 fileL.sprintf( "%s",fi->fileName().data() );
154 fileDate= fi->lastModified().toString(); 160 fileDate= fi->lastModified().toString();
155 if( QDir(QDir::cleanDirPath( path +"/"+fileL)).exists() ) 161 if( QDir(QDir::cleanDirPath( path +"/"+fileL)).exists() )
156 { 162 {
157 fileL+="/"; 163 fileL+="/";
158 isDir=TRUE; 164 isDir=TRUE;
159 } 165 }
160 } 166 }
161 167
162 QFileInfo fileInfo( path + "/" + fileL); 168 QFileInfo fileInfo( path + "/" + fileL);
163 169
164 if(fileL !="./" && fi->exists()) 170 if(fileL !="./" && fi->exists())
165 { 171 {
166 item= new QListViewItem( thisView, fileL, fileS , fileDate); 172 item= new QListViewItem( thisView, fileL, fileS , fileDate);
167 173
168 if(isDir || fileL.find("/",0,TRUE) != -1) 174 if(isDir || fileL.find("/",0,TRUE) != -1)
169 { 175 {
170 176
171 if( !QDir( fi->filePath() ).isReadable()) //is directory 177 if( !QDir( fi->filePath() ).isReadable()) //is directory
172 pm = Resource::loadPixmap( "lockedfolder" ); 178 pm = Resource::loadPixmap( "lockedfolder" );
173 else 179 else
174 pm= Resource::loadPixmap( "folder" ); 180 pm= Resource::loadPixmap( "folder" );
175 } 181 }
176 else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) 182 else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") )
177 { 183 {
178 pm = Resource::loadPixmap( "exec"); 184 pm = Resource::loadPixmap( "exec");
179 } 185 }
180 else if( (fileInfo.permission( QFileInfo::ExeUser) 186 else if( (fileInfo.permission( QFileInfo::ExeUser)
181 | fileInfo.permission( QFileInfo::ExeGroup) 187 | fileInfo.permission( QFileInfo::ExeGroup)
182 | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) 188 | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" )
183 { 189 {
184 pm = Resource::loadPixmap( "exec"); 190 pm = Resource::loadPixmap( "exec");
185 } 191 }
186 else if( !fi->isReadable() ) 192 else if( !fi->isReadable() )
187 { 193 {
188 pm = Resource::loadPixmap( "locked" ); 194 pm = Resource::loadPixmap( "locked" );
189 } 195 }
190 else { //everything else goes by mimetype 196 else { //everything else goes by mimetype
191 MimeType mt(fi->filePath()); 197 MimeType mt(fi->filePath());
192 pm=mt.pixmap(); //sets the correct pixmap for mimetype 198 pm=mt.pixmap(); //sets the correct pixmap for mimetype
193 if(pm.isNull()) 199 if(pm.isNull()) {
194 pm = Resource::loadPixmap( "UnknownDocument-14" ); 200 pm = unknownXpm;
195 } 201 }
196 item->setPixmap( 0,pm); 202 }
197 if( fi->isSymLink() && fileL.find("->",0,TRUE) != -1) 203 if( fi->isSymLink() && fileL.find("->",0,TRUE) != -1)
198 { 204 {
199 // overlay link image 205 // overlay link image
200 pm= Resource::loadPixmap( "folder" ); 206 pm= Resource::loadPixmap( "folder" );
201 QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); 207 QPixmap lnk = Resource::loadPixmap( "opie/symlink" );
202 QPainter painter( &pm ); 208 QPainter painter( &pm );
203 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); 209 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk );
204 pm.setMask( pm.createHeuristicMask( FALSE ) ); 210 pm.setMask( pm.createHeuristicMask( FALSE ) );
205 item->setPixmap( 0, pm); 211 }
206 } 212 item->setPixmap( 0,pm);
207 } 213
208 isDir=FALSE; 214 }
209 ++it; 215 isDir=FALSE;
210 } 216 ++it;
217 }
211 218
212 if( path.find("dev",0,TRUE) != -1) 219 if( path.find("dev",0,TRUE) != -1)
213 { 220 {
214 struct stat buf; 221 struct stat buf;
215 dev_t devT; 222 dev_t devT;
216 DIR *dir; 223 DIR *dir;
217 struct dirent *mydirent; 224 struct dirent *mydirent;
218 225
219 if((dir = opendir( path.latin1())) != NULL) 226 if((dir = opendir( path.latin1())) != NULL)
220 while ((mydirent = readdir(dir)) != NULL) 227 while ((mydirent = readdir(dir)) != NULL)
221 { 228 {
222 lstat( mydirent->d_name, &buf); 229 lstat( mydirent->d_name, &buf);
223// qDebug(mydirent->d_name); 230// qDebug(mydirent->d_name);
224 fileL.sprintf("%s", mydirent->d_name); 231 fileL.sprintf("%s", mydirent->d_name);
225 devT = buf.st_dev; 232 devT = buf.st_dev;
226 fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF); 233 fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF);
227 fileDate.sprintf("%s", ctime( &buf.st_mtime)); 234 fileDate.sprintf("%s", ctime( &buf.st_mtime));
228 if( fileL.find(".") == -1 ) 235 if( fileL.find(".") == -1 )
229 { 236 {
230 item= new QListViewItem( thisView, fileL, fileS, fileDate); 237 item= new QListViewItem( thisView, fileL, fileS, fileDate);
231 pm = Resource::loadPixmap( "UnknownDocument-14" ); 238 pm = unknownXpm;
232 item->setPixmap( 0,pm); 239 item->setPixmap( 0,pm);
233 } 240 }
234 } 241 }
235 242
236 closedir(dir); 243 closedir(dir);
237 } 244 }
238 245
239 thisView->setSorting( 3,FALSE); 246 thisView->setSorting( 3,FALSE);
240 fillCombo( (const QString &) path ); 247 fillCombo( (const QString &) path );
@@ -242,61 +249,61 @@ void AdvancedFm::populateView()
242 249
243void AdvancedFm::rePopulate() 250void AdvancedFm::rePopulate()
244{ 251{
245 int tmpTab = whichTab; 252 int tmpTab = whichTab;
246 qDebug("%d", tmpTab); 253 qDebug("%d", tmpTab);
247 254
248 for(int i =1; i < 3; i++) 255 for(int i =1; i < 3; i++)
249 { 256 {
250 TabWidget->setCurrentTab(i - 1); 257 TabWidget->setCurrentTab(i - 1);
251 populateView(); 258 populateView();
252 } 259 }
253 TabWidget->setCurrentTab( tmpTab - 1); 260 TabWidget->setCurrentTab( tmpTab - 1);
254} 261}
255 262
256void AdvancedFm::ListClicked(QListViewItem *selectedItem) 263void AdvancedFm::ListClicked(QListViewItem *selectedItem)
257{ 264{
258 if(selectedItem) 265 if(selectedItem)
259 { 266 {
260 QString strItem=selectedItem->text(0); 267 QString strItem=selectedItem->text(0);
261 QString strSize=selectedItem->text(1); 268 QString strSize=selectedItem->text(1);
262 strSize=strSize.stripWhiteSpace(); 269 strSize=strSize.stripWhiteSpace();
263 bool isDirectory = false; 270 bool isDirectory = false;
264 QString strItem2; 271 QString strItem2;
265 272
266 if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 )//if symlink 273 if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 )//if symlink
267 { 274 {
268 strItem2 = dealWithSymName((const QString&)strItem); 275 strItem2 = dealWithSymName((const QString&)strItem);
269 if(QDir(strItem2).exists() ) 276 if(QDir(strItem2).exists() )
270 strItem = strItem2; 277 strItem = strItem2;
271 } 278 }
272 279
273 if( strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) 280 if( strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 )
274 { 281 {
275 282
276 if(QDir(strItem).exists()) 283 if(QDir(strItem).exists())
277 isDirectory = true; 284 isDirectory = true;
278 } 285 }
279 286
280 if( isDirectory ) 287 if( isDirectory )
281 { 288 {
282 CurrentDir()->cd( strItem, TRUE); 289 CurrentDir()->cd( strItem, TRUE);
283 populateView(); 290 populateView();
284 CurrentView()->ensureItemVisible( CurrentView()->firstChild()); 291 CurrentView()->ensureItemVisible( CurrentView()->firstChild());
285 } 292 }
286 chdir( strItem.latin1()); 293 chdir( strItem.latin1());
287 } 294 }
288} 295}
289 296
290void AdvancedFm::ListPressed( int mouse, QListViewItem *, const QPoint& , int ) { 297void AdvancedFm::ListPressed( int mouse, QListViewItem *, const QPoint& , int ) {
291 switch (mouse) { 298 switch (mouse) {
292 case 1: 299 case 1:
293 { 300 {
294 if(renameBox != 0 ) 301 if(renameBox != 0 )
295 { 302 {
296 cancelRename(); 303 cancelRename();
297 } 304 }
298 } 305 }
299 break; 306 break;
300 case 2: 307 case 2:
301 menuTimer.start( 500, TRUE ); 308 menuTimer.start( 500, TRUE );
302 break; 309 break;
@@ -327,40 +334,40 @@ void AdvancedFm::writeConfig()
327 334
328void AdvancedFm::currentPathComboChanged() 335void AdvancedFm::currentPathComboChanged()
329{ 336{
330 if(QDir( currentPathCombo->lineEdit()->text()).exists()) 337 if(QDir( currentPathCombo->lineEdit()->text()).exists())
331 { 338 {
332 CurrentDir()->setPath( currentPathCombo->lineEdit()->text() ); 339 CurrentDir()->setPath( currentPathCombo->lineEdit()->text() );
333 populateView(); 340 populateView();
334 } 341 }
335 else 342 else
336 { 343 {
337 QMessageBox::message(tr("Note"),tr("That directory does not exist")); 344 QMessageBox::message(tr("Note"),tr("That directory does not exist"));
338 } 345 }
339} 346}
340 347
341void AdvancedFm::fillCombo(const QString &currentPath) 348void AdvancedFm::fillCombo(const QString &currentPath)
342{ 349{
343// qDebug("%d",TabWidget->getCurrentTab()); 350// qDebug("%d",TabWidget->getCurrentTab());
344 if ( whichTab == 1) 351 if ( whichTab == 1)
345 { 352 {
346 currentPathCombo->lineEdit()->setText( currentPath); 353 currentPathCombo->lineEdit()->setText( currentPath);
347 if( localDirPathStringList.grep( currentPath,TRUE).isEmpty() ) 354 if( localDirPathStringList.grep( currentPath,TRUE).isEmpty() )
348 { 355 {
349 currentPathCombo->clear(); 356 currentPathCombo->clear();
350 localDirPathStringList.prepend( currentPath ); 357 localDirPathStringList.prepend( currentPath );
351 currentPathCombo->insertStringList( localDirPathStringList,-1); 358 currentPathCombo->insertStringList( localDirPathStringList,-1);
352 } 359 }
353 } 360 }
354 else 361 else
355 { 362 {
356 currentPathCombo->lineEdit()->setText( currentPath); 363 currentPathCombo->lineEdit()->setText( currentPath);
357 if( remoteDirPathStringList.grep( currentPath,TRUE).isEmpty() ) 364 if( remoteDirPathStringList.grep( currentPath,TRUE).isEmpty() )
358 { 365 {
359 currentPathCombo->clear(); 366 currentPathCombo->clear();
360 remoteDirPathStringList.prepend( currentPath ); 367 remoteDirPathStringList.prepend( currentPath );
361 currentPathCombo->insertStringList( remoteDirPathStringList,-1); 368 currentPathCombo->insertStringList( remoteDirPathStringList,-1);
362 } 369 }
363 } 370 }
364} 371}
365 372
366void AdvancedFm::currentPathComboActivated(const QString & currentPath) 373void AdvancedFm::currentPathComboActivated(const QString & currentPath)
@@ -374,26 +381,26 @@ void AdvancedFm::currentPathComboActivated(const QString & currentPath)
374QStringList AdvancedFm::getPath() 381QStringList AdvancedFm::getPath()
375{ 382{
376 QStringList strList; 383 QStringList strList;
377 QListView *thisView=CurrentView(); 384 QListView *thisView=CurrentView();
378 QList<QListViewItem> * getSelectedItems( QListView * thisView ); 385 QList<QListViewItem> * getSelectedItems( QListView * thisView );
379 QListViewItemIterator it( thisView ); 386 QListViewItemIterator it( thisView );
380 for ( ; it.current(); ++it ) 387 for ( ; it.current(); ++it )
381 { 388 {
382 if ( it.current()->isSelected() ) 389 if ( it.current()->isSelected() )
383 { 390 {
384 strList << it.current()->text(0); 391 strList << it.current()->text(0);
385// qDebug(it.current()->text(0)); 392// qDebug(it.current()->text(0));
386 } 393 }
387 } 394 }
388 return strList; 395 return strList;
389} 396}
390 397
391void AdvancedFm::homeButtonPushed() 398void AdvancedFm::homeButtonPushed()
392{ 399{
393 QString current = QDir::homeDirPath(); 400 QString current = QDir::homeDirPath();
394 chdir( current.latin1() ); 401 chdir( current.latin1() );
395 CurrentDir()->cd( current, TRUE); 402 CurrentDir()->cd( current, TRUE);
396 populateView(); 403 populateView();
397 update(); 404 update();
398} 405}
399 406
@@ -401,40 +408,40 @@ void AdvancedFm::docButtonPushed()
401{ 408{
402 QString current = QPEApplication::documentDir(); 409 QString current = QPEApplication::documentDir();
403 chdir( current.latin1() ); 410 chdir( current.latin1() );
404 CurrentDir()->cd( current, TRUE); 411 CurrentDir()->cd( current, TRUE);
405 populateView(); 412 populateView();
406 update(); 413 update();
407} 414}
408 415
409void AdvancedFm::SDButtonPushed() 416void AdvancedFm::SDButtonPushed()
410{ 417{
411 QString current = "/mnt/card";// this can change so fix 418 QString current = "/mnt/card";// this can change so fix
412 chdir( current.latin1() ); 419 chdir( current.latin1() );
413 CurrentDir()->cd( current, TRUE); 420 CurrentDir()->cd( current, TRUE);
414 populateView(); 421 populateView();
415 update(); 422 update();
416} 423}
417 424
418void AdvancedFm::CFButtonPushed() 425void AdvancedFm::CFButtonPushed()
419{ 426{
420 QString current; 427 QString current;
421 if(zaurusDevice) 428 if(zaurusDevice)
422 current= "/mnt/cf"; //zaurus 429 current= "/mnt/cf"; //zaurus
423 else 430 else
424 current = "/mnt/hda"; //ipaq 431 current = "/mnt/hda"; //ipaq
425 chdir( current.latin1() ); 432 chdir( current.latin1() );
426 CurrentDir()->cd( current, TRUE); 433 CurrentDir()->cd( current, TRUE);
427 populateView(); 434 populateView();
428 update(); 435 update();
429} 436}
430 437
431 438
432void AdvancedFm::doAbout() 439void AdvancedFm::doAbout()
433{ 440{
434 QMessageBox::message("AdvancedFm",tr("Advanced FileManager\n" 441 QMessageBox::message("AdvancedFm",tr("Advanced FileManager\n"
435 "is copyright 2002-2003 by\n" 442 "is copyright 2002-2003 by\n"
436 "L.J.Potter<llornkcor@handhelds.org>\n" 443 "L.J.Potter<llornkcor@handhelds.org>\n"
437 "and is licensed by the GPL")); 444 "and is licensed by the GPL"));
438} 445}
439 446
440void AdvancedFm::keyPressEvent( QKeyEvent *e) 447void AdvancedFm::keyPressEvent( QKeyEvent *e)
@@ -442,81 +449,81 @@ void AdvancedFm::keyPressEvent( QKeyEvent *e)
442// e->accept(); 449// e->accept();
443 if( CurrentView()->hasFocus() ) 450 if( CurrentView()->hasFocus() )
444 { 451 {
445 switch ( e->key() ) { 452 switch ( e->key() ) {
446 case Key_Delete: 453 case Key_Delete:
447 del(); 454 del();
448 break; 455 break;
449 case Key_A: 456 case Key_A:
450 copyAs(); 457 copyAs();
451 break; 458 break;
452 case Key_C: 459 case Key_C:
453 copy(); 460 copy();
454 break; 461 break;
455 case Key_E: 462 case Key_E:
456 runThis(); 463 runThis();
457 break; 464 break;
458 case Key_G: 465 case Key_G:
459 { 466 {
460 currentPathCombo->lineEdit()->setFocus(); 467 currentPathCombo->lineEdit()->setFocus();
461 } 468 }
462 break; 469 break;
463 470
464 case Key_H: 471 case Key_H:
465 showHidden(); 472 showHidden();
466 break; 473 break;
467 case Key_I: 474 case Key_I:
468 fileStatus(); 475 fileStatus();
469 break; 476 break;
470 case Key_M: 477 case Key_M:
471 move(); 478 move();
472 break; 479 break;
473 case Key_N: 480 case Key_N:
474 mkDir(); 481 mkDir();
475 break; 482 break;
476 case Key_P: 483 case Key_P:
477 filePerms(); 484 filePerms();
478 break; 485 break;
479 case Key_R: 486 case Key_R:
480 rn(); 487 rn();
481 break; 488 break;
482 case Key_U: 489 case Key_U:
483 upDir(); 490 upDir();
484 break; 491 break;
485 case Key_1: 492 case Key_1:
486 switchToLocalTab(); 493 switchToLocalTab();
487 break; 494 break;
488 case Key_2: 495 case Key_2:
489 switchToRemoteTab(); 496 switchToRemoteTab();
490 break; 497 break;
491 case Key_3: 498 case Key_3:
492 CFButtonPushed(); 499 CFButtonPushed();
493 break; 500 break;
494 case Key_4: 501 case Key_4:
495 SDButtonPushed(); 502 SDButtonPushed();
496 break; 503 break;
497 case Key_5: 504 case Key_5:
498 homeButtonPushed(); 505 homeButtonPushed();
499 break; 506 break;
500 case Key_6: 507 case Key_6:
501 docButtonPushed(); 508 docButtonPushed();
502 break; 509 break;
503 case Key_7: 510 case Key_7:
504 break; 511 break;
505 case Key_8: 512 case Key_8:
506 break; 513 break;
507 case Key_9: 514 case Key_9:
508 break; 515 break;
509 case Key_0: 516 case Key_0:
510 break; 517 break;
511 }; 518 };
512 e->accept(); 519 e->accept();
513 } 520 }
514} 521}
515 522
516void AdvancedFm::keyReleaseEvent( QKeyEvent *e) 523void AdvancedFm::keyReleaseEvent( QKeyEvent *e)
517{ 524{
518 if( CurrentView()->hasFocus() ) 525 if( CurrentView()->hasFocus() )
519 e->ignore(); 526 e->ignore();
520} 527}
521 528
522 529
@@ -537,14 +544,14 @@ void AdvancedFm::parsetab(const QString &fileName)
537 struct mntent *me; 544 struct mntent *me;
538 FILE *mntfp = setmntent( fileName.latin1(), "r" ); 545 FILE *mntfp = setmntent( fileName.latin1(), "r" );
539 if ( mntfp ) 546 if ( mntfp )
540 { 547 {
541 while ( (me = getmntent( mntfp )) != 0 ) 548 while ( (me = getmntent( mntfp )) != 0 )
542 { 549 {
543 QString deviceName = me->mnt_fsname; 550 QString deviceName = me->mnt_fsname;
544 QString filesystemType = me->mnt_type; 551 QString filesystemType = me->mnt_type;
545 QString mountDir = me->mnt_dir; 552 QString mountDir = me->mnt_dir;
546 if(deviceName != "none") 553 if(deviceName != "none")
547 { 554 {
548 if( fsList.contains(filesystemType) == 0 555 if( fsList.contains(filesystemType) == 0
549 & filesystemType.find("proc",0,TRUE) == -1 556 & filesystemType.find("proc",0,TRUE) == -1
550 & filesystemType.find("cramfs",0,TRUE) == -1 557 & filesystemType.find("cramfs",0,TRUE) == -1
@@ -576,90 +583,90 @@ QString AdvancedFm::getFileSystemType(const QString &currentText)
576 583
577QString AdvancedFm::getDiskSpace( const QString &path) 584QString AdvancedFm::getDiskSpace( const QString &path)
578{ 585{
579 struct statfs fss; 586 struct statfs fss;
580 if ( !statfs( path.latin1(), &fss ) ) { 587 if ( !statfs( path.latin1(), &fss ) ) {
581 int blkSize = fss.f_bsize; 588 int blkSize = fss.f_bsize;
582 // int totalBlks = fs.f_blocks; 589 // int totalBlks = fs.f_blocks;
583 int availBlks = fss.f_bavail; 590 int availBlks = fss.f_bavail;
584 591
585 long mult = blkSize / 1024; 592 long mult = blkSize / 1024;
586 long div = 1024 / blkSize; 593 long div = 1024 / blkSize;
587 if ( !mult ) mult = 1; 594 if ( !mult ) mult = 1;
588 if ( !div ) div = 1; 595 if ( !div ) div = 1;
589 596
590 return QString::number(availBlks * mult / div); 597 return QString::number(availBlks * mult / div);
591 } 598 }
592 return ""; 599 return "";
593} 600}
594 601
595 602
596void AdvancedFm::showFileMenu() 603void AdvancedFm::showFileMenu()
597{ 604{
598 QString curApp; 605 QString curApp;
599 curApp = CurrentView()->currentItem()->text(0); 606 curApp = CurrentView()->currentItem()->text(0);
600 607
601 MimeType mt( curApp ); 608 MimeType mt( curApp );
602 const AppLnk* app = mt.application(); 609 const AppLnk* app = mt.application();
603 QFile fi(curApp); 610 QFile fi(curApp);
604 QPopupMenu *m = new QPopupMenu(0); 611 QPopupMenu *m = new QPopupMenu(0);
605 QPopupMenu *n = new QPopupMenu(0); 612 QPopupMenu *n = new QPopupMenu(0);
606 // QPopupMenu *o = new QPopupMenu(0); 613 // QPopupMenu *o = new QPopupMenu(0);
607 m->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); 614 m->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() ));
608 615
609 if ( QFileInfo(fi).isDir() ) 616 if ( QFileInfo(fi).isDir() )
610 { 617 {
611 m->insertSeparator(); 618 m->insertSeparator();
612 m->insertItem( tr( "Change Directory" ), this, SLOT( doDirChange() )); 619 m->insertItem( tr( "Change Directory" ), this, SLOT( doDirChange() ));
613 } 620 }
614 else 621 else
615 { 622 {
616 623
617 if ( app ) 624 if ( app )
618 m->insertItem( app->pixmap(), tr( "Open in " 625 m->insertItem( app->pixmap(), tr( "Open in "
619 + app->name() ), this, SLOT( runThis() ) ); 626 + app->name() ), this, SLOT( runThis() ) );
620 else if( QFileInfo(fi).isExecutable() ) //damn opie doesnt like this 627 else if( QFileInfo(fi).isExecutable() ) //damn opie doesnt like this
621 m->insertItem( tr( "Execute" ), this, SLOT( runThis() ) ); 628 m->insertItem( tr( "Execute" ), this, SLOT( runThis() ) );
622 m->insertItem( Resource::loadPixmap( "txt" ), tr( "Open as text" ),this, SLOT( runText() ) ); 629 m->insertItem( Resource::loadPixmap( "txt" ), tr( "Open as text" ),this, SLOT( runText() ) );
623 } 630 }
624 631
625 m->insertItem(tr("Actions"),n); 632 m->insertItem(tr("Actions"),n);
626 n->insertItem( tr( "Make Directory" ), this, SLOT( makeDir() )); 633 n->insertItem( tr( "Make Directory" ), this, SLOT( makeDir() ));
627 634
628 n->insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() )); 635 n->insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() ));
629 636
630 n->insertSeparator(); 637 n->insertSeparator();
631 n->insertItem( tr( "Rename" ), this, SLOT( renameIt() )); 638 n->insertItem( tr( "Rename" ), this, SLOT( renameIt() ));
632 639
633 n->insertItem( tr( "Copy" ), this, SLOT( copy() )); 640 n->insertItem( tr( "Copy" ), this, SLOT( copy() ));
634 n->insertItem( tr( "Copy As" ), this, SLOT( copyAs() )); 641 n->insertItem( tr( "Copy As" ), this, SLOT( copyAs() ));
635 n->insertItem( tr( "Copy Same Dir" ), this, SLOT( copySameDir() )); 642 n->insertItem( tr( "Copy Same Dir" ), this, SLOT( copySameDir() ));
636 n->insertItem( tr( "Move" ), this, SLOT( move() )); 643 n->insertItem( tr( "Move" ), this, SLOT( move() ));
637 644
638 n->insertSeparator(); 645 n->insertSeparator();
639 n->insertItem( tr( "Delete" ), this, SLOT( doDelete() )); 646 n->insertItem( tr( "Delete" ), this, SLOT( doDelete() ));
640 m->insertItem( tr( "Add To Documents" ), this, SLOT( addToDocs() )); 647 m->insertItem( tr( "Add To Documents" ), this, SLOT( addToDocs() ));
641 648
642 m->insertItem( tr( "Run Command" ), this, SLOT( runCommand() )); 649 m->insertItem( tr( "Run Command" ), this, SLOT( runCommand() ));
643 m->insertItem( tr( "File Info" ), this, SLOT( fileStatus() )); 650 m->insertItem( tr( "File Info" ), this, SLOT( fileStatus() ));
644 651
645 m->insertSeparator(); 652 m->insertSeparator();
646 m->insertItem( tr( "Set Permissions" ), this, SLOT( filePerms() )); 653 m->insertItem( tr( "Set Permissions" ), this, SLOT( filePerms() ));
647 654
648#if defined(QT_QWS_OPIE) 655#if defined(QT_QWS_OPIE)
649 m->insertItem( tr( "Properties" ), this, SLOT( doProperties() )); 656 m->insertItem( tr( "Properties" ), this, SLOT( doProperties() ));
650#endif 657#endif
651 m->setCheckable(TRUE); 658 m->setCheckable(TRUE);
652 if (!b) 659 if (!b)
653 m->setItemChecked(m->idAt(0),TRUE); 660 m->setItemChecked(m->idAt(0),TRUE);
654 else 661 else
655 m->setItemChecked(m->idAt(0),FALSE); 662 m->setItemChecked(m->idAt(0),FALSE);
656 663
657 if(Ir::supported()) 664 if(Ir::supported())
658 m->insertItem( tr( "Beam File" ), this, SLOT( doBeam() )); 665 m->insertItem( tr( "Beam File" ), this, SLOT( doBeam() ));
659 m->setFocus(); 666 m->setFocus();
660 m->exec( QPoint( 4,QCursor::pos().y()) ); 667 m->exec( QPoint( 4,QCursor::pos().y()) );
661 668
662 if(m) delete m; 669 if(m) delete m;
663} 670}
664 671
665 672
@@ -674,7 +681,7 @@ QString AdvancedFm::checkDiskSpace(const QString &path)
674{ 681{
675 struct statfs fss; 682 struct statfs fss;
676 if ( !statfs( path.latin1(), &fss ) ) 683 if ( !statfs( path.latin1(), &fss ) )
677 { 684 {
678 int blkSize = fss.f_bsize; 685 int blkSize = fss.f_bsize;
679// int totalBlks = fs.f_blocks; 686// int totalBlks = fs.f_blocks;
680 int availBlks = fss.f_bavail; 687 int availBlks = fss.f_bavail;
@@ -692,34 +699,34 @@ QString AdvancedFm::checkDiskSpace(const QString &path)
692 699
693void AdvancedFm::addToDocs() 700void AdvancedFm::addToDocs()
694{ 701{
695 QStringList strListPaths = getPath(); 702 QStringList strListPaths = getPath();
696 QDir *thisDir = CurrentDir(); 703 QDir *thisDir = CurrentDir();
697 704
698 if( strListPaths.count() > 0) 705 if( strListPaths.count() > 0)
699 { 706 {
700 QString curFile; 707 QString curFile;
701 for ( QStringList::Iterator it = strListPaths.begin(); it != strListPaths.end(); ++it ) 708 for ( QStringList::Iterator it = strListPaths.begin(); it != strListPaths.end(); ++it )
702 { 709 {
703 curFile = thisDir->canonicalPath()+"/"+(*it); 710 curFile = thisDir->canonicalPath()+"/"+(*it);
704// qDebug(curFile); 711// qDebug(curFile);
705 DocLnk f; 712 DocLnk f;
706// curFile.replace(QRegExp("\\..*"),""); 713// curFile.replace(QRegExp("\\..*"),"");
707 f.setName((*it)); 714 f.setName((*it));
708 f.setFile( curFile); 715 f.setFile( curFile);
709 f.writeLink(); 716 f.writeLink();
710 } 717 }
711 } 718 }
712} 719}
713 720
714 721
715void AdvancedFm::customDirsToMenu() 722void AdvancedFm::customDirsToMenu()
716{ 723{
717 724
718 Config cfg("AdvancedFm"); 725 Config cfg("AdvancedFm");
719 cfg.setGroup("Menu"); 726 cfg.setGroup("Menu");
720 727
721 QStringList list = cfg.readListEntry( "CustomDir", ','); 728 QStringList list = cfg.readListEntry( "CustomDir", ',');
722 menuButton->insertItems(list ); 729 menuButton->insertItems(list );
723 730
724// for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) 731// for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it )
725// { 732// {
@@ -729,54 +736,54 @@ void AdvancedFm::customDirsToMenu()
729 736
730void AdvancedFm::dirMenuSelected(int item) 737void AdvancedFm::dirMenuSelected(int item)
731{ 738{
732 qDebug("menu item %d", item); 739 qDebug("menu item %d", item);
733 switch(item) 740 switch(item)
734 { 741 {
735 742
736 case -21: 743 case -21:
737 case 0: 744 case 0:
738 addCustomDir(); 745 addCustomDir();
739 break; 746 break;
740 case -22: 747 case -22:
741 case 1: 748 case 1:
742 removeCustomDir(); 749 removeCustomDir();
743 break; 750 break;
744 default: 751 default:
745 { 752 {
746// gotoCustomDir( menuButton->text(item)); 753// gotoCustomDir( menuButton->text(item));
747// gotoCustomDir( customDirMenu->text(item)); 754// gotoCustomDir( customDirMenu->text(item));
748 } 755 }
749 break; 756 break;
750 757
751 }; 758 };
752} 759}
753 760
754void AdvancedFm::addCustomDir() 761void AdvancedFm::addCustomDir()
755{ 762{
756 Config cfg("AdvancedFm"); 763 Config cfg("AdvancedFm");
757 cfg.setGroup("Menu"); 764 cfg.setGroup("Menu");
758 QString dir; 765 QString dir;
759 QStringList list = cfg.readListEntry( (const QString &)"CustomDir", (const QChar)','); 766 QStringList list = cfg.readListEntry( (const QString &)"CustomDir", (const QChar)',');
760 767
761 dir = CurrentDir()->canonicalPath(); 768 dir = CurrentDir()->canonicalPath();
762 769
763 bool addIt=true; 770 bool addIt=true;
764 for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) 771 for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it )
765 { 772 {
766 if( dir == (*it)) 773 if( dir == (*it))
767 { 774 {
768 addIt=false; 775 addIt=false;
769 } 776 }
770 } 777 }
771 if(addIt) 778 if(addIt)
772 { 779 {
773 menuButton->insertItem(dir); 780 menuButton->insertItem(dir);
774// customDirMenu->insertItem(dir); 781// customDirMenu->insertItem(dir);
775 list << dir; 782 list << dir;
776 } 783 }
777 784
778 cfg.writeEntry("CustomDir", list, ','); 785 cfg.writeEntry("CustomDir", list, ',');
779 cfg.write(); 786 cfg.write();
780} 787}
781 788
782void AdvancedFm::removeCustomDir() 789void AdvancedFm::removeCustomDir()
@@ -787,35 +794,35 @@ void AdvancedFm::removeCustomDir()
787 QString dir; 794 QString dir;
788 QStringList list = cfg.readListEntry( (const QString &)"CustomDir", (const QChar)','); 795 QStringList list = cfg.readListEntry( (const QString &)"CustomDir", (const QChar)',');
789 QStringList list2; 796 QStringList list2;
790 dir = CurrentDir()->canonicalPath(); 797 dir = CurrentDir()->canonicalPath();
791 int ramble=2; 798 int ramble=2;
792// int ramble=-24; 799// int ramble=-24;
793//first remove list 800//first remove list
794 if(list.grep(dir,true).isEmpty()) 801 if(list.grep(dir,true).isEmpty())
795 { 802 {
796 QMessageBox::message("AdvancedFm", 803 QMessageBox::message("AdvancedFm",
797 tr("Cannot remove current directory\nfrom bookmarks.\nIt is not bookmarked!!")); 804 tr("Cannot remove current directory\nfrom bookmarks.\nIt is not bookmarked!!"));
798 } 805 }
799 else 806 else
800 { 807 {
801 for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) 808 for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it )
802 { 809 {
803 if((*it) != dir)//current item is not our current dir, so add it to temp list 810 if((*it) != dir)//current item is not our current dir, so add it to temp list
804 { 811 {
805 list2 <<(*it); 812 list2 <<(*it);
806 } 813 }
807 else 814 else
808 { 815 {
809// customDirMenu->removeItem( ramble); 816// customDirMenu->removeItem( ramble);
810 menuButton->remove( ramble); 817 menuButton->remove( ramble);
811 818
812 } 819 }
813 ramble++; 820 ramble++;
814// ramble--; 821// ramble--;
815 } 822 }
816 823
817 cfg.writeEntry("CustomDir", list2, ','); 824 cfg.writeEntry("CustomDir", list2, ',');
818 cfg.write(); 825 cfg.write();
819 } 826 }
820// customDirsToMenu(); 827// customDirsToMenu();
821 828
@@ -824,74 +831,74 @@ void AdvancedFm::removeCustomDir()
824void AdvancedFm::gotoCustomDir(const QString &dir) 831void AdvancedFm::gotoCustomDir(const QString &dir)
825{ 832{
826// qDebug("gotoCustomDir(const QString &dir) " +dir ); 833// qDebug("gotoCustomDir(const QString &dir) " +dir );
827 QString curDir = dir; 834 QString curDir = dir;
828 QDir *thisDir = CurrentDir(); 835 QDir *thisDir = CurrentDir();
829// if( curDir.isEmpty()) { 836// if( curDir.isEmpty()) {
830// } 837// }
831 if( curDir == s_addBookmark) 838 if( curDir == s_addBookmark)
832 { 839 {
833 addCustomDir(); 840 addCustomDir();
834 } 841 }
835 if( curDir == s_removeBookmark) 842 if( curDir == s_removeBookmark)
836 { 843 {
837 removeCustomDir( ); 844 removeCustomDir( );
838 } 845 }
839 else 846 else
840 { 847 {
841 if(QDir( curDir).exists() ) 848 if(QDir( curDir).exists() )
842 { 849 {
843 thisDir->setPath( curDir ); 850 thisDir->setPath( curDir );
844 chdir( curDir.latin1() ); 851 chdir( curDir.latin1() );
845 thisDir->cd( curDir, TRUE); 852 thisDir->cd( curDir, TRUE);
846 populateView(); 853 populateView();
847 } 854 }
848 } 855 }
849} 856}
850 857
851QDir *AdvancedFm::CurrentDir() 858QDir *AdvancedFm::CurrentDir()
852{ 859{
853 if ( whichTab == 1) 860 if ( whichTab == 1)
854 { 861 {
855 return &currentDir; 862 return &currentDir;
856 } 863 }
857 else 864 else
858 { 865 {
859 return &currentRemoteDir; 866 return &currentRemoteDir;
860 } 867 }
861} 868}
862 869
863QDir *AdvancedFm::OtherDir() 870QDir *AdvancedFm::OtherDir()
864{ 871{
865 if ( whichTab == 1) 872 if ( whichTab == 1)
866 { 873 {
867 return &currentRemoteDir; 874 return &currentRemoteDir;
868 } 875 }
869 else 876 else
870 { 877 {
871 return &currentDir; 878 return &currentDir;
872 } 879 }
873} 880}
874 881
875QListView * AdvancedFm::CurrentView() 882QListView * AdvancedFm::CurrentView()
876{ 883{
877 if ( whichTab == 1) 884 if ( whichTab == 1)
878 return Local_View; 885 return Local_View;
879 else 886 else
880 return Remote_View; 887 return Remote_View;
881} 888}
882 889
883QListView * AdvancedFm::OtherView() 890QListView * AdvancedFm::OtherView()
884{ 891{
885 if ( whichTab == 1) 892 if ( whichTab == 1)
886 return Remote_View; 893 return Remote_View;
887 else 894 else
888 return Local_View; 895 return Local_View;
889} 896}
890 897
891void AdvancedFm::setOtherTabCurrent() 898void AdvancedFm::setOtherTabCurrent()
892{ 899{
893 if ( whichTab == 1) 900 if ( whichTab == 1)
894 TabWidget->setCurrentTab(1); 901 TabWidget->setCurrentTab(1);
895 else 902 else
896 TabWidget->setCurrentTab(0); 903 TabWidget->setCurrentTab(0);
897} 904}
diff --git a/noncore/apps/advancedfm/advancedfm.h b/noncore/apps/advancedfm/advancedfm.h
index f31956c..c30d8e0 100644
--- a/noncore/apps/advancedfm/advancedfm.h
+++ b/noncore/apps/advancedfm/advancedfm.h
@@ -26,6 +26,7 @@
26#include <qstring.h> 26#include <qstring.h>
27#include <qpoint.h> 27#include <qpoint.h>
28#include <qtimer.h> 28#include <qtimer.h>
29#include <qpixmap.h>
29 30
30class OTabWidget; 31class OTabWidget;
31class QVBoxLayout; 32class QVBoxLayout;
@@ -91,6 +92,7 @@ protected slots:
91protected: 92protected:
92 93
93 OTabWidget *TabWidget; 94 OTabWidget *TabWidget;
95 QPixmap unknownXpm;
94 int whichTab; 96 int whichTab;
95// QTabWidget *TabWidget; 97// QTabWidget *TabWidget;
96 QWidget *tab, *tab_2, *tab_3; 98 QWidget *tab, *tab_2, *tab_3;