2 This file is part of KMail, the KDE mail client.
3 Copyright (c) 2010 Montel Laurent <montel@kde.org>
5 KMail is free software; you can redistribute it and/or modify it
6 under the terms of the GNU General Public License, version 2, as
7 published by the Free Software Foundation.
9 KMail is distributed in the hope that it will be useful, but
10 WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 General Public License for more details.
14 You should have received a copy of the GNU General Public License along
15 with this program; if not, write to the Free Software Foundation, Inc.,
16 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 #include "collectionpane.h"
22 #include "mailkernel.h"
24 #include "foldercollection.h"
25 #include <kpimidentities/identitymanager.h>
26 #include <kpimidentities/identity.h>
27 #include <akonadi/kmime/messagefolderattribute.h>
29 using namespace MailCommon
;
31 CollectionPane::CollectionPane( QAbstractItemModel
*model
, QItemSelectionModel
*selectionModel
, QWidget
*parent
)
32 :MessageList::Pane( model
, selectionModel
, parent
)
36 CollectionPane::~CollectionPane()
40 MessageList::StorageModel
*CollectionPane::createStorageModel( QAbstractItemModel
*model
, QItemSelectionModel
*selectionModel
, QObject
*parent
)
42 return new CollectionStorageModel( model
, selectionModel
, parent
);
45 CollectionStorageModel::CollectionStorageModel( QAbstractItemModel
*model
, QItemSelectionModel
*selectionModel
, QObject
*parent
)
46 : MessageList::StorageModel( model
, selectionModel
, parent
)
50 CollectionStorageModel::~CollectionStorageModel()
54 bool CollectionStorageModel::isOutBoundFolder( const Akonadi::Collection
& c
) const
56 if ( c
.hasAttribute
<Akonadi::MessageFolderAttribute
>()
57 && c
.attribute
<Akonadi::MessageFolderAttribute
>()->isOutboundFolder() ) {
60 QSharedPointer
<FolderCollection
> fd
= FolderCollection::forCollection( c
, false );
62 const QString
folderString( fd
->idString() );
64 const KPIMIdentities::Identity
& identity
=
65 kmkernel
->identityManager()->identityForUoidOrDefault( fd
->identity() );
67 if ( CommonKernel
->isSystemFolderCollection(c
) &&
68 !kmkernel
->isImapFolder( c
) ) {
69 // local system folders
70 if ( c
== CommonKernel
->inboxCollectionFolder() ||
71 c
== CommonKernel
->trashCollectionFolder() )
73 if ( c
== CommonKernel
->outboxCollectionFolder() ||
74 c
== CommonKernel
->sentCollectionFolder() ||
75 c
== CommonKernel
->templatesCollectionFolder() ||
76 c
== CommonKernel
->draftsCollectionFolder() )
78 } else if ( identity
.drafts() == folderString
||
79 identity
.templates() == folderString
||
80 identity
.fcc() == folderString
)
81 // drafts, templates or sent of the identity
92 #include "collectionpane.moc"