-rw-r--r-- | noncore/apps/advancedfm/advancedfm.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/noncore/apps/advancedfm/advancedfm.cpp b/noncore/apps/advancedfm/advancedfm.cpp index fd81313..979549d 100644 --- a/noncore/apps/advancedfm/advancedfm.cpp +++ b/noncore/apps/advancedfm/advancedfm.cpp | |||
@@ -240,194 +240,199 @@ void AdvancedFm::ListClicked(QListViewItem *selectedItem) { | |||
240 | } | 240 | } |
241 | 241 | ||
242 | void AdvancedFm::ListPressed( int mouse, QListViewItem *item, const QPoint& , int ) { | 242 | void AdvancedFm::ListPressed( int mouse, QListViewItem *item, const QPoint& , int ) { |
243 | Q_UNUSED(item); | 243 | Q_UNUSED(item); |
244 | switch (mouse) { | 244 | switch (mouse) { |
245 | case 1: | 245 | case 1: |
246 | { | 246 | { |
247 | if(renameBox != 0 ) { | 247 | if(renameBox != 0 ) { |
248 | cancelRename(); | 248 | cancelRename(); |
249 | } | 249 | } |
250 | } | 250 | } |
251 | break; | 251 | break; |
252 | // case 2: | 252 | // case 2: |
253 | // menuTimer.start( 50, TRUE ); | 253 | // menuTimer.start( 50, TRUE ); |
254 | // break; | 254 | // break; |
255 | }; | 255 | }; |
256 | } | 256 | } |
257 | 257 | ||
258 | 258 | ||
259 | void AdvancedFm::refreshCurrentTab() { | 259 | void AdvancedFm::refreshCurrentTab() { |
260 | populateView(); | 260 | populateView(); |
261 | // if ( TabWidget->currentWidget() == tab) { | 261 | // if ( TabWidget->currentWidget() == tab) { |
262 | } | 262 | } |
263 | 263 | ||
264 | void AdvancedFm::switchToLocalTab() { | 264 | void AdvancedFm::switchToLocalTab() { |
265 | TabWidget->setCurrentWidget(tab); | 265 | TabWidget->setCurrentWidget(tab); |
266 | Local_View->setFocus(); | 266 | Local_View->setFocus(); |
267 | // whichTab = 1; | 267 | // whichTab = 1; |
268 | } | 268 | } |
269 | 269 | ||
270 | void AdvancedFm::switchToRemoteTab() { | 270 | void AdvancedFm::switchToRemoteTab() { |
271 | TabWidget->setCurrentWidget(tab_2); | 271 | TabWidget->setCurrentWidget(tab_2); |
272 | Remote_View->setFocus(); | 272 | Remote_View->setFocus(); |
273 | // whichTab = 2; | 273 | // whichTab = 2; |
274 | } | 274 | } |
275 | 275 | ||
276 | void AdvancedFm::currentPathComboChanged() { | 276 | void AdvancedFm::currentPathComboChanged() { |
277 | QString pDir = currentPathCombo->lineEdit()->text(); | 277 | QString pDir = currentPathCombo->lineEdit()->text(); |
278 | if(QDir(pDir).exists()) { | 278 | if(QDir(pDir).exists()) { |
279 | CurrentDir()->setPath(pDir ); | 279 | CurrentDir()->setPath(pDir ); |
280 | populateView(); | 280 | populateView(); |
281 | } else { | 281 | } else { |
282 | QMessageBox::message(tr("Note"),tr("<p>%1 does not exist</p>").arg(pDir)); | 282 | QMessageBox::message(tr("Note"),tr("<p>%1 does not exist</p>").arg(pDir)); |
283 | } | 283 | } |
284 | } | 284 | } |
285 | 285 | ||
286 | void AdvancedFm::fillCombo(const QString ¤tPath) { | 286 | void AdvancedFm::fillCombo(const QString ¤tPath) { |
287 | 287 | ||
288 | if ( TabWidget->currentWidget() == tab) { | 288 | if ( TabWidget->currentWidget() == tab) { |
289 | // if ( whichTab == 1) { | 289 | // if ( whichTab == 1) { |
290 | currentPathCombo->lineEdit()->setText( currentPath); | 290 | currentPathCombo->lineEdit()->setText( currentPath); |
291 | if( localDirPathStringList.grep( currentPath,TRUE).isEmpty() ) { | 291 | if( localDirPathStringList.grep( currentPath,TRUE).isEmpty() ) { |
292 | currentPathCombo->clear(); | 292 | currentPathCombo->clear(); |
293 | localDirPathStringList.prepend( currentPath ); | 293 | localDirPathStringList.prepend( currentPath ); |
294 | currentPathCombo->insertStringList( localDirPathStringList,-1); | 294 | currentPathCombo->insertStringList( localDirPathStringList,-1); |
295 | } | 295 | } |
296 | } else { | 296 | } else { |
297 | currentPathCombo->lineEdit()->setText( currentPath); | 297 | currentPathCombo->lineEdit()->setText( currentPath); |
298 | if( remoteDirPathStringList.grep( currentPath,TRUE).isEmpty() ) { | 298 | if( remoteDirPathStringList.grep( currentPath,TRUE).isEmpty() ) { |
299 | currentPathCombo->clear(); | 299 | currentPathCombo->clear(); |
300 | remoteDirPathStringList.prepend( currentPath ); | 300 | remoteDirPathStringList.prepend( currentPath ); |
301 | currentPathCombo->insertStringList( remoteDirPathStringList,-1); | 301 | currentPathCombo->insertStringList( remoteDirPathStringList,-1); |
302 | } | 302 | } |
303 | } | 303 | } |
304 | } | 304 | } |
305 | 305 | ||
306 | QStringList AdvancedFm::getPath() { | 306 | QStringList AdvancedFm::getPath() { |
307 | QStringList strList; | 307 | QStringList strList; |
308 | QListView *thisView=CurrentView(); | 308 | QListView *thisView=CurrentView(); |
309 | QList<QListViewItem> * getSelectedItems( QListView * thisView ); | 309 | QList<QListViewItem> * getSelectedItems( QListView * thisView ); |
310 | QListViewItemIterator it( thisView ); | 310 | QListViewItemIterator it( thisView ); |
311 | for ( ; it.current(); ++it ) { | 311 | for ( ; it.current(); ++it ) { |
312 | if ( it.current()->isSelected() ) { | 312 | if ( it.current()->isSelected() ) { |
313 | strList << it.current()->text(0); | 313 | strList << it.current()->text(0); |
314 | // odebug << it.current()->text(0) << oendl; | 314 | // odebug << it.current()->text(0) << oendl; |
315 | } | 315 | } |
316 | } | 316 | } |
317 | return strList; | 317 | return strList; |
318 | } | 318 | } |
319 | 319 | ||
320 | void AdvancedFm::changeTo(const QString &dir) { | 320 | void AdvancedFm::changeTo(const QString &dir) { |
321 | chdir( dir.latin1()); | 321 | chdir( dir.latin1()); |
322 | CurrentDir()->cd(dir, TRUE); | 322 | CurrentDir()->cd(dir, TRUE); |
323 | populateView(); | 323 | populateView(); |
324 | update(); | 324 | update(); |
325 | } | 325 | } |
326 | 326 | ||
327 | void AdvancedFm::homeButtonPushed() { | 327 | void AdvancedFm::homeButtonPushed() { |
328 | changeTo(QDir::homeDirPath()); | 328 | changeTo(QDir::homeDirPath()); |
329 | } | 329 | } |
330 | 330 | ||
331 | void AdvancedFm::docButtonPushed() { | 331 | void AdvancedFm::docButtonPushed() { |
332 | changeTo(QPEApplication::documentDir()); | 332 | changeTo(QPEApplication::documentDir()); |
333 | } | 333 | } |
334 | 334 | ||
335 | void AdvancedFm::SDButtonPushed() { | 335 | void AdvancedFm::SDButtonPushed() { |
336 | Opie::Core::OStorageInfo info; | 336 | Opie::Core::OStorageInfo info; |
337 | changeTo(info.sdPath()); | 337 | if(StorageInfo::hasSd() ) { |
338 | changeTo(info.sdPath()); | ||
339 | } | ||
340 | else if(StorageInfo::hasMmc()) { | ||
341 | changeTo(info.mmcPath()); | ||
342 | } | ||
338 | } | 343 | } |
339 | 344 | ||
340 | void AdvancedFm::CFButtonPushed() { | 345 | void AdvancedFm::CFButtonPushed() { |
341 | Opie::Core::OStorageInfo info; | 346 | Opie::Core::OStorageInfo info; |
342 | changeTo(info.cfPath()); | 347 | changeTo(info.cfPath()); |
343 | } | 348 | } |
344 | 349 | ||
345 | void AdvancedFm::QPEButtonPushed() { | 350 | void AdvancedFm::QPEButtonPushed() { |
346 | changeTo(QPEApplication::qpeDir()); | 351 | changeTo(QPEApplication::qpeDir()); |
347 | } | 352 | } |
348 | 353 | ||
349 | void AdvancedFm::doAbout() { | 354 | void AdvancedFm::doAbout() { |
350 | QMessageBox::message("AdvancedFm",tr("<P>Advanced FileManager is copyright 2002-2003 by L.J.Potter<llornkcor@handhelds.org> and is licensed by the GPL</P>")); | 355 | QMessageBox::message("AdvancedFm",tr("<P>Advanced FileManager is copyright 2002-2003 by L.J.Potter<llornkcor@handhelds.org> and is licensed by the GPL</P>")); |
351 | } | 356 | } |
352 | 357 | ||
353 | void AdvancedFm::keyPressEvent( QKeyEvent *e) { | 358 | void AdvancedFm::keyPressEvent( QKeyEvent *e) { |
354 | Q_UNUSED(e); | 359 | Q_UNUSED(e); |
355 | } | 360 | } |
356 | 361 | ||
357 | void AdvancedFm::keyReleaseEvent( QKeyEvent *e) { | 362 | void AdvancedFm::keyReleaseEvent( QKeyEvent *e) { |
358 | // if( CurrentView()->hasFocus() ) | 363 | // if( CurrentView()->hasFocus() ) |
359 | // e->ignore(); | 364 | // e->ignore(); |
360 | 365 | ||
361 | if( currentPathCombo->lineEdit()->hasFocus()) { | 366 | if( currentPathCombo->lineEdit()->hasFocus()) { |
362 | // qDebug("shout!"); | 367 | // qDebug("shout!"); |
363 | } | 368 | } |
364 | 369 | ||
365 | else if( e->key() == Key_Left ) | 370 | else if( e->key() == Key_Left ) |
366 | upDir(); | 371 | upDir(); |
367 | else if( e->key() == Key_Return || e->key() == Key_Enter) | 372 | else if( e->key() == Key_Return || e->key() == Key_Enter) |
368 | navigateToSelected(); | 373 | navigateToSelected(); |
369 | else if( e->key() == Key_Tab) | 374 | else if( e->key() == Key_Tab) |
370 | setOtherTabCurrent(); | 375 | setOtherTabCurrent(); |
371 | else if( e->key() == Key_Delete ) | 376 | else if( e->key() == Key_Delete ) |
372 | del(); | 377 | del(); |
373 | else | 378 | else |
374 | e->accept(); | 379 | e->accept(); |
375 | 380 | ||
376 | } | 381 | } |
377 | 382 | ||
378 | 383 | ||
379 | void AdvancedFm::parsetab(const QString &fileName) { | 384 | void AdvancedFm::parsetab(const QString &fileName) { |
380 | 385 | ||
381 | fileSystemTypeList.clear(); | 386 | fileSystemTypeList.clear(); |
382 | fsList.clear(); | 387 | fsList.clear(); |
383 | struct mntent *me; | 388 | struct mntent *me; |
384 | FILE *mntfp = setmntent( fileName.latin1(), "r" ); | 389 | FILE *mntfp = setmntent( fileName.latin1(), "r" ); |
385 | if ( mntfp ) { | 390 | if ( mntfp ) { |
386 | while ( (me = getmntent( mntfp )) != 0 ) { | 391 | while ( (me = getmntent( mntfp )) != 0 ) { |
387 | QString deviceName = me->mnt_fsname; | 392 | QString deviceName = me->mnt_fsname; |
388 | QString filesystemType = me->mnt_type; | 393 | QString filesystemType = me->mnt_type; |
389 | QString mountDir = me->mnt_dir; | 394 | QString mountDir = me->mnt_dir; |
390 | if(deviceName != "none") { | 395 | if(deviceName != "none") { |
391 | if( fsList.contains(filesystemType) == 0 | 396 | if( fsList.contains(filesystemType) == 0 |
392 | & filesystemType.find("proc",0,TRUE) == -1 | 397 | & filesystemType.find("proc",0,TRUE) == -1 |
393 | & filesystemType.find("cramfs",0,TRUE) == -1 | 398 | & filesystemType.find("cramfs",0,TRUE) == -1 |
394 | & filesystemType.find("auto",0,TRUE) == -1) | 399 | & filesystemType.find("auto",0,TRUE) == -1) |
395 | fsList << filesystemType; | 400 | fsList << filesystemType; |
396 | fileSystemTypeList << mountDir+"::"+filesystemType; | 401 | fileSystemTypeList << mountDir+"::"+filesystemType; |
397 | } | 402 | } |
398 | } | 403 | } |
399 | } | 404 | } |
400 | endmntent( mntfp ); | 405 | endmntent( mntfp ); |
401 | } | 406 | } |
402 | 407 | ||
403 | QString AdvancedFm::getFileSystemType(const QString ¤tText) { | 408 | QString AdvancedFm::getFileSystemType(const QString ¤tText) { |
404 | parsetab("/etc/mtab"); //why did TT forget filesystem type? | 409 | parsetab("/etc/mtab"); //why did TT forget filesystem type? |
405 | QString current = currentText;//.right( currentText.length()-1); | 410 | QString current = currentText;//.right( currentText.length()-1); |
406 | QString baseFs; | 411 | QString baseFs; |
407 | for ( QStringList::Iterator it = fileSystemTypeList.begin(); it != fileSystemTypeList.end(); ++it ) { | 412 | for ( QStringList::Iterator it = fileSystemTypeList.begin(); it != fileSystemTypeList.end(); ++it ) { |
408 | QString temp = (*it); | 413 | QString temp = (*it); |
409 | QString path = temp.left(temp.find("::",0,TRUE) ); | 414 | QString path = temp.left(temp.find("::",0,TRUE) ); |
410 | path = path.right( path.length()-1); | 415 | path = path.right( path.length()-1); |
411 | if(path.isEmpty()) baseFs = temp.right( temp.length() - temp.find("::",0,TRUE) - 2); | 416 | if(path.isEmpty()) baseFs = temp.right( temp.length() - temp.find("::",0,TRUE) - 2); |
412 | if( current.find( path,0,TRUE) != -1 && !path.isEmpty()) { | 417 | if( current.find( path,0,TRUE) != -1 && !path.isEmpty()) { |
413 | return temp.right( temp.length() - temp.find("::",0,TRUE) - 2); | 418 | return temp.right( temp.length() - temp.find("::",0,TRUE) - 2); |
414 | } | 419 | } |
415 | } | 420 | } |
416 | return baseFs; | 421 | return baseFs; |
417 | } | 422 | } |
418 | 423 | ||
419 | QString AdvancedFm::getDiskSpace( const QString &path) { | 424 | QString AdvancedFm::getDiskSpace( const QString &path) { |
420 | struct statfs fss; | 425 | struct statfs fss; |
421 | if ( !statfs( path.latin1(), &fss ) ) { | 426 | if ( !statfs( path.latin1(), &fss ) ) { |
422 | int blkSize = fss.f_bsize; | 427 | int blkSize = fss.f_bsize; |
423 | // int totalBlks = fs.f_blocks; | 428 | // int totalBlks = fs.f_blocks; |
424 | int availBlks = fss.f_bavail; | 429 | int availBlks = fss.f_bavail; |
425 | 430 | ||
426 | long mult = blkSize / 1024; | 431 | long mult = blkSize / 1024; |
427 | long div = 1024 / blkSize; | 432 | long div = 1024 / blkSize; |
428 | if ( !mult ) mult = 1; | 433 | if ( !mult ) mult = 1; |
429 | if ( !div ) div = 1; | 434 | if ( !div ) div = 1; |
430 | 435 | ||
431 | return QString::number(availBlks * mult / div); | 436 | return QString::number(availBlks * mult / div); |
432 | } | 437 | } |
433 | return ""; | 438 | return ""; |