mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-20 15:37:26 -06:00
Added back support for RSS download rules import
Fix rule deletion
This commit is contained in:
@@ -29,6 +29,7 @@
|
||||
*/
|
||||
|
||||
#include <QFile>
|
||||
#include <QDebug>
|
||||
|
||||
#include "rssdownloadrulelist.h"
|
||||
#include "qinisettings.h"
|
||||
@@ -133,6 +134,7 @@ void RssDownloadRuleList::saveRule(const RssDownloadRule &rule)
|
||||
|
||||
void RssDownloadRuleList::removeRule(const QString &name)
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO << name;
|
||||
if(!m_rules.contains(name)) return;
|
||||
const RssDownloadRule rule = m_rules.take(name);
|
||||
// Update feedRules hashtable
|
||||
@@ -184,3 +186,29 @@ bool RssDownloadRuleList::serialize(const QString& path)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool RssDownloadRuleList::unserialize(const QString &path)
|
||||
{
|
||||
QFile f(path);
|
||||
if(f.open(QIODevice::ReadOnly)) {
|
||||
QDataStream in(&f);
|
||||
if(path.endsWith(".filters")) {
|
||||
// Old format (< 2.5.0)
|
||||
in.setVersion(QDataStream::Qt_4_3);
|
||||
QVariantHash tmp;
|
||||
in >> tmp;
|
||||
f.close();
|
||||
if(tmp.isEmpty()) return false;
|
||||
importRulesInOldFormat(tmp);
|
||||
} else {
|
||||
in.setVersion(QDataStream::Qt_4_5);
|
||||
QVariantHash tmp;
|
||||
in >> tmp;
|
||||
f.close();
|
||||
if(tmp.isEmpty()) return false;
|
||||
loadRulesFromVariantHash(tmp);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user