← Back to team overview

ubuntu-touch-coreapps-reviewers team mailing list archive

[Merge] lp:~renatofilho/ubuntu-calendar-app/week-press-and-hold-create-event into lp:ubuntu-calendar-app

 

Renato Araujo Oliveira Filho has proposed merging lp:~renatofilho/ubuntu-calendar-app/week-press-and-hold-create-event into lp:ubuntu-calendar-app with lp:~renatofilho/ubuntu-calendar-app/optimize-page-load as a prerequisite.

Requested reviews:
  Jenkins Bot (ubuntu-core-apps-jenkins-bot): continuous-integration
  Ubuntu Calendar Developers (ubuntu-calendar-dev)

For more details, see:
https://code.launchpad.net/~renatofilho/ubuntu-calendar-app/week-press-and-hold-create-event/+merge/284290
-- 
Your team Ubuntu Calendar Developers is requested to review the proposed merge of lp:~renatofilho/ubuntu-calendar-app/week-press-and-hold-create-event into lp:ubuntu-calendar-app.
=== modified file 'DayView.qml'
--- DayView.qml	2016-01-28 14:15:58 +0000
+++ DayView.qml	2016-01-28 14:15:58 +0000
@@ -29,6 +29,7 @@
     property bool isCurrentPage: false
 
     signal dateSelected(var date);
+    signal pressAndHoldAt(var date)
 
     Keys.forwardTo: [dayViewPath]
     flickable: null
@@ -103,6 +104,10 @@
                     startDay: dayViewPath.startDay.addDays(dayViewPath.indexType(index))
                     keyboardEventProvider: dayViewPath
 
+                    onPressAndHoldAt: {
+                        dayViewPage.pressAndHoldAt(date)
+                    }
+
                     Component.onCompleted: {
                         if(dayViewPage.isCurrentPage){
                             timeLineView.scrollToCurrentTime();

=== modified file 'EventBubble.qml'
--- EventBubble.qml	2016-01-28 14:15:58 +0000
+++ EventBubble.qml	2016-01-28 14:15:58 +0000
@@ -219,10 +219,12 @@
     MouseArea {
         id: dragArea
         anchors.fill: parent
-        drag.target: isLiveEditing ? infoBubble : null
-        drag.axis: Drag.YAxis
-        drag.minimumY: flickable ? flickable.y : 0
-        drag.maximumY: flickable ? flickable.contentHeight - infoBubble.height : infoBubble.height
+        drag {
+            target: isLiveEditing ? infoBubble : null
+            axis: Drag.YAxis
+            minimumY: flickable ? flickable.y : 0
+            maximumY: flickable ? flickable.contentHeight - infoBubble.height : infoBubble.height
+        }
         onReleased: parent.Drag.drop()
         onClicked: {
             if( isLiveEditing ) {

=== modified file 'NewEvent.qml'
--- NewEvent.qml	2016-01-28 14:15:58 +0000
+++ NewEvent.qml	2016-01-28 14:15:58 +0000
@@ -294,10 +294,15 @@
     function roundDate(date) {
         var tempDate = new Date(date)
         tempDate.setHours(date.getHours(), date.getMinutes(), 0, 0);
-        if(tempDate.getMinutes() < 30)
+        var tempMinutes = tempDate.getMinutes()
+        if (tempMinutes === 0) {
+            return tempDate
+        } else if(tempMinutes < 30) {
             return tempDate.setMinutes(30)
-        tempDate.setMinutes(0)
-        return tempDate.setHours(tempDate.getHours() + 1)
+        } else {
+            tempDate.setMinutes(0)
+            return tempDate.setHours(tempDate.getHours() + 1)
+        }
     }
 
     function adjustEndDateToStartDate(time_forward) {

=== modified file 'TimeLineBase.qml'
--- TimeLineBase.qml	2016-01-28 14:15:58 +0000
+++ TimeLineBase.qml	2016-01-28 14:15:58 +0000
@@ -29,19 +29,54 @@
     property int hourHeight: units.gu(8)
     property var model;
 
+    signal pressAndHoldAt(var date)
+
     Component.onCompleted: {
         bubbleOverLay.createEvents();
     }
 
     MouseArea {
+        id: overlayMouseArea
+
+        property bool creatingEvent: false
+
         anchors.fill: parent
         objectName: "mouseArea"
+        drag {
+            target: creatingEvent ? temporaryEvent : null
+            axis: Drag.YAxis
+            minimumY: 0
+            maximumY: height - temporaryEvent.height
+        }
+
+        EventBubble {
+            id: temporaryEvent
+
+             Drag.active: overlayMouseArea.drag.active
+             isLiveEditing: overlayMouseArea.creatingEvent
+             visible: overlayMouseArea.creatingEvent
+             z: visible ? 100 : 0
+        }
+
+        Binding {
+            target: temporaryEvent
+            property: "visible"
+            value: overlayMouseArea.creatingEvent
+        }
 
         onPressAndHold: {
             var selectedDate = new Date(day);
-            var hour = parseInt(mouseY / hourHeight);
+            var hour = Math.round(mouse.y / hourHeight);
             selectedDate.setHours(hour)
-            createOrganizerEvent(selectedDate);
+            var event = createOrganizerEvent(selectedDate)
+
+            assignBubbleProperties(temporaryEvent, event, 100, 1000);
+            creatingEvent = true
+        }
+
+        onReleased: {
+            bubbleOverLay.pressAndHoldAt(temporaryEvent.event.startDateTime)
+            creatingEvent = false
         }
 
         onPressed: {
@@ -52,6 +87,17 @@
         }
     }
 
+    function createOrganizerEvent( startDate ) {
+        var event = Qt.createQmlObject("import QtOrganizer 5.0; Event {}", Qt.application,"TimeLineBase.qml");
+        event.collectionId = (model.defaultCollection().collectionId);
+        var endDate = new Date( startDate.getTime() + 3600000 );
+        event.startDateTime = startDate;
+        event.endDateTime = endDate;
+        event.displayLabel = i18n.tr("New event");
+        event.setDetail(Qt.createQmlObject("import QtOrganizer 5.0; Comment{ comment: 'X-CAL-DEFAULT-EVENT'}", event,"TimeLineBase.qml"));
+        return event
+    }
+
     function getTimeFromYPos(y, day) {
         var date = new Date(day);
         var time = y / hourHeight;
@@ -64,17 +110,6 @@
         return date;
     }
 
-    function createOrganizerEvent( startDate ) {
-        var event = Qt.createQmlObject("import QtOrganizer 5.0; Event {}", Qt.application,"TimeLineBase.qml");
-        event.collectionId = (model.defaultCollection().collectionId);
-        var endDate = new Date( startDate.getTime() + 3600000 );
-        event.startDateTime = startDate;
-        event.endDateTime = endDate;
-        event.displayLabel = i18n.tr("Untitled");
-        event.setDetail(Qt.createQmlObject("import QtOrganizer 5.0; Comment{ comment: 'X-CAL-DEFAULT-EVENT'}", event,"TimeLineBase.qml"));
-        model.saveItem(event);
-    }
-
     TimeSeparator {
         id: separator
         objectName: "separator"

=== modified file 'TimeLineBaseComponent.qml'
--- TimeLineBaseComponent.qml	2016-01-28 14:15:58 +0000
+++ TimeLineBaseComponent.qml	2016-01-28 14:15:58 +0000
@@ -45,6 +45,7 @@
 
     signal dateSelected(var date);
     signal dateHighlighted(var date);
+    signal pressAndHoldAt(var date);
 
     function scrollToCurrentTime() {
         var currentTime = new Date();
@@ -228,6 +229,10 @@
                             day: startDay.addDays(index)
                             model: mainModel
 
+                            onPressAndHoldAt: {
+                                root.pressAndHoldAt(date)
+                            }
+
                             Connections{
                                 target: mainModel
 

=== modified file 'WeekView.qml'
--- WeekView.qml	2016-01-28 14:15:58 +0000
+++ WeekView.qml	2016-01-28 14:15:58 +0000
@@ -32,6 +32,7 @@
 
     signal dateSelected(var date);
     signal dateHighlighted(var date);
+    signal pressAndHoldAt(var date)
 
     Keys.forwardTo: [weekViewPath]
 
@@ -123,6 +124,10 @@
                         weekViewPage.dateHighlighted(date);
                     }
 
+                    onPressAndHoldAt: {
+                        weekViewPage.pressAndHoldAt(date)
+                    }
+
                     Connections{
                         target: calendarTodayAction
                         onTriggered:{

=== modified file 'calendar.qml'
--- calendar.qml	2016-01-28 14:15:58 +0000
+++ calendar.qml	2016-01-28 14:15:58 +0000
@@ -518,6 +518,10 @@
                 if (active)
                     dayStart = tabs.currentDay
             }
+            onPressAndHoldAt: {
+                tabs.currentDay = date;
+                commonHeaderActions.newEventAction.trigger()
+            }
         }
     }
 
@@ -537,6 +541,11 @@
                 if (active)
                     currentDay = tabs.currentDay;
             }
+
+            onPressAndHoldAt: {
+                tabs.currentDay = date;
+                commonHeaderActions.newEventAction.trigger()
+            }
         }
     }