From 54bfb7cda9cb9339f61463410fcb6a350dfdf81b Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Fri, 6 Mar 2009 23:16:09 +0000 Subject: [PATCH] - RSS items read status is now remembered upon startup --- src/rss.h | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/rss.h b/src/rss.h index aa52b3e0b..d3b42134a 100644 --- a/src/rss.h +++ b/src/rss.h @@ -320,6 +320,8 @@ class RssStream : public QObject{ } ~RssStream(){ + QSettings qBTRSS("qBittorrent-rss"); + qBTRSS.setValue(url, getAllReadHashes()); removeAllItems(); if(QFile::exists(filePath)) QFile::remove(filePath); @@ -327,6 +329,15 @@ class RssStream : public QObject{ QFile::remove(iconPath); } + QStringList getAllReadHashes() { + QStringList hashes; + foreach(RssItem *item, listItem) { + if(item->isRead()) + hashes << item->getHash(); + } + return hashes; + } + // delete all the items saved void removeAllItems() { qDeleteAll(listItem); @@ -462,6 +473,11 @@ class RssStream : public QObject{ private: // read and create items from a rss document short readDoc(const QDomDocument& doc) { + QStringList old_items; + if(!refreshed) { + QSettings qBTRSS("qBittorrent-rss"); + old_items = qBTRSS.value(this->url, QVariant()).toStringList(); + } // is it a rss file ? QDomElement root = doc.documentElement(); if(root.tagName() == QString::fromUtf8("html")){ @@ -493,10 +509,13 @@ class RssStream : public QObject{ image = property.text(); else if(property.tagName() == "item") { RssItem * item = new RssItem(property); - if(!itemAlreadyExists(item->getHash())) + if(!itemAlreadyExists(item->getHash())) { + if(!refreshed && old_items.contains(item->getHash())) + item->setRead(); listItem.append(item); - else + } else { delete item; + } } property = property.nextSibling().toElement(); }