[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdepimlibs/akonadi
From:       Tobias Koenig <tokoe () kde ! org>
Date:       2008-04-11 14:48:15
Message-ID: 1207925295.721417.4342.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 795833 by tokoe:

Removed Collection::Type property from public API and added helper class


 M  +2 -1      cachepolicypage.cpp  
 M  +0 -14     collection.cpp  
 M  +0 -26     collection.h  
 M  +0 -3      collection_p.h  
 M  +16 -10    collectionmodel.cpp  
 M  +2 -1      collectionmodel_p.cpp  
 A             collectionutils_p.h   [License: LGPL (v2+)]
 M  +0 -14     protocolhelper.cpp  
 M  +5 -4      standardactionmanager.cpp  
 M  +3 -2      subscriptionmodel.cpp  
 M  +6 -5      tests/collectionjobtest.cpp  
 M  +3 -1      tests/searchjobtest.cpp  


--- trunk/KDE/kdepimlibs/akonadi/cachepolicypage.cpp #795832:795833
@@ -21,6 +21,7 @@
 
 #include "cachepolicy.h"
 #include "collection.h"
+#include "collectionutils_p.h"
 
 using namespace Akonadi;
 
@@ -33,7 +34,7 @@
 
 bool Akonadi::CachePolicyPage::canHandle(const Collection & collection) const
 {
-  return collection.type() != Collection::VirtualParent && collection.type() != \
Collection::Virtual; +  return !CollectionUtils::isVirtual( collection );
 }
 
 void CachePolicyPage::load(const Collection & collection)
--- trunk/KDE/kdepimlibs/akonadi/collection.cpp #795832:795833
@@ -41,7 +41,6 @@
     CollectionPrivate( Collection::Id id = -1 ) :
       EntityPrivate( id ),
       parentId( -1 ),
-      type( Collection::Unknown ),
       contentTypesChanged( false ),
       cachePolicyChanged( false )
     {}
@@ -52,7 +51,6 @@
       parentId = other.parentId;
       name = other.name;
       parentRemoteId = other.parentRemoteId;
-      type = other.type;
       resource = other.resource;
       statistics = other.statistics;
       contentTypes = other.contentTypes;
@@ -89,7 +87,6 @@
     Collection::Id parentId;
     QString name;
     QString parentRemoteId;
-    Collection::Type type;
     QString resource;
     CollectionStatistics statistics;
     QStringList contentTypes;
@@ -134,17 +131,6 @@
   d->name = name;
 }
 
-Collection::Type Collection::type() const
-{
-  return d_func()->type;
-}
-
-void Collection::setType( Type type )
-{
-  Q_D( Collection );
-  d->type = type;
-}
-
 Collection::Rights Collection::rights() const
 {
   CollectionRightsAttribute *attr = attribute<CollectionRightsAttribute>();
--- trunk/KDE/kdepimlibs/akonadi/collection.h #795832:795833
@@ -48,19 +48,6 @@
 class AKONADI_EXPORT Collection : public Entity
 {
   public:
-    /**
-      Collection types.
-    */
-    enum Type {
-      Folder, /**< 'Real' folder on an IMAP server for example. */
-      Virtual, /**< Virtual collection (aka search folder). */
-      Structural, /**< Structural node to keep the collection tree consistent but \
                cannot contain any content. */
-      Resource, /**< Resource or account. */
-      VirtualParent, /**< The parent collection of all virtual collections. */
-      Unknown /**< Unknown collection type. */
-    };
-    //FIXME_API: drop the above types completely
-
     /// A list of collections.
     typedef QList<Collection> List;
 
@@ -120,19 +107,6 @@
     void setName( const QString &name );
 
     /**
-      Returns the type of this collection (e.g. virtual folder, folder on an
-      IMAP server, etc.).
-    */
-    Type type() const;
-    //FIXME_API: drop together with types
-
-    /**
-      Sets the type of this collection.
-    */
-    void setType( Type type );
-    //FIXME_API: drop together with types
-
-    /**
       Returns the rights the user has on this collection.
      */
     Rights rights() const;
--- trunk/KDE/kdepimlibs/akonadi/collection_p.h #795832:795833
@@ -31,7 +31,6 @@
     CollectionPrivate( Collection::Id id = -1 ) :
       EntityPrivate( id ),
       parentId( -1 ),
-      type( Collection::Unknown ),
       contentTypesChanged( false ),
       cachePolicyChanged( false )
     {}
@@ -42,7 +41,6 @@
       parentId = other.parentId;
       name = other.name;
       parentRemoteId = other.parentRemoteId;
-      type = other.type;
       resource = other.resource;
       statistics = other.statistics;
       contentTypes = other.contentTypes;
@@ -79,7 +77,6 @@
     Collection::Id parentId;
     QString name;
     QString parentRemoteId;
-    Collection::Type type;
     QString resource;
     CollectionStatistics statistics;
     QStringList contentTypes;
--- trunk/KDE/kdepimlibs/akonadi/collectionmodel.cpp #795832:795833
@@ -19,6 +19,7 @@
 
 #include "collectionmodel.h"
 #include "collectionmodel_p.h"
+#include "collectionutils_p.h"
 
 #include "collectionmodifyjob.h"
 #include "monitor.h"
@@ -87,17 +88,19 @@
   switch ( role ) {
     case Qt::DecorationRole:
       if ( index.column() == 0 ) {
-        if ( col.type() == Collection::Resource )
-          return SmallIcon( QLatin1String( "network-wired" ) );
-        if ( col.type() == Collection::VirtualParent )
+        if ( CollectionUtils::isVirtualParent( col ) )
           return SmallIcon( QLatin1String( "edit-find" ) );
-        if ( col.type() == Collection::Virtual )
+        if ( CollectionUtils::isVirtual( col ) )
           return SmallIcon( QLatin1String( "folder-violet" ) );
-        if ( col.type() == Collection::Structural )
+        if ( CollectionUtils::isResource( col ) )
+          return SmallIcon( QLatin1String( "network-wired" ) );
+        if ( CollectionUtils::isStructural( col ) )
           return SmallIcon( QLatin1String( "folder-grey" ) );
-        QStringList content = col.contentMimeTypes();
+
+        const QStringList content = col.contentMimeTypes();
         if ( content.size() == 1 || (content.size() == 2 && content.contains( \
                Collection::mimeType() )) ) {
-          if ( content.contains( QLatin1String( "text/x-vcard" ) ) || \
content.contains( QLatin1String( "text/directory" ) ) || content.contains( \
QLatin1String( "text/vcard" ) ) ) +          if ( content.contains( QLatin1String( \
"text/x-vcard" ) ) || content.contains( QLatin1String( "text/directory" ) ) +         \
                || content.contains( QLatin1String( "text/vcard" ) ) )
             return SmallIcon( QLatin1String( "kmgroupware_folder_contacts" ) );
           // TODO: add all other content types and/or fix their mimetypes
           if ( content.contains( QLatin1String( "akonadi/event" ) ) || \
content.contains( QLatin1String( "text/ical" ) ) ) @@ -216,11 +219,14 @@
     return flags | Qt::ItemIsDropEnabled; // HACK Workaround for a probable bug in \
Qt  
   if ( col.isValid() ) {
-    if ( col.type() != Collection::VirtualParent )  {
+    if ( col.rights() & (Collection::CanChangeCollection |
+                         Collection::CanCreateCollection |
+                         Collection::CanDeleteCollection |
+                         Collection::CanCreateItem) )  {
       if ( index.column() == 0 )
         flags = flags | Qt::ItemIsEditable;
-      if ( col.type() != Collection::Virtual )
-        flags = flags | Qt::ItemIsDropEnabled;
+
+      flags = flags | Qt::ItemIsDropEnabled;
     }
   }
 
--- trunk/KDE/kdepimlibs/akonadi/collectionmodel_p.cpp #795832:795833
@@ -21,6 +21,7 @@
 
 #include "collectionmodel_p.h"
 #include "collectionmodel.h"
+#include "collectionutils_p.h"
 
 #include "collectionfetchjob.h"
 #include "collectionstatistics.h"
@@ -164,7 +165,7 @@
     updateSupportedMimeTypes( col );
 
     // start a statistics job for every collection to get message counts, etc.
-    if ( fetchStatistics && col.type() != Collection::VirtualParent ) {
+    if ( fetchStatistics && !CollectionUtils::isVirtualParent( col ) ) {
       CollectionStatisticsJob* csjob = new CollectionStatisticsJob( col, session );
       q->connect( csjob, SIGNAL(result(KJob*)), q, SLOT(updateDone(KJob*)) );
     }
--- trunk/KDE/kdepimlibs/akonadi/protocolhelper.cpp #795832:795833
@@ -126,20 +126,6 @@
     }
   }
 
-  // determine collection type
-  if ( collection.parent() == Collection::root().id() ) {
-    if ( collection.resource() == QLatin1String( "akonadi_search_resource" ) )
-      collection.setType( Collection::VirtualParent );
-    else
-      collection.setType( Collection::Resource );
-  } else if ( collection.resource() == QLatin1String( "akonadi_search_resource" ) ) \
                {
-    collection.setType( Collection::Virtual );
-  } else if ( collection.contentMimeTypes().isEmpty() ) {
-    collection.setType( Collection::Structural );
-  } else {
-    collection.setType( Collection::Folder );
-  }
-
   return pos;
 }
 
--- trunk/KDE/kdepimlibs/akonadi/standardactionmanager.cpp #795832:795833
@@ -23,6 +23,7 @@
 #include "collectioncreatejob.h"
 #include "collectiondeletejob.h"
 #include "collectionmodel.h"
+#include "collectionutils_p.h"
 #include "collectionpropertiesdialog.h"
 #include "itemdeletejob.h"
 #include "itemmodel.h"
@@ -68,7 +69,7 @@
 
 static bool canCreateCollection( const Collection &collection )
 {
-  if ( collection.type() == Collection::Virtual || collection.type() == \
Collection::VirtualParent ) +  if ( !( collection.rights() & \
Collection::CanCreateCollection ) )  return false;
 
   if ( !collection.contentMimeTypes().contains( Collection::mimeType() ) )
@@ -136,8 +137,8 @@
       if ( singleColSelected && selectedIndex.isValid() ) {
         const Collection col = selectedIndex.data( CollectionModel::CollectionRole \
).value<Collection>();  enableAction( CreateCollection, canCreateCollection( col ) );
-        enableAction( DeleteCollections, col.type() != Collection::Resource && \
                col.type() != Collection::VirtualParent );
-        enableAction( SynchronizeCollections, col.type() == Collection::Folder || \
col.type() == Collection::Resource ); +        enableAction( DeleteCollections, \
col.rights() & Collection::CanDeleteCollection ); +        enableAction( \
SynchronizeCollections, CollectionUtils::isResource( col ) || \
                CollectionUtils::isFolder( col ) );
         enableAction( Paste, PasteHelper::canPaste( \
QApplication::clipboard()->mimeData(), col ) );  } else {
         enableAction( CreateCollection, false );
@@ -207,7 +208,7 @@
 
       const Collection collection = index.data( CollectionModel::CollectionRole \
                ).value<Collection>();
       QString text = i18n( "Do you really want to delete folder '%1' and all its \
                sub-folders?", index.data().toString() );
-      if ( collection.type() == Collection::Virtual )
+      if ( CollectionUtils::isVirtual( collection ) )
         text = i18n( "Do you really want to delete the search view '%1'?", \
index.data().toString() );  
       if ( KMessageBox::questionYesNo( parentWidget, text,
--- trunk/KDE/kdepimlibs/akonadi/subscriptionmodel.cpp #795832:795833
@@ -19,6 +19,7 @@
 
 #include "subscriptionmodel.h"
 #include "collectionfetchjob.h"
+#include "collectionutils_p.h"
 
 #include <kdebug.h>
 
@@ -53,7 +54,7 @@
       }
       Collection::List cols = static_cast<CollectionFetchJob*>( job \
)->collections();  foreach( const Collection col, cols )
-        if ( col.type() != Collection::Structural )
+        if ( !CollectionUtils::isStructural( col ) )
           subscriptions[ col.id() ] = true;
       q->reset();
       emit q->loaded();
@@ -62,7 +63,7 @@
     bool isSubscribable( Collection::Id id )
     {
       Collection col = q->collectionForId( id );
-      if ( col.type() == Collection::VirtualParent || col.type() == \
Collection::Structural ) +      if ( CollectionUtils::isVirtualParent( col ) || \
CollectionUtils::isStructural( col ) )  return false;
       if ( col.contentMimeTypes().isEmpty() )
         return false;
--- trunk/KDE/kdepimlibs/akonadi/tests/collectionjobtest.cpp #795832:795833
@@ -28,10 +28,11 @@
 #include "collectiondeletejob.h"
 #include "collectionfetchjob.h"
 #include "collectionmodifyjob.h"
+#include "collectionselectjob.h"
 #include "collectionstatistics.h"
 #include "collectionstatisticsjob.h"
 #include "collectionpathresolver_p.h"
-#include "collectionselectjob.h"
+#include "collectionutils_p.h"
 #include "control.h"
 #include "item.h"
 #include "kmime/messageparts.h"
@@ -97,7 +98,7 @@
   QVERIFY( col.isValid() );
   res1ColId = col.id(); // for the next test
   QVERIFY( res1ColId > 0 );
-  QCOMPARE( col.type(), Collection::Resource );
+  QVERIFY( CollectionUtils::isResource( col ) );
   QCOMPARE( col.parent(), Collection::root().id() );
   QCOMPARE( col.resource(), QLatin1String("akonadi_dummy_resource_1") );
 
@@ -111,7 +112,7 @@
   col = findCol( list, "Search" );
   searchColId = col.id();
   QVERIFY( col.isValid() );
-  QCOMPARE( col.type(), Collection::VirtualParent );
+  QVERIFY( CollectionUtils::isVirtualParent( col ) );
   QCOMPARE( col.resource(), QLatin1String("akonadi_search_resource") );
 }
 
@@ -143,7 +144,7 @@
   col = findCol( list, "foo" );
   QVERIFY( col.isValid() );
   QCOMPARE( col.parent(), res1ColId );
-  QCOMPARE( col.type(), Collection::Folder );
+  QVERIFY( CollectionUtils::isFolder( col ) );
   contentTypes << "message/rfc822" << "text/calendar" << "text/vcard" << \
"application/octet-stream";  compareLists( col.contentMimeTypes(), contentTypes );
 
@@ -180,7 +181,7 @@
   QCOMPARE( list.count(), 3 );
   Collection col = findCol( list, "Test ?er" );
   QVERIFY( col.isValid() );
-  QCOMPARE( col.type(), Collection::Virtual );
+  QVERIFY( CollectionUtils::isVirtual( col ) );
   QCOMPARE( col.resource(), QLatin1String("akonadi_search_resource" ) );
   QVERIFY( findCol( list, "all" ).isValid() );
   QVERIFY( findCol( list, "kde-core-devel" ).isValid() );
--- trunk/KDE/kdepimlibs/akonadi/tests/searchjobtest.cpp #795832:795833
@@ -25,6 +25,8 @@
 #include <akonadi/collectionfetchjob.h>
 #include <akonadi/searchcreatejob.h>
 
+#include "collectionutils_p.h"
+
 #include <qtest_kde.h>
 
 QTEST_KDEMAIN( SearchJobTest, NoGUI )
@@ -46,7 +48,7 @@
   }
   QVERIFY( col.isValid() );
   QCOMPARE( col.parent(), 1LL );
-  QCOMPARE( col.type(), Collection::Virtual );
+  QVERIFY( CollectionUtils::isVirtual( col ) );
 
   CollectionDeleteJob *delJob = new CollectionDeleteJob( col, this );
   QVERIFY( delJob->exec() );


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic