2 var <itemPressedAction;
5 *qtClass { ^'QcTreeWidget' }
7 columns_ { arg labels; this.setProperty( \columns, labels ); }
8 columns { ^this.getProperty( \columns ); }
9 numColumns { ^this.getProperty( \columnCount ); }
11 addItem { arg strings;
12 ^this.invokeMethod( \addItem, [QTreeViewItem(),strings] ).prValidItem(this);
15 insertItem { arg index, strings;
16 ^this.invokeMethod( \insertItem, [QTreeViewItem(),index, strings] ).prValidItem(this);
19 removeItem { arg item; this.invokeMethod( \removeItem, item ); }
21 numItems { ^this.getProperty( \topLevelItemCount ); }
24 ^this.getProperty( \currentItem ).prValidItem(this);
27 currentItem_ { arg item;
28 this.setProperty( \currentItem, item ? QTreeViewItem() );
32 ^this.invokeMethod( \item, [QTreeViewItem(), index] ).prValidItem(this);
35 canSort { ^this.getProperty( \sortingEnabled ) }
36 canSort_ { arg bool; this.setProperty( \sortingEnabled, bool ) }
38 sort { arg column, descending = false;
39 this.invokeMethod( \sort, [column, descending] )
42 itemPressedAction_ { arg action;
43 if(itemPressedAction.notNil) {
44 this.disconnectFunction( 'itemPressedAction()', itemPressedAction );
47 this.connectFunction( 'itemPressedAction()', action );
49 itemPressedAction = action;
52 onItemChanged_ { arg hook;
53 if(onItemChanged.notNil) {
54 this.disconnectFunction( 'currentItemChanged()', onItemChanged );
57 this.connectFunction( 'currentItemChanged()', hook );
64 These methods can only operate on top level items
65 Should we include them?
68 var i = this.currentItem.index;
69 if( i < 0 ) { ^nil } { ^i };
75 this.currentItem = this.itemAt(index);
77 this.currentItem = nil;
82 background { ^this.palette.base; }
83 background_ { arg color; this.palette = this.palette.base_(color) }
87 prForEachColumnDataPair { arg data, func;
88 var n = this.numColumns;
96 func.value( i, d[id] );
102 // dummy for convenience in case tree view is invalid
115 ^ other.class == QTreeViewItem and: {id == other.id}
118 isNull { ^ id.isNil }
121 ^treeView.invokeMethod( \parentItem, this ).prValidItem(treeView);
125 var i = treeView.invokeMethod( \indexOfItem, this );
126 if(i.isInteger) {^i} {^-1};
130 ^treeView.invokeMethod( \item, [this, index] ).prValidItem(treeView);
133 addChild { arg strings;
134 ^treeView.invokeMethod( \addItem, [this,strings] ).prValidItem(treeView);
137 insertChild { arg index, strings;
138 ^treeView.invokeMethod( \insertItem, [this,index,strings] ).prValidItem(treeView);
142 ^treeView.invokeMethod( \strings, this );
145 strings_ { arg strings;
146 strings.do { |string, column| this.setString(column,string) };
149 setString { arg column, string;
150 treeView.invokeMethod( \setText, [this,column,string] );
153 colors_ { arg colors;
154 treeView.prForEachColumnDataPair( colors, {
155 |column,color| this.setColor(column,color);
159 setColor { arg column, color;
160 treeView.invokeMethod( \setColor, [this,column,color] );
163 textColors_ { arg textColors;
164 treeView.prForEachColumnDataPair( textColors, {
165 |column,color| this.setTextColor(column,color);
169 setTextColor { arg column, color;
170 treeView.invokeMethod( \setTextColor, [this,column,color] );
173 setView { arg column, view;
175 treeView.invokeMethod( \setItemWidget, [this, column, view] );
177 this.removeView( column );
181 removeView { arg column;
182 treeView.invokeMethod( \removeItemWidget, [this, column] );
186 ^treeView.invokeMethod( \itemWidget, [this,column] );
191 prValidItem { arg treeView_;
192 if( qtObject.notNil ) {
193 treeView = treeView_;