Added back support for RSS download rules import

Fix rule deletion
This commit is contained in:
Christophe Dumez
2010-11-13 12:33:52 +00:00
parent 265ab7bef2
commit d7b0299416
4 changed files with 43 additions and 4 deletions

View File

@@ -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;
}