• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdepimlibs-4.11.3 API Reference
  • KDE Home
  • Contact Us
 

KCalCore Library

  • kcalcore
alarm.cpp
Go to the documentation of this file.
1 /*
2  This file is part of the kcalcore library.
3 
4  Copyright (c) 1998 Preston Brown <pbrown@kde.org>
5  Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
6  Copyright (c) 2003 David Jarvie <software@astrojar.org.uk>
7 
8  This library is free software; you can redistribute it and/or
9  modify it under the terms of the GNU Library General Public
10  License as published by the Free Software Foundation; either
11  version 2 of the License, or (at your option) any later version.
12 
13  This library 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 GNU
16  Library General Public License for more details.
17 
18  You should have received a copy of the GNU Library General Public License
19  along with this library; see the file COPYING.LIB. If not, write to
20  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21  Boston, MA 02110-1301, USA.
22 */
33 #include "alarm.h"
34 #include "duration.h"
35 #include "incidence.h"
36 
37 #include <QTime>
38 
39 using namespace KCalCore;
40 
45 //@cond PRIVATE
46 class KCalCore::Alarm::Private
47 {
48  public:
49  Private()
50  : mParent( 0 ),
51  mType( Alarm::Invalid ),
52  mAlarmSnoozeTime( 5 ),
53  mAlarmRepeatCount( 0 ),
54  mEndOffset( false ),
55  mHasTime( false ),
56  mAlarmEnabled( false ),
57  mHasLocationRadius ( false ),
58  mLocationRadius ( 0 )
59  {}
60  Private( const Private &other )
61  : mParent( other.mParent ),
62  mType( other.mType ),
63  mDescription( other.mDescription ),
64  mFile( other.mFile ),
65  mMailSubject( other.mMailSubject ),
66  mMailAttachFiles( other.mMailAttachFiles ),
67  mMailAddresses( other.mMailAddresses ),
68  mAlarmTime( other.mAlarmTime ),
69  mAlarmSnoozeTime( other.mAlarmSnoozeTime ),
70  mAlarmRepeatCount( other.mAlarmRepeatCount ),
71  mOffset( other.mOffset ),
72  mEndOffset( other.mEndOffset ),
73  mHasTime( other.mHasTime ),
74  mAlarmEnabled( other.mAlarmEnabled ),
75  mHasLocationRadius( other.mHasLocationRadius ),
76  mLocationRadius( other.mLocationRadius )
77  {}
78 
79  Incidence *mParent; // the incidence which this alarm belongs to
80 
81  Type mType; // type of alarm
82  QString mDescription;// text to display/email body/procedure arguments
83  QString mFile; // program to run/optional audio file to play
84  QString mMailSubject;// subject of email
85  QStringList mMailAttachFiles; // filenames to attach to email
86  Person::List mMailAddresses; // who to mail for reminder
87 
88  KDateTime mAlarmTime;// time at which to trigger the alarm
89  Duration mAlarmSnoozeTime; // how long after alarm to snooze before
90  // triggering again
91  int mAlarmRepeatCount;// number of times for alarm to repeat
92  // after the initial time
93 
94  Duration mOffset; // time relative to incidence DTSTART
95  // to trigger the alarm
96  bool mEndOffset; // if true, mOffset relates to DTEND, not DTSTART
97  bool mHasTime; // use mAlarmTime, not mOffset
98  bool mAlarmEnabled;
99 
100  bool mHasLocationRadius;
101  int mLocationRadius; // location radius for the alarm
102 };
103 //@endcond
104 
105 Alarm::Alarm( Incidence *parent ) : d( new KCalCore::Alarm::Private )
106 {
107  d->mParent = parent;
108 }
109 
110 Alarm::Alarm( const Alarm &other ) :
111  CustomProperties( other ), d( new KCalCore::Alarm::Private( *other.d ) )
112 {
113 }
114 
115 Alarm::~Alarm()
116 {
117  delete d;
118 }
119 
120 Alarm &Alarm::operator=( const Alarm &a )
121 {
122  if ( &a != this ) {
123  d->mParent = a.d->mParent;
124  d->mType = a.d->mType;
125  d->mDescription = a.d->mDescription;
126  d->mFile = a.d->mFile;
127  d->mMailAttachFiles = a.d->mMailAttachFiles;
128  d->mMailAddresses = a.d->mMailAddresses;
129  d->mMailSubject = a.d->mMailSubject;
130  d->mAlarmSnoozeTime = a.d->mAlarmSnoozeTime;
131  d->mAlarmRepeatCount = a.d->mAlarmRepeatCount;
132  d->mAlarmTime = a.d->mAlarmTime;
133  d->mOffset = a.d->mOffset;
134  d->mEndOffset = a.d->mEndOffset;
135  d->mHasTime = a.d->mHasTime;
136  d->mAlarmEnabled = a.d->mAlarmEnabled;
137  }
138 
139  return *this;
140 }
141 
142 bool Alarm::operator==( const Alarm &rhs ) const
143 {
144  if ( d->mType != rhs.d->mType ||
145  d->mAlarmSnoozeTime != rhs.d->mAlarmSnoozeTime ||
146  d->mAlarmRepeatCount != rhs.d->mAlarmRepeatCount ||
147  d->mAlarmEnabled != rhs.d->mAlarmEnabled ||
148  d->mHasTime != rhs.d->mHasTime ||
149  d->mHasLocationRadius != rhs.d->mHasLocationRadius ||
150  d->mLocationRadius != rhs.d->mLocationRadius ) {
151  return false;
152  }
153 
154  if ( d->mHasTime ) {
155  if ( d->mAlarmTime != rhs.d->mAlarmTime ) {
156  return false;
157  }
158  } else {
159  if ( d->mOffset != rhs.d->mOffset || d->mEndOffset != rhs.d->mEndOffset ) {
160  return false;
161  }
162  }
163 
164  switch ( d->mType ) {
165  case Display:
166  return d->mDescription == rhs.d->mDescription;
167 
168  case Email:
169  return d->mDescription == rhs.d->mDescription &&
170  d->mMailAttachFiles == rhs.d->mMailAttachFiles &&
171  d->mMailAddresses == rhs.d->mMailAddresses &&
172  d->mMailSubject == rhs.d->mMailSubject;
173 
174  case Procedure:
175  return d->mFile == rhs.d->mFile &&
176  d->mDescription == rhs.d->mDescription;
177 
178  case Audio:
179  return d->mFile == rhs.d->mFile;
180 
181  case Invalid:
182  break;
183  }
184  return false;
185 }
186 
187 bool Alarm::operator!=( const Alarm &a ) const
188 {
189  return !operator==( a );
190 }
191 
192 void Alarm::setType( Alarm::Type type )
193 {
194  if ( type == d->mType ) {
195  return;
196  }
197 
198  if ( d->mParent ) {
199  d->mParent->update();
200  }
201  switch ( type ) {
202  case Display:
203  d->mDescription = "";
204  break;
205  case Procedure:
206  d->mFile = d->mDescription = "";
207  break;
208  case Audio:
209  d->mFile = "";
210  break;
211  case Email:
212  d->mMailSubject = d->mDescription = "";
213  d->mMailAddresses.clear();
214  d->mMailAttachFiles.clear();
215  break;
216  case Invalid:
217  break;
218  default:
219  if ( d->mParent ) {
220  d->mParent->updated(); // not really
221  }
222  return;
223  }
224  d->mType = type;
225  if ( d->mParent ) {
226  d->mParent->updated();
227  }
228 }
229 
230 Alarm::Type Alarm::type() const
231 {
232  return d->mType;
233 }
234 
235 void Alarm::setAudioAlarm( const QString &audioFile )
236 {
237  if ( d->mParent ) {
238  d->mParent->update();
239  }
240  d->mType = Audio;
241  d->mFile = audioFile;
242  if ( d->mParent ) {
243  d->mParent->updated();
244  }
245 }
246 
247 void Alarm::setAudioFile( const QString &audioFile )
248 {
249  if ( d->mType == Audio ) {
250  if ( d->mParent ) {
251  d->mParent->update();
252  }
253  d->mFile = audioFile;
254  if ( d->mParent ) {
255  d->mParent->updated();
256  }
257  }
258 }
259 
260 QString Alarm::audioFile() const
261 {
262  return ( d->mType == Audio ) ? d->mFile : QString();
263 }
264 
265 void Alarm::setProcedureAlarm( const QString &programFile,
266  const QString &arguments )
267 {
268  if ( d->mParent ) {
269  d->mParent->update();
270  }
271  d->mType = Procedure;
272  d->mFile = programFile;
273  d->mDescription = arguments;
274  if ( d->mParent ) {
275  d->mParent->updated();
276  }
277 }
278 
279 void Alarm::setProgramFile( const QString &programFile )
280 {
281  if ( d->mType == Procedure ) {
282  if ( d->mParent ) {
283  d->mParent->update();
284  }
285  d->mFile = programFile;
286  if ( d->mParent ) {
287  d->mParent->updated();
288  }
289  }
290 }
291 
292 QString Alarm::programFile() const
293 {
294  return ( d->mType == Procedure ) ? d->mFile : QString();
295 }
296 
297 void Alarm::setProgramArguments( const QString &arguments )
298 {
299  if ( d->mType == Procedure ) {
300  if ( d->mParent ) {
301  d->mParent->update();
302  }
303  d->mDescription = arguments;
304  if ( d->mParent ) {
305  d->mParent->updated();
306  }
307  }
308 }
309 
310 QString Alarm::programArguments() const
311 {
312  return ( d->mType == Procedure ) ? d->mDescription : QString();
313 }
314 
315 void Alarm::setEmailAlarm( const QString &subject, const QString &text,
316  const Person::List &addressees,
317  const QStringList &attachments )
318 {
319  if ( d->mParent ) {
320  d->mParent->update();
321  }
322  d->mType = Email;
323  d->mMailSubject = subject;
324  d->mDescription = text;
325  d->mMailAddresses = addressees;
326  d->mMailAttachFiles = attachments;
327  if ( d->mParent ) {
328  d->mParent->updated();
329  }
330 }
331 
332 void Alarm::setMailAddress( const Person::Ptr &mailAddress )
333 {
334  if ( d->mType == Email ) {
335  if ( d->mParent ) {
336  d->mParent->update();
337  }
338  d->mMailAddresses.clear();
339  d->mMailAddresses.append( mailAddress );
340  if ( d->mParent ) {
341  d->mParent->updated();
342  }
343  }
344 }
345 
346 void Alarm::setMailAddresses( const Person::List &mailAddresses )
347 {
348  if ( d->mType == Email ) {
349  if ( d->mParent ) {
350  d->mParent->update();
351  }
352  d->mMailAddresses += mailAddresses;
353  if ( d->mParent ) {
354  d->mParent->updated();
355  }
356  }
357 }
358 
359 void Alarm::addMailAddress( const Person::Ptr &mailAddress )
360 {
361  if ( d->mType == Email ) {
362  if ( d->mParent ) {
363  d->mParent->update();
364  }
365  d->mMailAddresses.append( mailAddress );
366  if ( d->mParent ) {
367  d->mParent->updated();
368  }
369  }
370 }
371 
372 Person::List Alarm::mailAddresses() const
373 {
374  return ( d->mType == Email ) ? d->mMailAddresses : Person::List();
375 }
376 
377 void Alarm::setMailSubject( const QString &mailAlarmSubject )
378 {
379  if ( d->mType == Email ) {
380  if ( d->mParent ) {
381  d->mParent->update();
382  }
383  d->mMailSubject = mailAlarmSubject;
384  if ( d->mParent ) {
385  d->mParent->updated();
386  }
387  }
388 }
389 
390 QString Alarm::mailSubject() const
391 {
392  return ( d->mType == Email ) ? d->mMailSubject : QString();
393 }
394 
395 void Alarm::setMailAttachment( const QString &mailAttachFile )
396 {
397  if ( d->mType == Email ) {
398  if ( d->mParent ) {
399  d->mParent->update();
400  }
401  d->mMailAttachFiles.clear();
402  d->mMailAttachFiles += mailAttachFile;
403  if ( d->mParent ) {
404  d->mParent->updated();
405  }
406  }
407 }
408 
409 void Alarm::setMailAttachments( const QStringList &mailAttachFiles )
410 {
411  if ( d->mType == Email ) {
412  if ( d->mParent ) {
413  d->mParent->update();
414  }
415  d->mMailAttachFiles = mailAttachFiles;
416  if ( d->mParent ) {
417  d->mParent->updated();
418  }
419  }
420 }
421 
422 void Alarm::addMailAttachment( const QString &mailAttachFile )
423 {
424  if ( d->mType == Email ) {
425  if ( d->mParent ) {
426  d->mParent->update();
427  }
428  d->mMailAttachFiles += mailAttachFile;
429  if ( d->mParent ) {
430  d->mParent->updated();
431  }
432  }
433 }
434 
435 QStringList Alarm::mailAttachments() const
436 {
437  return ( d->mType == Email ) ? d->mMailAttachFiles : QStringList();
438 }
439 
440 void Alarm::setMailText( const QString &text )
441 {
442  if ( d->mType == Email ) {
443  if ( d->mParent ) {
444  d->mParent->update();
445  }
446  d->mDescription = text;
447  if ( d->mParent ) {
448  d->mParent->updated();
449  }
450  }
451 }
452 
453 QString Alarm::mailText() const
454 {
455  return ( d->mType == Email ) ? d->mDescription : QString();
456 }
457 
458 void Alarm::setDisplayAlarm( const QString &text )
459 {
460  if ( d->mParent ) {
461  d->mParent->update();
462  }
463  d->mType = Display;
464  if ( !text.isNull() ) {
465  d->mDescription = text;
466  }
467  if ( d->mParent ) {
468  d->mParent->updated();
469  }
470 }
471 
472 void Alarm::setText( const QString &text )
473 {
474  if ( d->mType == Display ) {
475  if ( d->mParent ) {
476  d->mParent->update();
477  }
478  d->mDescription = text;
479  if ( d->mParent ) {
480  d->mParent->updated();
481  }
482  }
483 }
484 
485 QString Alarm::text() const
486 {
487  return ( d->mType == Display ) ? d->mDescription : QString();
488 }
489 
490 void Alarm::setTime( const KDateTime &alarmTime )
491 {
492  if ( d->mParent ) {
493  d->mParent->update();
494  }
495  d->mAlarmTime = alarmTime;
496  d->mHasTime = true;
497 
498  if ( d->mParent ) {
499  d->mParent->updated();
500  }
501 }
502 
503 KDateTime Alarm::time() const
504 {
505  if ( hasTime() ) {
506  return d->mAlarmTime;
507  } else if ( d->mParent ) {
508  if ( d->mEndOffset ) {
509  KDateTime dt = d->mParent->dateTime( Incidence::RoleAlarmEndOffset );
510  return d->mOffset.end( dt );
511  } else {
512  KDateTime dt = d->mParent->dateTime( Incidence::RoleAlarmStartOffset );
513  return d->mOffset.end( dt );
514  }
515  } else {
516  return KDateTime();
517  }
518 }
519 
520 KDateTime Alarm::nextTime( const KDateTime &preTime, bool ignoreRepetitions ) const
521 {
522  if ( d->mParent && d->mParent->recurs() ) {
523  KDateTime dtEnd = d->mParent->dateTime( Incidence::RoleAlarmEndOffset );
524 
525  KDateTime dtStart = d->mParent->dtStart();
526  // Find the incidence's earliest alarm
527  // Alarm time is defined by an offset from the event start or end time.
528  KDateTime alarmStart = d->mOffset.end( d->mEndOffset ? dtEnd : dtStart );
529  // Find the offset from the event start time, which is also used as the
530  // offset from the recurrence time.
531  Duration alarmOffset( dtStart, alarmStart );
532  /*
533  kDebug() << "dtStart " << dtStart;
534  kDebug() << "dtEnd " << dtEnd;
535  kDebug() << "alarmStart " << alarmStart;
536  kDebug() << "alarmOffset " << alarmOffset.value();
537  kDebug() << "preTime " << preTime;
538  */
539  if ( alarmStart > preTime ) {
540  // No need to go further.
541  return alarmStart;
542  }
543  if ( d->mAlarmRepeatCount && !ignoreRepetitions ) {
544  // The alarm has repetitions, so check whether repetitions of previous
545  // recurrences happen after given time.
546  KDateTime prevRecurrence = d->mParent->recurrence()->getPreviousDateTime( preTime );
547  if ( prevRecurrence.isValid() ) {
548  KDateTime prevLastRepeat = alarmOffset.end( duration().end( prevRecurrence ) );
549  // kDebug() << "prevRecurrence" << prevRecurrence;
550  // kDebug() << "prevLastRepeat" << prevLastRepeat;
551  if ( prevLastRepeat > preTime ) {
552  // Yes they did, return alarm offset to previous recurrence.
553  KDateTime prevAlarm = alarmOffset.end( prevRecurrence );
554  // kDebug() << "prevAlarm " << prevAlarm;
555  return prevAlarm;
556  }
557  }
558  }
559  // Check the next recurrence now.
560  KDateTime nextRecurrence = d->mParent->recurrence()->getNextDateTime( preTime );
561  if ( nextRecurrence.isValid() ) {
562  KDateTime nextAlarm = alarmOffset.end( nextRecurrence );
563  /*
564  kDebug() << "nextRecurrence" << nextRecurrence;
565  kDebug() << "nextAlarm " << nextAlarm;
566  */
567  if ( nextAlarm > preTime ) {
568  // It's first alarm takes place after given time.
569  return nextAlarm;
570  }
571  }
572  } else {
573  // Not recurring.
574  KDateTime alarmTime = time();
575  if ( alarmTime > preTime ) {
576  return alarmTime;
577  }
578  }
579  return KDateTime();
580 }
581 
582 bool Alarm::hasTime() const
583 {
584  return d->mHasTime;
585 }
586 
587 void Alarm::shiftTimes( const KDateTime::Spec &oldSpec,
588  const KDateTime::Spec &newSpec )
589 {
590  if ( d->mParent ) {
591  d->mParent->update();
592  }
593  d->mAlarmTime = d->mAlarmTime.toTimeSpec( oldSpec );
594  d->mAlarmTime.setTimeSpec( newSpec );
595  if ( d->mParent ) {
596  d->mParent->updated();
597  }
598 }
599 
600 void Alarm::setSnoozeTime( const Duration &alarmSnoozeTime )
601 {
602  if ( alarmSnoozeTime.value() > 0 ) {
603  if ( d->mParent ) {
604  d->mParent->update();
605  }
606  d->mAlarmSnoozeTime = alarmSnoozeTime;
607  if ( d->mParent ) {
608  d->mParent->updated();
609  }
610  }
611 }
612 
613 Duration Alarm::snoozeTime() const
614 {
615  return d->mAlarmSnoozeTime;
616 }
617 
618 void Alarm::setRepeatCount( int alarmRepeatCount )
619 {
620  if ( d->mParent ) {
621  d->mParent->update();
622  }
623  d->mAlarmRepeatCount = alarmRepeatCount;
624  if ( d->mParent ) {
625  d->mParent->updated();
626  }
627 }
628 
629 int Alarm::repeatCount() const
630 {
631  return d->mAlarmRepeatCount;
632 }
633 
634 Duration Alarm::duration() const
635 {
636  return Duration( d->mAlarmSnoozeTime.value() * d->mAlarmRepeatCount,
637  d->mAlarmSnoozeTime.type() );
638 }
639 
640 KDateTime Alarm::nextRepetition( const KDateTime &preTime ) const
641 {
642  KDateTime at = nextTime( preTime );
643  if ( at > preTime ) {
644  return at;
645  }
646  if ( !d->mAlarmRepeatCount ) {
647  // there isn't an occurrence after the specified time
648  return KDateTime();
649  }
650  qint64 repetition;
651  int interval = d->mAlarmSnoozeTime.value();
652  bool daily = d->mAlarmSnoozeTime.isDaily();
653  if ( daily ) {
654  int daysTo = at.daysTo( preTime );
655  if ( !preTime.isDateOnly() && preTime.time() <= at.time() ) {
656  --daysTo;
657  }
658  repetition = daysTo / interval + 1;
659  } else {
660  repetition = at.secsTo_long( preTime ) / interval + 1;
661  }
662  if ( repetition > d->mAlarmRepeatCount ) {
663  // all repetitions have finished before the specified time
664  return KDateTime();
665  }
666  return daily ? at.addDays( int( repetition * interval ) )
667  : at.addSecs( repetition * interval );
668 }
669 
670 KDateTime Alarm::previousRepetition( const KDateTime &afterTime ) const
671 {
672  KDateTime at = time();
673  if ( at >= afterTime ) {
674  // alarm's first/only time is at/after the specified time
675  return KDateTime();
676  }
677  if ( !d->mAlarmRepeatCount ) {
678  return at;
679  }
680  qint64 repetition;
681  int interval = d->mAlarmSnoozeTime.value();
682  bool daily = d->mAlarmSnoozeTime.isDaily();
683  if ( daily ) {
684  int daysTo = at.daysTo( afterTime );
685  if ( afterTime.isDateOnly() || afterTime.time() <= at.time() ) {
686  --daysTo;
687  }
688  repetition = daysTo / interval;
689  } else {
690  repetition = ( at.secsTo_long( afterTime ) - 1 ) / interval;
691  }
692  if ( repetition > d->mAlarmRepeatCount ) {
693  repetition = d->mAlarmRepeatCount;
694  }
695  return daily ? at.addDays( int( repetition * interval ) )
696  : at.addSecs( repetition * interval );
697 }
698 
699 KDateTime Alarm::endTime() const
700 {
701  if ( !d->mAlarmRepeatCount ) {
702  return time();
703  }
704  if ( d->mAlarmSnoozeTime.isDaily() ) {
705  return time().addDays( d->mAlarmRepeatCount * d->mAlarmSnoozeTime.asDays() );
706  } else {
707  return time().addSecs( d->mAlarmRepeatCount * d->mAlarmSnoozeTime.asSeconds() );
708  }
709 }
710 
711 void Alarm::toggleAlarm()
712 {
713  if ( d->mParent ) {
714  d->mParent->update();
715  }
716  d->mAlarmEnabled = !d->mAlarmEnabled;
717  if ( d->mParent ) {
718  d->mParent->updated();
719  }
720 }
721 
722 void Alarm::setEnabled( bool enable )
723 {
724  if ( d->mParent ) {
725  d->mParent->update();
726  }
727  d->mAlarmEnabled = enable;
728  if ( d->mParent ) {
729  d->mParent->updated();
730  }
731 }
732 
733 bool Alarm::enabled() const
734 {
735  return d->mAlarmEnabled;
736 }
737 
738 void Alarm::setStartOffset( const Duration &offset )
739 {
740  if ( d->mParent ) {
741  d->mParent->update();
742  }
743  d->mOffset = offset;
744  d->mEndOffset = false;
745  d->mHasTime = false;
746  if ( d->mParent ) {
747  d->mParent->updated();
748  }
749 }
750 
751 Duration Alarm::startOffset() const
752 {
753  return ( d->mHasTime || d->mEndOffset ) ? Duration( 0 ) : d->mOffset;
754 }
755 
756 bool Alarm::hasStartOffset() const
757 {
758  return !d->mHasTime && !d->mEndOffset;
759 }
760 
761 bool Alarm::hasEndOffset() const
762 {
763  return !d->mHasTime && d->mEndOffset;
764 }
765 
766 void Alarm::setEndOffset( const Duration &offset )
767 {
768  if ( d->mParent ) {
769  d->mParent->update();
770  }
771  d->mOffset = offset;
772  d->mEndOffset = true;
773  d->mHasTime = false;
774  if ( d->mParent ) {
775  d->mParent->updated();
776  }
777 }
778 
779 Duration Alarm::endOffset() const
780 {
781  return ( d->mHasTime || !d->mEndOffset ) ? Duration( 0 ) : d->mOffset;
782 }
783 
784 void Alarm::setParent( Incidence *parent )
785 {
786  d->mParent = parent;
787 }
788 
789 QString Alarm::parentUid() const
790 {
791  return d->mParent ? d->mParent->uid() : QString();
792 }
793 
794 void Alarm::customPropertyUpdated()
795 {
796  if ( d->mParent ) {
797  d->mParent->update();
798  d->mParent->updated();
799  }
800 }
801 
802 void Alarm::setHasLocationRadius( bool hasLocationRadius )
803 {
804  if ( d->mParent ) {
805  d->mParent->update();
806  }
807  d->mHasLocationRadius = hasLocationRadius;
808  if ( hasLocationRadius ) {
809  setNonKDECustomProperty( "X-LOCATION-RADIUS", QString::number( d->mLocationRadius ) );
810  } else {
811  removeNonKDECustomProperty( "X-LOCATION-RADIUS" );
812  }
813  if ( d->mParent ) {
814  d->mParent->updated();
815  }
816 }
817 
818 bool Alarm::hasLocationRadius() const
819 {
820  return d->mHasLocationRadius;
821 }
822 
823 void Alarm::setLocationRadius( int locationRadius )
824 {
825  if ( d->mParent ) {
826  d->mParent->update();
827  }
828  d->mLocationRadius = locationRadius;
829  if ( d->mParent ) {
830  d->mParent->updated();
831  }
832 }
833 
834 int Alarm::locationRadius() const
835 {
836  return d->mLocationRadius;
837 }
838 
839 void Alarm::virtual_hook( int id, void *data )
840 {
841  Q_UNUSED( id );
842  Q_UNUSED( data );
843  Q_ASSERT( false );
844 }
KCalCore::Alarm::setEnabled
void setEnabled(bool enable)
Sets the enabled status of the alarm.
Definition: alarm.cpp:722
KCalCore::Alarm::operator!=
bool operator!=(const Alarm &a) const
Compares two alarms for inequality.
Definition: alarm.cpp:187
KCalCore::Alarm::setAudioFile
void setAudioFile(const QString &audioFile)
Sets the name of the audio file to play when the audio alarm is triggered.
Definition: alarm.cpp:247
KCalCore::Alarm::setRepeatCount
void setRepeatCount(int alarmRepeatCount)
Sets how many times an alarm is to repeat itself after its initial occurrence (w/snoozes).
Definition: alarm.cpp:618
KCalCore::Alarm::startOffset
Duration startOffset() const
Returns offset of alarm in time relative to the start of the parent Incidence.
Definition: alarm.cpp:751
KCalCore::Alarm::setEmailAlarm
void setEmailAlarm(const QString &subject, const QString &text, const Person::List &addressees, const QStringList &attachments=QStringList())
Sets the Email type for this alarm and the email subject, text, addresses, and attachments that make ...
Definition: alarm.cpp:315
KCalCore::Alarm::operator==
bool operator==(const Alarm &a) const
Compares two alarms for equality.
Definition: alarm.cpp:142
KCalCore::Duration
Represents a span of time measured in seconds or days.
Definition: duration.h:52
KCalCore::CustomProperties::removeNonKDECustomProperty
void removeNonKDECustomProperty(const QByteArray &name)
Delete a non-KDE or non-standard custom calendar property.
Definition: customproperties.cpp:166
KCalCore::Alarm::setType
void setType(Type type)
Sets the Type for this alarm to type.
Definition: alarm.cpp:192
KCalCore::Alarm::parentUid
QString parentUid() const
Returns the parent&#39;s incidence UID of the alarm.
Definition: alarm.cpp:789
KCalCore::Alarm::setSnoozeTime
void setSnoozeTime(const Duration &alarmSnoozeTime)
Sets the snooze time interval for the alarm.
Definition: alarm.cpp:600
KCalCore::Alarm::operator=
Alarm & operator=(const Alarm &)
Copy operator.
Definition: alarm.cpp:120
KCalCore::Alarm::hasStartOffset
bool hasStartOffset() const
Returns whether the alarm is defined in terms of an offset relative to the start of the parent Incide...
Definition: alarm.cpp:756
KCalCore::Alarm::nextRepetition
KDateTime nextRepetition(const KDateTime &preTime) const
Returns the date/time of the alarm&#39;s initial occurrence or its next repetition after a given time...
Definition: alarm.cpp:640
KCalCore::Alarm::shiftTimes
void shiftTimes(const KDateTime::Spec &oldSpec, const KDateTime::Spec &newSpec)
Shift the times of the alarm so that they appear at the same clock time as before but in a new time z...
Definition: alarm.cpp:587
KCalCore::Alarm
Represents an alarm notification.
Definition: alarm.h:59
KCalCore::Alarm::nextTime
KDateTime nextTime(const KDateTime &preTime, bool ignoreRepetitions=false) const
Returns the next alarm trigger date/time after given date/time.
Definition: alarm.cpp:520
KCalCore::Alarm::setParent
void setParent(Incidence *parent)
Sets the parent Incidence of the alarm.
Definition: alarm.cpp:784
KCalCore::Alarm::virtual_hook
virtual void virtual_hook(int id, void *data)
Definition: alarm.cpp:839
KCalCore::Alarm::Type
Type
The different types of alarms.
Definition: alarm.h:65
KCalCore::Alarm::duration
Duration duration() const
Returns the interval between the alarm&#39;s initial occurrence and its final repetition.
Definition: alarm.cpp:634
KCalCore::Person::List
QVector< Ptr > List
List of persons.
Definition: person.h:61
KCalCore::Alarm::setProcedureAlarm
void setProcedureAlarm(const QString &programFile, const QString &arguments=QString())
Sets the Procedure type for this alarm and the program (with arguments) to execute when the alarm is ...
Definition: alarm.cpp:265
KCalCore::Alarm::~Alarm
virtual ~Alarm()
Destroys the alarm.
Definition: alarm.cpp:115
KCalCore::Alarm::hasTime
bool hasTime() const
Returns true if the alarm has a trigger date/time.
Definition: alarm.cpp:582
KCalCore::Alarm::previousRepetition
KDateTime previousRepetition(const KDateTime &afterTime) const
Returns the date/time of the alarm&#39;s latest repetition or, if none, its initial occurrence before a g...
Definition: alarm.cpp:670
KCalCore::Alarm::setProgramFile
void setProgramFile(const QString &programFile)
Sets the program file to execute when the alarm is triggered.
Definition: alarm.cpp:279
KCalCore::Duration::end
KDateTime end(const KDateTime &start) const
Computes a duration end time by adding the number of seconds or days in the duration to the specified...
Definition: duration.cpp:184
KCalCore::Alarm::setText
void setText(const QString &text)
Sets the description text to be displayed when the alarm is triggered.
Definition: alarm.cpp:472
KCalCore::CustomProperties::setNonKDECustomProperty
void setNonKDECustomProperty(const QByteArray &name, const QString &value, const QString &parameters=QString())
Create or modify a non-KDE or non-standard custom calendar property.
Definition: customproperties.cpp:155
KCalCore::Alarm::hasEndOffset
bool hasEndOffset() const
Returns whether the alarm is defined in terms of an offset relative to the end of the event...
Definition: alarm.cpp:761
KCalCore::Alarm::addMailAddress
void addMailAddress(const Person::Ptr &mailAlarmAddress)
Adds an address to the list of email addresses to send mail to when the alarm is triggered.
Definition: alarm.cpp:359
KCalCore::Alarm::snoozeTime
Duration snoozeTime() const
Returns the snooze time interval.
Definition: alarm.cpp:613
KCalCore::Alarm::text
QString text() const
Returns the display text string for a Display alarm type.
Definition: alarm.cpp:485
KCalCore::Alarm::setMailAttachment
void setMailAttachment(const QString &mailAttachFile)
Sets the filename to attach to a mail message for an Email alarm type.
Definition: alarm.cpp:395
KCalCore::Alarm::setMailText
void setMailText(const QString &text)
Sets the body text for an Email alarm type.
Definition: alarm.cpp:440
KCalCore::Alarm::Alarm
Alarm(Incidence *parent)
Constructs an alarm belonging to the parent Incidence.
Definition: alarm.cpp:105
KCalCore::Alarm::setEndOffset
void setEndOffset(const Duration &offset)
Sets the alarm offset relative to the end of the parent Incidence.
Definition: alarm.cpp:766
KCalCore::Alarm::customPropertyUpdated
virtual void customPropertyUpdated()
Definition: alarm.cpp:794
KCalCore::Alarm::Display
Display a dialog box.
Definition: alarm.h:67
KCalCore::Alarm::mailAttachments
QStringList mailAttachments() const
Returns the list of attachment filenames for an Email alarm type.
Definition: alarm.cpp:435
KCalCore::Alarm::setTime
void setTime(const KDateTime &alarmTime)
Sets the trigger time of the alarm.
Definition: alarm.cpp:490
KCalCore::Alarm::setStartOffset
void setStartOffset(const Duration &offset)
Sets the alarm offset relative to the start of the parent Incidence.
Definition: alarm.cpp:738
KCalCore::IncidenceBase::RoleAlarmEndOffset
Role for an incidence alarm&#39;s ending offset date/time.
Definition: incidencebase.h:133
KCalCore::Duration::value
int value() const
Returns the length of the duration in seconds or days.
Definition: duration.cpp:210
KCalCore::Alarm::Invalid
Invalid, or no alarm.
Definition: alarm.h:66
duration.h
This file is part of the API for handling calendar data and defines the Duration class.
KCalCore::Alarm::setAudioAlarm
void setAudioAlarm(const QString &audioFile=QString())
Sets the Audio type for this alarm and the name of the audio file to play when the alarm is triggered...
Definition: alarm.cpp:235
alarm.h
This file is part of the API for handling calendar data and defines the Alarm class.
KCalCore::Alarm::endTime
KDateTime endTime() const
Returns the date/time when the last repetition of the alarm goes off.
Definition: alarm.cpp:699
KCalCore::Person::Ptr
QSharedPointer< Person > Ptr
A shared pointer to a Person object.
Definition: person.h:56
KCalCore::Alarm::addMailAttachment
void addMailAttachment(const QString &mailAttachFile)
Adds a filename to the list of files to attach to a mail message for an Email alarm type...
Definition: alarm.cpp:422
KCalCore::Alarm::enabled
bool enabled() const
Returns the alarm enabled status: true (enabled) or false (disabled).
Definition: alarm.cpp:733
KCalCore::Alarm::setMailAttachments
void setMailAttachments(const QStringList &mailAttachFiles)
Sets a list of filenames to attach to a mail message for an Email alarm type.
Definition: alarm.cpp:409
KCalCore::Alarm::type
Type type() const
Returns the Type of the alarm.
Definition: alarm.cpp:230
KCalCore::CustomProperties
A class to manage custom calendar properties.
Definition: customproperties.h:51
KCalCore::Alarm::setMailAddress
void setMailAddress(const Person::Ptr &mailAlarmAddress)
Sets the email address of an Email type alarm.
Definition: alarm.cpp:332
KCalCore::Alarm::Email
Send email.
Definition: alarm.h:69
KCalCore::Alarm::Procedure
Call a script.
Definition: alarm.h:68
incidence.h
This file is part of the API for handling calendar data and defines the Incidence class...
KCalCore::Alarm::time
KDateTime time() const
Returns the alarm trigger date/time.
Definition: alarm.cpp:503
KCalCore::Alarm::mailSubject
QString mailSubject() const
Returns the subject line string for an Email alarm type.
Definition: alarm.cpp:390
KCalCore::Alarm::Audio
Play an audio file.
Definition: alarm.h:70
KCalCore::Alarm::hasLocationRadius
bool hasLocationRadius() const
Returns true if alarm has location radius defined.
Definition: alarm.cpp:818
KCalCore::Alarm::repeatCount
int repeatCount() const
Returns how many times an alarm may repeats after its initial occurrence.
Definition: alarm.cpp:629
KCalCore::Alarm::setDisplayAlarm
void setDisplayAlarm(const QString &text=QString())
Sets the Display type for this alarm.
Definition: alarm.cpp:458
KCalCore::Alarm::mailAddresses
Person::List mailAddresses() const
Returns the list of addresses for an Email alarm type.
Definition: alarm.cpp:372
KCalCore::Alarm::mailText
QString mailText() const
Returns the body text for an Email alarm type.
Definition: alarm.cpp:453
KCalCore::Alarm::toggleAlarm
void toggleAlarm()
Toggles the alarm status, i.e, an enable alarm becomes disabled and a disabled alarm becomes enabled...
Definition: alarm.cpp:711
KCalCore::Alarm::setHasLocationRadius
void setHasLocationRadius(bool hasLocationRadius)
Set if the location radius for the alarm has been defined.
Definition: alarm.cpp:802
KCalCore::IncidenceBase::RoleAlarmStartOffset
Role for an incidence alarm&#39;s starting offset date/time.
Definition: incidencebase.h:132
KCalCore::Alarm::programArguments
QString programArguments() const
Returns the program arguments string for a Procedure alarm type.
Definition: alarm.cpp:310
KCalCore::Alarm::setMailSubject
void setMailSubject(const QString &mailAlarmSubject)
Sets the subject line of a mail message for an Email alarm type.
Definition: alarm.cpp:377
KCalCore::Alarm::setMailAddresses
void setMailAddresses(const Person::List &mailAlarmAddresses)
Sets a list of email addresses of an Email type alarm.
Definition: alarm.cpp:346
KCalCore::Alarm::setProgramArguments
void setProgramArguments(const QString &arguments)
Sets the program arguments string when the alarm is triggered.
Definition: alarm.cpp:297
KCalCore::Alarm::audioFile
QString audioFile() const
Returns the audio file name for an Audio alarm type.
Definition: alarm.cpp:260
KCalCore::Incidence
Provides the abstract base class common to non-FreeBusy (Events, To-dos, Journals) calendar component...
Definition: incidence.h:68
KCalCore::Alarm::endOffset
Duration endOffset() const
Returns offset of alarm in time relative to the end of the event.
Definition: alarm.cpp:779
KCalCore::Alarm::locationRadius
int locationRadius() const
Returns the location radius in meters.
Definition: alarm.cpp:834
KCalCore::Alarm::programFile
QString programFile() const
Returns the program file name for a Procedure alarm type.
Definition: alarm.cpp:292
KCalCore::Alarm::setLocationRadius
void setLocationRadius(int locationRadius)
Set location radius for the alarm.
Definition: alarm.cpp:823
This file is part of the KDE documentation.
Documentation copyright © 1996-2013 The KDE developers.
Generated on Tue Nov 26 2013 09:02:03 by doxygen 1.8.5 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KCalCore Library

Skip menu "KCalCore Library"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdepimlibs-4.11.3 API Reference

Skip menu "kdepimlibs-4.11.3 API Reference"
  • akonadi
  •   contact
  •   kmime
  •   socialutils
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmbox
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal