summaryrefslogtreecommitdiffabout
path: root/libkcal
authorzautrix <zautrix>2005-02-07 20:05:18 (UTC)
committer zautrix <zautrix>2005-02-07 20:05:18 (UTC)
commitda5e47069d88fa9aa656423ce4c60bf505728e1c (patch) (side-by-side diff)
treefdbaf29835a028f1204a19fc10dea97d469c0b29 /libkcal
parent456b0246521847635fe98471691ceecae211e0c3 (diff)
downloadkdepimpi-da5e47069d88fa9aa656423ce4c60bf505728e1c.zip
kdepimpi-da5e47069d88fa9aa656423ce4c60bf505728e1c.tar.gz
kdepimpi-da5e47069d88fa9aa656423ce4c60bf505728e1c.tar.bz2
fixes
Diffstat (limited to 'libkcal') (more/less context) (show whitespace changes)
-rw-r--r--libkcal/calendar.cpp1
-rw-r--r--libkcal/event.cpp6
-rw-r--r--libkcal/todo.cpp4
3 files changed, 5 insertions, 6 deletions
diff --git a/libkcal/calendar.cpp b/libkcal/calendar.cpp
index 88351eb..dcfee5d 100644
--- a/libkcal/calendar.cpp
+++ b/libkcal/calendar.cpp
@@ -31,192 +31,193 @@
#include "calendar.h"
#include "syncdefines.h"
using namespace KCal;
Calendar::Calendar()
{
init();
setTimeZoneId( i18n (" 00:00 Europe/London(UTC)") );
}
Calendar::Calendar( const QString &timeZoneId )
{
init();
setTimeZoneId(timeZoneId);
}
void Calendar::init()
{
mObserver = 0;
mNewObserver = false;
mUndoIncidence = 0;
mModified = false;
// Setup default filter, which does nothing
mDefaultFilter = new CalFilter;
mFilter = mDefaultFilter;
mFilter->setEnabled(false);
// initialize random numbers. This is a hack, and not
// even that good of one at that.
// srandom(time(0));
// user information...
setOwner(i18n("Unknown Name"));
setEmail(i18n("unknown@nowhere"));
#if 0
tmpStr = KOPrefs::instance()->mTimeZone;
// kdDebug(5800) << "Calendar::Calendar(): TimeZone: " << tmpStr << endl;
int dstSetting = KOPrefs::instance()->mDaylightSavings;
extern long int timezone;
struct tm *now;
time_t curtime;
curtime = time(0);
now = localtime(&curtime);
int hourOff = - ((timezone / 60) / 60);
if (now->tm_isdst)
hourOff += 1;
QString tzStr;
tzStr.sprintf("%.2d%.2d",
hourOff,
abs((timezone / 60) % 60));
// if no time zone was in the config file, write what we just discovered.
if (tmpStr.isEmpty()) {
// KOPrefs::instance()->mTimeZone = tzStr;
} else {
tzStr = tmpStr;
}
// if daylight savings has changed since last load time, we need
// to rewrite these settings to the config file.
if ((now->tm_isdst && !dstSetting) ||
(!now->tm_isdst && dstSetting)) {
KOPrefs::instance()->mTimeZone = tzStr;
KOPrefs::instance()->mDaylightSavings = now->tm_isdst;
}
setTimeZone(tzStr);
#endif
// KOPrefs::instance()->writeConfig();
}
Calendar::~Calendar()
{
delete mDefaultFilter;
if ( mUndoIncidence )
delete mUndoIncidence;
}
const QString &Calendar::getOwner() const
{
return mOwner;
}
bool Calendar::undoDeleteIncidence()
{
if (!mUndoIncidence)
return false;
addIncidence(mUndoIncidence);
mUndoIncidence = 0;
+ return true;
}
void Calendar::setOwner(const QString &os)
{
int i;
mOwner = os;
i = mOwner.find(',');
if (i != -1)
mOwner = mOwner.left(i);
setModified( true );
}
void Calendar::setTimeZone(const QString & tz)
{
bool neg = FALSE;
int hours, minutes;
QString tmpStr(tz);
if (tmpStr.left(1) == "-")
neg = TRUE;
if (tmpStr.left(1) == "-" || tmpStr.left(1) == "+")
tmpStr.remove(0, 1);
hours = tmpStr.left(2).toInt();
if (tmpStr.length() > 2)
minutes = tmpStr.right(2).toInt();
else
minutes = 0;
mTimeZone = (60*hours+minutes);
if (neg)
mTimeZone = -mTimeZone;
mLocalTime = false;
setModified( true );
}
QString Calendar::getTimeZoneStr() const
{
if (mLocalTime)
return "";
QString tmpStr;
int hours = abs(mTimeZone / 60);
int minutes = abs(mTimeZone % 60);
bool neg = mTimeZone < 0;
tmpStr.sprintf("%c%.2d%.2d",
(neg ? '-' : '+'),
hours, minutes);
return tmpStr;
}
void Calendar::setTimeZone(int tz)
{
mTimeZone = tz;
mLocalTime = false;
setModified( true );
}
int Calendar::getTimeZone() const
{
return mTimeZone;
}
void Calendar::setTimeZoneId(const QString &id)
{
mTimeZoneId = id;
mLocalTime = false;
mTimeZone = KGlobal::locale()->timezoneOffset(mTimeZoneId);
if ( mTimeZone > 1000)
setLocalTime();
//qDebug("Calendar::setTimeZoneOffset %s %d ",mTimeZoneId.latin1(), mTimeZone);
setModified( true );
}
QString Calendar::timeZoneId() const
{
return mTimeZoneId;
}
void Calendar::setLocalTime()
{
//qDebug("Calendar::setLocalTime() ");
mLocalTime = true;
mTimeZone = 0;
mTimeZoneId = "";
setModified( true );
}
bool Calendar::isLocalTime() const
{
return mLocalTime;
}
const QString &Calendar::getEmail()
{
diff --git a/libkcal/event.cpp b/libkcal/event.cpp
index 7256f05..de8dceb 100644
--- a/libkcal/event.cpp
+++ b/libkcal/event.cpp
@@ -1,223 +1,221 @@
/*
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 "event.h"
using namespace KCal;
Event::Event() :
mHasEndDate( false ), mTransparency( Opaque )
{
}
Event::Event(const Event &e) : Incidence(e)
{
mDtEnd = e.mDtEnd;
mHasEndDate = e.mHasEndDate;
mTransparency = e.mTransparency;
}
Event::~Event()
{
}
Incidence *Event::clone()
{
return new Event(*this);
}
bool KCal::operator==( const Event& e1, const Event& e2 )
{
return operator==( (const Incidence&)e1, (const Incidence&)e2 ) &&
e1.dtEnd() == e2.dtEnd() &&
e1.hasEndDate() == e2.hasEndDate() &&
e1.transparency() == e2.transparency();
}
bool Event::contains ( Event* from )
{
if ( !from->summary().isEmpty() )
if ( !summary().startsWith( from->summary() ))
return false;
if ( from->dtStart().isValid() )
if (dtStart() != from->dtStart() )
return false;
if ( from->dtEnd().isValid() )
if ( dtEnd() != from->dtEnd() )
return false;
if ( !from->location().isEmpty() )
if ( !location().startsWith( from->location() ) )
return false;
if ( !from->description().isEmpty() )
if ( !description().startsWith( from->description() ))
return false;
if ( from->alarms().count() ) {
Alarm *a = from->alarms().first();
if ( a->enabled() ){
if ( !alarms().count() )
return false;
Alarm *b = alarms().first();
if( ! b->enabled() )
return false;
if ( ! (a->offset() == b->offset() ))
return false;
}
}
QStringList cat = categories();
QStringList catFrom = from->categories();
QString nCat;
- int iii;
+ unsigned int iii;
for ( iii = 0; iii < catFrom.count();++iii ) {
nCat = catFrom[iii];
if ( !nCat.isEmpty() )
if ( !cat.contains( nCat )) {
return false;
}
}
if ( from->doesRecur() )
if ( from->doesRecur() != doesRecur() && ! (from->doesRecur()== Recurrence::rYearlyMonth && doesRecur()== Recurrence::rYearlyDay) )
return false;
return true;
}
void Event::setDtEnd(const QDateTime &dtEnd)
{
if (mReadOnly) return;
mDtEnd = getEvenTime( dtEnd );
setHasEndDate(true);
setHasDuration(false);
updated();
}
QDateTime Event::dtEnd() const
{
if (hasEndDate()) return mDtEnd;
if (hasDuration()) return dtStart().addSecs(duration());
- kdDebug(5800) << "Warning! Event '" << summary()
- << "' does have neither end date nor duration." << endl;
return dtStart();
}
QString Event::dtEndTimeStr() const
{
return KGlobal::locale()->formatTime(mDtEnd.time());
}
QString Event::dtEndDateStr(bool shortfmt) const
{
return KGlobal::locale()->formatDate(mDtEnd.date(),shortfmt);
}
QString Event::dtEndStr(bool shortfmt) const
{
return KGlobal::locale()->formatDateTime(mDtEnd, shortfmt);
}
void Event::setHasEndDate(bool b)
{
mHasEndDate = b;
}
bool Event::hasEndDate() const
{
return mHasEndDate;
}
bool Event::isMultiDay() const
{
bool multi = !(dtStart().date() == dtEnd().date());
return multi;
}
void Event::setTransparency(Event::Transparency transparency)
{
if (mReadOnly) return;
mTransparency = transparency;
updated();
}
Event::Transparency Event::transparency() const
{
return mTransparency;
}
void Event::setDuration(int seconds)
{
setHasEndDate(false);
Incidence::setDuration(seconds);
}
QDateTime Event::getNextAlarmDateTime( bool * ok, int * offset ) const
{
bool yes;
QDateTime incidenceStart = getNextOccurence( QDateTime::currentDateTime(), &yes );
if ( ! yes || cancelled() ) {
*ok = false;
return QDateTime ();
}
bool enabled = false;
Alarm* alarm;
- int off;
+ int off = 0;
QDateTime alarmStart = QDateTime::currentDateTime().addDays( 3650 );;
// if ( QDateTime::currentDateTime() > incidenceStart ){
// *ok = false;
// return incidenceStart;
// }
for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) {
if (alarm->enabled()) {
if ( alarm->hasTime () ) {
if ( alarm->time() < alarmStart ) {
alarmStart = alarm->time();
enabled = true;
off = alarmStart.secsTo( incidenceStart );
}
} else {
int secs = alarm->startOffset().asSeconds();
if ( incidenceStart.addSecs( secs ) < alarmStart ) {
alarmStart = incidenceStart.addSecs( secs );
enabled = true;
off = -secs;
}
}
}
}
if ( enabled ) {
if ( alarmStart > QDateTime::currentDateTime() ) {
*ok = true;
* offset = off;
return alarmStart;
}
}
*ok = false;
return QDateTime ();
}
diff --git a/libkcal/todo.cpp b/libkcal/todo.cpp
index d81a68f..9c04a7e 100644
--- a/libkcal/todo.cpp
+++ b/libkcal/todo.cpp
@@ -3,193 +3,193 @@
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 "todo.h"
using namespace KCal;
Todo::Todo(): Incidence()
{
// mStatus = TENTATIVE;
mHasDueDate = false;
setHasStartDate( false );
mCompleted = getEvenTime(QDateTime::currentDateTime());
mHasCompletedDate = false;
mPercentComplete = 0;
}
Todo::Todo(const Todo &t) : Incidence(t)
{
mDtDue = t.mDtDue;
mHasDueDate = t.mHasDueDate;
mCompleted = t.mCompleted;
mHasCompletedDate = t.mHasCompletedDate;
mPercentComplete = t.mPercentComplete;
}
Todo::~Todo()
{
}
Incidence *Todo::clone()
{
return new Todo(*this);
}
bool Todo::contains ( Todo* from )
{
if ( !from->summary().isEmpty() )
if ( !summary().startsWith( from->summary() ))
return false;
if ( from->hasStartDate() ) {
if ( !hasStartDate() )
return false;
if ( from->dtStart() != dtStart())
return false;
}
if ( from->hasDueDate() ){
if ( !hasDueDate() )
return false;
if ( from->dtDue() != dtDue())
return false;
}
if ( !from->location().isEmpty() )
if ( !location().startsWith( from->location() ) )
return false;
if ( !from->description().isEmpty() )
if ( !description().startsWith( from->description() ))
return false;
if ( from->alarms().count() ) {
Alarm *a = from->alarms().first();
if ( a->enabled() ){
if ( !alarms().count() )
return false;
Alarm *b = alarms().first();
if( ! b->enabled() )
return false;
if ( ! (a->offset() == b->offset() ))
return false;
}
}
QStringList cat = categories();
QStringList catFrom = from->categories();
QString nCat;
- int iii;
+ unsigned int iii;
for ( iii = 0; iii < catFrom.count();++iii ) {
nCat = catFrom[iii];
if ( !nCat.isEmpty() )
if ( !cat.contains( nCat )) {
return false;
}
}
if ( from->isCompleted() ) {
if ( !isCompleted() )
return false;
}
if( priority() != from->priority() )
return false;
return true;
}
bool KCal::operator==( const Todo& t1, const Todo& t2 )
{
bool ret = operator==( (const Incidence&)t1, (const Incidence&)t2 );
if ( ! ret )
return false;
if ( t1.hasDueDate() == t2.hasDueDate() ) {
if ( t1.hasDueDate() ) {
if ( t1.doesFloat() == t2.doesFloat() ) {
if ( t1.doesFloat() ) {
if ( t1.dtDue().date() != t2.dtDue().date() )
return false;
} else
if ( t1.dtDue() != t2.dtDue() )
return false;
} else
return false;// float !=
}
} else
return false;
if ( t1.percentComplete() != t2.percentComplete() )
return false;
if ( t1.isCompleted() ) {
if ( t1.hasCompletedDate() == t2.hasCompletedDate() ) {
if ( t1.hasCompletedDate() ) {
if ( t1.completed() != t2.completed() )
return false;
}
} else
return false;
}
return true;
}
void Todo::setDtDue(const QDateTime &dtDue)
{
//int diffsecs = mDtDue.secsTo(dtDue);
/*if (mReadOnly) return;
const QPtrList<Alarm>& alarms = alarms();
for (Alarm* alarm = alarms.first(); alarm; alarm = alarms.next()) {
if (alarm->enabled()) {
alarm->setTime(alarm->time().addSecs(diffsecs));
}
}*/
mDtDue = getEvenTime(dtDue);
//kdDebug(5800) << "setDtDue says date is " << mDtDue.toString() << endl;
/*const QPtrList<Alarm>& alarms = alarms();
for (Alarm* alarm = alarms.first(); alarm; alarm = alarms.next())
alarm->setAlarmStart(mDtDue);*/
updated();
}
QDateTime Todo::dtDue() const
{
return mDtDue;
}
QString Todo::dtDueTimeStr() const
{
return KGlobal::locale()->formatTime(mDtDue.time());
}
QString Todo::dtDueDateStr(bool shortfmt) const
{
return KGlobal::locale()->formatDate(mDtDue.date(),shortfmt);
}
QString Todo::dtDueStr(bool shortfmt) const
{
return KGlobal::locale()->formatDateTime(mDtDue, shortfmt);
}
@@ -282,133 +282,133 @@ QString Todo::statusStr() const
switch(mStatus) {
case NEEDS_ACTION:
return QString("NEEDS ACTION");
break;
case ACCEPTED:
return QString("ACCEPTED");
break;
case SENT:
return QString("SENT");
break;
case TENTATIVE:
return QString("TENTATIVE");
break;
case CONFIRMED:
return QString("CONFIRMED");
break;
case DECLINED:
return QString("DECLINED");
break;
case COMPLETED:
return QString("COMPLETED");
break;
case DELEGATED:
return QString("DELEGATED");
break;
}
return QString("");
}
#endif
bool Todo::isCompleted() const
{
if (mPercentComplete == 100) return true;
else return false;
}
void Todo::setCompleted(bool completed)
{
if (completed) mPercentComplete = 100;
else {
mPercentComplete = 0;
mHasCompletedDate = false;
}
updated();
}
QDateTime Todo::completed() const
{
return mCompleted;
}
QString Todo::completedStr( bool shortF ) const
{
return KGlobal::locale()->formatDateTime(mCompleted, shortF);
}
void Todo::setCompleted(const QDateTime &completed)
{
//qDebug("Todo::setCompleted ");
if ( mHasCompletedDate ) {
// qDebug("has completed data - return ");
return;
}
mHasCompletedDate = true;
mPercentComplete = 100;
mCompleted = getEvenTime(completed);
updated();
}
bool Todo::hasCompletedDate() const
{
return mHasCompletedDate;
}
int Todo::percentComplete() const
{
return mPercentComplete;
}
void Todo::setPercentComplete(int v)
{
mPercentComplete = v;
if ( v != 100 )
mHasCompletedDate = false;
updated();
}
QDateTime Todo::getNextAlarmDateTime( bool * ok, int * offset ) const
{
if ( isCompleted() || ! hasDueDate() || cancelled() ) {
*ok = false;
return QDateTime ();
}
QDateTime incidenceStart;
incidenceStart = dtDue();
bool enabled = false;
Alarm* alarm;
- int off;
+ int off = 0;
QDateTime alarmStart = QDateTime::currentDateTime().addDays( 3650 );;
// if ( QDateTime::currentDateTime() > incidenceStart ){
// *ok = false;
// return incidenceStart;
// }
for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) {
if (alarm->enabled()) {
if ( alarm->hasTime () ) {
if ( alarm->time() < alarmStart ) {
alarmStart = alarm->time();
enabled = true;
off = alarmStart.secsTo( incidenceStart );
}
} else {
int secs = alarm->startOffset().asSeconds();
if ( incidenceStart.addSecs( secs ) < alarmStart ) {
alarmStart = incidenceStart.addSecs( secs );
enabled = true;
off = -secs;
}
}
}
}
if ( enabled ) {
if ( alarmStart > QDateTime::currentDateTime() ) {
*ok = true;
* offset = off;
return alarmStart;
}
}
*ok = false;
return QDateTime ();
}