summaryrefslogtreecommitdiffabout
path: root/libkcal/incidencebase.cpp
authorzautrix <zautrix>2005-06-15 18:23:08 (UTC)
committer zautrix <zautrix>2005-06-15 18:23:08 (UTC)
commitccfe3f97afd65c75ee6c7c931cb3694919a4e29b (patch) (unidiff)
tree117d3467ef1d9678f31dea1b506390707f88d94a /libkcal/incidencebase.cpp
parentcba0ac17d3d505805be6aa4b4fea6f63473a1e00 (diff)
downloadkdepimpi-ccfe3f97afd65c75ee6c7c931cb3694919a4e29b.zip
kdepimpi-ccfe3f97afd65c75ee6c7c931cb3694919a4e29b.tar.gz
kdepimpi-ccfe3f97afd65c75ee6c7c931cb3694919a4e29b.tar.bz2
fixess
Diffstat (limited to 'libkcal/incidencebase.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/incidencebase.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/libkcal/incidencebase.cpp b/libkcal/incidencebase.cpp
index 2ddbb01..96039df 100644
--- a/libkcal/incidencebase.cpp
+++ b/libkcal/incidencebase.cpp
@@ -16,256 +16,258 @@
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
142void IncidenceBase::setCalID( int id ) 142void IncidenceBase::setCalID( int id )
143{ 143{
144 if ( mCalID > 0 )
145 updated();
144 mCalID = id; 146 mCalID = id;
145} 147}
146int IncidenceBase::calID() const 148int IncidenceBase::calID() const
147{ 149{
148 return mCalID; 150 return mCalID;
149} 151}
150void IncidenceBase::setCalEnabled( bool b ) 152void IncidenceBase::setCalEnabled( bool b )
151{ 153{
152 mCalEnabled = b; 154 mCalEnabled = b;
153} 155}
154bool IncidenceBase::calEnabled() const 156bool IncidenceBase::calEnabled() const
155{ 157{
156 return mCalEnabled; 158 return mCalEnabled;
157} 159}
158 160
159void IncidenceBase::setAlarmEnabled( bool b ) 161void IncidenceBase::setAlarmEnabled( bool b )
160{ 162{
161 mAlarmEnabled = b; 163 mAlarmEnabled = b;
162} 164}
163bool IncidenceBase::alarmEnabled() const 165bool IncidenceBase::alarmEnabled() const
164{ 166{
165 return mAlarmEnabled; 167 return mAlarmEnabled;
166} 168}
167 169
168 170
169void IncidenceBase::setUid(const QString &uid) 171void IncidenceBase::setUid(const QString &uid)
170{ 172{
171 mUid = uid; 173 mUid = uid;
172 updated(); 174 updated();
173} 175}
174 176
175QString IncidenceBase::uid() const 177QString IncidenceBase::uid() const
176{ 178{
177 return mUid; 179 return mUid;
178} 180}
179 181
180void IncidenceBase::setLastModified(const QDateTime &lm) 182void IncidenceBase::setLastModified(const QDateTime &lm)
181{ 183{
182 // DON'T! updated() because we call this from 184 // DON'T! updated() because we call this from
183 // Calendar::updateEvent(). 185 // Calendar::updateEvent().
184 mLastModified = getEvenTime(lm); 186 mLastModified = getEvenTime(lm);
185 //qDebug("IncidenceBase::setLastModified %s ",lm.toString().latin1()); 187 //qDebug("IncidenceBase::setLastModified %s ",lm.toString().latin1());
186} 188}
187 189
188QDateTime IncidenceBase::lastModified() const 190QDateTime IncidenceBase::lastModified() const
189{ 191{
190 return mLastModified; 192 return mLastModified;
191} 193}
192 194
193void IncidenceBase::setOrganizer(const QString &o) 195void IncidenceBase::setOrganizer(const QString &o)
194{ 196{
195 // we don't check for readonly here, because it is 197 // we don't check for readonly here, because it is
196 // possible that by setting the organizer we are changing 198 // possible that by setting the organizer we are changing
197 // the event's readonly status... 199 // the event's readonly status...
198 mOrganizer = o; 200 mOrganizer = o;
199 if (mOrganizer.left(7).upper() == "MAILTO:") 201 if (mOrganizer.left(7).upper() == "MAILTO:")
200 mOrganizer = mOrganizer.remove(0,7); 202 mOrganizer = mOrganizer.remove(0,7);
201 203
202 updated(); 204 updated();
203} 205}
204 206
205QString IncidenceBase::organizer() const 207QString IncidenceBase::organizer() const
206{ 208{
207 return mOrganizer; 209 return mOrganizer;
208} 210}
209 211
210void IncidenceBase::setReadOnly( bool readOnly ) 212void IncidenceBase::setReadOnly( bool readOnly )
211{ 213{
212 mReadOnly = readOnly; 214 mReadOnly = readOnly;
213} 215}
214 216
215void IncidenceBase::setDtStart(const QDateTime &dtStart) 217void IncidenceBase::setDtStart(const QDateTime &dtStart)
216{ 218{
217// if (mReadOnly) return; 219// if (mReadOnly) return;
218 mDtStart = getEvenTime(dtStart); 220 mDtStart = getEvenTime(dtStart);
219 updated(); 221 updated();
220} 222}
221 223
222 224
223QDateTime IncidenceBase::dtStart() const 225QDateTime IncidenceBase::dtStart() const
224{ 226{
225 return mDtStart; 227 return mDtStart;
226} 228}
227 229
228QString IncidenceBase::dtStartTimeStr() const 230QString IncidenceBase::dtStartTimeStr() const
229{ 231{
230 return KGlobal::locale()->formatTime(dtStart().time()); 232 return KGlobal::locale()->formatTime(dtStart().time());
231} 233}
232 234
233QString IncidenceBase::dtStartDateStr(bool shortfmt) const 235QString IncidenceBase::dtStartDateStr(bool shortfmt) const
234{ 236{
235 return KGlobal::locale()->formatDate(dtStart().date(),shortfmt); 237 return KGlobal::locale()->formatDate(dtStart().date(),shortfmt);
236} 238}
237 239
238QString IncidenceBase::dtStartStr(bool shortfmt) const 240QString IncidenceBase::dtStartStr(bool shortfmt) const
239{ 241{
240 if ( doesFloat() ) 242 if ( doesFloat() )
241 return KGlobal::locale()->formatDate(dtStart().date(),shortfmt); 243 return KGlobal::locale()->formatDate(dtStart().date(),shortfmt);
242 return KGlobal::locale()->formatDateTime(dtStart(), shortfmt); 244 return KGlobal::locale()->formatDateTime(dtStart(), shortfmt);
243} 245}
244 246
245 247
246bool IncidenceBase::doesFloat() const 248bool IncidenceBase::doesFloat() const
247{ 249{
248 return mFloats; 250 return mFloats;
249} 251}
250 252
251void IncidenceBase::setFloats(bool f) 253void IncidenceBase::setFloats(bool f)
252{ 254{
253 if (mReadOnly) return; 255 if (mReadOnly) return;
254 mFloats = f; 256 mFloats = f;
255 updated(); 257 updated();
256} 258}
257 259
258 260
259bool IncidenceBase::addAttendee(Attendee *a, bool doupdate) 261bool IncidenceBase::addAttendee(Attendee *a, bool doupdate)
260{ 262{
261 if (mReadOnly) return false; 263 if (mReadOnly) return false;
262 if (a->name().left(7).upper() == "MAILTO:") 264 if (a->name().left(7).upper() == "MAILTO:")
263 a->setName(a->name().remove(0,7)); 265 a->setName(a->name().remove(0,7));
264 266
265 QPtrListIterator<Attendee> qli(mAttendees); 267 QPtrListIterator<Attendee> qli(mAttendees);
266 268
267 qli.toFirst(); 269 qli.toFirst();
268 while (qli) { 270 while (qli) {
269 if (*qli.current() == *a) 271 if (*qli.current() == *a)
270 return false; 272 return false;
271 ++qli; 273 ++qli;