ubuntu-touch-coreapps-reviewers team mailing list archive
-
ubuntu-touch-coreapps-reviewers team
-
Mailing list archive
-
Message #04754
[Merge] lp:~pkunal-parmar/ubuntu-calendar-app/SyncSelection into lp:ubuntu-calendar-app
Kunal Parmar has proposed merging lp:~pkunal-parmar/ubuntu-calendar-app/SyncSelection into lp:ubuntu-calendar-app.
Commit message:
resolves Bug #1475747
Requested reviews:
Ubuntu Calendar Developers (ubuntu-calendar-dev)
For more details, see:
https://code.launchpad.net/~pkunal-parmar/ubuntu-calendar-app/SyncSelection/+merge/270237
resolves Bug #1475747
--
Your team Ubuntu Calendar Developers is requested to review the proposed merge of lp:~pkunal-parmar/ubuntu-calendar-app/SyncSelection into lp:ubuntu-calendar-app.
=== modified file 'MonthComponent.qml'
--- MonthComponent.qml 2015-08-03 04:32:33 +0000
+++ MonthComponent.qml 2015-09-05 05:32:09 +0000
@@ -30,6 +30,7 @@
property var currentMonth;
property var isYearView;
+ property var selectedDay;
property string dayLabelFontSize: "medium"
property string dateLabelFontSize: "large"
@@ -40,7 +41,8 @@
property alias dateLabelDelegate : dateLabelRepeater.delegate
signal monthSelected(var date);
- signal dateSelected(var date)
+ signal dateSelected(var date);
+ signal dateHighlighted(var date);
//creatng timer only if we need to show events in month
Loader {
@@ -90,6 +92,7 @@
property int todayMonth: today.getMonth()
property int todayYear: today.getFullYear()
+
//date from month will start, this date might be from previous month
property var monthStart: currentMonth.weekStart( Qt.locale().firstDayOfWeek )
property int monthStartDate: monthStart.getDate()
@@ -113,10 +116,29 @@
property int dayFontSize: FontUtils.sizeToPixels(root.dayLabelFontSize)
property int selectedIndex: -1
+
+ function findSelectedDayIndex(){
+ if(!selectedDay) {
+ return -1;
+ }
+
+ if( todayMonth === selectedDay.getMonth() && selectedDay.getFullYear() === todayYear){
+ return selectedDay.getDate() +
+ (Date.daysInMonth(monthStartYear, monthStartMonth) - monthStartDate);
+ } else {
+ return -1;
+ }
+ }
+ }
+
+ onSelectedDayChanged: {
+ if( isCurrentItem ) {
+ intern.selectedIndex = intern.findSelectedDayIndex();
+ }
}
onCurrentMonthChanged: {
- intern.selectedIndex = -1
+ intern.selectedIndex = -1;
}
Column{
=== modified file 'MonthComponentDateDelegate.qml'
--- MonthComponentDateDelegate.qml 2015-08-20 12:14:57 +0000
+++ MonthComponentDateDelegate.qml 2015-09-05 05:32:09 +0000
@@ -114,6 +114,7 @@
root.dateSelected(selectedDate);
} else {
intern.selectedIndex = index
+ root.dateHighlighted(selectedDate)
}
}
}
=== modified file 'MonthView.qml'
--- MonthView.qml 2015-03-01 14:01:35 +0000
+++ MonthView.qml 2015-09-05 05:32:09 +0000
@@ -25,8 +25,10 @@
objectName: "monthViewPage"
property var currentMonth: DateExt.today();
+ property var selectedDay;
signal dateSelected(var date);
+ signal dateHighlighted(var date);
Keys.forwardTo: [monthViewPath]
@@ -111,11 +113,17 @@
currentMonth: monthViewPath.addMonth(monthViewPath.startMonth,
monthViewPath.indexType(index));
+ selectedDay: monthViewPage.selectedDay
isYearView: false
onDateSelected: {
+ print("Date selected ..."+ date);
monthViewPage.dateSelected(date);
}
+
+ onDateHighlighted: {
+ monthViewPage.dateHighlighted(date);
+ }
}
}
}
=== modified file 'TimeLineBaseComponent.qml'
--- TimeLineBaseComponent.qml 2015-07-25 05:19:10 +0000
+++ TimeLineBaseComponent.qml 2015-09-05 05:32:09 +0000
@@ -35,6 +35,7 @@
property bool isActive: false
property alias contentY: timeLineView.contentY
property alias contentInteractive: timeLineView.interactive
+ property var selectedDay;
property int type: ViewType.ViewTypeWeek
@@ -44,6 +45,7 @@
property EventListModel mainModel;
signal dateSelected(var date);
+ signal dateHighlighted(var date);
function scrollToCurrentTime() {
var currentTime = new Date();
@@ -139,10 +141,15 @@
contentX: timeLineView.contentX
type: root.type
isActive: root.isActive
+ selectedDay: root.selectedDay
onDateSelected: {
root.dateSelected(date);
}
+
+ onDateHighlighted: {
+ root.dateHighlighted(date);
+ }
}
SimpleDivider{}
=== modified file 'TimeLineHeader.qml'
--- TimeLineHeader.qml 2015-07-25 05:19:10 +0000
+++ TimeLineHeader.qml 2015-09-05 05:32:09 +0000
@@ -30,8 +30,10 @@
property double contentX;
property int firstDayOfWeek: Qt.locale().firstDayOfWeek
property bool isActive: false;
+ property var selectedDay;
signal dateSelected(var date);
+ signal dateHighlighted(var date);
width: parent.width
height: units.gu(10)
@@ -155,10 +157,22 @@
width: parent.width
height: units.gu(5)
isCurrentItem: root.isActive
+ selectedDay: {
+ if( root.selectedDay && startDay.weekNumber(Qt.locale().firstDayOfWeek)
+ === root.selectedDay.weekNumber(Qt.locale().firstDayOfWeek)) {
+ root.selectedDay;
+ } else {
+ null;
+ }
+ }
onDateSelected: {
root.dateSelected(date);
}
+
+ onDateHighlighted: {
+ root.dateHighlighted(date);
+ }
}
SimpleDivider{}
=== modified file 'TimeLineHeaderComponent.qml'
--- TimeLineHeaderComponent.qml 2015-07-25 05:19:10 +0000
+++ TimeLineHeaderComponent.qml 2015-09-05 05:32:09 +0000
@@ -31,27 +31,42 @@
property var currentDay
property int highlightedIndex;
+ property var selectedDay;
signal dateSelected(var date);
+ signal dateHighlighted(var date);
width: parent.width
height: units.gu(4)
+ function findSelectedDayIndex() {
+ if(!selectedDay){
+ return -1;
+ }
+ return DateExt.daysBetween(startDay, selectedDay);
+ }
+
onIsCurrentItemChanged: {
highlightedIndex = -1
}
+ onSelectedDayChanged: {
+ if(isCurrentItem){
+ highlightedIndex = findSelectedDayIndex()
+ }
+ }
+
Repeater{
model: type == ViewType.ViewTypeWeek ? 7 : 1
delegate: HeaderDateComponent{
date: type == ViewType.ViewTypeWeek ? startDay.addDays(index) : startDay
dayFormat: Locale.ShortFormat
- highlighted: (type == ViewType.ViewTypeWeek) && (highlightedIndex == index)
+ highlighted: (type == ViewType.ViewTypeWeek) && (highlightedIndex === index)
dayColor: {
if( type == ViewType.ViewTypeWeek && date.isSameDay(DateExt.today())){
- header.highlightedIndex = index
+ //header.highlightedIndex = index
UbuntuColors.orange
} /*else if( type == ViewType.ViewTypeDay && date.isSameDay(currentDay) ) {
UbuntuColors.orange
@@ -71,6 +86,7 @@
header.dateSelected(date);
} else {
header.highlightedIndex = index
+ header.dateHighlighted(date);
}
}
}
=== modified file 'WeekView.qml'
--- WeekView.qml 2015-03-20 17:32:03 +0000
+++ WeekView.qml 2015-09-05 05:32:09 +0000
@@ -28,8 +28,10 @@
property var dayStart: new Date();
property var firstDay: dayStart.weekStart(Qt.locale().firstDayOfWeek);
property bool isCurrentPage: false
+ property var selectedDay;
signal dateSelected(var date);
+ signal dateHighlighted(var date);
Keys.forwardTo: [weekViewPath]
@@ -106,6 +108,7 @@
isActive: parent.PathView.isCurrentItem
startDay: firstDay.addDays( weekViewPath.indexType(index) * 7)
keyboardEventProvider: weekViewPath
+ selectedDay: weekViewPage.selectedDay
onIsActiveChanged: {
timeLineView.scrollTocurrentDate();
@@ -115,6 +118,10 @@
weekViewPage.dateSelected(date);
}
+ onDateHighlighted:{
+ weekViewPage.dateHighlighted(date);
+ }
+
Connections{
target: calendarTodayAction
onTriggered:{
=== modified file 'calendar.qml'
--- calendar.qml 2015-06-11 12:29:28 +0000
+++ calendar.qml 2015-09-05 05:32:09 +0000
@@ -214,6 +214,7 @@
Keys.forwardTo: [tabs.currentPage.item]
property var currentDay: DateExt.today();
+ property var selectedDay;
// Arguments on startup
property bool newevent: false;
@@ -385,6 +386,7 @@
source: tabs.selectedTab == monthTab ? Qt.resolvedUrl("MonthView.qml"):""
onLoaded: {
item.currentMonth = tabs.currentDay.midnight();
+ item.selectedDay = tabs.selectedDay;
}
anchors{
@@ -399,6 +401,10 @@
tabs.currentDay = date;
tabs.selectedTabIndex = dayTab.index;
}
+
+ onDateHighlighted:{
+ tabs.selectedDay = date;
+ }
}
}
}
@@ -414,6 +420,7 @@
onLoaded: {
item.isCurrentPage= Qt.binding(function() { return tabs.selectedTab == weekTab })
item.dayStart = tabs.currentDay;
+ item.selectedDay = tabs.selectedDay;
}
anchors{
@@ -432,6 +439,10 @@
tabs.currentDay = date;
tabs.selectedTabIndex = dayTab.index;
}
+
+ onDateHighlighted:{
+ tabs.selectedDay = date;
+ }
}
}
}
=== modified file 'dateExt.js'
--- dateExt.js 2015-04-02 12:54:38 +0000
+++ dateExt.js 2015-09-05 05:32:09 +0000
@@ -132,3 +132,18 @@
return ( date1.getFullYear() === date2.getFullYear()
&& date1.getMonth() === date2.getMonth() )
}
+
+function daysBetween( date1, date2 ) {
+ //Get 1 day in milliseconds
+ var one_day=1000*60*60*24;
+
+ // Convert both dates to milliseconds
+ var date1_ms = date1.getTime();
+ var date2_ms = date2.getTime();
+
+ // Calculate the difference in milliseconds
+ var difference_ms = date2_ms - date1_ms;
+
+ // Convert back to days and return
+ return Math.round(difference_ms/one_day);
+}
Follow ups