~renatofilho/ubuntu-calendar-app/optimize

« back to all changes in this revision

Viewing changes to calendar.qml

  • Committer: Renato Araujo Oliveira Filho
  • Date: 2016-02-02 01:21:57 UTC
  • Revision ID: renato.filho@canonical.com-20160202012157-ikgkkb37z5pcs51d
Does not change main date if the current date change on views.

Show diffs side-by-side

added added

removed removed

Lines of Context:
505
505
 
506
506
        YearView {
507
507
            model: eventModel
508
 
 
509
 
            onCurrentYearChanged: {
510
 
                tabs.currentDay = new Date(currentYear, 0, 1, 0, 0, 0)
511
 
            }
512
 
 
513
508
            onMonthSelected: {
514
509
                var now = DateExt.today();
515
510
                if ((date.getMonth() === now.getMonth()) &&
534
529
 
535
530
        MonthView {
536
531
            model: eventModel
537
 
            onCurrentDateChanged: {
538
 
                var cDate = currentDate
539
 
                if (highlightedDate) {
540
 
                    // highlighted date has priority over current date
541
 
                    cDate = new Date(highlightedDate.fullYear(),
542
 
                                     highlightedDate.getMonth(),
543
 
                                     highlightedDate.getDate(),
544
 
                                     cDate.getHours(),
545
 
                                     cDate.getMinutes(),
546
 
                                     0)
547
 
                }
548
 
 
549
 
                tabs.currentDay = cDate
550
 
            }
551
 
 
552
532
            onDateHighlighted: {
553
533
                tabs.currentDay = date
554
534
            }
573
553
            property var highlightedDate
574
554
 
575
555
            model: eventModel
576
 
            onCurrentDateChanged: {
577
 
                var cDate = currentDate
578
 
                if (highlightedDate) {
579
 
                    // highlighted date has priority over current date
580
 
                    cDate = new Date(highlightedDate.getFullYear(),
581
 
                                     highlightedDate.getMonth(),
582
 
                                     highlightedDate.getDate(),
583
 
                                     cDate.getHours(),
584
 
                                     cDate.getMinutes(),
585
 
                                     0)
586
 
                }
587
 
 
588
 
                tabs.currentDay = cDate
589
 
            }
590
 
 
591
556
            onDateHighlighted: {
592
557
                highlightedDate = date
593
558
                if (date)
599
564
                tabs.selectedTabIndex = dayTab.index
600
565
            }
601
566
 
602
 
            onActiveChanged: {
603
 
                if (active) {
604
 
                    anchorDate = tabs.currentDay.midnight()
605
 
                }
606
 
            }
607
 
 
608
567
            onPressAndHoldAt: {
609
568
                pageStack.push(Qt.resolvedUrl("NewEvent.qml"),{"date":date, "model":eventModel});
610
569
            }
 
570
 
 
571
            onActiveChanged: {
 
572
                if (active) {
 
573
                    anchorDate = tabs.currentDay
 
574
                }
 
575
            }
611
576
        }
612
577
    }
613
578
 
617
582
        DayView {
618
583
            model: eventModel
619
584
 
620
 
            onCurrentDateChanged: {
621
 
                tabs.currentDay = currentDate
622
 
            }
623
 
 
624
585
            onDateSelected: {
625
586
                tabs.currentDay = date
626
587
            }
627
588
 
 
589
            onPressAndHoldAt: {
 
590
                pageStack.push(Qt.resolvedUrl("NewEvent.qml"),
 
591
                               {"date": date, "model": eventModel});
 
592
            }
 
593
 
628
594
            onActiveChanged: {
629
595
                if (active) {
630
596
                    anchorDate = tabs.currentDay
631
597
                }
632
598
            }
633
 
 
634
 
            onPressAndHoldAt: {
635
 
                pageStack.push(Qt.resolvedUrl("NewEvent.qml"),{"date": date, "model": eventModel});
636
 
            }
637
599
        }
638
600
    }
639
601