Diffstat (limited to 'noncore/graphics/opie-eye/gui/iconview.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/graphics/opie-eye/gui/iconview.cpp | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/noncore/graphics/opie-eye/gui/iconview.cpp b/noncore/graphics/opie-eye/gui/iconview.cpp index 660c4fa..087db30 100644 --- a/noncore/graphics/opie-eye/gui/iconview.cpp +++ b/noncore/graphics/opie-eye/gui/iconview.cpp | |||
@@ -336,44 +336,50 @@ void PIconView::slotTrash() { | |||
336 | 336 | ||
337 | currentView()->dirLister()->deleteImage( pa ); | 337 | currentView()->dirLister()->deleteImage( pa ); |
338 | delete m_view->currentItem(); | 338 | delete m_view->currentItem(); |
339 | } | 339 | } |
340 | 340 | ||
341 | /* | 341 | /* |
342 | * see what views are available | 342 | * see what views are available |
343 | */ | 343 | */ |
344 | void PIconView::loadViews() { | 344 | void PIconView::loadViews() { |
345 | ViewMap::Iterator it; | 345 | ViewMap::Iterator it; |
346 | ViewMap* map = viewMap(); | 346 | ViewMap* map = viewMap(); |
347 | for ( it = map->begin(); it != map->end(); ++it ) | 347 | for ( it = map->begin(); it != map->end(); ++it ) |
348 | m_views->insertItem( QObject::tr(it.key() ) ); | 348 | m_views->insertItem( it.key() ); |
349 | } | 349 | } |
350 | 350 | ||
351 | void PIconView::resetView() { | 351 | void PIconView::resetView() { |
352 | slotViewChanged(m_views->currentItem()); | 352 | slotViewChanged(m_views->currentItem()); |
353 | } | 353 | } |
354 | 354 | ||
355 | /* | 355 | /* |
356 | *swicth view reloadDir and connect signals | 356 | *swicth view reloadDir and connect signals |
357 | */ | 357 | */ |
358 | void PIconView::slotViewChanged( int i) { | 358 | void PIconView::slotViewChanged( int i) { |
359 | if (!m_views->count() ) { | 359 | if (!m_views->count() ) { |
360 | setCurrentView( 0l); | 360 | setCurrentView( 0l); |
361 | return; | 361 | return; |
362 | } | 362 | } |
363 | 363 | ||
364 | PDirView* cur = currentView(); | 364 | PDirView* cur = currentView(); |
365 | delete cur; | 365 | if (cur) delete cur; |
366 | QString str = m_views->text(i); | 366 | QString str = m_views->text(i); |
367 | cur = (*(*viewMap())[str])(*m_cfg); | 367 | ViewMap* map = viewMap(); |
368 | if (!map) {setCurrentView(0l); return;} | ||
369 | if (map->find(str) == map->end()) { | ||
370 | owarn << "Key not found" << oendl; | ||
371 | setCurrentView(0l); return; | ||
372 | } | ||
373 | cur = (*(*map)[str])(*m_cfg); | ||
368 | setCurrentView( cur ); | 374 | setCurrentView( cur ); |
369 | 375 | ||
370 | /* connect to the signals of the lister */ | 376 | /* connect to the signals of the lister */ |
371 | PDirLister* lis = cur->dirLister(); | 377 | PDirLister* lis = cur->dirLister(); |
372 | connect(lis, SIGNAL(sig_thumbInfo(const QString&, const QString& )), | 378 | connect(lis, SIGNAL(sig_thumbInfo(const QString&, const QString& )), |
373 | this, SLOT( slotThumbInfo(const QString&, const QString&))); | 379 | this, SLOT( slotThumbInfo(const QString&, const QString&))); |
374 | connect(lis, SIGNAL( sig_thumbNail(const QString&, const QPixmap&)), | 380 | connect(lis, SIGNAL( sig_thumbNail(const QString&, const QPixmap&)), |
375 | this, SLOT(slotThumbNail(const QString&, const QPixmap&))); | 381 | this, SLOT(slotThumbNail(const QString&, const QPixmap&))); |
376 | connect(lis, SIGNAL(sig_start()), | 382 | connect(lis, SIGNAL(sig_start()), |
377 | this, SLOT(slotStart())); | 383 | this, SLOT(slotStart())); |
378 | connect(lis, SIGNAL(sig_end()) , | 384 | connect(lis, SIGNAL(sig_end()) , |
379 | this, SLOT(slotEnd()) ); | 385 | this, SLOT(slotEnd()) ); |
@@ -397,27 +403,31 @@ void PIconView::addFolders( const QStringList& lst) { | |||
397 | IconViewItem * _iv; | 403 | IconViewItem * _iv; |
398 | 404 | ||
399 | for(it=lst.begin(); it != lst.end(); ++it ) { | 405 | for(it=lst.begin(); it != lst.end(); ++it ) { |
400 | _iv = new IconViewItem( m_view, m_path+"/"+(*it), (*it), true ); | 406 | _iv = new IconViewItem( m_view, m_path+"/"+(*it), (*it), true ); |
401 | if (m_mode==3) _iv->setTextOnly(true); | 407 | if (m_mode==3) _iv->setTextOnly(true); |
402 | } | 408 | } |
403 | } | 409 | } |
404 | 410 | ||
405 | void PIconView::addFiles( const QStringList& lst) { | 411 | void PIconView::addFiles( const QStringList& lst) { |
406 | QStringList::ConstIterator it; | 412 | QStringList::ConstIterator it; |
407 | IconViewItem * _iv; | 413 | IconViewItem * _iv; |
408 | QPixmap*m_pix = 0; | 414 | QPixmap*m_pix = 0; |
415 | QString pre = ""; | ||
416 | if (!m_path.isEmpty()) { | ||
417 | pre = m_path+"/"; | ||
418 | } | ||
409 | for (it=lst.begin(); it!= lst.end(); ++it ) { | 419 | for (it=lst.begin(); it!= lst.end(); ++it ) { |
410 | m_pix = PPixmapCache::self()->cachedImage( m_path+"/"+(*it), 64, 64 ); | 420 | m_pix = PPixmapCache::self()->cachedImage( pre+(*it), 64, 64 ); |
411 | _iv = new IconViewItem( m_view, m_path+"/"+(*it), (*it) ); | 421 | _iv = new IconViewItem( m_view, pre+(*it), (*it) ); |
412 | if (m_mode==3) { | 422 | if (m_mode==3) { |
413 | _iv->setTextOnly(true); | 423 | _iv->setTextOnly(true); |
414 | _iv->setPixmap(QPixmap()); | 424 | _iv->setPixmap(QPixmap()); |
415 | } else { | 425 | } else { |
416 | if (m_pix) _iv->setPixmap(*m_pix); | 426 | if (m_pix) _iv->setPixmap(*m_pix); |
417 | } | 427 | } |
418 | } | 428 | } |
419 | 429 | ||
420 | } | 430 | } |
421 | 431 | ||
422 | /* | 432 | /* |
423 | * user clicked on the item. Change dir or view | 433 | * user clicked on the item. Change dir or view |
@@ -534,62 +544,63 @@ void PIconView::slotShowPrev() | |||
534 | if (name.isEmpty()) return; | 544 | if (name.isEmpty()) return; |
535 | if (isDir) return; | 545 | if (isDir) return; |
536 | /* if we got a name we have a prev item */ | 546 | /* if we got a name we have a prev item */ |
537 | m_view->setCurrentItem(m_view->currentItem()->prevItem()); | 547 | m_view->setCurrentItem(m_view->currentItem()->prevItem()); |
538 | slotShowImage(name); | 548 | slotShowImage(name); |
539 | } | 549 | } |
540 | 550 | ||
541 | void PIconView::slotShowImage() | 551 | void PIconView::slotShowImage() |
542 | { | 552 | { |
543 | bool isDir = false; | 553 | bool isDir = false; |
544 | QString name = currentFileName(isDir); | 554 | QString name = currentFileName(isDir); |
545 | if (isDir) return; | 555 | if (isDir) return; |
546 | |||
547 | slotShowImage( name ); | 556 | slotShowImage( name ); |
548 | } | 557 | } |
549 | void PIconView::slotShowImage( const QString& name) { | 558 | void PIconView::slotShowImage( const QString& name) { |
550 | emit sig_display( name ); | 559 | PDirLister *lister = currentView()->dirLister(); |
560 | QString r_name = lister->nameToFname(name); | ||
561 | emit sig_display( r_name ); | ||
551 | } | 562 | } |
552 | void PIconView::slotImageInfo() { | 563 | void PIconView::slotImageInfo() { |
553 | bool isDir = false; | 564 | bool isDir = false; |
554 | QString name = currentFileName(isDir); | 565 | QString name = currentFileName(isDir); |
555 | if (isDir) return; | 566 | if (isDir) return; |
556 | 567 | ||
557 | slotImageInfo( name ); | 568 | slotImageInfo( name ); |
558 | } | 569 | } |
559 | 570 | ||
560 | void PIconView::slotImageInfo( const QString& name) { | 571 | void PIconView::slotImageInfo( const QString& name) { |
561 | emit sig_showInfo( name ); | 572 | PDirLister *lister = currentView()->dirLister(); |
573 | QString r_name = lister->nameToFname(name); | ||
574 | emit sig_showInfo(r_name ); | ||
562 | } | 575 | } |
563 | 576 | ||
564 | 577 | ||
565 | void PIconView::slotChangeMode( int mode ) { | 578 | void PIconView::slotChangeMode( int mode ) { |
566 | if ( mode >= 1 && mode <= 3 ) | 579 | if ( mode >= 1 && mode <= 3 ) |
567 | m_mode = mode; | 580 | m_mode = mode; |
568 | 581 | ||
569 | m_cfg->writeEntry("ListViewMode", m_mode); | 582 | m_cfg->writeEntry("ListViewMode", m_mode); |
570 | calculateGrid(); | 583 | calculateGrid(); |
571 | slotReloadDir(); | 584 | slotReloadDir(); |
572 | } | 585 | } |
573 | 586 | ||
574 | 587 | ||
575 | void PIconView::resizeEvent( QResizeEvent* re ) { | 588 | void PIconView::resizeEvent( QResizeEvent* re ) { |
576 | QVBox::resizeEvent( re ); | 589 | QVBox::resizeEvent( re ); |
577 | calculateGrid(); | 590 | calculateGrid(); |
578 | } | 591 | } |
579 | 592 | ||
580 | 593 | ||
581 | void PIconView::calculateGrid() { | 594 | void PIconView::calculateGrid() { |
582 | odebug << "Calc grid: x=" << m_view->gridX() << " y=" << m_view->gridY() << oendl; | ||
583 | odebug << "Size of view: " << m_view->size() << oendl; | ||
584 | int dw = QApplication::desktop()->width(); | 595 | int dw = QApplication::desktop()->width(); |
585 | int viewerWidth = dw-style().scrollBarExtent().width(); | 596 | int viewerWidth = dw-style().scrollBarExtent().width(); |
586 | 597 | ||
587 | QIconView::ItemTextPos pos; | 598 | QIconView::ItemTextPos pos; |
588 | switch( m_mode ) { | 599 | switch( m_mode ) { |
589 | case 2: | 600 | case 2: |
590 | pos = QIconView::Bottom; | 601 | pos = QIconView::Bottom; |
591 | break; | 602 | break; |
592 | case 3: | 603 | case 3: |
593 | case 1: | 604 | case 1: |
594 | default: | 605 | default: |
595 | pos = QIconView::Right; | 606 | pos = QIconView::Right; |