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
1=== modified file 'MonthView.qml'
2--- MonthView.qml 2013-02-14 18:03:27 +0000
3+++ MonthView.qml 2013-02-15 10:49:23 +0000
4@@ -3,63 +3,71 @@
5 import "dateTimeUtils.js" as DateTime
6
7 ListView {
8+ id: monthView // id for internal reference
9+
10 // public properties
11 property bool portraitMode: width < height
12 property real weeksInView: 8
13 property int weekStartDay: 1 // Monday, FIXME: depends on locale / user settings
14
15- id: monthView // id for internal reference
16-
17 // private properties
18- property real weekHeight: height / weeksInView | 0
19- property int indexOrigin: count / 2
20- property var timeOrigin: (new Date()).weekStart(weekStartDay)
21- property var today: (new Date()).midnight()
22+ QtObject {
23+ id: internal
24+
25+ property real weekHeight: monthView.height / monthView.weeksInView | 0
26+ property int indexOrigin: monthView.count / 2
27+ property var timeOrigin: (new Date()).weekStart(monthView.weekStartDay)
28+ property var today: (new Date()).midnight()
29+ }
30+
31+ clip: true
32+
33+ model: 1041 // weeks for about +-10y
34+
35+ delegate: Item {
36+ id: weekItem
37+
38+ property var weekOrigin: internal.timeOrigin.addDays((index - internal.indexOrigin) * 7)
39+
40+ width: parent.width
41+ height: internal.weekHeight
42+
43+ Row {
44+ anchors.fill: parent
45+ spacing: 1
46+
47+ Repeater {
48+ model: 7
49+ delegate: Rectangle {
50+ id: dayItem
51+
52+ property var dayOrigin: weekOrigin.addDays(index)
53+ property bool isToday: internal.today.getTime() == dayOrigin.getTime()
54+
55+ width: weekItem.width / 7
56+ height: weekItem.height - 1
57+ color: isToday ? "#c94212" : dayOrigin.getMonth() % 2 ? "#c4c4c4" : "#e0e0e0"
58+
59+ Label {
60+ anchors.centerIn: parent
61+ text: dayOrigin.getDate()
62+ color: isToday ? "white" : dayOrigin.getDay() == 0 ? "#c94212" : "#404040"
63+ }
64+ }
65+ }
66+ }
67+ }
68
69 Timer { // make sure today is updated at midnight
70 interval: 1000
71 repeat: true
72 running: true
73+
74 onTriggered: {
75 var newDate = (new Date()).midnight()
76- if (today < newDate) today = newDate
77- }
78- }
79-
80- clip: true
81-
82- model: 1041 // weeks for about +-10y
83-
84- delegate: Component {
85- Item {
86- id: weekItem
87- property var weekOrigin: timeOrigin.addDays((index - indexOrigin) * 7)
88- width: parent.width
89- height: weekHeight
90- Row {
91- anchors.fill: parent
92- spacing: 1
93- Repeater {
94- model: 7
95- delegate: Rectangle {
96- id: dayItem
97- property var dayOrigin: weekOrigin.addDays(index)
98- property bool isToday: today.getTime() == dayOrigin.getTime()
99- width: weekItem.width / 7
100- height: weekItem.height - 1
101- color: isToday ? "#c94212" : dayOrigin.getMonth() % 2 ? "#c4c4c4" : "#e0e0e0"
102- Label {
103- anchors.centerIn: parent
104- text: dayOrigin.getDate()
105- color: isToday ? "white" : dayOrigin.getDay() == 0 ? "#c94212" : "#404040"
106- }
107- }
108- }
109- }
110- }
111- }
112-
113- Component.onCompleted: {
114- positionViewAtIndex(indexOrigin, ListView.Center)
115- }
116+ if (internal.today < newDate) internal.today = newDate
117+ }
118+ }
119+
120+ Component.onCompleted: positionViewAtIndex(internal.indexOrigin, ListView.Center)
121 }

Subscribers

People subscribed via source and target branches

to status/vote changes: