[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [kdepimlibs/akregator_port] krss: improve feeditemmodel
From: Christophe Giboudeaux <cgiboudeaux () gmx ! com>
Date: 2012-03-31 15:16:24
Message-ID: 20120331151624.49816A6108 () git ! kde ! org
[Download RAW message or body]
Git commit fb2449b3016bfc256444739e886038f5f7f34caa by Christophe Giboudeaux, on behalf of Frank Osterfeld.
Committed on 24/09/2011 at 22:46.
Pushed by osterfeld into branch 'akregator_port'.
improve feeditemmodel
(cherry picked from commit 2235b97c92be6d75df262834724e662a8306720b)
Conflicts:
akregator/src/selectioncontroller.cpp
M +7 -9 krss/feeditemmodel.cpp
M +1 -1 krss/feeditemmodel.h
M +21 -1 krss/person.cpp
M +2 -0 krss/person.h
M +4 -4 krss/ui/feedlistview.cpp
http://commits.kde.org/kdepimlibs/fb2449b3016bfc256444739e886038f5f7f34caa
diff --git a/krss/feeditemmodel.cpp b/krss/feeditemmodel.cpp
index 6608134..e077e2c 100644
--- a/krss/feeditemmodel.cpp
+++ b/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/feeditemmodel.h b/krss/feeditemmodel.h
index 964a4d1..d176c91 100644
--- a/krss/feeditemmodel.h
+++ b/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/person.cpp b/krss/person.cpp
index 3d1e106..426e10d 100644
--- a/krss/person.cpp
+++ b/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/person.h b/krss/person.h
index 0d9b80d..1d7222a 100644
--- a/krss/person.h
+++ b/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/ui/feedlistview.cpp b/krss/ui/feedlistview.cpp
index 6008b36..e13d691 100644
--- a/krss/ui/feedlistview.cpp
+++ b/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