summaryrefslogtreecommitdiffabout
path: root/libkcal/incidencebase.cpp
authorzautrix <zautrix>2004-08-02 00:52:35 (UTC)
committer zautrix <zautrix>2004-08-02 00:52:35 (UTC)
commit54157cb44316de72d776cfae70bdadf6c52f4773 (patch) (side-by-side diff)
tree953c8ae225a54fc43a7298d49b08e821bf741cb9 /libkcal/incidencebase.cpp
parent3ebd85e83e6f9d4ac59ce1828548f7236e2b1af0 (diff)
downloadkdepimpi-54157cb44316de72d776cfae70bdadf6c52f4773.zip
kdepimpi-54157cb44316de72d776cfae70bdadf6c52f4773.tar.gz
kdepimpi-54157cb44316de72d776cfae70bdadf6c52f4773.tar.bz2
Hack, hack, hack
Diffstat (limited to 'libkcal/incidencebase.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/incidencebase.cpp12
1 files changed, 0 insertions, 12 deletions
diff --git a/libkcal/incidencebase.cpp b/libkcal/incidencebase.cpp
index f1db8b7..5d8785b 100644
--- a/libkcal/incidencebase.cpp
+++ b/libkcal/incidencebase.cpp
@@ -1,161 +1,159 @@
/*
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 "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;
- 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;
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;
- 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();
a2 = i2.attendees().next();
}
}
//if ( i1.dtStart() != i2.dtStart() )
// return false;
#if 0
qDebug("1 %d ",i1.doesFloat() == i2.doesFloat() );
qDebug("1 %d ",i1.duration() == i2.duration() );
qDebug("3 %d ",i1.hasDuration() == i2.hasDuration() );
qDebug("1 %d ",i1.pilotId() == i2.pilotId() );
qDebug("1 %d %d %d",i1.syncStatus() == i2.syncStatus() , i1.syncStatus(),i2.syncStatus() );
qDebug("6 %d ",i1.organizer() == i2.organizer() );
#endif
return ( i1.organizer() == i2.organizer() &&
// i1.uid() == i2.uid() &&
// Don't compare lastModified, otherwise the operator is not
// of much use. We are not comparing for identity, after all.
i1.doesFloat() == i2.doesFloat() &&
i1.duration() == i2.duration() &&
i1.hasDuration() == i2.hasDuration() &&
i1.pilotId() == i2.pilotId() );// && i1.syncStatus() == i2.syncStatus() );
// no need to compare mObserver
}
QDateTime IncidenceBase::getEvenTime( QDateTime dt )
{
QTime t = dt.time();
dt.setTime( QTime (t.hour (), t.minute (), t.second () ) );
return dt;
}
void IncidenceBase::setUid(const QString &uid)
{
mUid = uid;
updated();
}
QString IncidenceBase::uid() const
{
return mUid;
}
void IncidenceBase::setLastModified(const QDateTime &lm)
{
// DON'T! updated() because we call this from
// Calendar::updateEvent().
mLastModified = getEvenTime(lm);
//qDebug("IncidenceBase::setLastModified %s ",lm.toString().latin1());
}
QDateTime IncidenceBase::lastModified() const
{
return mLastModified;
}
void IncidenceBase::setOrganizer(const QString &o)
{
// we don't check for readonly here, because it is
// possible that by setting the organizer we are changing
// the event's readonly status...
mOrganizer = o;
if (mOrganizer.left(7).upper() == "MAILTO:")
@@ -249,202 +247,192 @@ void IncidenceBase::removeAttendee(const char *n)
void IncidenceBase::clearAttendees()
{
if (mReadOnly) return;
mAttendees.clear();
}
#if 0
Attendee *IncidenceBase::getAttendee(const char *n) const
{
QPtrListIterator<Attendee> qli(mAttendees);
qli.toFirst();
while (qli) {
if (qli.current()->getName() == n)
return qli.current();
++qli;
}
return 0L;
}
#endif
Attendee *IncidenceBase::attendeeByMail(const QString &email)
{
QPtrListIterator<Attendee> qli(mAttendees);
qli.toFirst();
while (qli) {
if (qli.current()->email() == email)
return qli.current();
++qli;
}
return 0L;
}
Attendee *IncidenceBase::attendeeByMails(const QStringList &emails, const QString& email)
{
QPtrListIterator<Attendee> qli(mAttendees);
QStringList mails = emails;
if (!email.isEmpty()) {
mails.append(email);
}
qli.toFirst();
while (qli) {
for ( QStringList::Iterator it = mails.begin(); it != mails.end(); ++it ) {
if (qli.current()->email() == *it)
return qli.current();
}
++qli;
}
return 0L;
}
void IncidenceBase::setDuration(int seconds)
{
mDuration = seconds;
setHasDuration(true);
}
int IncidenceBase::duration() const
{
return mDuration;
}
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;
}
-void IncidenceBase::setZaurusId( int id )
-{
- if (mReadOnly) return;
- mZaurusId = id;
-}
-
-int IncidenceBase::zaurusId() const
-{
- return mZaurusId;
-}
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 )
{
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;
}
// 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::setIDStr( const QString & s )
{
if (mReadOnly) return;
mExternalId = s;
}