~ubuntu-filemanager-dev/ubuntu-filemanager-app/nemo-qml-plugins-packaging

« back to all changes in this revision

Viewing changes to alarms/src/alarmsbackendmodel.h

  • Committer: Timo Jyrinki
  • Date: 2013-03-20 15:03:31 UTC
  • Revision ID: timo.jyrinki@canonical.com-20130320150331-aggtqfb7cufdiuzc
ImportĀ upstreamĀ 0.3.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2012 Jolla Ltd.
 
3
 * Contact: John Brooks <john.brooks@jollamobile.com>
 
4
 *
 
5
 * You may use this file under the terms of the BSD license as follows:
 
6
 *
 
7
 * "Redistribution and use in source and binary forms, with or without
 
8
 * modification, are permitted provided that the following conditions are
 
9
 * met:
 
10
 *   * Redistributions of source code must retain the above copyright
 
11
 *     notice, this list of conditions and the following disclaimer.
 
12
 *   * Redistributions in binary form must reproduce the above copyright
 
13
 *     notice, this list of conditions and the following disclaimer in
 
14
 *     the documentation and/or other materials provided with the
 
15
 *     distribution.
 
16
 *   * Neither the name of Nemo Mobile nor the names of its contributors
 
17
 *     may be used to endorse or promote products derived from this
 
18
 *     software without specific prior written permission.
 
19
 *
 
20
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 
21
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 
22
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 
23
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 
24
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 
25
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 
26
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 
27
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 
28
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 
29
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 
30
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
 
31
 */
 
32
 
 
33
#ifndef ALARMSBACKENDMODEL_H
 
34
#define ALARMSBACKENDMODEL_H
 
35
 
 
36
#include <QAbstractListModel>
 
37
 
 
38
class AlarmsBackendModelPriv;
 
39
class AlarmObject;
 
40
 
 
41
class AlarmsBackendModel : public QAbstractListModel
 
42
{
 
43
    Q_OBJECT
 
44
 
 
45
public:
 
46
    enum {
 
47
        AlarmObjectRole = Qt::UserRole,
 
48
        EnabledRole,
 
49
        HourRole,
 
50
        MinuteRole,
 
51
        WeekDaysRole
 
52
    };
 
53
 
 
54
    AlarmsBackendModel(QObject *parent = 0);
 
55
    virtual ~AlarmsBackendModel();
 
56
 
 
57
    /*!
 
58
     *  \qmlmethod Alarm AlarmsModel::createAlarm
 
59
     *
 
60
     *  Create a new alarm object. After setting properties, call the save()
 
61
     *  method of the object to commit it to the backend and model.
 
62
     *
 
63
     *  If the operation is aborted, call the deleteAlarm() method of the object.
 
64
     */
 
65
    Q_INVOKABLE AlarmObject *createAlarm();
 
66
 
 
67
    /*!
 
68
     *  \qmlproperty bool AlarmsModel::populated
 
69
     *
 
70
     *  True when the model has loaded all available alarms from the backend.
 
71
     *  The model may still be empty afterwards.
 
72
     */
 
73
    Q_PROPERTY(bool populated READ isPopulated NOTIFY populatedChanged)
 
74
    bool isPopulated() const;
 
75
 
 
76
    virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
 
77
    QVariant data(const QModelIndex &index, int role) const;
 
78
 
 
79
signals:
 
80
    void populatedChanged();
 
81
 
 
82
private:
 
83
    friend class AlarmsBackendModelPriv;
 
84
    AlarmsBackendModelPriv *priv;
 
85
};
 
86
 
 
87
#endif // ALARMSBACKENDMODEL_H