mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-02-02 18:04:32 +00:00
- RSS items read status is now remembered upon startup
This commit is contained in:
parent
aa18f19ab7
commit
54bfb7cda9
23
src/rss.h
23
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();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user