Browse Source

RSS code clean up

adaptive-webui-19844
Christophe Dumez 12 years ago
parent
commit
0d1f9fcc58
  1. 22
      src/rss/rss_imp.cpp
  2. 2
      src/rss/rss_imp.h
  3. 5
      src/rss/rssfeed.cpp
  4. 2
      src/rss/rssfeed.h
  5. 2
      src/rss/rssfile.h
  6. 7
      src/rss/rssfolder.cpp
  7. 2
      src/rss/rssfolder.h

22
src/rss/rss_imp.cpp

@ -320,7 +320,7 @@ void RSSImp::saveFoldersOpenState() {
} }
// refresh all streams by a button // refresh all streams by a button
void RSSImp::on_updateAllButton_clicked() { void RSSImp::refreshAllFeeds() {
foreach (QTreeWidgetItem *item, m_feedList->getAllFeedItems()) { foreach (QTreeWidgetItem *item, m_feedList->getAllFeedItems()) {
item->setData(0,Qt::DecorationRole, QVariant(QIcon(":/Icons/loading.png"))); item->setData(0,Qt::DecorationRole, QVariant(QIcon(":/Icons/loading.png")));
} }
@ -402,24 +402,21 @@ void RSSImp::refreshSelectedItems() {
RssFilePtr file = m_feedList->getRSSItem(item); RssFilePtr file = m_feedList->getRSSItem(item);
// Update icons // Update icons
if (item == m_feedList->stickyUnreadItem()) { if (item == m_feedList->stickyUnreadItem()) {
foreach (QTreeWidgetItem *feed, m_feedList->getAllFeedItems()) { refreshAllFeeds();
feed->setData(0, Qt::DecorationRole, QVariant(QIcon(":/Icons/loading.png"))); return;
}
file->refresh();
break;
} else { } else {
if (!file->refresh())
continue;
// Update UI
if (qSharedPointerDynamicCast<RssFeed>(file)) { if (qSharedPointerDynamicCast<RssFeed>(file)) {
item->setData(0, Qt::DecorationRole, QVariant(QIcon(":/Icons/loading.png"))); item->setData(0, Qt::DecorationRole, QVariant(QIcon(":/Icons/loading.png")));
} else if (qSharedPointerDynamicCast<RssFolder>(file)) { } else if (qSharedPointerDynamicCast<RssFolder>(file)) {
// Update feeds in the folder // Update feeds in the folder
foreach (QTreeWidgetItem *feed, m_feedList->getAllFeedItems(item)) { foreach (QTreeWidgetItem *feed, m_feedList->getAllFeedItems(item))
feed->setData(0, Qt::DecorationRole, QVariant(QIcon(":/Icons/loading.png"))); feed->setData(0, Qt::DecorationRole, QVariant(QIcon(":/Icons/loading.png")));
} }
} }
} }
// Actually refresh
file->refresh();
}
} }
void RSSImp::copySelectedFeedsURL() { void RSSImp::copySelectedFeedsURL() {
@ -688,7 +685,8 @@ RSSImp::RSSImp(QWidget *parent) : QWidget(parent), m_rssManager(new RssManager)
connect(actionUpdate, SIGNAL(triggered()), this, SLOT(refreshSelectedItems())); connect(actionUpdate, SIGNAL(triggered()), this, SLOT(refreshSelectedItems()));
connect(actionNew_folder, SIGNAL(triggered()), this, SLOT(askNewFolder())); connect(actionNew_folder, SIGNAL(triggered()), this, SLOT(askNewFolder()));
connect(actionNew_subscription, SIGNAL(triggered()), this, SLOT(on_newFeedButton_clicked())); connect(actionNew_subscription, SIGNAL(triggered()), this, SLOT(on_newFeedButton_clicked()));
connect(actionUpdate_all_feeds, SIGNAL(triggered()), this, SLOT(on_updateAllButton_clicked())); connect(actionUpdate_all_feeds, SIGNAL(triggered()), this, SLOT(refreshAllFeeds()));
connect(updateAllButton, SIGNAL(clicked()), SLOT(refreshAllFeeds()));
connect(actionCopy_feed_URL, SIGNAL(triggered()), this, SLOT(copySelectedFeedsURL())); connect(actionCopy_feed_URL, SIGNAL(triggered()), this, SLOT(copySelectedFeedsURL()));
connect(actionMark_items_read, SIGNAL(triggered()), this, SLOT(on_markReadButton_clicked())); connect(actionMark_items_read, SIGNAL(triggered()), this, SLOT(on_markReadButton_clicked()));
// News list actions // News list actions
@ -731,5 +729,5 @@ void RSSImp::on_rssDownloaderBtn_clicked()
AutomatedRssDownloader dlg(m_rssManager, this); AutomatedRssDownloader dlg(m_rssManager, this);
dlg.exec(); dlg.exec();
if (dlg.isRssDownloaderEnabled()) if (dlg.isRssDownloaderEnabled())
on_updateAllButton_clicked(); refreshAllFeeds();
} }

2
src/rss/rss_imp.h

@ -57,7 +57,7 @@ public slots:
private slots: private slots:
void on_newFeedButton_clicked(); void on_newFeedButton_clicked();
void on_updateAllButton_clicked(); void refreshAllFeeds();
void on_markReadButton_clicked(); void on_markReadButton_clicked();
void displayRSSListMenu(const QPoint&); void displayRSSListMenu(const QPoint&);
void displayItemsListMenu(const QPoint&); void displayItemsListMenu(const QPoint&);

5
src/rss/rssfeed.cpp

@ -127,14 +127,15 @@ void RssFeed::addArticle(const RssArticlePtr& article)
} }
} }
void RssFeed::refresh() { bool RssFeed::refresh() {
if (m_loading) { if (m_loading) {
qWarning() << Q_FUNC_INFO << "Feed" << this->displayName() << "is already being refreshed, ignoring request"; qWarning() << Q_FUNC_INFO << "Feed" << this->displayName() << "is already being refreshed, ignoring request";
return; return false;
} }
m_loading = true; m_loading = true;
// Download the RSS again // Download the RSS again
m_manager->rssDownloader()->downloadUrl(m_url); m_manager->rssDownloader()->downloadUrl(m_url);
return true;
} }
void RssFeed::removeAllSettings() { void RssFeed::removeAllSettings() {

2
src/rss/rssfeed.h

@ -55,7 +55,7 @@ public:
virtual ~RssFeed(); virtual ~RssFeed();
virtual RssFolder* parent() const { return m_parent; } virtual RssFolder* parent() const { return m_parent; }
virtual void setParent(RssFolder* parent) { m_parent = parent; } virtual void setParent(RssFolder* parent) { m_parent = parent; }
void refresh(); bool refresh();
virtual QString id() const { return m_url; } virtual QString id() const { return m_url; }
virtual void removeAllSettings(); virtual void removeAllSettings();
virtual void saveItemsToDisk(); virtual void saveItemsToDisk();

2
src/rss/rssfile.h

@ -58,7 +58,7 @@ public:
virtual void markAsRead() = 0; virtual void markAsRead() = 0;
virtual RssFolder* parent() const = 0; virtual RssFolder* parent() const = 0;
virtual void setParent(RssFolder* parent) = 0; virtual void setParent(RssFolder* parent) = 0;
virtual void refresh() = 0; virtual bool refresh() = 0;
virtual RssArticleList articleListByDateDesc() const = 0; virtual RssArticleList articleListByDateDesc() const = 0;
virtual RssArticleList unreadArticleListByDateDesc() const = 0; virtual RssArticleList unreadArticleListByDateDesc() const = 0;
virtual void removeAllSettings() = 0; virtual void removeAllSettings() = 0;

7
src/rss/rssfolder.cpp

@ -83,12 +83,15 @@ RssFeedPtr RssFolder::addStream(RssManager* manager, const QString &url) {
} }
// Refresh All Children // Refresh All Children
void RssFolder::refresh() { bool RssFolder::refresh() {
RssFileHash::ConstIterator it = m_children.begin(); RssFileHash::ConstIterator it = m_children.begin();
RssFileHash::ConstIterator itend = m_children.end(); RssFileHash::ConstIterator itend = m_children.end();
bool refreshed = false;
for ( ; it != itend; ++it) { for ( ; it != itend; ++it) {
it.value()->refresh(); if (it.value()->refresh())
refreshed = true;
} }
return refreshed;
} }
RssArticleList RssFolder::articleListByDateDesc() const { RssArticleList RssFolder::articleListByDateDesc() const {

2
src/rss/rssfolder.h

@ -71,7 +71,7 @@ public:
RssFilePtr takeChild(const QString &childId); RssFilePtr takeChild(const QString &childId);
public slots: public slots:
virtual void refresh(); virtual bool refresh();
void addFile(const RssFilePtr& item); void addFile(const RssFilePtr& item);
void removeChild(const QString &childId); void removeChild(const QString &childId);
virtual void rename(const QString &new_name); virtual void rename(const QString &new_name);

Loading…
Cancel
Save