Bug 107568

Summary: Normal view mode: retain context in article list pane
Product: [Applications] akregator Reporter: Alexandra Walford <alexandra>
Component: generalAssignee: kdepim bugs <kdepim-bugs>
Status: RESOLVED FIXED    
Severity: normal    
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: unspecified   
OS: Linux   
Latest Commit: Version Fixed In:

Description Alexandra Walford 2005-06-17 01:53:46 UTC
Version:           1.1.1 (using KDE KDE 3.4.1)
Installed from:    Unlisted Binary Package
OS:                Linux

When scrolling up and down with the up/down arrow keys (or whatever keys are bound to Next/Previous Article) in the article pane, it would be nice to display some context - i.e. prevent the selected article from being displayed right at the top or bottom of the pane (unless of course the article is the first or last in the list), and instead display (at least) one or two articles above or below the selected article.  Behaviour similar to that of kmail (where the selected message is kept in the middle of the message list) would be nice (and consistent).

Some ASCII art to illustrate (complete with smileys!), where Article 6 was selected and in the middle of the pane, and the user has scrolled up to Article 4:

Current behaviour:

 Article              | Feed       | Date
----------------------+------------+-------------
[Article 4]           | Feed Name  | 2005-06-17  <-- no context :(
 Article 5            | Feed Name  | 2005-06-17
 Article 6            | Feed Name  | 2005-06-17
 Article 7            | Feed Name  | 2005-06-17
 Article 8            | Feed Name  | 2005-06-17

(My) ideal behaviour:

 Article              | Feed       | Date
----------------------+------------+-------------
 Article 2            | Feed Name  | 2005-06-17  <-- context :)
 Article 3            | Feed Name  | 2005-06-17  <-- context :)
[Article 4]           | Feed Name  | 2005-06-17
 Article 5            | Feed Name  | 2005-06-17
 Article 6            | Feed Name  | 2005-06-17
Comment 1 Frank Osterfeld 2005-11-22 01:56:22 UTC
> Behaviour similar to that of kmail (where the selected message is kept in
> the middle of the message list) would be nice (and consistent).

I agree, that behaviour definitely makes more sense. Right now, there is no "lookahead" possible at all when iterating over items.

Comment 2 Frank Osterfeld 2005-11-22 08:22:33 UTC
SVN commit 482225 by osterfeld:

center current article when browsing the list, so one can look ahead what articles coming while browsing 
using next/prev article shortcuts.
BUG: 107568


 M  +19 -6     articlelistview.cpp  


--- trunk/KDE/kdepim/akregator/src/articlelistview.cpp #482224:482225
@@ -62,9 +62,21 @@
 class ArticleListView::ArticleListViewPrivate
 {
     public:
+
+    ArticleListViewPrivate(ArticleListView* parent) : m_parent(parent) { }
+
+    void ensureCurrentItemVisible()
+    {
+        if (m_parent->currentItem())
+        {
+            m_parent->center( m_parent->contentsX(), m_parent->itemPos(m_parent->currentItem()), 0, 9.0 );
+        }
+    }
+
+    ArticleListView* m_parent;
+
     /** maps article to article item */
     QMap<Article, ArticleItem*> articleMap;
-    
     TreeNode* node;
     Akregator::Filters::ArticleMatcher textFilter;
     Akregator::Filters::ArticleMatcher statusFilter;
@@ -204,8 +216,9 @@
 /* ==================================================================================== */
 
 ArticleListView::ArticleListView(QWidget *parent, const char *name)
-    : KListView(parent), d (new ArticleListViewPrivate)
+    : KListView(parent)
 {
+    d = new ArticleListViewPrivate(this);
     setObjectName(name);
     d->noneSelected = true;
     d->node = 0;
@@ -528,7 +541,7 @@
         clearSelection();
         setSelected(d->articleMap[a], true);
         setCurrentItem(d->articleMap[a]);
-        ensureItemVisible(d->articleMap[a]);
+        d->ensureCurrentItemVisible();
     }
 }
 
@@ -546,7 +559,7 @@
         clearSelection();
         setSelected(d->articleMap[a], true);
         setCurrentItem(d->articleMap[a]);
-        ensureItemVisible(d->articleMap[a]);
+        d->ensureCurrentItemVisible();
     }
 }
 
@@ -576,7 +589,7 @@
         setCurrentItem(d->articleMap[a]);
         clearSelection();
         setSelected(d->articleMap[a], true);
-        ensureItemVisible(d->articleMap[a]);
+        d->ensureCurrentItemVisible();
     }
 }
 
@@ -606,7 +619,7 @@
         setCurrentItem(d->articleMap[a]);
         clearSelection();
         setSelected(d->articleMap[a], true);
-        ensureItemVisible(d->articleMap[a]);
+        d->ensureCurrentItemVisible();
     }
 }
 
Comment 3 Frank Osterfeld 2005-11-22 08:29:46 UTC
SVN commit 482228 by osterfeld:

backport of #107568: center current article when browsing the list
CCBUG: 107568


 M  +19 -6     articlelistview.cpp  


--- branches/KDE/3.5/kdepim/akregator/src/articlelistview.cpp #482227:482228
@@ -59,9 +59,21 @@
 class ArticleListView::ArticleListViewPrivate
 {
     public:
+
+    ArticleListViewPrivate(ArticleListView* parent) : m_parent(parent) { }
+
+    void ensureCurrentItemVisible()
+    {
+        if (m_parent->currentItem())
+        {
+            m_parent->center( m_parent->contentsX(), m_parent->itemPos(m_parent->currentItem()), 0, 9.0 );
+        }
+    }
+
+    ArticleListView* m_parent;
+
     /** maps article to article item */
     QMap<Article, ArticleItem*> articleMap;
-    
     TreeNode* node;
     Akregator::Filters::ArticleMatcher textFilter;
     Akregator::Filters::ArticleMatcher statusFilter;
@@ -201,8 +213,9 @@
 /* ==================================================================================== */
 
 ArticleListView::ArticleListView(QWidget *parent, const char *name)
-    : KListView(parent, name), d (new ArticleListViewPrivate)
+    : KListView(parent, name)
 {
+    d = new ArticleListViewPrivate(this);
     d->noneSelected = true;
     d->node = 0;
     d->columnMode = ArticleListViewPrivate::feedMode;
@@ -524,7 +537,7 @@
         clearSelection();
         setSelected(d->articleMap[a], true);
         setCurrentItem(d->articleMap[a]);
-        ensureItemVisible(d->articleMap[a]);
+        d->ensureCurrentItemVisible();
     }
 }
 
@@ -542,7 +555,7 @@
         clearSelection();
         setSelected(d->articleMap[a], true);
         setCurrentItem(d->articleMap[a]);
-        ensureItemVisible(d->articleMap[a]);
+        d->ensureCurrentItemVisible();
     }
 }
 
@@ -572,7 +585,7 @@
         setCurrentItem(d->articleMap[a]);
         clearSelection();
         setSelected(d->articleMap[a], true);
-        ensureItemVisible(d->articleMap[a]);
+        d->ensureCurrentItemVisible();
     }
 }
 
@@ -602,7 +615,7 @@
         setCurrentItem(d->articleMap[a]);
         clearSelection();
         setSelected(d->articleMap[a], true);
-        ensureItemVisible(d->articleMap[a]);
+        d->ensureCurrentItemVisible();
     }
 }