Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 1

Qt-interest Archive, March 2008
Models, dragging and undo


Message 1 in thread

Hi.

I want to find a way to implement undo for dragging in an item view.

The problem is that when dragging items within the view (re-ordering),
first rows are inserted (in "dropMimeData"), and then later on one or more calls to 
"removeRows" are made. As far as I can tell, there is no way for the model to
know that these 2+ operations should be grouped into a single command.

One could keep track of the rows to be inserted in "dropMimeData", and then keep
track of the rows to be removed in "removeRows" until the counts are equal and
then issue the command, but of course that does not work when just dropping
into the model. Again as far as I can tell, there is no way
for the model to distinguish between drag-and-drop and just drop.

Am I missing something? Has anyone implemented something like this or 
knows of a Qt4 app i could look at that has undo for dragging in a model view?

cheers,
Christian Henz

--
 [ signature omitted ] 

Message 2 in thread

You need to override the default drop implementation and create your own that 
uses one of your command objects instead.

Bo.

On søndag den 2. Marts 2008, Christian Henz wrote:
> Hi.
>
> I want to find a way to implement undo for dragging in an item view.
>
> The problem is that when dragging items within the view (re-ordering),
> first rows are inserted (in "dropMimeData"), and then later on one or more
> calls to "removeRows" are made. As far as I can tell, there is no way for
> the model to know that these 2+ operations should be grouped into a single
> command.
>
> One could keep track of the rows to be inserted in "dropMimeData", and then
> keep track of the rows to be removed in "removeRows" until the counts are
> equal and then issue the command, but of course that does not work when
> just dropping into the model. Again as far as I can tell, there is no way
> for the model to distinguish between drag-and-drop and just drop.
>
> Am I missing something? Has anyone implemented something like this or
> knows of a Qt4 app i could look at that has undo for dragging in a model
> view?
>
> cheers,
> Christian Henz
>
> --
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with
> "unsubscribe" in the subject or the body. List archive and information:
> http://lists.trolltech.com/qt-interest/



-- 
 [ signature omitted ] 

Message 3 in thread

On Mon, Mar 03, 2008 at 11:36:45AM +0100, Bo Thorsen wrote:
> You need to override the default drop implementation and create your own that 
> uses one of your command objects instead.
> 
> Bo.
> 

Ah yes, that was easier than I thought.

I now have a list view that communicates to the model if an internal move
is happening. The model then keeps track of what to insert and remove and
finally "commits" it.

Thanks,
Christian

--
 [ signature omitted ]