Christophe Dumez
14 years ago
94 changed files with 8288 additions and 4855 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,56 @@
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Bittorrent Client using Qt4 and libtorrent. |
||||
* Copyright (C) 2010 Christophe Dumez |
||||
* |
||||
* This program is free software; you can redistribute it and/or |
||||
* modify it under the terms of the GNU General Public License |
||||
* as published by the Free Software Foundation; either version 2 |
||||
* of the License, or (at your option) any later version. |
||||
* |
||||
* This program is distributed in the hope that it will be useful, |
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
* GNU General Public License for more details. |
||||
* |
||||
* You should have received a copy of the GNU General Public License |
||||
* along with this program; if not, write to the Free Software |
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
||||
* |
||||
* In addition, as a special exception, the copyright holders give permission to |
||||
* link this program with the OpenSSL project's "OpenSSL" library (or with |
||||
* modified versions of it that use the same license as the "OpenSSL" library), |
||||
* and distribute the linked executables. You must obey the GNU General Public |
||||
* License in all respects for all of the code used other than "OpenSSL". If you |
||||
* modify file(s), you may extend this exception to your version of the file(s), |
||||
* but you are not obligated to do so. If you do not wish to do so, delete this |
||||
* exception statement from your version. |
||||
* |
||||
* Contact : chris@qbittorrent.org |
||||
*/ |
||||
|
||||
#ifndef AUTOMATEDRSSDOWNLOADER_H |
||||
#define AUTOMATEDRSSDOWNLOADER_H |
||||
|
||||
#include <QDialog> |
||||
|
||||
namespace Ui { |
||||
class AutomatedRssDownloader; |
||||
} |
||||
|
||||
class AutomatedRssDownloader : public QDialog |
||||
{ |
||||
Q_OBJECT |
||||
|
||||
public: |
||||
explicit AutomatedRssDownloader(QWidget *parent = 0); |
||||
~AutomatedRssDownloader(); |
||||
|
||||
protected slots: |
||||
void loadSettings(); |
||||
void saveSettings(); |
||||
|
||||
private: |
||||
Ui::AutomatedRssDownloader *ui; |
||||
}; |
||||
|
||||
#endif // AUTOMATEDRSSDOWNLOADER_H
|
@ -0,0 +1,310 @@
@@ -0,0 +1,310 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<ui version="4.0"> |
||||
<class>AutomatedRssDownloader</class> |
||||
<widget class="QDialog" name="AutomatedRssDownloader"> |
||||
<property name="geometry"> |
||||
<rect> |
||||
<x>0</x> |
||||
<y>0</y> |
||||
<width>816</width> |
||||
<height>494</height> |
||||
</rect> |
||||
</property> |
||||
<property name="windowTitle"> |
||||
<string>Automated RSS Downloader</string> |
||||
</property> |
||||
<layout class="QVBoxLayout" name="verticalLayout_4"> |
||||
<item> |
||||
<widget class="QCheckBox" name="checkEnableDownloader"> |
||||
<property name="font"> |
||||
<font> |
||||
<weight>75</weight> |
||||
<bold>true</bold> |
||||
</font> |
||||
</property> |
||||
<property name="text"> |
||||
<string>Enable the automated RSS downloader</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item> |
||||
<layout class="QHBoxLayout" name="horizontalLayout_3"> |
||||
<item> |
||||
<layout class="QVBoxLayout" name="verticalLayout_3"> |
||||
<item> |
||||
<layout class="QHBoxLayout" name="horizontalLayout_2"> |
||||
<item> |
||||
<widget class="QLabel" name="label"> |
||||
<property name="font"> |
||||
<font> |
||||
<weight>75</weight> |
||||
<bold>true</bold> |
||||
</font> |
||||
</property> |
||||
<property name="text"> |
||||
<string>Download rules</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item> |
||||
<spacer name="horizontalSpacer"> |
||||
<property name="orientation"> |
||||
<enum>Qt::Horizontal</enum> |
||||
</property> |
||||
<property name="sizeType"> |
||||
<enum>QSizePolicy::Expanding</enum> |
||||
</property> |
||||
<property name="sizeHint" stdset="0"> |
||||
<size> |
||||
<width>40</width> |
||||
<height>20</height> |
||||
</size> |
||||
</property> |
||||
</spacer> |
||||
</item> |
||||
<item> |
||||
<widget class="QToolButton" name="removeRuleBtn"> |
||||
<property name="text"> |
||||
<string/> |
||||
</property> |
||||
<property name="icon"> |
||||
<iconset resource="../icons.qrc"> |
||||
<normaloff>:/Icons/oxygen/list-remove.png</normaloff>:/Icons/oxygen/list-remove.png</iconset> |
||||
</property> |
||||
<property name="iconSize"> |
||||
<size> |
||||
<width>24</width> |
||||
<height>20</height> |
||||
</size> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item> |
||||
<widget class="QToolButton" name="addRuleBtn"> |
||||
<property name="text"> |
||||
<string/> |
||||
</property> |
||||
<property name="icon"> |
||||
<iconset resource="../icons.qrc"> |
||||
<normaloff>:/Icons/oxygen/list-add.png</normaloff>:/Icons/oxygen/list-add.png</iconset> |
||||
</property> |
||||
<property name="iconSize"> |
||||
<size> |
||||
<width>24</width> |
||||
<height>20</height> |
||||
</size> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item> |
||||
<spacer name="horizontalSpacer_2"> |
||||
<property name="orientation"> |
||||
<enum>Qt::Horizontal</enum> |
||||
</property> |
||||
<property name="sizeHint" stdset="0"> |
||||
<size> |
||||
<width>40</width> |
||||
<height>20</height> |
||||
</size> |
||||
</property> |
||||
</spacer> |
||||
</item> |
||||
</layout> |
||||
</item> |
||||
<item> |
||||
<widget class="QListWidget" name="listRules"/> |
||||
</item> |
||||
</layout> |
||||
</item> |
||||
<item> |
||||
<widget class="Line" name="line"> |
||||
<property name="orientation"> |
||||
<enum>Qt::Vertical</enum> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item> |
||||
<widget class="QGroupBox" name="ruleDefBox"> |
||||
<property name="title"> |
||||
<string>Rule definition</string> |
||||
</property> |
||||
<layout class="QGridLayout" name="gridLayout"> |
||||
<property name="leftMargin"> |
||||
<number>0</number> |
||||
</property> |
||||
<property name="bottomMargin"> |
||||
<number>0</number> |
||||
</property> |
||||
<item row="0" column="0"> |
||||
<widget class="QLabel" name="label_4"> |
||||
<property name="text"> |
||||
<string>Must contain:</string> |
||||
</property> |
||||
<property name="alignment"> |
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item row="0" column="1"> |
||||
<widget class="QLineEdit" name="lineContains"/> |
||||
</item> |
||||
<item row="1" column="0"> |
||||
<widget class="QLabel" name="label_5"> |
||||
<property name="text"> |
||||
<string>Must not contain:</string> |
||||
</property> |
||||
<property name="alignment"> |
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item row="1" column="1"> |
||||
<widget class="QLineEdit" name="lineNotContains"/> |
||||
</item> |
||||
<item row="2" column="0"> |
||||
<widget class="QLabel" name="label_6"> |
||||
<property name="text"> |
||||
<string>Save torrent to:</string> |
||||
</property> |
||||
<property name="alignment"> |
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item row="2" column="1"> |
||||
<layout class="QHBoxLayout" name="horizontalLayout"> |
||||
<item> |
||||
<widget class="QLineEdit" name="lineSavePath"/> |
||||
</item> |
||||
<item> |
||||
<widget class="QToolButton" name="browseSP"> |
||||
<property name="text"> |
||||
<string>...</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
</layout> |
||||
</item> |
||||
<item row="3" column="0"> |
||||
<widget class="QLabel" name="label_7"> |
||||
<property name="text"> |
||||
<string>Assign label:</string> |
||||
</property> |
||||
<property name="alignment"> |
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item row="3" column="1"> |
||||
<widget class="QComboBox" name="comboLabel"> |
||||
<property name="editable"> |
||||
<bool>true</bool> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item row="4" column="0" colspan="2"> |
||||
<layout class="QVBoxLayout" name="verticalLayout"> |
||||
<item> |
||||
<widget class="QLabel" name="label_2"> |
||||
<property name="font"> |
||||
<font> |
||||
<weight>50</weight> |
||||
<bold>false</bold> |
||||
</font> |
||||
</property> |
||||
<property name="text"> |
||||
<string>Apply rule to feeds:</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item> |
||||
<widget class="QListWidget" name="listFeeds"/> |
||||
</item> |
||||
</layout> |
||||
</item> |
||||
</layout> |
||||
</widget> |
||||
</item> |
||||
<item> |
||||
<widget class="Line" name="line_2"> |
||||
<property name="orientation"> |
||||
<enum>Qt::Vertical</enum> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item> |
||||
<layout class="QVBoxLayout" name="verticalLayout_2"> |
||||
<item> |
||||
<widget class="QLabel" name="label_3"> |
||||
<property name="font"> |
||||
<font> |
||||
<weight>75</weight> |
||||
<bold>true</bold> |
||||
</font> |
||||
</property> |
||||
<property name="text"> |
||||
<string>Matching RSS articles</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item> |
||||
<widget class="QListWidget" name="listMatchingArticles"> |
||||
<property name="enabled"> |
||||
<bool>false</bool> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
</layout> |
||||
</item> |
||||
</layout> |
||||
</item> |
||||
<item> |
||||
<widget class="QDialogButtonBox" name="buttonBox"> |
||||
<property name="orientation"> |
||||
<enum>Qt::Horizontal</enum> |
||||
</property> |
||||
<property name="standardButtons"> |
||||
<set>QDialogButtonBox::Close</set> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
</layout> |
||||
</widget> |
||||
<resources> |
||||
<include location="../icons.qrc"/> |
||||
</resources> |
||||
<connections> |
||||
<connection> |
||||
<sender>buttonBox</sender> |
||||
<signal>accepted()</signal> |
||||
<receiver>AutomatedRssDownloader</receiver> |
||||
<slot>accept()</slot> |
||||
<hints> |
||||
<hint type="sourcelabel"> |
||||
<x>248</x> |
||||
<y>254</y> |
||||
</hint> |
||||
<hint type="destinationlabel"> |
||||
<x>157</x> |
||||
<y>274</y> |
||||
</hint> |
||||
</hints> |
||||
</connection> |
||||
<connection> |
||||
<sender>buttonBox</sender> |
||||
<signal>rejected()</signal> |
||||
<receiver>AutomatedRssDownloader</receiver> |
||||
<slot>reject()</slot> |
||||
<hints> |
||||
<hint type="sourcelabel"> |
||||
<x>316</x> |
||||
<y>260</y> |
||||
</hint> |
||||
<hint type="destinationlabel"> |
||||
<x>286</x> |
||||
<y>274</y> |
||||
</hint> |
||||
</hints> |
||||
</connection> |
||||
</connections> |
||||
</ui> |
@ -0,0 +1,87 @@
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* Bittorrent Client using Qt4 and libtorrent. |
||||
* Copyright (C) 2010 Christophe Dumez |
||||
* |
||||
* This program is free software; you can redistribute it and/or |
||||
* modify it under the terms of the GNU General Public License |
||||
* as published by the Free Software Foundation; either version 2 |
||||
* of the License, or (at your option) any later version. |
||||
* |
||||
* This program is distributed in the hope that it will be useful, |
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
* GNU General Public License for more details. |
||||
* |
||||
* You should have received a copy of the GNU General Public License |
||||
* along with this program; if not, write to the Free Software |
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
||||
* |
||||
* In addition, as a special exception, the copyright holders give permission to |
||||
* link this program with the OpenSSL project's "OpenSSL" library (or with |
||||
* modified versions of it that use the same license as the "OpenSSL" library), |
||||
* and distribute the linked executables. You must obey the GNU General Public |
||||
* License in all respects for all of the code used other than "OpenSSL". If you |
||||
* modify file(s), you may extend this exception to your version of the file(s), |
||||
* but you are not obligated to do so. If you do not wish to do so, delete this |
||||
* exception statement from your version. |
||||
* |
||||
* Contact : chris@qbittorrent.org |
||||
*/ |
||||
|
||||
#include <QRegExp> |
||||
|
||||
#include "rssdownloadrule.h" |
||||
#include "qinisettings.h" |
||||
|
||||
RssDownloadRule::RssDownloadRule() |
||||
{ |
||||
} |
||||
|
||||
bool RssDownloadRule::matches(const QString &article_title) const |
||||
{ |
||||
foreach(const QString& token, m_mustContain) { |
||||
if(token.isEmpty() || token == "") |
||||
continue; |
||||
QRegExp reg(token, Qt::CaseInsensitive, QRegExp::Wildcard); |
||||
//reg.setMinimal(false);
|
||||
if(reg.indexIn(article_title) < 0) return false; |
||||
} |
||||
qDebug("Checking not matching tokens"); |
||||
// Checking not matching
|
||||
foreach(const QString& token, m_mustNotContain) { |
||||
if(token.isEmpty()) continue; |
||||
QRegExp reg(token, Qt::CaseInsensitive, QRegExp::Wildcard); |
||||
if(reg.indexIn(article_title) > -1) return false; |
||||
} |
||||
return true; |
||||
} |
||||
|
||||
void RssDownloadRule::setMustContain(const QString &tokens) |
||||
{ |
||||
m_mustContain = tokens.split(" "); |
||||
} |
||||
|
||||
void RssDownloadRule::setMustNotContain(const QString &tokens) |
||||
{ |
||||
m_mustNotContain = tokens.split(QRegExp("[\\s|]")); |
||||
} |
||||
|
||||
RssDownloadRule RssDownloadRule::fromOldFormat(const QHash<QString, QVariant> &rule_hash, const QString &feed_url, const QString &rule_name) |
||||
{ |
||||
RssDownloadRule rule; |
||||
rule.setName(rule_name); |
||||
rule.setMustContain(rule_hash.value("matches", "").toString()); |
||||
rule.setMustNotContain(rule_hash.value("not", "").toString()); |
||||
rule.setRssFeeds(QStringList() << feed_url); |
||||
rule.setSavePath(rule_hash.value("save_path", "").toString()); |
||||
// Is enabled?
|
||||
QIniSettings qBTRSS("qBittorrent", "qBittorrent-rss"); |
||||
const QHash<QString, QVariant> feeds_w_downloader = qBTRSS.value("downloader_on").toHash(); |
||||
rule.setEnabled(feeds_w_downloader.value(feed_url, false).toBool()); |
||||
// label was unsupported < 2.5.0
|
||||
return rule; |
||||
} |
||||
|
||||
bool RssDownloadRule::operator==(const RssDownloadRule &other) { |
||||
return m_name == other.name(); |
||||
} |
@ -0,0 +1,69 @@
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* Bittorrent Client using Qt4 and libtorrent. |
||||
* Copyright (C) 2010 Christophe Dumez |
||||
* |
||||
* This program is free software; you can redistribute it and/or |
||||
* modify it under the terms of the GNU General Public License |
||||
* as published by the Free Software Foundation; either version 2 |
||||
* of the License, or (at your option) any later version. |
||||
* |
||||
* This program is distributed in the hope that it will be useful, |
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
* GNU General Public License for more details. |
||||
* |
||||
* You should have received a copy of the GNU General Public License |
||||
* along with this program; if not, write to the Free Software |
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
||||
* |
||||
* In addition, as a special exception, the copyright holders give permission to |
||||
* link this program with the OpenSSL project's "OpenSSL" library (or with |
||||
* modified versions of it that use the same license as the "OpenSSL" library), |
||||
* and distribute the linked executables. You must obey the GNU General Public |
||||
* License in all respects for all of the code used other than "OpenSSL". If you |
||||
* modify file(s), you may extend this exception to your version of the file(s), |
||||
* but you are not obligated to do so. If you do not wish to do so, delete this |
||||
* exception statement from your version. |
||||
* |
||||
* Contact : chris@qbittorrent.org |
||||
*/ |
||||
|
||||
#ifndef RSSDOWNLOADRULE_H |
||||
#define RSSDOWNLOADRULE_H |
||||
|
||||
#include <QStringList> |
||||
#include <QHash> |
||||
|
||||
class RssDownloadRule |
||||
{ |
||||
|
||||
public: |
||||
explicit RssDownloadRule(); |
||||
static RssDownloadRule fromOldFormat(const QHash<QString, QVariant>& rule_hash, const QString &feed_url, const QString &rule_name); // Before v2.5.0
|
||||
bool matches(const QString &article_title) const; |
||||
void setMustContain(const QString &tokens); |
||||
void setMustNotContain(const QString &tokens); |
||||
inline QStringList rssFeeds() const { return m_rssFeeds; } |
||||
inline void setRssFeeds(const QStringList& rss_feeds) { m_rssFeeds = rss_feeds; } |
||||
inline QString name() const { return m_name; } |
||||
inline void setName(const QString &name) { m_name = name; } |
||||
inline QString savePath() const { return m_savePath; } |
||||
inline void setSavePath(const QString &save_path) { m_savePath = save_path; } |
||||
inline QString label() const { return m_label; } |
||||
inline void setLabel(const QString &_label) { m_label = _label; } |
||||
inline bool isEnabled() const { return m_enabled; } |
||||
inline void setEnabled(bool enable) { m_enabled = enable; } |
||||
// Operators
|
||||
bool operator==(const RssDownloadRule &other); |
||||
|
||||
private: |
||||
QString m_name; |
||||
QStringList m_mustContain; |
||||
QStringList m_mustNotContain; |
||||
QString m_savePath; |
||||
QString m_label; |
||||
bool m_enabled; |
||||
QStringList m_rssFeeds; |
||||
}; |
||||
|
||||
#endif // RSSDOWNLOADRULE_H
|
@ -0,0 +1,88 @@
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
* Bittorrent Client using Qt4 and libtorrent. |
||||
* Copyright (C) 2010 Christophe Dumez |
||||
* |
||||
* This program is free software; you can redistribute it and/or |
||||
* modify it under the terms of the GNU General Public License |
||||
* as published by the Free Software Foundation; either version 2 |
||||
* of the License, or (at your option) any later version. |
||||
* |
||||
* This program is distributed in the hope that it will be useful, |
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
* GNU General Public License for more details. |
||||
* |
||||
* You should have received a copy of the GNU General Public License |
||||
* along with this program; if not, write to the Free Software |
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
||||
* |
||||
* In addition, as a special exception, the copyright holders give permission to |
||||
* link this program with the OpenSSL project's "OpenSSL" library (or with |
||||
* modified versions of it that use the same license as the "OpenSSL" library), |
||||
* and distribute the linked executables. You must obey the GNU General Public |
||||
* License in all respects for all of the code used other than "OpenSSL". If you |
||||
* modify file(s), you may extend this exception to your version of the file(s), |
||||
* but you are not obligated to do so. If you do not wish to do so, delete this |
||||
* exception statement from your version. |
||||
* |
||||
* Contact : chris@qbittorrent.org |
||||
*/ |
||||
|
||||
#include "rssdownloadrulelist.h" |
||||
#include "qinisettings.h" |
||||
|
||||
RssDownloadRuleList* RssDownloadRuleList::m_instance = 0; |
||||
|
||||
RssDownloadRuleList::RssDownloadRuleList(){ |
||||
loadRulesFromStorage(); |
||||
} |
||||
|
||||
RssDownloadRuleList* RssDownloadRuleList::instance() |
||||
{ |
||||
if(!m_instance) |
||||
m_instance = new RssDownloadRuleList; |
||||
return m_instance; |
||||
} |
||||
|
||||
void RssDownloadRuleList::drop() |
||||
{ |
||||
if(m_instance) |
||||
delete m_instance; |
||||
} |
||||
|
||||
const RssDownloadRule * RssDownloadRuleList::findMatchingRule(const QString &feed_url, const QString &article_title) const |
||||
{ |
||||
const QList<RssDownloadRule*> rules = feedRules(feed_url); |
||||
foreach(const RssDownloadRule* rule, rules) { |
||||
if(rule->matches(article_title)) return rule; |
||||
} |
||||
return 0; |
||||
} |
||||
|
||||
void RssDownloadRuleList::loadRulesFromStorage() |
||||
{ |
||||
QIniSettings qBTRSS("qBittorrent", "qBittorrent-rss"); |
||||
if(qBTRSS.contains("feed_filters")) { |
||||
importRulesInOldFormat(qBTRSS.value("feed_filters").toHash()); |
||||
} |
||||
} |
||||
|
||||
void RssDownloadRuleList::importRulesInOldFormat(const QHash<QString, QVariant> &rules) |
||||
{ |
||||
foreach(const QString &feed_url, rules.keys()) { |
||||
const QHash<QString, QVariant> feed_rules = rules.value(feed_url).toHash(); |
||||
foreach(const QString &rule_name, feed_rules.keys()) { |
||||
const RssDownloadRule rule = RssDownloadRule::fromOldFormat(feed_rules.value(rule_name).toHash(), feed_url, rule_name); |
||||
append(rule); |
||||
} |
||||
} |
||||
} |
||||
|
||||
void RssDownloadRuleList::append(const RssDownloadRule &rule) |
||||
{ |
||||
Q_ASSERT(!contains(rule)); |
||||
QList<RssDownloadRule>::append(rule); |
||||
foreach(const QString &feed_url, rule.rssFeeds()) { |
||||
m_feedRules[feed_url].append(&last()); |
||||
} |
||||
} |
@ -0,0 +1,64 @@
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Bittorrent Client using Qt4 and libtorrent. |
||||
* Copyright (C) 2010 Christophe Dumez |
||||
* |
||||
* This program is free software; you can redistribute it and/or |
||||
* modify it under the terms of the GNU General Public License |
||||
* as published by the Free Software Foundation; either version 2 |
||||
* of the License, or (at your option) any later version. |
||||
* |
||||
* This program is distributed in the hope that it will be useful, |
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
* GNU General Public License for more details. |
||||
* |
||||
* You should have received a copy of the GNU General Public License |
||||
* along with this program; if not, write to the Free Software |
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
||||
* |
||||
* In addition, as a special exception, the copyright holders give permission to |
||||
* link this program with the OpenSSL project's "OpenSSL" library (or with |
||||
* modified versions of it that use the same license as the "OpenSSL" library), |
||||
* and distribute the linked executables. You must obey the GNU General Public |
||||
* License in all respects for all of the code used other than "OpenSSL". If you |
||||
* modify file(s), you may extend this exception to your version of the file(s), |
||||
* but you are not obligated to do so. If you do not wish to do so, delete this |
||||
* exception statement from your version. |
||||
* |
||||
* Contact : chris@qbittorrent.org |
||||
*/ |
||||
|
||||
#ifndef RSSDOWNLOADRULELIST_H |
||||
#define RSSDOWNLOADRULELIST_H |
||||
|
||||
#include <QList> |
||||
#include <QHash> |
||||
|
||||
#include "rssdownloadrule.h" |
||||
|
||||
// This class is not thread-safe (not required)
|
||||
class RssDownloadRuleList : public QList<RssDownloadRule> |
||||
{ |
||||
Q_DISABLE_COPY(RssDownloadRuleList) |
||||
|
||||
private: |
||||
explicit RssDownloadRuleList(); |
||||
static RssDownloadRuleList* m_instance; |
||||
|
||||
public: |
||||
static RssDownloadRuleList* instance(); |
||||
static void drop(); |
||||
const RssDownloadRule* findMatchingRule(const QString &feed_url, const QString &article_title) const; |
||||
inline QList<RssDownloadRule*> feedRules(const QString &feed_url) const { return m_feedRules.value(feed_url); } |
||||
void append(const RssDownloadRule& rule); |
||||
|
||||
private: |
||||
void loadRulesFromStorage(); |
||||
void importRulesInOldFormat(const QHash<QString, QVariant> &rules); // Before v2.5.0
|
||||
|
||||
private: |
||||
QHash<QString, QList<RssDownloadRule*> > m_feedRules; |
||||
|
||||
}; |
||||
|
||||
#endif // RSSDOWNLOADFILTERLIST_H
|
@ -0,0 +1,55 @@
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Bittorrent Client using Qt4 and libtorrent. |
||||
* Copyright (C) 2010 Christophe Dumez |
||||
* |
||||
* This program is free software; you can redistribute it and/or |
||||
* modify it under the terms of the GNU General Public License |
||||
* as published by the Free Software Foundation; either version 2 |
||||
* of the License, or (at your option) any later version. |
||||
* |
||||
* This program is distributed in the hope that it will be useful, |
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
* GNU General Public License for more details. |
||||
* |
||||
* You should have received a copy of the GNU General Public License |
||||
* along with this program; if not, write to the Free Software |
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
||||
* |
||||
* In addition, as a special exception, the copyright holders give permission to |
||||
* link this program with the OpenSSL project's "OpenSSL" library (or with |
||||
* modified versions of it that use the same license as the "OpenSSL" library), |
||||
* and distribute the linked executables. You must obey the GNU General Public |
||||
* License in all respects for all of the code used other than "OpenSSL". If you |
||||
* modify file(s), you may extend this exception to your version of the file(s), |
||||
* but you are not obligated to do so. If you do not wish to do so, delete this |
||||
* exception statement from your version. |
||||
* |
||||
* Contact : chris@qbittorrent.org |
||||
*/ |
||||
|
||||
#include "rsssettingsdlg.h" |
||||
#include "ui_rsssettingsdlg.h" |
||||
#include "rsssettings.h" |
||||
|
||||
RssSettingsDlg::RssSettingsDlg(QWidget *parent) : |
||||
QDialog(parent), |
||||
ui(new Ui::RssSettingsDlg) |
||||
{ |
||||
ui->setupUi(this); |
||||
// Load settings
|
||||
ui->spinRSSRefresh->setValue(RssSettings::getRSSRefreshInterval()); |
||||
ui->spinRSSMaxArticlesPerFeed->setValue(RssSettings::getRSSMaxArticlesPerFeed()); |
||||
} |
||||
|
||||
RssSettingsDlg::~RssSettingsDlg() |
||||
{ |
||||
qDebug("Deleting the RSS settings dialog"); |
||||
delete ui; |
||||
} |
||||
|
||||
void RssSettingsDlg::on_buttonBox_accepted() { |
||||
// Save settings
|
||||
RssSettings::setRSSRefreshInterval(ui->spinRSSRefresh->value()); |
||||
RssSettings::setRSSMaxArticlesPerFeed(ui->spinRSSMaxArticlesPerFeed->value()); |
||||
} |
@ -0,0 +1,56 @@
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Bittorrent Client using Qt4 and libtorrent. |
||||
* Copyright (C) 2010 Christophe Dumez |
||||
* |
||||
* This program is free software; you can redistribute it and/or |
||||
* modify it under the terms of the GNU General Public License |
||||
* as published by the Free Software Foundation; either version 2 |
||||
* of the License, or (at your option) any later version. |
||||
* |
||||
* This program is distributed in the hope that it will be useful, |
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
* GNU General Public License for more details. |
||||
* |
||||
* You should have received a copy of the GNU General Public License |
||||
* along with this program; if not, write to the Free Software |
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
||||
* |
||||
* In addition, as a special exception, the copyright holders give permission to |
||||
* link this program with the OpenSSL project's "OpenSSL" library (or with |
||||
* modified versions of it that use the same license as the "OpenSSL" library), |
||||
* and distribute the linked executables. You must obey the GNU General Public |
||||
* License in all respects for all of the code used other than "OpenSSL". If you |
||||
* modify file(s), you may extend this exception to your version of the file(s), |
||||
* but you are not obligated to do so. If you do not wish to do so, delete this |
||||
* exception statement from your version. |
||||
* |
||||
* Contact : chris@qbittorrent.org |
||||
*/ |
||||
|
||||
#ifndef RSSSETTINGSDLG_H |
||||
#define RSSSETTINGSDLG_H |
||||
|
||||
#include <QDialog> |
||||
|
||||
namespace Ui { |
||||
class RssSettingsDlg; |
||||
} |
||||
|
||||
class RssSettingsDlg : public QDialog |
||||
{ |
||||
Q_OBJECT |
||||
|
||||
public: |
||||
explicit RssSettingsDlg(QWidget *parent = 0); |
||||
~RssSettingsDlg(); |
||||
|
||||
protected slots: |
||||
void on_buttonBox_accepted(); |
||||
|
||||
private: |
||||
Ui::RssSettingsDlg *ui; |
||||
|
||||
}; |
||||
|
||||
#endif // RSSSETTINGS_H
|
Loading…
Reference in new issue