Ticket #1921: 1921-v1.patch
File 1921-v1.patch, 7.9 KB (added by , 18 years ago) |
---|
-
mythgallery/mythgallery/iconview.cpp
132 132 SLOT(mediaStatusChanged(MediaStatus, MythMediaDevice*))); 133 133 134 134 loadDirectory(m_currDevice->getMountPath()); 135 m_galleryDir = m_currDevice->getMountPath();136 135 137 136 mon->Unlock(m_currDevice); 138 137 } … … 315 314 &pix, 0, 0, -1, -1, Qt::CopyROP); 316 315 } 317 316 317 static bool has_action(QString action, const QStringList &actions) 318 { 319 QStringList::const_iterator it; 320 for (it = actions.begin(); it != actions.end(); ++it) 321 { 322 if (action == *it) 323 return true; 324 } 325 return false; 326 } 327 318 328 void IconView::keyPressEvent(QKeyEvent *e) 319 329 { 320 330 if (!e) return; … … 564 574 if (!handled && !menuHandled) 565 575 { 566 576 gContext->GetMainWindow()->TranslateKeyPress("Global", e, actions); 567 for (unsigned int i = 0; i < actions.size() && !handled; i++) 577 if (has_action("ESCAPE", actions)) 578 handled = HandleEscape(); 579 } 580 581 if (handled || menuHandled) 582 update(); 583 else 584 MythDialog::keyPressEvent(e); 585 } 586 587 bool IconView::HandleEscape(void) 588 { 589 //VERBOSE(VB_IMPORTANT, "ESCAPE: showDevices("<<m_showDevices<<")"); 590 591 if (m_showDevices) 592 return false; 593 594 MediaMonitor *mon = MediaMonitor::GetMediaMonitor(); 595 if (!mon) 596 return false; 597 598 bool handled = false; 599 QDir curdir(m_currDir); 600 QValueList<MythMediaDevice*> removables = mon->GetMedias(MEDIATYPE_DATA); 601 QValueList<MythMediaDevice*>::iterator it = removables.begin(); 602 for (; !handled && (it != removables.end()); it++) 603 { 604 if (!mon->ValidateAndLock(*it)) 605 continue; 606 607 if (curdir == QDir((*it)->getMountPath())) 568 608 { 569 QString action = actions[i]; 570 if (action == "ESCAPE") 609 actionShowDevices(); 610 611 // Make sure previous devices are visible and selected 612 ThumbItem *item = NULL; 613 if (!(*it)->getVolumeID().isEmpty()) 614 item = m_itemDict.find((*it)->getVolumeID()); 615 else 616 item = m_itemDict.find((*it)->getDevicePath()); 617 618 if (item) 571 619 { 572 if (m_showDevices) 620 int pos = m_itemList.find(item); 621 if (pos != -1) 573 622 { 574 loadDirectory(m_galleryDir); 575 handled = true; 623 m_currRow = pos / m_nCols; 624 m_currCol = pos - (m_currRow * m_nCols); 625 m_topRow = max(0, m_currRow + 1 - m_nRows); 576 626 } 577 else 578 { 579 QDir d(m_currDir); 627 } 580 628 581 #ifndef _WIN32 582 MediaMonitor *mon = MediaMonitor::GetMediaMonitor(); 583 if (mon) 584 { 585 QValueList<MythMediaDevice*> removables = 586 mon->GetMedias(MEDIATYPE_DATA); 587 588 QValueList<MythMediaDevice*>::Iterator it = 589 removables.begin(); 590 for (; it != removables.end(); it++) 591 { 592 if (mon->ValidateAndLock(*it)) 593 { 594 if (d == QDir((*it)->getMountPath())) 595 { 596 actionShowDevices(); 629 handled = true; 630 } 597 631 598 // make sure previous devies is 599 // visible and selected 600 ThumbItem *item; 601 if ((*it)->getVolumeID() != "") 602 item = m_itemDict.find( 603 (*it)->getVolumeID()); 604 else 605 item = m_itemDict.find( 606 (*it)->getDevicePath()); 632 mon->Unlock(*it); 633 } 607 634 608 if (item) 609 { 610 int pos = m_itemList.find(item); 611 if (pos != -1) 612 { 613 m_currRow = pos / m_nCols; 614 m_currCol = 615 pos - m_currRow*m_nCols; 616 m_topRow = 617 QMAX(0, (m_currRow - 618 (m_nRows - 1))); 619 } 620 } 621 handled = true; 622 mon->Unlock(*it); 623 break; 624 } 625 mon->Unlock(*it); 626 } 627 } 628 } 635 if (!handled && (curdir != QDir(m_galleryDir))) 636 { 637 QString oldDirName = curdir.dirName(); 638 curdir.cdUp(); 639 loadDirectory(curdir.absPath()); 629 640 630 if (!handled) 631 { 632 #endif 633 if (d != QDir(m_galleryDir)) 634 { 635 QString oldDirName = d.dirName(); 636 d.cdUp(); 637 loadDirectory(d.absPath()); 638 639 // make sure up-directory is visible and selected 640 ThumbItem* item = m_itemDict.find(oldDirName); 641 if (item) 642 { 643 int pos = m_itemList.find(item); 644 if (pos != -1) { 645 m_currRow = pos/m_nCols; 646 m_currCol = pos-m_currRow*m_nCols; 647 m_topRow = QMAX(0, m_currRow-(m_nRows-1)); 648 } 649 } 650 handled = true; 651 } 652 #ifndef _WIN32 653 } 654 } 655 #endif 641 // Make sure up-directory is visible and selected 642 ThumbItem *item = m_itemDict.find(oldDirName); 643 if (item) 644 { 645 int pos = m_itemList.find(item); 646 if (pos != -1) 647 { 648 m_currRow = pos / m_nCols; 649 m_currCol = pos - (m_currRow * m_nCols); 650 m_topRow = max(0, m_currRow + 1 - m_nRows); 656 651 } 657 652 } 658 }659 653 660 if (handled || menuHandled) { 661 update(); 654 handled = true; 662 655 } 663 else 664 { 665 MythDialog::keyPressEvent(e); 666 } 656 657 return handled; 667 658 } 668 659 669 660 void IconView::customEvent(QCustomEvent *e) -
mythgallery/mythgallery/iconview.h
73 73 void paintEvent(QPaintEvent *e); 74 74 void keyPressEvent(QKeyEvent *e); 75 75 void customEvent(QCustomEvent *e); 76 76 bool HandleEscape(void); 77 77 78 private: 78 79 void loadTheme(void); 79 80 void loadDirectory(const QString& dir, bool topleft = true); … … 99 100 void actionRandomShow(void); 100 101 void actionSettings(void); 101 102 void actionImport(void); 102 #ifndef _WIN32103 103 void actionShowDevices(void); 104 #endif105 104 void actionCopyHere(void); 106 105 void actionMoveHere(void); 107 106 void actionDelete(void);