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

List:       kde-commits
Subject:    KDE/kdepim/akonadi/libakonadi
From:       Tobias Koenig <tokoe () kde ! org>
Date:       2007-04-21 17:27:07
Message-ID: 1177176427.441783.7952.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 656556 by tokoe:

API cleanup


 M  +5 -4      collectionattributefactory.cpp  
 M  +0 -1      collectionattributefactory.h  
 M  +36 -27    collectionfilterproxymodel.cpp  
 M  +26 -29    collectionfilterproxymodel.h  


--- trunk/KDE/kdepim/akonadi/libakonadi/collectionattributefactory.cpp #656555:656556
@@ -27,16 +27,17 @@
 {
   public:
     QHash<QByteArray, CollectionAttribute*> attributes;
+    static CollectionAttributeFactory* mInstance;
 };
 
-CollectionAttributeFactory* CollectionAttributeFactory::mInstance = 0;
+CollectionAttributeFactory* CollectionAttributeFactory::Private::mInstance = 0;
 
 CollectionAttributeFactory* CollectionAttributeFactory::self()
 {
-  if ( !mInstance )
-    mInstance = new CollectionAttributeFactory();
+  if ( !Private::mInstance )
+    Private::mInstance = new CollectionAttributeFactory();
 
-  return mInstance;
+  return Private::mInstance;
 }
 
 CollectionAttributeFactory::CollectionAttributeFactory()
--- trunk/KDE/kdepim/akonadi/libakonadi/collectionattributefactory.h #656555:656556
@@ -51,7 +51,6 @@
     void registerAttribute( CollectionAttribute *attr );
 
   private:
-    static CollectionAttributeFactory* mInstance;
     class Private;
     Private* const d;
 };
--- trunk/KDE/kdepim/akonadi/libakonadi/collectionfilterproxymodel.cpp #656555:656556
@@ -29,17 +29,48 @@
 class CollectionFilterProxyModel::Private
 {
   public:
+    Private( CollectionFilterProxyModel *parent )
+      : mParent( parent ), sourceModel( 0 )
+    {
+    }
+
+    bool collectionAccepted( const QModelIndex &index );
+
+    CollectionFilterProxyModel *mParent;
     QStringList mimeTypes;
     CollectionModel *sourceModel;
 };
 
-CollectionFilterProxyModel::CollectionFilterProxyModel(QObject *parent) :
-  QSortFilterProxyModel(parent),
-  d( new Private() )
+bool CollectionFilterProxyModel::Private::collectionAccepted( const QModelIndex \
&index )  {
-  d->sourceModel = 0L;
+  // Retrieve supported mimetypes
+  QStringList collectionMimeTypes = mParent->sourceModel()->data( index, \
CollectionModel::CollectionContentTypesRole ).toStringList(); +
+  // If this collection directly contains one valid mimetype, it is accepted
+  foreach ( QString type, mimeTypes ) {
+    if ( collectionMimeTypes.contains( type ) )
+      return true;
+  }
+  // If this collection has a child which contains valid mimetypes, it is accepted
+  QModelIndex childIndex = index.child( 0, 0 );
+  while ( childIndex.isValid() ) {
+    if ( collectionAccepted( childIndex ) )
+      return true;
+
+    childIndex = childIndex.sibling( childIndex.row() + 1, 0 );
+  }
+
+  // Or else, no reason to keep this collection.
+  return false;
 }
 
+
+CollectionFilterProxyModel::CollectionFilterProxyModel( QObject *parent )
+  : QSortFilterProxyModel( parent ),
+    d( new Private( this ) )
+{
+}
+
 CollectionFilterProxyModel::~CollectionFilterProxyModel()
 {
   delete d;
@@ -57,7 +88,7 @@
 
 bool CollectionFilterProxyModel::filterAcceptsRow( int sourceRow, const QModelIndex \
&sourceParent) const  {
-  return collectionAccepted( sourceModel()->index(sourceRow, 0, sourceParent));
+  return d->collectionAccepted( sourceModel()->index( sourceRow, 0, sourceParent ) \
);  }
 
 QStringList CollectionFilterProxyModel::mimeTypes() const
@@ -65,26 +96,4 @@
   return d->mimeTypes;
 }
 
-bool CollectionFilterProxyModel::collectionAccepted(const QModelIndex &index) const
-{
-  // Retrieve supported mimetypes
-  QStringList collectionMimeTypes = sourceModel()->data( index, \
                CollectionModel::CollectionContentTypesRole).toStringList();
-
-  // If this collection directly contains one valid mimetype, it is accepted
-  foreach(QString type, d->mimeTypes) {
-    if (collectionMimeTypes.contains(type))
-      return true;
-  }
-  // If this collection has a child which contains valid mimetypes, it is accepted
-  QModelIndex childIndex = index.child(0, 0);
-  while(childIndex.isValid()) {
-    if (collectionAccepted(childIndex)) return true;
-    childIndex = childIndex.sibling(childIndex.row() + 1, 0);
-  }
-
-  // Or else, no reason to keep this collection.
-  return false;
-}
-
-
 #include "collectionfilterproxymodel.moc"
--- trunk/KDE/kdepim/akonadi/libakonadi/collectionfilterproxymodel.h #656555:656556
@@ -49,44 +49,41 @@
   Q_OBJECT
 
   public:
-	/**
-	 * Create a new CollectionProxyFilterModel
-	 * @param parent The parent object
-	 */
-	CollectionFilterProxyModel(QObject *parent = 0);
-	
-	/**
-	 * Destroy the model
-	 **/
-	virtual ~CollectionFilterProxyModel();
+    /**
+     * Create a new CollectionProxyFilterModel
+     * @param parent The parent object
+     */
+    CollectionFilterProxyModel( QObject *parent = 0 );
 
-	/**
-	 * Add types to be shown by the filter
-	 * @param typeList A list of mimetypes to be shown
-	 */
-	void addMimeTypes(const QStringList &typeList);
-	/**
-	 * Convenience method for the previous one
-	 * @param type A type to show
-	 */
-	void addMimeType(const QString &type);
     /**
+     * Destroy the model
+     **/
+    virtual ~CollectionFilterProxyModel();
+
+    /**
+     * Add types to be shown by the filter
+     * @param typeList A list of mimetypes to be shown
+     */
+    void addMimeTypes( const QStringList &typeList );
+
+    /**
+     * Convenience method for the previous one
+     * @param type A type to show
+     */
+    void addMimeType( const QString &type );
+
+    /**
      * @return The list of supported mimetypes
      */
     QStringList mimeTypes() const;
-    
-   protected:
+
+  protected:
     /**
      * Reimplemented to only accept rows (collections) which are able to contain the \
                filter mimetypes.
      */
-	virtual bool filterAcceptsRow( int sourceRow, const QModelIndex &sourceParent) \
                const; 
-	
-  private:
-    /**
-     * Used by filterAcceptsRow (recursive)
-     */
-    bool collectionAccepted(const QModelIndex &index) const;
+    virtual bool filterAcceptsRow( int sourceRow, const QModelIndex &sourceParent) \
const;   
+  private:
     class Private;
     Private* const d;
 };


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

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