KCal Library
calformat.cpp
Go to the documentation of this file.00001 /* 00002 This file is part of the kcal library. 00003 00004 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 00005 00006 This library is free software; you can redistribute it and/or 00007 modify it under the terms of the GNU Library General Public 00008 License as published by the Free Software Foundation; either 00009 version 2 of the License, or (at your option) any later version. 00010 00011 This library is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 Library General Public License for more details. 00015 00016 You should have received a copy of the GNU Library General Public License 00017 along with this library; see the file COPYING.LIB. If not, write to 00018 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00019 Boston, MA 02110-1301, USA. 00020 */ 00032 #include "calformat.h" 00033 00034 #include <klocale.h> 00035 #include <kdebug.h> 00036 #include <krandom.h> 00037 00038 using namespace KCal; 00039 00044 //@cond PRIVATE 00045 class KCal::CalFormat::Private 00046 { 00047 public: 00048 Private() : mException( 0 ) {} 00049 ~Private() { delete mException; } 00050 static QString mApplication; // Name of application, for creating unique ID strings 00051 static QString mProductId; // PRODID string to write to calendar files 00052 QString mLoadedProductId; // PRODID string loaded from calendar file 00053 ErrorFormat *mException; 00054 }; 00055 00056 //TODO: change strings to use "kcal" instead of "libkcal"? 00057 QString CalFormat::Private::mApplication = QLatin1String( "libkcal" ); 00058 QString CalFormat::Private::mProductId = 00059 QLatin1String( "-//K Desktop Environment//NONSGML libkcal 3.5//EN" ); 00060 //@endcond 00061 00062 CalFormat::CalFormat() 00063 : d( new KCal::CalFormat::Private ) 00064 { 00065 } 00066 00067 CalFormat::~CalFormat() 00068 { 00069 delete d; 00070 } 00071 00072 void CalFormat::clearException() 00073 { 00074 delete d->mException; 00075 d->mException = 0; 00076 } 00077 00078 void CalFormat::setException( ErrorFormat *exception ) 00079 { 00080 delete d->mException; 00081 d->mException = exception; 00082 } 00083 00084 ErrorFormat *CalFormat::exception() 00085 { 00086 return d->mException; 00087 } 00088 00089 void CalFormat::setApplication( const QString &application, 00090 const QString &productID ) 00091 { 00092 Private::mApplication = application; 00093 Private::mProductId = productID; 00094 } 00095 00096 const QString &CalFormat::application() 00097 { 00098 return Private::mApplication; 00099 } 00100 00101 const QString &CalFormat::productId() 00102 { 00103 return Private::mProductId; 00104 } 00105 00106 const QString &CalFormat::loadedProductId() 00107 { 00108 return d->mLoadedProductId; 00109 } 00110 00111 void CalFormat::setLoadedProductId( const QString &id ) 00112 { 00113 d->mLoadedProductId = id; 00114 } 00115 00116 QString CalFormat::createUniqueId() 00117 { 00118 int hashTime = QTime::currentTime().hour() + 00119 QTime::currentTime().minute() + QTime::currentTime().second() + 00120 QTime::currentTime().msec(); 00121 QString uidStr = QString( "%1-%2.%3" ). 00122 arg( Private::mApplication ). 00123 arg( KRandom::random() ). 00124 arg( hashTime ); 00125 return uidStr; 00126 }