summaryrefslogtreecommitdiffabout
path: root/libkcal/incidencebase.cpp
Unidiff
Diffstat (limited to 'libkcal/incidencebase.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/incidencebase.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/libkcal/incidencebase.cpp b/libkcal/incidencebase.cpp
index 96039df..dcead02 100644
--- a/libkcal/incidencebase.cpp
+++ b/libkcal/incidencebase.cpp
@@ -14,256 +14,264 @@
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#include "syncdefines.h"
28 28
29#include "incidencebase.h" 29#include "incidencebase.h"
30 30
31using namespace KCal; 31using namespace KCal;
32 32
33IncidenceBase::IncidenceBase() : 33IncidenceBase::IncidenceBase() :
34 mReadOnly(false), mFloats(true), mDuration(0), mHasDuration(false), 34 mReadOnly(false), mFloats(true), mDuration(0), mHasDuration(false),
35 mPilotId(0), mSyncStatus(SYNCMOD) 35 mPilotId(0), mSyncStatus(SYNCMOD)
36{ 36{
37 setUid(CalFormat::createUniqueId()); 37 setUid(CalFormat::createUniqueId());
38 mOrganizer = ""; 38 mOrganizer = "";
39 mFloats = false; 39 mFloats = false;
40 mDuration = 0; 40 mDuration = 0;
41 mHasDuration = false; 41 mHasDuration = false;
42 mPilotId = 0; 42 mPilotId = 0;
43 mExternalId = ":"; 43 mExternalId = ":";
44 mTempSyncStat = SYNC_TEMPSTATE_INITIAL; 44 mTempSyncStat = SYNC_TEMPSTATE_INITIAL;
45 mSyncStatus = 0; 45 mSyncStatus = 0;
46 mAttendees.setAutoDelete( true ); 46 mAttendees.setAutoDelete( true );
47 mCalEnabled = true; 47 mCalEnabled = true;
48 mAlarmEnabled = true; 48 mAlarmEnabled = true;
49 mCalID = 0; 49 mCalID = 0;
50} 50}
51 51
52IncidenceBase::IncidenceBase(const IncidenceBase &i) : 52IncidenceBase::IncidenceBase(const IncidenceBase &i) :
53 CustomProperties( i ) 53 CustomProperties( i )
54{ 54{
55 55
56 mReadOnly = i.mReadOnly; 56 mReadOnly = i.mReadOnly;
57 mDtStart = i.mDtStart; 57 mDtStart = i.mDtStart;
58 mDuration = i.mDuration; 58 mDuration = i.mDuration;
59 mHasDuration = i.mHasDuration; 59 mHasDuration = i.mHasDuration;
60 mOrganizer = i.mOrganizer; 60 mOrganizer = i.mOrganizer;
61 mUid = i.mUid; 61 mUid = i.mUid;
62 mCalEnabled = i.mCalEnabled; 62 mCalEnabled = i.mCalEnabled;
63 mAlarmEnabled = i.mAlarmEnabled; 63 mAlarmEnabled = i.mAlarmEnabled;
64 mCalID = i.mCalID; 64 mCalID = i.mCalID;
65 QPtrList<Attendee> attendees = i.attendees(); 65 QPtrList<Attendee> attendees = i.attendees();
66 for( Attendee *a = attendees.first(); a; a = attendees.next() ) { 66 for( Attendee *a = attendees.first(); a; a = attendees.next() ) {
67 mAttendees.append( new Attendee( *a ) ); 67 mAttendees.append( new Attendee( *a ) );
68 } 68 }
69 mFloats = i.mFloats; 69 mFloats = i.mFloats;
70 mLastModified = i.mLastModified; 70 mLastModified = i.mLastModified;
71 mPilotId = i.mPilotId; 71 mPilotId = i.mPilotId;
72 mTempSyncStat = i.mTempSyncStat; 72 mTempSyncStat = i.mTempSyncStat;
73 mSyncStatus = i.mSyncStatus; 73 mSyncStatus = i.mSyncStatus;
74 mExternalId = i.mExternalId; 74 mExternalId = i.mExternalId;
75 // The copied object is a new one, so it isn't observed by the observer 75 // The copied object is a new one, so it isn't observed by the observer
76 // of the original object. 76 // of the original object.
77 mObservers.clear(); 77 mObservers.clear();
78 78
79 mAttendees.setAutoDelete( true ); 79 mAttendees.setAutoDelete( true );
80} 80}
81 81
82IncidenceBase::~IncidenceBase() 82IncidenceBase::~IncidenceBase()
83{ 83{
84} 84}
85 85
86 86
87bool KCal::operator==( const IncidenceBase& i1, const IncidenceBase& i2 ) 87bool KCal::operator==( const IncidenceBase& i1, const IncidenceBase& i2 )
88{ 88{
89 // do not compare mSyncStatus and mExternalId 89 // do not compare mSyncStatus and mExternalId
90 if( i1.attendees().count() != i2.attendees().count() ) { 90 if( i1.attendees().count() != i2.attendees().count() ) {
91 return false; // no need to check further 91 return false; // no need to check further
92 } 92 }
93 if ( i1.attendees().count() > 0 ) { 93 if ( i1.attendees().count() > 0 ) {
94 Attendee * a1 = i1.attendees().first(), *a2 =i2.attendees().first() ; 94 Attendee * a1 = i1.attendees().first(), *a2 =i2.attendees().first() ;
95 while ( a1 ) { 95 while ( a1 ) {
96 if ( !( (*a1) == (*a2)) ) 96 if ( !( (*a1) == (*a2)) )
97 { 97 {
98 //qDebug("Attendee not equal "); 98 //qDebug("Attendee not equal ");
99 return false; 99 return false;
100 } 100 }
101 a1 = i1.attendees().next(); 101 a1 = i1.attendees().next();
102 a2 = i2.attendees().next(); 102 a2 = i2.attendees().next();
103 } 103 }
104 } 104 }
105 //if ( i1.dtStart() != i2.dtStart() ) 105 //if ( i1.dtStart() != i2.dtStart() )
106 // return false; 106 // return false;
107#if 0 107#if 0
108 qDebug("1 %d ",i1.doesFloat() == i2.doesFloat() ); 108 qDebug("1 %d ",i1.doesFloat() == i2.doesFloat() );
109 qDebug("1 %d ",i1.duration() == i2.duration() ); 109 qDebug("1 %d ",i1.duration() == i2.duration() );
110 qDebug("3 %d ",i1.hasDuration() == i2.hasDuration() ); 110 qDebug("3 %d ",i1.hasDuration() == i2.hasDuration() );
111 qDebug("1 %d ",i1.pilotId() == i2.pilotId() ); 111 qDebug("1 %d ",i1.pilotId() == i2.pilotId() );
112 qDebug("1 %d %d %d",i1.syncStatus() == i2.syncStatus() , i1.syncStatus(),i2.syncStatus() ); 112 qDebug("1 %d %d %d",i1.syncStatus() == i2.syncStatus() , i1.syncStatus(),i2.syncStatus() );
113 qDebug("6 %d ",i1.organizer() == i2.organizer() ); 113 qDebug("6 %d ",i1.organizer() == i2.organizer() );
114 114
115#endif 115#endif
116 if ( i1.hasDuration() == i2.hasDuration() ) { 116 if ( i1.hasDuration() == i2.hasDuration() ) {
117 if ( i1.hasDuration() ) { 117 if ( i1.hasDuration() ) {
118 if ( i1.duration() != i2.duration() ) 118 if ( i1.duration() != i2.duration() )
119 return false; 119 return false;
120 } 120 }
121 } else { 121 } else {
122 return false; 122 return false;
123 } 123 }
124 124
125 return ( i1.organizer() == i2.organizer() && 125 return ( i1.organizer() == i2.organizer() &&
126 // i1.uid() == i2.uid() && 126 // i1.uid() == i2.uid() &&
127 // Don't compare lastModified, otherwise the operator is not 127 // Don't compare lastModified, otherwise the operator is not
128 // of much use. We are not comparing for identity, after all. 128 // of much use. We are not comparing for identity, after all.
129 i1.doesFloat() == i2.doesFloat() && 129 i1.doesFloat() == i2.doesFloat() &&
130 i1.pilotId() == i2.pilotId() );// && i1.syncStatus() == i2.syncStatus() ); 130 i1.pilotId() == i2.pilotId() );// && i1.syncStatus() == i2.syncStatus() );
131 // no need to compare mObserver 131 // no need to compare mObserver
132} 132}
133 133
134 134
135QDateTime IncidenceBase::getEvenTime( QDateTime dt ) 135QDateTime IncidenceBase::getEvenTime( QDateTime dt )
136{ 136{
137 QTime t = dt.time(); 137 QTime t = dt.time();
138 dt.setTime( QTime (t.hour (), t.minute (), t.second () ) ); 138 dt.setTime( QTime (t.hour (), t.minute (), t.second () ) );
139 return dt; 139 return dt;
140} 140}
141 141
142bool IncidenceBase::isTagged() const
143{
144 return mIsTagged;
145}
146void IncidenceBase::setTagged( bool b)
147{
148 mIsTagged = b;
149}
142void IncidenceBase::setCalID( int id ) 150void IncidenceBase::setCalID( int id )
143{ 151{
144 if ( mCalID > 0 ) 152 if ( mCalID > 0 )
145 updated(); 153 updated();
146 mCalID = id; 154 mCalID = id;
147} 155}
148int IncidenceBase::calID() const 156int IncidenceBase::calID() const
149{ 157{
150 return mCalID; 158 return mCalID;
151} 159}
152void IncidenceBase::setCalEnabled( bool b ) 160void IncidenceBase::setCalEnabled( bool b )
153{ 161{
154 mCalEnabled = b; 162 mCalEnabled = b;
155} 163}
156bool IncidenceBase::calEnabled() const 164bool IncidenceBase::calEnabled() const
157{ 165{
158 return mCalEnabled; 166 return mCalEnabled;
159} 167}
160 168
161void IncidenceBase::setAlarmEnabled( bool b ) 169void IncidenceBase::setAlarmEnabled( bool b )
162{ 170{
163 mAlarmEnabled = b; 171 mAlarmEnabled = b;
164} 172}
165bool IncidenceBase::alarmEnabled() const 173bool IncidenceBase::alarmEnabled() const
166{ 174{
167 return mAlarmEnabled; 175 return mAlarmEnabled;
168} 176}
169 177
170 178
171void IncidenceBase::setUid(const QString &uid) 179void IncidenceBase::setUid(const QString &uid)
172{ 180{
173 mUid = uid; 181 mUid = uid;
174 updated(); 182 updated();
175} 183}
176 184
177QString IncidenceBase::uid() const 185QString IncidenceBase::uid() const
178{ 186{
179 return mUid; 187 return mUid;
180} 188}
181 189
182void IncidenceBase::setLastModified(const QDateTime &lm) 190void IncidenceBase::setLastModified(const QDateTime &lm)
183{ 191{
184 // DON'T! updated() because we call this from 192 // DON'T! updated() because we call this from
185 // Calendar::updateEvent(). 193 // Calendar::updateEvent().
186 mLastModified = getEvenTime(lm); 194 mLastModified = getEvenTime(lm);
187 //qDebug("IncidenceBase::setLastModified %s ",lm.toString().latin1()); 195 //qDebug("IncidenceBase::setLastModified %s ",lm.toString().latin1());
188} 196}
189 197
190QDateTime IncidenceBase::lastModified() const 198QDateTime IncidenceBase::lastModified() const
191{ 199{
192 return mLastModified; 200 return mLastModified;
193} 201}
194 202
195void IncidenceBase::setOrganizer(const QString &o) 203void IncidenceBase::setOrganizer(const QString &o)
196{ 204{
197 // we don't check for readonly here, because it is 205 // we don't check for readonly here, because it is
198 // possible that by setting the organizer we are changing 206 // possible that by setting the organizer we are changing
199 // the event's readonly status... 207 // the event's readonly status...
200 mOrganizer = o; 208 mOrganizer = o;
201 if (mOrganizer.left(7).upper() == "MAILTO:") 209 if (mOrganizer.left(7).upper() == "MAILTO:")
202 mOrganizer = mOrganizer.remove(0,7); 210 mOrganizer = mOrganizer.remove(0,7);
203 211
204 updated(); 212 updated();
205} 213}
206 214
207QString IncidenceBase::organizer() const 215QString IncidenceBase::organizer() const
208{ 216{
209 return mOrganizer; 217 return mOrganizer;
210} 218}
211 219
212void IncidenceBase::setReadOnly( bool readOnly ) 220void IncidenceBase::setReadOnly( bool readOnly )
213{ 221{
214 mReadOnly = readOnly; 222 mReadOnly = readOnly;
215} 223}
216 224
217void IncidenceBase::setDtStart(const QDateTime &dtStart) 225void IncidenceBase::setDtStart(const QDateTime &dtStart)
218{ 226{
219// if (mReadOnly) return; 227// if (mReadOnly) return;
220 mDtStart = getEvenTime(dtStart); 228 mDtStart = getEvenTime(dtStart);
221 updated(); 229 updated();
222} 230}
223 231
224 232
225QDateTime IncidenceBase::dtStart() const 233QDateTime IncidenceBase::dtStart() const
226{ 234{
227 return mDtStart; 235 return mDtStart;
228} 236}
229 237
230QString IncidenceBase::dtStartTimeStr() const 238QString IncidenceBase::dtStartTimeStr() const
231{ 239{
232 return KGlobal::locale()->formatTime(dtStart().time()); 240 return KGlobal::locale()->formatTime(dtStart().time());
233} 241}
234 242
235QString IncidenceBase::dtStartDateStr(bool shortfmt) const 243QString IncidenceBase::dtStartDateStr(bool shortfmt) const
236{ 244{
237 return KGlobal::locale()->formatDate(dtStart().date(),shortfmt); 245 return KGlobal::locale()->formatDate(dtStart().date(),shortfmt);
238} 246}
239 247
240QString IncidenceBase::dtStartStr(bool shortfmt) const 248QString IncidenceBase::dtStartStr(bool shortfmt) const
241{ 249{
242 if ( doesFloat() ) 250 if ( doesFloat() )
243 return KGlobal::locale()->formatDate(dtStart().date(),shortfmt); 251 return KGlobal::locale()->formatDate(dtStart().date(),shortfmt);
244 return KGlobal::locale()->formatDateTime(dtStart(), shortfmt); 252 return KGlobal::locale()->formatDateTime(dtStart(), shortfmt);
245} 253}
246 254
247 255
248bool IncidenceBase::doesFloat() const 256bool IncidenceBase::doesFloat() const
249{ 257{
250 return mFloats; 258 return mFloats;
251} 259}
252 260
253void IncidenceBase::setFloats(bool f) 261void IncidenceBase::setFloats(bool f)
254{ 262{
255 if (mReadOnly) return; 263 if (mReadOnly) return;
256 mFloats = f; 264 mFloats = f;
257 updated(); 265 updated();
258} 266}
259 267
260 268
261bool IncidenceBase::addAttendee(Attendee *a, bool doupdate) 269bool IncidenceBase::addAttendee(Attendee *a, bool doupdate)
262{ 270{
263 if (mReadOnly) return false; 271 if (mReadOnly) return false;
264 if (a->name().left(7).upper() == "MAILTO:") 272 if (a->name().left(7).upper() == "MAILTO:")
265 a->setName(a->name().remove(0,7)); 273 a->setName(a->name().remove(0,7));
266 274
267 QPtrListIterator<Attendee> qli(mAttendees); 275 QPtrListIterator<Attendee> qli(mAttendees);
268 276
269 qli.toFirst(); 277 qli.toFirst();