Re: fine-tune drag'n'drop in a tree
- From: Murray Cumming <murrayc murrayc com>
- To: iborco gmail com
- Cc: gtkmm-list gnome org
- Subject: Re: fine-tune drag'n'drop in a tree
- Date: Wed, 07 May 2008 13:25:22 +0200
On Sat, 2008-05-03 at 13:29 +0300, Ionutz Borcoman wrote:
> Hi,
>
> I'm playing around with the TreeStore, but I'm unable to obtain the effects I
> want.
>
> Let's assume I have this tree:
>
> -- 1
> -- 1.1
> -- 1.1.1
> -- 1.1.2
> -- 1.2
> -- 1.2.1
> -- 1.2.2
> -- 2
>
> I want to be able to do these:
> * move (1) after (2) or (2) in front of (1)
> * move (1.1) after (1.2) or (1.2) in front of (1.1)
> * move (1.1) or (1.2) under (2)
> * (1.1.1), (1.1.2), (1.2.1) and (1.2.2) should not be draggable
> * (1.1) and (1.2) should always be attached to (1) or (2)
> * (2) or (1) should always stay under the root
>
> I have so far created a TreeStore with a model that has a
> Gtk::TreeModelColumn<int> m_level member.
>
> I have set m_level to 1 for (1) and (2) and with 2 for (1.1) and (1.2).
> The "unmovable" rows has this set to 0.
>
> I was able to restrict this way what rows can be dragged via
> row_draggable_vfunc. But I'm unable to controll the dropping mechanism
> correctly.
You can do this by overriding the row_drop_possible_vfunc() virtual
method. You can then add any logic you like, usually examining the
relevant model data for that row.
I do that in Glom's (ugly) layout dialog. For instance, text items can
be dropped into group items, but not into other text items:
http://svn.gnome.org/viewvc/glom/trunk/glom/mode_data/treestore_layout.h?view=markup
http://svn.gnome.org/viewvc/glom/trunk/glom/mode_data/treestore_layout.cc?view=markup
It works well, so we should probably mention in the documentation.
> That is:
> * I can't attach (1.1) or (1.2)
> * move (2) in front of (1) if I drop it over (1)
> * move (1) after (2) if I drop (1) over (2)
> * move (1.1) as the last item if I drop it over (1)
>
> Any help would be appreciated. I have attached the code I've wrote so far.
>
> Thanx,
>
> Johnny
--
murrayc murrayc com
www.murrayc.com
www.openismus.com
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]