alias(dump)
{
	# Objects Tree Dump  script
	# Written by Noldor & Grifisx  (2005)
	# This script allow you to see all kvirc's interface objects in a listview.
	# It's just an alias, install it and "/dump"  =) EnjoY! 
	
	class (mylistview,listview)
	{
		constructor
		{
		@%list_name[]= ""
		}
		selectionChangedEvent
		{
			%tmp=$0
			%i=0
			while(%tmp->$classname != "mylistview")
			{
				%temp_object[%i]=%tmp->$text(0);
				%i++;
				%tmp=%tmp->$parent();
			}
			@$killPropertyChildren()
			%i=%temp_object[]#
			while(%i)
			{
			 %gerarchia=%gerarchia%temp_object[$(%i-1)]
			if (%i !=1) %gerarchia=%gerarchia"->"
			%i --;
			}
			%tmp_property=$new(listviewitem,$$->$parent->%property)
			$$->$parent->%property->$setTooltip(%gerarchia)
			%ger=$str.replace(%gerarchia,",","->")
			eval \%Wrapper\=\$new\(wrapper,0,test,%ger\) 
			$$->$parent->%line_ger->$setText(%ger)
			if (!%Wrapper)
			{
				echo"No such object!"
				return
			}
			# For the NEW kvs engine, the returned thingie is an Array!
			# %arry = %Wrapper->$listProperties($true)
			# %i = 0
			# foreach(%x,%arry)
			# {
			#     %property=$str.section(%x,",",0,0)
			#     @%list_name[%i]=$new(listviewitem,$$->$parent->%property)
			#     @%list_name[%i]->$setText(0,%property)
			#     @%list_name[%i]->$setText(1,$str.section(%x,",",1,1))
			#     @%list_name[%i]->$setText(2,%Wrapper->$property(%property,0))
			#     @%list_name[%i]->$setRenameEnabled(2)
			#     %i++;
			# }
			%array_property[]=$split("\|",%Wrapper->$listproperty(0))
			%i=0
			while(%i !=%array_property[]#)
			{
			%property=$str.section(%array_property[%i],"\,",0,0)
			@%list_name[%i]=$new(listviewitem,$$->$parent->%property)
			@%list_name[%i]->$setText(0,%property)
			@%list_name[%i]->$setText(1,$str.section(%array_property[%i],"\,",1,1))
			@%list_name[%i]->$setText(2,%Wrapper->$property(%property,0))
			@%list_name[%i]->$setRenameEnabled(2)
			%i++;
			}
			
		}
		killPropertyChildren()
		{
			%i=0
			while(%i != @%list_name[]#)
			{
				delete @%list_name[%i]
				%i++
			}
			@%list_name[]= ""
		}
		itemRenamed
		{
			%property=$0->$text(0)
			%value=$2
			eval \%Wrapper\-\>\$setProperty\(%property\,%value\)
		}
		
	}
	class (dump,widget)
	{
		constructor
		{	
			%Flag=0
			@$resize(800,600)
			@%tree[]=$split("\|",$objects.dump(0))
			@$setCaption("Kvir Objects Dump")	
			@%lay=$new(layout,$$)
			@%dump=$new(mylistview,$$)
			@%tree=$new(object)		
			@%property=$new(listview,$$)
	
			privateimpl(@%property,itemRenamedEvent)
			{
				$$->$parent->%dump->$itemRenamed($0,$1,$2)
			}
			@%property->$addColumn("Property",-1)
			@%property->$addColumn("Type",-1)
			@%property->$addColumn("Value",-1)
			@%dump->$addcolumn("Kvirc Widget Objects Tree",300)
			@%dump->$setRootIsDecorated(1)
			@%lay->$addwidget(@%dump,0,0)
			@%lay->$addwidget(@%property,0,1)		
			@%line_find=$new(lineedit,$$)
			@%line_ger=$new(lineedit,$$)
			@%lay->$addwidget(@%line_find,1,0)
			@%lay->$addwidget(@%line_ger,1,1)
			objects.connect @%line_find returnPressed $$ find
		}
			createtree()
			{
			%string=$0
			%i=0
			while (%i != @%tree[]#)
			{
				if ($str.findfirst(@%tree[%i],"\>") == -1)
				{
					%parent_current[0]=$new(listviewitem,@%dump)
					%child=0
				}
				else
				{
					%child=1;
					while ($str.find(@%tree[%i],"\>",%child) != -1)
					{
						%child++;
					}
					%child--;
					%parent_current[%child]=""
					%parent_current[%child]=$new(listviewitem,%parent_current[$(%child-1)])
				}
					%parent_current[%child]->$setopen(1)
					if ($str.findfirst(@%tree[%i],%string) != -1) %parent_current[%child]->$setpixmap(0,39)
					%tmp=$str.mid(@%tree[%i],%child,$($str.len(@%tree[%i])-%child))
					%parent_current[%child]->$settext(0,%tmp)
				%i++;
				}
			@$show()
			}
		find()
		{
		%tmp=@%line_find->$text()
		@%line_find->$setText("")
		delete @%dump
		@%dump=$new(mylistview,$$)
		@%dump->$addcolumn("Kvirc Widget Objects Tree",300)
		@%dump->$setRootIsDecorated(1)
		@%lay->$addwidget(@%dump,0,0)
		@%dump->$show
		$$->$createtree(%tmp)
		}
	}
	%A=$new(dump)
	%A->$createtree()
}

