From 141d3b6737c5e2e51060aa5bb3e187b8873084ca Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Mon, 14 Dec 2009 18:42:21 +0000 Subject: [PATCH] - Fix RSS Feed downloader for RSS with no torrent attachment (but articles link points to the torrent instead) --- .../oxygen/application-x-kgetlist-no.png | Bin 743 -> 0 bytes src/Icons/oxygen/application-x-kgetlist.png | Bin 659 -> 0 bytes src/icons.qrc | 2 - src/rss.cpp | 49 +++++++++--------- src/rss.h | 2 - src/rss_imp.cpp | 14 ++--- 6 files changed, 27 insertions(+), 40 deletions(-) delete mode 100644 src/Icons/oxygen/application-x-kgetlist-no.png delete mode 100644 src/Icons/oxygen/application-x-kgetlist.png diff --git a/src/Icons/oxygen/application-x-kgetlist-no.png b/src/Icons/oxygen/application-x-kgetlist-no.png deleted file mode 100644 index 0db2ebd842bee7b9504bdbf3177bf81873d1c9a5..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 743 zcmV?P)Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L00FxI00FxJI_%@(00007bV*G`2iXW6 z12qp@E<(Bh00L)8L_t(I%axPOOH@%9#-DQ>wMo)orXsLu;iR|`L@}yWixzDMGJ?=W zLjD0cB|(b_BwV-%Dr%RIn{bgXS_~AXAqGZ*XgPh*Ov>oYz4LKDX6~6gPm6KXVIt^- z7tXtQe&^*m&k-osX#hR=zghthtqdVM6e0ntwl*eXF{U()nyyn%ru&pkcM z(cumfU`a|^kqAxGq-9yPfRv^&l}gbX86g2?nml|md6iakBMH#D9j0yDv~8RDLZKF* z={hxCXF8Rl)7wJ=T<<+oW<2eQ5%LI?;Us-9vWAOxfkFzhU{C;j-@=>q_)wl_id9Yxy8Kr{6kh^KN8Qo?Z^ zOe}|Sap4y(FK@#>B+>ghi`d5)ru_G?{ymGwS0>TmX{-rF$S@3=rpXU)UNZ0XPAG&MiH2#?%4X^I^^pL-TsX!X@6L0zyM+X}(-maiG->X3 zjfp}C)Q^opE-isRALefjvT#j#NX1-a#4+1=>t&oDdYyGR%%6C-* Z{s6uQpM&(s52yeD002ovPDHLkV1m|;Hsb&Q diff --git a/src/Icons/oxygen/application-x-kgetlist.png b/src/Icons/oxygen/application-x-kgetlist.png deleted file mode 100644 index 55c04aa98f25a6226cb90aa003e2a6d2a7639f07..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 659 zcmV;E0&M+>P)mzf$l^)8)D=V!5j-e8 zt?WTOdGIQD5kc@@*n=Y8J;)yR4=B`wKfsIbVWI4zWrb3tCT?j{o3u@nad;%ruuH)& z4D*tC?=v&W8-<9VD9RZCHT<7;iKwk54>iYewqu5=sw$14Ib)?>#!p(-9RL{sF=3%3 zC|%>PGJp_jwviCy@{8-Jlr5-=fa8wv`QZnsq5vh?lLMq>fd~rwSrp-H)xx!NHRyck z-PbRO0O)Fxgnb^6QrYA;AQctc!Y}_2nyR5vG9mcA5CT|GLFNSmiYJ!fB!FVU;8v8} z!J~jA_&e|r#&Z-R1FruALJ_ddDhB=#dKh5YDjf?*dY@r)=P}B*0eiW?v4TjId2l?QOcKK2IRamvzBv<$TR2RK9@_tzewAaoGX(F&0C zcy;v(Iy)U`l`Zs!19?AA7j2x6H?UT%VKSK<+d}Tv-Me%buRi?*N^d~~tPF49_Juk+ zosP`j?RLKb*aIsqXWjRGVmi%cGYZ3y=JPpizJEf`KR%@(2&mO+(Re(jMx)^XxX32w zC>^GCKM1z@Ph@kz0C=8<(P#wIG~v1~dcB@ouh(yKf?ZIcons/oxygen/encrypted.png Icons/oxygen/edit_clear.png Icons/oxygen/download.png - Icons/oxygen/application-x-kgetlist-no.png Icons/oxygen/gear.png Icons/oxygen/remove.png Icons/oxygen/dialog-warning.png @@ -165,7 +164,6 @@ Icons/oxygen/help-about.png Icons/oxygen/list-add.png Icons/oxygen/network-server.png - Icons/oxygen/application-x-kgetlist.png Icons/oxygen/folder.png Icons/oxygen/urlseed.png Icons/oxygen/edit-cut.png diff --git a/src/rss.cpp b/src/rss.cpp index bc539a19b..9b2b6fd92 100644 --- a/src/rss.cpp +++ b/src/rss.cpp @@ -376,7 +376,6 @@ void RssManager::saveStreamList(){ /** RssStream **/ RssStream::RssStream(RssFolder* parent, RssManager *rssmanager, Bittorrent *BTSession, QString _url): parent(parent), rssmanager(rssmanager), BTSession(BTSession), alias(""), iconPath(":/Icons/rss16.png"), refreshed(false), downloadFailure(false), currently_loading(false) { - has_attachments = false; qDebug("RSSStream constructed"); QSettings qBTRSS("qBittorrent", "qBittorrent-rss"); url = QUrl(_url).toString(); @@ -388,8 +387,6 @@ RssStream::RssStream(RssFolder* parent, RssManager *rssmanager, Bittorrent *BTSe RssItem *rss_item = RssItem::fromHash(this, item); if(rss_item->isValid()) { (*this)[rss_item->getTitle()] = rss_item; - if(rss_item->has_attachment()) - has_attachments = true; } } } @@ -584,29 +581,31 @@ short RssStream::readDoc(const QDomDocument& doc) { delete item; item = this->value(title); } - if(item->has_attachment()) { - has_attachments = true; - // Check if the item should be automatically downloaded - if(!already_exists || !(*this)[item->getTitle()]->isRead()) { - FeedFilter * matching_filter = FeedFilters::getFeedFilters(url).matches(item->getTitle()); - if(matching_filter != 0) { - // Download the torrent - BTSession->addConsoleMessage(tr("Automatically downloading %1 torrent from %2 RSS feed...").arg(item->getTitle()).arg(getName())); - if(matching_filter->isValid()) { - QString save_path = matching_filter->getSavePath(); - if(save_path.isEmpty()) - BTSession->downloadUrlAndSkipDialog(item->getTorrentUrl()); - else - BTSession->downloadUrlAndSkipDialog(item->getTorrentUrl(), save_path); - } else { - // All torrents are downloaded from this feed - BTSession->downloadUrlAndSkipDialog(item->getTorrentUrl()); - } - // Item was downloaded, consider it as Read - (*this)[item->getTitle()]->setRead(); - // Clean up - delete matching_filter; + QString torrent_url; + if(item->has_attachment()) + torrent_url = item->getTorrentUrl(); + else + torrent_url = item->getLink(); + // Check if the item should be automatically downloaded + if(!already_exists || !(*this)[item->getTitle()]->isRead()) { + FeedFilter * matching_filter = FeedFilters::getFeedFilters(url).matches(item->getTitle()); + if(matching_filter != 0) { + // Download the torrent + BTSession->addConsoleMessage(tr("Automatically downloading %1 torrent from %2 RSS feed...").arg(item->getTitle()).arg(getName())); + if(matching_filter->isValid()) { + QString save_path = matching_filter->getSavePath(); + if(save_path.isEmpty()) + BTSession->downloadUrlAndSkipDialog(torrent_url); + else + BTSession->downloadUrlAndSkipDialog(torrent_url, save_path); + } else { + // All torrents are downloaded from this feed + BTSession->downloadUrlAndSkipDialog(torrent_url); } + // Item was downloaded, consider it as Read + (*this)[item->getTitle()]->setRead(); + // Clean up + delete matching_filter; } } diff --git a/src/rss.h b/src/rss.h index 2d68dff9f..9cf1167d5 100644 --- a/src/rss.h +++ b/src/rss.h @@ -394,7 +394,6 @@ private: bool refreshed; bool downloadFailure; bool currently_loading; - bool has_attachments; public slots: void processDownloadedFile(QString file_path); @@ -430,7 +429,6 @@ public: QList getNewsList() const; QList getUnreadNewsList() const; QString getIconUrl(); - bool hasAttachments() const { return has_attachments; } private: short readDoc(const QDomDocument& doc); diff --git a/src/rss_imp.cpp b/src/rss_imp.cpp index 3c77edcc7..c74420032 100644 --- a/src/rss_imp.cpp +++ b/src/rss_imp.cpp @@ -71,10 +71,8 @@ void RSSImp::displayRSSListMenu(const QPoint& pos){ myRSSListMenu.addSeparator(); myRSSListMenu.addAction(actionCopy_feed_URL); if(selectedItems.size() == 1) { - if(((RssStream*)listStreams->getRSSItem(selectedItems.first()))->hasAttachments()) { - myRSSListMenu.addSeparator(); - myRSSListMenu.addAction(actionRSS_feed_downloader); - } + myRSSListMenu.addSeparator(); + myRSSListMenu.addAction(actionRSS_feed_downloader); } } }else{ @@ -293,9 +291,7 @@ void RSSImp::downloadTorrent() { if(article->has_attachment()) { BTSession->downloadFromUrl(article->getTorrentUrl()); } else { - QString link = article->getLink(); - if(!link.isEmpty()) - QDesktopServices::openUrl(QUrl(link)); + BTSession->downloadFromUrl(article->getLink()); } } } @@ -444,10 +440,6 @@ void RSSImp::refreshNewsList(QTreeWidgetItem* item) { foreach(RssItem* article, news){ QTreeWidgetItem* it = new QTreeWidgetItem(listNews); it->setText(NEWS_TITLE_COL, article->getTitle()); - if(article->has_attachment()) - it->setData(NEWS_TITLE_COL, Qt::DecorationRole, QVariant(QIcon(":/Icons/oxygen/application-x-kgetlist.png"))); - else - it->setData(NEWS_TITLE_COL, Qt::DecorationRole, QVariant(QIcon(":/Icons/oxygen/application-x-kgetlist-no.png"))); it->setText(NEWS_URL_COL, article->getParent()->getUrl()); if(article->isRead()){ it->setData(NEWS_TITLE_COL, Qt::ForegroundRole, QVariant(QColor("grey")));