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 "exceptions.h"
21 
22 #include <QUuid>
23 
24 using namespace KCalendarCore;
25 
26 /**
27  Private class that helps to provide binary compatibility between releases.
28  @internal
29 */
30 //@cond PRIVATE
31 class Q_DECL_HIDDEN KCalendarCore::CalFormat::Private
32 {
33 public:
34  Private()
35  {
36  }
37  ~Private()
38  {
39  delete mException;
40  }
41  static QString mApplication; // Name of application, for creating unique ID strings
42  static QString mProductId; // PRODID string to write to calendar files
43  QString mLoadedProductId; // PRODID string loaded from calendar file
44  Exception *mException = nullptr;
45 };
46 
47 QString CalFormat::Private::mApplication = QStringLiteral("libkcal");
48 QString CalFormat::Private::mProductId = QStringLiteral("-//K Desktop Environment//NONSGML libkcal 4.3//EN");
49 //@endcond
50 
52  : d(new KCalendarCore::CalFormat::Private)
53 {
54 }
55 
57 {
59  delete d;
60 }
61 
63 {
64  delete d->mException;
65  d->mException = nullptr;
66 }
67 
69 {
70  delete d->mException;
71  d->mException = exception;
72 }
73 
75 {
76  return d->mException;
77 }
78 
79 void CalFormat::setApplication(const QString &application, const QString &productID)
80 {
81  Private::mApplication = application;
82  Private::mProductId = productID;
83 }
84 
86 {
87  return Private::mApplication;
88 }
89 
91 {
92  return Private::mProductId;
93 }
94 
96 {
97  return d->mLoadedProductId;
98 }
99 
101 {
102  d->mLoadedProductId = id;
103 }
104 
106 {
107  return QUuid::createUuid().toString().mid(1, 36);
108 }
109 
110 void CalFormat::virtual_hook(int id, void *data)
111 {
112  Q_UNUSED(id);
113  Q_UNUSED(data);
114  Q_ASSERT(false);
115 }
static QString createUniqueId()
Creates a unique id string.
Definition: calformat.cpp:105
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:79
An abstract base class that provides an interface to various calendar formats.
Definition: calformat.h:35
void setLoadedProductId(const QString &id)
Sets the PRODID string loaded from calendar file.
Definition: calformat.cpp:100
static const QString & productId()
Returns the our library&#39;s PRODID string to write into calendar files.
Definition: calformat.cpp:90
This file is part of the API for handling calendar data and defines the CalFormat abstract base class...
void clearException()
Clears the exception status.
Definition: calformat.cpp:62
virtual void virtual_hook(int id, void *data)
Definition: calformat.cpp:110
This file is part of the API for handling calendar data and defines the Exception class...
static const QString & application()
Returns the application name used in unique IDs and error messages.
Definition: calformat.cpp:85
QString mid(int position, int n) const const
Exception base class, currently used as a fancy kind of error code and not as an C++ exception...
Definition: exceptions.h:41
CalFormat()
Constructs a new Calendar Format object.
Definition: calformat.cpp:51
void setException(Exception *error)
Sets an exception that is to be used by the functions of this class to report errors.
Definition: calformat.cpp:68
QString loadedProductId()
Returns the PRODID string loaded from calendar file.
Definition: calformat.cpp:95
virtual ~CalFormat()
Destructor.
Definition: calformat.cpp:56
QString toString() const const
QUuid createUuid()
Namespace for all KCalendarCore types.
Definition: alarm.h:36
Exception * exception() const
Returns an exception, if there is any, containing information about the last error that occurred...
Definition: calformat.cpp:74
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Fri Sep 24 2021 22:51:50 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.