GNOME Bugzilla – Bug 769470
drag and drop places the event on wrong date
Last modified: 2017-04-17 18:20:40 UTC
When the event is spanning more than one month, drag and drop sometimes places the event on the wrong date. How to reproduce: 1. Create a new event: Let it be a 2 day event on 31st August and 1st September. 2. In Month view, Go to the month September, drag the event (which is shown as the continuation on 1st September) to some other date of the same month. 3. The event is placed on the same day of the previous month, which is not intended. 4. Also, in year view, the drag and drop works pretty much weird. The end date is set as one day past the beginning date (This happens on single full day events too).
Created attachment 332675 [details] [review] month-view: fix dnd Currently, the event is moved by a number of cells, calculated from the start date and the cell index. The problem with that is that it does not work with events, whose start and end dates of which are on different months or years. This commit changes the logic so that the start date is calculated by taking the year and month difference into consideration and the end date is set by adding the event length to the adjusted start date.
I am not proud of this mess, but it does fix the month view (at least judging by the minimal testing I had done).
Created attachment 332676 [details] [review] Plugged a leak.
Created attachment 332677 [details] [review] month-view: fix dnd Sorry for the noise. This avoids crashes with null end dates.
Review of attachment 332677 [details] [review]: Only a minor nitpik. ::: src/gcal-month-view.c @@ +888,3 @@ + { + timespan = g_date_time_difference (end_dt, start_dt); + } Remove the {}s
Created attachment 332820 [details] [review] month-view: fix dnd Currently, the event is moved by a number of cells, calculated from the start date and the cell index. The problem with that is that it does not work with events, whose start and end dates of which are on different months or years. This commit changes the logic so that the start date is calculated by taking the year and month difference into consideration and the end date is set by adding the event length to the adjusted start date.
Created attachment 332824 [details] [review] year-view: fix dnd Currently, the end date is set by calling gcal_event_set_date_end() with new_start instead of new_end, which is incorrect. With the former issue fixed, the difference evaluates to one less than required when dragging to a later date. This can be fixed by calculating the drop date by adding to the start date and adding the difference. This commit fixes both issues.
Re the year view fix, I do not actually know what causes the latter issue. Could it have something to do with timezones? The difference between drop date and start date would always be a couple of hours short off a full day.
Review of attachment 332820 [details] [review]: Sure.
Review of attachment 332824 [details] [review]: Sure
I notice that Month view doesn't update events modified on Year view with DnD. Fixing that in a third patch would be a nice addition to this patchset.
Created attachment 333095 [details] [review] month-view: update events after dnd The month view is not updated after a DnD operation. This commit marks the children as changed after a drop.
Is this what you meant?
Review of attachment 333095 [details] [review]: Sure!
Attachment 332820 [details] pushed as b5fb1d4 - month-view: fix dnd Attachment 332824 [details] pushed as 04617fc - year-view: fix dnd Attachment 333095 [details] pushed as 7243f70 - month-view: update events after dnd