Handle MouseArea.enabled = false after mouse is pressed.
[profile/ivi/qtdeclarative.git] / examples / qml / canvas / twitterfriends / cache.js
1 var UserCache = function() {
2   this._users = [];
3 }
4
5
6 UserCache.prototype.getById = function(id){
7   for (var i=0; i < this._users.length; i++){
8     var user = this._users[i];
9     if (user.twitterId == id) {
10       return user;
11     }
12   }
13 }
14 UserCache.prototype.getByName = function(name){
15   for (var i=0; i < this._users.length; i++){
16     var user = this._users[i];
17     if (user.name == name)
18         return user;
19   }
20 }
21
22 UserCache.prototype.add = function(user){
23   this._users[this._users.length] = user;
24 }
25
26
27 var cache = new UserCache;
28
29 function getById(id) {
30     return cache.getById(id);
31 }
32
33 function getByName(name) {
34     return cache.getByName(name);
35 }
36
37 function createTwitterUser(canvas) {
38     var user = Qt.createQmlObject("import QtQuick 2.0; TwitterUser{}", canvas);
39     user.canvas = canvas;
40     cache.add(user);
41     return user;
42 }