[Kde-bindings] branches/KDE/3.5/kdebindings/qtruby

Richard Dale Richard_Dale at tipitina.demon.co.uk
Mon Nov 20 17:22:06 UTC 2006


SVN commit 606521 by rdale:

* Made Qt::ListView, Qt::ListViewItem, Qt::BoxLayout, Qt::HBoxLayout,
  Qt::VBoxLayout and Qt::GridLayout Enumerable with implementations
  of each() so they don't need to use the Qt External iterators like
  Qt::LayoutIterator anymore. For instance:

	lv = Qt::ListView.new do
		["one", "two", "three", "four"].each do |label|
			Qt::ListViewItem.new(self, label, "zzz")
		end
	end

	lv.each do |item|
		p item.inspect
		pp item.inspect
	end

* Add inspect() and pretty_print() methods to Qt::ListViewItem so that
  they show the text of their columns

CCMAIL: kde-bindings at kde.org



 M  +21 -0     ChangeLog  
 M  +112 -4    rubylib/qtruby/lib/Qt/qtruby.rb  


--- branches/KDE/3.5/kdebindings/qtruby/ChangeLog #606520:606521
@@ -1,3 +1,24 @@
+2006-11-20  Richard Dale  <rdale at foton.es>
+
+	* Made Qt::ListView, Qt::ListViewItem, Qt::BoxLayout, Qt::HBoxLayout,
+	  Qt::VBoxLayout and Qt::GridLayout Enumerable with implementations
+	  of each() so they don't need to use the Qt External iterators like
+	  Qt::LayoutIterator anymore. For instance:
+
+		lv = Qt::ListView.new do
+			["one", "two", "three", "four"].each do |label|
+				Qt::ListViewItem.new(self, label, "zzz")
+			end
+		end
+
+		lv.each do |item|
+			p item.inspect
+			pp item.inspect
+		end
+
+	* Add inspect() and pretty_print() methods to Qt::ListViewItem so that
+	  they show the text of their columns
+
 2006-09-19  Richard Dale  <rdale at foton.es>
 
 	* Upped the QtRuby version to 1.0.13 for the KDE 3.5.5 release
--- branches/KDE/3.5/kdebindings/qtruby/rubylib/qtruby/lib/Qt/qtruby.rb #606520:606521
@@ -195,6 +195,18 @@
 		end
 	end
 
+	class BoxLayout < Qt::Base
+		include Enumerable
+
+		def each
+			it = iterator()
+			while it.current
+				yield it.current
+				it += 1
+			end
+		end
+	end
+
 	class Buffer < Qt::Base
 		def open(*args)
 			method_missing(:open, *args)
@@ -451,6 +463,30 @@
 		end
 	end
 
+	class GridLayout < Qt::Base
+		include Enumerable
+
+		def each
+			it = iterator()
+			while it.current
+				yield it.current
+				it += 1
+			end
+		end
+	end
+
+	class HBoxLayout < Qt::Base
+		include Enumerable
+
+		def each
+			it = iterator()
+			while it.current
+				yield it.current
+				it += 1
+			end
+		end
+	end
+
 	class HebrewCodec < Qt::Base
 		def name(*args)
 			method_missing(:name, *args)
@@ -539,12 +575,64 @@
 		end
 	end
 
+	class LayoutIterator < Qt::Base
+		def +(a)
+			for i in 1..a
+				send("operator++".to_sym)
+			end
+            return self
+		end
+	end
+
 	class Library < Qt::Base
 		def load(*args)
 			method_missing(:load, *args)
 		end
 	end
 
+	class ListView < Qt::Base
+		include Enumerable
+
+		def each
+			it = Qt::ListViewItemIterator.new(self)
+			while it.current
+				yield it.current
+				it += 1
+			end
+		end
+	end
+
+	class ListViewItem < Qt::Base
+		include Enumerable
+
+		def each
+			it = Qt::ListViewItemIterator.new(self)
+			while it.current
+				yield it.current
+				it += 1
+			end
+		end
+
+		def inspect
+			str = super
+			str.sub!(/>$/, "")
+			for i in 0..(listView.columns - 1)
+				str << " text%d=%s," % [i, self.text(i)]
+			end
+			str.sub!(/,?$/, ">")
+		end
+		
+		def pretty_print(pp)
+			str = to_s
+			str.sub!(/>$/, "")
+			for i in 0..(listView.columns - 1)
+				str << " text%d=%s," % [i, self.text(i)]
+			end
+			str.sub!(/,?$/, ">")
+			pp.text str
+		end
+	end
+
 	class Locale < Qt::Base
 		def name(*args)
 			method_missing(:name, *args)
@@ -1040,6 +1128,18 @@
 			method_missing(:type, *args)
 		end
 	end
+
+	class VBoxLayout < Qt::Base
+		include Enumerable
+
+		def each
+			it = iterator()
+			while it.current
+				yield it.current
+				it += 1
+			end
+		end
+	end
 	
 	class WhatsThis < Qt::Base
 		def WhatsThis.display(*k)
@@ -1562,13 +1662,21 @@
 		end
 	
 		def Internal.signalAt(qobject, index)
-			classname = qobject.class.name
-			Meta[classname].get_signals[index].full_name
+			klass = qobject.class
+			begin
+				meta = Meta[klass.name]
+				klass = klass.superclass
+			end while meta.nil? and klass != Object
+			meta.get_signals[index].full_name
 		end
 	
 		def Internal.slotAt(qobject, index)
-			classname = qobject.class.name
-			Meta[classname].get_slots[index].full_name
+			klass = qobject.class
+			begin
+				meta = Meta[klass.name]
+				klass = klass.superclass
+			end while meta.nil? and klass != Object
+			meta.get_slots[index].full_name
 		end
 	
 		def Internal.getMocArguments(member)



More information about the Kde-bindings mailing list