mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-22 04:24:23 +00:00
Added back support for RSS download rules export
This commit is contained in:
parent
e824bc8bb1
commit
265ab7bef2
@ -10,6 +10,7 @@
|
||||
- FEATURE: Bring up the connection settings when clicking on the connection status icon
|
||||
- COSMETIC: Replaced message box by on-screen notification for download errors
|
||||
- COSMETIC: Improved the torrent creation tool appearance
|
||||
- OTHERS: Dropped support for Qt <= 4.4
|
||||
|
||||
* Tue Aug 24 2010 - Christophe Dumez <chris@qbittorrent.org> - v2.4.0
|
||||
- FEATURE: Added actions to "Move to top/bottom" of priority queue
|
||||
|
@ -216,7 +216,7 @@ void AutomatedRssDownloader::saveCurrentRule(QListWidgetItem * item)
|
||||
rule.setLabel(ui->comboLabel->currentText());
|
||||
// Save new label
|
||||
if(!rule.label().isEmpty())
|
||||
Preferences::addTorrentLabel(rule.label());
|
||||
Preferences::addTorrentLabel(rule.label());
|
||||
rule.setRssFeeds(getSelectedFeeds());
|
||||
// Save it
|
||||
m_ruleList->saveRule(rule);
|
||||
@ -259,3 +259,25 @@ void AutomatedRssDownloader::on_browseSP_clicked()
|
||||
if(!save_path.isEmpty())
|
||||
ui->lineSavePath->setText(save_path);
|
||||
}
|
||||
|
||||
void AutomatedRssDownloader::on_exportBtn_clicked()
|
||||
{
|
||||
if(m_ruleList->isEmpty()) {
|
||||
QMessageBox::warning(this, tr("Invalid action"), tr("The list is empty, there is nothing to export."));
|
||||
return;
|
||||
}
|
||||
// Ask for a save path
|
||||
QString save_path = QFileDialog::getSaveFileName(this, tr("Where would you like to save the list?"), QDir::homePath(), tr("Rule list (*.rssrules *.filters)"));
|
||||
if(save_path.isEmpty()) return;
|
||||
if(!save_path.endsWith(".rssrules", Qt::CaseInsensitive))
|
||||
save_path += ".rssrules";
|
||||
if(!m_ruleList->serialize(save_path)) {
|
||||
QMessageBox::warning(this, tr("I/O Error"), tr("Failed to create the destination file"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void AutomatedRssDownloader::on_importBtn_clicked()
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
@ -64,6 +64,10 @@ private slots:
|
||||
void on_removeRuleBtn_clicked();
|
||||
void on_browseSP_clicked();
|
||||
|
||||
void on_exportBtn_clicked();
|
||||
|
||||
void on_importBtn_clicked();
|
||||
|
||||
private:
|
||||
RssDownloadRule getCurrentRule() const;
|
||||
void initLabelCombobox();
|
||||
|
@ -28,6 +28,8 @@
|
||||
* Contact : chris@qbittorrent.org
|
||||
*/
|
||||
|
||||
#include <QFile>
|
||||
|
||||
#include "rssdownloadrulelist.h"
|
||||
#include "qinisettings.h"
|
||||
|
||||
@ -135,7 +137,7 @@ void RssDownloadRuleList::removeRule(const QString &name)
|
||||
const RssDownloadRule rule = m_rules.take(name);
|
||||
// Update feedRules hashtable
|
||||
foreach(const QString &feed_url, rule.rssFeeds()) {
|
||||
m_feedRules[feed_url].removeOne(rule.name());
|
||||
m_feedRules[feed_url].removeOne(rule.name());
|
||||
}
|
||||
// Save rules
|
||||
saveRulesToStorage();
|
||||
@ -158,7 +160,7 @@ void RssDownloadRuleList::renameRule(const QString &old_name, const QString &new
|
||||
m_rules.insert(new_name, rule);
|
||||
// Update feedRules hashtable
|
||||
foreach(const QString &feed_url, rule.rssFeeds()) {
|
||||
m_feedRules[feed_url].replace(m_feedRules[feed_url].indexOf(old_name), new_name);
|
||||
m_feedRules[feed_url].replace(m_feedRules[feed_url].indexOf(old_name), new_name);
|
||||
}
|
||||
// Save rules
|
||||
saveRulesToStorage();
|
||||
@ -168,3 +170,17 @@ RssDownloadRule RssDownloadRuleList::getRule(const QString &name) const
|
||||
{
|
||||
return m_rules.value(name);
|
||||
}
|
||||
|
||||
bool RssDownloadRuleList::serialize(const QString& path)
|
||||
{
|
||||
QFile f(path);
|
||||
if(f.open(QIODevice::WriteOnly)) {
|
||||
QDataStream out(&f);
|
||||
out.setVersion(QDataStream::Qt_4_5);
|
||||
out << toVariantHash();
|
||||
f.close();
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -57,6 +57,8 @@ public:
|
||||
void renameRule(const QString &old_name, const QString &new_name);
|
||||
RssDownloadRule getRule(const QString &name) const;
|
||||
inline QStringList ruleNames() const { return m_rules.keys(); }
|
||||
inline bool isEmpty() const { return m_rules.isEmpty(); }
|
||||
bool serialize(const QString& path);
|
||||
|
||||
private:
|
||||
void loadRulesFromStorage();
|
||||
|
Loading…
x
Reference in New Issue
Block a user