Re: drag/drop after sort
- From: Torsten Schoenfeld <kaffeetisch gmx de>
- To: gtk-perl-list gnome org
- Subject: Re: drag/drop after sort
- Date: Fri, 31 Dec 2004 18:51:54 +0100
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.
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);
}
}
}
}
--
HTH,
-Torsten
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]