RSS code clean up

This commit is contained in:
Christophe Dumez 2012-02-19 15:42:51 +02:00
parent 1905a6f0d1
commit 32a6c89c8c
6 changed files with 13 additions and 8 deletions

View File

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

View File

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

View File

@ -43,8 +43,9 @@ class RssArticleData;
class RssArticle { class RssArticle {
public: public:
RssArticle();
RssArticle(RssFeed* parent, QXmlStreamReader& xml); 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(const RssArticle& other); // Copy constructor
RssArticle& operator=(const RssArticle& other); RssArticle& operator=(const RssArticle& other);
~RssArticle(); ~RssArticle();

View File

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

View File

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

View File

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