KCalendarCore

calformat.cpp
Go to the documentation of this file.
1 /*
2  This file is part of the kcalcore library.
3 
4  SPDX-FileCopyrightText: 2001 Cornelius Schumacher <[email protected]>
5 
6  SPDX-License-Identifier: LGPL-2.0-or-later
7 */
8 /**
9  @file
10  This file is part of the API for handling calendar data and
11  defines the CalFormat base class.
12 
13  @brief
14  Base class providing an interface to various calendar formats.
15 
16  @author Cornelius Schumacher <[email protected]>
17 */
18 
19 #include "calformat.h"
20 #include "calformat_p.h"
21 #include "exceptions.h"
22 
23 #include <QUuid>
24 
25 using namespace KCalendarCore;
26 
27 CalFormatPrivate::~CalFormatPrivate() = default;
28 
29 QString CalFormatPrivate::mApplication = QStringLiteral("libkcal");
30 QString CalFormatPrivate::mProductId = QStringLiteral("-//K Desktop Environment//NONSGML libkcal 4.3//EN");
31 
32 #if KCALENDARCORE_BUILD_DEPRECATED_SINCE(5, 96)
34  : d_ptr(new KCalendarCore::CalFormatPrivate)
35 {
36 }
37 #endif
38 
39 CalFormat::CalFormat(CalFormatPrivate *dd)
40  : d_ptr(dd)
41 {
42 }
43 
45 {
47 }
48 
49 bool CalFormat::fromString(const Calendar::Ptr &calendar, const QString &string, const QString &notebook)
50 {
51  return fromRawString(calendar, string.toUtf8(), false, notebook);
52 }
53 
55 {
56  d_ptr->mException.reset();
57 }
58 
60 {
61  d_ptr->mException.reset(exception);
62 }
63 
65 {
66  return d_ptr->mException.get();
67 }
68 
69 void CalFormat::setApplication(const QString &application, const QString &productID)
70 {
71  CalFormatPrivate::mApplication = application;
72  CalFormatPrivate::mProductId = productID;
73 }
74 
76 {
77  return CalFormatPrivate::mApplication;
78 }
79 
81 {
82  return CalFormatPrivate::mProductId;
83 }
84 
86 {
87  return d_ptr->mLoadedProductId;
88 }
89 
91 {
92  d_ptr->mLoadedProductId = id;
93 }
94 
96 {
97  return QUuid::createUuid().toString().mid(1, 36);
98 }
99 
100 #if KCALENDARCORE_BUILD_DEPRECATED_SINCE(5, 96)
101 void CalFormat::virtual_hook(int id, void *data)
102 {
103  Q_UNUSED(id);
104  Q_UNUSED(data);
105  Q_ASSERT(false);
106 }
107 #endif
Exception base class.
virtual void virtual_hook(int id, void *data)
Definition: calformat.cpp:101
Namespace for all KCalendarCore types.
Definition: alarm.h:36
void clearException()
Clears the exception status.
Definition: calformat.cpp:54
Exception base class, currently used as a fancy kind of error code and not as an C++ exception.
Definition: exceptions.h:41
void setException(Exception *error)
Sets an exception that is to be used by the functions of this class to report errors.
Definition: calformat.cpp:59
void setLoadedProductId(const QString &id)
Sets the PRODID string loaded from calendar file.
Definition: calformat.cpp:90
static const QString & application()
Returns the application name used in unique IDs and error messages.
Definition: calformat.cpp:75
static QString createUniqueId()
Creates a unique id string.
Definition: calformat.cpp:95
QUuid createUuid()
Exception * exception() const
Returns an exception, if there is any, containing information about the last error that occurred.
Definition: calformat.cpp:64
QString loadedProductId()
Returns the PRODID string loaded from calendar file.
Definition: calformat.cpp:85
static void setApplication(const QString &application, const QString &productID)
Sets the application name for use in unique IDs and error messages, and product ID for incidence PROD...
Definition: calformat.cpp:69
QString toString() const const
virtual bool fromString(const Calendar::Ptr &calendar, const QString &string, bool deleted, const QString &notebook={})=0
Loads a calendar from a string.
QString mid(int position, int n) const const
CalFormat()
Constructs a new Calendar Format object.
Definition: calformat.cpp:33
virtual ~CalFormat()
Destructor.
Definition: calformat.cpp:44
static const QString & productId()
Returns the our library's PRODID string to write into calendar files.
Definition: calformat.cpp:80
virtual bool fromRawString(const Calendar::Ptr &calendar, const QByteArray &string, bool deleted=false, const QString &notebook=QString())=0
Parses a utf8 encoded string, returning the first iCal component encountered in that string.
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Thu Sep 21 2023 04:00:45 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.