[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: playground/pim/krss
From: Dmitry Ivanov <vonami () gmail ! com>
Date: 2009-05-25 12:51:57
Message-ID: 1243255917.846137.1354.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 972610 by divanov:
Reintroduce item monitoring, fine-grained this time since
it affects performance a lot
M +5 -2 krssreader/mainwidget.cpp
M +2 -0 libkrss/feed.h
M +1 -0 libkrss/item.h
M +46 -17 libkrss/itemlisting.cpp
M +16 -5 libkrss/itemlisting.h
M +1 -1 libkrss/treenodevisitor.cpp
--- trunk/playground/pim/krss/krssreader/mainwidget.cpp #972609:972610
@@ -259,11 +259,14 @@
assert( job );
if ( job->error() ) {
//TODO print error
- setCollection( shared_ptr<ItemListing>( new ItemListing( QList<Item>() ) ) \
); + setCollection( shared_ptr<ItemListing>( new ItemListing( QList<Item>(), \
Akonadi::ItemFetchScope() ) ) ); return;
}
- const shared_ptr<ItemListing> coll( new ItemListing( job->items() ) );
+ Akonadi::ItemFetchScope fetchScope;
+ fetchScope.fetchPayloadPart( Item::HeadersPart );
+ fetchScope.fetchAllAttributes();
+ const shared_ptr<ItemListing> coll( new ItemListing( job->items(), fetchScope ) \
);
auto_ptr<ConnectToItemListingVisitor> visitor( new ConnectToItemListingVisitor( \
m_feedList, coll ) ); m_currentNode->accept( visitor.get() );
setCollection( coll );
--- trunk/playground/pim/krss/libkrss/feed.h #972609:972610
@@ -34,6 +34,7 @@
class ItemListJob;
class ItemListJobImpl;
class FeedPrivate;
+class ItemListing;
class KRSS_EXPORT Feed : public QObject
{
@@ -101,6 +102,7 @@
friend class FeedDeleteJobPrivate;
friend class ::KRss::FeedPrivate;
friend class ::KRss::ItemListJobImpl;
+ friend class ::KRss::ItemListing;
Q_PRIVATE_SLOT( d, void slotCollectionLoadDone( KJob *job ) )
Q_PRIVATE_SLOT( d, void slotStatisticsFetchDone( KJob *job ) )
--- trunk/playground/pim/krss/libkrss/item.h #972609:972610
@@ -259,6 +259,7 @@
friend class ItemDeleteJobPrivate;
friend class Feed;
friend class ItemListJobImpl;
+ friend class ItemListing;
class Private;
QSharedDataPointer<Private> d;
--- trunk/playground/pim/krss/libkrss/itemlisting.cpp #972609:972610
@@ -17,8 +17,13 @@
#include "itemlisting.h"
#include "feed.h"
+#include "feed_p.h"
#include "item.h"
+#include "item_p.h"
+#include <akonadi/monitor.h>
+#include <akonadi/item.h>
+#include <akonadi/itemfetchscope.h>
#include <boost/bind.hpp>
#include <algorithm>
@@ -40,34 +45,62 @@
class ItemListing::Private {
ItemListing* const q;
public:
- explicit Private( const QList<Item>& list, ItemListing* qq );
+ explicit Private( const QList<Item>& list, const Akonadi::ItemFetchScope& \
fetchScope, + ItemListing* qq );
+ ~Private();
void addItems( const QList<Item>& list );
void updateItems( const QList<Item>& list );
void removeItems( const QList<Item>& list );
- void itemsAdded( KRss::Feed*, const QList<KRss::Item>& list ) {
- addItems( list );
+ void slotItemAdded( const Akonadi::Item& item, const Akonadi::Collection& \
collection ) + {
+ Q_UNUSED( collection )
+ Item rssItem;
+ rssItem.d->akonadiItem = item;
+ addItems( QList<Item>() << rssItem );
}
- void itemsChanged( KRss::Feed*, const QList<KRss::Item>& list ) {
- updateItems( list );
+ void slotItemChanged( const Akonadi::Item& item, const QSet<QByteArray>& parts )
+ {
+ Q_UNUSED( parts )
+ Item rssItem;
+ rssItem.d->akonadiItem = item;
+ updateItems( QList<Item>() << rssItem );
}
- void itemsRemoved( KRss::Feed*, const QList<KRss::Item>& list ) {
- removeItems( list );
+ void slotItemRemoved( const Akonadi::Item& item )
+ {
+ Item rssItem;
+ rssItem.d->akonadiItem = item;
+ removeItems( QList<Item>() << rssItem );
}
QList<Item> items;
QList<ItemListing::Listener*> listeners;
+ Akonadi::Monitor *m_monitor;
};
-ItemListing::Private::Private( const QList<Item>& list, ItemListing* qq )
+ItemListing::Private::Private( const QList<Item>& list, const \
Akonadi::ItemFetchScope& fetchScope, + ItemListing* qq \
) : q( qq )
- , items( list ) {
+ , items( list ), m_monitor( new Akonadi::Monitor ) {
std::sort( items.begin(), items.end(), lessByItemId );
+
+ m_monitor->setItemFetchScope( fetchScope );
+ QObject::connect( m_monitor, SIGNAL( itemAdded( const Akonadi::Item&, const \
Akonadi::Collection& ) ), + q, SLOT( slotItemAdded( const \
Akonadi::Item&, const Akonadi::Collection& ) ) ); + QObject::connect( m_monitor, \
SIGNAL( itemChanged( const Akonadi::Item&, const QSet<QByteArray>& ) ), + \
q, SLOT( slotItemChanged( const Akonadi::Item&, const QSet<QByteArray>& ) ) ); + \
QObject::connect( m_monitor, SIGNAL( itemRemoved( const Akonadi::Item& ) ), + \
q, SLOT( slotItemRemoved( const Akonadi::Item& ) ) ); }
+ItemListing::Private::~Private()
+{
+ delete m_monitor;
+}
+
void ItemListing::Private::addItems( const QList<Item>& list_ ) {
if ( list_.isEmpty() )
return;
@@ -124,7 +157,8 @@
}
}
-ItemListing::ItemListing( const QList<Item>& items, QObject* parent ) : QObject( \
parent ), d( new Private( items, this ) ) { +ItemListing::ItemListing( const \
QList<Item>& items, const Akonadi::ItemFetchScope& fetchScope, QObject* parent ) + \
: QObject( parent ), d( new Private( items, fetchScope, this ) ) { }
ItemListing::~ItemListing() {
@@ -135,13 +169,8 @@
return d->items;
}
-void ItemListing::connectToFeed( const Feed* feed ) {
- connect( feed, SIGNAL(itemsAdded(KRss::Feed*,QList<KRss::Item>)),
- this, SLOT(itemsAdded(KRss::Feed*,QList<KRss::Item>)) );
- connect( feed, SIGNAL(itemsChanged(KRss::Feed*,QList<KRss::Item>)),
- this, SLOT(itemsChanged(KRss::Feed*,QList<KRss::Item>)) );
- connect( feed, SIGNAL(itemsRemoved(KRss::Feed*,QList<KRss::Item>)),
- this, SLOT(itemsRemoved(KRss::Feed*,QList<KRss::Item>)) );
+void ItemListing::connectToFeed( const shared_ptr<const Feed>& feed ) {
+ d->m_monitor->setCollectionMonitored( feed->d->m_feedCollection );
}
void ItemListing::addListener( ItemListing::Listener* listener ) {
--- trunk/playground/pim/krss/libkrss/itemlisting.h #972609:972610
@@ -22,6 +22,14 @@
#include <QObject>
+namespace boost {
+template <typename T> class shared_ptr;
+}
+
+namespace Akonadi {
+class ItemFetchScope;
+}
+
namespace KRss {
class Feed;
@@ -41,12 +49,15 @@
virtual void update( int ) = 0;
};
- explicit ItemListing( const QList<Item>& item, QObject* parent=0 );
+ explicit ItemListing( const QList<Item>& items, const \
Akonadi::ItemFetchScope& fetchScope, + QObject* parent=0 \
); ~ItemListing();
const QList<Item>& items() const;
- void connectToFeed( const Feed* );
+ void connectToFeed( const boost::shared_ptr<const Feed>& feed );
+ void setFetchScope( const Akonadi::ItemFetchScope& fetchScope );
+ Akonadi::ItemFetchScope& fetchScope();
void addListener( Listener* listener );
void removeListener( Listener* listener );
@@ -56,9 +67,9 @@
private:
class Private;
Private* const d;
- Q_PRIVATE_SLOT( d, void itemsAdded( KRss::Feed *, const QList<KRss::Item> & \
) )
- Q_PRIVATE_SLOT( d, void itemsChanged( KRss::Feed *, const QList<KRss::Item> \
& ) )
- Q_PRIVATE_SLOT( d, void itemsRemoved( KRss::Feed *, const QList<KRss::Item> \
& ) ) + Q_PRIVATE_SLOT( d, void slotItemAdded( const Akonadi::Item&, const \
Akonadi::Collection& ) ) + Q_PRIVATE_SLOT( d, void slotItemChanged( const \
Akonadi::Item&, const QSet<QByteArray>& ) ) + Q_PRIVATE_SLOT( d, void \
slotItemRemoved( const Akonadi::Item& ) ) };
}
--- trunk/playground/pim/krss/libkrss/treenodevisitor.cpp #972609:972610
@@ -71,7 +71,7 @@
void ConnectToItemListingVisitor::visit( const shared_ptr<FeedNode>& feedNode )
{
- d->m_itemListing->connectToFeed( d->m_feedList->constFeedById( \
feedNode->feedId() ).get() ); + d->m_itemListing->connectToFeed( \
d->m_feedList->constFeedById( feedNode->feedId() ) ); }
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic