1 | /* |
2 | This file is part of the kcal library. |
3 | |
4 | Copyright (c) 1998 Preston Brown <pbrown@kde.org> |
5 | Copyright (c) 2001,2003 Cornelius Schumacher <schumacher@kde.org> |
6 | |
7 | This library is free software; you can redistribute it and/or |
8 | modify it under the terms of the GNU Library General Public |
9 | License as published by the Free Software Foundation; either |
10 | version 2 of the License, or (at your option) any later version. |
11 | |
12 | This library is distributed in the hope that it will be useful, |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 | Library General Public License for more details. |
16 | |
17 | You should have received a copy of the GNU Library General Public License |
18 | along with this library; see the file COPYING.LIB. If not, write to |
19 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
20 | Boston, MA 02110-1301, USA. |
21 | */ |
22 | /** |
23 | @file |
24 | This file is part of the API for handling calendar data and |
25 | defines the ResourceLocal class. |
26 | |
27 | @author Preston Brown <pbrown@kde.org> |
28 | @author Cornelius Schumacher <schumacher@kde.org> |
29 | */ |
30 | |
31 | #ifndef KCAL_RESOURCELOCAL_H |
32 | #define KCAL_RESOURCELOCAL_H |
33 | |
34 | #include <QtCore/QString> |
35 | |
36 | #include <kdatetime.h> |
37 | |
38 | #include "kcal_export.h" |
39 | #include "resourcecached.h" |
40 | |
41 | namespace KCal { |
42 | |
43 | /** |
44 | @brief Provides a calendar resource stored as a local file. |
45 | */ |
46 | class KCAL_DEPRECATED_EXPORT ResourceLocal : public ResourceCached |
47 | { |
48 | Q_OBJECT |
49 | |
50 | friend class ResourceLocalConfig; |
51 | |
52 | public: |
53 | |
54 | /** |
55 | Constructs a resource using default configuration information. |
56 | */ |
57 | ResourceLocal(); |
58 | |
59 | /** |
60 | Constructs a resource from configuration information |
61 | stored in a KConfig object. |
62 | |
63 | @param group the configuration group to read the resource configuration from |
64 | */ |
65 | explicit ResourceLocal( const KConfigGroup &group ); |
66 | |
67 | /** |
68 | Constructs a resource for file named @p fileName. |
69 | |
70 | @param fileName the file to link to the resource. |
71 | */ |
72 | explicit ResourceLocal( const QString &fileName ); |
73 | |
74 | /** |
75 | Destroys the resource. |
76 | **/ |
77 | virtual ~ResourceLocal(); |
78 | |
79 | /** |
80 | Writes KConfig @p config to a local file. |
81 | **/ |
82 | virtual void writeConfig( KConfigGroup &group ); |
83 | |
84 | /** |
85 | Returns the lock. |
86 | **/ |
87 | KABC::Lock *lock(); |
88 | |
89 | /** |
90 | Returns the fileName for this resource. |
91 | |
92 | @see setFileName() |
93 | **/ |
94 | QString fileName() const; |
95 | |
96 | /** |
97 | Sets the fileName for this resource. This will be the local |
98 | file where the resource data will be stored. |
99 | |
100 | @param fileName the file to use for this resource |
101 | |
102 | @see fileName() |
103 | **/ |
104 | bool setFileName( const QString &fileName ); |
105 | |
106 | /** |
107 | Sets a value for this resource. |
108 | |
109 | @param key the distinct name for this value. |
110 | @param value the actual data for this value. |
111 | **/ |
112 | bool setValue( const QString &key, const QString &value ); |
113 | |
114 | /** |
115 | Dumps the resource. |
116 | **/ |
117 | void dump() const; |
118 | |
119 | protected Q_SLOTS: |
120 | |
121 | /** |
122 | Reload the resource data from the local file. |
123 | **/ |
124 | void reload(); |
125 | |
126 | protected: |
127 | |
128 | /** |
129 | Actually loads the data from the local file. |
130 | **/ |
131 | virtual bool doLoad( bool syncCache ); |
132 | |
133 | /** |
134 | Actually saves the data to the local file. |
135 | **/ |
136 | virtual bool doSave( bool syncCache ); |
137 | |
138 | /** |
139 | @copydoc |
140 | ResourceCached::doSave(bool, Incidence*) |
141 | */ |
142 | virtual bool doSave( bool syncCache, Incidence *incidence ); |
143 | |
144 | /** |
145 | Called by reload() to reload the resource, if it is already open. |
146 | @return true if successful, else false. If true is returned, |
147 | reload() will emit a resourceChanged() signal. |
148 | |
149 | @see doLoad(), doSave() |
150 | */ |
151 | virtual bool doReload(); |
152 | |
153 | /** |
154 | Returns the date/time the local file was last modified. |
155 | |
156 | @see doSave() |
157 | **/ |
158 | KDateTime readLastModified(); |
159 | |
160 | /** |
161 | Compares this ResourceLocal and @p other for equality. |
162 | Returns true if they are equal. |
163 | |
164 | @param other the instance to compare with |
165 | **/ |
166 | bool operator==( const ResourceLocal &other ); |
167 | |
168 | /** |
169 | Sets this ResourceLocal equal to @p other. |
170 | **/ |
171 | ResourceLocal &operator=( const ResourceLocal &other ); |
172 | |
173 | private: |
174 | // Inherited virtual methods which should not be used by derived classes. |
175 | using ResourceCalendar::doLoad; |
176 | using ResourceCalendar::doSave; |
177 | |
178 | void init(); |
179 | //@cond PRIVATE |
180 | class Private; |
181 | Private *const d; |
182 | //@endcond |
183 | }; |
184 | |
185 | } |
186 | |
187 | #endif |
188 | |