diff options
author | Alan Alpert <alan.alpert@nokia.com> | 2012-02-20 10:34:44 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-02-24 10:24:58 +0100 |
commit | 9d2b618fa022daeabd45e57aa1596197db883037 (patch) | |
tree | 90536e9fc088d734439921dde304b49fe7f38df0 /examples/qtquick/canvas/twitterfriends/cache.js | |
parent | 91d543f00904a6caa2fab850ff3eca12de2d65ac (diff) |
Start of examples refactor
This is the general reorg of the examples directory structure, plus additional
guidelines.
calculator, animations and accessibility have been updated to the new standards
and tested, as an example.
Task-number: QTBUG-24133
Change-Id: I76c3b86751d3195ba2a5474ff23afb875765e9a4
Reviewed-by: Alan Alpert <alan.alpert@nokia.com>
Diffstat (limited to 'examples/qtquick/canvas/twitterfriends/cache.js')
-rw-r--r-- | examples/qtquick/canvas/twitterfriends/cache.js | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/examples/qtquick/canvas/twitterfriends/cache.js b/examples/qtquick/canvas/twitterfriends/cache.js new file mode 100644 index 0000000000..6c8a1cd71a --- /dev/null +++ b/examples/qtquick/canvas/twitterfriends/cache.js @@ -0,0 +1,42 @@ +var UserCache = function() { + this._users = []; +} + + +UserCache.prototype.getById = function(id){ + for (var i=0; i < this._users.length; i++){ + var user = this._users[i]; + if (user.twitterId == id) { + return user; + } + } +} +UserCache.prototype.getByName = function(name){ + for (var i=0; i < this._users.length; i++){ + var user = this._users[i]; + if (user.name == name) + return user; + } +} + +UserCache.prototype.add = function(user){ + this._users[this._users.length] = user; +} + + +var cache = new UserCache; + +function getById(id) { + return cache.getById(id); +} + +function getByName(name) { + return cache.getByName(name); +} + +function createTwitterUser(canvas) { + var user = Qt.createQmlObject("import QtQuick 2.0; TwitterUser{}", canvas); + user.canvas = canvas; + cache.add(user); + return user; +} |