summaryrefslogtreecommitdiffabout
path: root/libkcal/calendar.cpp
Side-by-side diff
Diffstat (limited to 'libkcal/calendar.cpp') (more/less context) (show whitespace changes)
-rw-r--r--libkcal/calendar.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/libkcal/calendar.cpp b/libkcal/calendar.cpp
index 52daaaa..88351eb 100644
--- a/libkcal/calendar.cpp
+++ b/libkcal/calendar.cpp
@@ -7,160 +7,169 @@
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 <stdlib.h>
#include <time.h>
#include <kdebug.h>
#include <kglobal.h>
#include <klocale.h>
#include "exceptions.h"
#include "calfilter.h"
#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;
+}
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;
}