Commit 78aa3c3d authored by Thomas McGuire's avatar Thomas McGuire
Browse files

Renaming:

MessageCollectionModel => CollectionStatisticsModel
MessageCollectionDelegate => CollectionStatisticsDelegate
CollectionStatus => CollectionStatistics
CollectionStatusJob => CollectionStatisticsJob

The actual file renaming will follow soon.

svn path=/trunk/KDE/kdepimlibs/; revision=789152
parent cf1e35e1
......@@ -81,8 +81,12 @@ set( akonadikde_LIB_SRC
collectionpropertiespage.cpp
collectionrightsattribute.cpp
collectionselectjob.cpp
collectionstatus.cpp
collectionstatusjob.cpp
# collectionstatisticsdelegate.cpp
# collectionstatisticsmodel.cpp
#collectionstatistics.cpp
# collectionstatisticsjob.cpp
messagecollectionmodel.cpp messagecollectiondelegate.cpp
collectionstatus.cpp collectionstatusjob.cpp
collectionsync.cpp
collectionview.cpp
control.cpp
......@@ -103,8 +107,6 @@ set( akonadikde_LIB_SRC
itemsync.cpp
itemview.cpp
job.cpp
messagecollectiondelegate.cpp
messagecollectionmodel.cpp
monitor.cpp
monitor_p.cpp
pastehelper.cpp
......@@ -176,8 +178,12 @@ install( FILES
collectionpropertiesdialog.h
collectionpropertiespage.h
collectionselectjob.h
collectionstatus.h
collectionstatusjob.h
# collectionstatisticsdelegate.h
# collectionstatisticsmodel.h
#collectionstatistics.h
# collectionstatisticsjob.h
messagecollectionmodel.h messagecollectiondelegate.h
collectionstatus.h collectionstatusjob.h
collectionview.h
control.h
entity.h
......@@ -196,8 +202,6 @@ install( FILES
itemsync.h
itemview.h
job.h
messagecollectiondelegate.h
messagecollectionmodel.h
monitor.h
profilemanager.h
profilemodel.h
......
......@@ -36,7 +36,7 @@ Classes to retrieve information about collections:
- Akonadi::CollectionFetchJob
- Akonadi::CollectionSelectJob
- Akonadi::CollectionStatusJob
- Akonadi::CollectionStatisticsJob
Classes to manipulate collections:
......
......@@ -48,7 +48,7 @@ class Akonadi::CollectionPrivate : public EntityPrivate
parentRemoteId = other.parentRemoteId;
type = other.type;
resource = other.resource;
status = other.status;
statistics = other.statistics;
contentTypes = other.contentTypes;
cachePolicy = other.cachePolicy;
}
......@@ -76,7 +76,7 @@ class Akonadi::CollectionPrivate : public EntityPrivate
QString parentRemoteId;
Collection::Type type;
QString resource;
CollectionStatus status;
CollectionStatistics statistics;
QStringList contentTypes;
static const Collection root;
CachePolicy cachePolicy;
......@@ -234,15 +234,15 @@ uint qHash( const Akonadi::Collection &collection )
return qHash( collection.id() );
}
CollectionStatus Collection::status() const
CollectionStatistics Collection::statistics() const
{
return d_func()->status;
return d_func()->statistics;
}
void Collection::setStatus(const CollectionStatus & status)
void Collection::setStatistics(const CollectionStatistics & statistics)
{
Q_D( Collection );
d->status = status;
d->statistics = statistics;
}
bool Collection::urlIsValid( const KUrl &url )
......
......@@ -216,14 +216,14 @@ class AKONADI_EXPORT Collection : public Entity
void setCachePolicy( const CachePolicy &cachePolicy );
/**
Returns the CollectionStatus object.
Returns the CollectionStatistics object.
*/
CollectionStatus status() const;
CollectionStatistics statistics() const;
/**
Sets the CollectionStatus object for this collection.
Sets the CollectionStatistics object for this collection.
*/
void setStatus( const CollectionStatus &status );
void setStatistics( const CollectionStatistics &statistics );
/**
Returns the collection url
......
......@@ -33,8 +33,9 @@ CollectionGeneralPropertiesPage::CollectionGeneralPropertiesPage(QWidget * paren
void CollectionGeneralPropertiesPage::load(const Collection & collection)
{
ui.nameEdit->setText( collection.name() );
if ( collection.status().count() >= 0 ) {
ui.countLabel->setText( i18np( "One object", "%1 objects", collection.status().count() ) );
if ( collection.statistics().count() >= 0 ) {
ui.countLabel->setText( i18np( "One object", "%1 objects",
collection.statistics().count() ) );
} else {
ui.statsBox->hide();
}
......
......@@ -366,11 +366,11 @@ Collection CollectionModel::collectionForId(Collection::Id id) const
return d->collections.value( id );
}
void CollectionModel::fetchCollectionStatus(bool enable)
void CollectionModel::fetchCollectionStatistics(bool enable)
{
Q_D( CollectionModel );
d->fetchStatus = enable;
d->monitor->fetchCollectionStatus( enable );
d->fetchStatistics = enable;
d->monitor->fetchCollectionStatistics( enable );
}
void CollectionModel::includeUnsubscribed(bool include)
......
......@@ -136,10 +136,10 @@ class AKONADI_EXPORT CollectionModel : public QAbstractItemModel
Collection collectionForId( Collection::Id id ) const;
/**
Enable fetching of collection status information.
@see CollectionStatus.
Enable fetching of collection statistics information.
@see CollectionStatistics.
*/
void fetchCollectionStatus( bool enable );
void fetchCollectionStatistics( bool enable );
/**
Also include unsubscribed collections.
......@@ -183,7 +183,9 @@ class AKONADI_EXPORT CollectionModel : public QAbstractItemModel
Q_PRIVATE_SLOT( d_func(), void collectionRemoved( const Akonadi::Collection& ) )
Q_PRIVATE_SLOT( d_func(), void collectionChanged( const Akonadi::Collection& ) )
Q_PRIVATE_SLOT( d_func(), void updateDone( KJob* ) )
Q_PRIVATE_SLOT( d_func(), void collectionStatusChanged( Akonadi::Collection::Id, const Akonadi::CollectionStatus& ) )
Q_PRIVATE_SLOT( d_func(), void collectionStatisticsChanged(
Akonadi::Collection::Id,
const Akonadi::CollectionStatistics& ) )
Q_PRIVATE_SLOT( d_func(), void listDone( KJob* ) )
Q_PRIVATE_SLOT( d_func(), void editDone( KJob* ) )
Q_PRIVATE_SLOT( d_func(), void dropResult( KJob* ) )
......
......@@ -93,20 +93,21 @@ void CollectionModelPrivate::updateDone( KJob *job )
// TODO: handle job errors
kWarning( 5250 ) << "Job error:" << job->errorString();
} else {
CollectionStatusJob *csjob = static_cast<CollectionStatusJob*>( job );
CollectionStatisticsJob *csjob = static_cast<CollectionStatisticsJob*>( job );
Collection result = csjob->collection();
collectionStatusChanged( result.id(), csjob->status() );
collectionStatisticsChanged( result.id(), csjob->statistics() );
}
}
void CollectionModelPrivate::collectionStatusChanged( Collection::Id collection, const Akonadi::CollectionStatus & status )
void CollectionModelPrivate::collectionStatisticsChanged( Collection::Id collection,
const Akonadi::CollectionStatistics &statistics )
{
Q_Q( CollectionModel );
if ( !collections.contains( collection ) )
kWarning( 5250 ) << "Got status response for non-existing collection:" << collection;
kWarning( 5250 ) << "Got statistics response for non-existing collection:" << collection;
else {
collections[ collection ].setStatus( status );
collections[ collection ].setStatistics( statistics );
Collection col = collections.value( collection );
QModelIndex startIndex = q->indexForId( col.id() );
......@@ -117,7 +118,7 @@ void CollectionModelPrivate::collectionStatusChanged( Collection::Id collection,
static int oldTotalUnread = -1;
int totalUnread = 0;
foreach ( const Collection& col, collections.values() ) {
int colUnread = col.status().unreadCount();
int colUnread = col.statistics().unreadCount();
if ( colUnread > 0 )
totalUnread += colUnread;
}
......@@ -156,7 +157,7 @@ void CollectionModelPrivate::collectionsChanged( const Collection::List &cols )
foreach( Collection col, cols ) {
if ( collections.contains( col.id() ) ) {
// collection already known
col.setStatus( collections.value( col.id() ).status() );
col.setStatistics( collections.value( col.id() ).statistics() );
collections[ col.id() ] = col;
QModelIndex startIndex = q->indexForId( col.id() );
QModelIndex endIndex = q->indexForId( col.id(), q->columnCount( q->parent( startIndex ) ) - 1 );
......@@ -175,9 +176,9 @@ void CollectionModelPrivate::collectionsChanged( const Collection::List &cols )
updateSupportedMimeTypes( col );
// start a status job for every collection to get message counts, etc.
if ( fetchStatus && col.type() != Collection::VirtualParent ) {
CollectionStatusJob* csjob = new CollectionStatusJob( col, session );
// start a statistics job for every collection to get message counts, etc.
if ( fetchStatistics && col.type() != Collection::VirtualParent ) {
CollectionStatisticsJob* csjob = new CollectionStatisticsJob( col, session );
q->connect( csjob, SIGNAL(result(KJob*)), q, SLOT(updateDone(KJob*)) );
}
}
......@@ -206,8 +207,8 @@ void CollectionModelPrivate::init()
q, SLOT(collectionChanged(Akonadi::Collection)) );
q->connect( monitor, SIGNAL(collectionRemoved(Akonadi::Collection)),
q, SLOT(collectionRemoved(Akonadi::Collection)) );
q->connect( monitor, SIGNAL(collectionStatusChanged(Akonadi::Collection::Id,Akonadi::CollectionStatus)),
q, SLOT(collectionStatusChanged(Akonadi::Collection::Id,Akonadi::CollectionStatus)) );
q->connect( monitor, SIGNAL(collectionStatisticsChanged(Akonadi::Collection::Id,Akonadi::CollectionStatistics)),
q, SLOT(collectionStatisticsChanged(Akonadi::Collection::Id,Akonadi::CollectionStatistics)) );
}
void CollectionModelPrivate::startFirstListJob()
......
......@@ -34,7 +34,7 @@ namespace Akonadi {
class CollectionModel;
class CollectionStatus;
class CollectionStatistics;
class Monitor;
class Session;
......@@ -43,7 +43,7 @@ class CollectionModelPrivate
public:
Q_DECLARE_PUBLIC( CollectionModel )
CollectionModelPrivate( CollectionModel *parent )
: q_ptr( parent ), fetchStatus( false ), unsubscribed( false )
: q_ptr( parent ), fetchStatistics( false ), unsubscribed( false )
{
}
......@@ -55,7 +55,7 @@ class CollectionModelPrivate
Monitor *monitor;
Session *session;
QStringList mimeTypes;
bool fetchStatus;
bool fetchStatistics;
bool unsubscribed;
void init();
......@@ -63,7 +63,7 @@ class CollectionModelPrivate
void collectionRemoved( const Akonadi::Collection& );
void collectionChanged( const Akonadi::Collection& );
void updateDone( KJob* );
void collectionStatusChanged( Collection::Id, const Akonadi::CollectionStatus& );
void collectionStatisticsChanged( Collection::Id, const Akonadi::CollectionStatistics& );
void listDone( KJob* );
void editDone( KJob* );
void dropResult( KJob* );
......
......@@ -23,7 +23,7 @@
using namespace Akonadi;
class CollectionStatus::Private : public QSharedData
class CollectionStatistics::Private : public QSharedData
{
public:
Private() :
......@@ -44,41 +44,41 @@ class CollectionStatus::Private : public QSharedData
};
CollectionStatus::CollectionStatus() :
CollectionStatistics::CollectionStatistics() :
d( new Private )
{
}
CollectionStatus::CollectionStatus(const CollectionStatus &other) :
CollectionStatistics::CollectionStatistics(const CollectionStatistics &other) :
d( other.d )
{
}
CollectionStatus::~CollectionStatus()
CollectionStatistics::~CollectionStatistics()
{
}
int CollectionStatus::count( ) const
int CollectionStatistics::count( ) const
{
return d->count;
}
void CollectionStatus::setCount( int count )
void CollectionStatistics::setCount( int count )
{
d->count = count;
}
int CollectionStatus::unreadCount( ) const
int CollectionStatistics::unreadCount( ) const
{
return d->unreadCount;
}
void CollectionStatus::setUnreadCount( int count )
void CollectionStatistics::setUnreadCount( int count )
{
d->unreadCount = count;
}
CollectionStatus& CollectionStatus::operator =(const CollectionStatus & other)
CollectionStatistics& CollectionStatistics::operator =(const CollectionStatistics & other)
{
d = other.d;
return *this;
......
......@@ -17,8 +17,8 @@
02110-1301, USA.
*/
#ifndef AKONADI_COLLECTIONSTATUS_H
#define AKONADI_COLLECTIONSTATUS_H
#ifndef AKONADI_COLLECTIONSTATISTICS_H
#define AKONADI_COLLECTIONSTATISTICS_H
#include "akonadi_export.h"
#include <QtCore/QMetaType>
......@@ -27,32 +27,32 @@
namespace Akonadi {
/**
Contains status information of a collection, such as
Contains statistics information of a collection, such as
total number of items, number of new/unread items, etc.
These information might be expensive to obtain and are thus
not included when fetching collection with a CollectionFetchJob.
They can be retrieved spearately using CollectionStatusJob.
They can be retrieved spearately using CollectionStatisticsJob.
This class is implicitely shared.
*/
class AKONADI_EXPORT CollectionStatus
class AKONADI_EXPORT CollectionStatistics
{
public:
/**
Creates a new CollectionStatus object.
Creates a new CollectionStatistics object.
*/
CollectionStatus();
CollectionStatistics();
/**
Copy constructor.
*/
CollectionStatus( const CollectionStatus &other );
CollectionStatistics( const CollectionStatistics &other );
/**
Destructor.
*/
~CollectionStatus();
~CollectionStatistics();
/**
Returns the number of objects in this collection.
......@@ -88,7 +88,7 @@ class AKONADI_EXPORT CollectionStatus
Assignment operator.
@param other The status object to assign to @c this
*/
CollectionStatus& operator=( const CollectionStatus &other );
CollectionStatistics& operator=( const CollectionStatistics &other );
private:
class Private;
......@@ -98,6 +98,6 @@ class AKONADI_EXPORT CollectionStatus
}
Q_DECLARE_METATYPE(Akonadi::CollectionStatus)
Q_DECLARE_METATYPE(Akonadi::CollectionStatistics)
#endif
......@@ -25,40 +25,40 @@
using namespace Akonadi;
class Akonadi::CollectionStatusJobPrivate : public JobPrivate
class Akonadi::CollectionStatisticsJobPrivate : public JobPrivate
{
public:
CollectionStatusJobPrivate( CollectionStatusJob *parent )
CollectionStatisticsJobPrivate( CollectionStatisticsJob *parent )
: JobPrivate( parent )
{
}
Collection mCollection;
CollectionStatus mStatus;
CollectionStatistics mStatistics;
};
CollectionStatusJob::CollectionStatusJob( const Collection &collection, QObject * parent )
: Job( new CollectionStatusJobPrivate( this ), parent )
CollectionStatisticsJob::CollectionStatisticsJob( const Collection &collection, QObject * parent )
: Job( new CollectionStatisticsJobPrivate( this ), parent )
{
Q_D( CollectionStatusJob );
Q_D( CollectionStatisticsJob );
d->mCollection = collection;
}
CollectionStatusJob::~CollectionStatusJob()
CollectionStatisticsJob::~CollectionStatisticsJob()
{
}
void CollectionStatusJob::doStart( )
void CollectionStatisticsJob::doStart( )
{
Q_D( CollectionStatusJob );
Q_D( CollectionStatisticsJob );
writeData( newTag() + " STATUS " + QByteArray::number( d->mCollection.id() ) + " (MESSAGES UNSEEN)\n" );
}
void CollectionStatusJob::doHandleResponse( const QByteArray & tag, const QByteArray & data )
void CollectionStatisticsJob::doHandleResponse( const QByteArray & tag, const QByteArray & data )
{
Q_D( CollectionStatusJob );
Q_D( CollectionStatisticsJob );
if ( tag == "*" ) {
QByteArray token;
......@@ -71,33 +71,33 @@ void CollectionStatusJob::doHandleResponse( const QByteArray & tag, const QByteA
current = ImapParser::parseParenthesizedList( data, list, current );
for ( int i = 0; i < list.count() - 1; i += 2 ) {
if ( list[i] == "MESSAGES" ) {
d->mStatus.setCount( list[i+1].toInt() );
d->mStatistics.setCount( list[i+1].toInt() );
} else if ( list[i] == "UNSEEN" ) {
d->mStatus.setUnreadCount( list[i+1].toInt() );
d->mStatistics.setUnreadCount( list[i+1].toInt() );
} else {
kDebug( 5250 ) << "Unknown STATUS response: " << list[i];
}
}
d->mCollection.setStatus( d->mStatus );
d->mCollection.setStatistics( d->mStatistics );
return;
}
}
kDebug( 5250 ) << "Unhandled response: " << tag << data;
}
Collection CollectionStatusJob::collection() const
Collection CollectionStatisticsJob::collection() const
{
Q_D( const CollectionStatusJob );
Q_D( const CollectionStatisticsJob );
return d->mCollection;
}
CollectionStatus Akonadi::CollectionStatusJob::status() const
CollectionStatistics Akonadi::CollectionStatisticsJob::statistics() const
{
Q_D( const CollectionStatusJob );
Q_D( const CollectionStatisticsJob );
return d->mStatus;
return d->mStatistics;
}
#include "collectionstatusjob.moc"
......@@ -17,8 +17,8 @@
02110-1301, USA.
*/
#ifndef AKONADI_COLLECTIONSTATUSJOB_H
#define AKONADI_COLLECTIONSTATUSJOB_H
#ifndef AKONADI_COLLECTIONSTATISTICSJOB_H
#define AKONADI_COLLECTIONSTATISTICSJOB_H
#include "akonadi_export.h"
#include <akonadi/collection.h>
......@@ -27,32 +27,32 @@
namespace Akonadi {
class CollectionStatusJobPrivate;
class CollectionStatisticsJobPrivate;
/**
Fetches the CollectionStatus object for a given collection.
Fetches the CollectionStatistics object for a given collection.
*/
class AKONADI_EXPORT CollectionStatusJob : public Job
class AKONADI_EXPORT CollectionStatisticsJob : public Job
{
Q_OBJECT
public:
/**
Creates a new collection status job.
Creates a new CollectionStatisticsJob
@param collection The collection.
@param parent The parent object.
*/
explicit CollectionStatusJob( const Collection &collection, QObject *parent = 0 );
explicit CollectionStatisticsJob( const Collection &collection, QObject *parent = 0 );
/**
Destroys this job.
*/
virtual ~CollectionStatusJob();
virtual ~CollectionStatisticsJob();
/**
Returns the fetched collection status.
Returns the fetched collection statistics.
*/
CollectionStatus status() const;
CollectionStatistics statistics() const;
/**
Returns the corresponding collection, if the job was executed successfully,
......@@ -65,7 +65,7 @@ class AKONADI_EXPORT CollectionStatusJob : public Job
virtual void doHandleResponse( const QByteArray &tag, const QByteArray &data );
private:
Q_DECLARE_PRIVATE( CollectionStatusJob )
Q_DECLARE_PRIVATE( CollectionStatisticsJob )
};
}
......
......@@ -30,7 +30,7 @@ using namespace Akonadi;
namespace Akonadi {
class MessageCollectionDelegatePrivate
class CollectionStatisticsDelegatePrivate
{
public:
QModelIndex index;
......@@ -38,7 +38,7 @@ class MessageCollectionDelegatePrivate
bool drawUnreadAfterFolder;
QColor unreadColor;
MessageCollectionDelegatePrivate( QTreeView *treeView )
CollectionStatisticsDelegatePrivate( QTreeView *treeView )
: parent( treeView ), drawUnreadAfterFolder( false )
{
unreadColor = KColorScheme( QPalette::Active ).
......@@ -48,44 +48,44 @@ class MessageCollectionDelegatePrivate
}
MessageCollectionDelegate::MessageCollectionDelegate( QTreeView *parent )
CollectionStatisticsDelegate::CollectionStatisticsDelegate( QTreeView *parent )
: QItemDelegate( parent ),
d_ptr( new MessageCollectionDelegatePrivate( parent ) )
d_ptr( new CollectionStatisticsDelegatePrivate( parent ) )
{
}
MessageCollectionDelegate::~MessageCollectionDelegate()
CollectionStatisticsDelegate::~CollectionStatisticsDelegate()
{
delete d_ptr;
d_ptr = 0;
}
void MessageCollectionDelegate::setUnreadColor( const QColor &color )
void CollectionStatisticsDelegate::setUnreadColor( const QColor &color )
{
Q_D( MessageCollectionDelegate );
Q_D( CollectionStatisticsDelegate );
d->unreadColor = color;
}
void MessageCollectionDelegate::toggleUnreadAfterFolderName( bool enable )
void CollectionStatisticsDelegate::toggleUnreadAfterFolderName( bool enable )
{
Q_D( MessageCollectionDelegate );
Q_D( CollectionStatisticsDelegate );
d->drawUnreadAfterFolder = enable;
}
void MessageCollectionDelegate::paint( QPainter *painter,
const QStyleOptionViewItem &option,
const QModelIndex &index ) const
void CollectionStatisticsDelegate::paint( QPainter *painter,
const QStyleOptionViewItem &option,
const QModelIndex &index ) const
{
d_ptr->index = index;
QItemDelegate::paint( painter, option, index );
}
void MessageCollectionDelegate::drawDisplay( QPainter *painter,
const QStyleOptionViewItem &option,
const QRect &rect,
const QString &text) const
void CollectionStatisticsDelegate::drawDisplay( QPainter *painter,