Re: drag/drop after sort




On Dec 31, 2004, at 1:32 PM, Dan Espen wrote:

Torsten Schoenfeld <kaffeetisch gmx de> writes:
So, manually reordering a sorted list with d'n'd
wouldn't have any effect, since moved rows would automatically jump back
to their original position -- hence d'n'd reordering is disabled when
sorting is enabled.

If that is the design, I think its a bad design. I sort on one or 2 columns to get the approximate order I need and then drag/drop the remaining rows that didn't land where I wanted them to.

I think that's entirely normal for a list of things without unique keys.

Not necessarily bad design --- in 90% of use cases for a sortable list or tree, you want completely automatic sorting, and this works very well. What you're wanting is to use the sorting functions as single-shot helpers for manual sorting, which is a special case.


I take it, there is no way to clear this "sorted" indicator?
I'm searching the sources and I don't see the indicator, let
alone a way to clear it.

According to the TreeSortable iface docs, it looks like you either set a sort func or set the sort column id to "default":

http://developer.gnome.org/doc/API/2.0/gtk/GtkTreeSortable.html#gtk- tree-sortable-set-default-sort-func

"If sort_func is NULL, then there will be no default comparison function. This means that once the model has been sorted, it can't go back to the default state. In this case, when the current sort column id of sortable is GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID, the model will be unsorted."


There's also the column's set_sort_indicator() and set_sort_order() methods --- set_sort_indicator() tells the column whether to show the sort direction indicator, while set_sort_order() tells the column whether to sort up or down.

http://developer.gnome.org/doc/API/2.0/gtk/GtkTreeViewColumn.html#gtk- tree-view-column-set-sort-order


After reading the first part of this, my first inclination was to copy the SimpleList data somewhere else, destroy the SimpleList and recreate it.

If you don't have huge amounts of data, this can be done easily by simply populating a new model with the contents of the old model, then swapping out the models and destroying the old one; that way the view doesn't have to be recreated. This won't work with SimpleList, though -- SimpleList caches a reference to the model in the TiedRow class and connects some signals to the model when setting up the view, so swapping the model would be bad.

--
That's it! It's one thing for a ghost to scare my children, but it's another to play my theremin!
  - Homer Simpson




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]