@ -90,8 +90,12 @@ void RssFolder::refreshAll(){
}
}
void RssFolder : : removeFile ( QString ID ) {
void RssFolder : : removeFile ( QString ID ) {
if ( this - > contains ( ID ) )
if ( this - > contains ( ID ) ) {
delete this - > take ( ID ) ;
RssFile * child = this - > take ( ID ) ;
child - > removeAllSettings ( ) ;
child - > removeAllItems ( ) ;
delete child ;
}
}
}
RssFolder * RssFolder : : addFolder ( QString name ) {
RssFolder * RssFolder : : addFolder ( QString name ) {
@ -427,6 +431,20 @@ void RssStream::removeAllItems() {
this - > clear ( ) ;
this - > clear ( ) ;
}
}
void RssStream : : removeAllSettings ( ) {
QSettings qBTRSS ( " qBittorrent " , " qBittorrent-rss " ) ;
QHash < QString , QVariant > feeds_w_downloader = qBTRSS . value ( " downloader_on " , QHash < QString , QVariant > ( ) ) . toHash ( ) ;
if ( feeds_w_downloader . contains ( url ) ) {
feeds_w_downloader . remove ( url ) ;
qBTRSS . setValue ( " downloader_on " , feeds_w_downloader ) ;
}
QHash < QString , QVariant > all_feeds_filters = qBTRSS . value ( " feed_filters " , QHash < QString , QVariant > ( ) ) . toHash ( ) ;
if ( all_feeds_filters . contains ( url ) ) {
all_feeds_filters . remove ( url ) ;
qBTRSS . setValue ( " feed_filters " , all_feeds_filters ) ;
}
}
bool RssStream : : itemAlreadyExists ( QString name ) {
bool RssStream : : itemAlreadyExists ( QString name ) {
return this - > contains ( name ) ;
return this - > contains ( name ) ;
}
}
@ -579,15 +597,26 @@ short RssStream::readDoc(const QDomDocument& doc) {
( * this ) [ title ] = item ;
( * this ) [ title ] = item ;
} else {
} else {
delete item ;
delete item ;
item = this - > value ( title ) ;
}
}
} else {
delete item ;
}
}
property = property . nextSibling ( ) . toElement ( ) ;
}
}
channel = channel . nextSibling ( ) . toElement ( ) ;
}
resizeList ( ) ;
// RSS Feed Downloader
foreach ( RssItem * item , values ( ) ) {
if ( item - > isRead ( ) ) continue ;
QString torrent_url ;
QString torrent_url ;
if ( item - > has_attachment ( ) )
if ( item - > has_attachment ( ) )
torrent_url = item - > getTorrentUrl ( ) ;
torrent_url = item - > getTorrentUrl ( ) ;
else
else
torrent_url = item - > getLink ( ) ;
torrent_url = item - > getLink ( ) ;
// Check if the item should be automatically downloaded
// Check if the item should be automatically downloaded
if ( ! already_exists | | ! ( * this ) [ item - > getTitle ( ) ] - > isRead ( ) ) {
FeedFilter * matching_filter = FeedFilters : : getFeedFilters ( url ) . matches ( item - > getTitle ( ) ) ;
FeedFilter * matching_filter = FeedFilters : : getFeedFilters ( url ) . matches ( item - > getTitle ( ) ) ;
if ( matching_filter ! = 0 ) {
if ( matching_filter ! = 0 ) {
// Download the torrent
// Download the torrent
@ -603,22 +632,11 @@ short RssStream::readDoc(const QDomDocument& doc) {
BTSession - > downloadUrlAndSkipDialog ( torrent_url ) ;
BTSession - > downloadUrlAndSkipDialog ( torrent_url ) ;
}
}
// Item was downloaded, consider it as Read
// Item was downloaded, consider it as Read
( * this ) [ item - > getTitle ( ) ] - > setRead ( ) ;
item - > setRead ( ) ;
// Clean up
// Clean up
delete matching_filter ;
delete matching_filter ;
}
}
}
}
} else {
delete item ;
}
}
property = property . nextSibling ( ) . toElement ( ) ;
}
}
channel = channel . nextSibling ( ) . toElement ( ) ;
}
resizeList ( ) ;
return 0 ;
return 0 ;
}
}