Class: QML::ListModel
- Inherits:
-
Object
- Object
- QML::ListModel
- Includes:
- Enumerable
- Defined in:
- lib/qml/data/list_model.rb
Overview
ListModel is the base class of list models which provides data to QML list views.
Direct Known Subclasses
Instance Attribute Summary collapse
- #columns ⇒ Array<Symbol|String> readonly
Instance Method Summary collapse
-
#[](index) ⇒ Object
abstract
Returns an item.
-
#count ⇒ Integer
abstract
The number of the items.
-
#each ⇒ Object
Iterates each item.
-
#initialize(*columns) ⇒ ListModel
constructor
A new instance of ListModel.
-
#inserting(range) { ... } ⇒ Object
protected
Notifies the list views that items are about to be and were inserted.
-
#moving(range, destination) { ... } ⇒ Object
protected
Notifies the list views that items are about to be and were moved.
-
#removing(range) { ... } ⇒ Object
protected
Notifies the list views that items are about to be and were removed.
- #resetting(&block) ⇒ Object protected
- #to_qml ⇒ QML::JSObject
-
#update(range) ⇒ Object
protected
Notifies the list views that the data of the items was changed.
Constructor Details
Instance Attribute Details
Instance Method Details
#[](index) ⇒ Object
Returns an item.
42 43 44 |
# File 'lib/qml/data/list_model.rb', line 42 def [](index) fail ::NotImplementedError end |
#count ⇒ Integer
Returns the number of the items.
34 35 36 |
# File 'lib/qml/data/list_model.rb', line 34 def count fail ::NotImplementedError end |
#each ⇒ Enumerator #each {|item| ... } ⇒ self
Iterates each item.
24 25 26 27 28 29 30 |
# File 'lib/qml/data/list_model.rb', line 24 def each return to_enum unless block_given? count.times do |i| yield self[i] end self end |
#inserting(range) { ... } ⇒ Object (protected)
Notifies the list views that items are about to be and were inserted.
89 90 91 92 93 94 95 96 |
# File 'lib/qml/data/list_model.rb', line 89 def inserting(range, &block) return if range.count == 0 @access.begin_insert(range.min, range.max) ret = yield @access.end_insert ret end |
#moving(range, destination) { ... } ⇒ Object (protected)
Notifies the list views that items are about to be and were moved.
68 69 70 71 72 73 74 75 |
# File 'lib/qml/data/list_model.rb', line 68 def moving(range, destination) return if range.count == 0 @access.begin_move(range.min, range.max, destination) ret = yield @access.end_move ret end |
#removing(range) { ... } ⇒ Object (protected)
Notifies the list views that items are about to be and were removed.
106 107 108 109 110 111 112 113 |
# File 'lib/qml/data/list_model.rb', line 106 def removing(range, &block) return if range.count == 0 @access.begin_remove(range.min, range.max) ret = yield @access.end_remove ret end |
#resetting(&block) ⇒ Object (protected)
115 116 117 118 119 120 |
# File 'lib/qml/data/list_model.rb', line 115 def resetting(&block) @access.begin_reset ret = yield @access.end_reset ret end |
#to_qml ⇒ QML::JSObject
47 48 49 |
# File 'lib/qml/data/list_model.rb', line 47 def to_qml @qml_model end |
#update(range) ⇒ Object (protected)
Notifies the list views that the data of the items was changed.
55 56 57 |
# File 'lib/qml/data/list_model.rb', line 55 def update(range) @access.update(range.min, range.max) end |