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

2
src/rss/rss_imp.h

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

5
src/rss/rssfeed.cpp

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

2
src/rss/rssfeed.h

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

2
src/rss/rssfile.h

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

7
src/rss/rssfolder.cpp

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

2
src/rss/rssfolder.h

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

Loading…
Cancel
Save