Re: drag/drop after sort



Torsten Schoenfeld <kaffeetisch gmx de> writes:
On Fri, 2004-12-31 at 11:14 -0500, Dan Espen wrote:

The problem I have is after I sort by clicking on a column
header, I can no longer drag/drop rows to rearrange them.

That's by design.  When you click on a column header, you not only sort
the list, but you make it sorted.  That is, newly added rows will be
added pre-sorted, and modified rows will be reordered according to the
sort function.  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.

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.

To get what you (I think) want -- a way to just sort the list once --
can still be done, though.  For example you can have a "Sort" button or
context menu entry that would reorder the children of the currently
selected row.  Or you could sort your list when the tree view column's
clicked event occurs.  The latter would be bad usability, though, since
most users will probably expect to get a sorted list when they click a
clickable column header.

To manually sort all children of a row, you can for example use
something like the following (copied from odot):

sub sort_one {
  my ($self, $model, $iterator) = @_;
  my $children = $model -> iter_n_children($iterator);

  # Look, son!  A bubble sort!
  foreach my $i (1 .. $children) {
    foreach my $j (1 .. ($children - $i)) {
      my ($a, $b) = ($model -> iter_nth_child($iterator, $j - 1),
                     $model -> iter_nth_child($iterator, $j));

      if (($model -> get($a, Odot::COLUMN_TASK) cmp
           $model -> get($b, Odot::COLUMN_TASK)) == 1) {
        $model -> swap($a, $b);
      }
    }
  }
}

I'll take a look at this odot thing, it looks like its a task manager.
If I take that approach I'll need the column number since some
columns sort different than others.

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

Thanks

-- 
Dan Espen                           E-mail: dane mk telcordia com



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