mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-11 07:18:08 +00:00
[RSS] Allow multiple selection in RSS torrents list
This commit is contained in:
parent
7c7da44622
commit
2eaeead67c
@ -139,7 +139,7 @@ p, li { white-space: pre-wrap; }
|
|||||||
<enum>Qt::CustomContextMenu</enum>
|
<enum>Qt::CustomContextMenu</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="selectionMode">
|
<property name="selectionMode">
|
||||||
<enum>QAbstractItemView::SingleSelection</enum>
|
<enum>QAbstractItemView::ExtendedSelection</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="selectionBehavior">
|
<property name="selectionBehavior">
|
||||||
<enum>QAbstractItemView::SelectItems</enum>
|
<enum>QAbstractItemView::SelectItems</enum>
|
||||||
|
@ -340,13 +340,20 @@ void RSSImp::refreshAllFeeds()
|
|||||||
void RSSImp::downloadSelectedTorrents()
|
void RSSImp::downloadSelectedTorrents()
|
||||||
{
|
{
|
||||||
QList<QListWidgetItem*> selected_items = listArticles->selectedItems();
|
QList<QListWidgetItem*> selected_items = listArticles->selectedItems();
|
||||||
foreach (const QListWidgetItem* item, selected_items) {
|
if (selected_items.size() <= 0)
|
||||||
|
return;
|
||||||
|
foreach (QListWidgetItem* item, selected_items) {
|
||||||
if (!item) continue;
|
if (!item) continue;
|
||||||
RssFeedPtr feed = m_feedList->getRSSItemFromUrl(item->data(Article::FeedUrlRole).toString());
|
RssFeedPtr feed = m_feedList->getRSSItemFromUrl(item->data(Article::FeedUrlRole).toString());
|
||||||
if (!feed) continue;
|
if (!feed) continue;
|
||||||
RssArticlePtr article = feed->getItem(item->data(Article::IdRole).toString());
|
RssArticlePtr article = feed->getItem(item->data(Article::IdRole).toString());
|
||||||
if (!article) continue;
|
if (!article) continue;
|
||||||
|
|
||||||
|
// Mark as read
|
||||||
|
article->markAsRead();
|
||||||
|
item->setData(Article::ColorRole, QVariant(QColor("grey")));
|
||||||
|
item->setData(Article::IconRole, QVariant(QIcon(":/icons/sphere.png")));
|
||||||
|
|
||||||
if (article->torrentUrl().isEmpty())
|
if (article->torrentUrl().isEmpty())
|
||||||
continue;
|
continue;
|
||||||
if (Preferences::instance()->useAdditionDialog())
|
if (Preferences::instance()->useAdditionDialog())
|
||||||
@ -354,19 +361,36 @@ void RSSImp::downloadSelectedTorrents()
|
|||||||
else
|
else
|
||||||
BitTorrent::Session::instance()->addTorrent(article->torrentUrl());
|
BitTorrent::Session::instance()->addTorrent(article->torrentUrl());
|
||||||
}
|
}
|
||||||
|
// Decrement feed nb unread news
|
||||||
|
updateItemInfos(m_feedList->stickyUnreadItem());
|
||||||
|
updateItemInfos(m_feedList->getTreeItemFromUrl(selected_items.first()->data(Article::FeedUrlRole).toString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// open the url of the selected RSS articles in the Web browser
|
// open the url of the selected RSS articles in the Web browser
|
||||||
void RSSImp::openSelectedArticlesUrls()
|
void RSSImp::openSelectedArticlesUrls()
|
||||||
{
|
{
|
||||||
QList<QListWidgetItem *> selected_items = listArticles->selectedItems();
|
QList<QListWidgetItem *> selected_items = listArticles->selectedItems();
|
||||||
foreach (const QListWidgetItem* item, selected_items) {
|
if (selected_items.size() <= 0)
|
||||||
RssArticlePtr news = m_feedList->getRSSItemFromUrl(item->data(Article::FeedUrlRole).toString())
|
return;
|
||||||
->getItem(item->data(Article::IdRole).toString());
|
foreach (QListWidgetItem* item, selected_items) {
|
||||||
const QString link = news->link();
|
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;
|
||||||
|
|
||||||
|
// Mark as read
|
||||||
|
article->markAsRead();
|
||||||
|
item->setData(Article::ColorRole, QVariant(QColor("grey")));
|
||||||
|
item->setData(Article::IconRole, QVariant(QIcon(":/icons/sphere.png")));
|
||||||
|
|
||||||
|
const QString link = article->link();
|
||||||
if (!link.isEmpty())
|
if (!link.isEmpty())
|
||||||
QDesktopServices::openUrl(QUrl(link));
|
QDesktopServices::openUrl(QUrl(link));
|
||||||
}
|
}
|
||||||
|
// Decrement feed nb unread news
|
||||||
|
updateItemInfos(m_feedList->stickyUnreadItem());
|
||||||
|
updateItemInfos(m_feedList->getTreeItemFromUrl(selected_items.first()->data(Article::FeedUrlRole).toString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
//right-click on stream : give it an alias
|
//right-click on stream : give it an alias
|
||||||
@ -543,7 +567,6 @@ void RSSImp::refreshTextBrowser()
|
|||||||
{
|
{
|
||||||
QList<QListWidgetItem*> selection = listArticles->selectedItems();
|
QList<QListWidgetItem*> selection = listArticles->selectedItems();
|
||||||
if (selection.empty()) return;
|
if (selection.empty()) return;
|
||||||
Q_ASSERT(selection.size() == 1);
|
|
||||||
QListWidgetItem *item = selection.first();
|
QListWidgetItem *item = selection.first();
|
||||||
Q_ASSERT(item);
|
Q_ASSERT(item);
|
||||||
if (item == m_currentArticle) return;
|
if (item == m_currentArticle) return;
|
||||||
@ -708,8 +731,6 @@ RSSImp::RSSImp(QWidget *parent):
|
|||||||
|
|
||||||
m_feedList = new FeedListWidget(splitter_h, m_rssManager);
|
m_feedList = new FeedListWidget(splitter_h, m_rssManager);
|
||||||
splitter_h->insertWidget(0, m_feedList);
|
splitter_h->insertWidget(0, m_feedList);
|
||||||
listArticles->setSelectionBehavior(QAbstractItemView::SelectItems);
|
|
||||||
listArticles->setSelectionMode(QAbstractItemView::SingleSelection);
|
|
||||||
editHotkey = new QShortcut(QKeySequence("F2"), m_feedList, 0, 0, Qt::WidgetShortcut);
|
editHotkey = new QShortcut(QKeySequence("F2"), m_feedList, 0, 0, Qt::WidgetShortcut);
|
||||||
connect(editHotkey, SIGNAL(activated()), SLOT(renameSelectedRssFile()));
|
connect(editHotkey, SIGNAL(activated()), SLOT(renameSelectedRssFile()));
|
||||||
connect(m_feedList, SIGNAL(doubleClicked(QModelIndex)), SLOT(renameSelectedRssFile()));
|
connect(m_feedList, SIGNAL(doubleClicked(QModelIndex)), SLOT(renameSelectedRssFile()));
|
||||||
|
Loading…
Reference in New Issue
Block a user