mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-02-02 18:04:32 +00:00
- Fix crash when right-clicking on RSS news list (closes #422495)
This commit is contained in:
parent
6cd185d0d5
commit
c9c4f7001a
@ -142,19 +142,11 @@ p, li { white-space: pre-wrap; }
|
|||||||
<attribute name="headerStretchLastSection">
|
<attribute name="headerStretchLastSection">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</attribute>
|
</attribute>
|
||||||
<attribute name="headerStretchLastSection">
|
|
||||||
<bool>true</bool>
|
|
||||||
</attribute>
|
|
||||||
<column>
|
<column>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Bullet</string>
|
<string>Bullet</string>
|
||||||
</property>
|
</property>
|
||||||
</column>
|
</column>
|
||||||
<column>
|
|
||||||
<property name="text">
|
|
||||||
<string>Attachment</string>
|
|
||||||
</property>
|
|
||||||
</column>
|
|
||||||
<column>
|
<column>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Article title</string>
|
<string>Article title</string>
|
||||||
|
@ -42,6 +42,9 @@
|
|||||||
#include "feedList.h"
|
#include "feedList.h"
|
||||||
#include "bittorrent.h"
|
#include "bittorrent.h"
|
||||||
|
|
||||||
|
#define NEWS_TITLE_COL 1
|
||||||
|
#define NEWS_URL_COL 2
|
||||||
|
|
||||||
// display a right-click menu
|
// display a right-click menu
|
||||||
void RSSImp::displayRSSListMenu(const QPoint& pos){
|
void RSSImp::displayRSSListMenu(const QPoint& pos){
|
||||||
if(!listStreams->indexAt(pos).isValid()) {
|
if(!listStreams->indexAt(pos).isValid()) {
|
||||||
@ -85,11 +88,13 @@ void RSSImp::displayRSSListMenu(const QPoint& pos){
|
|||||||
|
|
||||||
void RSSImp::displayItemsListMenu(const QPoint&){
|
void RSSImp::displayItemsListMenu(const QPoint&){
|
||||||
QMenu myItemListMenu(this);
|
QMenu myItemListMenu(this);
|
||||||
QList<QTreeWidgetItem*> selectedItems = listStreams->selectedItems();
|
QList<QTreeWidgetItem*> selectedItems = listNews->selectedItems();
|
||||||
if(selectedItems.size() > 0) {
|
if(selectedItems.size() > 0) {
|
||||||
bool has_attachment = false;
|
bool has_attachment = false;
|
||||||
foreach(QTreeWidgetItem *item, selectedItems) {
|
foreach(QTreeWidgetItem *item, selectedItems) {
|
||||||
if(listStreams->getRSSItemFromUrl(item->text(3))->getItem(item->text(2))->has_attachment()) {
|
qDebug("text(3) URL: %s", item->text(NEWS_URL_COL).toLocal8Bit().data());
|
||||||
|
qDebug("text(2) TITLE: %s", item->text(NEWS_TITLE_COL).toLocal8Bit().data());
|
||||||
|
if(listStreams->getRSSItemFromUrl(item->text(NEWS_URL_COL))->getItem(item->text(NEWS_TITLE_COL))->has_attachment()) {
|
||||||
has_attachment = true;
|
has_attachment = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -284,7 +289,7 @@ void RSSImp::on_updateAllButton_clicked() {
|
|||||||
void RSSImp::downloadTorrent() {
|
void RSSImp::downloadTorrent() {
|
||||||
QList<QTreeWidgetItem *> selected_items = listNews->selectedItems();
|
QList<QTreeWidgetItem *> selected_items = listNews->selectedItems();
|
||||||
foreach(const QTreeWidgetItem* item, selected_items) {
|
foreach(const QTreeWidgetItem* item, selected_items) {
|
||||||
RssItem* article = listStreams->getRSSItemFromUrl(item->text(3))->getItem(item->text(2));
|
RssItem* article = listStreams->getRSSItemFromUrl(item->text(NEWS_URL_COL))->getItem(item->text(NEWS_TITLE_COL));
|
||||||
if(article->has_attachment()) {
|
if(article->has_attachment()) {
|
||||||
BTSession->downloadFromUrl(article->getTorrentUrl());
|
BTSession->downloadFromUrl(article->getTorrentUrl());
|
||||||
} else {
|
} else {
|
||||||
@ -299,7 +304,7 @@ void RSSImp::downloadTorrent() {
|
|||||||
void RSSImp::openNewsUrl() {
|
void RSSImp::openNewsUrl() {
|
||||||
QList<QTreeWidgetItem *> selected_items = listNews->selectedItems();
|
QList<QTreeWidgetItem *> selected_items = listNews->selectedItems();
|
||||||
foreach(const QTreeWidgetItem* item, selected_items) {
|
foreach(const QTreeWidgetItem* item, selected_items) {
|
||||||
RssItem* news = listStreams->getRSSItemFromUrl(item->text(3))->getItem(item->text(2));
|
RssItem* news = listStreams->getRSSItemFromUrl(item->text(NEWS_URL_COL))->getItem(item->text(NEWS_TITLE_COL));
|
||||||
QString link = news->getLink();
|
QString link = news->getLink();
|
||||||
if(!link.isEmpty())
|
if(!link.isEmpty())
|
||||||
QDesktopServices::openUrl(QUrl(link));
|
QDesktopServices::openUrl(QUrl(link));
|
||||||
@ -436,17 +441,17 @@ void RSSImp::refreshNewsList(QTreeWidgetItem* item) {
|
|||||||
qDebug("Got the list of news");
|
qDebug("Got the list of news");
|
||||||
foreach(RssItem* article, news){
|
foreach(RssItem* article, news){
|
||||||
QTreeWidgetItem* it = new QTreeWidgetItem(listNews);
|
QTreeWidgetItem* it = new QTreeWidgetItem(listNews);
|
||||||
it->setText(2, article->getTitle());
|
it->setText(NEWS_TITLE_COL, article->getTitle());
|
||||||
if(article->has_attachment())
|
if(article->has_attachment())
|
||||||
it->setData(1, Qt::DecorationRole, QVariant(QIcon(":/Icons/oxygen/application-x-kgetlist.png")));
|
it->setData(NEWS_TITLE_COL, Qt::DecorationRole, QVariant(QIcon(":/Icons/oxygen/application-x-kgetlist.png")));
|
||||||
else
|
else
|
||||||
it->setData(1, Qt::DecorationRole, QVariant(QIcon(":/Icons/oxygen/application-x-kgetlist-no.png")));
|
it->setData(NEWS_TITLE_COL, Qt::DecorationRole, QVariant(QIcon(":/Icons/oxygen/application-x-kgetlist-no.png")));
|
||||||
it->setText(3, article->getParent()->getUrl());
|
it->setText(NEWS_URL_COL, article->getParent()->getUrl());
|
||||||
if(article->isRead()){
|
if(article->isRead()){
|
||||||
it->setData(2, Qt::ForegroundRole, QVariant(QColor("grey")));
|
it->setData(NEWS_TITLE_COL, Qt::ForegroundRole, QVariant(QColor("grey")));
|
||||||
it->setData(0, Qt::DecorationRole, QVariant(QIcon(":/Icons/sphere.png")));
|
it->setData(0, Qt::DecorationRole, QVariant(QIcon(":/Icons/sphere.png")));
|
||||||
}else{
|
}else{
|
||||||
it->setData(2, Qt::ForegroundRole, QVariant(QColor("blue")));
|
it->setData(NEWS_TITLE_COL, Qt::ForegroundRole, QVariant(QColor("blue")));
|
||||||
it->setData(0, Qt::DecorationRole, QVariant(QIcon(":/Icons/sphere2.png")));
|
it->setData(0, Qt::DecorationRole, QVariant(QIcon(":/Icons/sphere2.png")));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -465,8 +470,8 @@ void RSSImp::refreshTextBrowser(QTreeWidgetItem *item) {
|
|||||||
}
|
}
|
||||||
previous_news = item;
|
previous_news = item;
|
||||||
}
|
}
|
||||||
RssStream *stream = listStreams->getRSSItemFromUrl(item->text(3));
|
RssStream *stream = listStreams->getRSSItemFromUrl(item->text(NEWS_URL_COL));
|
||||||
RssItem* article = stream->getItem(item->text(2));
|
RssItem* article = stream->getItem(item->text(NEWS_TITLE_COL));
|
||||||
QString html;
|
QString html;
|
||||||
html += "<div style='border: 2px solid red; margin-left: 5px; margin-right: 5px; margin-bottom: 5px;'>";
|
html += "<div style='border: 2px solid red; margin-left: 5px; margin-right: 5px; margin-bottom: 5px;'>";
|
||||||
html += "<div style='background-color: #678db2; font-weight: bold; color: #fff;'>"+article->getTitle() + "</div>";
|
html += "<div style='background-color: #678db2; font-weight: bold; color: #fff;'>"+article->getTitle() + "</div>";
|
||||||
@ -480,11 +485,11 @@ void RSSImp::refreshTextBrowser(QTreeWidgetItem *item) {
|
|||||||
html += "<divstyle='margin-left: 5px; margin-right: 5px;'>"+article->getDescription()+"</div>";
|
html += "<divstyle='margin-left: 5px; margin-right: 5px;'>"+article->getDescription()+"</div>";
|
||||||
textBrowser->setHtml(html);
|
textBrowser->setHtml(html);
|
||||||
article->setRead();
|
article->setRead();
|
||||||
item->setData(2, Qt::ForegroundRole, QVariant(QColor("grey")));
|
item->setData(NEWS_TITLE_COL, Qt::ForegroundRole, QVariant(QColor("grey")));
|
||||||
item->setData(0, Qt::DecorationRole, QVariant(QIcon(":/Icons/sphere.png")));
|
item->setData(0, Qt::DecorationRole, QVariant(QIcon(":/Icons/sphere.png")));
|
||||||
// Decrement feed nb unread news
|
// Decrement feed nb unread news
|
||||||
updateItemInfos(listStreams->getUnreadItem());
|
updateItemInfos(listStreams->getUnreadItem());
|
||||||
updateItemInfos(listStreams->getTreeItemFromUrl(item->text(3)));
|
updateItemInfos(listStreams->getTreeItemFromUrl(item->text(NEWS_URL_COL)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void RSSImp::saveSlidersPosition() {
|
void RSSImp::saveSlidersPosition() {
|
||||||
@ -560,9 +565,8 @@ RSSImp::RSSImp(bittorrent *BTSession) : QWidget(), BTSession(BTSession){
|
|||||||
|
|
||||||
listStreams = new FeedList(splitter_h, rssmanager);
|
listStreams = new FeedList(splitter_h, rssmanager);
|
||||||
splitter_h->insertWidget(0, listStreams);
|
splitter_h->insertWidget(0, listStreams);
|
||||||
listNews->hideColumn(3);
|
listNews->hideColumn(NEWS_URL_COL);
|
||||||
listNews->setColumnWidth(0, 16);
|
listNews->setColumnWidth(0, 16);
|
||||||
listNews->setColumnWidth(1, 20);
|
|
||||||
|
|
||||||
fillFeedsList();
|
fillFeedsList();
|
||||||
refreshNewsList(listStreams->currentItem());
|
refreshNewsList(listStreams->currentItem());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user