void RSSImp::displayItemsListMenu(const QPoint&) { QMenu myItemListMenu(this); QList<QListWidgetItem*> selectedItems = listArticles->selectedItems(); if (selectedItems.size() <= 0) return; bool hasTorrent = false; bool hasLink = false; foreach (const QListWidgetItem* item, selectedItems) { if (!item) continue; Rss::FeedPtr feed = m_feedList->getRSSItemFromUrl(item->data(Article::FeedUrlRole).toString()); if (!feed) continue; Rss::ArticlePtr 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; } if (hasTorrent) myItemListMenu.addAction(actionDownload_torrent); if (hasLink) myItemListMenu.addAction(actionOpen_news_URL); if (hasTorrent || hasLink) myItemListMenu.exec(QCursor::pos()); }
void RSSImp::displayItemsListMenu(const QPoint&) { QMenu myItemListMenu(this); QList<QListWidgetItem*> selectedItems = listArticles->selectedItems(); if (selectedItems.size() > 0) { bool has_attachment = false; foreach (const QListWidgetItem *item, selectedItems) { qDebug("text(3) URL: %s", qPrintable(item->data(Article::FeedUrlRole).toString())); qDebug("text(2) TITLE: %s", qPrintable(item->data(Article::TitleRole).toString())); if (m_feedList->getRSSItemFromUrl(item->data(Article::FeedUrlRole).toString()) ->getItem(item->data(Article::IdRole).toString())->hasAttachment()) { has_attachment = true; break; } }
void RSSImp::displayItemsListMenu(const QPoint&) { QMenu myItemListMenu(this); QList<QListWidgetItem*> 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); }
void RSSWidget::displayItemsListMenu(const QPoint &) { bool hasTorrent = false; bool hasLink = false; foreach (const QListWidgetItem *item, m_articleListWidget->selectedItems()) { auto article = reinterpret_cast<RSS::Article *>(item->data(Qt::UserRole).value<quintptr>()); Q_ASSERT(article); if (!article->torrentUrl().isEmpty()) hasTorrent = true; if (!article->link().isEmpty()) hasLink = true; if (hasTorrent && hasLink) break; } QMenu myItemListMenu(this); if (hasTorrent) myItemListMenu.addAction(m_ui->actionDownloadTorrent); if (hasLink) myItemListMenu.addAction(m_ui->actionOpenNewsURL); if (hasTorrent || hasLink) myItemListMenu.exec(QCursor::pos()); }