2 * resourcelocaldir.h - KAlarm local directory alarm calendar resource
4 * Copyright © 2006-2011 by David Jarvie <djarvie@kde.org>
5 * Based on resourcelocaldir.h in libkcal,
6 * Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23 #ifndef RESOURCELOCALDIR_H
24 #define RESOURCELOCALDIR_H
26 /* @file resourcelocaldir.h - KAlarm local directory alarm calendar resource */
28 #include "alarmresource.h"
31 #include <kdirwatch.h>
40 /** A KAlarm calendar resource stored in a directory as one file per alarm. */
41 class KALARM_RESOURCES_EXPORT KAResourceLocalDir
: public AlarmResource
46 /** Create resource from configuration information stored in a KConfig object. */
47 explicit KAResourceLocalDir(const KConfigGroup
&);
48 /** Create resource for directory named @p dirName. */
49 KAResourceLocalDir(CalEvent::Type
, const QString
& dirName
);
50 virtual ~KAResourceLocalDir();
52 const KUrl
& url() const { return mURL
; }
53 QString
dirName() const;
54 bool setDirName(const KUrl
&);
55 virtual QString
displayType() const;
56 virtual QString
displayLocation() const;
57 virtual QStringList
location() const { return QStringList(dirName()); }
58 virtual bool setLocation(const QString
& dirName
, const QString
& = QString());
59 virtual bool readOnly() const;
60 virtual void setReadOnly(bool);
61 virtual bool addEvent(KCal::Event
*);
62 virtual bool deleteEvent(KCal::Event
*);
63 virtual void writeConfig(KConfigGroup
&);
64 virtual void startReconfig();
65 virtual void applyReconfig();
67 // Override unused virtual functions
68 virtual KCal::Todo::List
rawTodos(KCal::TodoSortField
= KCal::TodoSortUnsorted
, KCal::SortDirection
= KCal::SortDirectionAscending
) { return KCal::Todo::List(); }
69 virtual KCal::Journal::List
rawJournals(KCal::JournalSortField
= KCal::JournalSortUnsorted
, KCal::SortDirection
= KCal::SortDirectionAscending
) { return KCal::Journal::List(); }
72 virtual bool doOpen();
73 /** Load the resource. If 'syncCache' is true, all files in the directory
74 * are reloaded. If 'syncCache' is false, only changed files are reloaded. */
75 virtual bool doLoad(bool syncCache
);
77 virtual bool doSave(bool syncCache
);
78 bool doSave(bool syncCache
, KCal::Incidence
*);
79 virtual void enableResource(bool enable
);
82 void slotUpdated(const QString
& filepath
);
86 bool loadFile(const QString
& fileName
, const QString
& id
, bool readOnly
, FixFunc
& prompt
);
87 bool deleteIncidenceFile(KCal::Incidence
*incidence
);
88 // Inherited virtual methods which are not used by derived classes
89 using ResourceCalendar::doLoad
;
90 virtual bool doSave() { return false; }
91 virtual bool doSave(KCal::Incidence
*) { return false; }
94 KUrl mNewURL
; // new directory to be applied by applyReconfig()
96 typedef QMap
<QString
, QDateTime
> ModifiedMap
;
97 ModifiedMap mLastModified
;
98 QList
<KCal::Incidence
*> mDeletedIncidences
;
99 bool mDirReadOnly
; // directory is read-only