[Qt-interest] Drag and drop model/view questions
Stephen Kelly
steveire at gmail.com
Sun Jan 31 12:47:36 CET 2010
Sorry if you got a similar email already and this is a repeat. I'm not
seeing it come through.
Jeremy Sanders wrote:
> I've managed to get basic dragging and dropping working in my tree model.
> I have a few questions:
>
> 1. If I have CopyAction and MoveAction as supported drop operations, how
> does the user change between moving and copying? Is this documented?
You can overload some methods in the view to offer a popup to the user or
handle keyboard modifiers.
websvn.kde.org/trunk/KDE/kdepimlibs/akonadi/entitytreeview
.cpp?view=markup
http://websvn.kde.org/trunk/KDE/kdepimlibs/akonadi/dragdropmanager
.cpp?view=markup
>
> I'd like to having moving by default, but copying only if Ctrl is held
> down. Is this possible?
>
> 2. Is it possible to get moving implemented in a single method? As moving
> is done by dropping then deleting, my application sees it as two separate
> operations. This means it shows up as two operations in the undo menu. I'd
> like the user to be able to undo both operations in one go.
>
> The current delete then paste way of moving also means that the naming of
> the items in my tree gets messed up. Each item in my model needs a unique
> name. As a moved item is pasted before deletion, I have to give the item a
> new name to preserve uniqueness, because I don't know a deletion is going
> to occur. This is pretty ugly.
You want to use the beginMoveRows and endMoveRows methods in Qt 4.6.
>
> 3. Is it possible for drag and drop to check the target is a possible
> destination so that the mouse cursor can be changed? It would be good if
> the user could get immediate feedback that the destination is valid.
You could again use an overload in the view. Unfortunately the model does
not have a virtual method for this. I think it would be useful too.
All the best,
Steve.
>
> Thanks
>
> Jeremy
>
>
More information about the Qt-interest-old
mailing list