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

List:       kde-commits
Subject:    [kdepim/work/akonadi-ports] /: improve feeditemmodel
From:       Frank Osterfeld <frank.osterfeld () kdab ! com>
Date:       2011-09-26 17:03:12
Message-ID: 20110926170312.07DFCA607A () git ! kde ! org
[Download RAW message or body]

Git commit 2235b97c92be6d75df262834724e662a8306720b by Frank Osterfeld.
Committed on 24/09/2011 at 22:46.
Pushed by osterfeld into branch 'work/akonadi-ports'.

improve feeditemmodel

M  +1    -0    akregator/src/selectioncontroller.cpp
M  +7    -9    krss/krss/feeditemmodel.cpp
M  +1    -1    krss/krss/feeditemmodel.h
M  +21   -1    krss/krss/person.cpp
M  +2    -0    krss/krss/person.h
M  +4    -4    krss/krss/ui/feedlistview.cpp

http://commits.kde.org/kdepim/2235b97c92be6d75df262834724e662a8306720b

diff --git a/akregator/src/selectioncontroller.cpp b/akregator/src/selectioncontroller.cpp
index e8d0fc1..0ffe223 100644
--- a/akregator/src/selectioncontroller.cpp
+++ b/akregator/src/selectioncontroller.cpp
@@ -88,6 +88,7 @@ Akregator::SelectionController::SelectionController( Akonadi::Session* session,
     recorder->setAllMonitored();
     recorder->setCollectionFetchScope( cscope );
     recorder->setItemFetchScope( iscope );
+    recorder->fetchCollectionStatistics( true );
     recorder->setCollectionMonitored( Akonadi::Collection::root() );
     recorder->setMimeTypeMonitored( KRss::Item::mimeType() );
 
diff --git a/krss/krss/feeditemmodel.cpp b/krss/krss/feeditemmodel.cpp
index 6608134..e077e2c 100644
--- a/krss/krss/feeditemmodel.cpp
+++ b/krss/krss/feeditemmodel.cpp
@@ -64,17 +64,13 @@ QVariant FeedItemModel::entityData( const Akonadi::Item &akonadiItem, int column
                 return item.titleAsPlainText();
             case AuthorsColumn:
             {
-#if 0 //TODO: we probably want to cache this
                 QString authors;
                 Q_FOREACH( const KRss::Person &person, item.authors() ) {
                     if ( !authors.isEmpty() )
                         authors.append( QLatin1Char(';') );
-                    authors += person.name();
+                    authors += person.condensedPlainText();
                 }
                 return authors;
-#else
-                return EntityTreeModel::entityData( akonadiItem, column, role );
-#endif
             }
             case DateColumn:
                 if ( role == SortRole )
@@ -120,8 +116,6 @@ QVariant FeedItemModel::entityData( const Akonadi::Item &akonadiItem, int column
 QVariant FeedItemModel::entityData( const Collection &collection, int column, int role ) const {
     if ( role == Qt::DisplayRole || role == SortRole ) {
         switch ( column ) {
-        case IsTagRole:
-            return false;
         case FeedTitleColumn:
         {
             const QString title = FeedCollection( collection ).title();
@@ -129,6 +123,12 @@ QVariant FeedItemModel::entityData( const Collection &collection, int column, in
                 return title;
             break;
         }
+        case UnreadCountColumn:
+        {
+            return EntityTreeModel::entityData( collection, column, EntityTreeModel::UnreadCountRole );
+        }
+        case IsFolderRole:
+            return FeedCollection( collection ).isFolder();
         default:
             break;
         }
@@ -174,12 +174,10 @@ QVariant FeedItemModel::entityHeaderData( int section, Qt::Orientation orientati
           switch ( section ) {
             case FeedTitleColumn:
                 return i18n("Title");
-#if 0
             case UnreadCountColumn:
                 return i18n("Unread");
             case TotalCountColumn:
                 return i18n("Total");
-#endif
             default:
                 break;
             }
diff --git a/krss/krss/feeditemmodel.h b/krss/krss/feeditemmodel.h
index 964a4d1..d176c91 100644
--- a/krss/krss/feeditemmodel.h
+++ b/krss/krss/feeditemmodel.h
@@ -58,7 +58,7 @@ public:
         IsDeletedRole, //PENDING(frank) transitional Akregator compat, review
         IsImportantRole, //PENDING(frank) transitional Akregator compat, review
         LinkRole, //PENDING(frank) transitional Akregator compat, review
-        IsTagRole //PENDING(frank) old krss transitional
+        IsFolderRole //PENDING(frank) old krss transitional
     };
 
 public:
diff --git a/krss/krss/person.cpp b/krss/krss/person.cpp
index 3d1e106..426e10d 100644
--- a/krss/krss/person.cpp
+++ b/krss/krss/person.cpp
@@ -49,16 +49,33 @@ public:
     QString name;
     QString email;
     QString uri;
+    mutable QString condensed;
+    mutable bool condensedDirty : 1;
 };
 
 Person::Private::Private( const Private& other )
     : QSharedData( other ),
     name( other.name ),
     email( other.email ),
-    uri( other.uri )
+    uri( other.uri ),
+    condensedDirty( true )
 {
 }
 
+QString Person::condensedPlainText() const {
+    if ( d->condensedDirty ) {
+        if ( !d->name.isEmpty() )
+            d->condensed = d->name;
+        else if ( d->email.isEmpty() )
+            d->condensed = d->email;
+        else
+            d->condensed = d->uri;
+        d->condensedDirty = false;
+    }
+
+    return d->condensed;
+}
+
 QString Person::name() const
 {
     return d->name;
@@ -67,6 +84,7 @@ QString Person::name() const
 void Person::setName( const QString& name )
 {
     d->name = name;
+    d->condensedDirty = true;
 }
 
 QString Person::email() const
@@ -77,6 +95,7 @@ QString Person::email() const
 void Person::setEmail( const QString& email )
 {
     d->email = email;
+    d->condensedDirty = true;
 }
 
 QString Person::uri() const
@@ -87,6 +106,7 @@ QString Person::uri() const
 void Person::setUri( const QString& uri )
 {
     d->uri = uri;
+    d->condensedDirty = true;
 }
 
 Person::Person() : d( new Private )
diff --git a/krss/krss/person.h b/krss/krss/person.h
index 0d9b80d..1d7222a 100644
--- a/krss/krss/person.h
+++ b/krss/krss/person.h
@@ -38,6 +38,8 @@ public:
     Person( const Person& other );
     ~Person();
 
+    QString condensedPlainText() const;
+
     QString name() const;
     void setName( const QString& name );
 
diff --git a/krss/krss/ui/feedlistview.cpp b/krss/krss/ui/feedlistview.cpp
index 6008b36..e13d691 100644
--- a/krss/krss/ui/feedlistview.cpp
+++ b/krss/krss/ui/feedlistview.cpp
@@ -56,7 +56,7 @@ static QModelIndex prevIndex( const QModelIndex&idx )
 static QModelIndex prevFeedIndex( const QModelIndex& idx, bool allowPassed = false )
 {
     QModelIndex prev = allowPassed ? idx : prevIndex( idx );
-    while ( prev.isValid() && prev.data( FeedItemModel::IsTagRole ).toBool() ) {
+    while ( prev.isValid() && prev.data( FeedItemModel::IsFolderRole ).toBool() ) {
         prev = prevIndex( prev );
     }
     return prev;
@@ -65,7 +65,7 @@ static QModelIndex prevFeedIndex( const QModelIndex& idx, bool allowPassed = fal
 static QModelIndex prevUnreadFeedIndex( const QModelIndex& idx, bool allowPassed = false )
 {
     QModelIndex prev = allowPassed ? idx : prevIndex( idx );
-    while ( prev.isValid() && ( prev.data( FeedItemModel::IsTagRole ).toBool() ||
+    while ( prev.isValid() && ( prev.data( FeedItemModel::IsFolderRole ).toBool() ||
             prev.sibling( prev.row(), FeedItemModel::UnreadCountColumn ).data().toInt() == 0 ) ) {
         prev = prevIndex( prev );
     }
@@ -106,7 +106,7 @@ static QModelIndex nextIndex( const QModelIndex& idx )
 static QModelIndex nextFeedIndex( const QModelIndex& idx )
 {
     QModelIndex next = nextIndex( idx );
-    while ( next.isValid() && next.data( FeedItemModel::IsTagRole ).toBool() ) {
+    while ( next.isValid() && next.data( FeedItemModel::IsFolderRole ).toBool() ) {
         next = nextIndex( next );
     }
     return next;
@@ -115,7 +115,7 @@ static QModelIndex nextFeedIndex( const QModelIndex& idx )
 static QModelIndex nextUnreadFeedIndex( const QModelIndex& idx )
 {
     QModelIndex next = nextIndex( idx );
-    while ( next.isValid() && ( next.data( FeedItemModel::IsTagRole ).toBool() ||
+    while ( next.isValid() && ( next.data( FeedItemModel::IsFolderRole ).toBool() ||
             next.sibling( next.row(), FeedItemModel::UnreadCountColumn ).data().toInt() == 0 ) ) {
         next = nextIndex( next );
     }


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

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