File indexing completed on 2024-04-28 15:19:00

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 #if KCALENDARCORE_BUILD_DEPRECATED_SINCE(5, 96)
0033 CalFormat::CalFormat()
0034     : d_ptr(new KCalendarCore::CalFormatPrivate)
0035 {
0036 }
0037 #endif
0038 
0039 CalFormat::CalFormat(CalFormatPrivate *dd)
0040     : d_ptr(dd)
0041 {
0042 }
0043 
0044 CalFormat::~CalFormat()
0045 {
0046     clearException();
0047 }
0048 
0049 bool CalFormat::fromString(const Calendar::Ptr &calendar, const QString &string, const QString &notebook)
0050 {
0051     return fromRawString(calendar, string.toUtf8(), false, notebook);
0052 }
0053 
0054 void CalFormat::clearException()
0055 {
0056     d_ptr->mException.reset();
0057 }
0058 
0059 void CalFormat::setException(Exception *exception)
0060 {
0061     d_ptr->mException.reset(exception);
0062 }
0063 
0064 Exception *CalFormat::exception() const
0065 {
0066     return d_ptr->mException.get();
0067 }
0068 
0069 void CalFormat::setApplication(const QString &application, const QString &productID)
0070 {
0071     CalFormatPrivate::mApplication = application;
0072     CalFormatPrivate::mProductId = productID;
0073 }
0074 
0075 const QString &CalFormat::application()
0076 {
0077     return CalFormatPrivate::mApplication;
0078 }
0079 
0080 const QString &CalFormat::productId()
0081 {
0082     return CalFormatPrivate::mProductId;
0083 }
0084 
0085 QString CalFormat::loadedProductId()
0086 {
0087     return d_ptr->mLoadedProductId;
0088 }
0089 
0090 void CalFormat::setLoadedProductId(const QString &id)
0091 {
0092     d_ptr->mLoadedProductId = id;
0093 }
0094 
0095 QString CalFormat::createUniqueId()
0096 {
0097     return QUuid::createUuid().toString().mid(1, 36);
0098 }
0099 
0100 #if KCALENDARCORE_BUILD_DEPRECATED_SINCE(5, 96)
0101 void CalFormat::virtual_hook(int id, void *data)
0102 {
0103     Q_UNUSED(id);
0104     Q_UNUSED(data);
0105     Q_ASSERT(false);
0106 }
0107 #endif