Browse Source

RSS code clean up

adaptive-webui-19844
Christophe Dumez 12 years ago
parent
commit
82fbb351dd
  1. 34
      src/rss/rssmanager.cpp
  2. 14
      src/rss/rssmanager.h

34
src/rss/rssmanager.cpp

@ -48,7 +48,8 @@ RssManager::RssManager():
m_refreshTimer.start(m_refreshInterval*60000); m_refreshTimer.start(m_refreshInterval*60000);
} }
RssManager::~RssManager() { RssManager::~RssManager()
{
qDebug("Deleting RSSManager..."); qDebug("Deleting RSSManager...");
delete m_downloadRules; delete m_downloadRules;
delete m_rssParser; delete m_rssParser;
@ -67,7 +68,8 @@ RssParser* RssManager::rssParser() const
return m_rssParser; return m_rssParser;
} }
void RssManager::updateRefreshInterval(uint val) { void RssManager::updateRefreshInterval(uint val)
{
if (m_refreshInterval != val) { if (m_refreshInterval != val) {
m_refreshInterval = val; m_refreshInterval = val;
m_refreshTimer.start(m_refreshInterval*60000); m_refreshTimer.start(m_refreshInterval*60000);
@ -75,7 +77,8 @@ void RssManager::updateRefreshInterval(uint val) {
} }
} }
void RssManager::loadStreamList() { void RssManager::loadStreamList()
{
RssSettings settings; RssSettings settings;
const QStringList streamsUrl = settings.getRssFeedsUrls(); const QStringList streamsUrl = settings.getRssFeedsUrls();
const QStringList aliases = settings.getRssFeedsAliases(); const QStringList aliases = settings.getRssFeedsAliases();
@ -113,35 +116,38 @@ void RssManager::forwardFeedContentChanged(const QString& url)
emit feedContentChanged(url); emit feedContentChanged(url);
} }
void RssManager::forwardFeedInfosChanged(const QString &url, const QString &display_name, uint nbUnread) { void RssManager::forwardFeedInfosChanged(const QString& url, const QString& displayName, uint unreadCount)
emit feedInfosChanged(url, display_name, nbUnread); {
emit feedInfosChanged(url, displayName, unreadCount);
} }
void RssManager::forwardFeedIconChanged(const QString &url, const QString &icon_path) { void RssManager::forwardFeedIconChanged(const QString& url, const QString& iconPath)
emit feedIconChanged(url, icon_path); {
emit feedIconChanged(url, iconPath);
} }
void RssManager::moveFile(const RssFilePtr& file, const RssFolderPtr& dest_folder) { void RssManager::moveFile(const RssFilePtr& file, const RssFolderPtr& destinationFolder)
{
RssFolder* src_folder = file->parent(); RssFolder* src_folder = file->parent();
if (dest_folder != src_folder) { if (destinationFolder != src_folder) {
// Remove reference in old folder // Remove reference in old folder
src_folder->takeChild(file->id()); src_folder->takeChild(file->id());
// add to new Folder // add to new Folder
dest_folder->addFile(file); destinationFolder->addFile(file);
} else { } else {
qDebug("Nothing to move, same destination folder"); qDebug("Nothing to move, same destination folder");
} }
} }
void RssManager::saveStreamList() const { void RssManager::saveStreamList() const
{
QStringList streamsUrl; QStringList streamsUrl;
QStringList aliases; QStringList aliases;
RssFeedList streams = getAllFeeds(); RssFeedList streams = getAllFeeds();
foreach (const RssFeedPtr& stream, streams) { foreach (const RssFeedPtr& stream, streams) {
QString stream_path = stream->pathHierarchy().join("\\"); QString stream_path = stream->pathHierarchy().join("\\");
if (stream_path.isNull()) { if (stream_path.isNull())
stream_path = ""; stream_path = "";
}
qDebug("Saving stream path: %s", qPrintable(stream_path)); qDebug("Saving stream path: %s", qPrintable(stream_path));
streamsUrl << stream_path; streamsUrl << stream_path;
aliases << stream->displayName(); aliases << stream->displayName();
@ -151,7 +157,7 @@ void RssManager::saveStreamList() const {
settings.setRssFeedsAliases(aliases); settings.setRssFeedsAliases(aliases);
} }
RssDownloadRuleList *RssManager::downloadRules() const RssDownloadRuleList* RssManager::downloadRules() const
{ {
Q_ASSERT(m_downloadRules); Q_ASSERT(m_downloadRules);
return m_downloadRules; return m_downloadRules;

14
src/rss/rssmanager.h

@ -59,21 +59,21 @@ public slots:
void loadStreamList(); void loadStreamList();
void saveStreamList() const; void saveStreamList() const;
void forwardFeedContentChanged(const QString& url); void forwardFeedContentChanged(const QString& url);
void forwardFeedInfosChanged(const QString &url, const QString &aliasOrUrl, uint nbUnread); void forwardFeedInfosChanged(const QString& url, const QString& displayName, uint unreadCount);
void forwardFeedIconChanged(const QString &url, const QString &icon_path); void forwardFeedIconChanged(const QString& url, const QString& iconPath);
void moveFile(const RssFilePtr& file, const RssFolderPtr& dest_folder); void moveFile(const RssFilePtr& file, const RssFolderPtr& destinationFolder);
void updateRefreshInterval(uint val); void updateRefreshInterval(uint val);
signals: signals:
void feedContentChanged(const QString& url); void feedContentChanged(const QString& url);
void feedInfosChanged(const QString &url, const QString &display_name, uint nbUnread); void feedInfosChanged(const QString& url, const QString& displayName, uint unreadCount);
void feedIconChanged(const QString &url, const QString &icon_path); void feedIconChanged(const QString& url, const QString& iconPath);
private: private:
QTimer m_refreshTimer; QTimer m_refreshTimer;
uint m_refreshInterval; uint m_refreshInterval;
DownloadThread *m_rssDownloader; DownloadThread* m_rssDownloader;
RssDownloadRuleList *m_downloadRules; RssDownloadRuleList* m_downloadRules;
RssParser* m_rssParser; RssParser* m_rssParser;
}; };

Loading…
Cancel
Save