author | alwin <alwin> | 2004-04-21 18:31:44 (UTC) |
---|---|---|
committer | alwin <alwin> | 2004-04-21 18:31:44 (UTC) |
commit | 81cd1a4a916fb00b6c8867bdc1d945db155b12c0 (patch) (unidiff) | |
tree | ce302c254c8c2160a86ffc0a5abe6cfd51fd33b3 /noncore/graphics/opie-eye/gui/iconview.cpp | |
parent | ac414fa3802b471857bc84ecdd0d37200541b0a7 (diff) | |
download | opie-81cd1a4a916fb00b6c8867bdc1d945db155b12c0.zip opie-81cd1a4a916fb00b6c8867bdc1d945db155b12c0.tar.gz opie-81cd1a4a916fb00b6c8867bdc1d945db155b12c0.tar.bz2 |
- added DocView mode
- fixed a bug in iconview and some small fixes more
Diffstat (limited to 'noncore/graphics/opie-eye/gui/iconview.cpp') (more/less context) (ignore 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 | |||
@@ -324,112 +324,122 @@ QString PIconView::prevFileName(bool &isDir)const{ | |||
324 | 324 | ||
325 | void PIconView::slotTrash() { | 325 | void PIconView::slotTrash() { |
326 | bool isDir; | 326 | bool isDir; |
327 | QString pa = currentFileName( isDir ); | 327 | QString pa = currentFileName( isDir ); |
328 | if ( isDir && pa.isEmpty() ) | 328 | if ( isDir && pa.isEmpty() ) |
329 | return; | 329 | return; |
330 | 330 | ||
331 | if (!QPEMessageBox::confirmDelete( this, | 331 | if (!QPEMessageBox::confirmDelete( this, |
332 | tr("Delete Image" ), | 332 | tr("Delete Image" ), |
333 | tr("the Image %1" ).arg(pa))) | 333 | tr("the Image %1" ).arg(pa))) |
334 | return | 334 | return |
335 | 335 | ||
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()) ); |
380 | 386 | ||
381 | 387 | ||
382 | /* reload now */ | 388 | /* reload now */ |
383 | QTimer::singleShot( 0, this, SLOT(slotReloadDir())); | 389 | QTimer::singleShot( 0, this, SLOT(slotReloadDir())); |
384 | } | 390 | } |
385 | 391 | ||
386 | 392 | ||
387 | void PIconView::slotReloadDir() { | 393 | void PIconView::slotReloadDir() { |
388 | slotChangeDir( m_path ); | 394 | slotChangeDir( m_path ); |
389 | } | 395 | } |
390 | 396 | ||
391 | 397 | ||
392 | /* | 398 | /* |
393 | * add files and folders | 399 | * add files and folders |
394 | */ | 400 | */ |
395 | void PIconView::addFolders( const QStringList& lst) { | 401 | void PIconView::addFolders( const QStringList& lst) { |
396 | QStringList::ConstIterator it; | 402 | QStringList::ConstIterator it; |
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 |
424 | */ | 434 | */ |
425 | void PIconView::slotClicked(QIconViewItem* _it) { | 435 | void PIconView::slotClicked(QIconViewItem* _it) { |
426 | if(!_it ) | 436 | if(!_it ) |
427 | return; | 437 | return; |
428 | 438 | ||
429 | IconViewItem* it = static_cast<IconViewItem*>(_it); | 439 | IconViewItem* it = static_cast<IconViewItem*>(_it); |
430 | if( it->isDir() ) | 440 | if( it->isDir() ) |
431 | slotChangeDir( it->path() ); | 441 | slotChangeDir( it->path() ); |
432 | else // view image | 442 | else // view image |
433 | slotShowImage(); | 443 | slotShowImage(); |
434 | } | 444 | } |
435 | 445 | ||
@@ -522,86 +532,87 @@ void PIconView::slotShowNext() | |||
522 | QString name = nextFileName(isDir); | 532 | QString name = nextFileName(isDir); |
523 | if (name.isEmpty()) return; | 533 | if (name.isEmpty()) return; |
524 | if (isDir) return; | 534 | if (isDir) return; |
525 | /* if we got a name we have a next item */ | 535 | /* if we got a name we have a next item */ |
526 | m_view->setCurrentItem(m_view->currentItem()->nextItem()); | 536 | m_view->setCurrentItem(m_view->currentItem()->nextItem()); |
527 | slotShowImage(name); | 537 | slotShowImage(name); |
528 | } | 538 | } |
529 | 539 | ||
530 | void PIconView::slotShowPrev() | 540 | void PIconView::slotShowPrev() |
531 | { | 541 | { |
532 | bool isDir = false; | 542 | bool isDir = false; |
533 | QString name = prevFileName(isDir); | 543 | QString name = prevFileName(isDir); |
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; |
596 | break; | 607 | break; |
597 | } | 608 | } |
598 | m_view->setItemTextPos( pos ); | 609 | m_view->setItemTextPos( pos ); |
599 | switch (m_mode) { | 610 | switch (m_mode) { |
600 | case 2: | 611 | case 2: |
601 | m_view->setGridX(50); | 612 | m_view->setGridX(50); |
602 | m_view->setGridY(20); | 613 | m_view->setGridY(20); |
603 | PPixmapCache::self()->setMaxImages(40); | 614 | PPixmapCache::self()->setMaxImages(40); |
604 | break; | 615 | break; |
605 | case 3: | 616 | case 3: |
606 | m_view->setGridX( fontMetrics().width("testimage.jpg")+20); | 617 | m_view->setGridX( fontMetrics().width("testimage.jpg")+20); |
607 | m_view->setGridY(8); | 618 | m_view->setGridY(8); |