~ubuntu-branches/ubuntu/saucy/ubuntu-ui-toolkit/saucy

« back to all changes in this revision

Viewing changes to modules/Ubuntu/Components/plugin/ucalarm.cpp

  • Committer: Package Import Robot
  • Author(s): Ubuntu daily release, Timo Jyrinki, Christian Dywan, Zsombor Egri, Leo Arias, Nick Dedekind, Alberto Mardegan, Dennis O'Flaherty, tpeeters, Ubuntu daily release
  • Date: 2013-09-25 07:08:56 UTC
  • mfrom: (1.1.56)
  • Revision ID: package-import@ubuntu.com-20130925070856-2xfkzyjou81vb7m9
Tags: 0.1.46+13.10.20130925.1-0ubuntu1
[ Timo Jyrinki ]
* Temporarily disable the jokes example in order to not have
  qtmultimedia dependency from examples that is not used otherwise.
  This lessens the dependency chains of packages. It can be added back
  after Ubuntu 13.10.
* Fix regression in qmlscene usage (LP: #1229541). (LP: #1229541)

[ Christian Dywan ]
* Set QCoreApplication::applicationName based on MainView. (LP:
  #1197056, #1197051, #1224126)
* Include subfolders of Components in api check.

[ Zsombor Egri ]
* Organizer EDS (Evolution Data Server) integration.
* StateSaver attached component.
* Fix alarm status reporting, updating documentation on asynchronous
  behavior of save and cancel operations. Alarm status notification
  reports the operation the status refers to. (LP: #1226516)
* Dialer + DialerHand components required for TimePicker. .

[ Leo Arias ]
* Added UbuntuUIToolkitAppTestCase as a base test case for the
  autopilot tests. (LP: #1227355)
* Added the autopilot emulator for toggles.

[ Nick Dedekind ]
* Added clipping to tab bar. (LP: #1226104)

[ Alberto Mardegan ]
* Support re-attaching to a different QQuickView Make the plugin
  correctly handle the case when the QQuickView is destroyed and a new
  one is created: this is done by avoiding using static variables, and
  instead binding the data to the QQmlEngine, QQmlContext or QWindow
  as appropriate. . (LP: #1221707)

[ Dennis O'Flaherty ]
* Reword the description for easier reading.

[ tpeeters ]
* Fix warnings when running gallery-app autopilot tests. (LP:
  #1223329, #1223326)
* Smarter automatic updating of Panel's opened property. Panel.open()
  and Panel.close() should be used to open/close a Panel, or when
  using a toolbar with ToolbarItems from a Page, set Page.tools.opened
  to open/close the toolbar. No API or behavior changes since the
  panel-open-close branch. Toolbar behavior changes will be done in a
  following MR.

[ Ubuntu daily release ]
* Automatic snapshot from revision 765

Show diffs side-by-side

added added

removed removed

Lines of Context:
52
52
    if (!request) {
53
53
        return false;
54
54
    }
55
 
    QObject::connect(request, SIGNAL(statusChanged(int,int)),
56
 
                     q_ptr, SLOT(_q_syncStatus(int,int)));
 
55
    QObject::connect(request, SIGNAL(statusChanged(int,int,int)),
 
56
                     q_ptr, SLOT(_q_syncStatus(int,int,int)));
57
57
    return true;
58
58
}
59
59
 
60
 
void UCAlarmPrivate::_q_syncStatus(int status, int error) {
 
60
void UCAlarmPrivate::_q_syncStatus(int operation, int status, int error) {
61
61
    UCAlarm::Status alarmStatus = static_cast<UCAlarm::Status>(status);
62
62
    if (this->status != alarmStatus || this->error != error) {
63
63
        this->status = alarmStatus;
80
80
            rawData.changes = 0;
81
81
        }
82
82
 
83
 
        Q_EMIT q_func()->statusChanged();
 
83
        Q_EMIT q_func()->statusChanged(static_cast<UCAlarm::Operation>(operation));
84
84
        Q_EMIT q_func()->errorChanged();
85
85
    }
86
86
}
135
135
        return UCAlarm::InvalidDate;
136
136
    }
137
137
 
 
138
    rawData.date = rawData.normalizeDate(rawData.date);
 
139
 
138
140
    // check type first as it may alter start day
139
141
    if (rawData.type == UCAlarm::OneTime) {
140
142
       return checkOneTime();
180
182
    }
181
183
 
182
184
    // start date should be later then the current date/time
183
 
    if (rawData.date <= QDateTime::currentDateTime()) {
 
185
    if (rawData.date <= AlarmData::normalizeDate(QDateTime::currentDateTime())) {
184
186
        return UCAlarm::EarlyDate;
185
187
    }
186
188
    return UCAlarm::NoError;
278
280
 *                 alarm.save();
279
281
 *                 if (alarm.error != Alarm.NoError)
280
282
 *                     print("Error saving alarm, code: " + alarm.error);
281
 
 *                 else alarm.reset();
282
283
 *             }
283
284
 *         }
284
285
 *     }
567
568
 
568
569
/*!
569
570
 * \qmlproperty Status Alarm::status
570
 
 * The property holds the status of the last performed operation.
 
571
 * The property holds the status of the last performed operation. It can take one
 
572
 * of the following values:
 
573
 * \table
 
574
 *   \header
 
575
 *      \li Status code
 
576
 *      \li Value
 
577
 *      \li Description
 
578
 *   \row
 
579
 *      \li Ready
 
580
 *      \li 1
 
581
 *      \li Specifies either that the Alarm object is ready to perform any operation
 
582
 *          or that the previous operation has been successfully completed.
 
583
 *   \row
 
584
 *      \li InProgress
 
585
 *      \li 2
 
586
 *      \li Specifies that there is an operation pending on Alarm object.
 
587
 *   \row
 
588
 *      \li Fail
 
589
 *      \li 3
 
590
 *      \li Specifies that the last alarm operation has failed. The failure code is
 
591
 *          set in \l error property.
 
592
 * \endtable
 
593
 *
 
594
 * The notification signal has a parameter specifying the \a operation the status
 
595
 * refers to. The operation can take the following values:
 
596
 * \table
 
597
 *   \header
 
598
 *      \li Operation code
 
599
 *      \li Description
 
600
 *   \row
 
601
 *      \li NoOperation
 
602
 *      \li There is no operation pending. This may be set when an error occured
 
603
 *          in the alarm adapters and the operation cannot be determined.
 
604
 *  \row
 
605
 *      \li Saving
 
606
 *      \li The status reported refers to an operation requested through save().
 
607
 *  \row
 
608
 *      \li Canceling
 
609
 *      \li The status reported refers to an operation requested through cancel().
 
610
 *  \row
 
611
 *      \li Reseting
 
612
 *      \li The status reported refers to an operation requested through reset().
 
613
 * \endtable
 
614
 *
 
615
 * For example an implementation which resets the alarm data whenever
 
616
 * the save or cancel operations succeed would look as follows:
 
617
 *
 
618
 * \qml
 
619
 * Alarm {
 
620
 *     onStatusChanged: {
 
621
 *         if (status !== Alarm.Ready)
 
622
 *             return;
 
623
 *         if ((operation > Alarm.NoOperation) && (operation < Alarm.Reseting)) {
 
624
 *             reset();
 
625
 *         }
 
626
 *     }
 
627
 * }
 
628
 * \endqml
571
629
 */
572
630
UCAlarm::Status UCAlarm::status() const
573
631
{
593
651
 *  \li - the \l daysOfWeek property is set to multiple days for one time alarm
594
652
 * \endlist
595
653
 *
 
654
 * The operation is asynchronous, and its status is reported through the \l status
 
655
 * property. Further operations should wait till the previous operation is completed.
596
656
 * The operation result is stored in the \l error property.
597
657
 */
598
658
void UCAlarm::save()
608
668
 
609
669
    UCAlarm::Error result = d->checkAlarm();
610
670
    if (result != UCAlarm::NoError) {
611
 
        d->_q_syncStatus(Fail, result);
 
671
        d->_q_syncStatus(Saving, Fail, result);
612
672
    } else {
613
673
        if (d->createRequest()) {
614
674
            d->request->save(d->rawData);
621
681
 * The function removes the alarm from the collection. The function will fail
622
682
 * for alarms which are not yet registered to the collection.
623
683
 *
 
684
 * The operation is asynchronous, and its status is reported through the \l status
 
685
 * property. Further operations should wait till the previous operation is completed.
624
686
 * The operation result is stored in the \l error property.
625
687
 */
626
688
void UCAlarm::cancel()
642
704
 * \qmlmethod Alarm::reset()
643
705
 * The function resets the alarm properties to its defaults. After this call the
644
706
 * object can be used to create a new alarm event.
 
707
 *
 
708
 * \b Note: do not call this function on alarm objects retrieved from AlarmModel, as
 
709
 * calling it will result in the model being out of sync from the alarm database.
645
710
 */
646
711
void UCAlarm::reset()
647
712
{
648
713
    Q_D(UCAlarm);
649
 
    d->error = NoError;
650
 
    d->status = InProgress;
 
714
    d->_q_syncStatus(Reseting, InProgress, NoError);
651
715
 
652
 
    delete d->request;
653
 
    d->request = 0;
654
716
    d->rawData = AlarmData();
655
717
    d->setDefaults();
656
718
    d->rawData.changes = AlarmData::AllFields;
657
 
    d->_q_syncStatus(Ready, NoError);
 
719
    d->_q_syncStatus(Reseting, Ready, NoError);
658
720
}
659
721
 
660
722
#include "moc_ucalarm.cpp"