~ubuntu-branches/ubuntu/quantal/qtmobility/quantal

« back to all changes in this revision

Viewing changes to examples/qmlorganizer/contents/timeline.js

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2010-11-16 16:18:07 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20101116161807-k2dzt2nyse975r3l
Tags: 1.1.0-0ubuntu1
* New upstream release
* Syncronise with Debian, no remaining changes

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
function changeDate() {
 
2
   //TODO
 
3
}
 
4
 
 
5
function changeToday() {
 
6
    var now = new Date();
 
7
    var year = now.getFullYear();
 
8
    var month = now.getMonth();
 
9
    var day = now.getUTCDate();
 
10
 
 
11
    yearList.currentIndex = year - yearModel.start;
 
12
    monthList.currentIndex = month;
 
13
    dayList.positionViewAtIndex(day, Center);
 
14
    dayList.currentIndex = day;
 
15
}
 
16
function extendYearModel(init) {
 
17
 
 
18
    var start = yearModel.start;
 
19
    var end = yearModel.end;
 
20
    var now = new Date();
 
21
    var year = 1900 + now.getYear();
 
22
 
 
23
    if (init) {
 
24
        //initializes the year model
 
25
        if (yearModel.count == 1) {
 
26
            yearModel.set(0, {"year" : year});
 
27
            start = year;
 
28
            end = year;
 
29
        }
 
30
    }
 
31
 
 
32
    if (start == 0) return;
 
33
 
 
34
    //extends forward
 
35
    if (yearList.currentIndex == yearList.count - 1) {
 
36
        for (var i = 0; i < 10; i ++) {
 
37
            end++;
 
38
            yearModel.append({"year" : end});
 
39
        }
 
40
    }
 
41
 
 
42
 
 
43
    //extends backward
 
44
    if (yearList.currentIndex == 0) {
 
45
        if (start == 1900)
 
46
             break;
 
47
        for (var i = 0; i < 10; i ++) {
 
48
            start--;
 
49
            yearModel.insert(1, {"year" : start});
 
50
        }
 
51
        yearModel.move(0, 10, 1);
 
52
    }
 
53
    yearModel.start = start;
 
54
    yearModel.end = end;
 
55
    if (init) {
 
56
        yearList.currentIndex = year - start;
 
57
    }
 
58
}