File indexing completed on 2024-03-24 03:55:33
0001 /* 0002 This file is part of the kcalcore library. 0003 0004 SPDX-FileCopyrightText: 2002, 2003 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 FileStorage class. 0012 0013 @author Cornelius Schumacher \<schumacher@kde.org\> 0014 */ 0015 0016 #ifndef KCALCORE_FILESTORAGE_H 0017 #define KCALCORE_FILESTORAGE_H 0018 0019 #include "calstorage.h" 0020 #include "kcalendarcore_export.h" 0021 0022 namespace KCalendarCore 0023 { 0024 class CalFormat; 0025 class Calendar; 0026 0027 /** 0028 @brief 0029 This class provides a calendar storage as a local file. 0030 */ 0031 class KCALENDARCORE_EXPORT FileStorage : public CalStorage 0032 { 0033 Q_OBJECT 0034 public: 0035 /** 0036 A shared pointer to a FileStorage. 0037 */ 0038 typedef QSharedPointer<FileStorage> Ptr; 0039 0040 /** 0041 Constructs a new FileStorage object for Calendar @p calendar with format 0042 @p format, and storage to file @p fileName. 0043 0044 @param calendar is a pointer to a valid Calendar object. 0045 @param fileName is the name of the disk file containing the calendar data. 0046 @param format is a pointer to a valid CalFormat object that specifies 0047 the calendar format to be used. FileStorage takes ownership; i.e., the 0048 memory for @p format is deleted by this destructor. If no format is 0049 specified, then iCalendar format is assumed. 0050 */ 0051 explicit FileStorage(const Calendar::Ptr &calendar, const QString &fileName = QString(), KCalendarCore::CalFormat *format = nullptr); 0052 0053 /** 0054 Destructor. 0055 */ 0056 ~FileStorage() override; 0057 0058 /** 0059 Sets the name of the file that contains the calendar data. 0060 0061 @param fileName is the name of the disk file containing the calendar data. 0062 @see fileName(). 0063 */ 0064 void setFileName(const QString &fileName); 0065 0066 /** 0067 Returns the calendar file name. 0068 @return A QString with the name of the calendar file for this storge. 0069 @see setFileName(). 0070 */ 0071 Q_REQUIRED_RESULT QString fileName() const; 0072 0073 /** 0074 Sets the CalFormat object to use for this storage. 0075 0076 @param format is a pointer to a valid CalFormat object that specifies 0077 the calendar format to be used. FileStorage takes ownership. 0078 @see saveFormat(). 0079 */ 0080 void setSaveFormat(KCalendarCore::CalFormat *format); 0081 0082 /** 0083 Returns the CalFormat object used by this storage. 0084 @return A pointer to the CalFormat object used by this storage. 0085 @see setSaveFormat(). 0086 */ 0087 CalFormat *saveFormat() const; 0088 0089 /** 0090 @copydoc CalStorage::open() 0091 */ 0092 Q_REQUIRED_RESULT bool open() override; 0093 0094 /** 0095 @copydoc CalStorage::load() 0096 */ 0097 Q_REQUIRED_RESULT bool load() override; 0098 0099 /** 0100 @copydoc CalStorage::save() 0101 */ 0102 Q_REQUIRED_RESULT bool save() override; 0103 0104 /** 0105 @copydoc CalStorage::close() 0106 */ 0107 Q_REQUIRED_RESULT bool close() override; 0108 0109 private: 0110 //@cond PRIVATE 0111 Q_DISABLE_COPY(FileStorage) 0112 class Private; 0113 Private *const d; 0114 //@endcond 0115 }; 0116 0117 } 0118 0119 #endif