[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdepim/akregator/src
From: Aurélien Gâteau <agateau () kde ! org>
Date: 2010-12-16 17:30:03
Message-ID: 20101216173003.A2E3FAC8AB () svn ! kde ! org
[Download RAW message or body]
SVN commit 1207042 by gateau:
Nicer subscription list columns
- By default, only show title column
- If unread column is not visible, append unread count to title column
M +39 -0 subscriptionlistdelegate.cpp
M +3 -0 subscriptionlistdelegate.h
M +13 -5 subscriptionlistview.cpp
M +1 -0 subscriptionlistview.h
--- trunk/KDE/kdepim/akregator/src/subscriptionlistdelegate.cpp #1207041:1207042
@@ -30,6 +30,9 @@
#include <KGlobalSettings>
#include <KIconTheme>
+#include <QHeaderView>
+#include <QTreeView>
+
using namespace Akregator;
@@ -81,4 +84,40 @@
}
+void Akregator::SubscriptionListDelegate::initStyleOption( QStyleOptionViewItem *option,
+ const QModelIndex &index ) const
+{
+ QStyledItemDelegate::initStyleOption( option, index );
+
+ if ( index.column() != 0 )
+ {
+ // Append unread count to the title column only (it is always the first
+ // one)
+ return;
+ }
+
+ QTreeView *view = static_cast< QTreeView * >( parent() );
+ if ( !view->header()->isSectionHidden( SubscriptionListModel::UnreadCountColumn ) )
+ {
+ // Do not append unread count to the title if the unread count column
+ // is visible
+ return;
+ }
+
+ QStyleOptionViewItemV4 *optionV4 = qstyleoption_cast< QStyleOptionViewItemV4 * >( option );
+ if ( !optionV4 )
+ {
+ // Should never happen, but play it safe
+ return;
+ }
+
+ QModelIndex unreadIndex = index.sibling( index.row(), SubscriptionListModel::UnreadCountColumn );
+ int unread = unreadIndex.data().toInt();
+ if ( unread > 0 )
+ {
+ optionV4->text += QString( " (%1)" ).arg( unread );
+ }
+}
+
+
#include "subscriptionlistdelegate.moc"
--- trunk/KDE/kdepim/akregator/src/subscriptionlistdelegate.h #1207041:1207042
@@ -47,6 +47,9 @@
const QStyleOptionViewItem &option,
const QModelIndex &index ) const;
+ void initStyleOption( QStyleOptionViewItem *option,
+ const QModelIndex &index ) const;
+
private slots:
void recalculateRowHeight();
--- trunk/KDE/kdepim/akregator/src/subscriptionlistview.cpp #1207041:1207042
@@ -151,11 +151,8 @@
QTreeView::setModel( m );
- if ( m ) {
- header()->restoreState( m_headerState );
- // Always shows title column
- header()->showSection( SubscriptionListModel::TitleColumn );
- }
+ if ( m )
+ restoreHeaderState();
QStack<QModelIndex> stack;
stack.push( rootIndex() );
@@ -222,10 +219,21 @@
{
const KConfigGroup conf( Settings::self()->config(), "General" );
m_headerState = QByteArray::fromBase64( conf.readEntry( "SubscriptionListHeaders" ).toAscii() );
+ restoreHeaderState();
+}
+
+void Akregator::SubscriptionListView::restoreHeaderState()
+{
header()->restoreState( m_headerState ); // needed, even with Qt 4.5
// Always shows the title column
header()->showSection( SubscriptionListModel::TitleColumn );
+ if ( m_headerState.isEmpty() )
+ {
+ // Default configuration: only show the title column
+ header()->hideSection( SubscriptionListModel::UnreadCountColumn );
+ header()->hideSection( SubscriptionListModel::TotalCountColumn );
}
+}
void Akregator::SubscriptionListView::slotPrevFeed()
{
--- trunk/KDE/kdepim/akregator/src/subscriptionlistview.h #1207041:1207042
@@ -81,6 +81,7 @@
private:
void saveHeaderSettings();
void loadHeaderSettings();
+ void restoreHeaderState();
private Q_SLOTS:
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic