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.1//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 { 0 , QString() }
00043 };
00044
00045
00046 CalFormat::CalFormat()
00047 {
00048 mException = 0;
00049 }
00050
00051 CalFormat::~CalFormat()
00052 {
00053 delete mException;
00054 }
00055
00056 void CalFormat::clearException()
00057 {
00058 delete mException;
00059 mException = 0;
00060 }
00061
00062 void CalFormat::setException(ErrorFormat *exception)
00063 {
00064 delete mException;
00065 mException = exception;
00066 }
00067
00068 ErrorFormat *CalFormat::exception()
00069 {
00070 return mException;
00071 }
00072
00073 void CalFormat::setApplication(const QString& application, const QString& productID)
00074 {
00075 mApplication = application;
00076 mProductId = productID;
00077 }
00078
00079 QString CalFormat::createUniqueId()
00080 {
00081 int hashTime = QTime::currentTime().hour() +
00082 QTime::currentTime().minute() + QTime::currentTime().second() +
00083 QTime::currentTime().msec();
00084 QString uidStr = QString("%1-%2.%3")
00085 .arg(mApplication)
00086 .arg(KApplication::random())
00087 .arg(hashTime);
00088 return uidStr;
00089 }
00090
00091 int CalFormat::calendarVersion(const char* prodId)
00092 {
00093 for (const CalVersion* cv = prodIds; cv->version; ++cv) {
00094 if (!strcmp(prodId, cv->prodId.local8Bit()))
00095 return cv->version;
00096 }
00097 return 0;
00098 }
This file is part of the documentation for kdelibs Version 3.1.4.