1/*
2 This file is part of the kcalcore library.
3
4 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
5
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version.
10
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
15
16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA.
20*/
21/**
22 @file
23 This file is part of the API for handling calendar data and
24 defines the Journal class.
25
26 @brief
27 Provides a Journal in the sense of RFC2445.
28
29 @author Cornelius Schumacher \<schumacher@kde.org\>
30*/
31
32#include "journal.h"
33#include "visitor.h"
34
35#include <KDebug>
36
37using namespace KCalCore;
38
39Journal::Journal() : d(0)
40{
41}
42
43Journal::~Journal()
44{
45}
46
47Incidence::IncidenceType Journal::type() const
48{
49 return TypeJournal;
50}
51
52QByteArray Journal::typeStr() const
53{
54 return "Journal";
55}
56
57Journal *Journal::clone() const
58{
59 return new Journal(*this);
60}
61
62IncidenceBase &Journal::assign(const IncidenceBase &other)
63{
64 Incidence::assign(other);
65 return *this;
66}
67
68bool Journal::equals(const IncidenceBase &journal) const
69{
70 return Incidence::equals(journal);
71}
72
73bool Journal::accept(Visitor &v, IncidenceBase::Ptr incidence)
74{
75 return v.visit(incidence.staticCast<Journal>());
76}
77
78KDateTime Journal::dateTime(DateTimeRole role) const
79{
80 switch (role) {
81 case RoleEnd:
82 case RoleEndTimeZone:
83 return KDateTime();
84 case RoleDisplayStart:
85 case RoleDisplayEnd:
86 return dtStart();
87 default:
88 return dtStart();
89 }
90}
91
92void Journal::setDateTime(const KDateTime &dateTime, DateTimeRole role)
93{
94 switch (role) {
95 case RoleDnD:
96 {
97 setDtStart(dateTime);
98 break;
99 }
100 default:
101 kDebug() << "Unhandled role" << role;
102 }
103}
104
105void Journal::virtual_hook(int id, void *data)
106{
107 switch (static_cast<IncidenceBase::VirtualHook>(id)) {
108 case IncidenceBase::SerializerHook:
109 serialize(*reinterpret_cast<QDataStream*>(data));
110 break;
111 case IncidenceBase::DeserializerHook:
112 deserialize(*reinterpret_cast<QDataStream*>(data));
113 break;
114 default:
115 Q_ASSERT(false);
116 }
117}
118
119QLatin1String Journal::mimeType() const
120{
121 return Journal::journalMimeType();
122}
123
124/* static */
125QLatin1String Journal::journalMimeType()
126{
127 return QLatin1String("application/x-vnd.akonadi.calendar.journal");
128}
129
130QLatin1String Journal::iconName(const KDateTime &) const
131{
132 return QLatin1String("view-pim-journal");
133}
134
135void Journal::serialize(QDataStream &out)
136{
137 Incidence::serialize(out);
138}
139
140void Journal::deserialize(QDataStream &in)
141{
142 Incidence::deserialize(in);
143}
144