Drag and Drop with treeview



Hi all,

i saw examples on :

http://www.gtkmm.org/docs/gtkmm-2.4/docs/tutorial/html/ch08s07.html#id2501173

http://www.gtkmm.org/docs/gtkmm-2.4/docs/tutorial/html/ch15s05.html

I want to use drag and drop in the same treeview like in the first link.

There is 3 columns in my treemodel : col_id, col_name, col_select. I don't add col_id to the treeview because i don't want it to be visible but i use its value in order to know if i should accept drag or not.

I have override the two methods:

virtual bool row_draggable_vfunc(const Gtk::TreeModel::Path& path) const;
virtual bool row_drop_possible_vfunc(const Gtk::TreeModel::Path& dest,
           const Gtk::SelectionData& selection_data) const;

but i have difficulties to understand the dest value... In fact, i want that user can drop the selected row on row where col_id < 0 but not on row where col_id > 0.

I try this :

bool Dnd_TreeModel::row_drop_possible_vfunc(const Gtk::TreeModel::Path& dest, const Gtk::SelectionData& selection_data) const
{
  Gtk::TreeModel::Path dest_parent = dest;
  Dnd_TreeModel* unconstThis = const_cast<Dnd_TreeModel*>(this); 
  const_iterator iter_dest_parent = unconstThis->get_iter(dest_parent);
  if(iter_dest_parent)
  {
    Row row = *(iter_dest_parent);
       
    if( row[cols.col_id] < 0 ){
        return true;
    }else
        return false;
  }
  return Gtk::TreeStore::row_drop_possible_vfunc(dest, selection_data);
}

but it doesn't work. Sometimes, i can drop row on row where col_id < 0.

Do you have any idea to resolve my problem?

I have also tried to connect my treeview with the signal_drag_data_received but in the callback, i can't find how to cancel the drag&drop...

Thanks a lot in advance and sorry for my english!

lm.






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