From b78ccf289eea09c8ad677d16874eb0f7b0912e2b Mon Sep 17 00:00:00 2001 From: ngosang Date: Tue, 4 Aug 2015 01:30:31 +0200 Subject: [PATCH] [RSS] Fix contextual menu in RSS torrents list --- src/gui/rss/rss_imp.cpp | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/src/gui/rss/rss_imp.cpp b/src/gui/rss/rss_imp.cpp index f31edc1fb..8a8e8820d 100644 --- a/src/gui/rss/rss_imp.cpp +++ b/src/gui/rss/rss_imp.cpp @@ -112,20 +112,31 @@ void RSSImp::displayItemsListMenu(const QPoint&) { QMenu myItemListMenu(this); QList selectedItems = listArticles->selectedItems(); - if (selectedItems.size() > 0) { - bool has_attachment = false; - foreach (const QListWidgetItem* item, selectedItems) { - if (m_feedList->getRSSItemFromUrl(item->data(Article::FeedUrlRole).toString()) - ->getItem(item->data(Article::IdRole).toString())->hasAttachment()) { - has_attachment = true; - break; - } - } - if (has_attachment) - myItemListMenu.addAction(actionDownload_torrent); - myItemListMenu.addAction(actionOpen_news_URL); + if (selectedItems.size() <= 0) + return; + + bool hasTorrent = false; + bool hasLink = false; + foreach (const QListWidgetItem* item, selectedItems) { + if (!item) continue; + RssFeedPtr feed = m_feedList->getRSSItemFromUrl(item->data(Article::FeedUrlRole).toString()); + if (!feed) continue; + RssArticlePtr article = feed->getItem(item->data(Article::IdRole).toString()); + if (!article) continue; + + if (!article->torrentUrl().isEmpty()) + hasTorrent = true; + if (!article->link().isEmpty()) + hasLink = true; + if (hasTorrent && hasLink) + break; } - myItemListMenu.exec(QCursor::pos()); + if (hasTorrent) + myItemListMenu.addAction(actionDownload_torrent); + if (hasLink) + myItemListMenu.addAction(actionOpen_news_URL); + if (hasTorrent || hasLink) + myItemListMenu.exec(QCursor::pos()); } void RSSImp::on_actionManage_cookies_triggered()