summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCharles Yin <charles.yin@nokia.com>2010-12-10 11:36:11 +1000
committerCharles Yin <charles.yin@nokia.com>2010-12-10 14:56:10 +1000
commitfaeb3cffcbbcae44186c405bc940761b598497f9 (patch)
treeb91bcbe31a123fb3eb14e7e65692d1db033e8a99
parent764a110537e4ac30abc7b869012bb54fdbf2911c (diff)
qmlorganizer example improvements
Change-Id: If92a7f8d117c2c4cb52234b318b441331126df10 Task-number:MOBILITY-1317 Reviewed-by: Kevin Wu Won
-rw-r--r--examples/qmlorganizer/contents/DayView.qml10
-rw-r--r--examples/qmlorganizer/contents/MenuBar.qml2
-rw-r--r--examples/qmlorganizer/contents/MonthView.qml7
-rw-r--r--examples/qmlorganizer/contents/TimelineView.qml47
-rw-r--r--examples/qmlorganizer/contents/WeekView.qml16
-rw-r--r--examples/qmlorganizer/organizer.qml46
6 files changed, 58 insertions, 70 deletions
diff --git a/examples/qmlorganizer/contents/DayView.qml b/examples/qmlorganizer/contents/DayView.qml
index 96aaff8287..d297504e9a 100644
--- a/examples/qmlorganizer/contents/DayView.qml
+++ b/examples/qmlorganizer/contents/DayView.qml
@@ -45,7 +45,7 @@ import QtMobility.organizer 1.1
Rectangle
{
id:dayView
- property variant itemIds:calendar.organizer.itemIds(calendar.day)
+ property variant itemIds:calendar.organizer.itemIds(calendar.currentDate)
anchors.fill: parent
@@ -76,7 +76,6 @@ Rectangle
ListElement {hour : "21:00"}
ListElement {hour : "22:00"}
ListElement {hour : "23:00"}
- ListElement {hour : "0:00"}
}
Rectangle {
@@ -111,12 +110,7 @@ Rectangle
opacity : dayView.opacity * 0.8
itemId: modelData
-// Component.onCompleted: {
-// console.log ("startTime:" + startTime);
-// console.log ("endTime:" + endTime);
-// console.log ("height:" + height);
-// console.log ("anchors.top:" + timePos);
-// }
+
}
}
}
diff --git a/examples/qmlorganizer/contents/MenuBar.qml b/examples/qmlorganizer/contents/MenuBar.qml
index 5b469a827f..e18eadd7e5 100644
--- a/examples/qmlorganizer/contents/MenuBar.qml
+++ b/examples/qmlorganizer/contents/MenuBar.qml
@@ -63,7 +63,7 @@ Rectangle {
onClicked: Qt.quit()
}
}
- Button {id: todayButton; text: "Today";onClicked:calendar.day = new Date();}
+ Button {id: todayButton; text: "Today";onClicked:calendar.currentDate = new Date();}
Button { id: monthButton; text: "Month"; onClicked: calendar.state="MonthView";}
Button { id: weekButton; text: "Week";onClicked: calendar.state="WeekView";}
Button { id: dayButton; text: "Day";onClicked: calendar.state="DayView";}
diff --git a/examples/qmlorganizer/contents/MonthView.qml b/examples/qmlorganizer/contents/MonthView.qml
index 1b99dcde33..b167d447f0 100644
--- a/examples/qmlorganizer/contents/MonthView.qml
+++ b/examples/qmlorganizer/contents/MonthView.qml
@@ -44,11 +44,10 @@ import QtMobility.organizer 1.1
Rectangle {
id:monthView
- property int month: calendar.day.getMonth()
- property int year: calendar.day.getFullYear()
+ property int month
+ property int year
property date startDay:new Date(year, month, 1)
property int startWeekday:startDay.getDay()
-
anchors.fill: parent
Grid {
@@ -115,7 +114,7 @@ Rectangle {
dayContainer.radius = 0;
}
onClicked: {
- calendar.day = new Date(calendar.day.getFullYear(), calendar.day.getMonth(), index - startWeekday +1);
+ calendar.currentDate = new Date(calendar.year, calendar.month, index - startWeekday +1);
calendar.state = "DayView";
}
}
diff --git a/examples/qmlorganizer/contents/TimelineView.qml b/examples/qmlorganizer/contents/TimelineView.qml
index d8a744ab22..41124e8d66 100644
--- a/examples/qmlorganizer/contents/TimelineView.qml
+++ b/examples/qmlorganizer/contents/TimelineView.qml
@@ -46,20 +46,18 @@ Rectangle {
id : timelineView
anchors.fill : parent
opacity : parent.opacity
- property int year
- property int month
- property int day
+ property int year:calendar.year
+ property int month:calendar.month
+ property int day:calendar.day
Connections {
target: calendar
- onDayChanged : {
- year = calendar.day.getFullYear();
- month = calendar.day.getMonth();
- day = calendar.day.getDate();
+ onCurrentDateChanged : {
dayList.currentIndex = day - 1;
monthList.currentIndex = month;
yearList.currentIndex = year - yearModel.start;
}
}
+
//Day view
Rectangle {
id: dayView
@@ -97,11 +95,11 @@ Rectangle {
keyNavigationWraps : true
onCurrentIndexChanged : {
- calendar.day = new Date(calendar.day.getFullYear(), calendar.day.getMonth(), currentIndex + 1);
- timelineView.month = calendar.day.getMonth();
- timelineView.day = calendar.day.getDate();
- monthList.currentIndex = timelineView.month;
- currentIndex = timelineView.day - 1;
+ if (timelineView.opacity > 0) {
+ calendar.currentDate = new Date(timelineView.year, timelineView.month, currentIndex + 1);
+ monthList.currentIndex = timelineView.month;
+ currentIndex = timelineView.day - 1;
+ }
}
}
@@ -131,9 +129,7 @@ Rectangle {
}
Repeater {
focus: true
- model:calendar.organizer.itemIds(new Date(calendar.day.getFullYear(),
- calendar.day.getMonth(),
- index + 1))
+ model:calendar.organizer.itemIds(new Date(timelineView.year,timelineView.month, index + 1))
Text {
clip: true
@@ -222,11 +218,11 @@ Rectangle {
var d = Date.parse("Feb 31, 2010");
}
onCurrentIndexChanged : {
- calendar.day = new Date(calendar.day.getFullYear(), currentIndex, calendar.day.getDate());
- timelineView.month = calendar.day.getMonth();
- timelineView.day = calendar.day.getDate();
- currentIndex = timelineView.month;
- dayList.currentIndex = timelineView.day - 1;
+ if (timelineView.opacity > 0) {
+ calendar.currentDate = new Date(timelineView.year, currentIndex, timelineView.day);
+ currentIndex = timelineView.month;
+ dayList.currentIndex = timelineView.day - 1;
+ }
}
}
@@ -333,12 +329,11 @@ Rectangle {
Component.onCompleted: Timeline.extendYearModel(true);
onCurrentIndexChanged: {
Timeline.extendYearModel(false);
- calendar.day = new Date(yearModel.start + currentIndex, calendar.day.getMonth(), calendar.day.getDate());
- timelineView.year = calendar.day.getFullYear();
- timelineView.month = calendar.day.getMonth();
- timelineView.day = calendar.day.getDate();
- monthList.currentIndex = timelineView.month;
- dayList.currentIndex = timelineView.day - 1;
+ if (timelineView.opacity > 0) {
+ calendar.currentDate = new Date(yearModel.start + currentIndex, timelineView.month, timelineView.day);
+ monthList.currentIndex = timelineView.month;
+ dayList.currentIndex = timelineView.day - 1;
+ }
}
ListModel {
diff --git a/examples/qmlorganizer/contents/WeekView.qml b/examples/qmlorganizer/contents/WeekView.qml
index cfc11ceaa1..a59bcbc531 100644
--- a/examples/qmlorganizer/contents/WeekView.qml
+++ b/examples/qmlorganizer/contents/WeekView.qml
@@ -45,8 +45,6 @@ Rectangle
{
id:weekView
anchors.fill: parent
- property int day:calendar.day.getDay()
-
ListView {
id : dayList
anchors.fill: parent
@@ -60,10 +58,8 @@ Rectangle
keyNavigationWraps : true
Component.onCompleted : positionViewAtIndex(currentIndex, ListView.Beginning)
onOpacityChanged: {
- //when back to week view, select the current day.
- if (opacity != 0)
- currentIndex = calendar.day.getDay();
- }
+ currentIndex = calendar.weekDay;
+ }
model : ListModel {
ListElement {day : "Sunday"}
@@ -96,9 +92,9 @@ Rectangle
Repeater {
focus: true
- model:calendar.organizer.itemIds(new Date(calendar.day.getFullYear(),
- calendar.day.getMonth(),
- index - calendar.day.getDay() + calendar.day.getDate()))
+ model:calendar.organizer.itemIds(new Date(calendar.year,
+ calendar.month,
+ index - calendar.weekDay + calendar.day))
Text {
clip: true
@@ -117,7 +113,7 @@ Rectangle
anchors.fill: parent
onClicked: {
dayList.currentIndex = index
- calendar.day = new Date(calendar.day.getFullYear(), calendar.day.getMonth(), calendar.day.getDate() + dayList.currentIndex - weekView.day);
+ calendar.currentDate = new Date(calendar.year, calendar.month, calendar.day + dayList.currentIndex - calendar.weekDay);
calendar.state = "DayView"
}
}
diff --git a/examples/qmlorganizer/organizer.qml b/examples/qmlorganizer/organizer.qml
index c14417530e..1e7a725bb7 100644
--- a/examples/qmlorganizer/organizer.qml
+++ b/examples/qmlorganizer/organizer.qml
@@ -46,21 +46,12 @@ Rectangle {
id: calendar
width: 400
height: 640
- property date day: new Date()
- property string status:day.toDateString()
- property OrganizerModel organizer:OrganizerModel{
- id: organizer
- startPeriod:new Date(calendar.day.getFullYear(), 1, 1)
- endPeriod:new Date(calendar.day.getFullYear() +1, 12, 31)
- autoUpdate:false
- Component.onCompleted : {
- if (manager == "memory")
- organizer.importItems(Qt.resolvedUrl("contents/test.ics"));
- }
- }
- onDayChanged: {
- calendar.status = day.toDateString();
- }
+ property date currentDate:new Date()
+ property int year:currentDate.getFullYear()
+ property int month:currentDate.getMonth()
+ property int day:currentDate.getDate()
+ property int weekDay:currentDate.getDay()
+ property string status:currentDate.toDateString()
color: "#343434";
Image { source: "contents/images/stripes.png"; fillMode: Image.Tile; anchors.fill: parent; opacity: 1 }
@@ -68,6 +59,17 @@ Rectangle {
state: "MonthView";
SystemPalette { id: activePalette }
+ property OrganizerModel organizer:OrganizerModel{
+ id: organizer
+ manager:"qtorganizer:memory:id=qml"
+ startPeriod:'2009-01-01'
+ endPeriod:'2012-12-31'
+ autoUpdate:true
+ Component.onCompleted : {
+ if (managerName == "memory")
+ organizer.importItems(Qt.resolvedUrl("contents/test.ics"));
+ }
+ }
@@ -76,21 +78,21 @@ Rectangle {
id: statusBar; status:calendar.status; width: parent.width; height: 35; opacity: 0.9; anchors.bottom: calendar.bottom
onLeftClicked: {
if (calendar.state == "MonthView") {
- calendar.day = new Date(calendar.day.getFullYear(), calendar.day.getMonth() - 1, calendar.day.getDate());
+ calendar.currentDate = new Date(calendar.year, calendar.month - 1, calendar.day);
} else if (calendar.state == "WeekView") {
- calendar.day = new Date(calendar.day.getFullYear(), calendar.day.getMonth() , calendar.day.getDate() - 7);
+ calendar.currentDate = new Date(calendar.year, calendar.month , calendar.day - 7);
} else if (calendar.state == "DayView" || calendar.state == "TimelineView") {
- calendar.day = new Date(calendar.day.getFullYear(), calendar.day.getMonth() , calendar.day.getDate() - 1);
+ calendar.currentDate = new Date(calendar.year, calendar.month , calendar.day - 1);
}
}
onRightClicked: {
if (calendar.state == "MonthView") {
- calendar.day = new Date(calendar.day.getFullYear(), calendar.day.getMonth() + 1, calendar.day.getDate());
+ calendar.currentDate = new Date(calendar.year, calendar.month + 1, calendar.day);
} else if (calendar.state == "WeekView") {
- calendar.day = new Date(calendar.day.getFullYear(), calendar.day.getMonth() , calendar.day.getDate() + 7);
+ calendar.currentDate = new Date(calendar.year, calendar.month , calendar.day + 7);
} else if (calendar.state == "DayView" || calendar.state == "TimelineView") {
- calendar.day = new Date(calendar.day.getFullYear(), calendar.day.getMonth() , calendar.day.getDate() + 1);
+ calendar.currentDate = new Date(calendar.year, calendar.month , calendar.day + 1);
}
} //rightClick
}
@@ -126,6 +128,8 @@ Rectangle {
width: calendar.width;
height: calendar.height - menuBar.height - statusBar.height;
opacity: 0;
+ month:calendar.month
+ year:calendar.year
anchors.fill: contentArea;
}
TimelineView {