Make the boss happy.
[kdepim.git] / kmail / collectionpane.cpp
blobc6d6f9ed1e632cad4be10f85cac712c604244d8d
1 /*
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"
21 #include "kmkernel.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() ) {
58 return true;
60 QSharedPointer<FolderCollection> fd = FolderCollection::forCollection( c, false );
61 if ( fd ) {
62 const QString folderString( fd->idString() );
63 // default setting
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() )
72 return false;
73 if ( c == CommonKernel->outboxCollectionFolder() ||
74 c == CommonKernel->sentCollectionFolder() ||
75 c == CommonKernel->templatesCollectionFolder() ||
76 c == CommonKernel->draftsCollectionFolder() )
77 return true;
78 } else if ( identity.drafts() == folderString ||
79 identity.templates() == folderString ||
80 identity.fcc() == folderString )
81 // drafts, templates or sent of the identity
82 return true;
83 else
84 return false;
87 return false;
92 #include "collectionpane.moc"