Allow specializations to decide when re-indexing is necessary.
[kdepim.git] / messagelist / storagemodel.h
blobad7399da69d3fe317447ece6063cb82b25648a5b
1 /*
2 Copyright (c) 2009 Kevin Ottens <ervin@kde.org>
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 #ifndef __MESSAGELIST_STORAGEMODEL_H__
20 #define __MESSAGELIST_STORAGEMODEL_H__
22 #include <messagelist/core/storagemodelbase.h>
24 #include <akonadi/collection.h>
25 #include <akonadi/item.h>
27 #include <QtGui/QColor>
28 #include <QtGui/QFont>
30 #include <kmime/kmime_message.h>
32 #include <messagelist/messagelist_export.h>
34 class QAbstractItemModel;
35 class QItemSelectionModel;
37 namespace MessageList
40 namespace Core
42 class MessageItem;
45 /**
46 * The Akonadi specific implementation of the Core::StorageModel.
48 class MESSAGELIST_EXPORT StorageModel : public MessageList::Core::StorageModel
50 Q_OBJECT
52 public:
53 /**
54 * Create a StorageModel wrapping the specified folder.
56 explicit StorageModel( QAbstractItemModel *model, QItemSelectionModel *selectionModel, QObject *parent = 0 );
57 ~StorageModel();
59 Akonadi::Collection::List displayedCollections() const;
61 virtual QString id() const;
62 virtual bool containsOutboundMessages() const;
63 virtual int initialUnreadRowCountGuess() const;
64 virtual bool initializeMessageItem( MessageList::Core::MessageItem *mi, int row, bool bUseReceiver ) const;
65 virtual void fillMessageItemThreadingData( MessageList::Core::MessageItem *mi, int row, ThreadingDataSubset subset ) const;
66 virtual void updateMessageItemData( MessageList::Core::MessageItem *mi, int row ) const;
67 virtual void setMessageItemStatus( MessageList::Core::MessageItem *mi, int row, const KPIM::MessageStatus &status );
69 virtual int columnCount( const QModelIndex &parent = QModelIndex() ) const;
70 virtual QVariant data( const QModelIndex &index, int role = Qt::DisplayRole ) const;
71 virtual QModelIndex index( int row, int column, const QModelIndex &parent = QModelIndex() ) const;
72 virtual QModelIndex parent( const QModelIndex &index ) const;
73 virtual int rowCount( const QModelIndex &parent = QModelIndex() ) const;
75 virtual void prepareForScan();
77 Akonadi::Item itemForRow( int row ) const;
78 KMime::Message::Ptr messageForRow( int row ) const;
80 private:
81 Q_PRIVATE_SLOT(d, void onSourceDataChanged( const QModelIndex&, const QModelIndex& ))
82 Q_PRIVATE_SLOT(d, void onSelectionChanged())
83 Q_PRIVATE_SLOT(d, void loadSettings())
84 Q_PRIVATE_SLOT(d, void statementChanged( const Soprano::Statement & ))
86 class Private;
87 Private * const d;
90 } // namespace MessageList
92 #endif //!__MESSAGELIST_STORAGEMODEL_H__