summaryrefslogtreecommitdiffabout
path: root/libkcal/alarm.cpp
Unidiff
Diffstat (limited to 'libkcal/alarm.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/alarm.cpp36
1 files changed, 35 insertions, 1 deletions
diff --git a/libkcal/alarm.cpp b/libkcal/alarm.cpp
index 29e6205..1fc7169 100644
--- a/libkcal/alarm.cpp
+++ b/libkcal/alarm.cpp
@@ -1,131 +1,165 @@
1/* 1/*
2 This file is part of libkcal. 2 This file is part of libkcal.
3 Copyright (c) 1998 Preston Brown 3 Copyright (c) 1998 Preston Brown
4 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 4 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
5 5
6 This library is free software; you can redistribute it and/or 6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public 7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either 8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version. 9 version 2 of the License, or (at your option) any later version.
10 10
11 This library is distributed in the hope that it will be useful, 11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details. 14 Library General Public License for more details.
15 15
16 You should have received a copy of the GNU Library General Public License 16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to 17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. 19 Boston, MA 02111-1307, USA.
20*/ 20*/
21 21
22#include <kdebug.h> 22#include <kdebug.h>
23 23
24#include "incidence.h" 24#include "incidence.h"
25#include "todo.h" 25#include "todo.h"
26 26
27#include "alarm.h" 27#include "alarm.h"
28 28
29using namespace KCal; 29using namespace KCal;
30#include <qwidget.h> 30#include <qwidget.h>
31Alarm::Alarm(Incidence *parent) 31Alarm::Alarm(Incidence *parent)
32 : mParent(parent), 32 : mParent(parent),
33 mType(Audio), 33 mType(Audio),
34 mDescription(""), // to make operator==() not fail 34 mDescription(""), // to make operator==() not fail
35 mFile(""), // to make operator==() not fail 35 mFile(""), // to make operator==() not fail
36 mMailSubject(""), // to make operator==() not fail 36 mMailSubject(""), // to make operator==() not fail
37 mAlarmSnoozeTime(5), 37 mAlarmSnoozeTime(5),
38 mAlarmRepeatCount(0), 38 mAlarmRepeatCount(0),
39 mEndOffset(false), 39 mEndOffset(false),
40 mHasTime(false), 40 mHasTime(false),
41 mAlarmEnabled(false) 41 mAlarmEnabled(false)
42{ 42{
43 43
44} 44}
45 45
46Alarm::~Alarm() 46Alarm::~Alarm()
47{ 47{
48} 48}
49 49
50bool Alarm::operator==( const Alarm& rhs ) const 50bool Alarm::operator==( const Alarm& rhs ) const
51{ 51{
52
52 if ( mType != rhs.mType || 53 if ( mType != rhs.mType ||
53 mAlarmSnoozeTime != rhs.mAlarmSnoozeTime || 54 mAlarmSnoozeTime != rhs.mAlarmSnoozeTime ||
54 mAlarmRepeatCount != rhs.mAlarmRepeatCount || 55 mAlarmRepeatCount != rhs.mAlarmRepeatCount ||
55 mAlarmEnabled != rhs.mAlarmEnabled || 56 mAlarmEnabled != rhs.mAlarmEnabled ||
56 mHasTime != rhs.mHasTime) 57 mHasTime != rhs.mHasTime)
57 return false; 58 return false;
58 59
60#if 0
61 if ( mType != rhs.mType ) {
62
63 qDebug("aaa1 ");
64 return false;
65 }
66
67 if ( mAlarmSnoozeTime != rhs.mAlarmSnoozeTime ) {
68
69 qDebug("aaa2 ");
70 return false;
71 }
72
73
74 if ( mAlarmRepeatCount != rhs.mAlarmRepeatCount ) {
75
76 qDebug("aaa3 ");
77 return false;
78 }
79
80 if ( mAlarmEnabled != rhs.mAlarmEnabled ) {
81
82 qDebug("aaa4 ");
83 return false;
84 }
85
86 if ( mHasTime != rhs.mHasTime ) {
87
88 qDebug("aaa5 ");
89 return false;
90 }
91#endif
92
93
59 if (mHasTime) { 94 if (mHasTime) {
60 if (mAlarmTime != rhs.mAlarmTime) 95 if (mAlarmTime != rhs.mAlarmTime)
61 return false; 96 return false;
62 } else { 97 } else {
63 if (mOffset != rhs.mOffset || 98 if (mOffset != rhs.mOffset ||
64 mEndOffset != rhs.mEndOffset) 99 mEndOffset != rhs.mEndOffset)
65 return false; 100 return false;
66 } 101 }
67
68 switch (mType) { 102 switch (mType) {
69 case Display: 103 case Display:
70 return mDescription == rhs.mDescription; 104 return mDescription == rhs.mDescription;
71 105
72 case Email: 106 case Email:
73 return mDescription == rhs.mDescription && 107 return mDescription == rhs.mDescription &&
74 mMailAttachFiles == rhs.mMailAttachFiles && 108 mMailAttachFiles == rhs.mMailAttachFiles &&
75 mMailAddresses == rhs.mMailAddresses && 109 mMailAddresses == rhs.mMailAddresses &&
76 mMailSubject == rhs.mMailSubject; 110 mMailSubject == rhs.mMailSubject;
77 111
78 case Procedure: 112 case Procedure:
79 return mFile == rhs.mFile && 113 return mFile == rhs.mFile &&
80 mDescription == rhs.mDescription; 114 mDescription == rhs.mDescription;
81 115
82 case Audio: 116 case Audio:
83 return mFile == rhs.mFile; 117 return mFile == rhs.mFile;
84 118
85 case Invalid: 119 case Invalid:
86 break; 120 break;
87 } 121 }
88 return false; 122 return false;
89} 123}
90 124
91void Alarm::setType(Alarm::Type type) 125void Alarm::setType(Alarm::Type type)
92{ 126{
93 if (type == mType) 127 if (type == mType)
94 return; 128 return;
95 129
96 switch (type) { 130 switch (type) {
97 case Display: 131 case Display:
98 mDescription = ""; 132 mDescription = "";
99 break; 133 break;
100 case Procedure: 134 case Procedure:
101 mFile = mDescription = ""; 135 mFile = mDescription = "";
102 break; 136 break;
103 case Audio: 137 case Audio:
104 mFile = ""; 138 mFile = "";
105 break; 139 break;
106 case Email: 140 case Email:
107 mMailSubject = mDescription = ""; 141 mMailSubject = mDescription = "";
108 mMailAddresses.clear(); 142 mMailAddresses.clear();
109 mMailAttachFiles.clear(); 143 mMailAttachFiles.clear();
110 break; 144 break;
111 case Invalid: 145 case Invalid:
112 break; 146 break;
113 default: 147 default:
114 return; 148 return;
115 } 149 }
116 mType = type; 150 mType = type;
117 mParent->updated(); 151 mParent->updated();
118} 152}
119 153
120Alarm::Type Alarm::type() const 154Alarm::Type Alarm::type() const
121{ 155{
122 return mType; 156 return mType;
123} 157}
124 158
125void Alarm::setAudioAlarm(const QString &audioFile) 159void Alarm::setAudioAlarm(const QString &audioFile)
126{ 160{
127 mType = Audio; 161 mType = Audio;
128 mFile = audioFile; 162 mFile = audioFile;
129 mParent->updated(); 163 mParent->updated();
130} 164}
131 165