• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • kdepim
  • Sitemap
  • Contact Us
 

akregator

articlejobs.cpp

Go to the documentation of this file.
00001 /*
00002     This file is part of Akregator.
00003 
00004     Copyright (C) 2007 Frank Osterfeld <osterfeld@kde.org>
00005 
00006     This program is free software; you can redistribute it and/or modify
00007     it under the terms of the GNU General Public License as published by
00008     the Free Software Foundation; either version 2 of the License, or
00009     (at your option) any later version.
00010 
00011     This program is distributed in the hope that it will be useful,
00012     but WITHOUT ANY WARRANTY; without even the implied warranty of
00013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00014     GNU General Public License for more details.
00015 
00016     You should have received a copy of the GNU General Public License
00017     along with this program; if not, write to the Free Software
00018     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00019 
00020     As a special exception, permission is given to link this program
00021     with any edition of Qt, and distribute the resulting executable,
00022     without including the source code for Qt in the source distribution.
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"

akregator

Skip menu "akregator"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members

kdepim

Skip menu "kdepim"
  • akonadi
  •   clients
  •   kabc
  •   kcal
  •   kcm
  • akregator
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt
  • kdgantt1
  • kjots
  • kleopatra
  • kmail
  • kmobiletools
  • knode
  • knotes
  • kontact
  • kontactinterfaces
  • korganizer
  •   korgac
  • kpilot
  • ktimetracker
  •   doc
  • libkdepim
  • libkholidays
  • libkleo
  • libkpgp
  • maildir
Generated for kdepim by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal