collection.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_COLLECTION_H 00021 #define AKONADI_COLLECTION_H 00022 00023 #include "akonadi_export.h" 00024 00025 #include <akonadi/entity.h> 00026 00027 #include <QtCore/QMetaType> 00028 #include <QtCore/QSharedDataPointer> 00029 00030 class KUrl; 00031 00032 namespace Akonadi { 00033 00034 class CachePolicy; 00035 class CollectionPrivate; 00036 class CollectionStatistics; 00037 00075 class AKONADI_EXPORT Collection : public Entity 00076 { 00077 public: 00081 typedef QList<Collection> List; 00082 00086 enum Right { 00087 ReadOnly = 0x0, 00088 CanChangeItem = 0x1, 00089 CanCreateItem = 0x2, 00090 CanDeleteItem = 0x4, 00091 CanChangeCollection = 0x8, 00092 CanCreateCollection = 0x10, 00093 CanDeleteCollection = 0x20, 00094 CanLinkItem = 0x40, 00095 CanUnlinkItem = 0x80, 00096 AllRights = (CanChangeItem | CanCreateItem | CanDeleteItem | 00097 CanChangeCollection | CanCreateCollection | CanDeleteCollection) 00098 }; 00099 Q_DECLARE_FLAGS(Rights, Right) 00100 00101 00104 Collection(); 00105 00111 explicit Collection( Id id ); 00112 00116 ~Collection(); 00117 00121 Collection( const Collection &other ); 00122 00126 static Collection fromUrl( const KUrl &url ); 00127 00131 QString name() const; 00132 00138 void setName( const QString &name ); 00139 00143 Rights rights() const; 00144 00148 void setRights( Rights rights ); 00149 00155 QStringList contentMimeTypes() const; 00156 00160 void setContentMimeTypes( const QStringList &types ); 00161 00166 KDE_DEPRECATED Id parent() const; 00167 00172 KDE_DEPRECATED void setParent( Id parent ); 00173 00178 KDE_DEPRECATED void setParent( const Collection &collection ); 00179 00185 KDE_DEPRECATED QString parentRemoteId() const; 00186 00191 KDE_DEPRECATED void setParentRemoteId( const QString &identifier ); 00192 00196 static Collection root(); 00197 00201 static QString mimeType(); 00202 00206 QString resource() const; 00207 00211 void setResource( const QString &identifier ); 00212 00216 CachePolicy cachePolicy() const; 00217 00221 void setCachePolicy( const CachePolicy &policy ); 00222 00226 CollectionStatistics statistics() const; 00227 00231 void setStatistics( const CollectionStatistics &statistics ); 00232 00238 KUrl url() const; 00239 00245 enum UrlType 00246 { 00247 UrlShort = 0, 00248 UrlWithName = 1 00249 }; 00250 00256 KUrl url( UrlType type ) const; 00257 00263 bool isVirtual() const; 00264 00265 private: 00266 AKONADI_DECLARE_PRIVATE( Collection ) 00267 friend class CollectionFetchJob; 00268 friend class CollectionModifyJob; 00269 }; 00270 00271 } 00272 00273 AKONADI_EXPORT uint qHash( const Akonadi::Collection &collection ); 00277 AKONADI_EXPORT QDebug operator<<( QDebug d, const Akonadi::Collection &collection ); 00278 00279 Q_DECLARE_METATYPE(Akonadi::Collection) 00280 Q_DECLARE_METATYPE(Akonadi::Collection::List) 00281 Q_DECLARE_OPERATORS_FOR_FLAGS( Akonadi::Collection::Rights ) 00282 00283 #endif