45
|
1 |
/*
|
|
2 |
* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description: Single day item view model
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#ifndef CALENDAYMODEL_H
|
|
19 |
#define CALENDAYMODEL_H
|
|
20 |
|
|
21 |
//System includes
|
|
22 |
#include <QAbstractItemModel>
|
|
23 |
#include <QVariant>
|
|
24 |
#include <QDateTime>
|
|
25 |
|
|
26 |
#include <agendaentry.h>
|
|
27 |
|
|
28 |
//User includes
|
|
29 |
|
|
30 |
//Forward declarations
|
|
31 |
class MCalenServices;
|
|
32 |
|
|
33 |
//Constantss
|
|
34 |
const int CalenDayEntry = Qt::UserRole + 1;
|
|
35 |
|
|
36 |
Q_DECLARE_METATYPE(AgendaEntry)
|
|
37 |
class CalenDayModel : public QAbstractListModel
|
|
38 |
{
|
|
39 |
Q_OBJECT
|
|
40 |
public:
|
|
41 |
CalenDayModel(const QDateTime &date, MCalenServices &services,
|
|
42 |
QObject *parent = 0)
|
|
43 |
{
|
|
44 |
Q_UNUSED(date)
|
|
45 |
Q_UNUSED(parent)
|
81
|
46 |
Q_UNUSED(services)
|
45
|
47 |
};
|
|
48 |
|
81
|
49 |
void Reset()
|
|
50 |
{
|
|
51 |
mEntryList.clear();
|
|
52 |
}
|
|
53 |
|
|
54 |
bool insertRows(int num, int row, const QModelIndex &aparent)
|
|
55 |
{
|
|
56 |
Q_UNUSED(row);
|
|
57 |
Q_UNUSED(aparent);
|
|
58 |
AgendaEntry entry;
|
|
59 |
if ( !num ) {
|
|
60 |
entry.setType( AgendaEntry::TypeAppoinment ); //or reminder
|
|
61 |
// non all day event
|
|
62 |
entry.setStartAndEndTime( QDateTime(QDate(2010,07,12),QTime(0,0)),
|
|
63 |
QDateTime(QDate(2010,07,12),QTime(1,0)) );
|
|
64 |
}
|
|
65 |
else {
|
|
66 |
entry.setType( AgendaEntry::TypeEvent );
|
|
67 |
// all day event
|
|
68 |
entry.setStartAndEndTime( QDateTime(QDate(2010,07,12),QTime(0,0)),
|
|
69 |
QDateTime(QDate(2010,07,13),QTime(0,0)) );
|
|
70 |
}
|
|
71 |
mEntryList.append(QVariant::fromValue(entry));
|
|
72 |
return true;
|
|
73 |
}
|
|
74 |
|
45
|
75 |
// from QAbstractListModel
|
|
76 |
int rowCount(const QModelIndex &parent = QModelIndex()) const
|
|
77 |
{
|
81
|
78 |
Q_UNUSED(parent)
|
|
79 |
return mEntryList.count();
|
45
|
80 |
}
|
81
|
81 |
|
|
82 |
QVariant data(const QModelIndex &index, int role) const
|
45
|
83 |
{
|
81
|
84 |
if ( role == CalenDayEntry ) {
|
|
85 |
return mEntryList.at(index.row());
|
|
86 |
}
|
45
|
87 |
return QVariant();
|
|
88 |
}
|
|
89 |
|
|
90 |
void refreshModel(const QDateTime &date)
|
|
91 |
{
|
|
92 |
Q_UNUSED(date)
|
|
93 |
};
|
|
94 |
|
|
95 |
QDateTime modelDate() const
|
|
96 |
{return QDateTime();}
|
81
|
97 |
|
|
98 |
QVariantList mEntryList;
|
45
|
99 |
};
|
|
100 |
|
|
101 |
#endif //CALENDAYMODEL_H
|
|
102 |
|