itemmodel.h
00001 /* 00002 Copyright (c) 2006 - 2007 Volker Krause <vkrause@kde.org> 00003 00004 This library is free software; you can redistribute it and/or modify it 00005 under the terms of the GNU Library General Public License as published by 00006 the Free Software Foundation; either version 2 of the License, or (at your 00007 option) any later version. 00008 00009 This library is distributed in the hope that it will be useful, but WITHOUT 00010 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00011 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public 00012 License for more details. 00013 00014 You should have received a copy of the GNU Library General Public License 00015 along with this library; see the file COPYING.LIB. If not, write to the 00016 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 00017 02110-1301, USA. 00018 */ 00019 00020 #ifndef AKONADI_ITEMMODEL_H 00021 #define AKONADI_ITEMMODEL_H 00022 00023 #include "akonadi_export.h" 00024 #include <akonadi/item.h> 00025 #include <akonadi/job.h> 00026 00027 #include <QtCore/QAbstractTableModel> 00028 00029 namespace Akonadi { 00030 00031 class Collection; 00032 class ItemFetchScope; 00033 class Job; 00034 class Session; 00035 00056 class AKONADI_EXPORT_DEPRECATED ItemModel : public QAbstractTableModel 00057 { 00058 Q_OBJECT 00059 00060 public: 00064 enum Column { 00065 Id = 0, 00066 RemoteId, 00067 MimeType 00068 }; 00069 00073 enum Roles { 00074 IdRole = Qt::UserRole + 1, 00075 ItemRole, 00076 MimeTypeRole, 00077 UserRole = Qt::UserRole + 42 00078 }; 00079 00085 explicit ItemModel( QObject* parent = 0 ); 00086 00090 virtual ~ItemModel(); 00091 00092 virtual int columnCount( const QModelIndex & parent = QModelIndex() ) const; 00093 00094 virtual QVariant data( const QModelIndex & index, int role = Qt::DisplayRole ) const; 00095 00096 virtual int rowCount( const QModelIndex & parent = QModelIndex() ) const; 00097 00098 virtual QVariant headerData( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const; 00099 00100 virtual Qt::ItemFlags flags( const QModelIndex &index ) const; 00101 00102 virtual QMimeData *mimeData( const QModelIndexList &indexes ) const; 00103 00104 virtual QStringList mimeTypes() const; 00105 00106 virtual Qt::DropActions supportedDropActions() const; 00107 00118 void setFetchScope( const ItemFetchScope &fetchScope ); 00119 00132 ItemFetchScope &fetchScope(); 00133 00137 Item itemForIndex( const QModelIndex &index ) const; 00138 00145 QModelIndex indexForItem( const Akonadi::Item& item, const int column ) const; 00146 00147 bool dropMimeData( const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent ); 00148 00152 Collection collection() const; 00153 00154 public Q_SLOTS: 00162 void setCollection( const Akonadi::Collection &collection ); 00163 00164 Q_SIGNALS: 00170 void collectionChanged( const Akonadi::Collection &collection ); 00171 00172 protected: 00176 Session* session() const; 00177 00178 private: 00179 //@cond PRIVATE 00180 class Private; 00181 Private* const d; 00182 00183 Q_PRIVATE_SLOT( d, void listingDone( KJob* ) ) 00184 Q_PRIVATE_SLOT( d, void collectionFetchResult( KJob* ) ) 00185 Q_PRIVATE_SLOT( d, void itemChanged( const Akonadi::Item&, const QSet<QByteArray>& ) ) 00186 Q_PRIVATE_SLOT( d, void itemMoved( const Akonadi::Item&, const Akonadi::Collection&, const Akonadi::Collection& ) ) 00187 Q_PRIVATE_SLOT( d, void itemAdded( const Akonadi::Item& ) ) 00188 Q_PRIVATE_SLOT( d, void itemsAdded( const Akonadi::Item::List& ) ) 00189 Q_PRIVATE_SLOT( d, void itemRemoved( const Akonadi::Item& ) ) 00190 //@endcond 00191 }; 00192 00193 } 00194 00195 #endif