mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-10-22 10:46:04 +03:00
[RSS] Allow multiple selection in RSS torrents list
This commit is contained in:
parent
1a653829b8
commit
5db783cb7f
2 changed files with 30 additions and 9 deletions
|
@ -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>
|
||||||
|
|
|
@ -337,13 +337,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;
|
||||||
QString torrentLink = article->torrentUrl();
|
QString torrentLink = article->torrentUrl();
|
||||||
|
@ -360,19 +367,36 @@ void RSSImp::downloadSelectedTorrents()
|
||||||
QBtSession::instance()->downloadFromUrl(torrentLink, cookies);
|
QBtSession::instance()->downloadFromUrl(torrentLink, cookies);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// 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
|
||||||
|
@ -549,7 +573,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;
|
||||||
|
@ -714,8 +737,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 a new issue