Browse Source

- RSS items read status is now remembered upon startup

adaptive-webui-19844
Christophe Dumez 16 years ago
parent
commit
54bfb7cda9
  1. 23
      src/rss.h

23
src/rss.h

@ -320,6 +320,8 @@ class RssStream : public QObject{
} }
~RssStream(){ ~RssStream(){
QSettings qBTRSS("qBittorrent-rss");
qBTRSS.setValue(url, getAllReadHashes());
removeAllItems(); removeAllItems();
if(QFile::exists(filePath)) if(QFile::exists(filePath))
QFile::remove(filePath); QFile::remove(filePath);
@ -327,6 +329,15 @@ class RssStream : public QObject{
QFile::remove(iconPath); QFile::remove(iconPath);
} }
QStringList getAllReadHashes() {
QStringList hashes;
foreach(RssItem *item, listItem) {
if(item->isRead())
hashes << item->getHash();
}
return hashes;
}
// delete all the items saved // delete all the items saved
void removeAllItems() { void removeAllItems() {
qDeleteAll(listItem); qDeleteAll(listItem);
@ -462,6 +473,11 @@ class RssStream : public QObject{
private: private:
// read and create items from a rss document // read and create items from a rss document
short readDoc(const QDomDocument& doc) { 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 ? // is it a rss file ?
QDomElement root = doc.documentElement(); QDomElement root = doc.documentElement();
if(root.tagName() == QString::fromUtf8("html")){ if(root.tagName() == QString::fromUtf8("html")){
@ -493,10 +509,13 @@ class RssStream : public QObject{
image = property.text(); image = property.text();
else if(property.tagName() == "item") { else if(property.tagName() == "item") {
RssItem * item = new RssItem(property); 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); listItem.append(item);
else } else {
delete item; delete item;
}
} }
property = property.nextSibling().toElement(); property = property.nextSibling().toElement();
} }

Loading…
Cancel
Save