akregator
articlejobs.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include "articlejobs.h"
00026 #include "article.h"
00027 #include "feed.h"
00028 #include "feedlist.h"
00029 #include "kernel.h"
00030
00031 #include <QTimer>
00032
00033 #include <vector>
00034
00035 using namespace Akregator;
00036
00037 Akregator::ArticleDeleteJob::ArticleDeleteJob( QObject* parent ) : KJob( parent ), m_feedList( Kernel::self()->feedList() )
00038 {
00039 Q_ASSERT( m_feedList );
00040 }
00041
00042 void Akregator::ArticleDeleteJob::appendArticleIds( const QList<Akregator::ArticleId>& ids )
00043 {
00044 m_ids += ids;
00045 }
00046
00047 void Akregator::ArticleDeleteJob::appendArticleId( const Akregator::ArticleId& id )
00048 {
00049 m_ids += id;
00050 }
00051
00052
00053 void Akregator::ArticleDeleteJob::start()
00054 {
00055 QTimer::singleShot( 20, this, SLOT( doStart() ) );
00056 }
00057
00058 void Akregator::ArticleDeleteJob::doStart()
00059 {
00060 std::vector<Akregator::Feed*> feeds;
00061
00062 Q_FOREACH ( const Akregator::ArticleId id, m_ids )
00063 {
00064 Akregator::Article article = m_feedList->findArticle( id.feedUrl, id.guid );
00065 if ( article.isNull() )
00066 continue;
00067 ;
00068 if ( Feed* const feed = m_feedList->findByURL( id.feedUrl ) )
00069 {
00070 feeds.push_back( feed );
00071 feed->setNotificationMode( false );
00072 }
00073 article.setDeleted();
00074 }
00075
00076 Q_FOREACH ( Akregator::Feed* const i, feeds )
00077 i->setNotificationMode( true );
00078
00079 emitResult();
00080 }
00081
00082 Akregator::ArticleModifyJob::ArticleModifyJob( QObject* parent ) : KJob( parent ), m_feedList( Kernel::self()->feedList() )
00083 {
00084 Q_ASSERT( m_feedList );
00085 }
00086
00087 void Akregator::ArticleModifyJob::setStatus( const ArticleId& id, int status )
00088 {
00089 m_status[id] = status;
00090 }
00091
00092 void Akregator::ArticleModifyJob::setKeep( const ArticleId& id, bool keep )
00093 {
00094 m_keepFlags[id] = keep;
00095 }
00096
00097 void Akregator::ArticleModifyJob::start()
00098 {
00099 QTimer::singleShot( 20, this, SLOT( doStart() ) );
00100 }
00101
00102 void Akregator::ArticleModifyJob::doStart()
00103 {
00104 std::vector<Akregator::Feed*> feeds;
00105
00106 Q_FOREACH ( const Akregator::ArticleId id, m_keepFlags.keys() )
00107 {
00108 Akregator::Feed* feed = m_feedList->findByURL( id.feedUrl );
00109 if ( !feed )
00110 continue;
00111 feed->setNotificationMode( false );
00112 feeds.push_back( feed );
00113 Akregator::Article article = feed->findArticle( id.guid );
00114 if ( !article.isNull() )
00115 article.setKeep( m_keepFlags[id] );
00116 }
00117
00118 Q_FOREACH ( const Akregator::ArticleId id, m_status.keys() )
00119 {
00120 Akregator::Feed* feed = m_feedList->findByURL( id.feedUrl );
00121 if ( !feed )
00122 continue;
00123 feed->setNotificationMode( false );
00124 feeds.push_back( feed );
00125 Akregator::Article article = feed->findArticle( id.guid );
00126 if ( !article.isNull() )
00127 article.setStatus( m_status[id] );
00128 }
00129
00130 Q_FOREACH ( Akregator::Feed* const i, feeds )
00131 i->setNotificationMode( true );
00132 emitResult();
00133 }
00134
00135 #include "articlejobs.moc"