-rw-r--r-- | libkcal/incidencebase.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/libkcal/incidencebase.cpp b/libkcal/incidencebase.cpp index 15c4fa8..64a343c 100644 --- a/libkcal/incidencebase.cpp +++ b/libkcal/incidencebase.cpp | |||
@@ -1,171 +1,172 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkcal. | 2 | This file is part of libkcal. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | #include <kglobal.h> | 21 | #include <kglobal.h> |
22 | #include <klocale.h> | 22 | #include <klocale.h> |
23 | #include <kdebug.h> | 23 | #include <kdebug.h> |
24 | #include <kidmanager.h> | 24 | #include <kidmanager.h> |
25 | 25 | ||
26 | #include "calformat.h" | 26 | #include "calformat.h" |
27 | #include "syncdefines.h" | ||
27 | 28 | ||
28 | #include "incidencebase.h" | 29 | #include "incidencebase.h" |
29 | 30 | ||
30 | using namespace KCal; | 31 | using namespace KCal; |
31 | 32 | ||
32 | IncidenceBase::IncidenceBase() : | 33 | IncidenceBase::IncidenceBase() : |
33 | mReadOnly(false), mFloats(true), mDuration(0), mHasDuration(false), | 34 | mReadOnly(false), mFloats(true), mDuration(0), mHasDuration(false), |
34 | mPilotId(0), mSyncStatus(SYNCMOD) | 35 | mPilotId(0), mSyncStatus(SYNCMOD) |
35 | { | 36 | { |
36 | setUid(CalFormat::createUniqueId()); | 37 | setUid(CalFormat::createUniqueId()); |
37 | mOrganizer = ""; | 38 | mOrganizer = ""; |
38 | mFloats = false; | 39 | mFloats = false; |
39 | mDuration = 0; | 40 | mDuration = 0; |
40 | mHasDuration = false; | 41 | mHasDuration = false; |
41 | mPilotId = 0; | 42 | mPilotId = 0; |
42 | mExternalId = ":"; | 43 | mExternalId = ":"; |
43 | mTempSyncStat = 0; | 44 | mTempSyncStat = SYNC_TEMPSTATE_INITIAL; |
44 | mSyncStatus = 0; | 45 | mSyncStatus = 0; |
45 | mAttendees.setAutoDelete( true ); | 46 | mAttendees.setAutoDelete( true ); |
46 | } | 47 | } |
47 | 48 | ||
48 | IncidenceBase::IncidenceBase(const IncidenceBase &i) : | 49 | IncidenceBase::IncidenceBase(const IncidenceBase &i) : |
49 | CustomProperties( i ) | 50 | CustomProperties( i ) |
50 | { | 51 | { |
51 | mReadOnly = i.mReadOnly; | 52 | mReadOnly = i.mReadOnly; |
52 | mDtStart = i.mDtStart; | 53 | mDtStart = i.mDtStart; |
53 | mDuration = i.mDuration; | 54 | mDuration = i.mDuration; |
54 | mHasDuration = i.mHasDuration; | 55 | mHasDuration = i.mHasDuration; |
55 | mOrganizer = i.mOrganizer; | 56 | mOrganizer = i.mOrganizer; |
56 | mUid = i.mUid; | 57 | mUid = i.mUid; |
57 | QPtrList<Attendee> attendees = i.attendees(); | 58 | QPtrList<Attendee> attendees = i.attendees(); |
58 | for( Attendee *a = attendees.first(); a; a = attendees.next() ) { | 59 | for( Attendee *a = attendees.first(); a; a = attendees.next() ) { |
59 | mAttendees.append( new Attendee( *a ) ); | 60 | mAttendees.append( new Attendee( *a ) ); |
60 | } | 61 | } |
61 | mFloats = i.mFloats; | 62 | mFloats = i.mFloats; |
62 | mLastModified = i.mLastModified; | 63 | mLastModified = i.mLastModified; |
63 | mPilotId = i.mPilotId; | 64 | mPilotId = i.mPilotId; |
64 | mTempSyncStat = i.mTempSyncStat; | 65 | mTempSyncStat = i.mTempSyncStat; |
65 | mSyncStatus = i.mSyncStatus; | 66 | mSyncStatus = i.mSyncStatus; |
66 | mExternalId = i.mExternalId; | 67 | mExternalId = i.mExternalId; |
67 | // The copied object is a new one, so it isn't observed by the observer | 68 | // The copied object is a new one, so it isn't observed by the observer |
68 | // of the original object. | 69 | // of the original object. |
69 | mObservers.clear(); | 70 | mObservers.clear(); |
70 | 71 | ||
71 | mAttendees.setAutoDelete( true ); | 72 | mAttendees.setAutoDelete( true ); |
72 | } | 73 | } |
73 | 74 | ||
74 | IncidenceBase::~IncidenceBase() | 75 | IncidenceBase::~IncidenceBase() |
75 | { | 76 | { |
76 | } | 77 | } |
77 | 78 | ||
78 | 79 | ||
79 | bool KCal::operator==( const IncidenceBase& i1, const IncidenceBase& i2 ) | 80 | bool KCal::operator==( const IncidenceBase& i1, const IncidenceBase& i2 ) |
80 | { | 81 | { |
81 | // do not compare mSyncStatus and mExternalId | 82 | // do not compare mSyncStatus and mExternalId |
82 | if( i1.attendees().count() != i2.attendees().count() ) { | 83 | if( i1.attendees().count() != i2.attendees().count() ) { |
83 | return false; // no need to check further | 84 | return false; // no need to check further |
84 | } | 85 | } |
85 | if ( i1.attendees().count() > 0 ) { | 86 | if ( i1.attendees().count() > 0 ) { |
86 | Attendee * a1 = i1.attendees().first(), *a2 =i2.attendees().first() ; | 87 | Attendee * a1 = i1.attendees().first(), *a2 =i2.attendees().first() ; |
87 | while ( a1 ) { | 88 | while ( a1 ) { |
88 | if ( !( (*a1) == (*a2)) ) | 89 | if ( !( (*a1) == (*a2)) ) |
89 | { | 90 | { |
90 | //qDebug("Attendee not equal "); | 91 | //qDebug("Attendee not equal "); |
91 | return false; | 92 | return false; |
92 | } | 93 | } |
93 | a1 = i1.attendees().next(); | 94 | a1 = i1.attendees().next(); |
94 | a2 = i2.attendees().next(); | 95 | a2 = i2.attendees().next(); |
95 | } | 96 | } |
96 | } | 97 | } |
97 | //if ( i1.dtStart() != i2.dtStart() ) | 98 | //if ( i1.dtStart() != i2.dtStart() ) |
98 | // return false; | 99 | // return false; |
99 | #if 0 | 100 | #if 0 |
100 | qDebug("1 %d ",i1.doesFloat() == i2.doesFloat() ); | 101 | qDebug("1 %d ",i1.doesFloat() == i2.doesFloat() ); |
101 | qDebug("1 %d ",i1.duration() == i2.duration() ); | 102 | qDebug("1 %d ",i1.duration() == i2.duration() ); |
102 | qDebug("3 %d ",i1.hasDuration() == i2.hasDuration() ); | 103 | qDebug("3 %d ",i1.hasDuration() == i2.hasDuration() ); |
103 | qDebug("1 %d ",i1.pilotId() == i2.pilotId() ); | 104 | qDebug("1 %d ",i1.pilotId() == i2.pilotId() ); |
104 | qDebug("1 %d %d %d",i1.syncStatus() == i2.syncStatus() , i1.syncStatus(),i2.syncStatus() ); | 105 | qDebug("1 %d %d %d",i1.syncStatus() == i2.syncStatus() , i1.syncStatus(),i2.syncStatus() ); |
105 | qDebug("6 %d ",i1.organizer() == i2.organizer() ); | 106 | qDebug("6 %d ",i1.organizer() == i2.organizer() ); |
106 | 107 | ||
107 | #endif | 108 | #endif |
108 | return ( i1.organizer() == i2.organizer() && | 109 | return ( i1.organizer() == i2.organizer() && |
109 | // i1.uid() == i2.uid() && | 110 | // i1.uid() == i2.uid() && |
110 | // Don't compare lastModified, otherwise the operator is not | 111 | // Don't compare lastModified, otherwise the operator is not |
111 | // of much use. We are not comparing for identity, after all. | 112 | // of much use. We are not comparing for identity, after all. |
112 | i1.doesFloat() == i2.doesFloat() && | 113 | i1.doesFloat() == i2.doesFloat() && |
113 | i1.duration() == i2.duration() && | 114 | i1.duration() == i2.duration() && |
114 | i1.hasDuration() == i2.hasDuration() && | 115 | i1.hasDuration() == i2.hasDuration() && |
115 | i1.pilotId() == i2.pilotId() );// && i1.syncStatus() == i2.syncStatus() ); | 116 | i1.pilotId() == i2.pilotId() );// && i1.syncStatus() == i2.syncStatus() ); |
116 | // no need to compare mObserver | 117 | // no need to compare mObserver |
117 | } | 118 | } |
118 | 119 | ||
119 | 120 | ||
120 | QDateTime IncidenceBase::getEvenTime( QDateTime dt ) | 121 | QDateTime IncidenceBase::getEvenTime( QDateTime dt ) |
121 | { | 122 | { |
122 | QTime t = dt.time(); | 123 | QTime t = dt.time(); |
123 | dt.setTime( QTime (t.hour (), t.minute (), t.second () ) ); | 124 | dt.setTime( QTime (t.hour (), t.minute (), t.second () ) ); |
124 | return dt; | 125 | return dt; |
125 | } | 126 | } |
126 | 127 | ||
127 | 128 | ||
128 | void IncidenceBase::setUid(const QString &uid) | 129 | void IncidenceBase::setUid(const QString &uid) |
129 | { | 130 | { |
130 | mUid = uid; | 131 | mUid = uid; |
131 | updated(); | 132 | updated(); |
132 | } | 133 | } |
133 | 134 | ||
134 | QString IncidenceBase::uid() const | 135 | QString IncidenceBase::uid() const |
135 | { | 136 | { |
136 | return mUid; | 137 | return mUid; |
137 | } | 138 | } |
138 | 139 | ||
139 | void IncidenceBase::setLastModified(const QDateTime &lm) | 140 | void IncidenceBase::setLastModified(const QDateTime &lm) |
140 | { | 141 | { |
141 | // DON'T! updated() because we call this from | 142 | // DON'T! updated() because we call this from |
142 | // Calendar::updateEvent(). | 143 | // Calendar::updateEvent(). |
143 | mLastModified = getEvenTime(lm); | 144 | mLastModified = getEvenTime(lm); |
144 | //qDebug("IncidenceBase::setLastModified %s ",lm.toString().latin1()); | 145 | //qDebug("IncidenceBase::setLastModified %s ",lm.toString().latin1()); |
145 | } | 146 | } |
146 | 147 | ||
147 | QDateTime IncidenceBase::lastModified() const | 148 | QDateTime IncidenceBase::lastModified() const |
148 | { | 149 | { |
149 | return mLastModified; | 150 | return mLastModified; |
150 | } | 151 | } |
151 | 152 | ||
152 | void IncidenceBase::setOrganizer(const QString &o) | 153 | void IncidenceBase::setOrganizer(const QString &o) |
153 | { | 154 | { |
154 | // we don't check for readonly here, because it is | 155 | // we don't check for readonly here, because it is |
155 | // possible that by setting the organizer we are changing | 156 | // possible that by setting the organizer we are changing |
156 | // the event's readonly status... | 157 | // the event's readonly status... |
157 | mOrganizer = o; | 158 | mOrganizer = o; |
158 | if (mOrganizer.left(7).upper() == "MAILTO:") | 159 | if (mOrganizer.left(7).upper() == "MAILTO:") |
159 | mOrganizer = mOrganizer.remove(0,7); | 160 | mOrganizer = mOrganizer.remove(0,7); |
160 | 161 | ||
161 | updated(); | 162 | updated(); |
162 | } | 163 | } |
163 | 164 | ||
164 | QString IncidenceBase::organizer() const | 165 | QString IncidenceBase::organizer() const |
165 | { | 166 | { |
166 | return mOrganizer; | 167 | return mOrganizer; |
167 | } | 168 | } |
168 | 169 | ||
169 | void IncidenceBase::setReadOnly( bool readOnly ) | 170 | void IncidenceBase::setReadOnly( bool readOnly ) |
170 | { | 171 | { |
171 | mReadOnly = readOnly; | 172 | mReadOnly = readOnly; |