Logo Search packages:      
Sourcecode: akregator version File versions

void Feed::appendArticles ( const Document d  ) 

appends the articles in document to the feed's article list

Definition at line 254 of file feed.cpp.

References appendArticle(), RSS::Document::articles(), Akregator::ArticleSequence::enableSorting(), Akregator::MyArticle::guidIsHash(), Akregator::MyArticle::hash(), Akregator::MyArticle::isDeleted(), m_articles, m_unread, markImmediatelyAsRead(), Akregator::TreeNode::modified(), Akregator::MyArticle::offsetFetchTime(), Akregator::MyArticle::setKeep(), Akregator::MyArticle::setStatus(), Akregator::ArticleSequence::sort(), and Akregator::MyArticle::status().

{
    bool changed = false;
    
    m_articles.enableSorting(false);
    Article::List d_articles = d.articles();
    Article::List::ConstIterator it;
    Article::List::ConstIterator en = d_articles.end();
    
    int nudge=0;

    for (it = d_articles.begin(); it != en; ++it)
    {
        MyArticle mya(*it);

        // if archive isn't loaded, append. Otherwise check for dupes.
        if (!m_merged)
        {
            if (mya.status() == MyArticle::New)
                mya.setStatus(MyArticle::Unread);
  
            appendArticle(mya);
            changed = true;
        }
        else
        {
            ArticleSequence::Iterator old = m_articles.find(mya);
            
            if ( old == m_articles.end() ) // article not in list
            {
                if (!markImmediatelyAsRead())
                    mya.setStatus(MyArticle::New);
                else
                    mya.setStatus(MyArticle::Read);
                
                mya.offsetFetchTime(nudge);
                nudge--;
                appendArticle(mya);
                changed = true;
            }
            // if the article's guid is no hash but an ID, we have to check if the article was updated. That's done by comparing the hash values.
            else if (!mya.guidIsHash() && mya.hash() != (*old).hash() && !mya.isDeleted())
            {
                    mya.setKeep((*old).keep());
                    // reset status to New
                    mya.setStatus(MyArticle::New);
                    if ((*old).status() != MyArticle::Read)
                        m_unread--;
                    m_articles.remove(old);
                    appendArticle(mya);
                    changed = true;
            }
        }
    }
    
    m_articles.enableSorting(true);
    m_articles.sort();
    if (changed)
        modified();
}


Generated by  Doxygen 1.6.0   Back to index