400.1.1
by mihirsoni-123
Added copyright header comments in all the pages |
1 |
/*
|
400.1.2
by mihirsoni-123
updated copyright year |
2 |
* Copyright (C) 2013-2014 Canonical Ltd
|
400.1.1
by mihirsoni-123
Added copyright header comments in all the pages |
3 |
*
|
4 |
* This file is part of Ubuntu Calendar App
|
|
5 |
*
|
|
6 |
* Ubuntu Calendar App is free software: you can redistribute it and/or modify
|
|
7 |
* it under the terms of the GNU General Public License version 3 as
|
|
8 |
* published by the Free Software Foundation.
|
|
9 |
*
|
|
10 |
* Ubuntu Calendar App is distributed in the hope that it will be useful,
|
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13 |
* GNU General Public License for more details.
|
|
14 |
*
|
|
15 |
* You should have received a copy of the GNU General Public License
|
|
16 |
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17 |
*/
|
|
455.3.5
by Nekhelesh Ramananthan
Small change |
18 |
|
19 |
import QtQuick 2.3 |
|
422.5.1
by Akiva Avraham
Upgraded component library imports |
20 |
import Ubuntu.Components 1.1 |
460.1.1
by Mihir Soni
improved yearview & Monthview |
21 |
|
94.1.1
by Kunal Parmar
MonthView/YearView chaged according to new design |
22 |
import "dateExt.js" as DateExt |
222.3.8
by Bartosz Kosiorek
Sync with lp:ubuntu-calendar-app trunk |
23 |
Page { |
222.3.2
by Bartosz Kosiorek
Add quick add event for Year View |
24 |
id: yearViewPage
|
338.1.1
by Nicholas Skaggs
restructure yearview, add test |
25 |
objectName: "yearViewPage" |
235.1.1
by Kunal Parmar
View to PAge |
26 |
|
199.1.2
by Kunal Parmar
Code clean up and further improvemnts |
27 |
property int currentYear: DateExt.today().getFullYear(); |
94.1.1
by Kunal Parmar
MonthView/YearView chaged according to new design |
28 |
signal monthSelected(var date); |
29 |
||
338.1.1
by Nicholas Skaggs
restructure yearview, add test |
30 |
Keys.forwardTo: [yearPathView] |
455.3.6
by Nekhelesh Ramananthan
Just fixed the code indentation. No other change |
31 |
|
455.3.1
by Mihir Soni
Removed duplicate header section from views and added common header |
32 |
Action { |
455.3.6
by Nekhelesh Ramananthan
Just fixed the code indentation. No other change |
33 |
id: calendarTodayAction
|
34 |
objectName:"todaybutton" |
|
35 |
iconName: "calendar-today" |
|
36 |
text: i18n.tr("Today") |
|
37 |
onTriggered: { |
|
38 |
currentYear = new Date().getFullYear() |
|
39 |
}
|
|
40 |
}
|
|
455.3.1
by Mihir Soni
Removed duplicate header section from views and added common header |
41 |
|
460.1.1
by Mihir Soni
improved yearview & Monthview |
42 |
head { |
43 |
actions: [ |
|
44 |
calendarTodayAction, |
|
45 |
commonHeaderActions.newEventAction, |
|
46 |
commonHeaderActions.showCalendarAction, |
|
47 |
commonHeaderActions.reloadAction |
|
48 |
]
|
|
49 |
}
|
|
235.1.3
by Kunal Parmar
YearView merge issue fixed |
50 |
|
235.1.1
by Kunal Parmar
View to PAge |
51 |
PathViewBase { |
338.1.1
by Nicholas Skaggs
restructure yearview, add test |
52 |
id: yearPathView
|
53 |
objectName: "yearPathView" |
|
235.1.1
by Kunal Parmar
View to PAge |
54 |
|
55 |
anchors.fill: parent |
|
56 |
||
57 |
onNextItemHighlighted: { |
|
58 |
currentYear = currentYear + 1; |
|
59 |
}
|
|
60 |
||
61 |
onPreviousItemHighlighted: { |
|
62 |
currentYear = currentYear - 1; |
|
63 |
}
|
|
64 |
||
65 |
delegate: GridView{ |
|
66 |
id: yearView
|
|
67 |
clip: true |
|
338.1.1
by Nicholas Skaggs
restructure yearview, add test |
68 |
focus: index == yearPathView.currentIndex |
235.1.1
by Kunal Parmar
View to PAge |
69 |
|
235.1.2
by Kunal Parmar
Merge from trunk |
70 |
property int scrollMonth: 0; |
338.1.1
by Nicholas Skaggs
restructure yearview, add test |
71 |
property bool isCurrentItem: index == yearPathView.currentIndex |
72 |
property int year: (yearViewPage.currentYear + yearPathView.indexType(index)) |
|
235.1.1
by Kunal Parmar
View to PAge |
73 |
|
74 |
width: parent.width |
|
75 |
height: parent.height |
|
76 |
anchors.top: parent.top |
|
77 |
||
78 |
readonly property int minCellWidth: units.gu(30) |
|
79 |
cellWidth: Math.floor(Math.min.apply(Math, [3, 4].map(function(n) |
|
192.1.3
by Kunal Parmar
Review comment |
80 |
{ return ((width / n >= minCellWidth) ? width / n : width / 2) }))) |
81 |
||
235.1.1
by Kunal Parmar
View to PAge |
82 |
cellHeight: cellWidth * 1.4 |
83 |
||
84 |
model: 12 /* months in a year */ |
|
235.1.2
by Kunal Parmar
Merge from trunk |
85 |
|
222.3.12
by Bartosz Kosiorek
Use signals instead of direct call method from YearView |
86 |
onYearChanged: { |
87 |
scrollMonth = 0; |
|
392.1.2
by Kunal Parmar
using correct year |
88 |
var today = new Date(); |
89 |
if(year == today.getFullYear()) { |
|
90 |
scrollMonth = today.getMonth(); |
|
392.1.1
by Kunal Parmar
scrolling to current month |
91 |
}
|
222.3.12
by Bartosz Kosiorek
Use signals instead of direct call method from YearView |
92 |
yearView.positionViewAtIndex(scrollMonth, GridView.Beginning); |
235.1.2
by Kunal Parmar
Merge from trunk |
93 |
}
|
94 |
||
95 |
//scroll in case content height changed
|
|
96 |
onHeightChanged: { |
|
392.1.3
by Kunal Parmar
scrolling at construction complete |
97 |
yearView.positionViewAtIndex(scrollMonth, GridView.Beginning); |
98 |
}
|
|
99 |
||
100 |
Component.onCompleted: { |
|
222.3.12
by Bartosz Kosiorek
Use signals instead of direct call method from YearView |
101 |
yearView.positionViewAtIndex(scrollMonth, GridView.Beginning); |
235.1.2
by Kunal Parmar
Merge from trunk |
102 |
}
|
103 |
||
104 |
Connections{ |
|
338.1.1
by Nicholas Skaggs
restructure yearview, add test |
105 |
target: yearPathView |
222.3.12
by Bartosz Kosiorek
Use signals instead of direct call method from YearView |
106 |
onScrollUp: { |
235.1.2
by Kunal Parmar
Merge from trunk |
107 |
scrollMonth -= 2; |
108 |
if(scrollMonth < 0) { |
|
109 |
scrollMonth = 0; |
|
110 |
}
|
|
222.3.12
by Bartosz Kosiorek
Use signals instead of direct call method from YearView |
111 |
yearView.positionViewAtIndex(scrollMonth, GridView.Beginning); |
235.1.2
by Kunal Parmar
Merge from trunk |
112 |
}
|
113 |
||
222.3.12
by Bartosz Kosiorek
Use signals instead of direct call method from YearView |
114 |
onScrollDown: { |
235.1.2
by Kunal Parmar
Merge from trunk |
115 |
scrollMonth += 2; |
116 |
var visibleMonths = yearView.height / cellHeight; |
|
117 |
if( scrollMonth >= (11 - visibleMonths)) { |
|
118 |
scrollMonth = (11 - visibleMonths); |
|
119 |
}
|
|
222.3.12
by Bartosz Kosiorek
Use signals instead of direct call method from YearView |
120 |
yearView.positionViewAtIndex(scrollMonth, GridView.Beginning); |
235.1.2
by Kunal Parmar
Merge from trunk |
121 |
}
|
122 |
}
|
|
123 |
||
235.1.1
by Kunal Parmar
View to PAge |
124 |
delegate: Item { |
125 |
width: yearView.cellWidth |
|
126 |
height: yearView.cellHeight |
|
127 |
||
460.1.1
by Mihir Soni
improved yearview & Monthview |
128 |
UbuntuShape { |
138.1.1
by Kunal Parmar
creating month hightlight when necessary |
129 |
anchors.fill: parent |
235.1.1
by Kunal Parmar
View to PAge |
130 |
anchors.margins: units.gu(0.5) |
460.1.1
by Mihir Soni
improved yearview & Monthview |
131 |
radius: "medium" |
132 |
||
133 |
MonthComponent { |
|
134 |
id: monthComponent
|
|
135 |
objectName: "monthComponent" + index |
|
136 |
showEvents: false |
|
137 |
currentMonth: new Date(yearView.year, index, 1, 0, 0, 0, 0) |
|
138 |
||
139 |
isYearView: true |
|
140 |
anchors.fill: parent |
|
141 |
||
142 |
dayLabelFontSize:"x-small" |
|
143 |
dateLabelFontSize: "medium" |
|
144 |
monthLabelFontSize: "medium" |
|
145 |
yearLabelFontSize: "small" |
|
146 |
||
147 |
onMonthSelected: { |
|
148 |
yearViewPage.monthSelected(date); |
|
149 |
}
|
|
222.3.12
by Bartosz Kosiorek
Use signals instead of direct call method from YearView |
150 |
}
|
63.1.1
by Kunal Parmar
year view implementation |
151 |
}
|
152 |
}
|
|
153 |
}
|
|
154 |
}
|
|
155 |
}
|