Merge lp:~mariob/ubuntu-calendar-app/coding_conventions into lp:ubuntu-calendar-app

Proposed by Mario Boikov
Status: Merged
Merged at revision: 4
Proposed branch: lp:~mariob/ubuntu-calendar-app/coding_conventions
Merge into: lp:ubuntu-calendar-app
Diff against target: 121 lines (+54/-46)
1 file modified
MonthView.qml (+54/-46)
To merge this branch: bzr merge lp:~mariob/ubuntu-calendar-app/coding_conventions
Reviewer Review Type Date Requested Status
Frank Mertens (community) checked the diff, ran the app Approve
Review via email: mp+148661@code.launchpad.net

Description of the change

Updated MonthView with proposal to start following QML coding convention from http://qt-project.org/doc/qt-5.0/qtquick/qml-codingconventions.html

To post a comment you must log in.
Revision history for this message
Frank Mertens (frankencode) wrote :

Fine with me.

review: Approve (checked the diff, ran the app)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'MonthView.qml'
--- MonthView.qml 2013-02-14 18:03:27 +0000
+++ MonthView.qml 2013-02-15 10:49:23 +0000
@@ -3,63 +3,71 @@
3import "dateTimeUtils.js" as DateTime3import "dateTimeUtils.js" as DateTime
44
5ListView {5ListView {
6 id: monthView // id for internal reference
7
6 // public properties8 // public properties
7 property bool portraitMode: width < height9 property bool portraitMode: width < height
8 property real weeksInView: 810 property real weeksInView: 8
9 property int weekStartDay: 1 // Monday, FIXME: depends on locale / user settings11 property int weekStartDay: 1 // Monday, FIXME: depends on locale / user settings
1012
11 id: monthView // id for internal reference
12
13 // private properties13 // private properties
14 property real weekHeight: height / weeksInView | 014 QtObject {
15 property int indexOrigin: count / 215 id: internal
16 property var timeOrigin: (new Date()).weekStart(weekStartDay)16
17 property var today: (new Date()).midnight()17 property real weekHeight: monthView.height / monthView.weeksInView | 0
18 property int indexOrigin: monthView.count / 2
19 property var timeOrigin: (new Date()).weekStart(monthView.weekStartDay)
20 property var today: (new Date()).midnight()
21 }
22
23 clip: true
24
25 model: 1041 // weeks for about +-10y
26
27 delegate: Item {
28 id: weekItem
29
30 property var weekOrigin: internal.timeOrigin.addDays((index - internal.indexOrigin) * 7)
31
32 width: parent.width
33 height: internal.weekHeight
34
35 Row {
36 anchors.fill: parent
37 spacing: 1
38
39 Repeater {
40 model: 7
41 delegate: Rectangle {
42 id: dayItem
43
44 property var dayOrigin: weekOrigin.addDays(index)
45 property bool isToday: internal.today.getTime() == dayOrigin.getTime()
46
47 width: weekItem.width / 7
48 height: weekItem.height - 1
49 color: isToday ? "#c94212" : dayOrigin.getMonth() % 2 ? "#c4c4c4" : "#e0e0e0"
50
51 Label {
52 anchors.centerIn: parent
53 text: dayOrigin.getDate()
54 color: isToday ? "white" : dayOrigin.getDay() == 0 ? "#c94212" : "#404040"
55 }
56 }
57 }
58 }
59 }
1860
19 Timer { // make sure today is updated at midnight61 Timer { // make sure today is updated at midnight
20 interval: 100062 interval: 1000
21 repeat: true63 repeat: true
22 running: true64 running: true
65
23 onTriggered: {66 onTriggered: {
24 var newDate = (new Date()).midnight()67 var newDate = (new Date()).midnight()
25 if (today < newDate) today = newDate68 if (internal.today < newDate) internal.today = newDate
26 }69 }
27 }70 }
2871
29 clip: true72 Component.onCompleted: positionViewAtIndex(internal.indexOrigin, ListView.Center)
30
31 model: 1041 // weeks for about +-10y
32
33 delegate: Component {
34 Item {
35 id: weekItem
36 property var weekOrigin: timeOrigin.addDays((index - indexOrigin) * 7)
37 width: parent.width
38 height: weekHeight
39 Row {
40 anchors.fill: parent
41 spacing: 1
42 Repeater {
43 model: 7
44 delegate: Rectangle {
45 id: dayItem
46 property var dayOrigin: weekOrigin.addDays(index)
47 property bool isToday: today.getTime() == dayOrigin.getTime()
48 width: weekItem.width / 7
49 height: weekItem.height - 1
50 color: isToday ? "#c94212" : dayOrigin.getMonth() % 2 ? "#c4c4c4" : "#e0e0e0"
51 Label {
52 anchors.centerIn: parent
53 text: dayOrigin.getDate()
54 color: isToday ? "white" : dayOrigin.getDay() == 0 ? "#c94212" : "#404040"
55 }
56 }
57 }
58 }
59 }
60 }
61
62 Component.onCompleted: {
63 positionViewAtIndex(indexOrigin, ListView.Center)
64 }
65}73}

Subscribers

People subscribed via source and target branches

to status/vote changes: