File indexing completed on 2024-04-21 03:52:45

0001 /*
0002   This file is part of the kcalcore library.
0003 
0004   SPDX-FileCopyrightText: 2001 Cornelius Schumacher <schumacher@kde.org>
0005 
0006   SPDX-License-Identifier: LGPL-2.0-or-later
0007 */
0008 /**
0009   @file
0010   This file is part of the API for handling calendar data and
0011   defines the CalFormat base class.
0012 
0013   @brief
0014   Base class providing an interface to various calendar formats.
0015 
0016   @author Cornelius Schumacher \<schumacher@kde.org\>
0017 */
0018 
0019 #include "calformat.h"
0020 #include "calformat_p.h"
0021 #include "exceptions.h"
0022 
0023 #include <QUuid>
0024 
0025 using namespace KCalendarCore;
0026 
0027 CalFormatPrivate::~CalFormatPrivate() = default;
0028 
0029 QString CalFormatPrivate::mApplication = QStringLiteral("libkcal");
0030 QString CalFormatPrivate::mProductId = QStringLiteral("-//K Desktop Environment//NONSGML libkcal 4.3//EN");
0031 
0032 CalFormat::CalFormat(CalFormatPrivate *dd)
0033     : d_ptr(dd)
0034 {
0035 }
0036 
0037 CalFormat::~CalFormat()
0038 {
0039     clearException();
0040 }
0041 
0042 bool CalFormat::fromString(const Calendar::Ptr &calendar, const QString &string)
0043 {
0044     return fromRawString(calendar, string.toUtf8());
0045 }
0046 
0047 void CalFormat::clearException()
0048 {
0049     d_ptr->mException.reset();
0050 }
0051 
0052 void CalFormat::setException(Exception *exception)
0053 {
0054     d_ptr->mException.reset(exception);
0055 }
0056 
0057 Exception *CalFormat::exception() const
0058 {
0059     return d_ptr->mException.get();
0060 }
0061 
0062 void CalFormat::setApplication(const QString &application, const QString &productID)
0063 {
0064     CalFormatPrivate::mApplication = application;
0065     CalFormatPrivate::mProductId = productID;
0066 }
0067 
0068 const QString &CalFormat::application()
0069 {
0070     return CalFormatPrivate::mApplication;
0071 }
0072 
0073 const QString &CalFormat::productId()
0074 {
0075     return CalFormatPrivate::mProductId;
0076 }
0077 
0078 QString CalFormat::loadedProductId()
0079 {
0080     return d_ptr->mLoadedProductId;
0081 }
0082 
0083 void CalFormat::setLoadedProductId(const QString &id)
0084 {
0085     d_ptr->mLoadedProductId = id;
0086 }
0087 
0088 QString CalFormat::createUniqueId()
0089 {
0090     return QUuid::createUuid().toString(QUuid::WithoutBraces);
0091 }