Skip to content

Commit

Permalink
Fix three small bugs with QMLListModel.
Browse files Browse the repository at this point in the history
- $items was not initialized
- on insert this.$itemsChanged didn't pass the new value, which is
  needed internally
- on insert this.$itemsChanged would be emitted after rowsInserted,
  causing the new delegates to be created before all properties are
  in place.
  • Loading branch information
akreuzkamp committed Mar 7, 2014
1 parent 4ef79bb commit ec4bee9
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/qtcore.js
Expand Up @@ -2446,11 +2446,12 @@ function QMLRepeater(meta) {
function QMLListModel(meta) {
QMLBaseObject.call(this, meta);
var self = this,
firstItem = true;
firstItem = true;

createSimpleProperty("int", this, "count");
createSimpleProperty("list", this, "$items");
this.$defaultProperty = "$items";
this.$items = [];
this.$model = new JSItemModel();
this.count = 0;

Expand Down Expand Up @@ -2488,8 +2489,8 @@ function QMLListModel(meta) {
}
this.insert = function(index, dict) {
this.$items.splice(index, 0, dict);
this.$itemsChanged(this.$items);
this.$model.rowsInserted(index, index+1);
this.$itemsChanged();
}
this.move = function(from, to, n) {
var vals = this.$items.splice(from, n);
Expand Down

0 comments on commit ec4bee9

Please sign in to comment.