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

List:       kde-edu-devel
Subject:    [kde-edu-devel] patch for fix of bug 59365 and other issue
From:       Afonso Arantes <elpatchberri-kde () yahoo ! com>
Date:       2003-12-10 0:38:26
[Download RAW message or body]

This patch should fix bug #59365 "item changed with update card isn't sorted 
right"

What is happening is that the KListView::setFront() and KListView::setBack() 
methods (probably inherited from QListView)do not force a resort. So if, 
example, I change the front of a card from "dinosaur" to "zebra" nothing is 
resorted. That means that the card with front "zebra" is now in between 
"anteater" and "elephant."

As soon as the user inserts a new card or chooses a new sort order everything 
is resorted and the updated card ends up in its proper place.

What I did was add an explicit call to KListView::sort(), in the routine 
DataWidget::update(). This forces the sort order to be updated.

This can have the unexpected side effect of causing the card to vanish from 
the screen. Let's say that Bob has a huge card list. He changes the entry 
"Argentina/Moscow" to "Russia/Moscow." The result will be that the correct 
location for "Russia/Moscow" will be completely off the screen. This is, I 
believe, the correct behavior. The alternative would be to follow
the modified card to its new location, possibly causing all the other 
surrounding cards to scroll off the edge of the screen.

I also changed two calls like this:

-  cardListView->setSorting(cardListView->columns() + 1);
+  cardListView->setSorting(0);

When flashkard first started up there was no default sort order and cards were 
completely unsorted. This happened because there is no such column as
cardListView->columns() + 1. Perhaps this was deliberate? It did not appear 
so. The QListView documentation specifies that an unsorted list should
be specified using setSorting(-1). 
In any case now this will cause the default sort order on startup to be 
descending by first column. This can be changed by the user.
 
afonso arantes
["patch" (text/x-diff)]

? patch
Index: datawidget.cpp
===================================================================
RCS file: /home/kdecvs/kde/kdeedu/flashkard/flashkard/datawidget.cpp,v
retrieving revision 1.20
diff -u -r1.20 datawidget.cpp
--- datawidget.cpp	6 Sep 2003 18:44:19 -0000	1.20
+++ datawidget.cpp	9 Dec 2003 21:04:39 -0000
@@ -93,7 +93,7 @@
   cardListView->clear();
   frontBox->clear();
   backBox->clear();
-  cardListView->setSorting(cardListView->columns() + 1);
+  cardListView->setSorting(0);
 }
 
 void DataWidget::loadCards(const CardList &cards)
@@ -146,7 +146,7 @@
 
   cardListView->setFullWidth(true);
   cardListView->setAllColumnsShowFocus(true);
-  cardListView->setSorting(cardListView->columns() + 1);
+  cardListView->setSorting(0);
 
   connect(cardListView, SIGNAL(selectionChanged(QListViewItem *)),
 	  this, SLOT(changeSelection(QListViewItem *)));
@@ -302,6 +302,7 @@
     i->setFront(frontBox->text());
     i->setBack(backBox->text());
     frontBox->setFocus();
+    cardListView->sort();
     emit dataChanged();
   }
 }


_______________________________________________
kde-edu-devel mailing list
kde-edu-devel@kde.org
https://mail.kde.org/mailman/listinfo/kde-edu-devel


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

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