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

List:       kde-commits
Subject:    KDE/kdepim/akonadi/libakonadi
From:       Volker Krause <vkrause () kde ! org>
Date:       2007-01-12 14:15:57
Message-ID: 1168611357.829032.20060.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 622635 by vkrause:

fix the ItemModel to show at least something


 M  +6 -6      collectionview.h  
 M  +37 -3     itemmodel.cpp  
 M  +10 -3     itemmodel.h  
 M  +1 -1      messagemodel.cpp  


--- trunk/KDE/kdepim/akonadi/libakonadi/collectionview.h #622634:622635
@@ -52,6 +52,12 @@
     */
     virtual void setModel ( QAbstractItemModel * model );
 
+    /**
+      Translates a QModelIndex from the sort proxy model into a QModelIndex
+      from the CollectionModel if necessary.
+    */
+    QModelIndex sourceIndex( const QModelIndex &index );
+
   public Q_SLOTS:
     /**
       Add a child collection to the given model index.
@@ -63,12 +69,6 @@
     virtual void dragLeaveEvent( QDragLeaveEvent *event );
     virtual void dropEvent( QDropEvent *event );
 
-    /**
-      Translates a QModelIndex from the sort proxy model into a QModelIndex
-      from the CollectionModel if necessary.
-    */
-    QModelIndex sourceIndex( const QModelIndex &index );
-
   private slots:
     void dragExpand();
 
--- trunk/KDE/kdepim/akonadi/libakonadi/itemmodel.cpp #622634:622635
@@ -61,13 +61,24 @@
 
 QVariant Akonadi::ItemModel::data( const QModelIndex & index, int role ) const
 {
-  Q_UNUSED( role );
   if ( !index.isValid() )
     return QVariant();
   if ( index.row() >= d->items.count() )
     return QVariant();
-  Item* itm = d->items.at( index.row() );
-  return itm->data();
+  Item* item = d->items.at( index.row() );
+  if ( !item )
+    return QVariant();
+
+  if ( role == Qt::DisplayRole ) {
+    switch ( index.column() ) {
+      case Id:
+        return QString::number( item->reference().persistanceID() );
+      case MimeType:
+        return QString::fromLatin1( item->mimeType() );
+    }
+  }
+
+  return QVariant();
 }
 
 int Akonadi::ItemModel::rowCount( const QModelIndex & parent ) const
@@ -77,8 +88,25 @@
   return 0;
 }
 
+int ItemModel::columnCount(const QModelIndex & parent) const
+{
+  if ( !parent.isValid() )
+    return 2; // keep in sync with Column enum
+  return 0;
+}
+
 QVariant Akonadi::ItemModel::headerData( int section, Qt::Orientation orientation, int role ) const
 {
+  if ( orientation == Qt::Horizontal && role == Qt::DisplayRole ) {
+    switch ( section ) {
+      case Id:
+        return i18n( "Id" );
+      case MimeType:
+        return i18n( "MimeType" );
+      default:
+        return QString();
+    }
+  }
   return QAbstractTableModel::headerData( section, orientation, role );
 }
 
@@ -114,6 +142,7 @@
   } else {
     d->items = d->listingJob->items();
     reset();
+    kDebug() << k_funcinfo << "################################" << d->items.count() << endl;
   }
   d->listingJob->deleteLater();
   d->listingJob = 0;
@@ -235,4 +264,9 @@
   return itm;
 }
 
+ItemFetchJob* ItemModel::createFetchJob(const QString & path, QObject * parent)
+{
+  return new ItemFetchJob( path, parent );
+}
+
 #include "itemmodel.moc"
--- trunk/KDE/kdepim/akonadi/libakonadi/itemmodel.h #622634:622635
@@ -39,6 +39,14 @@
 
   public:
     /**
+      Columns types.
+    */
+    enum Column {
+      Id = 0, /**< The unique id. */
+      MimeType /**< Item mimetype. */
+    };
+
+    /**
       Creates a new message model.
 
       @param parent The parent object.
@@ -53,7 +61,7 @@
     /**
       Reimplemented from QAbstractItemModel.
      */
-    virtual int columnCount( const QModelIndex & parent = QModelIndex() ) const = 0;
+    virtual int columnCount( const QModelIndex & parent = QModelIndex() ) const;
 
     /**
       Reimplemented from QAbstractItemModel.
@@ -83,7 +91,7 @@
       @param path The full collection path.
       @param parent The parent of the fetchjob.
     */
-    virtual ItemFetchJob* createFetchJob( const QString &path, QObject* parent = 0 ) = 0;
+    virtual ItemFetchJob* createFetchJob( const QString &path, QObject* parent = 0 );
 
     /**
       Returns the message reference to the given model index. If the index
@@ -92,7 +100,6 @@
     */
     virtual DataReference referenceForIndex( const QModelIndex &index ) const;
 
-
   protected:
     /**
       Returns the item at given index.
--- trunk/KDE/kdepim/akonadi/libakonadi/messagemodel.cpp #622634:622635
@@ -99,7 +99,7 @@
         return QString();
     }
   }
-  return QAbstractTableModel::headerData( section, orientation, role );
+  return ItemModel::headerData( section, orientation, role );
 }
 
 ItemFetchJob* MessageModel::createFetchJob( const QString &path, QObject* parent )
[prev in list] [next in list] [prev in thread] [next in thread] 

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