mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-31 20:58:07 -06:00
Fix coding style (Issue #2192).
This commit is contained in:
committed by
Vladimir Golovnev (qlassez)
parent
405b06319d
commit
67758cb092
@@ -1,6 +1,7 @@
|
||||
/*
|
||||
* Bittorrent Client using Qt4 and libtorrent.
|
||||
* Copyright (C) 2010 Christophe Dumez, Arnaud Demaiziere
|
||||
* Bittorrent Client using Qt and libtorrent.
|
||||
* Copyright (C) 2010 Christophe Dumez <chris@qbittorrent.org>
|
||||
* Copyright (C) 2010 Arnaud Demaiziere <arnaud@qbittorrent.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
@@ -30,8 +31,8 @@
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
#include "base/logger.h"
|
||||
#include "base/preferences.h"
|
||||
#include "base/bittorrent/session.h"
|
||||
#include "rssfeed.h"
|
||||
#include "rssarticle.h"
|
||||
#include "rssdownloadrulelist.h"
|
||||
@@ -40,122 +41,124 @@
|
||||
|
||||
static const int MSECS_PER_MIN = 60000;
|
||||
|
||||
RssManager::RssManager():
|
||||
m_downloadRules(new RssDownloadRuleList),
|
||||
m_rssParser(new RssParser(this))
|
||||
RssManager::RssManager()
|
||||
: m_downloadRules(new RssDownloadRuleList)
|
||||
, m_rssParser(new RssParser(this))
|
||||
{
|
||||
connect(&m_refreshTimer, SIGNAL(timeout()), SLOT(refresh()));
|
||||
m_refreshInterval = Preferences::instance()->getRSSRefreshInterval();
|
||||
m_refreshTimer.start(m_refreshInterval * MSECS_PER_MIN);
|
||||
connect(&m_refreshTimer, SIGNAL(timeout()), SLOT(refresh()));
|
||||
m_refreshInterval = Preferences::instance()->getRSSRefreshInterval();
|
||||
m_refreshTimer.start(m_refreshInterval * MSECS_PER_MIN);
|
||||
}
|
||||
|
||||
RssManager::~RssManager()
|
||||
{
|
||||
qDebug("Deleting RSSManager...");
|
||||
delete m_downloadRules;
|
||||
delete m_rssParser;
|
||||
saveItemsToDisk();
|
||||
saveStreamList();
|
||||
qDebug("RSSManager deleted");
|
||||
qDebug("Deleting RSSManager...");
|
||||
delete m_downloadRules;
|
||||
delete m_rssParser;
|
||||
saveItemsToDisk();
|
||||
saveStreamList();
|
||||
qDebug("RSSManager deleted");
|
||||
}
|
||||
|
||||
RssParser* RssManager::rssParser() const
|
||||
RssParser *RssManager::rssParser() const
|
||||
{
|
||||
return m_rssParser;
|
||||
return m_rssParser;
|
||||
}
|
||||
|
||||
void RssManager::updateRefreshInterval(uint val)
|
||||
{
|
||||
if (m_refreshInterval != val) {
|
||||
m_refreshInterval = val;
|
||||
m_refreshTimer.start(m_refreshInterval*60000);
|
||||
qDebug("New RSS refresh interval is now every %dmin", m_refreshInterval);
|
||||
}
|
||||
if (m_refreshInterval != val) {
|
||||
m_refreshInterval = val;
|
||||
m_refreshTimer.start(m_refreshInterval*60000);
|
||||
qDebug("New RSS refresh interval is now every %dmin", m_refreshInterval);
|
||||
}
|
||||
}
|
||||
|
||||
void RssManager::loadStreamList()
|
||||
{
|
||||
const Preferences* const pref = Preferences::instance();
|
||||
const QStringList streamsUrl = pref->getRssFeedsUrls();
|
||||
const QStringList aliases = pref->getRssFeedsAliases();
|
||||
if (streamsUrl.size() != aliases.size()) {
|
||||
std::cerr << "Corrupted Rss list, not loading it\n";
|
||||
return;
|
||||
}
|
||||
uint i = 0;
|
||||
qDebug() << Q_FUNC_INFO << streamsUrl;
|
||||
foreach (QString s, streamsUrl) {
|
||||
QStringList path = s.split("\\", QString::SkipEmptyParts);
|
||||
if (path.empty()) continue;
|
||||
const QString feed_url = path.takeLast();
|
||||
qDebug() << "Feed URL:" << feed_url;
|
||||
// Create feed path (if it does not exists)
|
||||
RssFolder* feed_parent = this;
|
||||
foreach (const QString &folder_name, path) {
|
||||
qDebug() << "Adding parent folder:" << folder_name;
|
||||
feed_parent = feed_parent->addFolder(folder_name).data();
|
||||
const Preferences *const pref = Preferences::instance();
|
||||
const QStringList streamsUrl = pref->getRssFeedsUrls();
|
||||
const QStringList aliases = pref->getRssFeedsAliases();
|
||||
if (streamsUrl.size() != aliases.size()) {
|
||||
Logger::instance()->addMessage("Corrupted RSS list, not loading it.", Log::WARNING);
|
||||
return;
|
||||
}
|
||||
// Create feed
|
||||
qDebug() << "Adding feed to parent folder";
|
||||
RssFeedPtr stream = feed_parent->addStream(this, feed_url);
|
||||
const QString& alias = aliases[i];
|
||||
if (!alias.isEmpty()) {
|
||||
stream->rename(alias);
|
||||
|
||||
uint i = 0;
|
||||
qDebug() << Q_FUNC_INFO << streamsUrl;
|
||||
foreach (QString s, streamsUrl) {
|
||||
QStringList path = s.split("\\", QString::SkipEmptyParts);
|
||||
if (path.empty()) continue;
|
||||
|
||||
const QString feedUrl = path.takeLast();
|
||||
qDebug() << "Feed URL:" << feedUrl;
|
||||
// Create feed path (if it does not exists)
|
||||
RssFolder *feedParent = this;
|
||||
foreach (const QString &folderName, path) {
|
||||
qDebug() << "Adding parent folder:" << folderName;
|
||||
feedParent = feedParent->addFolder(folderName).data();
|
||||
}
|
||||
// Create feed
|
||||
qDebug() << "Adding feed to parent folder";
|
||||
RssFeedPtr stream = feedParent->addStream(this, feedUrl);
|
||||
const QString &alias = aliases[i];
|
||||
if (!alias.isEmpty())
|
||||
stream->rename(alias);
|
||||
++i;
|
||||
}
|
||||
++i;
|
||||
}
|
||||
qDebug("NB RSS streams loaded: %d", streamsUrl.size());
|
||||
qDebug("NB RSS streams loaded: %d", streamsUrl.size());
|
||||
}
|
||||
|
||||
void RssManager::forwardFeedContentChanged(const QString& url)
|
||||
void RssManager::forwardFeedContentChanged(const QString &url)
|
||||
{
|
||||
emit feedContentChanged(url);
|
||||
emit feedContentChanged(url);
|
||||
}
|
||||
|
||||
void RssManager::forwardFeedInfosChanged(const QString& url, const QString& displayName, uint unreadCount)
|
||||
void RssManager::forwardFeedInfosChanged(const QString &url, const QString &displayName, uint unreadCount)
|
||||
{
|
||||
emit feedInfosChanged(url, displayName, unreadCount);
|
||||
emit feedInfosChanged(url, displayName, unreadCount);
|
||||
}
|
||||
|
||||
void RssManager::forwardFeedIconChanged(const QString& url, const QString& iconPath)
|
||||
void RssManager::forwardFeedIconChanged(const QString &url, const QString &iconPath)
|
||||
{
|
||||
emit feedIconChanged(url, iconPath);
|
||||
emit feedIconChanged(url, iconPath);
|
||||
}
|
||||
|
||||
void RssManager::moveFile(const RssFilePtr& file, const RssFolderPtr& destinationFolder)
|
||||
void RssManager::moveFile(const RssFilePtr &file, const RssFolderPtr &destinationFolder)
|
||||
{
|
||||
RssFolder* src_folder = file->parent();
|
||||
if (destinationFolder != src_folder) {
|
||||
// Remove reference in old folder
|
||||
src_folder->takeChild(file->id());
|
||||
// add to new Folder
|
||||
destinationFolder->addFile(file);
|
||||
} else {
|
||||
qDebug("Nothing to move, same destination folder");
|
||||
}
|
||||
RssFolder *srcFolder = file->parent();
|
||||
if (destinationFolder != srcFolder) {
|
||||
// Remove reference in old folder
|
||||
srcFolder->takeChild(file->id());
|
||||
// add to new Folder
|
||||
destinationFolder->addFile(file);
|
||||
}
|
||||
else {
|
||||
qDebug("Nothing to move, same destination folder");
|
||||
}
|
||||
}
|
||||
|
||||
void RssManager::saveStreamList() const
|
||||
{
|
||||
QStringList streamsUrl;
|
||||
QStringList aliases;
|
||||
RssFeedList streams = getAllFeeds();
|
||||
foreach (const RssFeedPtr& stream, streams) {
|
||||
// This backslash has nothing to do with path handling
|
||||
QString stream_path = stream->pathHierarchy().join("\\");
|
||||
if (stream_path.isNull())
|
||||
stream_path = "";
|
||||
qDebug("Saving stream path: %s", qPrintable(stream_path));
|
||||
streamsUrl << stream_path;
|
||||
aliases << stream->displayName();
|
||||
}
|
||||
Preferences* const pref = Preferences::instance();
|
||||
pref->setRssFeedsUrls(streamsUrl);
|
||||
pref->setRssFeedsAliases(aliases);
|
||||
QStringList streamsUrl;
|
||||
QStringList aliases;
|
||||
RssFeedList streams = getAllFeeds();
|
||||
foreach (const RssFeedPtr &stream, streams) {
|
||||
// This backslash has nothing to do with path handling
|
||||
QString streamPath = stream->pathHierarchy().join("\\");
|
||||
if (streamPath.isNull())
|
||||
streamPath = "";
|
||||
qDebug("Saving stream path: %s", qPrintable(streamPath));
|
||||
streamsUrl << streamPath;
|
||||
aliases << stream->displayName();
|
||||
}
|
||||
Preferences *const pref = Preferences::instance();
|
||||
pref->setRssFeedsUrls(streamsUrl);
|
||||
pref->setRssFeedsAliases(aliases);
|
||||
}
|
||||
|
||||
RssDownloadRuleList* RssManager::downloadRules() const
|
||||
RssDownloadRuleList *RssManager::downloadRules() const
|
||||
{
|
||||
Q_ASSERT(m_downloadRules);
|
||||
return m_downloadRules;
|
||||
Q_ASSERT(m_downloadRules);
|
||||
return m_downloadRules;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user