40 #include <kmessagebox.h>
41 #include <kstandarddirs.h>
42 #include <kconfiggroup.h>
44 #include <kcal/icalformat.h>
50 kDebug( 5500 ) <<
"ResourceLocal::ResourceLocal()";
51 setType( QLatin1String(
"file") );
52 mURL = KUrl::fromPath( KGlobal::dirs()->saveLocation(
"data", QLatin1String(
"knotes/") ) +
53 QLatin1String(
"notes.ics") );
57 :
ResourceNotes( group ), mCalendar( QString::fromLatin1(
"UTC" ) )
59 kDebug( 5500 ) <<
"ResourceLocal::ResourceLocal()";
60 setType( QLatin1String(
"file") );
61 mURL = KUrl::fromPath( KGlobal::dirs()->saveLocation(
"data", QLatin1String(
"knotes/") ) +
62 QLatin1String(
"notes.ics") );
64 const KUrl u = group.readPathEntry(
"NotesURL", QString() );
76 KRES::Resource::writeConfig( group );
77 group.writePathEntry(
"NotesURL",
mURL.prettyUrl() );
84 KCal::Journal::List notes =
mCalendar.journals();
85 KCal::Journal::List::ConstIterator it;
86 KCal::Journal::List::ConstIterator end(notes.constEnd());
87 for ( it = notes.constBegin(); it != end; ++it ) {
96 if ( !
mCalendar.save(
mURL.toLocalFile(),
new KCal::ICalFormat() ) ) {
97 KMessageBox::error( 0, i18n(
"<qt>Unable to save the notes to <b>%1</b>. "
98 "Check that there is sufficient disk space."
99 "<br />There should be a backup in the same "
100 "directory though.</qt>",
mURL.toLocalFile() ) );
114 return mCalendar.deleteJournal( journal );
120 KCal::Journal::List notes =
mCalendar.journals();
121 KCal::Journal::List::ConstIterator note;
123 for ( note = notes.constBegin(); note != notes.constEnd(); ++note ) {
124 KDateTime preTime = from.addSecs( -1 );
125 KCal::Alarm::List::ConstIterator it;
126 KCal::Alarm::List::ConstIterator itEnd(( *note )->alarms().constEnd());
127 for( it = ( *note )->alarms().constBegin(); it != itEnd; ++it ) {
128 if ( ( *it )->enabled() ) {
129 KDateTime dt = ( *it )->nextRepetition( preTime );
130 if ( dt.isValid() && dt <= to ) {
131 alarms.append( *it );
virtual bool load()
Load resource data.
virtual void writeConfig(KConfigGroup &group)
virtual KCal::Alarm::List alarms(const KDateTime &from, const KDateTime &to)
virtual bool save()
Save resource data.
KCal::CalendarLocal mCalendar
virtual bool addNote(KCal::Journal *)
This class provides the interfaces for a KNotes resource.
KNotesResourceManager * manager() const
virtual bool deleteNote(KCal::Journal *)
void registerNote(ResourceNotes *resource, KCal::Journal *journal)