calformat.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <klocale.h>
00022 #include <kdebug.h>
00023 #include <kapplication.h>
00024
00025 #include "calformat.h"
00026
00027 using namespace KCal;
00028
00029 QString CalFormat::mApplication = QString::fromLatin1("libkcal");
00030 QString CalFormat::mProductId = QString::fromLatin1("-//K Desktop Environment//NONSGML libkcal 3.2//EN");
00031
00032
00033
00034 struct CalVersion {
00035 int version;
00036 QString prodId;
00037 };
00038 static CalVersion prodIds[] = {
00039 { 220, QString::fromLatin1("-//K Desktop Environment//NONSGML KOrganizer 2.2//EN") },
00040 { 300, QString::fromLatin1("-//K Desktop Environment//NONSGML KOrganizer 3.0//EN") },
00041 { 310, QString::fromLatin1("-//K Desktop Environment//NONSGML KOrganizer 3.1//EN") },
00042 { 320, QString::fromLatin1("-//K Desktop Environment//NONSGML KOrganizer 3.2//EN") },
00043 { 0 , QString() }
00044 };
00045
00046
00047 CalFormat::CalFormat()
00048 {
00049 mException = 0;
00050 }
00051
00052 CalFormat::~CalFormat()
00053 {
00054 delete mException;
00055 }
00056
00057 void CalFormat::clearException()
00058 {
00059 delete mException;
00060 mException = 0;
00061 }
00062
00063 void CalFormat::setException(ErrorFormat *exception)
00064 {
00065 delete mException;
00066 mException = exception;
00067 }
00068
00069 ErrorFormat *CalFormat::exception()
00070 {
00071 return mException;
00072 }
00073
00074 void CalFormat::setApplication(const QString& application, const QString& productID)
00075 {
00076 mApplication = application;
00077 mProductId = productID;
00078 }
00079
00080 QString CalFormat::createUniqueId()
00081 {
00082 int hashTime = QTime::currentTime().hour() +
00083 QTime::currentTime().minute() + QTime::currentTime().second() +
00084 QTime::currentTime().msec();
00085 QString uidStr = QString("%1-%2.%3")
00086 .arg(mApplication)
00087 .arg(KApplication::random())
00088 .arg(hashTime);
00089 return uidStr;
00090 }
00091
00092 int CalFormat::calendarVersion(const char* prodId)
00093 {
00094 for (const CalVersion* cv = prodIds; cv->version; ++cv) {
00095 if (!strcmp(prodId, cv->prodId.utf8()))
00096 return cv->version;
00097 }
00098 return 0;
00099 }
This file is part of the documentation for libkcal Library Version 3.2.2.