2
This file is part of the kolab resource - the implementation of the
3
Kolab storage format. See www.kolab.org for documentation on this.
5
Copyright (c) 2004 Bo Thorsen <bo@sonofthor.dk>
7
This library is free software; you can redistribute it and/or
8
modify it under the terms of the GNU Library General Public
9
License as published by the Free Software Foundation; either
10
version 2 of the License, or (at your option) any later version.
12
This library is distributed in the hope that it will be useful,
13
but WITHOUT ANY WARRANTY; without even the implied warranty of
14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
Library General Public License for more details.
17
You should have received a copy of the GNU Library General Public License
18
along with this library; see the file COPYING.LIB. If not, write to
19
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20
Boston, MA 02110-1301, USA.
22
In addition, as a special exception, the copyright holders give
23
permission to link the code of this program with any edition of
24
the Qt library by Trolltech AS, Norway (or with modified versions
25
of Qt that use the same license as Qt), and distribute linked
26
combinations including the two. You must obey the GNU General
27
Public License in all respects for all of the code used other than
28
Qt. If you modify this file, you may extend this exception to
29
your version of the file, but you are not obligated to do so. If
30
you do not wish to do so, delete this exception statement from
35
#include "kdepim-version.h"
37
#include <kcal/journal.h>
40
static const char korgVersion[] = KDEPIM_VERSION;
42
using namespace Kolab;
45
KCal::Journal* Journal::xmlToJournal( const QString& xml, const QString& tz )
47
Journal journal( tz );
49
KCal::Journal* kcalJournal = new KCal::Journal();
50
journal.saveTo( kcalJournal );
54
QString Journal::journalToXML( KCal::Journal* kcalJournal, const QString& tz )
56
Journal journal( tz, kcalJournal );
57
return journal.saveXML();
60
Journal::Journal( const QString& tz, KCal::Journal* journal )
71
void Journal::setSummary( const QString& summary )
76
QString Journal::summary() const
81
void Journal::setStartDate( const KDateTime& startDate )
83
mStartDate = startDate;
86
KDateTime Journal::startDate() const
91
void Journal::setEndDate( const KDateTime& endDate )
96
KDateTime Journal::endDate() const
101
bool Journal::loadAttribute( QDomElement& element )
103
QString tagName = element.tagName();
105
if ( tagName == "summary" )
106
setSummary( element.text() );
107
else if ( tagName == "start-date" )
108
setStartDate( stringToDateTime( element.text() ) );
111
return KolabBase::loadAttribute( element );
117
bool Journal::saveAttributes( QDomElement& element ) const
119
// Save the base class elements
120
KolabBase::saveAttributes( element );
122
writeString( element, "summary", summary() );
123
writeString( element, "start-date", dateTimeToString( startDate() ) );
129
bool Journal::loadXML( const QDomDocument& document )
131
QDomElement top = document.documentElement();
133
if ( top.tagName() != "journal" ) {
134
qWarning( "XML error: Top tag was %s instead of the expected Journal",
135
top.tagName().toAscii().data() );
139
for ( QDomNode n = top.firstChild(); !n.isNull(); n = n.nextSibling() ) {
142
if ( n.isElement() ) {
143
QDomElement e = n.toElement();
144
if ( !loadAttribute( e ) ) {
145
// Unhandled tag - save for later storage
146
//qDebug( "Unhandled tag: %s", e.toCString().data() );
149
qDebug( "Node is not a comment or an element???" );
155
QString Journal::saveXML() const
157
QDomDocument document = domTree();
158
QDomElement element = document.createElement( "journal" );
159
element.setAttribute( "version", "1.0" );
160
saveAttributes( element );
161
document.appendChild( element );
162
return document.toString();
165
void Journal::saveTo( KCal::Journal* journal )
167
KolabBase::saveTo( journal );
169
journal->setSummary( summary() );
170
journal->setDtStart( utcToLocal( startDate() ) );
173
void Journal::setFields( const KCal::Journal* journal )
175
// Set baseclass fields
176
KolabBase::setFields( journal );
178
// Set our own fields
179
setSummary( journal->summary() );
180
setStartDate( localToUTC( journal->dtStart() ) );
183
QString Journal::productID() const
185
return QString( "KOrganizer " ) + korgVersion + ", Kolab resource";