Browse Source

RSS code clean up

adaptive-webui-19844
Christophe Dumez 13 years ago
parent
commit
32a6c89c8c
  1. 2
      src/rss/rss_imp.cpp
  2. 5
      src/rss/rssarticle.cpp
  3. 3
      src/rss/rssarticle.h
  4. 6
      src/rss/rssfeed.cpp
  5. 2
      src/rss/rssfeed.h
  6. 3
      src/rss/rssmanager.cpp

2
src/rss/rss_imp.cpp

@ -508,7 +508,7 @@ void RSSImp::refreshTextBrowser() { @@ -508,7 +508,7 @@ void RSSImp::refreshTextBrowser() {
m_currentArticle = item;
}
RssFeed *stream = m_feedList->getRSSItemFromUrl(item->data(Article::FeedUrlRole).toString());
RssArticle &article = stream->getItem(item->data(Article::IdRole).toString());
RssArticle article = stream->getItem(item->data(Article::IdRole).toString());
QString html;
html += "<div style='border: 2px solid red; margin-left: 5px; margin-right: 5px; margin-bottom: 5px;'>";
html += "<div style='background-color: #678db2; font-weight: bold; color: #fff;'>"+article.title() + "</div>";

5
src/rss/rssarticle.cpp

@ -190,6 +190,11 @@ QDateTime RssArticle::parseDate(const QString &string) { @@ -190,6 +190,11 @@ QDateTime RssArticle::parseDate(const QString &string) {
return result;
}
RssArticle::RssArticle():
d(new RssArticleData(0))
{
}
// public constructor
RssArticle::RssArticle(RssFeed* parent, QXmlStreamReader& xml):
d(new RssArticleData(parent))

3
src/rss/rssarticle.h

@ -43,8 +43,9 @@ class RssArticleData; @@ -43,8 +43,9 @@ class RssArticleData;
class RssArticle {
public:
RssArticle();
RssArticle(RssFeed* parent, QXmlStreamReader& xml);
RssArticle(RssFeed* parent = 0, const QString &guid = QString());
RssArticle(RssFeed* parent, const QString &guid);
RssArticle(const RssArticle& other); // Copy constructor
RssArticle& operator=(const RssArticle& other);
~RssArticle();

6
src/rss/rssfeed.cpp

@ -177,8 +177,8 @@ void RssFeed::setIconPath(const QString &path) { @@ -177,8 +177,8 @@ void RssFeed::setIconPath(const QString &path) {
m_icon = path;
}
RssArticle& RssFeed::getItem(const QString &guid) {
return m_articles[guid];
const RssArticle RssFeed::getItem(const QString &guid) const {
return m_articles.value(guid);
}
uint RssFeed::count() const{
@ -300,7 +300,7 @@ void RssFeed::downloadMatchingArticleTorrents() { @@ -300,7 +300,7 @@ void RssFeed::downloadMatchingArticleTorrents() {
Q_ASSERT(RssSettings().isRssDownloadingEnabled());
QHash<QString, RssArticle>::iterator it;
for (it = m_articles.begin(); it != m_articles.end(); it++) {
RssArticle &item = it.value();
RssArticle item = it.value();
if(item.isRead()) continue;
QString torrent_url;
if(item.hasAttachment())

2
src/rss/rssfeed.h

@ -59,7 +59,7 @@ public: @@ -59,7 +59,7 @@ public:
QString icon() const;
bool hasCustomIcon() const;
void setIconPath(const QString &pathHierarchy);
RssArticle& getItem(const QString &guid);
const RssArticle getItem(const QString &guid) const;
uint count() const;
void markAsRead();
uint unreadCount() const;

3
src/rss/rssmanager.cpp

@ -39,8 +39,7 @@ @@ -39,8 +39,7 @@
RssManager* RssManager::m_instance = 0;
RssManager::RssManager(): RssFolder() {
m_rssDownloader = new DownloadThread(this);
RssManager::RssManager(): m_rssDownloader(new DownloadThread(this)) {
connect(&m_refreshTimer, SIGNAL(timeout()), this, SLOT(refresh()));
m_refreshInterval = RssSettings().getRSSRefreshInterval();
m_refreshTimer.start(m_refreshInterval*60000);

Loading…
Cancel
Save