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

List:       kde-core-devel
Subject:    Re: bug #86756: klistview::selectedItems() returns hidden items
From:       Aaron Seigo <aseigo () kde ! org>
Date:       2004-09-15 23:13:47
Message-ID: 200409151713.47950.aseigo () kde ! org
[Download RAW message or body]

On September 15, 2004 16:43, Sebastian Sauer wrote:
> So, it would be great if someone with enough power could apply this
> solution :-)

(quick) patch attached for review.

-- 
Aaron J. Seigo
Society is Geometric

["klistview.patch" (text/x-diff)]

? kmainwindow.loT
Index: klistview.cpp
===================================================================
RCS file: /home/kde/kdelibs/kdeui/klistview.cpp,v
retrieving revision 1.229
diff -u -3 -d -p -r1.229 klistview.cpp
--- klistview.cpp	8 Sep 2004 19:30:57 -0000	1.229
+++ klistview.cpp	15 Sep 2004 23:13:13 -0000
@@ -1187,6 +1187,11 @@ void KListView::setDropVisualizer(bool b
 
 QPtrList<QListViewItem> KListView::selectedItems() const
 {
+  return selectedItems(true);
+}
+
+QPtrList<QListViewItem> KListView::selectedItems(bool includeHiddenItems) const
+{
   QPtrList<QListViewItem> list;
 
   // Using selectionMode() instead of selectionModeExt() since for the cases that
@@ -1198,12 +1203,18 @@ QPtrList<QListViewItem> KListView::selec
   case NoSelection:
       break;
   case Single:
-      if(selectedItem())
+      if(selectedItem() && (includeHiddenItems || selectedItem()->isVisible()))
           list.append(selectedItem());
       break;
   default:
   {
-      QListViewItemIterator it(const_cast<KListView *>(this), \
QListViewItemIterator::Selected); +      int flags = QListViewItemIterator::Selected;
+      if (!includeHiddenItems)
+      {
+        flags |= QListViewItemIterator::Visible;
+      }
+
+      QListViewItemIterator it(const_cast<KListView *>(this), flags);
 
       for(; it.current(); ++it)
           list.append(it.current());
Index: klistview.h
===================================================================
RCS file: /home/kde/kdelibs/kdeui/klistview.h,v
retrieving revision 1.123
diff -u -3 -d -p -r1.123 klistview.h
--- klistview.h	9 Sep 2004 20:07:27 -0000	1.123
+++ klistview.h	15 Sep 2004 23:13:13 -0000
@@ -150,8 +150,22 @@ public:
 
   /**
    * @return a list containing the currently selected items.
+   *
+   * @deprecated
    */
-  QPtrList<QListViewItem> selectedItems() const; // ### BIC: KDE 4: use an \
implicitly shared class! (QValueList?) +  QPtrList<QListViewItem> selectedItems() \
const; +
+  /**
+   * @return a list containing the currently selected items.
+   *
+   * @param includeHiddenItems Set to true to return all items regardless of
+   * visibility. Set to false to only return items that are isVisible().
+   *
+   * @return a list of all selected listview items
+   *
+   * @since 3.4
+   */
+  QPtrList<QListViewItem> selectedItems(bool includeHiddenItems) const; // ### BIC: \
KDE 4: use an implicitly shared class! (QValutList?) and merge with above, default to \
true  
   /**
    * Arbitrarily move @p item to @p parent, positioned immediately after item @p \
after.



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

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