Re: [PyQt] Editing multiple items in QTreeView delegate

2011-04-07 Thread James Polk

...and  just to cleanup and clarify,

in ms.py, I had to go back and edit it to be:

global MyTreeView

instead of just simply MyTreeView which I wrote before...


___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Re: [PyQt] Editing multiple items in QTreeView delegate

2011-04-06 Thread Hans-Peter Jansen
On Wednesday 06 April 2011, 02:43:38 James Polk wrote:
 I have a curious dilemma I can't seem to find any information about
 in the docs...

 I have a QTreeView and a delegate...
 The items in the QTreeView have columns of similar data.  When I set
 the selection behaviour to multiSelect (actually called
 ExtendedSelect) I can pick a single column of numbers that all have
 either a 1 in them.  I can then CTRL-click and change one of them
 from 1 to 0...while all of them are still highlighted/selected.

 What I want to do is to simultaneously change all of them from 1 to 0
 in one fell swoop. In the delegate though...if I try to use

     indices = treeView.selectedIndexes()

 it of course doesn't know anything about treeViewhow can I pass
 to the delegate some variable that contains an
 address/pointer/reference to the QTreeView, so that I can query all
 the selected items.  I'm trying to make this work in the
 setModelData of the delegate.

The question is, why so? Since the treeview selection is a view thing, 
you should handle the selection there, e.g. by subclassing and 
reimplementing the QAbstractItemView.selectionChanged() method. 

Of course, you can add some convenience interface to the model to handle 
the bulk changes there.

Pete
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Re: [PyQt] Editing multiple items in QTreeView delegate

2011-04-06 Thread Zoltan Szalai

hi,

not sure its a good idea but i solved this kind of problem by sending a 
signal from the delegate which the view can catch and perform the edit 
on all the selected items. it works just fine here.


bests
Zoli


On 2011.04.06. 2:43, James Polk wrote:


I have a curious dilemma I can't seem to find any information about in 
the docs...


I have a QTreeView and a delegate...
The items in the QTreeView have columns of similar data.  When I set the
selection behaviour to multiSelect (actually called ExtendedSelect) I 
can pick

a single column of numbers that all have either a 1 in them.  I can then
CTRL-click and change one of them from 1 to 0...while all of them 
are still

highlighted/selected.

What I want to do is to simultaneously change all of them from 1 to 0 
in one fell swoop.

In the delegate though...if I try to use

indices = treeView.selectedIndexes()

it of course doesn't know anything about treeViewhow can I pass 
to the delegate
some variable that contains an address/pointer/reference to the 
QTreeView, so that I
can query all the selected items.  I'm trying to make this work in the 
setModelData

of the delegate.

Thanks,
-Jim





___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Re: [PyQt] Editing multiple items in QTreeView delegate

2011-04-06 Thread James Polk

Well I found a solution and thought I would share it...
Probably not the most elegant, but it does work..

Works by using an import global variable (told you it wasn't elegant ;-)

I created a file named ms.py and inside is a single line:

 MyTreeView

and that's all.

In my main.py,...I import ms at the top.  Later, I set the variable by...

 ms.MyTreeView = self.treeView

Then in my delegate file, delegate.py, I also add import ms at the top.
And then later, in the setModelData() function,  after checking selectionMode()
to make sure it's in multiSelect,...and after handling the main selection,I 
do a

  indices = ms.MyTreeView.selectedIndexes()

and loop thru them setting their value to the value of the main selection...

A side note,...when a treeView's selectionMode is set to 3 (Extended Selection),
one can pull a vertical pick from top to bottom, highlighting multiple items in 
a single
column.  Then, while holding down CTRL, you can double-click selection one item
out of this group.  This will pass this CTRL-selection to the delegate and 
remove its
index from the indices returned above.  Which is good, so you don't double-set
it's value.  When you hit enter, the code will take the value of the 
CTRL-selection
and apply it to all the others who are still highlighted, making a nice clean 
sweep
and saving lots of keystrokes if you need to change a lot of items.

Cheers,
-Jim
 
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

[PyQt] Editing multiple items in QTreeView delegate

2011-04-05 Thread James Polk

I have a curious dilemma I can't seem to find any information about in the 
docs...

I have a QTreeView and a delegate...
The items in the QTreeView have columns of similar data.  When I set the
selection behaviour to multiSelect (actually called ExtendedSelect) I can pick
a single column of numbers that all have either a 1 in them.  I can then
CTRL-click and change one of them from 1 to 0...while all of them are still
highlighted/selected. 

What I want to do is to simultaneously change all of them from 1 to 0 in one 
fell swoop.
In the delegate though...if I try to use

    indices = treeView.selectedIndexes()

it of course doesn't know anything about treeViewhow can I pass to the 
delegate
some variable that contains an address/pointer/reference to the QTreeView, so 
that I
can query all the selected items.  I'm trying to make this work in the 
setModelData
of the delegate.

Thanks,
-Jim




___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt