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

List:       kde-commits
Subject:    [kdepimlibs/akregator_port] krss: fixes for the model and example
From:       Frank Osterfeld <frank.osterfeld () kdemail ! net>
Date:       2012-03-31 15:16:22
Message-ID: 20120331151622.57C90A60FB () git ! kde ! org
[Download RAW message or body]

Git commit dae4f459c843e2b1bd4937b8a2e831ab556d3bdc by Frank Osterfeld.
Committed on 17/10/2009 at 18:23.
Pushed by osterfeld into branch 'akregator_port'.

fixes for the model and example

svn path=/branches/work/akonadi-ports/kdepim/; revision=1036693

M  +42   -19   krss/feeditemmodel.cpp
M  +9    -2    krss/feeditemmodel.h

http://commits.kde.org/kdepimlibs/dae4f459c843e2b1bd4937b8a2e831ab556d3bdc

diff --git a/krss/feeditemmodel.cpp b/krss/feeditemmodel.cpp
index 0dce9a1..fd41dbc 100644
--- a/krss/feeditemmodel.cpp
+++ b/krss/feeditemmodel.cpp
@@ -59,20 +59,23 @@ QVariant FeedItemModel::getData( const Akonadi::Item \
&akonadiItem, int column, i  return false;
 
     if ( role == Qt::DisplayRole || role == SortRole ) {
-        QString authors;
         switch ( column ) {
             case ItemTitleColumn:
                 return item.titleAsPlainText();
             case AuthorsColumn:
+            {
+                QString authors;
                 Q_FOREACH( const KRss::Person &person, item.authors() ) {
-                    authors += person.name() + QLatin1Char(';');
+                    if ( !authors.isEmpty() )
+                        authors.append( QLatin1Char(';') );
+                    authors += person.name();
                 }
-                authors.remove( authors.length() - 1, 1 );
                 return authors;
+            }
             case DateColumn:
                 return KGlobal::locale()->formatDateTime( item.dateUpdated(),
                                                           KLocale::FancyShortDate );
-            case FeedTitleColumn:
+            case FeedTitleForItemColumn:
 #ifdef TEMPORARILY_REMOVED
                return d->m_feed->title();
 #endif
@@ -122,28 +125,48 @@ QVariant FeedItemModel::getData( const Collection &collection, \
int column, int r  return EntityTreeModel::getData( collection, column, role );
 }
 
-int FeedItemModel::columnCount( const QModelIndex& index ) const {
-    Q_UNUSED( index );
-    return ItemColumnCount;
+int FeedItemModel::getColumnCount( int headerSet ) const {
+    if ( headerSet == ItemListHeaders )
+        return ItemColumnCount;
+    else
+        return FeedColumnCount;
 }
 
 QVariant FeedItemModel::getHeaderData( int section, Qt::Orientation orientation, int \
role, int headerSet ) const { +    Q_ASSERT( section >= 0 );
     if ( orientation != Qt::Horizontal )
         return QVariant();
     if ( role != Qt::DisplayRole )
         return QVariant();
-    if ( headerSet == ItemListHeaders ) {
-        if ( section >= ItemColumnCount )
-            return QVariant();
-        switch ( section ) {
-        case ItemTitleColumn:
-            return i18n("Title");
-        case AuthorsColumn:
-            return i18n("Author");
-        case DateColumn:
-            return i18n("Date");
-        case FeedTitleColumn:
-            return i18n("Feed");
+    switch ( headerSet ) {
+        case ItemListHeaders:
+        {
+            if ( section >= ItemColumnCount )
+                return QVariant();
+            switch ( section ) {
+            case ItemTitleColumn:
+                return i18n("Title");
+            case AuthorsColumn:
+                return i18n("Author");
+            case DateColumn:
+                return i18n("Date");
+            case FeedTitleForItemColumn:
+                return i18n("Feed");
+            }
+        }
+
+        case CollectionTreeHeaders:
+        {
+            if ( section >= FeedColumnCount )
+                return QVariant();
+            switch ( section ) {
+            case FeedTitleColumn:
+                return i18n("Title");
+            case UnreadCountColumn:
+                return i18n("Unread");
+            case TotalCountColumn:
+                return i18n("Total");
+            }
         }
     }
     return QVariant();
diff --git a/krss/feeditemmodel.h b/krss/feeditemmodel.h
index 13511ba..b44c679 100644
--- a/krss/feeditemmodel.h
+++ b/krss/feeditemmodel.h
@@ -39,10 +39,17 @@ public:
         ItemTitleColumn = 0,
         AuthorsColumn,
         DateColumn,
-        FeedTitleColumn,
+        FeedTitleForItemColumn,
         ItemColumnCount
     };
 
+    enum FeedColumn {
+        FeedTitleColumn=0,
+        UnreadCountColumn,
+        TotalCountColumn,
+        FeedColumnCount
+    };
+
     enum Role {
         ItemRole = Qt::UserRole,
         SortRole,
@@ -63,7 +70,7 @@ public:
 
     /* reimp */ QVariant getData( const Akonadi::Collection& collection, int column, \
int role=Qt::DisplayRole ) const;  
-    /* reimp */ int columnCount( const QModelIndex& index = QModelIndex() ) const;
+    /* reimp */ int getColumnCount( int headerSet ) const;
 
     /* reimp */ QVariant getHeaderData( int section, Qt::Orientation orientation, \
int role, int headerSet ) const;  


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

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