Changeset 14566
- Timestamp:
- Oct 4, 2015, 6:16:59 AM (5 years ago)
- Location:
- trunk/qt
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/qt/MainWindow.cc
r14563 r14566 570 570 MainWindow::openFolder () 571 571 { 572 const int torrentId (*getSelectedTorrents ().begin ()); 572 const QSet<int> selectedTorrents = getSelectedTorrents (); 573 if (selectedTorrents.size () != 1) 574 return; 575 576 const int torrentId (*selectedTorrents.begin ()); 573 577 const Torrent * tor (myModel.getTorrentFromId (torrentId)); 578 if (tor == nullptr) 579 return; 580 574 581 QString path (tor->getPath ()); 575 const FileList files = tor->files (); 582 const FileList& files = tor->files (); 583 if (files.isEmpty ()) 584 return; 585 576 586 const QString firstfile = files.at (0).filename; 577 587 int slashIndex = firstfile.indexOf (QLatin1Char ('/')); … … 587 597 } 588 598 #endif 599 589 600 QDesktopServices::openUrl (QUrl::fromLocalFile (path)); 590 601 } … … 735 746 int selectedAndPaused (0); 736 747 int selectedAndQueued (0); 748 int selectedWithMetadata (0); 737 749 int canAnnounce (0); 738 750 const QAbstractItemModel * model (ui.listView->model ()); … … 756 768 if (isSelected && isPaused) ++selectedAndPaused; 757 769 if (isSelected && isQueued) ++selectedAndQueued; 770 if (isSelected && tor->hasMetadata ()) ++selectedWithMetadata; 758 771 if (tor->canManualAnnounce ()) ++canAnnounce; 759 772 } … … 761 774 762 775 const bool haveSelection (selected > 0); 763 ui.action_Verify->setEnabled (haveSelection); 776 const bool haveSelectionWithMetadata = selectedWithMetadata > 0; 777 const bool oneSelection (selected == 1); 778 779 ui.action_Verify->setEnabled (haveSelectionWithMetadata); 764 780 ui.action_Remove->setEnabled (haveSelection); 765 781 ui.action_Delete->setEnabled (haveSelection); … … 768 784 ui.action_SetLocation->setEnabled (haveSelection); 769 785 770 const bool oneSelection (selected == 1); 771 ui.action_OpenFolder->setEnabled (oneSelection && mySession.isLocal ()); 786 ui.action_OpenFolder->setEnabled (oneSelection && haveSelectionWithMetadata && mySession.isLocal ()); 772 787 ui.action_CopyMagnetToClipboard->setEnabled (oneSelection); 773 788 … … 800 815 801 816 QSet<int> 802 MainWindow::getSelectedTorrents ( ) const817 MainWindow::getSelectedTorrents (bool withMetadataOnly) const 803 818 { 804 819 QSet<int> ids; … … 807 822 { 808 823 const Torrent * tor (index.data (TorrentModel::TorrentRole).value<const Torrent*> ()); 809 ids.insert (tor->id ()); 824 if (tor != nullptr && (!withMetadataOnly || tor->hasMetadata ())) 825 ids.insert (tor->id ()); 810 826 } 811 827 … … 871 887 MainWindow::verifySelected () 872 888 { 873 mySession.verifyTorrents (getSelectedTorrents ( ));889 mySession.verifyTorrents (getSelectedTorrents (true)); 874 890 } 875 891 void -
trunk/qt/MainWindow.h
r14556 r14566 89 89 QIcon getStockIcon (const QString&, int fallback = -1); 90 90 91 QSet<int> getSelectedTorrents ( ) const;91 QSet<int> getSelectedTorrents (bool withMetadataOnly = false) const; 92 92 void updateNetworkIcon (); 93 93
Note: See TracChangeset
for help on using the changeset viewer.