summaryrefslogtreecommitdiffabout
path: root/libkcal/incidencebase.cpp
Side-by-side diff
Diffstat (limited to 'libkcal/incidencebase.cpp') (more/less context) (show whitespace changes)
-rw-r--r--libkcal/incidencebase.cpp81
1 files changed, 79 insertions, 2 deletions
diff --git a/libkcal/incidencebase.cpp b/libkcal/incidencebase.cpp
index 707d666..d7c4595 100644
--- a/libkcal/incidencebase.cpp
+++ b/libkcal/incidencebase.cpp
@@ -31,24 +31,25 @@ using namespace KCal;
IncidenceBase::IncidenceBase() :
mReadOnly(false), mFloats(true), mDuration(0), mHasDuration(false),
mPilotId(0), mSyncStatus(SYNCMOD)
{
setUid(CalFormat::createUniqueId());
mOrganizer = "";
mFloats = false;
mDuration = 0;
mHasDuration = false;
mPilotId = 0;
mZaurusId = -1;
mZaurusUid = 0;
+ mExternalId = ":";
mTempSyncStat = 0;
mSyncStatus = 0;
mAttendees.setAutoDelete( true );
}
IncidenceBase::IncidenceBase(const IncidenceBase &i) :
CustomProperties( i )
{
mReadOnly = i.mReadOnly;
mDtStart = i.mDtStart;
mDuration = i.mDuration;
mHasDuration = i.mHasDuration;
@@ -56,40 +57,40 @@ IncidenceBase::IncidenceBase(const IncidenceBase &i) :
mUid = i.mUid;
QPtrList<Attendee> attendees = i.attendees();
for( Attendee *a = attendees.first(); a; a = attendees.next() ) {
mAttendees.append( new Attendee( *a ) );
}
mFloats = i.mFloats;
mLastModified = i.mLastModified;
mPilotId = i.mPilotId;
mZaurusId = i.mZaurusId;
mZaurusUid = i.mZaurusUid;
mTempSyncStat = i.mTempSyncStat;
mSyncStatus = i.mSyncStatus;
-
+ mExternalId = i.mExternalId;
// The copied object is a new one, so it isn't observed by the observer
// of the original object.
mObservers.clear();
mAttendees.setAutoDelete( true );
}
IncidenceBase::~IncidenceBase()
{
}
bool KCal::operator==( const IncidenceBase& i1, const IncidenceBase& i2 )
{
-
+ // do not compare mSyncStatus and mExternalId
if( i1.attendees().count() != i2.attendees().count() ) {
return false; // no need to check further
}
if ( i1.attendees().count() > 0 ) {
Attendee * a1 = i1.attendees().first(), *a2 =i2.attendees().first() ;
while ( a1 ) {
if ( !( (*a1) == (*a2)) )
{
//qDebug("Attendee not equal ");
return false;
}
a1 = i1.attendees().next();
@@ -363,24 +364,100 @@ void IncidenceBase::setZaurusUid( int id )
}
int IncidenceBase::tempSyncStat() const
{
return mTempSyncStat;
}
void IncidenceBase::setTempSyncStat( int id )
{
if (mReadOnly) return;
mTempSyncStat = id;
}
+void IncidenceBase::setID( const QString & prof , int id )
+{
+ int num = mExternalId.find( ":"+prof+";" );
+ if ( num >= 0 ) {
+ int len = prof.length()+2;
+ int end = mExternalId.find( ";", num+len );
+ if ( end > 0 ) {
+ mExternalId = mExternalId.left( num+len ) +QString::number( id)+mExternalId.mid( end );
+ } else
+ qDebug("Error in IncidenceBase::setID ");
+ } else {
+ mExternalId += prof+";"+QString::number( id) +";0:";
+ }
+}
+int IncidenceBase::getID( const QString & prof)
+{
+ int ret = -1;
+ int num = mExternalId.find(":"+ prof+";" );
+ if ( num >= 0 ) {
+ int len = prof.length()+2;
+ int end = mExternalId.find( ";", num+len );
+ if ( end > 0 ) {
+ bool ok;
+ ret = mExternalId.mid ( num + len,end-len-num).toInt( &ok );
+ if (!ok)
+ return -1;
+ }
+ }
+ return ret;
+}
+
+// example :Sharp_DTM;22;23566:TP;-1;8654:TPP;18;0:
+// format name;III;JJJ: III >= 0, may be -1. JJJ always >= 0
+void IncidenceBase::setCsum( const QString & prof , int id )
+{
+ int num = mExternalId.find( ":"+prof+";");
+ if ( num >= 0 ) {
+ int len = prof.length()+2;
+ num = mExternalId.find( ";", num+len );
+ int end = mExternalId.find( ":", num+1 );
+ if ( end > 0 ) {
+ mExternalId = mExternalId.left( num ) +QString::number(id)+mExternalId.mid( end );
+ } else
+ qDebug("Error in IncidenceBase::setCsum ");
+ } else {
+ mExternalId += prof+";-1;"+QString::number( id) +":";
+ }
+}
+int IncidenceBase::getCsum( const QString & prof)
+{
+ int ret = -1;
+ int num = mExternalId.find( ":"+prof+";" );
+ if ( num >= 0 ) {
+ int len = prof.length()+2;
+ num = mExternalId.find( ";", num+len );
+ int end = mExternalId.find( ":", num+1 );
+ if ( end > 0 ) {
+ bool ok;
+ ret = mExternalId.mid ( num ,end-num).toInt( &ok );
+ if (!ok)
+ return -1;
+ }
+ }
+ return ret;
+}
+
+void IncidenceBase::setIDStr( const QString & s )
+{
+ if (mReadOnly) return;
+ mExternalId = s;
+}
+
+QString IncidenceBase::IDStr() const
+{
+ return mExternalId ;
+}
void IncidenceBase::registerObserver( IncidenceBase::Observer *observer )
{
if( !mObservers.contains(observer) ) mObservers.append( observer );
}
void IncidenceBase::unRegisterObserver( IncidenceBase::Observer *observer )
{
mObservers.remove( observer );
}
void IncidenceBase::updated()
{