require "qt2"
include Qt2

class MyListView  < QListView
   def initialize ( parent = 0, name = "" )
      super(parent, name)
      @mySelectionChanged = RSignal.new("Object")
      @selector = 0
#      @eventfilter = QR2EventFilter.new(self)
#      self.installEventFilter(@eventfilter)
   end
   def contentsMousePressEvent(  e )
	selected = selectedItem();
print "sel0= ",selectedItem(),"\n"	
	#QListView::contentsMousePressEvent( e );
   end
   def contentsMouseReleaseEvent(  e )
	#QListView::contentsMouseReleaseEvent( e );
	if ( selectedItem() != selected )
	    @mySelectionChanged.sendWith( selectedItem() )

print "sel1= ",selectedItem(),"\n"
	    #@mySelectionChanged.send
        end
   end
   def mousePressEvent(e=nil)
   print "mousePress\n"
   end
   def resizeEvent(e)
   print "resizeEvent\n"
   end
   def contentsMouseMoveEvent( e )
   print "moveMouseEvent\n"
   end
   def mySelectionChanged
      @mySelectionChanged
   end
end


a = QApplication.new([$0]+ARGV)

m = MyListView.new
m.addColumn( "One" )
m.addColumn( "Two" )
m.setAllColumnsShowFocus( TRUE )

    lvi1=  QListViewItem.new(m, "Text", "Text" )
    lvi2=  QListViewItem.new( m, "Text", "Other Text" )
    lvi3=  QListViewItem.new( m, "Text", "More Text" )

@eventfilter1 = QR2EventFilter.new(m)
a.installEventFilter(@eventfilter1)

a.setMainWidget(m)
m.show
a.exec

