File r891012.diff of Package kdepim4
Subject: akregator: improve prev/next unread article behavior when a filter is set
From: wstephenson@suse.de
Bug: kde#138935
Patch-upstream: 891012
--- akregator/src/articlelistview.cpp (revision 891011)
+++ akregator/src/articlelistview.cpp (revision 891012)
@@ -437,12 +437,15 @@ void ArticleListView::slotNextArticle()
selectIndex( newIdx );
}
-void ArticleListView::slotNextUnreadArticle()
+bool ArticleListView::selectNextUnreadArticle()
{
if (!model())
- return;
+ return false;
const int rowCount = model()->rowCount();
+ if ( rowCount == 0 )
+ return false;
+
const int startRow = qMin( rowCount - 1, ( currentIndex().isValid() ? currentIndex().row() + 1 : 0 ) );
int i = startRow;
@@ -461,6 +464,7 @@ void ArticleListView::slotNextUnreadArti
{
selectIndex( model()->index( i, 0 ) );
}
+ return foundUnread;
}
void ArticleListView::selectIndex( const QModelIndex& idx )
@@ -476,12 +480,15 @@ void ArticleListView::selectIndex( const
}
}
-void ArticleListView::slotPreviousUnreadArticle()
+bool ArticleListView::selectPreviousUnreadArticle()
{
if ( !model() )
- return;
+ return false;
const int rowCount = model()->rowCount();
+ if ( rowCount == 0 )
+ return false;
+
const int startRow = qMax( 0, ( currentIndex().isValid() ? currentIndex().row() : rowCount ) - 1 );
int i = startRow;
@@ -500,6 +507,7 @@ void ArticleListView::slotPreviousUnread
{
selectIndex( model()->index( i, 0 ) );
}
+ return foundUnread;
}
--- akregator/src/articlelistview.h (revision 891011)
+++ akregator/src/articlelistview.h (revision 891012)
@@ -121,6 +121,10 @@ public:
void saveHeaderSettings();
+ bool selectPreviousUnreadArticle();
+
+ bool selectNextUnreadArticle();
+
protected:
void mousePressEvent( QMouseEvent *ev );
@@ -135,9 +139,6 @@ public Q_SLOTS:
void slotNextArticle();
- void slotPreviousUnreadArticle();
-
- void slotNextUnreadArticle();
private:
void loadHeaderSettings();
--- akregator/src/mainwidget.cpp (revision 891011)
+++ akregator/src/mainwidget.cpp (revision 891012)
@@ -756,10 +756,8 @@ void Akregator::MainWidget::slotNextUnre
m_feedListView->slotNextUnreadFeed();
return;
}
- TreeNode* sel = m_selectionController->selectedSubscription();
- if (sel && sel->unread() > 0)
- m_articleListView->slotNextUnreadArticle();
- else
+
+ if (!m_articleListView->selectNextUnreadArticle())
m_feedListView->slotNextUnreadFeed();
}
@@ -770,10 +768,7 @@ void Akregator::MainWidget::slotPrevUnre
m_feedListView->slotPrevUnreadFeed();
return;
}
- TreeNode* sel = m_selectionController->selectedSubscription();
- if (sel && sel->unread() > 0)
- m_articleListView->slotPreviousUnreadArticle();
- else
+ if (!m_articleListView->selectPreviousUnreadArticle())
m_feedListView->slotPrevUnreadFeed();
}
Index: akregator/src/articlelistview.cpp
===================================================================
Index: akregator/src/articlelistview.h
===================================================================
Index: akregator/src/mainwidget.cpp
===================================================================