qtmobility/examples/notesmanagerplugin/notesmanager.h
changeset 1 2b40d63a9c3d
child 4 90517678cc4f
equal deleted inserted replaced
0:cfcbf08528c4 1:2b40d63a9c3d
       
     1 /****************************************************************************
       
     2 **
       
     3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     4 ** All rights reserved.
       
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
       
     6 **
       
     7 ** This file is part of the Qt Mobility Components.
       
     8 **
       
     9 ** $QT_BEGIN_LICENSE:LGPL$
       
    10 ** You may use this file in accordance with the terms and conditions
       
    11 ** contained in the Technology Preview License Agreement accompanying
       
    12 ** this package.
       
    13 **
       
    14 ** GNU Lesser General Public License Usage
       
    15 ** Alternatively, this file may be used under the terms of the GNU Lesser
       
    16 ** General Public License version 2.1 as published by the Free Software
       
    17 ** Foundation and appearing in the file LICENSE.LGPL included in the
       
    18 ** packaging of this file.  Please review the following information to
       
    19 ** ensure the GNU Lesser General Public License version 2.1 requirements
       
    20 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
       
    21 **
       
    22 ** In addition, as a special exception, Nokia gives you certain additional
       
    23 ** rights.  These rights are described in the Nokia Qt LGPL Exception
       
    24 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
       
    25 **
       
    26 ** If you have questions regarding the use of this file, please contact
       
    27 ** Nokia at qt-info@nokia.com.
       
    28 **
       
    29 **
       
    30 **
       
    31 **
       
    32 **
       
    33 **
       
    34 **
       
    35 **
       
    36 ** $QT_END_LICENSE$
       
    37 **
       
    38 ****************************************************************************/
       
    39 
       
    40 #ifndef NOTESMANAGER_H
       
    41 #define NOTESMANAGER_H
       
    42 
       
    43 #include <QObject>
       
    44 #include <QDateTime>
       
    45 #include <QList>
       
    46 #include <QTimer>
       
    47 #include <QSqlDatabase>
       
    48 #include <QSqlQuery>
       
    49 
       
    50 typedef struct
       
    51 {
       
    52     int index;
       
    53     QString message;
       
    54     QDateTime alert;
       
    55 } Note;
       
    56 
       
    57 class NotesManager : public QObject
       
    58 {
       
    59     Q_OBJECT
       
    60     Q_PROPERTY(QDateTime alarm READ getAlarm WRITE setAlarm  NOTIFY soundAlarm)
       
    61     Q_PROPERTY(QString message READ getMessage WRITE setMessage)
       
    62 
       
    63 public:
       
    64     NotesManager(QObject *parent = 0);
       
    65     Q_INVOKABLE QList<Note> getNotes(const QString& search=QString()) const;
       
    66 
       
    67 public slots:
       
    68     void addNote(const QString &note, const QDateTime &alarm);
       
    69     void removeNote(int id);
       
    70 
       
    71 private:
       
    72     QDateTime m_alarm;
       
    73     QString m_message;
       
    74 
       
    75     QDateTime getAlarm() const;
       
    76     void setAlarm(const QDateTime &alarm);
       
    77     
       
    78     QString getMessage() const;
       
    79     void setMessage(const QString &message);
       
    80 
       
    81     void nextAlarm();
       
    82 
       
    83 private slots:
       
    84     void checkAlarm();
       
    85 
       
    86 signals:
       
    87     void soundAlarm(const QDateTime &alarm);
       
    88 };
       
    89 
       
    90 #endif
       
    91