Class: CSListViewItem
- Inherits:
-
Qt::ListViewItem
- Object
- Qt::ListViewItem
- CSListViewItem
- Defined in:
- lib/CSListViewItem.rb
Overview
CSListViewItem.rb - ClickSpotter
Copyright © 2005, 2006 by Chris Schlaeger <[email protected]> This program is free software; you can redistribute it and/or modify it under the terms of version 2 of the GNU General Public License as published by the Free Software Foundation.
$Id: CSListViewItem.rb 8 2006-01-22 15:19:51Z cs $
Instance Attribute Summary collapse
-
#values ⇒ Object
readonly
Returns the value of attribute values.
Instance Method Summary collapse
- #compare(lvi, col, ascending) ⇒ Object
-
#initialize(parent = nil) ⇒ CSListViewItem
constructor
A new instance of CSListViewItem.
- #insert(entries) ⇒ Object
Constructor Details
#initialize(parent = nil) ⇒ CSListViewItem
Returns a new instance of CSListViewItem.
16 17 18 19 |
# File 'lib/CSListViewItem.rb', line 16 def initialize(parent = nil) super @values = [] end |
Instance Attribute Details
#values ⇒ Object (readonly)
Returns the value of attribute values.
14 15 16 |
# File 'lib/CSListViewItem.rb', line 14 def values @values end |
Instance Method Details
#compare(lvi, col, ascending) ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/CSListViewItem.rb', line 21 def compare(lvi, col, ascending) # Workaround for a Qt bug. It seems like it even compares non-existing # columns. return 0 if col >= @values.size @values[col] <=> lvi.values[col] end |
#insert(entries) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/CSListViewItem.rb', line 29 def insert(entries) @values = entries 0.upto(entries.size - 1) do |i| if entries[i].class == String text = entries[i] elsif entries[i].class == Fixnum || i.class == Bignum text = "%8d" % entries[i] elsif entries[i].class == Float text = "%5.1f" % entries[i] elsif entries[i].class == Time text = entries[i].strftime("%H:%M:%S %Y/%m/%d") else raise "Unsupported type #{entries[i].class} of value #{i}:#{entries[i]}" end setText(i, text) end end |