author | zautrix <zautrix> | 2004-08-07 11:30:06 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-08-07 11:30:06 (UTC) |
commit | 835cc1b2c671bf2ab228362cf4ea2e4a04a1d5e5 (patch) (side-by-side diff) | |
tree | 816191299c688a7de051703af11d0ba4f8c8247f /libkcal/incidencebase.cpp | |
parent | 55ad0e5d505055016a0e5032bcc8f9355dfff210 (diff) | |
download | kdepimpi-835cc1b2c671bf2ab228362cf4ea2e4a04a1d5e5.zip kdepimpi-835cc1b2c671bf2ab228362cf4ea2e4a04a1d5e5.tar.gz kdepimpi-835cc1b2c671bf2ab228362cf4ea2e4a04a1d5e5.tar.bz2 |
More sync stuff converted
-rw-r--r-- | libkcal/incidencebase.cpp | 96 |
1 files changed, 20 insertions, 76 deletions
diff --git a/libkcal/incidencebase.cpp b/libkcal/incidencebase.cpp index 5d8785b..15c4fa8 100644 --- a/libkcal/incidencebase.cpp +++ b/libkcal/incidencebase.cpp @@ -1,96 +1,95 @@ /* This file is part of libkcal. Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include <kglobal.h> #include <klocale.h> #include <kdebug.h> +#include <kidmanager.h> #include "calformat.h" #include "incidencebase.h" 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; - mZaurusUid = 0; + mPilotId = 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; mOrganizer = i.mOrganizer; 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; - 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(); a2 = i2.attendees().next(); } @@ -312,151 +311,96 @@ int IncidenceBase::duration() const void IncidenceBase::setHasDuration(bool b) { mHasDuration = b; } bool IncidenceBase::hasDuration() const { return mHasDuration; } void IncidenceBase::setSyncStatus(int stat) { if (mReadOnly) return; mSyncStatus = stat; } int IncidenceBase::syncStatus() const { return mSyncStatus; } void IncidenceBase::setPilotId( int id ) { if (mReadOnly) return; mPilotId = id; } int IncidenceBase::pilotId() const { return mPilotId; } -int IncidenceBase::zaurusUid() const -{ - return mZaurusUid; -} -void IncidenceBase::setZaurusUid( int id ) -{ - if (mReadOnly) return; - mZaurusUid = 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 ) +void IncidenceBase::removeID(const QString &prof) { - 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:"; - } - qDebug("setID*%s*%d*%s* ", prof.latin1(), id,mExternalId.latin1() ); -} -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) - ret = -1; - } - } - qDebug("getID*%s*%d*%s* ", prof.latin1(), ret,mExternalId.latin1() ); - return ret; + mExternalId = KIdManager::removeId ( mExternalId, prof); + +} +void IncidenceBase::setID( const QString & prof , const QString & id ) +{ + mExternalId = KIdManager::setId ( mExternalId, prof, id ); +} +QString IncidenceBase::getID( const QString & prof) +{ + return KIdManager::getId ( mExternalId, prof ); } // 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) +":"; - } - qDebug("setCsum*%s*%d*%s* ", prof.latin1(), id,mExternalId.latin1() ); -} -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) - ret = -1; - } - } - qDebug("getCsum*%s*%d*%s* ", prof.latin1(), ret,mExternalId.latin1() ); - return ret; +void IncidenceBase::setCsum( const QString & prof , const QString & id ) +{ + mExternalId = KIdManager::setCsum ( mExternalId, prof, id ); +} +QString IncidenceBase::getCsum( const QString & prof) +{ + return KIdManager::getCsum ( mExternalId, prof ); } 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() { QPtrListIterator<Observer> it(mObservers); while( it.current() ) { Observer *o = it.current(); ++it; o->incidenceUpdated( this ); } } |