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;
}
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>";

View File

@ -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))

View File

@ -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();

View File

@ -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() {
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())

View File

@ -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;

View File

@ -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);