summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-04-08 10:54:05 (UTC)
committer zautrix <zautrix>2005-04-08 10:54:05 (UTC)
commit59fb8a0ac35bf3b81f1c4e2e4fc6b61356d064ef (patch) (unidiff)
treeab604082029c081fa8725c5535a51a23bb963ef2
parentc82f9b40f6023dc7b39ac555cba8c4c313f15ca8 (diff)
downloadkdepimpi-59fb8a0ac35bf3b81f1c4e2e4fc6b61356d064ef.zip
kdepimpi-59fb8a0ac35bf3b81f1c4e2e4fc6b61356d064ef.tar.gz
kdepimpi-59fb8a0ac35bf3b81f1c4e2e4fc6b61356d064ef.tar.bz2
fixes
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addressee.cpp17
-rw-r--r--kabc/addressee.h3
-rw-r--r--kabc/field.cpp6
-rw-r--r--kalarmd/simplealarmdaemonimpl.cpp2
-rw-r--r--korganizer/koagendaitem.cpp28
-rw-r--r--korganizer/komonthview.cpp21
6 files changed, 36 insertions, 41 deletions
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp
index 7f592e9..155ce24 100644
--- a/kabc/addressee.cpp
+++ b/kabc/addressee.cpp
@@ -1,2222 +1,2205 @@
1/*** Warning! This file has been generated by the script makeaddressee ***/ 1/*** Warning! This file has been generated by the script makeaddressee ***/
2/* 2/*
3 This file is part of libkabc. 3 This file is part of libkabc.
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/* 22/*
23Enhanced Version of the file for platform independent KDE tools. 23Enhanced Version of the file for platform independent KDE tools.
24Copyright (c) 2004 Ulf Schenk 24Copyright (c) 2004 Ulf Schenk
25 25
26$Id$ 26$Id$
27*/ 27*/
28 28
29#include <kconfig.h> 29#include <kconfig.h>
30 30
31#include <ksharedptr.h> 31#include <ksharedptr.h>
32#include <kdebug.h> 32#include <kdebug.h>
33#include <kapplication.h> 33#include <kapplication.h>
34#include <klocale.h> 34#include <klocale.h>
35#include <kidmanager.h> 35#include <kidmanager.h>
36//US 36//US
37#include <kstandarddirs.h> 37#include <kstandarddirs.h>
38#include <libkcal/syncdefines.h> 38#include <libkcal/syncdefines.h>
39 39
40//US #include "resource.h" 40//US #include "resource.h"
41#include "addressee.h" 41#include "addressee.h"
42 42
43using namespace KABC; 43using namespace KABC;
44 44
45static bool matchBinaryPattern( int value, int pattern ); 45static bool matchBinaryPattern( int value, int pattern );
46static bool matchBinaryPatternA( int value, int pattern ); 46static bool matchBinaryPatternA( int value, int pattern );
47static bool matchBinaryPatternP( int value, int pattern ); 47static bool matchBinaryPatternP( int value, int pattern );
48 48
49struct Addressee::AddresseeData : public KShared 49struct Addressee::AddresseeData : public KShared
50{ 50{
51 QString uid; 51 QString uid;
52 QString name; 52 QString name;
53 QString formattedName; 53 QString formattedName;
54 QString defaultFormattedName;
55 QString familyName; 54 QString familyName;
56 QString givenName; 55 QString givenName;
57 QString additionalName; 56 QString additionalName;
58 QString prefix; 57 QString prefix;
59 QString suffix; 58 QString suffix;
60 QString nickName; 59 QString nickName;
61 QDateTime birthday; 60 QDateTime birthday;
62 QString mailer; 61 QString mailer;
63 TimeZone timeZone; 62 TimeZone timeZone;
64 Geo geo; 63 Geo geo;
65 QString title; 64 QString title;
66 QString role; 65 QString role;
67 QString organization; 66 QString organization;
68 QString note; 67 QString note;
69 QString productId; 68 QString productId;
70 QDateTime revision; 69 QDateTime revision;
71 QString sortString; 70 QString sortString;
72 QString externalUID; 71 QString externalUID;
73 QString originalExternalUID; 72 QString originalExternalUID;
74 KURL url; 73 KURL url;
75 Secrecy secrecy; 74 Secrecy secrecy;
76 Picture logo; 75 Picture logo;
77 Picture photo; 76 Picture photo;
78 Sound sound; 77 Sound sound;
79 Agent agent; 78 Agent agent;
80 QString mExternalId; 79 QString mExternalId;
81 PhoneNumber::List phoneNumbers; 80 PhoneNumber::List phoneNumbers;
82 Address::List addresses; 81 Address::List addresses;
83 Key::List keys; 82 Key::List keys;
84 QStringList emails; 83 QStringList emails;
85 QStringList categories; 84 QStringList categories;
86 QStringList custom; 85 QStringList custom;
87 int mTempSyncStat; 86 int mTempSyncStat;
88 Resource *resource; 87 Resource *resource;
89 88
90 bool empty :1; 89 bool empty :1;
91 bool changed :1; 90 bool changed :1;
92 bool tagged :1; 91 bool tagged :1;
93}; 92};
94 93
95Addressee::Addressee() 94Addressee::Addressee()
96{ 95{
97 mData = new AddresseeData; 96 mData = new AddresseeData;
98 mData->empty = true; 97 mData->empty = true;
99 mData->changed = false; 98 mData->changed = false;
100 mData->resource = 0; 99 mData->resource = 0;
101 mData->mExternalId = ":"; 100 mData->mExternalId = ":";
102 mData->revision = QDateTime ( QDate( 2003,1,1)); 101 mData->revision = QDateTime ( QDate( 2003,1,1));
103 mData->mTempSyncStat = SYNC_TEMPSTATE_INITIAL; 102 mData->mTempSyncStat = SYNC_TEMPSTATE_INITIAL;
104} 103}
105 104
106Addressee::~Addressee() 105Addressee::~Addressee()
107{ 106{
108} 107}
109 108
110Addressee::Addressee( const Addressee &a ) 109Addressee::Addressee( const Addressee &a )
111{ 110{
112 mData = a.mData; 111 mData = a.mData;
113} 112}
114 113
115Addressee &Addressee::operator=( const Addressee &a ) 114Addressee &Addressee::operator=( const Addressee &a )
116{ 115{
117 mData = a.mData; 116 mData = a.mData;
118 return (*this); 117 return (*this);
119} 118}
120 119
121Addressee Addressee::copy() 120Addressee Addressee::copy()
122{ 121{
123 Addressee a; 122 Addressee a;
124 *(a.mData) = *mData; 123 *(a.mData) = *mData;
125 return a; 124 return a;
126} 125}
127 126
128void Addressee::detach() 127void Addressee::detach()
129{ 128{
130 if ( mData.count() == 1 ) return; 129 if ( mData.count() == 1 ) return;
131 *this = copy(); 130 *this = copy();
132} 131}
133 132
134bool Addressee::operator==( const Addressee &a ) const 133bool Addressee::operator==( const Addressee &a ) const
135{ 134{
136 if ( uid() != a.uid() ) return false; 135 if ( uid() != a.uid() ) return false;
137 if ( mData->name != a.mData->name ) return false; 136 if ( mData->name != a.mData->name ) return false;
138 if ( mData->formattedName != a.mData->formattedName ) return false; 137 if ( mData->formattedName != a.mData->formattedName ) return false;
139 if ( mData->familyName != a.mData->familyName ) return false; 138 if ( mData->familyName != a.mData->familyName ) return false;
140 if ( mData->givenName != a.mData->givenName ) return false; 139 if ( mData->givenName != a.mData->givenName ) return false;
141 if ( mData->additionalName != a.mData->additionalName ) return false; 140 if ( mData->additionalName != a.mData->additionalName ) return false;
142 if ( mData->prefix != a.mData->prefix ) return false; 141 if ( mData->prefix != a.mData->prefix ) return false;
143 if ( mData->suffix != a.mData->suffix ) return false; 142 if ( mData->suffix != a.mData->suffix ) return false;
144 if ( mData->nickName != a.mData->nickName ) return false; 143 if ( mData->nickName != a.mData->nickName ) return false;
145 if ( mData->birthday != a.mData->birthday ) return false; 144 if ( mData->birthday != a.mData->birthday ) return false;
146 if ( mData->mailer != a.mData->mailer ) return false; 145 if ( mData->mailer != a.mData->mailer ) return false;
147 if ( mData->timeZone != a.mData->timeZone ) return false; 146 if ( mData->timeZone != a.mData->timeZone ) return false;
148 if ( mData->geo != a.mData->geo ) return false; 147 if ( mData->geo != a.mData->geo ) return false;
149 if ( mData->title != a.mData->title ) return false; 148 if ( mData->title != a.mData->title ) return false;
150 if ( mData->role != a.mData->role ) return false; 149 if ( mData->role != a.mData->role ) return false;
151 if ( mData->organization != a.mData->organization ) return false; 150 if ( mData->organization != a.mData->organization ) return false;
152 if ( mData->note != a.mData->note ) return false; 151 if ( mData->note != a.mData->note ) return false;
153 if ( mData->productId != a.mData->productId ) return false; 152 if ( mData->productId != a.mData->productId ) return false;
154 //if ( mData->revision != a.mData->revision ) return false; 153 //if ( mData->revision != a.mData->revision ) return false;
155 if ( mData->sortString != a.mData->sortString ) return false; 154 if ( mData->sortString != a.mData->sortString ) return false;
156 if ( mData->secrecy != a.mData->secrecy ) return false; 155 if ( mData->secrecy != a.mData->secrecy ) return false;
157 if ( mData->logo != a.mData->logo ) return false; 156 if ( mData->logo != a.mData->logo ) return false;
158 if ( mData->photo != a.mData->photo ) return false; 157 if ( mData->photo != a.mData->photo ) return false;
159 if ( mData->sound != a.mData->sound ) return false; 158 if ( mData->sound != a.mData->sound ) return false;
160 if ( mData->agent != a.mData->agent ) return false; 159 if ( mData->agent != a.mData->agent ) return false;
161 if ( ( mData->url.isValid() || a.mData->url.isValid() ) && 160 if ( ( mData->url.isValid() || a.mData->url.isValid() ) &&
162 ( mData->url != a.mData->url ) ) return false; 161 ( mData->url != a.mData->url ) ) return false;
163 if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false; 162 if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false;
164 if ( mData->addresses != a.mData->addresses ) return false; 163 if ( mData->addresses != a.mData->addresses ) return false;
165 if ( mData->keys != a.mData->keys ) return false; 164 if ( mData->keys != a.mData->keys ) return false;
166 if ( mData->emails != a.mData->emails ) return false; 165 if ( mData->emails != a.mData->emails ) return false;
167 if ( mData->categories != a.mData->categories ) return false; 166 if ( mData->categories != a.mData->categories ) return false;
168 if ( mData->custom != a.mData->custom ) return false; 167 if ( mData->custom != a.mData->custom ) return false;
169 168
170 return true; 169 return true;
171} 170}
172 171
173bool Addressee::operator!=( const Addressee &a ) const 172bool Addressee::operator!=( const Addressee &a ) const
174{ 173{
175 return !( a == *this ); 174 return !( a == *this );
176} 175}
177 176
178bool Addressee::isEmpty() const 177bool Addressee::isEmpty() const
179{ 178{
180 return mData->empty; 179 return mData->empty;
181} 180}
182ulong Addressee::getCsum4List( const QStringList & attList) 181ulong Addressee::getCsum4List( const QStringList & attList)
183{ 182{
184 int max = attList.count(); 183 int max = attList.count();
185 ulong cSum = 0; 184 ulong cSum = 0;
186 int j,k,i; 185 int j,k,i;
187 int add; 186 int add;
188 for ( i = 0; i < max ; ++i ) { 187 for ( i = 0; i < max ; ++i ) {
189 QString s = attList[i]; 188 QString s = attList[i];
190 if ( ! s.isEmpty() ){ 189 if ( ! s.isEmpty() ){
191 j = s.length(); 190 j = s.length();
192 for ( k = 0; k < j; ++k ) { 191 for ( k = 0; k < j; ++k ) {
193 int mul = k +1; 192 int mul = k +1;
194 add = s[k].unicode (); 193 add = s[k].unicode ();
195 if ( k < 16 ) 194 if ( k < 16 )
196 mul = mul * mul; 195 mul = mul * mul;
197 int ii = i+1; 196 int ii = i+1;
198 add = add * mul *ii*ii*ii; 197 add = add * mul *ii*ii*ii;
199 cSum += add; 198 cSum += add;
200 //qDebug("csum: %d %d %d", i,k,cSum); 199 //qDebug("csum: %d %d %d", i,k,cSum);
201 } 200 }
202 } 201 }
203 202
204 } 203 }
205 //QString dump = attList.join(","); 204 //QString dump = attList.join(",");
206 //qDebug("csum: %d %s", cSum,dump.latin1()); 205 //qDebug("csum: %d %s", cSum,dump.latin1());
207 206
208 return cSum; 207 return cSum;
209 208
210} 209}
211void Addressee::computeCsum(const QString &dev) 210void Addressee::computeCsum(const QString &dev)
212{ 211{
213 QStringList l; 212 QStringList l;
214 //if ( !mData->name.isEmpty() ) l.append(mData->name); 213 //if ( !mData->name.isEmpty() ) l.append(mData->name);
215 //if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName ); 214 //if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName );
216 if ( !mData->familyName.isEmpty() ) l.append( mData->familyName ); 215 if ( !mData->familyName.isEmpty() ) l.append( mData->familyName );
217 if ( !mData->givenName.isEmpty() ) l.append(mData->givenName ); 216 if ( !mData->givenName.isEmpty() ) l.append(mData->givenName );
218 if ( !mData->additionalName.isEmpty() ) l.append( mData->additionalName ); 217 if ( !mData->additionalName.isEmpty() ) l.append( mData->additionalName );
219 if ( !mData->prefix.isEmpty() ) l.append( mData->prefix ); 218 if ( !mData->prefix.isEmpty() ) l.append( mData->prefix );
220 if ( !mData->suffix.isEmpty() ) l.append( mData->suffix ); 219 if ( !mData->suffix.isEmpty() ) l.append( mData->suffix );
221 if ( !mData->nickName.isEmpty() ) l.append( mData->nickName ); 220 if ( !mData->nickName.isEmpty() ) l.append( mData->nickName );
222 if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() ); 221 if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() );
223 if ( !mData->mailer.isEmpty() ) l.append( mData->mailer ); 222 if ( !mData->mailer.isEmpty() ) l.append( mData->mailer );
224 if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() ); 223 if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() );
225 if ( mData->geo.isValid() ) l.append( mData->geo.asString() ); 224 if ( mData->geo.isValid() ) l.append( mData->geo.asString() );
226 if ( !mData->title .isEmpty() ) l.append( mData->title ); 225 if ( !mData->title .isEmpty() ) l.append( mData->title );
227 if ( !mData->role.isEmpty() ) l.append( mData->role ); 226 if ( !mData->role.isEmpty() ) l.append( mData->role );
228 if ( !mData->organization.isEmpty() ) l.append( mData->organization ); 227 if ( !mData->organization.isEmpty() ) l.append( mData->organization );
229 if ( !mData->note.isEmpty() ) l.append( mData->note ); 228 if ( !mData->note.isEmpty() ) l.append( mData->note );
230 if ( !mData->productId.isEmpty() ) l.append(mData->productId ); 229 if ( !mData->productId.isEmpty() ) l.append(mData->productId );
231 if ( !mData->sortString.isEmpty() ) l.append( mData->sortString ); 230 if ( !mData->sortString.isEmpty() ) l.append( mData->sortString );
232 if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString()); 231 if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString());
233 if ( !mData->logo.undefined() ) { 232 if ( !mData->logo.undefined() ) {
234 if ( !mData->logo.isIntern() ) 233 if ( !mData->logo.isIntern() )
235 l.append( mData->logo.url() ); 234 l.append( mData->logo.url() );
236 else 235 else
237 l.append( QString::number(mData->logo.data().width()* mData->logo.data().height())); 236 l.append( QString::number(mData->logo.data().width()* mData->logo.data().height()));
238 } else { 237 } else {
239 l.append( "nologo"); 238 l.append( "nologo");
240 } 239 }
241 if ( !mData->photo.undefined() ) { 240 if ( !mData->photo.undefined() ) {
242 if ( !mData->photo.isIntern() ) 241 if ( !mData->photo.isIntern() )
243 l.append( mData->photo.url() ); 242 l.append( mData->photo.url() );
244 else 243 else
245 l.append( QString::number(mData->photo.data().width()* mData->photo.data().height())); 244 l.append( QString::number(mData->photo.data().width()* mData->photo.data().height()));
246 } else { 245 } else {
247 l.append( "nophoto"); 246 l.append( "nophoto");
248 } 247 }
249#if 0 248#if 0
250 if ( !mData->sound.undefined() ) { 249 if ( !mData->sound.undefined() ) {
251 if ( !mData->sound.isIntern() ) 250 if ( !mData->sound.isIntern() )
252 l.append( mData->sound.url() ); 251 l.append( mData->sound.url() );
253 else 252 else
254 l.append( QString(mData->sound.data().with()* mData->sound.data().height())); 253 l.append( QString(mData->sound.data().with()* mData->sound.data().height()));
255 } else { 254 } else {
256 l.append( "nosound"); 255 l.append( "nosound");
257 } 256 }
258#endif 257#endif
259 //if ( !mData->agent.isEmpty() ) l.append( ); 258 //if ( !mData->agent.isEmpty() ) l.append( );
260 if ( mData->url.isValid() ) 259 if ( mData->url.isValid() )
261 if ( ! mData->url.path().isEmpty()) l.append( mData->url.path() ); 260 if ( ! mData->url.path().isEmpty()) l.append( mData->url.path() );
262 KABC::PhoneNumber::List phoneNumbers; 261 KABC::PhoneNumber::List phoneNumbers;
263 KABC::PhoneNumber::List::Iterator phoneIter; 262 KABC::PhoneNumber::List::Iterator phoneIter;
264 263
265 QStringList t; 264 QStringList t;
266 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 265 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
267 ++phoneIter ) 266 ++phoneIter )
268 t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) ); 267 t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) );
269 t.sort(); 268 t.sort();
270 uint iii; 269 uint iii;
271 for ( iii = 0; iii < t.count(); ++iii) 270 for ( iii = 0; iii < t.count(); ++iii)
272 l.append( t[iii] ); 271 l.append( t[iii] );
273 t = mData->emails; 272 t = mData->emails;
274 t.sort(); 273 t.sort();
275 for ( iii = 0; iii < t.count(); ++iii) 274 for ( iii = 0; iii < t.count(); ++iii)
276 l.append( t[iii] ); 275 l.append( t[iii] );
277 t = mData->categories; 276 t = mData->categories;
278 t.sort(); 277 t.sort();
279 for ( iii = 0; iii < t.count(); ++iii) 278 for ( iii = 0; iii < t.count(); ++iii)
280 l.append( t[iii] ); 279 l.append( t[iii] );
281 t = mData->custom; 280 t = mData->custom;
282 t.sort(); 281 t.sort();
283 for ( iii = 0; iii < t.count(); ++iii) 282 for ( iii = 0; iii < t.count(); ++iii)
284 if ( t[iii].left( 25 ) != "KADDRESSBOOK-X-ExternalID" ) { 283 if ( t[iii].left( 25 ) != "KADDRESSBOOK-X-ExternalID" ) {
285 int find = t[iii].find (':')+1; 284 int find = t[iii].find (':')+1;
286 //qDebug("lennnn %d %d ", find, t[iii].length()); 285 //qDebug("lennnn %d %d ", find, t[iii].length());
287 if ( find < t[iii].length()) 286 if ( find < t[iii].length())
288 l.append( t[iii] ); 287 l.append( t[iii] );
289 288
290 } 289 }
291 KABC::Address::List::Iterator addressIter; 290 KABC::Address::List::Iterator addressIter;
292 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); 291 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end();
293 ++addressIter ) { 292 ++addressIter ) {
294 t = (*addressIter).asList(); 293 t = (*addressIter).asList();
295 t.sort(); 294 t.sort();
296 for ( iii = 0; iii < t.count(); ++iii) 295 for ( iii = 0; iii < t.count(); ++iii)
297 l.append( t[iii] ); 296 l.append( t[iii] );
298 } 297 }
299 uint cs = getCsum4List(l); 298 uint cs = getCsum4List(l);
300 299
301#if 0 300#if 0
302 for ( iii = 0; iii < l.count(); ++iii) 301 for ( iii = 0; iii < l.count(); ++iii)
303 qDebug("%d***%s***",iii,l[iii].latin1()); 302 qDebug("%d***%s***",iii,l[iii].latin1());
304 qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); 303 qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() );
305#endif 304#endif
306 305
307 306
308 setCsum( dev, QString::number (cs )); 307 setCsum( dev, QString::number (cs ));
309} 308}
310 309
311void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false) 310void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false)
312{ 311{
313 // merge all standard non-outlook fields. 312 // merge all standard non-outlook fields.
314 //if isSubSet (e.g. mobile phone sync) merge all fields 313 //if isSubSet (e.g. mobile phone sync) merge all fields
315 314
316 detach(); 315 detach();
317 if ( isSubSet ) { 316 if ( isSubSet ) {
318 if ( mData->name.isEmpty() ) mData->name = ad.mData->name; 317 if ( mData->name.isEmpty() ) mData->name = ad.mData->name;
319 if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName; 318 if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName;
320 if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName; 319 if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName;
321 if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ; 320 if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ;
322 if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName; 321 if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName;
323 if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix; 322 if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix;
324 if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix; 323 if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix;
325 if ( mData->title .isEmpty() ) mData->title = ad.mData->title ; 324 if ( mData->title .isEmpty() ) mData->title = ad.mData->title ;
326 if ( mData->role.isEmpty() ) mData->role = ad.mData->role ; 325 if ( mData->role.isEmpty() ) mData->role = ad.mData->role ;
327 if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName; 326 if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName;
328 if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ; 327 if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ;
329 if ( mData->note.isEmpty() ) mData->note = ad.mData->note ; 328 if ( mData->note.isEmpty() ) mData->note = ad.mData->note ;
330 if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy; 329 if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy;
331 if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ; 330 if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ;
332 if ( !mData->birthday.isValid() ) 331 if ( !mData->birthday.isValid() )
333 if ( ad.mData->birthday.isValid()) 332 if ( ad.mData->birthday.isValid())
334 mData->birthday = ad.mData->birthday; 333 mData->birthday = ad.mData->birthday;
335 334
336 } 335 }
337 if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer; 336 if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer;
338 if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone; 337 if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone;
339 if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo; 338 if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo;
340 if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId; 339 if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId;
341 if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString; 340 if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString;
342 QStringList t; 341 QStringList t;
343 QStringList tAD; 342 QStringList tAD;
344 uint iii; 343 uint iii;
345 344
346 // ********** phone numbers 345 // ********** phone numbers
347 if ( isSubSet ) { 346 if ( isSubSet ) {
348 PhoneNumber::List phoneAD = ad.phoneNumbers(); 347 PhoneNumber::List phoneAD = ad.phoneNumbers();
349 PhoneNumber::List::Iterator phoneItAD; 348 PhoneNumber::List::Iterator phoneItAD;
350 for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) { 349 for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) {
351 bool found = false; 350 bool found = false;
352 PhoneNumber::List::Iterator it; 351 PhoneNumber::List::Iterator it;
353 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 352 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
354 if ( ( *phoneItAD ).contains( (*it) ) ) { 353 if ( ( *phoneItAD ).contains( (*it) ) ) {
355 found = true; 354 found = true;
356 (*it).setType( ( *phoneItAD ).type() ); 355 (*it).setType( ( *phoneItAD ).type() );
357 (*it).setNumber( ( *phoneItAD ).number() ); 356 (*it).setNumber( ( *phoneItAD ).number() );
358 break; 357 break;
359 } 358 }
360 } 359 }
361 // if ( isSubSet && ! found ) 360 // if ( isSubSet && ! found )
362 if ( ! found ) // LR try this one... 361 if ( ! found ) // LR try this one...
363 mData->phoneNumbers.append( *phoneItAD ); 362 mData->phoneNumbers.append( *phoneItAD );
364 } 363 }
365 } else { 364 } else {
366 PhoneNumber::List phoneAD = ad.phoneNumbers(); 365 PhoneNumber::List phoneAD = ad.phoneNumbers();
367 PhoneNumber::List::Iterator phoneItAD; 366 PhoneNumber::List::Iterator phoneItAD;
368 for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) { 367 for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) {
369 bool found = false; 368 bool found = false;
370 PhoneNumber::List::Iterator it; 369 PhoneNumber::List::Iterator it;
371 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 370 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
372 if ( ( *phoneItAD ).contains( (*it) ) ) { 371 if ( ( *phoneItAD ).contains( (*it) ) ) {
373 found = true; 372 found = true;
374 (*it).setType( ( *phoneItAD ).type() ); 373 (*it).setType( ( *phoneItAD ).type() );
375 (*it).setNumber( ( *phoneItAD ).number() ); 374 (*it).setNumber( ( *phoneItAD ).number() );
376 break; 375 break;
377 } 376 }
378 } 377 }
379 if ( ! found ) { // append numbers which do not have work or home type 378 if ( ! found ) { // append numbers which do not have work or home type
380 if ( ! ( ( *phoneItAD ).type() & (PhoneNumber::Work | PhoneNumber::Home) ) ) 379 if ( ! ( ( *phoneItAD ).type() & (PhoneNumber::Work | PhoneNumber::Home) ) )
381 mData->phoneNumbers.append( *phoneItAD ); 380 mData->phoneNumbers.append( *phoneItAD );
382 } 381 }
383 } 382 }
384 } 383 }
385 if ( isSubSet ) { 384 if ( isSubSet ) {
386 // ************* emails; 385 // ************* emails;
387 t = mData->emails; 386 t = mData->emails;
388 tAD = ad.mData->emails; 387 tAD = ad.mData->emails;
389 for ( iii = 0; iii < tAD.count(); ++iii) 388 for ( iii = 0; iii < tAD.count(); ++iii)
390 if ( !t.contains(tAD[iii] ) ) 389 if ( !t.contains(tAD[iii] ) )
391 mData->emails.append( tAD[iii] ); 390 mData->emails.append( tAD[iii] );
392 } 391 }
393 392
394 // ************* categories; 393 // ************* categories;
395 if ( isSubSet ) { 394 if ( isSubSet ) {
396 t = mData->categories; 395 t = mData->categories;
397 tAD = ad.mData->categories; 396 tAD = ad.mData->categories;
398 for ( iii = 0; iii < tAD.count(); ++iii) 397 for ( iii = 0; iii < tAD.count(); ++iii)
399 if ( !t.contains(tAD[iii] ) ) 398 if ( !t.contains(tAD[iii] ) )
400 mData->categories.append( tAD[iii] ); 399 mData->categories.append( tAD[iii] );
401 } 400 }
402 QStringList::ConstIterator it; 401 QStringList::ConstIterator it;
403 for( it = ad.mData->custom.begin(); it != ad.mData->custom.end(); ++it ) { 402 for( it = ad.mData->custom.begin(); it != ad.mData->custom.end(); ++it ) {
404 QString qualifiedName = (*it).left( (*it).find( ":" )); 403 QString qualifiedName = (*it).left( (*it).find( ":" ));
405 bool found = false; 404 bool found = false;
406 QStringList::ConstIterator itL; 405 QStringList::ConstIterator itL;
407 for( itL = mData->custom.begin(); itL != mData->custom.end(); ++itL ) { 406 for( itL = mData->custom.begin(); itL != mData->custom.end(); ++itL ) {
408 if ( (*itL).startsWith( qualifiedName ) ) { 407 if ( (*itL).startsWith( qualifiedName ) ) {
409 found = true; 408 found = true;
410 break; 409 break;
411 } 410 }
412 } 411 }
413 if ( ! found ) { 412 if ( ! found ) {
414 mData->custom.append( *it ); 413 mData->custom.append( *it );
415 } 414 }
416 } 415 }
417 if ( mData->logo.undefined() && !ad.mData->logo.undefined() ) mData->logo = ad.mData->logo; 416 if ( mData->logo.undefined() && !ad.mData->logo.undefined() ) mData->logo = ad.mData->logo;
418 if ( mData->photo.undefined() && !ad.mData->photo.undefined() ) mData->photo = ad.mData->photo; 417 if ( mData->photo.undefined() && !ad.mData->photo.undefined() ) mData->photo = ad.mData->photo;
419 if ( !mData->sound.isIntern() ) { 418 if ( !mData->sound.isIntern() ) {
420 if ( mData->sound.url().isEmpty() ) { 419 if ( mData->sound.url().isEmpty() ) {
421 mData->sound = ad.mData->sound; 420 mData->sound = ad.mData->sound;
422 } 421 }
423 } 422 }
424 if ( !mData->agent.isIntern() ) { 423 if ( !mData->agent.isIntern() ) {
425 if ( mData->agent.url().isEmpty() ) { 424 if ( mData->agent.url().isEmpty() ) {
426 mData->agent = ad.mData->agent; 425 mData->agent = ad.mData->agent;
427 } 426 }
428 } 427 }
429 { 428 {
430 Key::List::Iterator itA; 429 Key::List::Iterator itA;
431 for( itA = ad.mData->keys.begin(); itA != ad.mData->keys.end(); ++itA ) { 430 for( itA = ad.mData->keys.begin(); itA != ad.mData->keys.end(); ++itA ) {
432 bool found = false; 431 bool found = false;
433 Key::List::Iterator it; 432 Key::List::Iterator it;
434 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { 433 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
435 if ( (*it) == (*itA)) { 434 if ( (*it) == (*itA)) {
436 found = true; 435 found = true;
437 break; 436 break;
438 437
439 } 438 }
440 } 439 }
441 if ( ! found ) { 440 if ( ! found ) {
442 mData->keys.append( *itA ); 441 mData->keys.append( *itA );
443 } 442 }
444 } 443 }
445 } 444 }
446 if ( isSubSet ) { 445 if ( isSubSet ) {
447 KABC::Address::List::Iterator addressIterA; 446 KABC::Address::List::Iterator addressIterA;
448 for ( addressIterA = ad.mData->addresses.begin(); addressIterA != ad.mData->addresses.end(); ++addressIterA ) { 447 for ( addressIterA = ad.mData->addresses.begin(); addressIterA != ad.mData->addresses.end(); ++addressIterA ) {
449 bool found = false; 448 bool found = false;
450 KABC::Address::List::Iterator addressIter; 449 KABC::Address::List::Iterator addressIter;
451 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); 450 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end();
452 ++addressIter ) { 451 ++addressIter ) {
453 if ( (*addressIter) == (*addressIterA)) { 452 if ( (*addressIter) == (*addressIterA)) {
454 found = true; 453 found = true;
455 (*addressIter).setType( (*addressIterA).type() ); 454 (*addressIter).setType( (*addressIterA).type() );
456 break; 455 break;
457 } 456 }
458 457
459 } 458 }
460 if ( isSubSet && ! found ) { 459 if ( isSubSet && ! found ) {
461 mData->addresses.append( *addressIterA ); 460 mData->addresses.append( *addressIterA );
462 } 461 }
463 } 462 }
464 } 463 }
465 //qDebug("merge contact %s ", ad.uid().latin1()); 464 //qDebug("merge contact %s ", ad.uid().latin1());
466 setUid( ad.uid() ); 465 setUid( ad.uid() );
467 setRevision( ad.revision() ); 466 setRevision( ad.revision() );
468} 467}
469 468
470bool Addressee::removeVoice() 469bool Addressee::removeVoice()
471{ 470{
472 PhoneNumber::List phoneN = phoneNumbers(); 471 PhoneNumber::List phoneN = phoneNumbers();
473 PhoneNumber::List::Iterator phoneIt; 472 PhoneNumber::List::Iterator phoneIt;
474 bool found = false; 473 bool found = false;
475 for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { 474 for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) {
476 if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found 475 if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found
477 if ((*phoneIt).type() - PhoneNumber::Voice ) { 476 if ((*phoneIt).type() - PhoneNumber::Voice ) {
478 (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice ); 477 (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice );
479 insertPhoneNumber( (*phoneIt) ); 478 insertPhoneNumber( (*phoneIt) );
480 found = true; 479 found = true;
481 } 480 }
482 } 481 }
483 482
484 } 483 }
485 return found; 484 return found;
486} 485}
487 486
488bool Addressee::containsAdr(const Addressee& ad ) 487bool Addressee::containsAdr(const Addressee& ad )
489{ 488{
490 if ( ! ad.mData->familyName.isEmpty() ) if ( mData->familyName != ad.mData->familyName) return false; 489 if ( ! ad.mData->familyName.isEmpty() ) if ( mData->familyName != ad.mData->familyName) return false;
491 if ( ! ad.mData->givenName.isEmpty() )if ( mData->givenName != ad.mData->givenName ) return false; 490 if ( ! ad.mData->givenName.isEmpty() )if ( mData->givenName != ad.mData->givenName ) return false;
492 if ( ad.mData->url.isValid() ) if (mData->url != ad.mData->url) return false ; 491 if ( ad.mData->url.isValid() ) if (mData->url != ad.mData->url) return false ;
493 if ( ! ad.mData->role.isEmpty() ) if (mData->role != ad.mData->role) return false ; 492 if ( ! ad.mData->role.isEmpty() ) if (mData->role != ad.mData->role) return false ;
494 if ( ! ad.mData->organization.isEmpty() ) if (mData->organization != ad.mData->organization) return false ; 493 if ( ! ad.mData->organization.isEmpty() ) if (mData->organization != ad.mData->organization) return false ;
495 if ( ! ad.mData->note.isEmpty() ) if (mData->note != ad.mData->note) return false ; 494 if ( ! ad.mData->note.isEmpty() ) if (mData->note != ad.mData->note) return false ;
496 if ( ! ad.mData->title .isEmpty() ) if (mData->title != ad.mData->title ) return false ; 495 if ( ! ad.mData->title .isEmpty() ) if (mData->title != ad.mData->title ) return false ;
497 496
498 // compare phone numbers 497 // compare phone numbers
499 PhoneNumber::List phoneN = ad.phoneNumbers(); 498 PhoneNumber::List phoneN = ad.phoneNumbers();
500 PhoneNumber::List::Iterator phoneIt; 499 PhoneNumber::List::Iterator phoneIt;
501 bool found = false; 500 bool found = false;
502 for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { 501 for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) {
503 bool found = false; 502 bool found = false;
504 PhoneNumber::List phoneL = ad.phoneNumbers(); 503 PhoneNumber::List phoneL = ad.phoneNumbers();
505 PhoneNumber::List::Iterator phoneItL; 504 PhoneNumber::List::Iterator phoneItL;
506 for ( phoneItL = phoneL.begin(); phoneItL != phoneL.end(); ++phoneItL ) { 505 for ( phoneItL = phoneL.begin(); phoneItL != phoneL.end(); ++phoneItL ) {
507 if ( ( *phoneItL ).number() == ( *phoneIt ).number() ) { 506 if ( ( *phoneItL ).number() == ( *phoneIt ).number() ) {
508 found = true; 507 found = true;
509 break; 508 break;
510 } 509 }
511 } 510 }
512 if ( ! found ) 511 if ( ! found )
513 return false; 512 return false;
514 } 513 }
515 return true; 514 return true;
516 515
517} 516}
518void Addressee::simplifyAddresses() 517void Addressee::simplifyAddresses()
519{ 518{
520 519
521 520
522 Address::List list; 521 Address::List list;
523 Address::List::Iterator it; 522 Address::List::Iterator it;
524 Address::List::Iterator it2; 523 Address::List::Iterator it2;
525 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 524 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
526 it2 = it; 525 it2 = it;
527 ++it2; 526 ++it2;
528 for( ; it2 != mData->addresses.end(); ++it2 ) { 527 for( ; it2 != mData->addresses.end(); ++it2 ) {
529 if ( (*it) == (*it2) ) { 528 if ( (*it) == (*it2) ) {
530 list.append( *it ); 529 list.append( *it );
531 break; 530 break;
532 } 531 }
533 } 532 }
534 } 533 }
535 for( it = list.begin(); it != list.end(); ++it ) { 534 for( it = list.begin(); it != list.end(); ++it ) {
536 removeAddress( (*it) ); 535 removeAddress( (*it) );
537 } 536 }
538 537
539 list.clear(); 538 list.clear();
540 int max = 2; 539 int max = 2;
541 if ( mData->url.isValid() ) 540 if ( mData->url.isValid() )
542 max = 1; 541 max = 1;
543 if ( mData->addresses.count() <= max ) return ; 542 if ( mData->addresses.count() <= max ) return ;
544 int count = 0; 543 int count = 0;
545 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 544 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
546 if ( count >= max ) 545 if ( count >= max )
547 list.append( *it ); 546 list.append( *it );
548 ++count; 547 ++count;
549 } 548 }
550 for( it = list.begin(); it != list.end(); ++it ) { 549 for( it = list.begin(); it != list.end(); ++it ) {
551 removeAddress( (*it) ); 550 removeAddress( (*it) );
552 } 551 }
553} 552}
554 553
555// removes all emails but the first 554// removes all emails but the first
556// needed by phone sync 555// needed by phone sync
557void Addressee::simplifyEmails() 556void Addressee::simplifyEmails()
558{ 557{
559 if ( mData->emails.count() == 0 ) return ; 558 if ( mData->emails.count() == 0 ) return ;
560 QString email = mData->emails.first(); 559 QString email = mData->emails.first();
561 detach(); 560 detach();
562 mData->emails.clear(); 561 mData->emails.clear();
563 mData->emails.append( email ); 562 mData->emails.append( email );
564} 563}
565 564
566void Addressee::simplifyPhoneNumbers() 565void Addressee::simplifyPhoneNumbers()
567{ 566{
568 int max = 4; 567 int max = 4;
569 int inList = mData->phoneNumbers.count(); 568 int inList = mData->phoneNumbers.count();
570 KABC::PhoneNumber::List removeNumbers; 569 KABC::PhoneNumber::List removeNumbers;
571 KABC::PhoneNumber::List::Iterator phoneIter; 570 KABC::PhoneNumber::List::Iterator phoneIter;
572 if ( inList > max ) { 571 if ( inList > max ) {
573 // delete non-preferred numbers 572 // delete non-preferred numbers
574 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 573 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
575 ++phoneIter ) { 574 ++phoneIter ) {
576 if ( inList > max ) { 575 if ( inList > max ) {
577 if ( ! (( *phoneIter ).type() & PhoneNumber::Pref )) { 576 if ( ! (( *phoneIter ).type() & PhoneNumber::Pref )) {
578 removeNumbers.append( ( *phoneIter ) ); 577 removeNumbers.append( ( *phoneIter ) );
579 --inList; 578 --inList;
580 } 579 }
581 } else 580 } else
582 break; 581 break;
583 } 582 }
584 for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); 583 for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end();
585 ++phoneIter ) { 584 ++phoneIter ) {
586 removePhoneNumber(( *phoneIter )); 585 removePhoneNumber(( *phoneIter ));
587 } 586 }
588 // delete preferred numbers 587 // delete preferred numbers
589 if ( inList > max ) { 588 if ( inList > max ) {
590 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 589 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
591 ++phoneIter ) { 590 ++phoneIter ) {
592 if ( inList > max ) { 591 if ( inList > max ) {
593 removeNumbers.append( ( *phoneIter ) ); 592 removeNumbers.append( ( *phoneIter ) );
594 --inList; 593 --inList;
595 } else 594 } else
596 break; 595 break;
597 } 596 }
598 for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); 597 for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end();
599 ++phoneIter ) { 598 ++phoneIter ) {
600 removePhoneNumber(( *phoneIter )); 599 removePhoneNumber(( *phoneIter ));
601 } 600 }
602 } 601 }
603 } 602 }
604 // remove non-numeric characters 603 // remove non-numeric characters
605 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 604 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
606 ++phoneIter ) { 605 ++phoneIter ) {
607 if ( ! ( *phoneIter ).simplifyNumber() ) 606 if ( ! ( *phoneIter ).simplifyNumber() )
608 removeNumbers.append( ( *phoneIter ) ); 607 removeNumbers.append( ( *phoneIter ) );
609 } 608 }
610 for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); 609 for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end();
611 ++phoneIter ) { 610 ++phoneIter ) {
612 removePhoneNumber(( *phoneIter )); 611 removePhoneNumber(( *phoneIter ));
613 } 612 }
614} 613}
615void Addressee::simplifyPhoneNumberTypes() 614void Addressee::simplifyPhoneNumberTypes()
616{ 615{
617 KABC::PhoneNumber::List::Iterator phoneIter; 616 KABC::PhoneNumber::List::Iterator phoneIter;
618 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 617 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
619 ++phoneIter ) 618 ++phoneIter )
620 ( *phoneIter ).simplifyType(); 619 ( *phoneIter ).simplifyType();
621} 620}
622void Addressee::removeID(const QString &prof) 621void Addressee::removeID(const QString &prof)
623{ 622{
624 detach(); 623 detach();
625 if ( prof.isEmpty() ) 624 if ( prof.isEmpty() )
626 mData->mExternalId = ":"; 625 mData->mExternalId = ":";
627 else 626 else
628 mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof); 627 mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof);
629 628
630} 629}
631void Addressee::setID( const QString & prof , const QString & id ) 630void Addressee::setID( const QString & prof , const QString & id )
632{ 631{
633 detach(); 632 detach();
634 mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id ); 633 mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id );
635 //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); 634 //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() );
636} 635}
637void Addressee::setTempSyncStat( int id ) 636void Addressee::setTempSyncStat( int id )
638{ 637{
639 if ( mData->mTempSyncStat == id ) return; 638 if ( mData->mTempSyncStat == id ) return;
640 detach(); 639 detach();
641 mData->mTempSyncStat = id; 640 mData->mTempSyncStat = id;
642} 641}
643int Addressee::tempSyncStat() const 642int Addressee::tempSyncStat() const
644{ 643{
645 return mData->mTempSyncStat; 644 return mData->mTempSyncStat;
646} 645}
647 646
648const QString Addressee::getID( const QString & prof) const 647const QString Addressee::getID( const QString & prof) const
649{ 648{
650 return KIdManager::getId ( mData->mExternalId, prof ); 649 return KIdManager::getId ( mData->mExternalId, prof );
651} 650}
652 651
653void Addressee::setCsum( const QString & prof , const QString & id ) 652void Addressee::setCsum( const QString & prof , const QString & id )
654{ 653{
655 detach(); 654 detach();
656 //qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); 655 //qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() );
657 mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id ); 656 mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id );
658 //qDebug("setcsum2 %s ",mData->mExternalId.latin1() ); 657 //qDebug("setcsum2 %s ",mData->mExternalId.latin1() );
659} 658}
660 659
661const QString Addressee::getCsum( const QString & prof) const 660const QString Addressee::getCsum( const QString & prof) const
662{ 661{
663 return KIdManager::getCsum ( mData->mExternalId, prof ); 662 return KIdManager::getCsum ( mData->mExternalId, prof );
664} 663}
665 664
666void Addressee::setIDStr( const QString & s ) 665void Addressee::setIDStr( const QString & s )
667{ 666{
668 detach(); 667 detach();
669 mData->mExternalId = s; 668 mData->mExternalId = s;
670} 669}
671 670
672const QString Addressee::IDStr() const 671const QString Addressee::IDStr() const
673{ 672{
674 return mData->mExternalId; 673 return mData->mExternalId;
675} 674}
676 675
677void Addressee::setExternalUID( const QString &id ) 676void Addressee::setExternalUID( const QString &id )
678{ 677{
679 if ( id == mData->externalUID ) return; 678 if ( id == mData->externalUID ) return;
680 detach(); 679 detach();
681 mData->empty = false; 680 mData->empty = false;
682 mData->externalUID = id; 681 mData->externalUID = id;
683} 682}
684 683
685const QString Addressee::externalUID() const 684const QString Addressee::externalUID() const
686{ 685{
687 return mData->externalUID; 686 return mData->externalUID;
688} 687}
689void Addressee::setOriginalExternalUID( const QString &id ) 688void Addressee::setOriginalExternalUID( const QString &id )
690{ 689{
691 if ( id == mData->originalExternalUID ) return; 690 if ( id == mData->originalExternalUID ) return;
692 detach(); 691 detach();
693 mData->empty = false; 692 mData->empty = false;
694 //qDebug("*******Set orig uid %s ", id.latin1()); 693 //qDebug("*******Set orig uid %s ", id.latin1());
695 mData->originalExternalUID = id; 694 mData->originalExternalUID = id;
696} 695}
697 696
698QString Addressee::originalExternalUID() const 697QString Addressee::originalExternalUID() const
699{ 698{
700 return mData->originalExternalUID; 699 return mData->originalExternalUID;
701} 700}
702 701
703void Addressee::setUid( const QString &id ) 702void Addressee::setUid( const QString &id )
704{ 703{
705 if ( id == mData->uid ) return; 704 if ( id == mData->uid ) return;
706 detach(); 705 detach();
707 //qDebug("****setuid %s ", id.latin1()); 706 //qDebug("****setuid %s ", id.latin1());
708 mData->empty = false; 707 mData->empty = false;
709 mData->uid = id; 708 mData->uid = id;
710} 709}
711 710
712const QString Addressee::uid() const 711const QString Addressee::uid() const
713{ 712{
714 if ( mData->uid.isEmpty() ) 713 if ( mData->uid.isEmpty() )
715 mData->uid = KApplication::randomString( 10 ); 714 mData->uid = KApplication::randomString( 10 );
716 715
717 return mData->uid; 716 return mData->uid;
718} 717}
719 718
720QString Addressee::uidLabel() 719QString Addressee::uidLabel()
721{ 720{
722 return i18n("Unique Identifier"); 721 return i18n("Unique Identifier");
723} 722}
724 723
725void Addressee::setName( const QString &name ) 724void Addressee::setName( const QString &name )
726{ 725{
727 if ( name == mData->name ) return; 726 if ( name == mData->name ) return;
728 detach(); 727 detach();
729 mData->empty = false; 728 mData->empty = false;
730 mData->name = name; 729 mData->name = name;
731} 730}
732 731
733QString Addressee::name() const 732QString Addressee::name() const
734{ 733{
735 return mData->name; 734 return mData->name;
736} 735}
737 736
738QString Addressee::nameLabel() 737QString Addressee::nameLabel()
739{ 738{
740 return i18n("Name"); 739 return i18n("Name");
741} 740}
742 741
743 742
744void Addressee::setFormattedName( const QString &formattedName ) 743void Addressee::setFormattedName( const QString &formattedName )
745{ 744{
746 if ( formattedName == mData->formattedName ) return; 745 if ( formattedName == mData->formattedName ) return;
747 detach(); 746 detach();
748 mData->empty = false; 747 mData->empty = false;
749 mData->formattedName = formattedName; 748 mData->formattedName = formattedName;
750} 749}
751void Addressee::setDefaultFormattedName( const QString &formattedName )
752{
753 if ( formattedName == mData->defaultFormattedName ) return;
754 detach();
755 mData->empty = false;
756 mData->defaultFormattedName = formattedName;
757}
758 750
759QString Addressee::formattedName() const 751QString Addressee::formattedName() const
760{ 752{
761 return mData->formattedName; 753 return mData->formattedName;
762} 754}
763QString Addressee::defaultFormattedName() const
764{
765 return mData->defaultFormattedName;
766}
767 755
768QString Addressee::formattedNameLabel() 756QString Addressee::formattedNameLabel()
769{ 757{
770 return i18n("Formatted Name"); 758 return i18n("Formatted Name");
771} 759}
772 760
773QString Addressee::defaultFormattedNameLabel()
774{
775 return i18n("Def.Formatted Name");
776}
777
778 761
779void Addressee::setFamilyName( const QString &familyName ) 762void Addressee::setFamilyName( const QString &familyName )
780{ 763{
781 if ( familyName == mData->familyName ) return; 764 if ( familyName == mData->familyName ) return;
782 detach(); 765 detach();
783 mData->empty = false; 766 mData->empty = false;
784 mData->familyName = familyName; 767 mData->familyName = familyName;
785} 768}
786 769
787QString Addressee::familyName() const 770QString Addressee::familyName() const
788{ 771{
789 return mData->familyName; 772 return mData->familyName;
790} 773}
791 774
792QString Addressee::familyNameLabel() 775QString Addressee::familyNameLabel()
793{ 776{
794 return i18n("Family Name"); 777 return i18n("Family Name");
795} 778}
796 779
797 780
798void Addressee::setGivenName( const QString &givenName ) 781void Addressee::setGivenName( const QString &givenName )
799{ 782{
800 if ( givenName == mData->givenName ) return; 783 if ( givenName == mData->givenName ) return;
801 detach(); 784 detach();
802 mData->empty = false; 785 mData->empty = false;
803 mData->givenName = givenName; 786 mData->givenName = givenName;
804} 787}
805 788
806QString Addressee::givenName() const 789QString Addressee::givenName() const
807{ 790{
808 return mData->givenName; 791 return mData->givenName;
809} 792}
810 793
811QString Addressee::givenNameLabel() 794QString Addressee::givenNameLabel()
812{ 795{
813 return i18n("Given Name"); 796 return i18n("Given Name");
814} 797}
815 798
816 799
817void Addressee::setAdditionalName( const QString &additionalName ) 800void Addressee::setAdditionalName( const QString &additionalName )
818{ 801{
819 if ( additionalName == mData->additionalName ) return; 802 if ( additionalName == mData->additionalName ) return;
820 detach(); 803 detach();
821 mData->empty = false; 804 mData->empty = false;
822 mData->additionalName = additionalName; 805 mData->additionalName = additionalName;
823} 806}
824 807
825QString Addressee::additionalName() const 808QString Addressee::additionalName() const
826{ 809{
827 return mData->additionalName; 810 return mData->additionalName;
828} 811}
829 812
830QString Addressee::additionalNameLabel() 813QString Addressee::additionalNameLabel()
831{ 814{
832 return i18n("Additional Names"); 815 return i18n("Additional Names");
833} 816}
834 817
835 818
836void Addressee::setPrefix( const QString &prefix ) 819void Addressee::setPrefix( const QString &prefix )
837{ 820{
838 if ( prefix == mData->prefix ) return; 821 if ( prefix == mData->prefix ) return;
839 detach(); 822 detach();
840 mData->empty = false; 823 mData->empty = false;
841 mData->prefix = prefix; 824 mData->prefix = prefix;
842} 825}
843 826
844QString Addressee::prefix() const 827QString Addressee::prefix() const
845{ 828{
846 return mData->prefix; 829 return mData->prefix;
847} 830}
848 831
849QString Addressee::prefixLabel() 832QString Addressee::prefixLabel()
850{ 833{
851 return i18n("Honorific Prefixes"); 834 return i18n("Honorific Prefixes");
852} 835}
853 836
854 837
855void Addressee::setSuffix( const QString &suffix ) 838void Addressee::setSuffix( const QString &suffix )
856{ 839{
857 if ( suffix == mData->suffix ) return; 840 if ( suffix == mData->suffix ) return;
858 detach(); 841 detach();
859 mData->empty = false; 842 mData->empty = false;
860 mData->suffix = suffix; 843 mData->suffix = suffix;
861} 844}
862 845
863QString Addressee::suffix() const 846QString Addressee::suffix() const
864{ 847{
865 return mData->suffix; 848 return mData->suffix;
866} 849}
867 850
868QString Addressee::suffixLabel() 851QString Addressee::suffixLabel()
869{ 852{
870 return i18n("Honorific Suffixes"); 853 return i18n("Honorific Suffixes");
871} 854}
872 855
873 856
874void Addressee::setNickName( const QString &nickName ) 857void Addressee::setNickName( const QString &nickName )
875{ 858{
876 if ( nickName == mData->nickName ) return; 859 if ( nickName == mData->nickName ) return;
877 detach(); 860 detach();
878 mData->empty = false; 861 mData->empty = false;
879 mData->nickName = nickName; 862 mData->nickName = nickName;
880} 863}
881 864
882QString Addressee::nickName() const 865QString Addressee::nickName() const
883{ 866{
884 return mData->nickName; 867 return mData->nickName;
885} 868}
886 869
887QString Addressee::nickNameLabel() 870QString Addressee::nickNameLabel()
888{ 871{
889 return i18n("Nick Name"); 872 return i18n("Nick Name");
890} 873}
891 874
892 875
893void Addressee::setBirthday( const QDateTime &birthday ) 876void Addressee::setBirthday( const QDateTime &birthday )
894{ 877{
895 if ( birthday == mData->birthday ) return; 878 if ( birthday == mData->birthday ) return;
896 detach(); 879 detach();
897 mData->empty = false; 880 mData->empty = false;
898 mData->birthday = birthday; 881 mData->birthday = birthday;
899} 882}
900 883
901QDateTime Addressee::birthday() const 884QDateTime Addressee::birthday() const
902{ 885{
903 return mData->birthday; 886 return mData->birthday;
904} 887}
905 888
906QString Addressee::birthdayLabel() 889QString Addressee::birthdayLabel()
907{ 890{
908 return i18n("Birthday"); 891 return i18n("Birthday");
909} 892}
910 893
911 894
912QString Addressee::homeAddressStreetLabel() 895QString Addressee::homeAddressStreetLabel()
913{ 896{
914 return i18n("Home Address Street"); 897 return i18n("Home Address Street");
915} 898}
916 899
917 900
918QString Addressee::homeAddressLocalityLabel() 901QString Addressee::homeAddressLocalityLabel()
919{ 902{
920 return i18n("Home Address Locality"); 903 return i18n("Home Address Locality");
921} 904}
922 905
923 906
924QString Addressee::homeAddressRegionLabel() 907QString Addressee::homeAddressRegionLabel()
925{ 908{
926 return i18n("Home Address Region"); 909 return i18n("Home Address Region");
927} 910}
928 911
929 912
930QString Addressee::homeAddressPostalCodeLabel() 913QString Addressee::homeAddressPostalCodeLabel()
931{ 914{
932 return i18n("Home Address Postal Code"); 915 return i18n("Home Address Postal Code");
933} 916}
934 917
935 918
936QString Addressee::homeAddressCountryLabel() 919QString Addressee::homeAddressCountryLabel()
937{ 920{
938 return i18n("Home Address Country"); 921 return i18n("Home Address Country");
939} 922}
940 923
941 924
942QString Addressee::homeAddressLabelLabel() 925QString Addressee::homeAddressLabelLabel()
943{ 926{
944 return i18n("Home Address Label"); 927 return i18n("Home Address Label");
945} 928}
946 929
947 930
948QString Addressee::businessAddressStreetLabel() 931QString Addressee::businessAddressStreetLabel()
949{ 932{
950 return i18n("Business Address Street"); 933 return i18n("Business Address Street");
951} 934}
952 935
953 936
954QString Addressee::businessAddressLocalityLabel() 937QString Addressee::businessAddressLocalityLabel()
955{ 938{
956 return i18n("Business Address Locality"); 939 return i18n("Business Address Locality");
957} 940}
958 941
959 942
960QString Addressee::businessAddressRegionLabel() 943QString Addressee::businessAddressRegionLabel()
961{ 944{
962 return i18n("Business Address Region"); 945 return i18n("Business Address Region");
963} 946}
964 947
965 948
966QString Addressee::businessAddressPostalCodeLabel() 949QString Addressee::businessAddressPostalCodeLabel()
967{ 950{
968 return i18n("Business Address Postal Code"); 951 return i18n("Business Address Postal Code");
969} 952}
970 953
971 954
972QString Addressee::businessAddressCountryLabel() 955QString Addressee::businessAddressCountryLabel()
973{ 956{
974 return i18n("Business Address Country"); 957 return i18n("Business Address Country");
975} 958}
976 959
977 960
978QString Addressee::businessAddressLabelLabel() 961QString Addressee::businessAddressLabelLabel()
979{ 962{
980 return i18n("Business Address Label"); 963 return i18n("Business Address Label");
981} 964}
982 965
983 966
984QString Addressee::homePhoneLabel() 967QString Addressee::homePhoneLabel()
985{ 968{
986 return i18n("Home Phone"); 969 return i18n("Home Phone");
987} 970}
988 971
989 972
990QString Addressee::businessPhoneLabel() 973QString Addressee::businessPhoneLabel()
991{ 974{
992 return i18n("Business Phone"); 975 return i18n("Business Phone");
993} 976}
994 977
995 978
996QString Addressee::mobilePhoneLabel() 979QString Addressee::mobilePhoneLabel()
997{ 980{
998 return i18n("Mobile Phone"); 981 return i18n("Mobile Phone");
999} 982}
1000QString Addressee::mobileWorkPhoneLabel() 983QString Addressee::mobileWorkPhoneLabel()
1001{ 984{
1002 return i18n("Mobile (work)"); 985 return i18n("Mobile (work)");
1003} 986}
1004QString Addressee::mobileHomePhoneLabel() 987QString Addressee::mobileHomePhoneLabel()
1005{ 988{
1006 return i18n("Mobile (home)"); 989 return i18n("Mobile (home)");
1007} 990}
1008 991
1009 992
1010QString Addressee::homeFaxLabel() 993QString Addressee::homeFaxLabel()
1011{ 994{
1012 return i18n("Home Fax"); 995 return i18n("Home Fax");
1013} 996}
1014 997
1015 998
1016QString Addressee::businessFaxLabel() 999QString Addressee::businessFaxLabel()
1017{ 1000{
1018 return i18n("Business Fax"); 1001 return i18n("Business Fax");
1019} 1002}
1020 1003
1021 1004
1022QString Addressee::carPhoneLabel() 1005QString Addressee::carPhoneLabel()
1023{ 1006{
1024 return i18n("Car Phone"); 1007 return i18n("Car Phone");
1025} 1008}
1026 1009
1027 1010
1028QString Addressee::isdnLabel() 1011QString Addressee::isdnLabel()
1029{ 1012{
1030 return i18n("ISDN"); 1013 return i18n("ISDN");
1031} 1014}
1032 1015
1033 1016
1034QString Addressee::pagerLabel() 1017QString Addressee::pagerLabel()
1035{ 1018{
1036 return i18n("Pager"); 1019 return i18n("Pager");
1037} 1020}
1038 1021
1039QString Addressee::sipLabel() 1022QString Addressee::sipLabel()
1040{ 1023{
1041 return i18n("SIP"); 1024 return i18n("SIP");
1042} 1025}
1043 1026
1044QString Addressee::emailLabel() 1027QString Addressee::emailLabel()
1045{ 1028{
1046 return i18n("Email Address"); 1029 return i18n("Email Address");
1047} 1030}
1048 1031
1049 1032
1050void Addressee::setMailer( const QString &mailer ) 1033void Addressee::setMailer( const QString &mailer )
1051{ 1034{
1052 if ( mailer == mData->mailer ) return; 1035 if ( mailer == mData->mailer ) return;
1053 detach(); 1036 detach();
1054 mData->empty = false; 1037 mData->empty = false;
1055 mData->mailer = mailer; 1038 mData->mailer = mailer;
1056} 1039}
1057 1040
1058QString Addressee::mailer() const 1041QString Addressee::mailer() const
1059{ 1042{
1060 return mData->mailer; 1043 return mData->mailer;
1061} 1044}
1062 1045
1063QString Addressee::mailerLabel() 1046QString Addressee::mailerLabel()
1064{ 1047{
1065 return i18n("Mail Client"); 1048 return i18n("Mail Client");
1066} 1049}
1067 1050
1068 1051
1069void Addressee::setTimeZone( const TimeZone &timeZone ) 1052void Addressee::setTimeZone( const TimeZone &timeZone )
1070{ 1053{
1071 if ( timeZone == mData->timeZone ) return; 1054 if ( timeZone == mData->timeZone ) return;
1072 detach(); 1055 detach();
1073 mData->empty = false; 1056 mData->empty = false;
1074 mData->timeZone = timeZone; 1057 mData->timeZone = timeZone;
1075} 1058}
1076 1059
1077TimeZone Addressee::timeZone() const 1060TimeZone Addressee::timeZone() const
1078{ 1061{
1079 return mData->timeZone; 1062 return mData->timeZone;
1080} 1063}
1081 1064
1082QString Addressee::timeZoneLabel() 1065QString Addressee::timeZoneLabel()
1083{ 1066{
1084 return i18n("Time Zone"); 1067 return i18n("Time Zone");
1085} 1068}
1086 1069
1087 1070
1088void Addressee::setGeo( const Geo &geo ) 1071void Addressee::setGeo( const Geo &geo )
1089{ 1072{
1090 if ( geo == mData->geo ) return; 1073 if ( geo == mData->geo ) return;
1091 detach(); 1074 detach();
1092 mData->empty = false; 1075 mData->empty = false;
1093 mData->geo = geo; 1076 mData->geo = geo;
1094} 1077}
1095 1078
1096Geo Addressee::geo() const 1079Geo Addressee::geo() const
1097{ 1080{
1098 return mData->geo; 1081 return mData->geo;
1099} 1082}
1100 1083
1101QString Addressee::geoLabel() 1084QString Addressee::geoLabel()
1102{ 1085{
1103 return i18n("Geographic Position"); 1086 return i18n("Geographic Position");
1104} 1087}
1105 1088
1106 1089
1107void Addressee::setTitle( const QString &title ) 1090void Addressee::setTitle( const QString &title )
1108{ 1091{
1109 if ( title == mData->title ) return; 1092 if ( title == mData->title ) return;
1110 detach(); 1093 detach();
1111 mData->empty = false; 1094 mData->empty = false;
1112 mData->title = title; 1095 mData->title = title;
1113} 1096}
1114 1097
1115QString Addressee::title() const 1098QString Addressee::title() const
1116{ 1099{
1117 return mData->title; 1100 return mData->title;
1118} 1101}
1119 1102
1120QString Addressee::titleLabel() 1103QString Addressee::titleLabel()
1121{ 1104{
1122 return i18n("Title"); 1105 return i18n("Title");
1123} 1106}
1124 1107
1125 1108
1126void Addressee::setRole( const QString &role ) 1109void Addressee::setRole( const QString &role )
1127{ 1110{
1128 if ( role == mData->role ) return; 1111 if ( role == mData->role ) return;
1129 detach(); 1112 detach();
1130 mData->empty = false; 1113 mData->empty = false;
1131 mData->role = role; 1114 mData->role = role;
1132} 1115}
1133 1116
1134QString Addressee::role() const 1117QString Addressee::role() const
1135{ 1118{
1136 return mData->role; 1119 return mData->role;
1137} 1120}
1138 1121
1139QString Addressee::roleLabel() 1122QString Addressee::roleLabel()
1140{ 1123{
1141 return i18n("Role"); 1124 return i18n("Role");
1142} 1125}
1143 1126
1144 1127
1145void Addressee::setOrganization( const QString &organization ) 1128void Addressee::setOrganization( const QString &organization )
1146{ 1129{
1147 if ( organization == mData->organization ) return; 1130 if ( organization == mData->organization ) return;
1148 detach(); 1131 detach();
1149 mData->empty = false; 1132 mData->empty = false;
1150 mData->organization = organization; 1133 mData->organization = organization;
1151} 1134}
1152 1135
1153QString Addressee::organization() const 1136QString Addressee::organization() const
1154{ 1137{
1155 return mData->organization; 1138 return mData->organization;
1156} 1139}
1157 1140
1158QString Addressee::organizationLabel() 1141QString Addressee::organizationLabel()
1159{ 1142{
1160 return i18n("Organization"); 1143 return i18n("Organization");
1161} 1144}
1162 1145
1163 1146
1164void Addressee::setNote( const QString &note ) 1147void Addressee::setNote( const QString &note )
1165{ 1148{
1166 if ( note == mData->note ) return; 1149 if ( note == mData->note ) return;
1167 detach(); 1150 detach();
1168 mData->empty = false; 1151 mData->empty = false;
1169 mData->note = note; 1152 mData->note = note;
1170} 1153}
1171 1154
1172QString Addressee::note() const 1155QString Addressee::note() const
1173{ 1156{
1174 return mData->note; 1157 return mData->note;
1175} 1158}
1176 1159
1177QString Addressee::noteLabel() 1160QString Addressee::noteLabel()
1178{ 1161{
1179 return i18n("Note"); 1162 return i18n("Note");
1180} 1163}
1181 1164
1182 1165
1183void Addressee::setProductId( const QString &productId ) 1166void Addressee::setProductId( const QString &productId )
1184{ 1167{
1185 if ( productId == mData->productId ) return; 1168 if ( productId == mData->productId ) return;
1186 detach(); 1169 detach();
1187 mData->empty = false; 1170 mData->empty = false;
1188 mData->productId = productId; 1171 mData->productId = productId;
1189} 1172}
1190 1173
1191QString Addressee::productId() const 1174QString Addressee::productId() const
1192{ 1175{
1193 return mData->productId; 1176 return mData->productId;
1194} 1177}
1195 1178
1196QString Addressee::productIdLabel() 1179QString Addressee::productIdLabel()
1197{ 1180{
1198 return i18n("Product Identifier"); 1181 return i18n("Product Identifier");
1199} 1182}
1200 1183
1201 1184
1202void Addressee::setRevision( const QDateTime &revision ) 1185void Addressee::setRevision( const QDateTime &revision )
1203{ 1186{
1204 if ( revision == mData->revision ) return; 1187 if ( revision == mData->revision ) return;
1205 detach(); 1188 detach();
1206 mData->empty = false; 1189 mData->empty = false;
1207 mData->revision = QDateTime( revision.date(), 1190 mData->revision = QDateTime( revision.date(),
1208 QTime (revision.time().hour(), 1191 QTime (revision.time().hour(),
1209 revision.time().minute(), 1192 revision.time().minute(),
1210 revision.time().second())); 1193 revision.time().second()));
1211} 1194}
1212 1195
1213QDateTime Addressee::revision() const 1196QDateTime Addressee::revision() const
1214{ 1197{
1215 return mData->revision; 1198 return mData->revision;
1216} 1199}
1217 1200
1218QString Addressee::revisionLabel() 1201QString Addressee::revisionLabel()
1219{ 1202{
1220 return i18n("Revision Date"); 1203 return i18n("Revision Date");
1221} 1204}
1222 1205
1223 1206
1224void Addressee::setSortString( const QString &sortString ) 1207void Addressee::setSortString( const QString &sortString )
1225{ 1208{
1226 if ( sortString == mData->sortString ) return; 1209 if ( sortString == mData->sortString ) return;
1227 detach(); 1210 detach();
1228 mData->empty = false; 1211 mData->empty = false;
1229 mData->sortString = sortString; 1212 mData->sortString = sortString;
1230} 1213}
1231 1214
1232QString Addressee::sortString() const 1215QString Addressee::sortString() const
1233{ 1216{
1234 return mData->sortString; 1217 return mData->sortString;
1235} 1218}
1236 1219
1237QString Addressee::sortStringLabel() 1220QString Addressee::sortStringLabel()
1238{ 1221{
1239 return i18n("Sort String"); 1222 return i18n("Sort String");
1240} 1223}
1241 1224
1242 1225
1243void Addressee::setUrl( const KURL &url ) 1226void Addressee::setUrl( const KURL &url )
1244{ 1227{
1245 if ( url == mData->url ) return; 1228 if ( url == mData->url ) return;
1246 detach(); 1229 detach();
1247 mData->empty = false; 1230 mData->empty = false;
1248 mData->url = url; 1231 mData->url = url;
1249} 1232}
1250 1233
1251KURL Addressee::url() const 1234KURL Addressee::url() const
1252{ 1235{
1253 return mData->url; 1236 return mData->url;
1254} 1237}
1255 1238
1256QString Addressee::urlLabel() 1239QString Addressee::urlLabel()
1257{ 1240{
1258 return i18n("URL"); 1241 return i18n("URL");
1259} 1242}
1260 1243
1261 1244
1262void Addressee::setSecrecy( const Secrecy &secrecy ) 1245void Addressee::setSecrecy( const Secrecy &secrecy )
1263{ 1246{
1264 if ( secrecy == mData->secrecy ) return; 1247 if ( secrecy == mData->secrecy ) return;
1265 detach(); 1248 detach();
1266 mData->empty = false; 1249 mData->empty = false;
1267 mData->secrecy = secrecy; 1250 mData->secrecy = secrecy;
1268} 1251}
1269 1252
1270Secrecy Addressee::secrecy() const 1253Secrecy Addressee::secrecy() const
1271{ 1254{
1272 return mData->secrecy; 1255 return mData->secrecy;
1273} 1256}
1274 1257
1275QString Addressee::secrecyLabel() 1258QString Addressee::secrecyLabel()
1276{ 1259{
1277 return i18n("Security Class"); 1260 return i18n("Security Class");
1278} 1261}
1279 1262
1280 1263
1281void Addressee::setLogo( const Picture &logo ) 1264void Addressee::setLogo( const Picture &logo )
1282{ 1265{
1283 if ( logo == mData->logo ) return; 1266 if ( logo == mData->logo ) return;
1284 detach(); 1267 detach();
1285 mData->empty = false; 1268 mData->empty = false;
1286 mData->logo = logo; 1269 mData->logo = logo;
1287} 1270}
1288 1271
1289Picture Addressee::logo() const 1272Picture Addressee::logo() const
1290{ 1273{
1291 return mData->logo; 1274 return mData->logo;
1292} 1275}
1293 1276
1294QString Addressee::logoLabel() 1277QString Addressee::logoLabel()
1295{ 1278{
1296 return i18n("Logo"); 1279 return i18n("Logo");
1297} 1280}
1298 1281
1299 1282
1300void Addressee::setPhoto( const Picture &photo ) 1283void Addressee::setPhoto( const Picture &photo )
1301{ 1284{
1302 if ( photo == mData->photo ) return; 1285 if ( photo == mData->photo ) return;
1303 detach(); 1286 detach();
1304 mData->empty = false; 1287 mData->empty = false;
1305 mData->photo = photo; 1288 mData->photo = photo;
1306} 1289}
1307 1290
1308Picture Addressee::photo() const 1291Picture Addressee::photo() const
1309{ 1292{
1310 return mData->photo; 1293 return mData->photo;
1311} 1294}
1312 1295
1313QString Addressee::photoLabel() 1296QString Addressee::photoLabel()
1314{ 1297{
1315 return i18n("Photo"); 1298 return i18n("Photo");
1316} 1299}
1317 1300
1318 1301
1319void Addressee::setSound( const Sound &sound ) 1302void Addressee::setSound( const Sound &sound )
1320{ 1303{
1321 if ( sound == mData->sound ) return; 1304 if ( sound == mData->sound ) return;
1322 detach(); 1305 detach();
1323 mData->empty = false; 1306 mData->empty = false;
1324 mData->sound = sound; 1307 mData->sound = sound;
1325} 1308}
1326 1309
1327Sound Addressee::sound() const 1310Sound Addressee::sound() const
1328{ 1311{
1329 return mData->sound; 1312 return mData->sound;
1330} 1313}
1331 1314
1332QString Addressee::soundLabel() 1315QString Addressee::soundLabel()
1333{ 1316{
1334 return i18n("Sound"); 1317 return i18n("Sound");
1335} 1318}
1336 1319
1337 1320
1338void Addressee::setAgent( const Agent &agent ) 1321void Addressee::setAgent( const Agent &agent )
1339{ 1322{
1340 if ( agent == mData->agent ) return; 1323 if ( agent == mData->agent ) return;
1341 detach(); 1324 detach();
1342 mData->empty = false; 1325 mData->empty = false;
1343 mData->agent = agent; 1326 mData->agent = agent;
1344} 1327}
1345 1328
1346Agent Addressee::agent() const 1329Agent Addressee::agent() const
1347{ 1330{
1348 return mData->agent; 1331 return mData->agent;
1349} 1332}
1350 1333
1351QString Addressee::agentLabel() 1334QString Addressee::agentLabel()
1352{ 1335{
1353 return i18n("Agent"); 1336 return i18n("Agent");
1354} 1337}
1355 1338
1356 1339
1357 1340
1358void Addressee::setNameFromString( const QString &str ) 1341void Addressee::setNameFromString( const QString &str )
1359{ 1342{
1360 setFormattedName( str ); 1343 setFormattedName( str );
1361 setName( str ); 1344 setName( str );
1362 1345
1363 static bool first = true; 1346 static bool first = true;
1364 static QStringList titles; 1347 static QStringList titles;
1365 static QStringList suffixes; 1348 static QStringList suffixes;
1366 static QStringList prefixes; 1349 static QStringList prefixes;
1367 1350
1368 if ( first ) { 1351 if ( first ) {
1369 first = false; 1352 first = false;
1370 titles += i18n( "Dr." ); 1353 titles += i18n( "Dr." );
1371 titles += i18n( "Miss" ); 1354 titles += i18n( "Miss" );
1372 titles += i18n( "Mr." ); 1355 titles += i18n( "Mr." );
1373 titles += i18n( "Mrs." ); 1356 titles += i18n( "Mrs." );
1374 titles += i18n( "Ms." ); 1357 titles += i18n( "Ms." );
1375 titles += i18n( "Prof." ); 1358 titles += i18n( "Prof." );
1376 1359
1377 suffixes += i18n( "I" ); 1360 suffixes += i18n( "I" );
1378 suffixes += i18n( "II" ); 1361 suffixes += i18n( "II" );
1379 suffixes += i18n( "III" ); 1362 suffixes += i18n( "III" );
1380 suffixes += i18n( "Jr." ); 1363 suffixes += i18n( "Jr." );
1381 suffixes += i18n( "Sr." ); 1364 suffixes += i18n( "Sr." );
1382 1365
1383 prefixes += "van"; 1366 prefixes += "van";
1384 prefixes += "von"; 1367 prefixes += "von";
1385 prefixes += "de"; 1368 prefixes += "de";
1386 1369
1387 KConfig config( locateLocal( "config", "kabcrc") ); 1370 KConfig config( locateLocal( "config", "kabcrc") );
1388 config.setGroup( "General" ); 1371 config.setGroup( "General" );
1389 titles += config.readListEntry( "Prefixes" ); 1372 titles += config.readListEntry( "Prefixes" );
1390 titles.remove( "" ); 1373 titles.remove( "" );
1391 prefixes += config.readListEntry( "Inclusions" ); 1374 prefixes += config.readListEntry( "Inclusions" );
1392 prefixes.remove( "" ); 1375 prefixes.remove( "" );
1393 suffixes += config.readListEntry( "Suffixes" ); 1376 suffixes += config.readListEntry( "Suffixes" );
1394 suffixes.remove( "" ); 1377 suffixes.remove( "" );
1395 } 1378 }
1396 1379
1397 // clear all name parts 1380 // clear all name parts
1398 setPrefix( "" ); 1381 setPrefix( "" );
1399 setGivenName( "" ); 1382 setGivenName( "" );
1400 setAdditionalName( "" ); 1383 setAdditionalName( "" );
1401 setFamilyName( "" ); 1384 setFamilyName( "" );
1402 setSuffix( "" ); 1385 setSuffix( "" );
1403 1386
1404 if ( str.isEmpty() ) 1387 if ( str.isEmpty() )
1405 return; 1388 return;
1406 1389
1407 int i = str.find(','); 1390 int i = str.find(',');
1408 if( i < 0 ) { 1391 if( i < 0 ) {
1409 QStringList parts = QStringList::split( " ", str ); 1392 QStringList parts = QStringList::split( " ", str );
1410 int leftOffset = 0; 1393 int leftOffset = 0;
1411 int rightOffset = parts.count() - 1; 1394 int rightOffset = parts.count() - 1;
1412 1395
1413 QString suffix; 1396 QString suffix;
1414 while ( rightOffset >= 0 ) { 1397 while ( rightOffset >= 0 ) {
1415 if ( suffixes.contains( parts[ rightOffset ] ) ) { 1398 if ( suffixes.contains( parts[ rightOffset ] ) ) {
1416 suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); 1399 suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " "));
1417 rightOffset--; 1400 rightOffset--;
1418 } else 1401 } else
1419 break; 1402 break;
1420 } 1403 }
1421 setSuffix( suffix ); 1404 setSuffix( suffix );
1422 1405
1423 if ( rightOffset < 0 ) 1406 if ( rightOffset < 0 )
1424 return; 1407 return;
1425 1408
1426 if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { 1409 if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) {
1427 setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); 1410 setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] );
1428 rightOffset--; 1411 rightOffset--;
1429 } else 1412 } else
1430 setFamilyName( parts[ rightOffset ] ); 1413 setFamilyName( parts[ rightOffset ] );
1431 1414
1432 QString prefix; 1415 QString prefix;
1433 while ( leftOffset < rightOffset ) { 1416 while ( leftOffset < rightOffset ) {
1434 if ( titles.contains( parts[ leftOffset ] ) ) { 1417 if ( titles.contains( parts[ leftOffset ] ) ) {
1435 prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); 1418 prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] );
1436 leftOffset++; 1419 leftOffset++;
1437 } else 1420 } else
1438 break; 1421 break;
1439 } 1422 }
1440 setPrefix( prefix ); 1423 setPrefix( prefix );
1441 1424
1442 if ( leftOffset < rightOffset ) { 1425 if ( leftOffset < rightOffset ) {
1443 setGivenName( parts[ leftOffset ] ); 1426 setGivenName( parts[ leftOffset ] );
1444 leftOffset++; 1427 leftOffset++;
1445 } 1428 }
1446 1429
1447 QString additionalName; 1430 QString additionalName;
1448 while ( leftOffset < rightOffset ) { 1431 while ( leftOffset < rightOffset ) {
1449 additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); 1432 additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] );
1450 leftOffset++; 1433 leftOffset++;
1451 } 1434 }
1452 setAdditionalName( additionalName ); 1435 setAdditionalName( additionalName );
1453 } else { 1436 } else {
1454 QString part1 = str.left( i ); 1437 QString part1 = str.left( i );
1455 QString part2 = str.mid( i + 1 ); 1438 QString part2 = str.mid( i + 1 );
1456 1439
1457 QStringList parts = QStringList::split( " ", part1 ); 1440 QStringList parts = QStringList::split( " ", part1 );
1458 int leftOffset = 0; 1441 int leftOffset = 0;
1459 int rightOffset = parts.count() - 1; 1442 int rightOffset = parts.count() - 1;
1460 1443
1461 QString suffix; 1444 QString suffix;
1462 while ( rightOffset >= 0 ) { 1445 while ( rightOffset >= 0 ) {
1463 if ( suffixes.contains( parts[ rightOffset ] ) ) { 1446 if ( suffixes.contains( parts[ rightOffset ] ) ) {
1464 suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); 1447 suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " "));
1465 rightOffset--; 1448 rightOffset--;
1466 } else 1449 } else
1467 break; 1450 break;
1468 } 1451 }
1469 setSuffix( suffix ); 1452 setSuffix( suffix );
1470 1453
1471 if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { 1454 if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) {
1472 setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); 1455 setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] );
1473 rightOffset--; 1456 rightOffset--;
1474 } else 1457 } else
1475 setFamilyName( parts[ rightOffset ] ); 1458 setFamilyName( parts[ rightOffset ] );
1476 1459
1477 QString prefix; 1460 QString prefix;
1478 while ( leftOffset < rightOffset ) { 1461 while ( leftOffset < rightOffset ) {
1479 if ( titles.contains( parts[ leftOffset ] ) ) { 1462 if ( titles.contains( parts[ leftOffset ] ) ) {
1480 prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); 1463 prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] );
1481 leftOffset++; 1464 leftOffset++;
1482 } else 1465 } else
1483 break; 1466 break;
1484 } 1467 }
1485 1468
1486 parts = QStringList::split( " ", part2 ); 1469 parts = QStringList::split( " ", part2 );
1487 1470
1488 leftOffset = 0; 1471 leftOffset = 0;
1489 rightOffset = parts.count(); 1472 rightOffset = parts.count();
1490 1473
1491 while ( leftOffset < rightOffset ) { 1474 while ( leftOffset < rightOffset ) {
1492 if ( titles.contains( parts[ leftOffset ] ) ) { 1475 if ( titles.contains( parts[ leftOffset ] ) ) {
1493 prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); 1476 prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] );
1494 leftOffset++; 1477 leftOffset++;
1495 } else 1478 } else
1496 break; 1479 break;
1497 } 1480 }
1498 setPrefix( prefix ); 1481 setPrefix( prefix );
1499 1482
1500 if ( leftOffset < rightOffset ) { 1483 if ( leftOffset < rightOffset ) {
1501 setGivenName( parts[ leftOffset ] ); 1484 setGivenName( parts[ leftOffset ] );
1502 leftOffset++; 1485 leftOffset++;
1503 } 1486 }
1504 1487
1505 QString additionalName; 1488 QString additionalName;
1506 while ( leftOffset < rightOffset ) { 1489 while ( leftOffset < rightOffset ) {
1507 additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); 1490 additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] );
1508 leftOffset++; 1491 leftOffset++;
1509 } 1492 }
1510 setAdditionalName( additionalName ); 1493 setAdditionalName( additionalName );
1511 } 1494 }
1512} 1495}
1513 1496
1514QString Addressee::realName() const 1497QString Addressee::realName() const
1515{ 1498{
1516 if ( !formattedName().isEmpty() ) 1499 if ( !formattedName().isEmpty() )
1517 return formattedName(); 1500 return formattedName();
1518 1501
1519 QString n = assembledName(); 1502 QString n = assembledName();
1520 1503
1521 if ( n.isEmpty() ) 1504 if ( n.isEmpty() )
1522 n = name(); 1505 n = name();
1523 if ( n.isEmpty() ) 1506 if ( n.isEmpty() )
1524 n = organization(); 1507 n = organization();
1525 return n; 1508 return n;
1526} 1509}
1527 1510
1528QString Addressee::assembledName() const 1511QString Addressee::assembledName() const
1529{ 1512{
1530 QString name = prefix() + " " + givenName() + " " + additionalName() + " " + 1513 QString name = prefix() + " " + givenName() + " " + additionalName() + " " +
1531 familyName() + " " + suffix(); 1514 familyName() + " " + suffix();
1532 1515
1533 return name.simplifyWhiteSpace(); 1516 return name.simplifyWhiteSpace();
1534} 1517}
1535 1518
1536QString Addressee::fullEmail( const QString &email ) const 1519QString Addressee::fullEmail( const QString &email ) const
1537{ 1520{
1538 QString e; 1521 QString e;
1539 if ( email.isNull() ) { 1522 if ( email.isNull() ) {
1540 e = preferredEmail(); 1523 e = preferredEmail();
1541 } else { 1524 } else {
1542 e = email; 1525 e = email;
1543 } 1526 }
1544 if ( e.isEmpty() ) return QString::null; 1527 if ( e.isEmpty() ) return QString::null;
1545 1528
1546 QString text; 1529 QString text;
1547 if ( realName().isEmpty() ) 1530 if ( realName().isEmpty() )
1548 text = e; 1531 text = e;
1549 else 1532 else
1550 text = assembledName() + " <" + e + ">"; 1533 text = assembledName() + " <" + e + ">";
1551 1534
1552 return text; 1535 return text;
1553} 1536}
1554 1537
1555void Addressee::insertEmail( const QString &email, bool preferred ) 1538void Addressee::insertEmail( const QString &email, bool preferred )
1556{ 1539{
1557 detach(); 1540 detach();
1558 1541
1559 QStringList::Iterator it = mData->emails.find( email ); 1542 QStringList::Iterator it = mData->emails.find( email );
1560 1543
1561 if ( it != mData->emails.end() ) { 1544 if ( it != mData->emails.end() ) {
1562 if ( !preferred || it == mData->emails.begin() ) return; 1545 if ( !preferred || it == mData->emails.begin() ) return;
1563 mData->emails.remove( it ); 1546 mData->emails.remove( it );
1564 mData->emails.prepend( email ); 1547 mData->emails.prepend( email );
1565 } else { 1548 } else {
1566 if ( preferred ) { 1549 if ( preferred ) {
1567 mData->emails.prepend( email ); 1550 mData->emails.prepend( email );
1568 } else { 1551 } else {
1569 mData->emails.append( email ); 1552 mData->emails.append( email );
1570 } 1553 }
1571 } 1554 }
1572} 1555}
1573 1556
1574void Addressee::removeEmail( const QString &email ) 1557void Addressee::removeEmail( const QString &email )
1575{ 1558{
1576 detach(); 1559 detach();
1577 1560
1578 QStringList::Iterator it = mData->emails.find( email ); 1561 QStringList::Iterator it = mData->emails.find( email );
1579 if ( it == mData->emails.end() ) return; 1562 if ( it == mData->emails.end() ) return;
1580 1563
1581 mData->emails.remove( it ); 1564 mData->emails.remove( it );
1582} 1565}
1583 1566
1584QString Addressee::preferredEmail() const 1567QString Addressee::preferredEmail() const
1585{ 1568{
1586 if ( mData->emails.count() == 0 ) return QString::null; 1569 if ( mData->emails.count() == 0 ) return QString::null;
1587 else return mData->emails.first(); 1570 else return mData->emails.first();
1588} 1571}
1589 1572
1590QStringList Addressee::emails() const 1573QStringList Addressee::emails() const
1591{ 1574{
1592 return mData->emails; 1575 return mData->emails;
1593} 1576}
1594void Addressee::setEmails( const QStringList& emails ) { 1577void Addressee::setEmails( const QStringList& emails ) {
1595 detach(); 1578 detach();
1596 mData->emails = emails; 1579 mData->emails = emails;
1597} 1580}
1598void Addressee::insertPhoneNumber( const PhoneNumber &phoneNumber ) 1581void Addressee::insertPhoneNumber( const PhoneNumber &phoneNumber )
1599{ 1582{
1600 detach(); 1583 detach();
1601 mData->empty = false; 1584 mData->empty = false;
1602 1585
1603 PhoneNumber::List::Iterator it; 1586 PhoneNumber::List::Iterator it;
1604 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 1587 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
1605 if ( (*it).id() == phoneNumber.id() ) { 1588 if ( (*it).id() == phoneNumber.id() ) {
1606 *it = phoneNumber; 1589 *it = phoneNumber;
1607 return; 1590 return;
1608 } 1591 }
1609 } 1592 }
1610 mData->phoneNumbers.append( phoneNumber ); 1593 mData->phoneNumbers.append( phoneNumber );
1611} 1594}
1612 1595
1613void Addressee::removePhoneNumber( const PhoneNumber &phoneNumber ) 1596void Addressee::removePhoneNumber( const PhoneNumber &phoneNumber )
1614{ 1597{
1615 detach(); 1598 detach();
1616 1599
1617 PhoneNumber::List::Iterator it; 1600 PhoneNumber::List::Iterator it;
1618 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 1601 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
1619 if ( (*it).id() == phoneNumber.id() ) { 1602 if ( (*it).id() == phoneNumber.id() ) {
1620 mData->phoneNumbers.remove( it ); 1603 mData->phoneNumbers.remove( it );
1621 return; 1604 return;
1622 } 1605 }
1623 } 1606 }
1624} 1607}
1625 1608
1626PhoneNumber Addressee::phoneNumber( int type ) const 1609PhoneNumber Addressee::phoneNumber( int type ) const
1627{ 1610{
1628 PhoneNumber phoneNumber( "", type ); 1611 PhoneNumber phoneNumber( "", type );
1629 PhoneNumber::List::ConstIterator it; 1612 PhoneNumber::List::ConstIterator it;
1630 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 1613 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
1631 if ( matchBinaryPatternP( (*it).type(), type ) ) { 1614 if ( matchBinaryPatternP( (*it).type(), type ) ) {
1632 if ( (*it).type() & PhoneNumber::Pref ) 1615 if ( (*it).type() & PhoneNumber::Pref )
1633 return (*it); 1616 return (*it);
1634 else if ( phoneNumber.number().isEmpty() ) 1617 else if ( phoneNumber.number().isEmpty() )
1635 phoneNumber = (*it); 1618 phoneNumber = (*it);
1636 } 1619 }
1637 } 1620 }
1638 1621
1639 return phoneNumber; 1622 return phoneNumber;
1640} 1623}
1641 1624
1642PhoneNumber::List Addressee::phoneNumbers() const 1625PhoneNumber::List Addressee::phoneNumbers() const
1643{ 1626{
1644 return mData->phoneNumbers; 1627 return mData->phoneNumbers;
1645} 1628}
1646 1629
1647PhoneNumber::List Addressee::phoneNumbers( int type ) const 1630PhoneNumber::List Addressee::phoneNumbers( int type ) const
1648{ 1631{
1649 PhoneNumber::List list; 1632 PhoneNumber::List list;
1650 1633
1651 PhoneNumber::List::ConstIterator it; 1634 PhoneNumber::List::ConstIterator it;
1652 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 1635 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
1653 if ( matchBinaryPattern( (*it).type(), type ) ) { 1636 if ( matchBinaryPattern( (*it).type(), type ) ) {
1654 list.append( *it ); 1637 list.append( *it );
1655 } 1638 }
1656 } 1639 }
1657 return list; 1640 return list;
1658} 1641}
1659 1642
1660PhoneNumber Addressee::findPhoneNumber( const QString &id ) const 1643PhoneNumber Addressee::findPhoneNumber( const QString &id ) const
1661{ 1644{
1662 PhoneNumber::List::ConstIterator it; 1645 PhoneNumber::List::ConstIterator it;
1663 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 1646 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
1664 if ( (*it).id() == id ) { 1647 if ( (*it).id() == id ) {
1665 return *it; 1648 return *it;
1666 } 1649 }
1667 } 1650 }
1668 return PhoneNumber(); 1651 return PhoneNumber();
1669} 1652}
1670 1653
1671void Addressee::insertKey( const Key &key ) 1654void Addressee::insertKey( const Key &key )
1672{ 1655{
1673 detach(); 1656 detach();
1674 mData->empty = false; 1657 mData->empty = false;
1675 1658
1676 Key::List::Iterator it; 1659 Key::List::Iterator it;
1677 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { 1660 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
1678 if ( (*it).id() == key.id() ) { 1661 if ( (*it).id() == key.id() ) {
1679 *it = key; 1662 *it = key;
1680 return; 1663 return;
1681 } 1664 }
1682 } 1665 }
1683 mData->keys.append( key ); 1666 mData->keys.append( key );
1684} 1667}
1685 1668
1686void Addressee::removeKey( const Key &key ) 1669void Addressee::removeKey( const Key &key )
1687{ 1670{
1688 detach(); 1671 detach();
1689 1672
1690 Key::List::Iterator it; 1673 Key::List::Iterator it;
1691 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { 1674 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
1692 if ( (*it).id() == key.id() ) { 1675 if ( (*it).id() == key.id() ) {
1693 mData->keys.remove( key ); 1676 mData->keys.remove( key );
1694 return; 1677 return;
1695 } 1678 }
1696 } 1679 }
1697} 1680}
1698 1681
1699Key Addressee::key( int type, QString customTypeString ) const 1682Key Addressee::key( int type, QString customTypeString ) const
1700{ 1683{
1701 Key::List::ConstIterator it; 1684 Key::List::ConstIterator it;
1702 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { 1685 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
1703 if ( (*it).type() == type ) { 1686 if ( (*it).type() == type ) {
1704 if ( type == Key::Custom ) { 1687 if ( type == Key::Custom ) {
1705 if ( customTypeString.isEmpty() ) { 1688 if ( customTypeString.isEmpty() ) {
1706 return *it; 1689 return *it;
1707 } else { 1690 } else {
1708 if ( (*it).customTypeString() == customTypeString ) 1691 if ( (*it).customTypeString() == customTypeString )
1709 return (*it); 1692 return (*it);
1710 } 1693 }
1711 } else { 1694 } else {
1712 return *it; 1695 return *it;
1713 } 1696 }
1714 } 1697 }
1715 } 1698 }
1716 return Key( QString(), type ); 1699 return Key( QString(), type );
1717} 1700}
1718void Addressee::setKeys( const Key::List& list ) { 1701void Addressee::setKeys( const Key::List& list ) {
1719 detach(); 1702 detach();
1720 mData->keys = list; 1703 mData->keys = list;
1721} 1704}
1722 1705
1723Key::List Addressee::keys() const 1706Key::List Addressee::keys() const
1724{ 1707{
1725 return mData->keys; 1708 return mData->keys;
1726} 1709}
1727 1710
1728Key::List Addressee::keys( int type, QString customTypeString ) const 1711Key::List Addressee::keys( int type, QString customTypeString ) const
1729{ 1712{
1730 Key::List list; 1713 Key::List list;
1731 1714
1732 Key::List::ConstIterator it; 1715 Key::List::ConstIterator it;
1733 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { 1716 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
1734 if ( (*it).type() == type ) { 1717 if ( (*it).type() == type ) {
1735 if ( type == Key::Custom ) { 1718 if ( type == Key::Custom ) {
1736 if ( customTypeString.isEmpty() ) { 1719 if ( customTypeString.isEmpty() ) {
1737 list.append(*it); 1720 list.append(*it);
1738 } else { 1721 } else {
1739 if ( (*it).customTypeString() == customTypeString ) 1722 if ( (*it).customTypeString() == customTypeString )
1740 list.append(*it); 1723 list.append(*it);
1741 } 1724 }
1742 } else { 1725 } else {
1743 list.append(*it); 1726 list.append(*it);
1744 } 1727 }
1745 } 1728 }
1746 } 1729 }
1747 return list; 1730 return list;
1748} 1731}
1749 1732
1750Key Addressee::findKey( const QString &id ) const 1733Key Addressee::findKey( const QString &id ) const
1751{ 1734{
1752 Key::List::ConstIterator it; 1735 Key::List::ConstIterator it;
1753 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { 1736 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
1754 if ( (*it).id() == id ) { 1737 if ( (*it).id() == id ) {
1755 return *it; 1738 return *it;
1756 } 1739 }
1757 } 1740 }
1758 return Key(); 1741 return Key();
1759} 1742}
1760 1743
1761QString Addressee::asString() const 1744QString Addressee::asString() const
1762{ 1745{
1763 return "Smith, agent Smith..."; 1746 return "Smith, agent Smith...";
1764} 1747}
1765 1748
1766void Addressee::dump() const 1749void Addressee::dump() const
1767{ 1750{
1768 return; 1751 return;
1769#if 0 1752#if 0
1770 kdDebug(5700) << "Addressee {" << endl; 1753 kdDebug(5700) << "Addressee {" << endl;
1771 1754
1772 kdDebug(5700) << " Uid: '" << uid() << "'" << endl; 1755 kdDebug(5700) << " Uid: '" << uid() << "'" << endl;
1773 1756
1774 kdDebug(5700) << " Name: '" << name() << "'" << endl; 1757 kdDebug(5700) << " Name: '" << name() << "'" << endl;
1775 kdDebug(5700) << " FormattedName: '" << formattedName() << "'" << endl; 1758 kdDebug(5700) << " FormattedName: '" << formattedName() << "'" << endl;
1776 kdDebug(5700) << " FamilyName: '" << familyName() << "'" << endl; 1759 kdDebug(5700) << " FamilyName: '" << familyName() << "'" << endl;
1777 kdDebug(5700) << " GivenName: '" << givenName() << "'" << endl; 1760 kdDebug(5700) << " GivenName: '" << givenName() << "'" << endl;
1778 kdDebug(5700) << " AdditionalName: '" << additionalName() << "'" << endl; 1761 kdDebug(5700) << " AdditionalName: '" << additionalName() << "'" << endl;
1779 kdDebug(5700) << " Prefix: '" << prefix() << "'" << endl; 1762 kdDebug(5700) << " Prefix: '" << prefix() << "'" << endl;
1780 kdDebug(5700) << " Suffix: '" << suffix() << "'" << endl; 1763 kdDebug(5700) << " Suffix: '" << suffix() << "'" << endl;
1781 kdDebug(5700) << " NickName: '" << nickName() << "'" << endl; 1764 kdDebug(5700) << " NickName: '" << nickName() << "'" << endl;
1782 kdDebug(5700) << " Birthday: '" << birthday().toString() << "'" << endl; 1765 kdDebug(5700) << " Birthday: '" << birthday().toString() << "'" << endl;
1783 kdDebug(5700) << " Mailer: '" << mailer() << "'" << endl; 1766 kdDebug(5700) << " Mailer: '" << mailer() << "'" << endl;
1784 kdDebug(5700) << " TimeZone: '" << timeZone().asString() << "'" << endl; 1767 kdDebug(5700) << " TimeZone: '" << timeZone().asString() << "'" << endl;
1785 kdDebug(5700) << " Geo: '" << geo().asString() << "'" << endl; 1768 kdDebug(5700) << " Geo: '" << geo().asString() << "'" << endl;
1786 kdDebug(5700) << " Title: '" << title() << "'" << endl; 1769 kdDebug(5700) << " Title: '" << title() << "'" << endl;
1787 kdDebug(5700) << " Role: '" << role() << "'" << endl; 1770 kdDebug(5700) << " Role: '" << role() << "'" << endl;
1788 kdDebug(5700) << " Organization: '" << organization() << "'" << endl; 1771 kdDebug(5700) << " Organization: '" << organization() << "'" << endl;
1789 kdDebug(5700) << " Note: '" << note() << "'" << endl; 1772 kdDebug(5700) << " Note: '" << note() << "'" << endl;
1790 kdDebug(5700) << " ProductId: '" << productId() << "'" << endl; 1773 kdDebug(5700) << " ProductId: '" << productId() << "'" << endl;
1791 kdDebug(5700) << " Revision: '" << revision().toString() << "'" << endl; 1774 kdDebug(5700) << " Revision: '" << revision().toString() << "'" << endl;
1792 kdDebug(5700) << " SortString: '" << sortString() << "'" << endl; 1775 kdDebug(5700) << " SortString: '" << sortString() << "'" << endl;
1793 kdDebug(5700) << " Url: '" << url().url() << "'" << endl; 1776 kdDebug(5700) << " Url: '" << url().url() << "'" << endl;
1794 kdDebug(5700) << " Secrecy: '" << secrecy().asString() << "'" << endl; 1777 kdDebug(5700) << " Secrecy: '" << secrecy().asString() << "'" << endl;
1795 kdDebug(5700) << " Logo: '" << logo().asString() << "'" << endl; 1778 kdDebug(5700) << " Logo: '" << logo().asString() << "'" << endl;
1796 kdDebug(5700) << " Photo: '" << photo().asString() << "'" << endl; 1779 kdDebug(5700) << " Photo: '" << photo().asString() << "'" << endl;
1797 kdDebug(5700) << " Sound: '" << sound().asString() << "'" << endl; 1780 kdDebug(5700) << " Sound: '" << sound().asString() << "'" << endl;
1798 kdDebug(5700) << " Agent: '" << agent().asString() << "'" << endl; 1781 kdDebug(5700) << " Agent: '" << agent().asString() << "'" << endl;
1799 1782
1800 kdDebug(5700) << " Emails {" << endl; 1783 kdDebug(5700) << " Emails {" << endl;
1801 QStringList e = emails(); 1784 QStringList e = emails();
1802 QStringList::ConstIterator it; 1785 QStringList::ConstIterator it;
1803 for( it = e.begin(); it != e.end(); ++it ) { 1786 for( it = e.begin(); it != e.end(); ++it ) {
1804 kdDebug(5700) << " " << (*it) << endl; 1787 kdDebug(5700) << " " << (*it) << endl;
1805 } 1788 }
1806 kdDebug(5700) << " }" << endl; 1789 kdDebug(5700) << " }" << endl;
1807 1790
1808 kdDebug(5700) << " PhoneNumbers {" << endl; 1791 kdDebug(5700) << " PhoneNumbers {" << endl;
1809 PhoneNumber::List p = phoneNumbers(); 1792 PhoneNumber::List p = phoneNumbers();
1810 PhoneNumber::List::ConstIterator it2; 1793 PhoneNumber::List::ConstIterator it2;
1811 for( it2 = p.begin(); it2 != p.end(); ++it2 ) { 1794 for( it2 = p.begin(); it2 != p.end(); ++it2 ) {
1812 kdDebug(5700) << " Type: " << int((*it2).type()) << " Number: " << (*it2).number() << endl; 1795 kdDebug(5700) << " Type: " << int((*it2).type()) << " Number: " << (*it2).number() << endl;
1813 } 1796 }
1814 kdDebug(5700) << " }" << endl; 1797 kdDebug(5700) << " }" << endl;
1815 1798
1816 Address::List a = addresses(); 1799 Address::List a = addresses();
1817 Address::List::ConstIterator it3; 1800 Address::List::ConstIterator it3;
1818 for( it3 = a.begin(); it3 != a.end(); ++it3 ) { 1801 for( it3 = a.begin(); it3 != a.end(); ++it3 ) {
1819 (*it3).dump(); 1802 (*it3).dump();
1820 } 1803 }
1821 1804
1822 kdDebug(5700) << " Keys {" << endl; 1805 kdDebug(5700) << " Keys {" << endl;
1823 Key::List k = keys(); 1806 Key::List k = keys();
1824 Key::List::ConstIterator it4; 1807 Key::List::ConstIterator it4;
1825 for( it4 = k.begin(); it4 != k.end(); ++it4 ) { 1808 for( it4 = k.begin(); it4 != k.end(); ++it4 ) {
1826 kdDebug(5700) << " Type: " << int((*it4).type()) << 1809 kdDebug(5700) << " Type: " << int((*it4).type()) <<
1827 " Key: " << (*it4).textData() << 1810 " Key: " << (*it4).textData() <<
1828 " CustomString: " << (*it4).customTypeString() << endl; 1811 " CustomString: " << (*it4).customTypeString() << endl;
1829 } 1812 }
1830 kdDebug(5700) << " }" << endl; 1813 kdDebug(5700) << " }" << endl;
1831 1814
1832 kdDebug(5700) << "}" << endl; 1815 kdDebug(5700) << "}" << endl;
1833#endif 1816#endif
1834} 1817}
1835 1818
1836 1819
1837void Addressee::insertAddress( const Address &address ) 1820void Addressee::insertAddress( const Address &address )
1838{ 1821{
1839 detach(); 1822 detach();
1840 mData->empty = false; 1823 mData->empty = false;
1841 1824
1842 Address::List::Iterator it; 1825 Address::List::Iterator it;
1843 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 1826 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
1844 if ( (*it).id() == address.id() ) { 1827 if ( (*it).id() == address.id() ) {
1845 *it = address; 1828 *it = address;
1846 return; 1829 return;
1847 } 1830 }
1848 } 1831 }
1849 mData->addresses.append( address ); 1832 mData->addresses.append( address );
1850} 1833}
1851 1834
1852void Addressee::removeAddress( const Address &address ) 1835void Addressee::removeAddress( const Address &address )
1853{ 1836{
1854 detach(); 1837 detach();
1855 1838
1856 Address::List::Iterator it; 1839 Address::List::Iterator it;
1857 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 1840 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
1858 if ( (*it).id() == address.id() ) { 1841 if ( (*it).id() == address.id() ) {
1859 mData->addresses.remove( it ); 1842 mData->addresses.remove( it );
1860 return; 1843 return;
1861 } 1844 }
1862 } 1845 }
1863} 1846}
1864 1847
1865Address Addressee::address( int type ) const 1848Address Addressee::address( int type ) const
1866{ 1849{
1867 Address address( type ); 1850 Address address( type );
1868 Address::List::ConstIterator it; 1851 Address::List::ConstIterator it;
1869 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 1852 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
1870 if ( matchBinaryPatternA( (*it).type(), type ) ) { 1853 if ( matchBinaryPatternA( (*it).type(), type ) ) {
1871 if ( (*it).type() & Address::Pref ) 1854 if ( (*it).type() & Address::Pref )
1872 return (*it); 1855 return (*it);
1873 else if ( address.isEmpty() ) 1856 else if ( address.isEmpty() )
1874 address = (*it); 1857 address = (*it);
1875 } 1858 }
1876 } 1859 }
1877 1860
1878 return address; 1861 return address;
1879} 1862}
1880 1863
1881Address::List Addressee::addresses() const 1864Address::List Addressee::addresses() const
1882{ 1865{
1883 return mData->addresses; 1866 return mData->addresses;
1884} 1867}
1885 1868
1886Address::List Addressee::addresses( int type ) const 1869Address::List Addressee::addresses( int type ) const
1887{ 1870{
1888 Address::List list; 1871 Address::List list;
1889 1872
1890 Address::List::ConstIterator it; 1873 Address::List::ConstIterator it;
1891 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 1874 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
1892 if ( matchBinaryPattern( (*it).type(), type ) ) { 1875 if ( matchBinaryPattern( (*it).type(), type ) ) {
1893 list.append( *it ); 1876 list.append( *it );
1894 } 1877 }
1895 } 1878 }
1896 1879
1897 return list; 1880 return list;
1898} 1881}
1899 1882
1900Address Addressee::findAddress( const QString &id ) const 1883Address Addressee::findAddress( const QString &id ) const
1901{ 1884{
1902 Address::List::ConstIterator it; 1885 Address::List::ConstIterator it;
1903 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 1886 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
1904 if ( (*it).id() == id ) { 1887 if ( (*it).id() == id ) {
1905 return *it; 1888 return *it;
1906 } 1889 }
1907 } 1890 }
1908 return Address(); 1891 return Address();
1909} 1892}
1910 1893
1911void Addressee::insertCategory( const QString &c ) 1894void Addressee::insertCategory( const QString &c )
1912{ 1895{
1913 detach(); 1896 detach();
1914 mData->empty = false; 1897 mData->empty = false;
1915 1898
1916 if ( mData->categories.contains( c ) ) return; 1899 if ( mData->categories.contains( c ) ) return;
1917 1900
1918 mData->categories.append( c ); 1901 mData->categories.append( c );
1919} 1902}
1920 1903
1921void Addressee::removeCategory( const QString &c ) 1904void Addressee::removeCategory( const QString &c )
1922{ 1905{
1923 detach(); 1906 detach();
1924 1907
1925 QStringList::Iterator it = mData->categories.find( c ); 1908 QStringList::Iterator it = mData->categories.find( c );
1926 if ( it == mData->categories.end() ) return; 1909 if ( it == mData->categories.end() ) return;
1927 1910
1928 mData->categories.remove( it ); 1911 mData->categories.remove( it );
1929} 1912}
1930 1913
1931bool Addressee::hasCategory( const QString &c ) const 1914bool Addressee::hasCategory( const QString &c ) const
1932{ 1915{
1933 return ( mData->categories.contains( c ) ); 1916 return ( mData->categories.contains( c ) );
1934} 1917}
1935 1918
1936void Addressee::setCategories( const QStringList &c ) 1919void Addressee::setCategories( const QStringList &c )
1937{ 1920{
1938 detach(); 1921 detach();
1939 mData->empty = false; 1922 mData->empty = false;
1940 1923
1941 mData->categories = c; 1924 mData->categories = c;
1942} 1925}
1943 1926
1944QStringList Addressee::categories() const 1927QStringList Addressee::categories() const
1945{ 1928{
1946 return mData->categories; 1929 return mData->categories;
1947} 1930}
1948 1931
1949void Addressee::insertCustom( const QString &app, const QString &name, 1932void Addressee::insertCustom( const QString &app, const QString &name,
1950 const QString &value ) 1933 const QString &value )
1951{ 1934{
1952 if ( value.isNull() || name.isEmpty() || app.isEmpty() ) return; 1935 if ( value.isNull() || name.isEmpty() || app.isEmpty() ) return;
1953 1936
1954 detach(); 1937 detach();
1955 mData->empty = false; 1938 mData->empty = false;
1956 1939
1957 QString qualifiedName = app + "-" + name + ":"; 1940 QString qualifiedName = app + "-" + name + ":";
1958 1941
1959 QStringList::Iterator it; 1942 QStringList::Iterator it;
1960 for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { 1943 for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) {
1961 if ( (*it).startsWith( qualifiedName ) ) { 1944 if ( (*it).startsWith( qualifiedName ) ) {
1962 (*it) = qualifiedName + value; 1945 (*it) = qualifiedName + value;
1963 return; 1946 return;
1964 } 1947 }
1965 } 1948 }
1966 mData->custom.append( qualifiedName + value ); 1949 mData->custom.append( qualifiedName + value );
1967} 1950}
1968 1951
1969void Addressee::removeCustom( const QString &app, const QString &name) 1952void Addressee::removeCustom( const QString &app, const QString &name)
1970{ 1953{
1971 detach(); 1954 detach();
1972 1955
1973 QString qualifiedName = app + "-" + name + ":"; 1956 QString qualifiedName = app + "-" + name + ":";
1974 1957
1975 QStringList::Iterator it; 1958 QStringList::Iterator it;
1976 for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { 1959 for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) {
1977 if ( (*it).startsWith( qualifiedName ) ) { 1960 if ( (*it).startsWith( qualifiedName ) ) {
1978 mData->custom.remove( it ); 1961 mData->custom.remove( it );
1979 return; 1962 return;
1980 } 1963 }
1981 } 1964 }
1982} 1965}
1983 1966
1984QString Addressee::custom( const QString &app, const QString &name ) const 1967QString Addressee::custom( const QString &app, const QString &name ) const
1985{ 1968{
1986 QString qualifiedName = app + "-" + name + ":"; 1969 QString qualifiedName = app + "-" + name + ":";
1987 QString value; 1970 QString value;
1988 1971
1989 QStringList::ConstIterator it; 1972 QStringList::ConstIterator it;
1990 for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { 1973 for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) {
1991 if ( (*it).startsWith( qualifiedName ) ) { 1974 if ( (*it).startsWith( qualifiedName ) ) {
1992 value = (*it).mid( (*it).find( ":" ) + 1 ); 1975 value = (*it).mid( (*it).find( ":" ) + 1 );
1993 break; 1976 break;
1994 } 1977 }
1995 } 1978 }
1996 1979
1997 return value; 1980 return value;
1998} 1981}
1999 1982
2000void Addressee::setCustoms( const QStringList &l ) 1983void Addressee::setCustoms( const QStringList &l )
2001{ 1984{
2002 detach(); 1985 detach();
2003 mData->empty = false; 1986 mData->empty = false;
2004 1987
2005 mData->custom = l; 1988 mData->custom = l;
2006} 1989}
2007 1990
2008QStringList Addressee::customs() const 1991QStringList Addressee::customs() const
2009{ 1992{
2010 return mData->custom; 1993 return mData->custom;
2011} 1994}
2012 1995
2013void Addressee::parseEmailAddress( const QString &rawEmail, QString &fullName, 1996void Addressee::parseEmailAddress( const QString &rawEmail, QString &fullName,
2014 QString &email) 1997 QString &email)
2015{ 1998{
2016 int startPos, endPos, len; 1999 int startPos, endPos, len;
2017 QString partA, partB, result; 2000 QString partA, partB, result;
2018 char endCh = '>'; 2001 char endCh = '>';
2019 2002
2020 startPos = rawEmail.find('<'); 2003 startPos = rawEmail.find('<');
2021 if (startPos < 0) 2004 if (startPos < 0)
2022 { 2005 {
2023 startPos = rawEmail.find('('); 2006 startPos = rawEmail.find('(');
2024 endCh = ')'; 2007 endCh = ')';
2025 } 2008 }
2026 if (startPos < 0) 2009 if (startPos < 0)
2027 { 2010 {
2028 // We couldn't find any separators, so we assume the whole string 2011 // We couldn't find any separators, so we assume the whole string
2029 // is the email address 2012 // is the email address
2030 email = rawEmail; 2013 email = rawEmail;
2031 fullName = ""; 2014 fullName = "";
2032 } 2015 }
2033 else 2016 else
2034 { 2017 {
2035 // We have a start position, try to find an end 2018 // We have a start position, try to find an end
2036 endPos = rawEmail.find(endCh, startPos+1); 2019 endPos = rawEmail.find(endCh, startPos+1);
2037 2020
2038 if (endPos < 0) 2021 if (endPos < 0)
2039 { 2022 {
2040 // We couldn't find the end of the email address. We can only 2023 // We couldn't find the end of the email address. We can only
2041 // assume the entire string is the email address. 2024 // assume the entire string is the email address.
2042 email = rawEmail; 2025 email = rawEmail;
2043 fullName = ""; 2026 fullName = "";
2044 } 2027 }
2045 else 2028 else
2046 { 2029 {
2047 // We have a start and end to the email address 2030 // We have a start and end to the email address
2048 2031
2049 // Grab the name part 2032 // Grab the name part
2050 fullName = rawEmail.left(startPos).stripWhiteSpace(); 2033 fullName = rawEmail.left(startPos).stripWhiteSpace();
2051 2034
2052 // grab the email part 2035 // grab the email part
2053 email = rawEmail.mid(startPos+1, endPos-startPos-1).stripWhiteSpace(); 2036 email = rawEmail.mid(startPos+1, endPos-startPos-1).stripWhiteSpace();
2054 2037
2055 // Check that we do not have any extra characters on the end of the 2038 // Check that we do not have any extra characters on the end of the
2056 // strings 2039 // strings
2057 len = fullName.length(); 2040 len = fullName.length();
2058 if (fullName[0]=='"' && fullName[len-1]=='"') 2041 if (fullName[0]=='"' && fullName[len-1]=='"')
2059 fullName = fullName.mid(1, len-2); 2042 fullName = fullName.mid(1, len-2);
2060 else if (fullName[0]=='<' && fullName[len-1]=='>') 2043 else if (fullName[0]=='<' && fullName[len-1]=='>')
2061 fullName = fullName.mid(1, len-2); 2044 fullName = fullName.mid(1, len-2);
2062 else if (fullName[0]=='(' && fullName[len-1]==')') 2045 else if (fullName[0]=='(' && fullName[len-1]==')')
2063 fullName = fullName.mid(1, len-2); 2046 fullName = fullName.mid(1, len-2);
2064 } 2047 }
2065 } 2048 }
2066} 2049}
2067 2050
2068void Addressee::setResource( Resource *resource ) 2051void Addressee::setResource( Resource *resource )
2069{ 2052{
2070 detach(); 2053 detach();
2071 mData->resource = resource; 2054 mData->resource = resource;
2072} 2055}
2073 2056
2074Resource *Addressee::resource() const 2057Resource *Addressee::resource() const
2075{ 2058{
2076 return mData->resource; 2059 return mData->resource;
2077} 2060}
2078 2061
2079//US 2062//US
2080QString Addressee::resourceLabel() 2063QString Addressee::resourceLabel()
2081{ 2064{
2082 return i18n("Resource"); 2065 return i18n("Resource");
2083} 2066}
2084QString Addressee::categoryLabel() 2067QString Addressee::categoryLabel()
2085{ 2068{
2086 return i18n("Category"); 2069 return i18n("Category");
2087} 2070}
2088 2071
2089void Addressee::setChanged( bool value ) 2072void Addressee::setChanged( bool value )
2090{ 2073{
2091 detach(); 2074 detach();
2092 mData->changed = value; 2075 mData->changed = value;
2093} 2076}
2094 2077
2095bool Addressee::changed() const 2078bool Addressee::changed() const
2096{ 2079{
2097 return mData->changed; 2080 return mData->changed;
2098} 2081}
2099 2082
2100void Addressee::setTagged( bool value ) 2083void Addressee::setTagged( bool value )
2101{ 2084{
2102 detach(); 2085 detach();
2103 mData->tagged = value; 2086 mData->tagged = value;
2104} 2087}
2105 2088
2106bool Addressee::tagged() const 2089bool Addressee::tagged() const
2107{ 2090{
2108 return mData->tagged; 2091 return mData->tagged;
2109} 2092}
2110 2093
2111QDataStream &KABC::operator<<( QDataStream &s, const Addressee &a ) 2094QDataStream &KABC::operator<<( QDataStream &s, const Addressee &a )
2112{ 2095{
2113 if (!a.mData) return s; 2096 if (!a.mData) return s;
2114 2097
2115 s << a.uid(); 2098 s << a.uid();
2116 2099
2117 s << a.mData->name; 2100 s << a.mData->name;
2118 s << a.mData->formattedName; 2101 s << a.mData->formattedName;
2119 s << a.mData->familyName; 2102 s << a.mData->familyName;
2120 s << a.mData->givenName; 2103 s << a.mData->givenName;
2121 s << a.mData->additionalName; 2104 s << a.mData->additionalName;
2122 s << a.mData->prefix; 2105 s << a.mData->prefix;
2123 s << a.mData->suffix; 2106 s << a.mData->suffix;
2124 s << a.mData->nickName; 2107 s << a.mData->nickName;
2125 s << a.mData->birthday; 2108 s << a.mData->birthday;
2126 s << a.mData->mailer; 2109 s << a.mData->mailer;
2127 s << a.mData->timeZone; 2110 s << a.mData->timeZone;
2128 s << a.mData->geo; 2111 s << a.mData->geo;
2129 s << a.mData->title; 2112 s << a.mData->title;
2130 s << a.mData->role; 2113 s << a.mData->role;
2131 s << a.mData->organization; 2114 s << a.mData->organization;
2132 s << a.mData->note; 2115 s << a.mData->note;
2133 s << a.mData->productId; 2116 s << a.mData->productId;
2134 s << a.mData->revision; 2117 s << a.mData->revision;
2135 s << a.mData->sortString; 2118 s << a.mData->sortString;
2136 s << a.mData->url; 2119 s << a.mData->url;
2137 s << a.mData->secrecy; 2120 s << a.mData->secrecy;
2138 s << a.mData->logo; 2121 s << a.mData->logo;
2139 s << a.mData->photo; 2122 s << a.mData->photo;
2140 s << a.mData->sound; 2123 s << a.mData->sound;
2141 s << a.mData->agent; 2124 s << a.mData->agent;
2142 s << a.mData->phoneNumbers; 2125 s << a.mData->phoneNumbers;
2143 s << a.mData->addresses; 2126 s << a.mData->addresses;
2144 s << a.mData->emails; 2127 s << a.mData->emails;
2145 s << a.mData->categories; 2128 s << a.mData->categories;
2146 s << a.mData->custom; 2129 s << a.mData->custom;
2147 s << a.mData->keys; 2130 s << a.mData->keys;
2148 return s; 2131 return s;
2149} 2132}
2150 2133
2151QDataStream &KABC::operator>>( QDataStream &s, Addressee &a ) 2134QDataStream &KABC::operator>>( QDataStream &s, Addressee &a )
2152{ 2135{
2153 if (!a.mData) return s; 2136 if (!a.mData) return s;
2154 2137
2155 s >> a.mData->uid; 2138 s >> a.mData->uid;
2156 2139
2157 s >> a.mData->name; 2140 s >> a.mData->name;
2158 s >> a.mData->formattedName; 2141 s >> a.mData->formattedName;
2159 s >> a.mData->familyName; 2142 s >> a.mData->familyName;
2160 s >> a.mData->givenName; 2143 s >> a.mData->givenName;
2161 s >> a.mData->additionalName; 2144 s >> a.mData->additionalName;
2162 s >> a.mData->prefix; 2145 s >> a.mData->prefix;
2163 s >> a.mData->suffix; 2146 s >> a.mData->suffix;
2164 s >> a.mData->nickName; 2147 s >> a.mData->nickName;
2165 s >> a.mData->birthday; 2148 s >> a.mData->birthday;
2166 s >> a.mData->mailer; 2149 s >> a.mData->mailer;
2167 s >> a.mData->timeZone; 2150 s >> a.mData->timeZone;
2168 s >> a.mData->geo; 2151 s >> a.mData->geo;
2169 s >> a.mData->title; 2152 s >> a.mData->title;
2170 s >> a.mData->role; 2153 s >> a.mData->role;
2171 s >> a.mData->organization; 2154 s >> a.mData->organization;
2172 s >> a.mData->note; 2155 s >> a.mData->note;
2173 s >> a.mData->productId; 2156 s >> a.mData->productId;
2174 s >> a.mData->revision; 2157 s >> a.mData->revision;
2175 s >> a.mData->sortString; 2158 s >> a.mData->sortString;
2176 s >> a.mData->url; 2159 s >> a.mData->url;
2177 s >> a.mData->secrecy; 2160 s >> a.mData->secrecy;
2178 s >> a.mData->logo; 2161 s >> a.mData->logo;
2179 s >> a.mData->photo; 2162 s >> a.mData->photo;
2180 s >> a.mData->sound; 2163 s >> a.mData->sound;
2181 s >> a.mData->agent; 2164 s >> a.mData->agent;
2182 s >> a.mData->phoneNumbers; 2165 s >> a.mData->phoneNumbers;
2183 s >> a.mData->addresses; 2166 s >> a.mData->addresses;
2184 s >> a.mData->emails; 2167 s >> a.mData->emails;
2185 s >> a.mData->categories; 2168 s >> a.mData->categories;
2186 s >> a.mData->custom; 2169 s >> a.mData->custom;
2187 s >> a.mData->keys; 2170 s >> a.mData->keys;
2188 2171
2189 a.mData->empty = false; 2172 a.mData->empty = false;
2190 2173
2191 return s; 2174 return s;
2192} 2175}
2193bool matchBinaryPattern( int value, int pattern ) 2176bool matchBinaryPattern( int value, int pattern )
2194{ 2177{
2195 /** 2178 /**
2196 We want to match all telephonnumbers/addresses which have the bits in the 2179 We want to match all telephonnumbers/addresses which have the bits in the
2197 pattern set. More are allowed. 2180 pattern set. More are allowed.
2198 if pattern == 0 we have a special handling, then we want only those with 2181 if pattern == 0 we have a special handling, then we want only those with
2199 exactly no bit set. 2182 exactly no bit set.
2200 */ 2183 */
2201 if ( pattern == 0 ) 2184 if ( pattern == 0 )
2202 return ( value == 0 ); 2185 return ( value == 0 );
2203 else 2186 else
2204 return ( pattern == ( pattern & value ) ); 2187 return ( pattern == ( pattern & value ) );
2205} 2188}
2206 2189
2207bool matchBinaryPatternP( int value, int pattern ) 2190bool matchBinaryPatternP( int value, int pattern )
2208{ 2191{
2209 2192
2210 if ( pattern == 0 ) 2193 if ( pattern == 0 )
2211 return ( value == 0 ); 2194 return ( value == 0 );
2212 else 2195 else
2213 return ( (pattern |PhoneNumber::Pref ) == ( value |PhoneNumber::Pref ) ); 2196 return ( (pattern |PhoneNumber::Pref ) == ( value |PhoneNumber::Pref ) );
2214} 2197}
2215bool matchBinaryPatternA( int value, int pattern ) 2198bool matchBinaryPatternA( int value, int pattern )
2216{ 2199{
2217 2200
2218 if ( pattern == 0 ) 2201 if ( pattern == 0 )
2219 return ( value == 0 ); 2202 return ( value == 0 );
2220 else 2203 else
2221 return ( (pattern | Address::Pref) == ( value | Address::Pref ) ); 2204 return ( (pattern | Address::Pref) == ( value | Address::Pref ) );
2222} 2205}
diff --git a/kabc/addressee.h b/kabc/addressee.h
index 0d688f8..a2fbcf5 100644
--- a/kabc/addressee.h
+++ b/kabc/addressee.h
@@ -1,858 +1,855 @@
1/*** Warning! This file has been generated by the script makeaddressee ***/ 1/*** Warning! This file has been generated by the script makeaddressee ***/
2/* 2/*
3 This file is part of libkabc. 3 This file is part of libkabc.
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/* 22/*
23Enhanced Version of the file for platform independent KDE tools. 23Enhanced Version of the file for platform independent KDE tools.
24Copyright (c) 2004 Ulf Schenk 24Copyright (c) 2004 Ulf Schenk
25 25
26$Id$ 26$Id$
27*/ 27*/
28 28
29#ifndef KABC_ADDRESSEE_H 29#ifndef KABC_ADDRESSEE_H
30#define KABC_ADDRESSEE_H 30#define KABC_ADDRESSEE_H
31 31
32#include <qdatetime.h> 32#include <qdatetime.h>
33#include <qstring.h> 33#include <qstring.h>
34#include <qstringlist.h> 34#include <qstringlist.h>
35#include <qvaluelist.h> 35#include <qvaluelist.h>
36 36
37#include <ksharedptr.h> 37#include <ksharedptr.h>
38#include <kurl.h> 38#include <kurl.h>
39 39
40#include "address.h" 40#include "address.h"
41#include "agent.h" 41#include "agent.h"
42#include "geo.h" 42#include "geo.h"
43#include "key.h" 43#include "key.h"
44#include "phonenumber.h" 44#include "phonenumber.h"
45#include "picture.h" 45#include "picture.h"
46#include "secrecy.h" 46#include "secrecy.h"
47#include "sound.h" 47#include "sound.h"
48#include "timezone.h" 48#include "timezone.h"
49 49
50namespace KABC { 50namespace KABC {
51 51
52class Resource; 52class Resource;
53 53
54/** 54/**
55 @short address book entry 55 @short address book entry
56 56
57 This class represents an entry in the address book. 57 This class represents an entry in the address book.
58 58
59 The data of this class is implicitly shared. You can pass this class by value. 59 The data of this class is implicitly shared. You can pass this class by value.
60 60
61 If you need the name of a field for presenting it to the user you should use 61 If you need the name of a field for presenting it to the user you should use
62 the functions ending in Label(). They return a translated string which can be 62 the functions ending in Label(). They return a translated string which can be
63 used as label for the corresponding field. 63 used as label for the corresponding field.
64 64
65 About the name fields: 65 About the name fields:
66 66
67 givenName() is the first name and familyName() the last name. In some 67 givenName() is the first name and familyName() the last name. In some
68 countries the family name comes first, that's the reason for the 68 countries the family name comes first, that's the reason for the
69 naming. formattedName() is the full name with the correct formatting. 69 naming. formattedName() is the full name with the correct formatting.
70 It is used as an override, when the correct formatting can't be generated 70 It is used as an override, when the correct formatting can't be generated
71 from the other name fields automatically. 71 from the other name fields automatically.
72 72
73 realName() returns a fully formatted name(). It uses formattedName, if set, 73 realName() returns a fully formatted name(). It uses formattedName, if set,
74 otherwise it constucts the name from the name fields. As fallback, if 74 otherwise it constucts the name from the name fields. As fallback, if
75 nothing else is set it uses name(). 75 nothing else is set it uses name().
76 76
77 name() is the NAME type of RFC2426. It can be used as internal name for the 77 name() is the NAME type of RFC2426. It can be used as internal name for the
78 data enty, but shouldn't be used for displaying the data to the user. 78 data enty, but shouldn't be used for displaying the data to the user.
79 */ 79 */
80class Addressee 80class Addressee
81{ 81{
82 friend QDataStream &operator<<( QDataStream &, const Addressee & ); 82 friend QDataStream &operator<<( QDataStream &, const Addressee & );
83 friend QDataStream &operator>>( QDataStream &, Addressee & ); 83 friend QDataStream &operator>>( QDataStream &, Addressee & );
84 84
85 public: 85 public:
86 typedef QValueList<Addressee> List; 86 typedef QValueList<Addressee> List;
87 87
88 /** 88 /**
89 Construct an empty address book entry. 89 Construct an empty address book entry.
90 */ 90 */
91 Addressee(); 91 Addressee();
92 ~Addressee(); 92 ~Addressee();
93 93
94 Addressee( const Addressee & ); 94 Addressee( const Addressee & );
95 Addressee &operator=( const Addressee & ); 95 Addressee &operator=( const Addressee & );
96 96
97 bool operator==( const Addressee & ) const; 97 bool operator==( const Addressee & ) const;
98 bool operator!=( const Addressee & ) const; 98 bool operator!=( const Addressee & ) const;
99 // sync stuff 99 // sync stuff
100 void setTempSyncStat(int id); 100 void setTempSyncStat(int id);
101 int tempSyncStat() const; 101 int tempSyncStat() const;
102 void setIDStr( const QString & ); 102 void setIDStr( const QString & );
103 const QString IDStr() const; 103 const QString IDStr() const;
104 void setID( const QString &, const QString & ); 104 void setID( const QString &, const QString & );
105 const QString getID( const QString & ) const; 105 const QString getID( const QString & ) const;
106 void setCsum( const QString &, const QString & ); 106 void setCsum( const QString &, const QString & );
107 const QString getCsum( const QString & ) const ; 107 const QString getCsum( const QString & ) const ;
108 void removeID(const QString &); 108 void removeID(const QString &);
109 void computeCsum(const QString &dev); 109 void computeCsum(const QString &dev);
110 ulong getCsum4List( const QStringList & attList); 110 ulong getCsum4List( const QStringList & attList);
111 /** 111 /**
112 Return, if the address book entry is empty. 112 Return, if the address book entry is empty.
113 */ 113 */
114 bool isEmpty() const; 114 bool isEmpty() const;
115 void setExternalUID( const QString &id ); 115 void setExternalUID( const QString &id );
116 const QString externalUID() const; 116 const QString externalUID() const;
117 void setOriginalExternalUID( const QString &id ); 117 void setOriginalExternalUID( const QString &id );
118 QString originalExternalUID() const; 118 QString originalExternalUID() const;
119 void mergeContact( const Addressee& ad, bool isSubSet ); 119 void mergeContact( const Addressee& ad, bool isSubSet );
120 void simplifyEmails(); 120 void simplifyEmails();
121 void simplifyAddresses(); 121 void simplifyAddresses();
122 void simplifyPhoneNumbers(); 122 void simplifyPhoneNumbers();
123 void simplifyPhoneNumberTypes(); 123 void simplifyPhoneNumberTypes();
124 bool removeVoice(); 124 bool removeVoice();
125 bool containsAdr(const Addressee& addr ); 125 bool containsAdr(const Addressee& addr );
126 126
127 /** 127 /**
128 Set unique identifier. 128 Set unique identifier.
129 */ 129 */
130 void setUid( const QString &uid ); 130 void setUid( const QString &uid );
131 /** 131 /**
132 Return unique identifier. 132 Return unique identifier.
133 */ 133 */
134 const QString uid() const; 134 const QString uid() const;
135 /** 135 /**
136 Return translated label for uid field. 136 Return translated label for uid field.
137 */ 137 */
138 static QString uidLabel(); 138 static QString uidLabel();
139 139
140 /** 140 /**
141 Set name. 141 Set name.
142 */ 142 */
143 void setName( const QString &name ); 143 void setName( const QString &name );
144 /** 144 /**
145 Return name. 145 Return name.
146 */ 146 */
147 QString name() const; 147 QString name() const;
148 /** 148 /**
149 Return translated label for name field. 149 Return translated label for name field.
150 */ 150 */
151 static QString nameLabel(); 151 static QString nameLabel();
152 152
153 /** 153 /**
154 Set formatted name. 154 Set formatted name.
155 */ 155 */
156 void setFormattedName( const QString &formattedName ); 156 void setFormattedName( const QString &formattedName );
157 void setDefaultFormattedName( const QString &formattedName );
158 /** 157 /**
159 Return formatted name. 158 Return formatted name.
160 */ 159 */
161 QString formattedName() const; 160 QString formattedName() const;
162 QString defaultFormattedName() const;
163 /** 161 /**
164 Return translated label for formattedName field. 162 Return translated label for formattedName field.
165 */ 163 */
166 static QString formattedNameLabel(); 164 static QString formattedNameLabel();
167 static QString defaultFormattedNameLabel();
168 165
169 /** 166 /**
170 Set family name. 167 Set family name.
171 */ 168 */
172 void setFamilyName( const QString &familyName ); 169 void setFamilyName( const QString &familyName );
173 /** 170 /**
174 Return family name. 171 Return family name.
175 */ 172 */
176 QString familyName() const; 173 QString familyName() const;
177 /** 174 /**
178 Return translated label for familyName field. 175 Return translated label for familyName field.
179 */ 176 */
180 static QString familyNameLabel(); 177 static QString familyNameLabel();
181 178
182 /** 179 /**
183 Set given name. 180 Set given name.
184 */ 181 */
185 void setGivenName( const QString &givenName ); 182 void setGivenName( const QString &givenName );
186 /** 183 /**
187 Return given name. 184 Return given name.
188 */ 185 */
189 QString givenName() const; 186 QString givenName() const;
190 /** 187 /**
191 Return translated label for givenName field. 188 Return translated label for givenName field.
192 */ 189 */
193 static QString givenNameLabel(); 190 static QString givenNameLabel();
194 191
195 /** 192 /**
196 Set additional names. 193 Set additional names.
197 */ 194 */
198 void setAdditionalName( const QString &additionalName ); 195 void setAdditionalName( const QString &additionalName );
199 /** 196 /**
200 Return additional names. 197 Return additional names.
201 */ 198 */
202 QString additionalName() const; 199 QString additionalName() const;
203 /** 200 /**
204 Return translated label for additionalName field. 201 Return translated label for additionalName field.
205 */ 202 */
206 static QString additionalNameLabel(); 203 static QString additionalNameLabel();
207 204
208 /** 205 /**
209 Set honorific prefixes. 206 Set honorific prefixes.
210 */ 207 */
211 void setPrefix( const QString &prefix ); 208 void setPrefix( const QString &prefix );
212 /** 209 /**
213 Return honorific prefixes. 210 Return honorific prefixes.
214 */ 211 */
215 QString prefix() const; 212 QString prefix() const;
216 /** 213 /**
217 Return translated label for prefix field. 214 Return translated label for prefix field.
218 */ 215 */
219 static QString prefixLabel(); 216 static QString prefixLabel();
220 217
221 /** 218 /**
222 Set honorific suffixes. 219 Set honorific suffixes.
223 */ 220 */
224 void setSuffix( const QString &suffix ); 221 void setSuffix( const QString &suffix );
225 /** 222 /**
226 Return honorific suffixes. 223 Return honorific suffixes.
227 */ 224 */
228 QString suffix() const; 225 QString suffix() const;
229 /** 226 /**
230 Return translated label for suffix field. 227 Return translated label for suffix field.
231 */ 228 */
232 static QString suffixLabel(); 229 static QString suffixLabel();
233 230
234 /** 231 /**
235 Set nick name. 232 Set nick name.
236 */ 233 */
237 void setNickName( const QString &nickName ); 234 void setNickName( const QString &nickName );
238 /** 235 /**
239 Return nick name. 236 Return nick name.
240 */ 237 */
241 QString nickName() const; 238 QString nickName() const;
242 /** 239 /**
243 Return translated label for nickName field. 240 Return translated label for nickName field.
244 */ 241 */
245 static QString nickNameLabel(); 242 static QString nickNameLabel();
246 243
247 /** 244 /**
248 Set birthday. 245 Set birthday.
249 */ 246 */
250 void setBirthday( const QDateTime &birthday ); 247 void setBirthday( const QDateTime &birthday );
251 /** 248 /**
252 Return birthday. 249 Return birthday.
253 */ 250 */
254 QDateTime birthday() const; 251 QDateTime birthday() const;
255 /** 252 /**
256 Return translated label for birthday field. 253 Return translated label for birthday field.
257 */ 254 */
258 static QString birthdayLabel(); 255 static QString birthdayLabel();
259 256
260 /** 257 /**
261 Return translated label for homeAddressStreet field. 258 Return translated label for homeAddressStreet field.
262 */ 259 */
263 static QString homeAddressStreetLabel(); 260 static QString homeAddressStreetLabel();
264 261
265 /** 262 /**
266 Return translated label for homeAddressLocality field. 263 Return translated label for homeAddressLocality field.
267 */ 264 */
268 static QString homeAddressLocalityLabel(); 265 static QString homeAddressLocalityLabel();
269 266
270 /** 267 /**
271 Return translated label for homeAddressRegion field. 268 Return translated label for homeAddressRegion field.
272 */ 269 */
273 static QString homeAddressRegionLabel(); 270 static QString homeAddressRegionLabel();
274 271
275 /** 272 /**
276 Return translated label for homeAddressPostalCode field. 273 Return translated label for homeAddressPostalCode field.
277 */ 274 */
278 static QString homeAddressPostalCodeLabel(); 275 static QString homeAddressPostalCodeLabel();
279 276
280 /** 277 /**
281 Return translated label for homeAddressCountry field. 278 Return translated label for homeAddressCountry field.
282 */ 279 */
283 static QString homeAddressCountryLabel(); 280 static QString homeAddressCountryLabel();
284 281
285 /** 282 /**
286 Return translated label for homeAddressLabel field. 283 Return translated label for homeAddressLabel field.
287 */ 284 */
288 static QString homeAddressLabelLabel(); 285 static QString homeAddressLabelLabel();
289 286
290 /** 287 /**
291 Return translated label for businessAddressStreet field. 288 Return translated label for businessAddressStreet field.
292 */ 289 */
293 static QString businessAddressStreetLabel(); 290 static QString businessAddressStreetLabel();
294 291
295 /** 292 /**
296 Return translated label for businessAddressLocality field. 293 Return translated label for businessAddressLocality field.
297 */ 294 */
298 static QString businessAddressLocalityLabel(); 295 static QString businessAddressLocalityLabel();
299 296
300 /** 297 /**
301 Return translated label for businessAddressRegion field. 298 Return translated label for businessAddressRegion field.
302 */ 299 */
303 static QString businessAddressRegionLabel(); 300 static QString businessAddressRegionLabel();
304 301
305 /** 302 /**
306 Return translated label for businessAddressPostalCode field. 303 Return translated label for businessAddressPostalCode field.
307 */ 304 */
308 static QString businessAddressPostalCodeLabel(); 305 static QString businessAddressPostalCodeLabel();
309 306
310 /** 307 /**
311 Return translated label for businessAddressCountry field. 308 Return translated label for businessAddressCountry field.
312 */ 309 */
313 static QString businessAddressCountryLabel(); 310 static QString businessAddressCountryLabel();
314 311
315 /** 312 /**
316 Return translated label for businessAddressLabel field. 313 Return translated label for businessAddressLabel field.
317 */ 314 */
318 static QString businessAddressLabelLabel(); 315 static QString businessAddressLabelLabel();
319 316
320 /** 317 /**
321 Return translated label for homePhone field. 318 Return translated label for homePhone field.
322 */ 319 */
323 static QString homePhoneLabel(); 320 static QString homePhoneLabel();
324 321
325 /** 322 /**
326 Return translated label for businessPhone field. 323 Return translated label for businessPhone field.
327 */ 324 */
328 static QString businessPhoneLabel(); 325 static QString businessPhoneLabel();
329 326
330 /** 327 /**
331 Return translated label for mobilePhone field. 328 Return translated label for mobilePhone field.
332 */ 329 */
333 static QString mobilePhoneLabel(); 330 static QString mobilePhoneLabel();
334 static QString mobileWorkPhoneLabel(); 331 static QString mobileWorkPhoneLabel();
335 static QString mobileHomePhoneLabel(); 332 static QString mobileHomePhoneLabel();
336 333
337 /** 334 /**
338 Return translated label for homeFax field. 335 Return translated label for homeFax field.
339 */ 336 */
340 static QString homeFaxLabel(); 337 static QString homeFaxLabel();
341 338
342 /** 339 /**
343 Return translated label for businessFax field. 340 Return translated label for businessFax field.
344 */ 341 */
345 static QString businessFaxLabel(); 342 static QString businessFaxLabel();
346 343
347 /** 344 /**
348 Return translated label for carPhone field. 345 Return translated label for carPhone field.
349 */ 346 */
350 static QString carPhoneLabel(); 347 static QString carPhoneLabel();
351 348
352 /** 349 /**
353 Return translated label for isdn field. 350 Return translated label for isdn field.
354 */ 351 */
355 static QString isdnLabel(); 352 static QString isdnLabel();
356 353
357 /** 354 /**
358 Return translated label for pager field. 355 Return translated label for pager field.
359 */ 356 */
360 static QString pagerLabel(); 357 static QString pagerLabel();
361 358
362 /** 359 /**
363 Return translated label for sip field. 360 Return translated label for sip field.
364 */ 361 */
365 static QString sipLabel(); 362 static QString sipLabel();
366 363
367 /** 364 /**
368 Return translated label for email field. 365 Return translated label for email field.
369 */ 366 */
370 static QString emailLabel(); 367 static QString emailLabel();
371 368
372 /** 369 /**
373 Set mail client. 370 Set mail client.
374 */ 371 */
375 void setMailer( const QString &mailer ); 372 void setMailer( const QString &mailer );
376 /** 373 /**
377 Return mail client. 374 Return mail client.
378 */ 375 */
379 QString mailer() const; 376 QString mailer() const;
380 /** 377 /**
381 Return translated label for mailer field. 378 Return translated label for mailer field.
382 */ 379 */
383 static QString mailerLabel(); 380 static QString mailerLabel();
384 381
385 /** 382 /**
386 Set time zone. 383 Set time zone.
387 */ 384 */
388 void setTimeZone( const TimeZone &timeZone ); 385 void setTimeZone( const TimeZone &timeZone );
389 /** 386 /**
390 Return time zone. 387 Return time zone.
391 */ 388 */
392 TimeZone timeZone() const; 389 TimeZone timeZone() const;
393 /** 390 /**
394 Return translated label for timeZone field. 391 Return translated label for timeZone field.
395 */ 392 */
396 static QString timeZoneLabel(); 393 static QString timeZoneLabel();
397 394
398 /** 395 /**
399 Set geographic position. 396 Set geographic position.
400 */ 397 */
401 void setGeo( const Geo &geo ); 398 void setGeo( const Geo &geo );
402 /** 399 /**
403 Return geographic position. 400 Return geographic position.
404 */ 401 */
405 Geo geo() const; 402 Geo geo() const;
406 /** 403 /**
407 Return translated label for geo field. 404 Return translated label for geo field.
408 */ 405 */
409 static QString geoLabel(); 406 static QString geoLabel();
410 407
411 /** 408 /**
412 Set title. 409 Set title.
413 */ 410 */
414 void setTitle( const QString &title ); 411 void setTitle( const QString &title );
415 /** 412 /**
416 Return title. 413 Return title.
417 */ 414 */
418 QString title() const; 415 QString title() const;
419 /** 416 /**
420 Return translated label for title field. 417 Return translated label for title field.
421 */ 418 */
422 static QString titleLabel(); 419 static QString titleLabel();
423 420
424 /** 421 /**
425 Set role. 422 Set role.
426 */ 423 */
427 void setRole( const QString &role ); 424 void setRole( const QString &role );
428 /** 425 /**
429 Return role. 426 Return role.
430 */ 427 */
431 QString role() const; 428 QString role() const;
432 /** 429 /**
433 Return translated label for role field. 430 Return translated label for role field.
434 */ 431 */
435 static QString roleLabel(); 432 static QString roleLabel();
436 433
437 /** 434 /**
438 Set organization. 435 Set organization.
439 */ 436 */
440 void setOrganization( const QString &organization ); 437 void setOrganization( const QString &organization );
441 /** 438 /**
442 Return organization. 439 Return organization.
443 */ 440 */
444 QString organization() const; 441 QString organization() const;
445 /** 442 /**
446 Return translated label for organization field. 443 Return translated label for organization field.
447 */ 444 */
448 static QString organizationLabel(); 445 static QString organizationLabel();
449 446
450 /** 447 /**
451 Set note. 448 Set note.
452 */ 449 */
453 void setNote( const QString &note ); 450 void setNote( const QString &note );
454 /** 451 /**
455 Return note. 452 Return note.
456 */ 453 */
457 QString note() const; 454 QString note() const;
458 /** 455 /**
459 Return translated label for note field. 456 Return translated label for note field.
460 */ 457 */
461 static QString noteLabel(); 458 static QString noteLabel();
462 459
463 /** 460 /**
464 Set product identifier. 461 Set product identifier.
465 */ 462 */
466 void setProductId( const QString &productId ); 463 void setProductId( const QString &productId );
467 /** 464 /**
468 Return product identifier. 465 Return product identifier.
469 */ 466 */
470 QString productId() const; 467 QString productId() const;
471 /** 468 /**
472 Return translated label for productId field. 469 Return translated label for productId field.
473 */ 470 */
474 static QString productIdLabel(); 471 static QString productIdLabel();
475 472
476 /** 473 /**
477 Set revision date. 474 Set revision date.
478 */ 475 */
479 void setRevision( const QDateTime &revision ); 476 void setRevision( const QDateTime &revision );
480 /** 477 /**
481 Return revision date. 478 Return revision date.
482 */ 479 */
483 QDateTime revision() const; 480 QDateTime revision() const;
484 /** 481 /**
485 Return translated label for revision field. 482 Return translated label for revision field.
486 */ 483 */
487 static QString revisionLabel(); 484 static QString revisionLabel();
488 485
489 /** 486 /**
490 Set sort string. 487 Set sort string.
491 */ 488 */
492 void setSortString( const QString &sortString ); 489 void setSortString( const QString &sortString );
493 /** 490 /**
494 Return sort string. 491 Return sort string.
495 */ 492 */
496 QString sortString() const; 493 QString sortString() const;
497 /** 494 /**
498 Return translated label for sortString field. 495 Return translated label for sortString field.
499 */ 496 */
500 static QString sortStringLabel(); 497 static QString sortStringLabel();
501 498
502 /** 499 /**
503 Set URL. 500 Set URL.
504 */ 501 */
505 void setUrl( const KURL &url ); 502 void setUrl( const KURL &url );
506 /** 503 /**
507 Return URL. 504 Return URL.
508 */ 505 */
509 KURL url() const; 506 KURL url() const;
510 /** 507 /**
511 Return translated label for url field. 508 Return translated label for url field.
512 */ 509 */
513 static QString urlLabel(); 510 static QString urlLabel();
514 511
515 /** 512 /**
516 Set security class. 513 Set security class.
517 */ 514 */
518 void setSecrecy( const Secrecy &secrecy ); 515 void setSecrecy( const Secrecy &secrecy );
519 /** 516 /**
520 Return security class. 517 Return security class.
521 */ 518 */
522 Secrecy secrecy() const; 519 Secrecy secrecy() const;
523 /** 520 /**
524 Return translated label for secrecy field. 521 Return translated label for secrecy field.
525 */ 522 */
526 static QString secrecyLabel(); 523 static QString secrecyLabel();
527 524
528 /** 525 /**
529 Set logo. 526 Set logo.
530 */ 527 */
531 void setLogo( const Picture &logo ); 528 void setLogo( const Picture &logo );
532 /** 529 /**
533 Return logo. 530 Return logo.
534 */ 531 */
535 Picture logo() const; 532 Picture logo() const;
536 /** 533 /**
537 Return translated label for logo field. 534 Return translated label for logo field.
538 */ 535 */
539 static QString logoLabel(); 536 static QString logoLabel();
540 537
541 /** 538 /**
542 Set photo. 539 Set photo.
543 */ 540 */
544 void setPhoto( const Picture &photo ); 541 void setPhoto( const Picture &photo );
545 /** 542 /**
546 Return photo. 543 Return photo.
547 */ 544 */
548 Picture photo() const; 545 Picture photo() const;
549 /** 546 /**
550 Return translated label for photo field. 547 Return translated label for photo field.
551 */ 548 */
552 static QString photoLabel(); 549 static QString photoLabel();
553 550
554 /** 551 /**
555 Set sound. 552 Set sound.
556 */ 553 */
557 void setSound( const Sound &sound ); 554 void setSound( const Sound &sound );
558 /** 555 /**
559 Return sound. 556 Return sound.
560 */ 557 */
561 Sound sound() const; 558 Sound sound() const;
562 /** 559 /**
563 Return translated label for sound field. 560 Return translated label for sound field.
564 */ 561 */
565 static QString soundLabel(); 562 static QString soundLabel();
566 563
567 /** 564 /**
568 Set agent. 565 Set agent.
569 */ 566 */
570 void setAgent( const Agent &agent ); 567 void setAgent( const Agent &agent );
571 /** 568 /**
572 Return agent. 569 Return agent.
573 */ 570 */
574 Agent agent() const; 571 Agent agent() const;
575 /** 572 /**
576 Return translated label for agent field. 573 Return translated label for agent field.
577 */ 574 */
578 static QString agentLabel(); 575 static QString agentLabel();
579 576
580 /** 577 /**
581 Set name fields by parsing the given string and trying to associate the 578 Set name fields by parsing the given string and trying to associate the
582 parts of the string with according fields. This function should probably 579 parts of the string with according fields. This function should probably
583 be a bit more clever. 580 be a bit more clever.
584 */ 581 */
585 void setNameFromString( const QString & ); 582 void setNameFromString( const QString & );
586 583
587 /** 584 /**
588 Return the name of the addressee. This is calculated from all the name 585 Return the name of the addressee. This is calculated from all the name
589 fields. 586 fields.
590 */ 587 */
591 QString realName() const; 588 QString realName() const;
592 589
593 /** 590 /**
594 Return the name that consists of all name parts. 591 Return the name that consists of all name parts.
595 */ 592 */
596 QString assembledName() const; 593 QString assembledName() const;
597 594
598 /** 595 /**
599 Return email address including real name. 596 Return email address including real name.
600 597
601 @param email Email address to be used to construct the full email string. 598 @param email Email address to be used to construct the full email string.
602 If this is QString::null the preferred email address is used. 599 If this is QString::null the preferred email address is used.
603 */ 600 */
604 QString fullEmail( const QString &email=QString::null ) const; 601 QString fullEmail( const QString &email=QString::null ) const;
605 602
606 /** 603 /**
607 Insert an email address. If the email address already exists in this 604 Insert an email address. If the email address already exists in this
608 addressee it is not duplicated. 605 addressee it is not duplicated.
609 606
610 @param email Email address 607 @param email Email address
611 @param preferred Set to true, if this is the preferred email address of 608 @param preferred Set to true, if this is the preferred email address of
612 the addressee. 609 the addressee.
613 */ 610 */
614 void insertEmail( const QString &email, bool preferred=false ); 611 void insertEmail( const QString &email, bool preferred=false );
615 612
616 /** 613 /**
617 Remove email address. If the email address doesn't exist, nothing happens. 614 Remove email address. If the email address doesn't exist, nothing happens.
618 */ 615 */
619 void removeEmail( const QString &email ); 616 void removeEmail( const QString &email );
620 617
621 /** 618 /**
622 Return preferred email address. This is the first email address or the 619 Return preferred email address. This is the first email address or the
623 last one added with @ref insertEmail() with a set preferred parameter. 620 last one added with @ref insertEmail() with a set preferred parameter.
624 */ 621 */
625 QString preferredEmail() const; 622 QString preferredEmail() const;
626 623
627 /** 624 /**
628 Return list of all email addresses. 625 Return list of all email addresses.
629 */ 626 */
630 QStringList emails() const; 627 QStringList emails() const;
631 628
632 /** 629 /**
633 Set the emails to @param. 630 Set the emails to @param.
634 The first email address gets the preferred one! 631 The first email address gets the preferred one!
635 @param list The list of email addresses. 632 @param list The list of email addresses.
636 */ 633 */
637 void setEmails( const QStringList& list); 634 void setEmails( const QStringList& list);
638 635
639 /** 636 /**
640 Insert a phone number. If a phone number with the same id already exists 637 Insert a phone number. If a phone number with the same id already exists
641 in this addressee it is not duplicated. 638 in this addressee it is not duplicated.
642 */ 639 */
643 void insertPhoneNumber( const PhoneNumber &phoneNumber ); 640 void insertPhoneNumber( const PhoneNumber &phoneNumber );
644 641
645 /** 642 /**
646 Remove phone number. If no phone number with the given id exists for this 643 Remove phone number. If no phone number with the given id exists for this
647 addresse nothing happens. 644 addresse nothing happens.
648 */ 645 */
649 void removePhoneNumber( const PhoneNumber &phoneNumber ); 646 void removePhoneNumber( const PhoneNumber &phoneNumber );
650 647
651 /** 648 /**
652 Return phone number, which matches the given type. 649 Return phone number, which matches the given type.
653 */ 650 */
654 PhoneNumber phoneNumber( int type ) const; 651 PhoneNumber phoneNumber( int type ) const;
655 652
656 /** 653 /**
657 Return list of all phone numbers. 654 Return list of all phone numbers.
658 */ 655 */
659 PhoneNumber::List phoneNumbers() const; 656 PhoneNumber::List phoneNumbers() const;
660 657
661 /** 658 /**
662 Return list of phone numbers with a special type. 659 Return list of phone numbers with a special type.
663 */ 660 */
664 PhoneNumber::List phoneNumbers( int type ) const; 661 PhoneNumber::List phoneNumbers( int type ) const;
665 662
666 /** 663 /**
667 Return phone number with the given id. 664 Return phone number with the given id.
668 */ 665 */
669 PhoneNumber findPhoneNumber( const QString &id ) const; 666 PhoneNumber findPhoneNumber( const QString &id ) const;
670 667
671 /** 668 /**
672 Insert a key. If a key with the same id already exists 669 Insert a key. If a key with the same id already exists
673 in this addressee it is not duplicated. 670 in this addressee it is not duplicated.
674 */ 671 */
675 void insertKey( const Key &key ); 672 void insertKey( const Key &key );
676 673
677 /** 674 /**
678 Remove a key. If no key with the given id exists for this 675 Remove a key. If no key with the given id exists for this
679 addresse nothing happens. 676 addresse nothing happens.
680 */ 677 */
681 void removeKey( const Key &key ); 678 void removeKey( const Key &key );
682 679
683 /** 680 /**
684 Return key, which matches the given type. 681 Return key, which matches the given type.
685 If @p type == Key::Custom you can specify a string 682 If @p type == Key::Custom you can specify a string
686 that should match. If you leave the string empty, the first 683 that should match. If you leave the string empty, the first
687 key with a custom value is returned. 684 key with a custom value is returned.
688 */ 685 */
689 Key key( int type, QString customTypeString = QString::null ) const; 686 Key key( int type, QString customTypeString = QString::null ) const;
690 687
691 /** 688 /**
692 Return list of all keys. 689 Return list of all keys.
693 */ 690 */
694 Key::List keys() const; 691 Key::List keys() const;
695 692
696 /** 693 /**
697 Set the list of keys 694 Set the list of keys
698 @param keys The keys to be set. 695 @param keys The keys to be set.
699 */ 696 */
700 void setKeys( const Key::List& keys); 697 void setKeys( const Key::List& keys);
701 698
702 /** 699 /**
703 Return list of keys with a special type. 700 Return list of keys with a special type.
704 If @p type == Key::Custom you can specify a string 701 If @p type == Key::Custom you can specify a string
705 that should match. If you leave the string empty, all custom 702 that should match. If you leave the string empty, all custom
706 keys will be returned. 703 keys will be returned.
707 */ 704 */
708 Key::List keys( int type, QString customTypeString = QString::null ) const; 705 Key::List keys( int type, QString customTypeString = QString::null ) const;
709 706
710 /** 707 /**
711 Return key with the given id. 708 Return key with the given id.
712 */ 709 */
713 Key findKey( const QString &id ) const; 710 Key findKey( const QString &id ) const;
714 711
715 /** 712 /**
716 Insert an address. If an address with the same id already exists 713 Insert an address. If an address with the same id already exists
717 in this addressee it is not duplicated. 714 in this addressee it is not duplicated.
718 */ 715 */
719 void insertAddress( const Address &address ); 716 void insertAddress( const Address &address );
720 717
721 /** 718 /**
722 Remove address. If no address with the given id exists for this 719 Remove address. If no address with the given id exists for this
723 addresse nothing happens. 720 addresse nothing happens.
724 */ 721 */
725 void removeAddress( const Address &address ); 722 void removeAddress( const Address &address );
726 723
727 /** 724 /**
728 Return address, which matches the given type. 725 Return address, which matches the given type.
729 */ 726 */
730 Address address( int type ) const; 727 Address address( int type ) const;
731 728
732 /** 729 /**
733 Return list of all addresses. 730 Return list of all addresses.
734 */ 731 */
735 Address::List addresses() const; 732 Address::List addresses() const;
736 733
737 /** 734 /**
738 Return list of addresses with a special type. 735 Return list of addresses with a special type.
739 */ 736 */
740 Address::List addresses( int type ) const; 737 Address::List addresses( int type ) const;
741 738
742 /** 739 /**
743 Return address with the given id. 740 Return address with the given id.
744 */ 741 */
745 Address findAddress( const QString &id ) const; 742 Address findAddress( const QString &id ) const;
746 743
747 /** 744 /**
748 Insert category. If the category already exists it is not duplicated. 745 Insert category. If the category already exists it is not duplicated.
749 */ 746 */
750 void insertCategory( const QString & ); 747 void insertCategory( const QString & );
751 748
752 /** 749 /**
753 Remove category. 750 Remove category.
754 */ 751 */
755 void removeCategory( const QString & ); 752 void removeCategory( const QString & );
756 753
757 /** 754 /**
758 Return, if addressee has the given category. 755 Return, if addressee has the given category.
759 */ 756 */
760 bool hasCategory( const QString & ) const; 757 bool hasCategory( const QString & ) const;
761 758
762 /** 759 /**
763 Set categories to given value. 760 Set categories to given value.
764 */ 761 */
765 void setCategories( const QStringList & ); 762 void setCategories( const QStringList & );
766 763
767 /** 764 /**
768 Return list of all set categories. 765 Return list of all set categories.
769 */ 766 */
770 QStringList categories() const; 767 QStringList categories() const;
771 768
772 /** 769 /**
773 Insert custom entry. The entry is identified by the name of the inserting 770 Insert custom entry. The entry is identified by the name of the inserting
774 application and a unique name. If an entry with the given app and name 771 application and a unique name. If an entry with the given app and name
775 already exists its value is replaced with the new given value. 772 already exists its value is replaced with the new given value.
776 */ 773 */
777 void insertCustom( const QString &app, const QString &name, 774 void insertCustom( const QString &app, const QString &name,
778 const QString &value ); 775 const QString &value );
779 776
780 /** 777 /**
781 Remove custom entry. 778 Remove custom entry.
782 */ 779 */
783 void removeCustom( const QString &app, const QString &name ); 780 void removeCustom( const QString &app, const QString &name );
784 781
785 /** 782 /**
786 Return value of custom entry, identified by app and entry name. 783 Return value of custom entry, identified by app and entry name.
787 */ 784 */
788 QString custom( const QString &app, const QString &name ) const; 785 QString custom( const QString &app, const QString &name ) const;
789 786
790 /** 787 /**
791 Set all custom entries. 788 Set all custom entries.
792 */ 789 */
793 void setCustoms( const QStringList & ); 790 void setCustoms( const QStringList & );
794 791
795 /** 792 /**
796 Return list of all custom entries. 793 Return list of all custom entries.
797 */ 794 */
798 QStringList customs() const; 795 QStringList customs() const;
799 796
800 /** 797 /**
801 Parse full email address. The result is given back in fullName and email. 798 Parse full email address. The result is given back in fullName and email.
802 */ 799 */
803 static void parseEmailAddress( const QString &rawEmail, QString &fullName, 800 static void parseEmailAddress( const QString &rawEmail, QString &fullName,
804 QString &email ); 801 QString &email );
805 802
806 /** 803 /**
807 Debug output. 804 Debug output.
808 */ 805 */
809 void dump() const; 806 void dump() const;
810 807
811 /** 808 /**
812 Returns string representation of the addressee. 809 Returns string representation of the addressee.
813 */ 810 */
814 QString asString() const; 811 QString asString() const;
815 812
816 /** 813 /**
817 Set resource where the addressee is from. 814 Set resource where the addressee is from.
818 */ 815 */
819 void setResource( Resource *resource ); 816 void setResource( Resource *resource );
820 817
821 /** 818 /**
822 Return pointer to resource. 819 Return pointer to resource.
823 */ 820 */
824 Resource *resource() const; 821 Resource *resource() const;
825 822
826 /** 823 /**
827 Return resourcelabel. 824 Return resourcelabel.
828 */ 825 */
829 //US 826 //US
830 static QString resourceLabel(); 827 static QString resourceLabel();
831 static QString categoryLabel(); 828 static QString categoryLabel();
832 /** 829 /**
833 Mark addressee as changed. 830 Mark addressee as changed.
834 */ 831 */
835 void setChanged( bool value ); 832 void setChanged( bool value );
836 833
837 /** 834 /**
838 Return whether the addressee is changed. 835 Return whether the addressee is changed.
839 */ 836 */
840 bool changed() const; 837 bool changed() const;
841 838
842 void setTagged( bool value ); 839 void setTagged( bool value );
843 bool tagged() const; 840 bool tagged() const;
844 841
845 private: 842 private:
846 Addressee copy(); 843 Addressee copy();
847 void detach(); 844 void detach();
848 845
849 struct AddresseeData; 846 struct AddresseeData;
850 mutable KSharedPtr<AddresseeData> mData; 847 mutable KSharedPtr<AddresseeData> mData;
851}; 848};
852 849
853QDataStream &operator<<( QDataStream &, const Addressee & ); 850QDataStream &operator<<( QDataStream &, const Addressee & );
854QDataStream &operator>>( QDataStream &, Addressee & ); 851QDataStream &operator>>( QDataStream &, Addressee & );
855 852
856} 853}
857 854
858#endif 855#endif
diff --git a/kabc/field.cpp b/kabc/field.cpp
index 5c561c3..fd51026 100644
--- a/kabc/field.cpp
+++ b/kabc/field.cpp
@@ -1,596 +1,590 @@
1/*** Warning! This file has been generated by the script makeaddressee ***/ 1/*** Warning! This file has been generated by the script makeaddressee ***/
2/* 2/*
3 This file is part of libkabc. 3 This file is part of libkabc.
4 Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org> 4 Copyright (c) 2002 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/* 22/*
23Enhanced Version of the file for platform independent KDE tools. 23Enhanced Version of the file for platform independent KDE tools.
24Copyright (c) 2004 Ulf Schenk 24Copyright (c) 2004 Ulf Schenk
25 25
26$Id$ 26$Id$
27*/ 27*/
28 28
29#include <klocale.h> 29#include <klocale.h>
30#include <kconfig.h> 30#include <kconfig.h>
31#include <kconfigbase.h> 31#include <kconfigbase.h>
32#include <kglobal.h> 32#include <kglobal.h>
33 33
34#include "field.h" 34#include "field.h"
35#include "resource.h" 35#include "resource.h"
36 36
37using namespace KABC; 37using namespace KABC;
38 38
39class Field::FieldImpl 39class Field::FieldImpl
40{ 40{
41 public: 41 public:
42 FieldImpl( int fieldId, int category = 0, 42 FieldImpl( int fieldId, int category = 0,
43 const QString &label = QString::null, 43 const QString &label = QString::null,
44 const QString &key = QString::null, 44 const QString &key = QString::null,
45 const QString &app = QString::null ) 45 const QString &app = QString::null )
46 : mFieldId( fieldId ), mCategory( category ), mLabel( label ), 46 : mFieldId( fieldId ), mCategory( category ), mLabel( label ),
47 mKey( key ), mApp( app ) {} 47 mKey( key ), mApp( app ) {}
48 48
49 enum FieldId 49 enum FieldId
50 { 50 {
51 CustomField, 51 CustomField,
52 FormattedName, 52 FormattedName,
53 FamilyName, 53 FamilyName,
54 GivenName, 54 GivenName,
55 AdditionalName, 55 AdditionalName,
56 Prefix, 56 Prefix,
57 Suffix, 57 Suffix,
58 NickName, 58 NickName,
59 Birthday, 59 Birthday,
60 Category, 60 Category,
61 HomeAddressStreet, 61 HomeAddressStreet,
62 HomeAddressLocality, 62 HomeAddressLocality,
63 HomeAddressRegion, 63 HomeAddressRegion,
64 HomeAddressPostalCode, 64 HomeAddressPostalCode,
65 HomeAddressCountry, 65 HomeAddressCountry,
66 HomeAddressLabel, 66 HomeAddressLabel,
67 BusinessAddressStreet, 67 BusinessAddressStreet,
68 BusinessAddressLocality, 68 BusinessAddressLocality,
69 BusinessAddressRegion, 69 BusinessAddressRegion,
70 BusinessAddressPostalCode, 70 BusinessAddressPostalCode,
71 BusinessAddressCountry, 71 BusinessAddressCountry,
72 BusinessAddressLabel, 72 BusinessAddressLabel,
73 HomePhone, 73 HomePhone,
74 BusinessPhone, 74 BusinessPhone,
75 MobilePhone, 75 MobilePhone,
76 HomeFax, 76 HomeFax,
77 BusinessFax, 77 BusinessFax,
78 CarPhone, 78 CarPhone,
79 Isdn, 79 Isdn,
80 Pager, 80 Pager,
81 Email, 81 Email,
82 Mailer, 82 Mailer,
83 Title, 83 Title,
84 Role, 84 Role,
85 Organization, 85 Organization,
86 Note, 86 Note,
87 Url, 87 Url,
88 Resource, 88 Resource,
89 Sip, 89 Sip,
90 DefaultFormattedName,
91 MobileWorkPhone, 90 MobileWorkPhone,
92 MobileHomePhone 91 MobileHomePhone
93 }; 92 };
94 93
95 int fieldId() { return mFieldId; } 94 int fieldId() { return mFieldId; }
96 int category() { return mCategory; } 95 int category() { return mCategory; }
97 96
98 QString label() { return mLabel; } 97 QString label() { return mLabel; }
99 QString key() { return mKey; } 98 QString key() { return mKey; }
100 QString app() { return mApp; } 99 QString app() { return mApp; }
101 100
102 private: 101 private:
103 int mFieldId; 102 int mFieldId;
104 int mCategory; 103 int mCategory;
105 104
106 QString mLabel; 105 QString mLabel;
107 QString mKey; 106 QString mKey;
108 QString mApp; 107 QString mApp;
109}; 108};
110 109
111 110
112Field::List Field::mAllFields; 111Field::List Field::mAllFields;
113Field::List Field::mDefaultFields; 112Field::List Field::mDefaultFields;
114Field::List Field::mCustomFields; 113Field::List Field::mCustomFields;
115 114
116 115
117Field::Field( FieldImpl *impl ) 116Field::Field( FieldImpl *impl )
118{ 117{
119 mImpl = impl; 118 mImpl = impl;
120} 119}
121 120
122Field::~Field() 121Field::~Field()
123{ 122{
124 delete mImpl; 123 delete mImpl;
125} 124}
126 125
127QString Field::label() 126QString Field::label()
128{ 127{
129 switch ( mImpl->fieldId() ) { 128 switch ( mImpl->fieldId() ) {
130 case FieldImpl::FormattedName: 129 case FieldImpl::FormattedName:
131 return Addressee::formattedNameLabel(); 130 return Addressee::formattedNameLabel();
132 case FieldImpl::DefaultFormattedName:
133 return Addressee::defaultFormattedNameLabel();
134 case FieldImpl::FamilyName: 131 case FieldImpl::FamilyName:
135 return Addressee::familyNameLabel(); 132 return Addressee::familyNameLabel();
136 case FieldImpl::GivenName: 133 case FieldImpl::GivenName:
137 return Addressee::givenNameLabel(); 134 return Addressee::givenNameLabel();
138 case FieldImpl::AdditionalName: 135 case FieldImpl::AdditionalName:
139 return Addressee::additionalNameLabel(); 136 return Addressee::additionalNameLabel();
140 case FieldImpl::Prefix: 137 case FieldImpl::Prefix:
141 return Addressee::prefixLabel(); 138 return Addressee::prefixLabel();
142 case FieldImpl::Suffix: 139 case FieldImpl::Suffix:
143 return Addressee::suffixLabel(); 140 return Addressee::suffixLabel();
144 case FieldImpl::NickName: 141 case FieldImpl::NickName:
145 return Addressee::nickNameLabel(); 142 return Addressee::nickNameLabel();
146 case FieldImpl::Birthday: 143 case FieldImpl::Birthday:
147 return Addressee::birthdayLabel(); 144 return Addressee::birthdayLabel();
148 case FieldImpl::HomeAddressStreet: 145 case FieldImpl::HomeAddressStreet:
149 return Addressee::homeAddressStreetLabel(); 146 return Addressee::homeAddressStreetLabel();
150 case FieldImpl::HomeAddressLocality: 147 case FieldImpl::HomeAddressLocality:
151 return Addressee::homeAddressLocalityLabel(); 148 return Addressee::homeAddressLocalityLabel();
152 case FieldImpl::HomeAddressRegion: 149 case FieldImpl::HomeAddressRegion:
153 return Addressee::homeAddressRegionLabel(); 150 return Addressee::homeAddressRegionLabel();
154 case FieldImpl::HomeAddressPostalCode: 151 case FieldImpl::HomeAddressPostalCode:
155 return Addressee::homeAddressPostalCodeLabel(); 152 return Addressee::homeAddressPostalCodeLabel();
156 case FieldImpl::HomeAddressCountry: 153 case FieldImpl::HomeAddressCountry:
157 return Addressee::homeAddressCountryLabel(); 154 return Addressee::homeAddressCountryLabel();
158 case FieldImpl::HomeAddressLabel: 155 case FieldImpl::HomeAddressLabel:
159 return Addressee::homeAddressLabelLabel(); 156 return Addressee::homeAddressLabelLabel();
160 case FieldImpl::BusinessAddressStreet: 157 case FieldImpl::BusinessAddressStreet:
161 return Addressee::businessAddressStreetLabel(); 158 return Addressee::businessAddressStreetLabel();
162 case FieldImpl::BusinessAddressLocality: 159 case FieldImpl::BusinessAddressLocality:
163 return Addressee::businessAddressLocalityLabel(); 160 return Addressee::businessAddressLocalityLabel();
164 case FieldImpl::BusinessAddressRegion: 161 case FieldImpl::BusinessAddressRegion:
165 return Addressee::businessAddressRegionLabel(); 162 return Addressee::businessAddressRegionLabel();
166 case FieldImpl::BusinessAddressPostalCode: 163 case FieldImpl::BusinessAddressPostalCode:
167 return Addressee::businessAddressPostalCodeLabel(); 164 return Addressee::businessAddressPostalCodeLabel();
168 case FieldImpl::BusinessAddressCountry: 165 case FieldImpl::BusinessAddressCountry:
169 return Addressee::businessAddressCountryLabel(); 166 return Addressee::businessAddressCountryLabel();
170 case FieldImpl::BusinessAddressLabel: 167 case FieldImpl::BusinessAddressLabel:
171 return Addressee::businessAddressLabelLabel(); 168 return Addressee::businessAddressLabelLabel();
172 case FieldImpl::HomePhone: 169 case FieldImpl::HomePhone:
173 return Addressee::homePhoneLabel(); 170 return Addressee::homePhoneLabel();
174 case FieldImpl::BusinessPhone: 171 case FieldImpl::BusinessPhone:
175 return Addressee::businessPhoneLabel(); 172 return Addressee::businessPhoneLabel();
176 case FieldImpl::MobilePhone: 173 case FieldImpl::MobilePhone:
177 return Addressee::mobilePhoneLabel(); 174 return Addressee::mobilePhoneLabel();
178 case FieldImpl::MobileHomePhone: 175 case FieldImpl::MobileHomePhone:
179 return Addressee::mobileHomePhoneLabel(); 176 return Addressee::mobileHomePhoneLabel();
180 case FieldImpl::MobileWorkPhone: 177 case FieldImpl::MobileWorkPhone:
181 return Addressee::mobileWorkPhoneLabel(); 178 return Addressee::mobileWorkPhoneLabel();
182 case FieldImpl::HomeFax: 179 case FieldImpl::HomeFax:
183 return Addressee::homeFaxLabel(); 180 return Addressee::homeFaxLabel();
184 case FieldImpl::BusinessFax: 181 case FieldImpl::BusinessFax:
185 return Addressee::businessFaxLabel(); 182 return Addressee::businessFaxLabel();
186 case FieldImpl::CarPhone: 183 case FieldImpl::CarPhone:
187 return Addressee::carPhoneLabel(); 184 return Addressee::carPhoneLabel();
188 case FieldImpl::Isdn: 185 case FieldImpl::Isdn:
189 return Addressee::isdnLabel(); 186 return Addressee::isdnLabel();
190 case FieldImpl::Pager: 187 case FieldImpl::Pager:
191 return Addressee::pagerLabel(); 188 return Addressee::pagerLabel();
192 case FieldImpl::Email: 189 case FieldImpl::Email:
193 return Addressee::emailLabel(); 190 return Addressee::emailLabel();
194 case FieldImpl::Mailer: 191 case FieldImpl::Mailer:
195 return Addressee::mailerLabel(); 192 return Addressee::mailerLabel();
196 case FieldImpl::Title: 193 case FieldImpl::Title:
197 return Addressee::titleLabel(); 194 return Addressee::titleLabel();
198 case FieldImpl::Role: 195 case FieldImpl::Role:
199 return Addressee::roleLabel(); 196 return Addressee::roleLabel();
200 case FieldImpl::Organization: 197 case FieldImpl::Organization:
201 return Addressee::organizationLabel(); 198 return Addressee::organizationLabel();
202 case FieldImpl::Note: 199 case FieldImpl::Note:
203 return Addressee::noteLabel(); 200 return Addressee::noteLabel();
204 case FieldImpl::Url: 201 case FieldImpl::Url:
205 return Addressee::urlLabel(); 202 return Addressee::urlLabel();
206 case FieldImpl::Resource: 203 case FieldImpl::Resource:
207 return Addressee::resourceLabel(); 204 return Addressee::resourceLabel();
208 case FieldImpl::Category: 205 case FieldImpl::Category:
209 return Addressee::categoryLabel(); 206 return Addressee::categoryLabel();
210 case FieldImpl::Sip: 207 case FieldImpl::Sip:
211 return Addressee::sipLabel(); 208 return Addressee::sipLabel();
212 case FieldImpl::CustomField: 209 case FieldImpl::CustomField:
213 return mImpl->label(); 210 return mImpl->label();
214 default: 211 default:
215 return i18n("Unknown Field"); 212 return i18n("Unknown Field");
216 } 213 }
217} 214}
218 215
219int Field::category() 216int Field::category()
220{ 217{
221 return mImpl->category(); 218 return mImpl->category();
222} 219}
223 220
224QString Field::categoryLabel( int category ) 221QString Field::categoryLabel( int category )
225{ 222{
226 switch ( category ) { 223 switch ( category ) {
227 case All: 224 case All:
228 return i18n("All"); 225 return i18n("All");
229 case Frequent: 226 case Frequent:
230 return i18n("Frequent"); 227 return i18n("Frequent");
231 case Address: 228 case Address:
232 return i18n("Address"); 229 return i18n("Address");
233 case Email: 230 case Email:
234 return i18n("Email"); 231 return i18n("Email");
235 case Personal: 232 case Personal:
236 return i18n("Personal"); 233 return i18n("Personal");
237 case Organization: 234 case Organization:
238 return i18n("Organization"); 235 return i18n("Organization");
239 case CustomCategory: 236 case CustomCategory:
240 return i18n("Custom"); 237 return i18n("Custom");
241 default: 238 default:
242 return i18n("Undefined"); 239 return i18n("Undefined");
243 } 240 }
244} 241}
245 242
246QString Field::value( const KABC::Addressee &a ) 243QString Field::value( const KABC::Addressee &a )
247{ 244{
248 switch ( mImpl->fieldId() ) { 245 switch ( mImpl->fieldId() ) {
249 case FieldImpl::FormattedName: 246 case FieldImpl::FormattedName:
250 return a.formattedName(); 247 return a.formattedName();
251 case FieldImpl::DefaultFormattedName:
252 return a.defaultFormattedName();
253 case FieldImpl::FamilyName: 248 case FieldImpl::FamilyName:
254 return a.familyName(); 249 return a.familyName();
255 case FieldImpl::GivenName: 250 case FieldImpl::GivenName:
256 return a.givenName(); 251 return a.givenName();
257 case FieldImpl::AdditionalName: 252 case FieldImpl::AdditionalName:
258 return a.additionalName(); 253 return a.additionalName();
259 case FieldImpl::Prefix: 254 case FieldImpl::Prefix:
260 return a.prefix(); 255 return a.prefix();
261 case FieldImpl::Suffix: 256 case FieldImpl::Suffix:
262 return a.suffix(); 257 return a.suffix();
263 case FieldImpl::NickName: 258 case FieldImpl::NickName:
264 return a.nickName(); 259 return a.nickName();
265 case FieldImpl::Mailer: 260 case FieldImpl::Mailer:
266 return a.mailer(); 261 return a.mailer();
267 case FieldImpl::Title: 262 case FieldImpl::Title:
268 return a.title(); 263 return a.title();
269 case FieldImpl::Role: 264 case FieldImpl::Role:
270 return a.role(); 265 return a.role();
271 case FieldImpl::Organization: 266 case FieldImpl::Organization:
272 return a.organization(); 267 return a.organization();
273 case FieldImpl::Note: 268 case FieldImpl::Note:
274 return a.note(); 269 return a.note();
275 case FieldImpl::Email: 270 case FieldImpl::Email:
276 return a.preferredEmail(); 271 return a.preferredEmail();
277 case FieldImpl::Birthday: 272 case FieldImpl::Birthday:
278 if ( a.birthday().isValid() ) { 273 if ( a.birthday().isValid() ) {
279//the generated code had the following format: return a.birthday().date().toString( Qt::ISODate ); 274//the generated code had the following format: return a.birthday().date().toString( Qt::ISODate );
280// But Qt::IsoDate was not specified. 275// But Qt::IsoDate was not specified.
281// QString _oldFormat = KGlobal::locale()->dateFormat(); 276// QString _oldFormat = KGlobal::locale()->dateFormat();
282// KGlobal::locale()->setDateFormat("%Y-%m-%d"); // = Qt::ISODate 277// KGlobal::locale()->setDateFormat("%Y-%m-%d"); // = Qt::ISODate
283 QString dt = KGlobal::locale()->formatDate(a.birthday().date(), false, KLocale::ISODate); 278 QString dt = KGlobal::locale()->formatDate(a.birthday().date(), false, KLocale::ISODate);
284// KGlobal::locale()->setDateFormat(_oldFormat); 279// KGlobal::locale()->setDateFormat(_oldFormat);
285 return dt; 280 return dt;
286 } 281 }
287 else 282 else
288 return QString::null; 283 return QString::null;
289 case FieldImpl::Url: 284 case FieldImpl::Url:
290 return a.url().prettyURL(); 285 return a.url().prettyURL();
291//US 286//US
292 case FieldImpl::Resource: 287 case FieldImpl::Resource:
293 return a.resource()->resourceName(); 288 return a.resource()->resourceName();
294 case FieldImpl::Category: 289 case FieldImpl::Category:
295 return a.categories().join(","); 290 return a.categories().join(",");
296 case FieldImpl::HomePhone: 291 case FieldImpl::HomePhone:
297 return a.phoneNumber( PhoneNumber::Home ).number(); 292 return a.phoneNumber( PhoneNumber::Home ).number();
298 case FieldImpl::BusinessPhone: 293 case FieldImpl::BusinessPhone:
299 return a.phoneNumber( PhoneNumber::Work ).number(); 294 return a.phoneNumber( PhoneNumber::Work ).number();
300 case FieldImpl::MobilePhone: 295 case FieldImpl::MobilePhone:
301 return a.phoneNumber( PhoneNumber::Cell ).number(); 296 return a.phoneNumber( PhoneNumber::Cell ).number();
302 case FieldImpl::MobileWorkPhone: 297 case FieldImpl::MobileWorkPhone:
303 return a.phoneNumber( PhoneNumber::Cell | PhoneNumber::Work ).number(); 298 return a.phoneNumber( PhoneNumber::Cell | PhoneNumber::Work ).number();
304 case FieldImpl::MobileHomePhone: 299 case FieldImpl::MobileHomePhone:
305 return a.phoneNumber( PhoneNumber::Cell | PhoneNumber::Home ).number(); 300 return a.phoneNumber( PhoneNumber::Cell | PhoneNumber::Home ).number();
306 case FieldImpl::HomeFax: 301 case FieldImpl::HomeFax:
307 return a.phoneNumber( PhoneNumber::Home | PhoneNumber::Fax ).number(); 302 return a.phoneNumber( PhoneNumber::Home | PhoneNumber::Fax ).number();
308 case FieldImpl::BusinessFax: 303 case FieldImpl::BusinessFax:
309 return a.phoneNumber( PhoneNumber::Work | PhoneNumber::Fax ).number(); 304 return a.phoneNumber( PhoneNumber::Work | PhoneNumber::Fax ).number();
310 case FieldImpl::CarPhone: 305 case FieldImpl::CarPhone:
311 return a.phoneNumber( PhoneNumber::Car ).number(); 306 return a.phoneNumber( PhoneNumber::Car ).number();
312 case FieldImpl::Isdn: 307 case FieldImpl::Isdn:
313 return a.phoneNumber( PhoneNumber::Isdn ).number(); 308 return a.phoneNumber( PhoneNumber::Isdn ).number();
314 case FieldImpl::Pager: 309 case FieldImpl::Pager:
315 return a.phoneNumber( PhoneNumber::Pager ).number(); 310 return a.phoneNumber( PhoneNumber::Pager ).number();
316 case FieldImpl::Sip: 311 case FieldImpl::Sip:
317 return a.phoneNumber( PhoneNumber::Sip ).number(); 312 return a.phoneNumber( PhoneNumber::Sip ).number();
318 case FieldImpl::HomeAddressStreet: 313 case FieldImpl::HomeAddressStreet:
319 return a.address( Address::Home ).street(); 314 return a.address( Address::Home ).street();
320 case FieldImpl::HomeAddressLocality: 315 case FieldImpl::HomeAddressLocality:
321 return a.address( Address::Home ).locality(); 316 return a.address( Address::Home ).locality();
322 case FieldImpl::HomeAddressRegion: 317 case FieldImpl::HomeAddressRegion:
323 return a.address( Address::Home ).region(); 318 return a.address( Address::Home ).region();
324 case FieldImpl::HomeAddressPostalCode: 319 case FieldImpl::HomeAddressPostalCode:
325 return a.address( Address::Home ).postalCode(); 320 return a.address( Address::Home ).postalCode();
326 case FieldImpl::HomeAddressCountry: 321 case FieldImpl::HomeAddressCountry:
327 return a.address( Address::Home ).country(); 322 return a.address( Address::Home ).country();
328 case FieldImpl::BusinessAddressStreet: 323 case FieldImpl::BusinessAddressStreet:
329 return a.address( Address::Work ).street(); 324 return a.address( Address::Work ).street();
330 case FieldImpl::BusinessAddressLocality: 325 case FieldImpl::BusinessAddressLocality:
331 return a.address( Address::Work ).locality(); 326 return a.address( Address::Work ).locality();
332 case FieldImpl::BusinessAddressRegion: 327 case FieldImpl::BusinessAddressRegion:
333 return a.address( Address::Work ).region(); 328 return a.address( Address::Work ).region();
334 case FieldImpl::BusinessAddressPostalCode: 329 case FieldImpl::BusinessAddressPostalCode:
335 return a.address( Address::Work ).postalCode(); 330 return a.address( Address::Work ).postalCode();
336 case FieldImpl::BusinessAddressCountry: 331 case FieldImpl::BusinessAddressCountry:
337 return a.address( Address::Work ).country(); 332 return a.address( Address::Work ).country();
338 case FieldImpl::CustomField: 333 case FieldImpl::CustomField:
339 return a.custom( mImpl->app(), mImpl->key() ); 334 return a.custom( mImpl->app(), mImpl->key() );
340 default: 335 default:
341 return QString::null; 336 return QString::null;
342 } 337 }
343} 338}
344 339
345bool Field::setValue( KABC::Addressee &a, const QString &value ) 340bool Field::setValue( KABC::Addressee &a, const QString &value )
346{ 341{
347 switch ( mImpl->fieldId() ) { 342 switch ( mImpl->fieldId() ) {
348 case FieldImpl::FormattedName: 343 case FieldImpl::FormattedName:
349 a.setFormattedName( value ); 344 a.setFormattedName( value );
350 return true; 345 return true;
351 case FieldImpl::FamilyName: 346 case FieldImpl::FamilyName:
352 a.setFamilyName( value ); 347 a.setFamilyName( value );
353 return true; 348 return true;
354 case FieldImpl::GivenName: 349 case FieldImpl::GivenName:
355 a.setGivenName( value ); 350 a.setGivenName( value );
356 return true; 351 return true;
357 case FieldImpl::AdditionalName: 352 case FieldImpl::AdditionalName:
358 a.setAdditionalName( value ); 353 a.setAdditionalName( value );
359 return true; 354 return true;
360 case FieldImpl::Prefix: 355 case FieldImpl::Prefix:
361 a.setPrefix( value ); 356 a.setPrefix( value );
362 return true; 357 return true;
363 case FieldImpl::Suffix: 358 case FieldImpl::Suffix:
364 a.setSuffix( value ); 359 a.setSuffix( value );
365 return true; 360 return true;
366 case FieldImpl::NickName: 361 case FieldImpl::NickName:
367 a.setNickName( value ); 362 a.setNickName( value );
368 return true; 363 return true;
369 case FieldImpl::Mailer: 364 case FieldImpl::Mailer:
370 a.setMailer( value ); 365 a.setMailer( value );
371 return true; 366 return true;
372 case FieldImpl::Title: 367 case FieldImpl::Title:
373 a.setTitle( value ); 368 a.setTitle( value );
374 return true; 369 return true;
375 case FieldImpl::Role: 370 case FieldImpl::Role:
376 a.setRole( value ); 371 a.setRole( value );
377 return true; 372 return true;
378 case FieldImpl::Organization: 373 case FieldImpl::Organization:
379 a.setOrganization( value ); 374 a.setOrganization( value );
380 return true; 375 return true;
381 case FieldImpl::Note: 376 case FieldImpl::Note:
382 a.setNote( value ); 377 a.setNote( value );
383 return true; 378 return true;
384 case FieldImpl::Birthday: 379 case FieldImpl::Birthday:
385//US 380//US
386//the generated code had the following format: return a.setBirthday( QDate::fromString( value, Qt::ISODate ) ); 381//the generated code had the following format: return a.setBirthday( QDate::fromString( value, Qt::ISODate ) );
387// But Qt::IsoDate and QDate::fromString was not specified. Do I have the wrong QT version ? 382// But Qt::IsoDate and QDate::fromString was not specified. Do I have the wrong QT version ?
388 { 383 {
389 QDate dt = KGlobal::locale()->readDate( value, "%Y-%m-%d"); // = Qt::ISODate 384 QDate dt = KGlobal::locale()->readDate( value, "%Y-%m-%d"); // = Qt::ISODate
390 a.setBirthday(dt); 385 a.setBirthday(dt);
391 } 386 }
392 return true; 387 return true;
393 case FieldImpl::CustomField: 388 case FieldImpl::CustomField:
394 a.insertCustom( mImpl->app(), mImpl->key(), value ); 389 a.insertCustom( mImpl->app(), mImpl->key(), value );
395//US never copy the resourcename back to the adressee. 390//US never copy the resourcename back to the adressee.
396 case FieldImpl::Resource: 391 case FieldImpl::Resource:
397 default: 392 default:
398 return false; 393 return false;
399 } 394 }
400} 395}
401 396
402bool Field::isCustom() 397bool Field::isCustom()
403{ 398{
404 return mImpl->fieldId() == FieldImpl::CustomField; 399 return mImpl->fieldId() == FieldImpl::CustomField;
405} 400}
406 401
407Field::List Field::allFields() 402Field::List Field::allFields()
408{ 403{
409 if ( mAllFields.isEmpty() ) { 404 if ( mAllFields.isEmpty() ) {
410 createField( FieldImpl::FormattedName, Frequent ); 405 createField( FieldImpl::FormattedName, Frequent );
411 createField( FieldImpl::DefaultFormattedName, Frequent );
412 createField( FieldImpl::FamilyName, Frequent ); 406 createField( FieldImpl::FamilyName, Frequent );
413 createField( FieldImpl::GivenName, Frequent ); 407 createField( FieldImpl::GivenName, Frequent );
414 createField( FieldImpl::AdditionalName ); 408 createField( FieldImpl::AdditionalName );
415 createField( FieldImpl::Prefix ); 409 createField( FieldImpl::Prefix );
416 createField( FieldImpl::Suffix ); 410 createField( FieldImpl::Suffix );
417 createField( FieldImpl::NickName, Personal ); 411 createField( FieldImpl::NickName, Personal );
418 createField( FieldImpl::Birthday, Personal ); 412 createField( FieldImpl::Birthday, Personal );
419 createField( FieldImpl::Category ); 413 createField( FieldImpl::Category );
420 createField( FieldImpl::HomeAddressStreet, Address|Personal ); 414 createField( FieldImpl::HomeAddressStreet, Address|Personal );
421 createField( FieldImpl::HomeAddressLocality, Address|Personal ); 415 createField( FieldImpl::HomeAddressLocality, Address|Personal );
422 createField( FieldImpl::HomeAddressRegion, Address|Personal ); 416 createField( FieldImpl::HomeAddressRegion, Address|Personal );
423 createField( FieldImpl::HomeAddressPostalCode, Address|Personal ); 417 createField( FieldImpl::HomeAddressPostalCode, Address|Personal );
424 createField( FieldImpl::HomeAddressCountry, Address|Personal ); 418 createField( FieldImpl::HomeAddressCountry, Address|Personal );
425 createField( FieldImpl::HomeAddressLabel, Address|Personal ); 419 createField( FieldImpl::HomeAddressLabel, Address|Personal );
426 createField( FieldImpl::BusinessAddressStreet, Address|Organization ); 420 createField( FieldImpl::BusinessAddressStreet, Address|Organization );
427 createField( FieldImpl::BusinessAddressLocality, Address|Organization ); 421 createField( FieldImpl::BusinessAddressLocality, Address|Organization );
428 createField( FieldImpl::BusinessAddressRegion, Address|Organization ); 422 createField( FieldImpl::BusinessAddressRegion, Address|Organization );
429 createField( FieldImpl::BusinessAddressPostalCode, Address|Organization ); 423 createField( FieldImpl::BusinessAddressPostalCode, Address|Organization );
430 createField( FieldImpl::BusinessAddressCountry, Address|Organization ); 424 createField( FieldImpl::BusinessAddressCountry, Address|Organization );
431 createField( FieldImpl::BusinessAddressLabel, Address|Organization ); 425 createField( FieldImpl::BusinessAddressLabel, Address|Organization );
432 createField( FieldImpl::HomePhone, Personal|Frequent ); 426 createField( FieldImpl::HomePhone, Personal|Frequent );
433 createField( FieldImpl::BusinessPhone, Organization|Frequent ); 427 createField( FieldImpl::BusinessPhone, Organization|Frequent );
434 createField( FieldImpl::MobilePhone, Frequent ); 428 createField( FieldImpl::MobilePhone, Frequent );
435 createField( FieldImpl::MobileHomePhone, Frequent ); 429 createField( FieldImpl::MobileHomePhone, Frequent );
436 createField( FieldImpl::MobileWorkPhone, Frequent ); 430 createField( FieldImpl::MobileWorkPhone, Frequent );
437 createField( FieldImpl::HomeFax ); 431 createField( FieldImpl::HomeFax );
438 createField( FieldImpl::BusinessFax ); 432 createField( FieldImpl::BusinessFax );
439 createField( FieldImpl::CarPhone ); 433 createField( FieldImpl::CarPhone );
440 createField( FieldImpl::Isdn ); 434 createField( FieldImpl::Isdn );
441 createField( FieldImpl::Pager ); 435 createField( FieldImpl::Pager );
442 createField( FieldImpl::Email, Email|Frequent ); 436 createField( FieldImpl::Email, Email|Frequent );
443 createField( FieldImpl::Mailer, Email ); 437 createField( FieldImpl::Mailer, Email );
444 createField( FieldImpl::Title, Organization ); 438 createField( FieldImpl::Title, Organization );
445 createField( FieldImpl::Role, Organization ); 439 createField( FieldImpl::Role, Organization );
446 createField( FieldImpl::Organization, Organization ); 440 createField( FieldImpl::Organization, Organization );
447 createField( FieldImpl::Note ); 441 createField( FieldImpl::Note );
448 createField( FieldImpl::Url ); 442 createField( FieldImpl::Url );
449 createField( FieldImpl::Resource ); 443 createField( FieldImpl::Resource );
450 createField( FieldImpl::Sip ); 444 createField( FieldImpl::Sip );
451 } 445 }
452 446
453 return mAllFields; 447 return mAllFields;
454} 448}
455 449
456Field::List Field::defaultFields() 450Field::List Field::defaultFields()
457{ 451{
458 if ( mDefaultFields.isEmpty() ) { 452 if ( mDefaultFields.isEmpty() ) {
459 createDefaultField( FieldImpl::GivenName ); 453 createDefaultField( FieldImpl::GivenName );
460 createDefaultField( FieldImpl::FamilyName ); 454 createDefaultField( FieldImpl::FamilyName );
461 createDefaultField( FieldImpl::Email ); 455 createDefaultField( FieldImpl::Email );
462 } 456 }
463 457
464 return mDefaultFields; 458 return mDefaultFields;
465} 459}
466 460
467void Field::createField( int id, int category ) 461void Field::createField( int id, int category )
468{ 462{
469 mAllFields.append( new Field( new FieldImpl( id, category ) ) ); 463 mAllFields.append( new Field( new FieldImpl( id, category ) ) );
470} 464}
471 465
472void Field::createDefaultField( int id, int category ) 466void Field::createDefaultField( int id, int category )
473{ 467{
474 mDefaultFields.append( new Field( new FieldImpl( id, category ) ) ); 468 mDefaultFields.append( new Field( new FieldImpl( id, category ) ) );
475} 469}
476 470
477void Field::deleteFields() 471void Field::deleteFields()
478{ 472{
479 Field::List::ConstIterator it; 473 Field::List::ConstIterator it;
480 474
481 for( it = mAllFields.begin(); it != mAllFields.end(); ++it ) { 475 for( it = mAllFields.begin(); it != mAllFields.end(); ++it ) {
482 delete (*it); 476 delete (*it);
483 } 477 }
484 mAllFields.clear(); 478 mAllFields.clear();
485 479
486 for( it = mDefaultFields.begin(); it != mDefaultFields.end(); ++it ) { 480 for( it = mDefaultFields.begin(); it != mDefaultFields.end(); ++it ) {
487 delete (*it); 481 delete (*it);
488 } 482 }
489 mDefaultFields.clear(); 483 mDefaultFields.clear();
490 484
491 for( it = mCustomFields.begin(); it != mCustomFields.end(); ++it ) { 485 for( it = mCustomFields.begin(); it != mCustomFields.end(); ++it ) {
492 delete (*it); 486 delete (*it);
493 } 487 }
494 mCustomFields.clear(); 488 mCustomFields.clear();
495} 489}
496 490
497void Field::saveFields( const QString &identifier, 491void Field::saveFields( const QString &identifier,
498 const Field::List &fields ) 492 const Field::List &fields )
499{ 493{
500 KConfig *cfg = KGlobal::config(); 494 KConfig *cfg = KGlobal::config();
501 KConfigGroupSaver( cfg, "KABCFields" ); 495 KConfigGroupSaver( cfg, "KABCFields" );
502 saveFields( cfg, identifier, fields ); 496 saveFields( cfg, identifier, fields );
503} 497}
504 498
505void Field::saveFields( KConfig *cfg, const QString &identifier, 499void Field::saveFields( KConfig *cfg, const QString &identifier,
506 const Field::List &fields ) 500 const Field::List &fields )
507{ 501{
508 QValueList<int> fieldIds; 502 QValueList<int> fieldIds;
509 503
510//US 504//US
511// qDebug("Field::saveFields to %s %s", cfg->getFileName().latin1(), identifier.latin1()); 505// qDebug("Field::saveFields to %s %s", cfg->getFileName().latin1(), identifier.latin1());
512 506
513 int custom = 0; 507 int custom = 0;
514 Field::List::ConstIterator it; 508 Field::List::ConstIterator it;
515 for( it = fields.begin(); it != fields.end(); ++it ) { 509 for( it = fields.begin(); it != fields.end(); ++it ) {
516//US 510//US
517// qDebug("Field::saveFields field:%i", (*it)->mImpl->fieldId()); 511// qDebug("Field::saveFields field:%i", (*it)->mImpl->fieldId());
518 512
519 fieldIds.append( (*it)->mImpl->fieldId() ); 513 fieldIds.append( (*it)->mImpl->fieldId() );
520 if( (*it)->isCustom() ) { 514 if( (*it)->isCustom() ) {
521 QStringList customEntry; 515 QStringList customEntry;
522 customEntry << (*it)->mImpl->label(); 516 customEntry << (*it)->mImpl->label();
523 customEntry << (*it)->mImpl->key(); 517 customEntry << (*it)->mImpl->key();
524 customEntry << (*it)->mImpl->app(); 518 customEntry << (*it)->mImpl->app();
525 cfg->writeEntry( "KABC_CustomEntry_" + identifier + "_" + 519 cfg->writeEntry( "KABC_CustomEntry_" + identifier + "_" +
526 QString::number( custom++ ), customEntry ); 520 QString::number( custom++ ), customEntry );
527 } 521 }
528 } 522 }
529 cfg->writeEntry( identifier, fieldIds ); 523 cfg->writeEntry( identifier, fieldIds );
530} 524}
531 525
532Field::List Field::restoreFields( const QString &identifier ) 526Field::List Field::restoreFields( const QString &identifier )
533{ 527{
534//US 528//US
535// qDebug("Field::restoreFields, identifier: %s", identifier.latin1()); 529// qDebug("Field::restoreFields, identifier: %s", identifier.latin1());
536 530
537 KConfig *cfg = KGlobal::config(); 531 KConfig *cfg = KGlobal::config();
538 KConfigGroupSaver( cfg, "KABCFields" ); 532 KConfigGroupSaver( cfg, "KABCFields" );
539 cfg->setGroup( "KABCFields" ); 533 cfg->setGroup( "KABCFields" );
540 534
541 Field::List l = restoreFields( cfg, identifier ); 535 Field::List l = restoreFields( cfg, identifier );
542 536
543 return l; 537 return l;
544} 538}
545 539
546Field::List Field::restoreFields( KConfig *cfg, const QString &identifier ) 540Field::List Field::restoreFields( KConfig *cfg, const QString &identifier )
547{ 541{
548 QValueList<int> fieldIds = cfg->readIntListEntry( identifier); 542 QValueList<int> fieldIds = cfg->readIntListEntry( identifier);
549//US 543//US
550// qDebug("Field::restoreFields from %s, identifier: %s", cfg->getFileName().latin1(), identifier.latin1()); 544// qDebug("Field::restoreFields from %s, identifier: %s", cfg->getFileName().latin1(), identifier.latin1());
551 545
552 Field::List fields; 546 Field::List fields;
553 547
554 int custom = 0; 548 int custom = 0;
555 QValueList<int>::ConstIterator it; 549 QValueList<int>::ConstIterator it;
556 for( it = fieldIds.begin(); it != fieldIds.end(); ++it ) { 550 for( it = fieldIds.begin(); it != fieldIds.end(); ++it ) {
557 FieldImpl *f = 0; 551 FieldImpl *f = 0;
558 if ( (*it) == FieldImpl::CustomField ) { 552 if ( (*it) == FieldImpl::CustomField ) {
559 QStringList customEntry = cfg->readListEntry( "KABC_CustomEntry_" + 553 QStringList customEntry = cfg->readListEntry( "KABC_CustomEntry_" +
560 identifier + "_" + 554 identifier + "_" +
561 QString::number( custom++ ) ); 555 QString::number( custom++ ) );
562 f = new FieldImpl( *it, CustomCategory, customEntry[ 0 ], 556 f = new FieldImpl( *it, CustomCategory, customEntry[ 0 ],
563 customEntry[ 1 ], customEntry[ 2 ] ); 557 customEntry[ 1 ], customEntry[ 2 ] );
564 } else { 558 } else {
565 f = new FieldImpl( *it ); 559 f = new FieldImpl( *it );
566 } 560 }
567 fields.append( new Field( f ) ); 561 fields.append( new Field( f ) );
568 } 562 }
569 563
570 return fields; 564 return fields;
571} 565}
572 566
573bool Field::equals( Field *field ) 567bool Field::equals( Field *field )
574{ 568{
575 bool sameId = ( mImpl->fieldId() == field->mImpl->fieldId() ); 569 bool sameId = ( mImpl->fieldId() == field->mImpl->fieldId() );
576 570
577 if ( !sameId ) return false; 571 if ( !sameId ) return false;
578 572
579 if ( mImpl->fieldId() != FieldImpl::CustomField ) return true; 573 if ( mImpl->fieldId() != FieldImpl::CustomField ) return true;
580 574
581 return mImpl->key() == field->mImpl->key(); 575 return mImpl->key() == field->mImpl->key();
582} 576}
583 577
584Field *Field::createCustomField( const QString &label, int category, 578Field *Field::createCustomField( const QString &label, int category,
585 const QString &key, const QString &app ) 579 const QString &key, const QString &app )
586{ 580{
587 Field *field = new Field( new FieldImpl( FieldImpl::CustomField, 581 Field *field = new Field( new FieldImpl( FieldImpl::CustomField,
588 category | CustomCategory, 582 category | CustomCategory,
589 label, key, app ) ); 583 label, key, app ) );
590//US 584//US
591// qDebug("Field::createCustomField label %s", label.latin1() ); 585// qDebug("Field::createCustomField label %s", label.latin1() );
592 586
593 mCustomFields.append( field ); 587 mCustomFields.append( field );
594 588
595 return field; 589 return field;
596} 590}
diff --git a/kalarmd/simplealarmdaemonimpl.cpp b/kalarmd/simplealarmdaemonimpl.cpp
index b3da428..294ce7d 100644
--- a/kalarmd/simplealarmdaemonimpl.cpp
+++ b/kalarmd/simplealarmdaemonimpl.cpp
@@ -1,686 +1,686 @@
1/* 1/*
2 This file is part of the KOrganizer alarm daemon. 2 This file is part of the KOrganizer alarm daemon.
3 Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include "simplealarmdaemonimpl.h" 24#include "simplealarmdaemonimpl.h"
25 25
26#include "alarmdialog.h" 26#include "alarmdialog.h"
27#include <qpopupmenu.h> 27#include <qpopupmenu.h>
28#include <qapp.h> 28#include <qapp.h>
29#include <qdir.h> 29#include <qdir.h>
30#include <qfile.h> 30#include <qfile.h>
31#include <qhbox.h> 31#include <qhbox.h>
32#include <qtimer.h> 32#include <qtimer.h>
33#include <qfile.h> 33#include <qfile.h>
34#include <qdatetime.h> 34#include <qdatetime.h>
35#include <qpushbutton.h> 35#include <qpushbutton.h>
36#include <qlayout.h> 36#include <qlayout.h>
37#include <qlineedit.h> 37#include <qlineedit.h>
38#include <qdialog.h> 38#include <qdialog.h>
39#define protected public 39#define protected public
40#include <qspinbox.h> 40#include <qspinbox.h>
41#undef protected 41#undef protected
42#include <qtextstream.h> 42#include <qtextstream.h>
43#include <qtopia/qcopenvelope_qws.h> 43#include <qtopia/qcopenvelope_qws.h>
44#include <qtopia/alarmserver.h> 44#include <qtopia/alarmserver.h>
45 45
46#include <stdlib.h> 46#include <stdlib.h>
47#include <stdio.h> 47#include <stdio.h>
48#include <unistd.h> 48#include <unistd.h>
49 49
50 50
51SimpleAlarmDaemonImpl::SimpleAlarmDaemonImpl( QWidget *parent ) 51SimpleAlarmDaemonImpl::SimpleAlarmDaemonImpl( QWidget *parent )
52 : QLabel( parent ) 52 : QLabel( parent )
53{ 53{
54 mAlarmDialog = new AlarmDialog( 0 ); 54 mAlarmDialog = new AlarmDialog( 0 );
55 mPopUp = new QPopupMenu( this ); 55 mPopUp = new QPopupMenu( this );
56 mPopUp->insertItem( "What's Next?", this, SLOT ( showWN() ) ); 56 mPopUp->insertItem( "What's Next?", this, SLOT ( showWN() ) );
57 mPopUp->insertItem( "Next Days!", this, SLOT ( showKO() ) ); 57 mPopUp->insertItem( "Next Days!", this, SLOT ( showKO() ) );
58 mPopUp->insertSeparator(); 58 mPopUp->insertSeparator();
59 mPopUp->insertItem( "What's Todo?", this, SLOT ( showTodo() ) ); 59 mPopUp->insertItem( "Todo List", this, SLOT ( showTodo() ) );
60 mPopUp->insertSeparator(); 60 mPopUp->insertSeparator();
61 mPopUp->insertItem( "Addresses", this, SLOT ( showAdd() ) ); 61 mPopUp->insertItem( "Addresses", this, SLOT ( showAdd() ) );
62 mPopUp->insertSeparator(); 62 mPopUp->insertSeparator();
63 mPopUp->insertItem( "Edit Journal", this, SLOT ( writeJournal() ) ); 63 mPopUp->insertItem( "Edit Journal", this, SLOT ( writeJournal() ) );
64 mPopUp->insertItem( "New Event", this, SLOT ( newEvent() ) ); 64 mPopUp->insertItem( "New Event", this, SLOT ( newEvent() ) );
65 mPopUp->insertItem( "New Todo", this, SLOT ( newTodo() ) ); 65 mPopUp->insertItem( "New Todo", this, SLOT ( newTodo() ) );
66 mPopUp->insertItem( "New Mail", this, SLOT ( newMail() ) ); 66 mPopUp->insertItem( "New Mail", this, SLOT ( newMail() ) );
67 mPopUp->insertSeparator(); 67 mPopUp->insertSeparator();
68 mPopUp->insertItem( "Multi Sync", this, SLOT ( ringSync() ) ); 68 mPopUp->insertItem( "Multi Sync", this, SLOT ( ringSync() ) );
69 mTimerPopUp = new QPopupMenu( this ); 69 mTimerPopUp = new QPopupMenu( this );
70 QFont fon = mTimerPopUp->font(); 70 QFont fon = mTimerPopUp->font();
71 fon.setPointSize( fon.pointSize() *3/2 ); 71 fon.setPointSize( fon.pointSize() *3/2 );
72 mTimerPopUp->setFont( fon ); 72 mTimerPopUp->setFont( fon );
73 mBeepPopUp = new QPopupMenu( this ); 73 mBeepPopUp = new QPopupMenu( this );
74 mSoundPopUp = new QPopupMenu( this ); 74 mSoundPopUp = new QPopupMenu( this );
75 mPausePopUp = new QPopupMenu( this ); 75 mPausePopUp = new QPopupMenu( this );
76 QPopupMenu* savePopUp = new QPopupMenu( this ); 76 QPopupMenu* savePopUp = new QPopupMenu( this );
77 savePopUp->insertItem( "Save", 0 ); 77 savePopUp->insertItem( "Save", 0 );
78 savePopUp->insertItem( "Load", 1 ); 78 savePopUp->insertItem( "Load", 1 );
79 mSoundPopUp->insertItem( "Buzzer", 0 ); 79 mSoundPopUp->insertItem( "Buzzer", 0 );
80 mSoundPopUp->insertItem( "Wav file", 1 ); 80 mSoundPopUp->insertItem( "Wav file", 1 );
81 mPausePopUp->insertItem( " 1 sec", 1 ); 81 mPausePopUp->insertItem( " 1 sec", 1 );
82 mPausePopUp->insertItem( " 2 sec", 2 ); 82 mPausePopUp->insertItem( " 2 sec", 2 );
83 mPausePopUp->insertItem( " 3 sec", 3 ); 83 mPausePopUp->insertItem( " 3 sec", 3 );
84 mPausePopUp->insertItem( " 5 sec", 5 ); 84 mPausePopUp->insertItem( " 5 sec", 5 );
85 mPausePopUp->insertItem( "10 sec", 10 ); 85 mPausePopUp->insertItem( "10 sec", 10 );
86 mPausePopUp->insertItem( "30 sec", 30 ); 86 mPausePopUp->insertItem( "30 sec", 30 );
87 mPausePopUp->insertItem( " 1 min", 60 ); 87 mPausePopUp->insertItem( " 1 min", 60 );
88 mPausePopUp->insertItem( " 5 min", 300 ); 88 mPausePopUp->insertItem( " 5 min", 300 );
89 mPausePopUp->insertItem( "10 min", 600 ); 89 mPausePopUp->insertItem( "10 min", 600 );
90 mSuspendPopUp = new QPopupMenu( this ); 90 mSuspendPopUp = new QPopupMenu( this );
91 mSuspendPopUp->insertItem( "Off", 0 ); 91 mSuspendPopUp->insertItem( "Off", 0 );
92 mSuspendPopUp->insertItem( " 1x", 1 ); 92 mSuspendPopUp->insertItem( " 1x", 1 );
93 mSuspendPopUp->insertItem( " 2x", 2 ); 93 mSuspendPopUp->insertItem( " 2x", 2 );
94 mSuspendPopUp->insertItem( " 3x", 3 ); 94 mSuspendPopUp->insertItem( " 3x", 3 );
95 mSuspendPopUp->insertItem( " 5x", 5 ); 95 mSuspendPopUp->insertItem( " 5x", 5 );
96 mSuspendPopUp->insertItem( "10x", 10 ); 96 mSuspendPopUp->insertItem( "10x", 10 );
97 mSuspendPopUp->insertItem( "20x", 20 ); 97 mSuspendPopUp->insertItem( "20x", 20 );
98 mSuspendPopUp->insertItem( "30x", 30 ); 98 mSuspendPopUp->insertItem( "30x", 30 );
99 mBeepPopUp->insertItem( "Auto suspend",mSuspendPopUp ); 99 mBeepPopUp->insertItem( "Auto suspend",mSuspendPopUp );
100 mBeepPopUp->insertItem( "Beep interval",mPausePopUp ); 100 mBeepPopUp->insertItem( "Beep interval",mPausePopUp );
101 mBeepPopUp->insertItem( "Replay",mSoundPopUp ); 101 mBeepPopUp->insertItem( "Replay",mSoundPopUp );
102 mBeepPopUp->insertItem( "Config",savePopUp ); 102 mBeepPopUp->insertItem( "Config",savePopUp );
103 mBeepPopUp->insertItem( "300", 300 ); 103 mBeepPopUp->insertItem( "300", 300 );
104 mBeepPopUp->insertItem( "180", 180 ); 104 mBeepPopUp->insertItem( "180", 180 );
105 mBeepPopUp->insertItem( "60", 60 ); 105 mBeepPopUp->insertItem( "60", 60 );
106 mBeepPopUp->insertItem( "30", 30 ); 106 mBeepPopUp->insertItem( "30", 30 );
107 mBeepPopUp->insertItem( "10", 10 ); 107 mBeepPopUp->insertItem( "10", 10 );
108 mBeepPopUp->insertItem( "3", 3 ); 108 mBeepPopUp->insertItem( "3", 3 );
109 mBeepPopUp->insertItem( "1", 1 ); 109 mBeepPopUp->insertItem( "1", 1 );
110 mBeepPopUp->insertItem( "Off", 0 ); 110 mBeepPopUp->insertItem( "Off", 0 );
111 mBeepPopUp->setCheckable( true ); 111 mBeepPopUp->setCheckable( true );
112 mPopUp->insertSeparator(); 112 mPopUp->insertSeparator();
113 mPopUp->insertItem( "Play beeps", mBeepPopUp ); 113 mPopUp->insertItem( "Play beeps", mBeepPopUp );
114 mPopUp->insertSeparator(); 114 mPopUp->insertSeparator();
115 mPopUp->insertItem( "Timer", mTimerPopUp ); 115 mPopUp->insertItem( "Timer", mTimerPopUp );
116 mPopUp->insertSeparator(); 116 mPopUp->insertSeparator();
117 mPopUp->insertItem( "Simulate", this, SLOT ( simulate() ) ); 117 mPopUp->insertItem( "Simulate", this, SLOT ( simulate() ) );
118 118
119 mPopUp->resize( mPopUp->sizeHint() ); 119 mPopUp->resize( mPopUp->sizeHint() );
120 mPlayBeeps = 60; 120 mPlayBeeps = 60;
121 mBeepPopUp->setItemChecked ( mPlayBeeps, true ); 121 mBeepPopUp->setItemChecked ( mPlayBeeps, true );
122 connect ( mBeepPopUp, SIGNAL( activated ( int ) ), this, SLOT (slotPlayBeep( int ) ) ); 122 connect ( mBeepPopUp, SIGNAL( activated ( int ) ), this, SLOT (slotPlayBeep( int ) ) );
123 connect ( mTimerPopUp, SIGNAL( activated ( int ) ), this, SLOT (confTimer( int ) ) ); 123 connect ( mTimerPopUp, SIGNAL( activated ( int ) ), this, SLOT (confTimer( int ) ) );
124 connect ( mTimerPopUp, SIGNAL(aboutToShow() ), this, SLOT ( showTimer( ) ) ); 124 connect ( mTimerPopUp, SIGNAL(aboutToShow() ), this, SLOT ( showTimer( ) ) );
125 connect ( mSoundPopUp, SIGNAL( activated ( int ) ), this, SLOT (confSound( int ) ) ); 125 connect ( mSoundPopUp, SIGNAL( activated ( int ) ), this, SLOT (confSound( int ) ) );
126 connect ( mPausePopUp, SIGNAL( activated ( int ) ), this, SLOT (confPause( int ) ) ); 126 connect ( mPausePopUp, SIGNAL( activated ( int ) ), this, SLOT (confPause( int ) ) );
127 connect ( mSuspendPopUp, SIGNAL( activated ( int ) ), this, SLOT (confSuspend( int ) ) ); 127 connect ( mSuspendPopUp, SIGNAL( activated ( int ) ), this, SLOT (confSuspend( int ) ) );
128 connect ( savePopUp, SIGNAL( activated ( int ) ), this, SLOT (saveSlot( int ) ) ); 128 connect ( savePopUp, SIGNAL( activated ( int ) ), this, SLOT (saveSlot( int ) ) );
129 mTimerTime = 0; 129 mTimerTime = 0;
130 mCustomText = "Custom Text"; 130 mCustomText = "Custom Text";
131 mCustomMinutes = 7; 131 mCustomMinutes = 7;
132 mTimerPopupConf = 1; 132 mTimerPopupConf = 1;
133 fillTimerPopUp(); 133 fillTimerPopUp();
134 mPausePlay = 0; 134 mPausePlay = 0;
135 confPause( 1 ); 135 confPause( 1 );
136 mSuspend = 0; 136 mSuspend = 0;
137 confSuspend( 0 ); 137 confSuspend( 0 );
138 if ( QApplication::desktop()->width() < 480 ) { 138 if ( QApplication::desktop()->width() < 480 ) {
139 wavAlarm = false; 139 wavAlarm = false;
140 mSoundPopUp->setItemChecked ( 0, true ); 140 mSoundPopUp->setItemChecked ( 0, true );
141 } 141 }
142 else { 142 else {
143 wavAlarm = true; 143 wavAlarm = true;
144 mSoundPopUp->setItemChecked ( 1, true ); 144 mSoundPopUp->setItemChecked ( 1, true );
145 } 145 }
146 saveSlot( 1 ); 146 saveSlot( 1 );
147} 147}
148 148
149SimpleAlarmDaemonImpl::~SimpleAlarmDaemonImpl() 149SimpleAlarmDaemonImpl::~SimpleAlarmDaemonImpl()
150{ 150{
151 //delete mPopUp; 151 //delete mPopUp;
152 delete mAlarmDialog; 152 delete mAlarmDialog;
153} 153}
154void SimpleAlarmDaemonImpl::saveSlot( int load ) 154void SimpleAlarmDaemonImpl::saveSlot( int load )
155{ 155{
156 QString fileName = QDir::homeDirPath() +"/.kopialarmrc"; 156 QString fileName = QDir::homeDirPath() +"/.kopialarmrc";
157 //qDebug("save %d ", load ); 157 //qDebug("save %d ", load );
158 QFile file( fileName ); 158 QFile file( fileName );
159 if ( load ) { 159 if ( load ) {
160 if( !QFile::exists( fileName) ) 160 if( !QFile::exists( fileName) )
161 return; 161 return;
162 if (!file.open( IO_ReadOnly ) ) { 162 if (!file.open( IO_ReadOnly ) ) {
163 return ; 163 return ;
164 } 164 }
165 QString line; 165 QString line;
166 bool ok; 166 bool ok;
167 int val; 167 int val;
168 int len; 168 int len;
169 while ( file.readLine( line, 1024 ) > 0 ) { 169 while ( file.readLine( line, 1024 ) > 0 ) {
170 //qDebug("read %s ", line.latin1()); 170 //qDebug("read %s ", line.latin1());
171 len = line.length(); 171 len = line.length();
172 if ( line.left(4 ) == "PPAU" ) { 172 if ( line.left(4 ) == "PPAU" ) {
173 val = line.mid( 4,len-5).toInt( &ok ); 173 val = line.mid( 4,len-5).toInt( &ok );
174 if ( ok ) { 174 if ( ok ) {
175 confPause( val ); 175 confPause( val );
176 } 176 }
177 } 177 }
178 if ( line.left(4 ) == "SUCO" ) { 178 if ( line.left(4 ) == "SUCO" ) {
179 val = line.mid( 4,len-5).toInt( &ok ); 179 val = line.mid( 4,len-5).toInt( &ok );
180 if ( ok ) 180 if ( ok )
181 confSuspend ( val ); 181 confSuspend ( val );
182 } 182 }
183 if ( line.left(4 ) == "WAAL" ) { 183 if ( line.left(4 ) == "WAAL" ) {
184 val = line.mid( 4,len-5).toInt( &ok ); 184 val = line.mid( 4,len-5).toInt( &ok );
185 if ( ok ) 185 if ( ok )
186 confSound( val ); 186 confSound( val );
187 187
188 } 188 }
189 if ( line.left(4 ) == "PLBE" ) { 189 if ( line.left(4 ) == "PLBE" ) {
190 val = line.mid( 4,len-5).toInt( &ok ); 190 val = line.mid( 4,len-5).toInt( &ok );
191 if ( ok ) 191 if ( ok )
192 slotPlayBeep( val ); 192 slotPlayBeep( val );
193 193
194 } 194 }
195 if ( line.left(4 ) == "CUTE" ) { 195 if ( line.left(4 ) == "CUTE" ) {
196 mCustomText = line.mid( 5,len-6); 196 mCustomText = line.mid( 5,len-6);
197 // qDebug("text ***%s*** ",mCustomText.latin1() ); 197 // qDebug("text ***%s*** ",mCustomText.latin1() );
198 198
199 } 199 }
200 if ( line.left(4 ) == "CUMI" ) { 200 if ( line.left(4 ) == "CUMI" ) {
201 val = line.mid( 4,len-5).toInt( &ok ); 201 val = line.mid( 4,len-5).toInt( &ok );
202 if ( ok ) 202 if ( ok )
203 mCustomMinutes = val; 203 mCustomMinutes = val;
204 204
205 } 205 }
206 if ( line.left(4 ) == "SUTI" ) { 206 if ( line.left(4 ) == "SUTI" ) {
207 val = line.mid( 4,len-5).toInt( &ok ); 207 val = line.mid( 4,len-5).toInt( &ok );
208 if ( ok ) 208 if ( ok )
209 mAlarmDialog->setSuspendTime( val );; 209 mAlarmDialog->setSuspendTime( val );;
210 210
211 } 211 }
212 } 212 }
213 file.close(); 213 file.close();
214 } else { 214 } else {
215 if (!file.open( IO_WriteOnly ) ) { 215 if (!file.open( IO_WriteOnly ) ) {
216 return; 216 return;
217 } 217 }
218 QString configString ; 218 QString configString ;
219 configString += "PPAU " + QString::number( mPausePlay ) + "\n"; 219 configString += "PPAU " + QString::number( mPausePlay ) + "\n";
220 configString += "SUCO " + QString::number( mSuspend ) + "\n"; 220 configString += "SUCO " + QString::number( mSuspend ) + "\n";
221 configString += "WAAL " + QString::number( wavAlarm ) + "\n"; 221 configString += "WAAL " + QString::number( wavAlarm ) + "\n";
222 configString += "PLBE " + QString::number( mPlayBeeps ) + "\n"; 222 configString += "PLBE " + QString::number( mPlayBeeps ) + "\n";
223 configString += "CUTE " + mCustomText + "\n"; 223 configString += "CUTE " + mCustomText + "\n";
224 configString += "CUMI " + QString::number( mCustomMinutes ) + "\n"; 224 configString += "CUMI " + QString::number( mCustomMinutes ) + "\n";
225 configString += "SUTI " + QString::number( mAlarmDialog->getSuspendTime( )) + "\n"; 225 configString += "SUTI " + QString::number( mAlarmDialog->getSuspendTime( )) + "\n";
226 QTextStream ts( &file ); 226 QTextStream ts( &file );
227 ts << configString ; 227 ts << configString ;
228 file.close(); 228 file.close();
229 } 229 }
230 230
231} 231}
232void SimpleAlarmDaemonImpl::confSuspend( int num ) 232void SimpleAlarmDaemonImpl::confSuspend( int num )
233{ 233{
234 mSuspendPopUp->setItemChecked ( mSuspend,false ); 234 mSuspendPopUp->setItemChecked ( mSuspend,false );
235 mSuspend = num; 235 mSuspend = num;
236 mSuspendPopUp->setItemChecked ( mSuspend,true ); 236 mSuspendPopUp->setItemChecked ( mSuspend,true );
237} 237}
238void SimpleAlarmDaemonImpl::confPause( int num ) 238void SimpleAlarmDaemonImpl::confPause( int num )
239{ 239{
240 mPausePopUp->setItemChecked ( mPausePlay,false ); 240 mPausePopUp->setItemChecked ( mPausePlay,false );
241 mPausePlay = num; 241 mPausePlay = num;
242 mPausePopUp->setItemChecked ( mPausePlay,true ); 242 mPausePopUp->setItemChecked ( mPausePlay,true );
243} 243}
244void SimpleAlarmDaemonImpl::confSound( int num ) 244void SimpleAlarmDaemonImpl::confSound( int num )
245{ 245{
246 if ( num == 0 ) { 246 if ( num == 0 ) {
247 wavAlarm = false; 247 wavAlarm = false;
248 mSoundPopUp->setItemChecked ( 0, true ); 248 mSoundPopUp->setItemChecked ( 0, true );
249 mSoundPopUp->setItemChecked ( 1, false ); 249 mSoundPopUp->setItemChecked ( 1, false );
250 } else { 250 } else {
251 wavAlarm = true; 251 wavAlarm = true;
252 mSoundPopUp->setItemChecked ( 0, false ); 252 mSoundPopUp->setItemChecked ( 0, false );
253 mSoundPopUp->setItemChecked ( 1, true ); 253 mSoundPopUp->setItemChecked ( 1, true );
254 } 254 }
255} 255}
256void SimpleAlarmDaemonImpl::slotPlayBeep( int num ) 256void SimpleAlarmDaemonImpl::slotPlayBeep( int num )
257{ 257{
258 mBeepPopUp->setItemChecked ( mPlayBeeps,false ); 258 mBeepPopUp->setItemChecked ( mPlayBeeps,false );
259 mPlayBeeps = num; 259 mPlayBeeps = num;
260 mBeepPopUp->setItemChecked ( mPlayBeeps, true ); 260 mBeepPopUp->setItemChecked ( mPlayBeeps, true );
261} 261}
262 262
263void SimpleAlarmDaemonImpl::recieve( const QCString& msg, const QByteArray& ) 263void SimpleAlarmDaemonImpl::recieve( const QCString& msg, const QByteArray& )
264{ 264{
265 //qDebug("SimpleAlarmDaemonImpl::ALARM RECEIVED! %s", msg.data()); 265 //qDebug("SimpleAlarmDaemonImpl::ALARM RECEIVED! %s", msg.data());
266 QString mess = msg; 266 QString mess = msg;
267 mAlarmMessage = mess.mid( 9 ); 267 mAlarmMessage = mess.mid( 9 );
268 QString filename = getenv("QPEDIR") ; 268 QString filename = getenv("QPEDIR") ;
269 filename += "/pics/kdepim/korganizer/koalarm.wav"; 269 filename += "/pics/kdepim/korganizer/koalarm.wav";
270 QString tempfilename; 270 QString tempfilename;
271 if ( mess.left( 13 ) == "suspend_alarm") { 271 if ( mess.left( 13 ) == "suspend_alarm") {
272 bool error = false; 272 bool error = false;
273 int len = mess.mid( 13 ).find("+++"); 273 int len = mess.mid( 13 ).find("+++");
274 if ( len < 2 ) 274 if ( len < 2 )
275 error = true; 275 error = true;
276 else { 276 else {
277 tempfilename = mess.mid( 13, len ); 277 tempfilename = mess.mid( 13, len );
278 if ( !QFile::exists( tempfilename ) ) 278 if ( !QFile::exists( tempfilename ) )
279 error = true; 279 error = true;
280 } 280 }
281 if ( ! error ) { 281 if ( ! error ) {
282 filename = tempfilename; 282 filename = tempfilename;
283 } 283 }
284 mAlarmMessage = mess.mid( 13+len+3 ); 284 mAlarmMessage = mess.mid( 13+len+3 );
285 //qDebug("suspend file %s ",tempfilename.latin1() ); 285 //qDebug("suspend file %s ",tempfilename.latin1() );
286 startAlarm( mAlarmMessage, filename); 286 startAlarm( mAlarmMessage, filename);
287 return; 287 return;
288 } 288 }
289 if ( mess.left( 11 ) == "timer_alarm") { 289 if ( mess.left( 11 ) == "timer_alarm") {
290 mTimerTime = 0; 290 mTimerTime = 0;
291 startAlarm( mess.mid( 11 ), filename ); 291 startAlarm( mess.mid( 11 ), filename );
292 return; 292 return;
293 } 293 }
294 if ( mess.left( 10 ) == "proc_alarm") { 294 if ( mess.left( 10 ) == "proc_alarm") {
295 bool error = false; 295 bool error = false;
296 int len = mess.mid( 10 ).find("+++"); 296 int len = mess.mid( 10 ).find("+++");
297 if ( len < 2 ) 297 if ( len < 2 )
298 error = true; 298 error = true;
299 else { 299 else {
300 tempfilename = mess.mid( 10, len ); 300 tempfilename = mess.mid( 10, len );
301 if ( !QFile::exists( tempfilename ) ) 301 if ( !QFile::exists( tempfilename ) )
302 error = true; 302 error = true;
303 } 303 }
304 if ( error ) { 304 if ( error ) {
305 mAlarmMessage = "Procedure Alarm\nError - File not found\n"; 305 mAlarmMessage = "Procedure Alarm\nError - File not found\n";
306 mAlarmMessage += mess.mid( 10+len+3+9 ); 306 mAlarmMessage += mess.mid( 10+len+3+9 );
307 } else { 307 } else {
308 QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); 308 QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent");
309 //qDebug("-----system command %s ",tempfilename.latin1() ); 309 //qDebug("-----system command %s ",tempfilename.latin1() );
310 if ( vfork () == 0 ) { 310 if ( vfork () == 0 ) {
311 execl ( tempfilename.latin1(), 0 ); 311 execl ( tempfilename.latin1(), 0 );
312 return; 312 return;
313 } 313 }
314 return; 314 return;
315 } 315 }
316 316
317 //qDebug("+++++++system command %s ",tempfilename.latin1() ); 317 //qDebug("+++++++system command %s ",tempfilename.latin1() );
318 } 318 }
319 if ( mess.left( 11 ) == "audio_alarm") { 319 if ( mess.left( 11 ) == "audio_alarm") {
320 bool error = false; 320 bool error = false;
321 int len = mess.mid( 11 ).find("+++"); 321 int len = mess.mid( 11 ).find("+++");
322 if ( len < 2 ) 322 if ( len < 2 )
323 error = true; 323 error = true;
324 else { 324 else {
325 tempfilename = mess.mid( 11, len ); 325 tempfilename = mess.mid( 11, len );
326 if ( !QFile::exists( tempfilename ) ) 326 if ( !QFile::exists( tempfilename ) )
327 error = true; 327 error = true;
328 } 328 }
329 if ( ! error ) { 329 if ( ! error ) {
330 filename = tempfilename; 330 filename = tempfilename;
331 } 331 }
332 mAlarmMessage = mess.mid( 11+len+3+9 ); 332 mAlarmMessage = mess.mid( 11+len+3+9 );
333 //qDebug("audio file command %s ",tempfilename.latin1() ); 333 //qDebug("audio file command %s ",tempfilename.latin1() );
334 } 334 }
335 if ( mess.left( 9 ) == "cal_alarm") { 335 if ( mess.left( 9 ) == "cal_alarm") {
336 mAlarmMessage = mess.mid( 9 ) ; 336 mAlarmMessage = mess.mid( 9 ) ;
337 } 337 }
338 338
339 writeFile(); 339 writeFile();
340 startAlarm( mAlarmMessage, filename ); 340 startAlarm( mAlarmMessage, filename );
341 341
342} 342}
343 343
344int SimpleAlarmDaemonImpl::getFileNameLen( QString mess ) 344int SimpleAlarmDaemonImpl::getFileNameLen( QString mess )
345{ 345{
346 return 0; 346 return 0;
347} 347}
348void SimpleAlarmDaemonImpl::startAlarm( QString mess, QString filename ) 348void SimpleAlarmDaemonImpl::startAlarm( QString mess, QString filename )
349{ 349{
350 //mAlarmDialog->show(); 350 //mAlarmDialog->show();
351 //mAlarmDialog->raise(); 351 //mAlarmDialog->raise();
352 mAlarmDialog->eventNotification( mess, mPlayBeeps, filename, wavAlarm,mPausePlay ,mSuspend ); 352 mAlarmDialog->eventNotification( mess, mPlayBeeps, filename, wavAlarm,mPausePlay ,mSuspend );
353} 353}
354 354
355 355
356void SimpleAlarmDaemonImpl::fillTimerPopUp() 356void SimpleAlarmDaemonImpl::fillTimerPopUp()
357{ 357{
358 358
359 // qDebug(" timer %d %d ",mTimerPopupConf, mTimerTime ); 359 // qDebug(" timer %d %d ",mTimerPopupConf, mTimerTime );
360 if ( mTimerPopupConf == mTimerTime ) { 360 if ( mTimerPopupConf == mTimerTime ) {
361 if ( mTimerTime ) { 361 if ( mTimerTime ) {
362 int secs = QDateTime::currentDateTime().secsTo ( mRunningTimer ); 362 int secs = QDateTime::currentDateTime().secsTo ( mRunningTimer );
363 QTime t ( secs/3600, (secs/60)%60, secs%60 ); 363 QTime t ( secs/3600, (secs/60)%60, secs%60 );
364 mTimerPopUp->changeItem ( 1 , t.toString() + " (countdown)"); 364 mTimerPopUp->changeItem ( 1 , t.toString() + " (countdown)");
365 } 365 }
366 else { 366 else {
367 QString text = mCustomText.stripWhiteSpace (); 367 QString text = mCustomText.stripWhiteSpace ();
368 int in = text.find( " " ); 368 int in = text.find( " " );
369 text = text.left ( in ); 369 text = text.left ( in );
370 mTimerPopUp->changeItem ( 3, text ); 370 mTimerPopUp->changeItem ( 3, text );
371 } 371 }
372 return; 372 return;
373 } 373 }
374 mTimerPopupConf = mTimerTime; 374 mTimerPopupConf = mTimerTime;
375 mTimerPopUp->clear(); 375 mTimerPopUp->clear();
376 if ( mTimerTime ) { 376 if ( mTimerTime ) {
377 int secs = QDateTime::currentDateTime().secsTo ( mRunningTimer ); 377 int secs = QDateTime::currentDateTime().secsTo ( mRunningTimer );
378 QTime t ( secs/3600, (secs/60)%60, secs%60 ); 378 QTime t ( secs/3600, (secs/60)%60, secs%60 );
379 379
380 380
381 mTimerPopUp->insertItem( "Stop timer "+ mRunningTimerText , 0 ); 381 mTimerPopUp->insertItem( "Stop timer "+ mRunningTimerText , 0 );
382 mTimerPopUp->insertItem( t.toString() + " (countdown)",1); 382 mTimerPopUp->insertItem( t.toString() + " (countdown)",1);
383 mTimerPopUp->insertItem( mRunningTimer.time().toString() + " (alarm)",2); 383 mTimerPopUp->insertItem( mRunningTimer.time().toString() + " (alarm)",2);
384 } else { 384 } else {
385 385
386 QString fileName = QDir::homeDirPath() +"/.kopialarmtimerrc"; 386 QString fileName = QDir::homeDirPath() +"/.kopialarmtimerrc";
387 QFile file( fileName ); 387 QFile file( fileName );
388 if( !QFile::exists( fileName) ) { 388 if( !QFile::exists( fileName) ) {
389 // write defaults 389 // write defaults
390 if (!file.open( IO_WriteOnly ) ) { 390 if (!file.open( IO_WriteOnly ) ) {
391 return; 391 return;
392 } 392 }
393 QString configString ; 393 QString configString ;
394 configString += "#config file for kopi alarm timer\n"; 394 configString += "#config file for kopi alarm timer\n";
395 configString += "#format: <Text for popup menu>;<timer countdown in minutes>\n"; 395 configString += "#format: <Text for popup menu>;<timer countdown in minutes>\n";
396 configString += "#NOTE: minimum value for timer are 3 minutes!\n"; 396 configString += "#NOTE: minimum value for timer are 3 minutes!\n";
397 configString += "24 h; 1440\n"; 397 configString += "24 h; 1440\n";
398 configString += " 8 h; 480\n"; 398 configString += " 8 h; 480\n";
399 configString += " 5 h; 300\n"; 399 configString += " 5 h; 300\n";
400 configString += " 1 h; 60\n"; 400 configString += " 1 h; 60\n";
401 configString += "30 min; 30\n"; 401 configString += "30 min; 30\n";
402 configString += "15 min; 15\n"; 402 configString += "15 min; 15\n";
403 configString += "SEPARATOR\n"; 403 configString += "SEPARATOR\n";
404 configString += "Pizza; 22\n"; 404 configString += "Pizza; 22\n";
405 configString += "Nap; 45\n"; 405 configString += "Nap; 45\n";
406 configString += "Tea; 5\n"; 406 configString += "Tea; 5\n";
407 QTextStream ts( &file ); 407 QTextStream ts( &file );
408 ts << configString ; 408 ts << configString ;
409 file.close(); 409 file.close();
410 } 410 }
411 411
412 if (!file.open( IO_ReadOnly ) ) { 412 if (!file.open( IO_ReadOnly ) ) {
413 return ; 413 return ;
414 } 414 }
415 QString line; 415 QString line;
416 bool ok; 416 bool ok;
417 while ( file.readLine( line, 1024 ) > 0 ) { 417 while ( file.readLine( line, 1024 ) > 0 ) {
418 //qDebug("read %s ", line.latin1()); 418 //qDebug("read %s ", line.latin1());
419 if ( line.left(1 ) != "#" ) { 419 if ( line.left(1 ) != "#" ) {
420 // no comment 420 // no comment
421 if ( line.left(9 ) == "SEPARATOR" ) { 421 if ( line.left(9 ) == "SEPARATOR" ) {
422 mTimerPopUp->insertSeparator(); 422 mTimerPopUp->insertSeparator();
423 } else { 423 } else {
424 QStringList li = QStringList::split(";",line); 424 QStringList li = QStringList::split(";",line);
425 ok = false; 425 ok = false;
426 if ( li.count() == 2 ) { 426 if ( li.count() == 2 ) {
427 int val = li[1].toInt( &ok ); 427 int val = li[1].toInt( &ok );
428 if ( ok && val > 2 ) { 428 if ( ok && val > 2 ) {
429 mTimerPopUp->insertItem( li[0], val); 429 mTimerPopUp->insertItem( li[0], val);
430 } 430 }
431 } 431 }
432 } 432 }
433 } 433 }
434 } 434 }
435 file.close(); 435 file.close();
436#if 0 436#if 0
437 mTimerPopUp->insertItem( "24 h", 1440 ); 437 mTimerPopUp->insertItem( "24 h", 1440 );
438 // mTimerPopUp->insertItem( i18n("12 h"), 720 ); 438 // mTimerPopUp->insertItem( i18n("12 h"), 720 );
439 mTimerPopUp->insertItem( " 8 h", 480 ); 439 mTimerPopUp->insertItem( " 8 h", 480 );
440 mTimerPopUp->insertItem( " 5 h", 300 ); 440 mTimerPopUp->insertItem( " 5 h", 300 );
441 // mTimerPopUp->insertItem( i18n(" 2 h"), 120 ); 441 // mTimerPopUp->insertItem( i18n(" 2 h"), 120 );
442 mTimerPopUp->insertItem( " 1 h", 60 ); 442 mTimerPopUp->insertItem( " 1 h", 60 );
443 mTimerPopUp->insertItem( "30 min", 30 ); 443 mTimerPopUp->insertItem( "30 min", 30 );
444 mTimerPopUp->insertItem( "15 min", 15 ); 444 mTimerPopUp->insertItem( "15 min", 15 );
445 mTimerPopUp->insertItem( "10 min", 10 ); 445 mTimerPopUp->insertItem( "10 min", 10 );
446 //mTimerPopUp->insertItem( " 5 min", 5 ); 446 //mTimerPopUp->insertItem( " 5 min", 5 );
447 mTimerPopUp->insertSeparator(); 447 mTimerPopUp->insertSeparator();
448 mTimerPopUp->insertItem( "Pizza", 22 ); 448 mTimerPopUp->insertItem( "Pizza", 22 );
449 mTimerPopUp->insertItem( "Nap", 45 ); 449 mTimerPopUp->insertItem( "Nap", 45 );
450 mTimerPopUp->insertItem( "Tea", 5 ); 450 mTimerPopUp->insertItem( "Tea", 5 );
451#endif 451#endif
452 QString text = mCustomText.stripWhiteSpace (); 452 QString text = mCustomText.stripWhiteSpace ();
453 int in = text.find( " " ); 453 int in = text.find( " " );
454 text = text.left ( in ); 454 text = text.left ( in );
455 mTimerPopUp->insertItem( text, 3 ); 455 mTimerPopUp->insertItem( text, 3 );
456 mTimerPopUp->insertSeparator(); 456 mTimerPopUp->insertSeparator();
457 mTimerPopUp->insertItem( "Customize", 2 ); 457 mTimerPopUp->insertItem( "Customize", 2 );
458 } 458 }
459 459
460} 460}
461 461
462void SimpleAlarmDaemonImpl::showTimer() 462void SimpleAlarmDaemonImpl::showTimer()
463{ 463{
464 fillTimerPopUp(); 464 fillTimerPopUp();
465} 465}
466 466
467void SimpleAlarmDaemonImpl::confTimer( int time ) 467void SimpleAlarmDaemonImpl::confTimer( int time )
468{ 468{
469 //qDebug("impleAlarmDaemonImpl::confTimer() %d ", time ); 469 //qDebug("impleAlarmDaemonImpl::confTimer() %d ", time );
470 int minutes = time; 470 int minutes = time;
471 if ( minutes == 0 ) { 471 if ( minutes == 0 ) {
472 if ( ! mTimerTime ) 472 if ( ! mTimerTime )
473 return; 473 return;
474 474
475 QDialog dia ( 0, ("Stop Timer" ), true ); 475 QDialog dia ( 0, ("Stop Timer" ), true );
476 QLabel lab (("Really stop the timer?\n\n"+ mRunningTimerText+"\n"), &dia ); 476 QLabel lab (("Really stop the timer?\n\n"+ mRunningTimerText+"\n"), &dia );
477 lab.setAlignment( AlignCenter ); 477 lab.setAlignment( AlignCenter );
478 dia.setCaption(("KO/Pi Timer Stop" )); 478 dia.setCaption(("KO/Pi Timer Stop" ));
479 QVBoxLayout lay( &dia ); 479 QVBoxLayout lay( &dia );
480 lay.addWidget( &lab); 480 lay.addWidget( &lab);
481 QPushButton ok ( "Stop timer!", &dia); 481 QPushButton ok ( "Stop timer!", &dia);
482 QFont fo = dia.font(); 482 QFont fo = dia.font();
483 fo.setPointSize( 36 ); 483 fo.setPointSize( 36 );
484 ok.setFont( fo ); 484 ok.setFont( fo );
485 lay.addWidget( &ok); 485 lay.addWidget( &ok);
486 connect ( &ok, SIGNAL (clicked()), &dia, SLOT ( accept() ) ); 486 connect ( &ok, SIGNAL (clicked()), &dia, SLOT ( accept() ) );
487 QPushButton con ( "Continue timer!", &dia); 487 QPushButton con ( "Continue timer!", &dia);
488 fo.setPointSize( 36 ); 488 fo.setPointSize( 36 );
489 con.setFont( fo ); 489 con.setFont( fo );
490 lay.addWidget( &con); 490 lay.addWidget( &con);
491 connect ( &con, SIGNAL (clicked()), &dia, SLOT ( reject() ) ); 491 connect ( &con, SIGNAL (clicked()), &dia, SLOT ( reject() ) );
492 lay.setMargin(5); 492 lay.setMargin(5);
493 lay.setSpacing(5); 493 lay.setSpacing(5);
494 dia.resize(dia.sizeHint() ); 494 dia.resize(dia.sizeHint() );
495 495
496 if ( !dia.exec() ) 496 if ( !dia.exec() )
497 return; 497 return;
498 498
499 AlarmServer::deleteAlarm ( mRunningTimer,"koalarm" , timerMesssage.latin1() ); 499 AlarmServer::deleteAlarm ( mRunningTimer,"koalarm" , timerMesssage.latin1() );
500 mTimerTime = 0; 500 mTimerTime = 0;
501 return; 501 return;
502 } 502 }
503 if ( mTimerTime ) 503 if ( mTimerTime )
504 return; 504 return;
505 if ( minutes == 1 ) { 505 if ( minutes == 1 ) {
506 return; 506 return;
507 } 507 }
508 QString mess = "timer_alarm"; 508 QString mess = "timer_alarm";
509 mess += ("Timer Alarm!\n"); 509 mess += ("Timer Alarm!\n");
510 if ( minutes == 22 ) { 510 if ( minutes == 22 ) {
511 mess += ( "Pizza is ready"); 511 mess += ( "Pizza is ready");
512 mRunningTimerText = "Pizza"; 512 mRunningTimerText = "Pizza";
513 } 513 }
514 else if ( minutes == 45 ) { 514 else if ( minutes == 45 ) {
515 mess += ( "Please wake up!"); 515 mess += ( "Please wake up!");
516 mRunningTimerText = "Nap"; 516 mRunningTimerText = "Nap";
517 } 517 }
518 else if ( minutes == 5 ) { 518 else if ( minutes == 5 ) {
519 mess += ( "Tea is ready"); 519 mess += ( "Tea is ready");
520 mRunningTimerText = "Tea"; 520 mRunningTimerText = "Tea";
521 } 521 }
522 else if ( minutes == 3 ) { 522 else if ( minutes == 3 ) {
523 mess += mCustomText; 523 mess += mCustomText;
524 minutes = mCustomMinutes ; 524 minutes = mCustomMinutes ;
525 mRunningTimerText = mCustomText.stripWhiteSpace (); 525 mRunningTimerText = mCustomText.stripWhiteSpace ();
526 int in = mRunningTimerText.find( " " ); 526 int in = mRunningTimerText.find( " " );
527 mRunningTimerText = mRunningTimerText.left ( in ); 527 mRunningTimerText = mRunningTimerText.left ( in );
528 } 528 }
529 else { 529 else {
530 if ( minutes == 2 ) { 530 if ( minutes == 2 ) {
531 // ask time 531 // ask time
532 QDialog dia ( 0, ("Customize Timer" ), true ); 532 QDialog dia ( 0, ("Customize Timer" ), true );
533 QLabel lab (("Message Text:"), &dia ); 533 QLabel lab (("Message Text:"), &dia );
534 dia.setCaption(("KO/Pi Timer" )); 534 dia.setCaption(("KO/Pi Timer" ));
535 QVBoxLayout lay( &dia ); 535 QVBoxLayout lay( &dia );
536 lay.setMargin(5); 536 lay.setMargin(5);
537 lay.setSpacing(5); 537 lay.setSpacing(5);
538 lay.addWidget( &lab); 538 lay.addWidget( &lab);
539 QLineEdit lEdit( mCustomText, &dia ); 539 QLineEdit lEdit( mCustomText, &dia );
540 lay.addWidget( &lEdit); 540 lay.addWidget( &lEdit);
541 QLabel lab2 (("Countdown time (1 min - 24 h):"), &dia ); 541 QLabel lab2 (("Countdown time (1 min - 24 h):"), &dia );
542 lay.addWidget( &lab2); 542 lay.addWidget( &lab2);
543 QHBox hbox1 ( &dia ); 543 QHBox hbox1 ( &dia );
544 lay.addWidget( &hbox1); 544 lay.addWidget( &hbox1);
545 QLabel lab3 (("Hours"), &hbox1 ); 545 QLabel lab3 (("Hours"), &hbox1 );
546 QLabel lab4 (("Minutes"), &hbox1 ); 546 QLabel lab4 (("Minutes"), &hbox1 );
547 QHBox hbox ( &dia ); 547 QHBox hbox ( &dia );
548 QSpinBox spinh( 0, 24, 1,& hbox ); 548 QSpinBox spinh( 0, 24, 1,& hbox );
549 QFont fo = dia.font(); 549 QFont fo = dia.font();
550 fo.setPointSize( 36 ); 550 fo.setPointSize( 36 );
551 QSpinBox spinm( 0, 59, 1,&hbox ); 551 QSpinBox spinm( 0, 59, 1,&hbox );
552 spinm.setFont( fo ); 552 spinm.setFont( fo );
553 spinh.setFont( fo ); 553 spinh.setFont( fo );
554 spinh.setButtonSymbols( QSpinBox::PlusMinus ); 554 spinh.setButtonSymbols( QSpinBox::PlusMinus );
555 spinm.setButtonSymbols( QSpinBox::PlusMinus ); 555 spinm.setButtonSymbols( QSpinBox::PlusMinus );
556 spinh.upButton ()->setFixedSize( QSize( 48, 30 )); 556 spinh.upButton ()->setFixedSize( QSize( 48, 30 ));
557 spinh.downButton ()->setFixedSize( QSize( 48, 30 )); 557 spinh.downButton ()->setFixedSize( QSize( 48, 30 ));
558 //spinh.editor ()->setFixedSize( QSize( 50, 100 )); 558 //spinh.editor ()->setFixedSize( QSize( 50, 100 ));
559 spinh.setFixedSize( 100,62 ); 559 spinh.setFixedSize( 100,62 );
560 spinm.upButton ()->setFixedSize( QSize( 48, 30 )); 560 spinm.upButton ()->setFixedSize( QSize( 48, 30 ));
561 spinm.downButton ()->setFixedSize( QSize( 48, 30 )); 561 spinm.downButton ()->setFixedSize( QSize( 48, 30 ));
562 spinm.downButton ()->setGeometry( 50,50,50,50); 562 spinm.downButton ()->setGeometry( 50,50,50,50);
563 // spinm.setSuffix( " m" ); 563 // spinm.setSuffix( " m" );
564 //spinh.setSuffix( " h" ); 564 //spinh.setSuffix( " h" );
565 spinm.setWrapping ( true ); 565 spinm.setWrapping ( true );
566 //spinm.editor ()->setFixedSize( QSize( 50, 100 )); 566 //spinm.editor ()->setFixedSize( QSize( 50, 100 ));
567 spinm.setLineStep( 1 ); 567 spinm.setLineStep( 1 );
568 spinm.setFixedSize( 110,62 ); 568 spinm.setFixedSize( 110,62 );
569 lay.addWidget( &hbox); 569 lay.addWidget( &hbox);
570 QLabel lab5 ("Timer fires at:", &dia ); 570 QLabel lab5 ("Timer fires at:", &dia );
571 lab5.setAlignment( AlignCenter ); 571 lab5.setAlignment( AlignCenter );
572 lay.addWidget( &lab5); 572 lay.addWidget( &lab5);
573 KODateLabel dl ( &dia ); 573 KODateLabel dl ( &dia );
574 dl.setAlignment( AlignCenter ); 574 dl.setAlignment( AlignCenter );
575 dl.setFont( fo ); 575 dl.setFont( fo );
576 connect ( &spinh, SIGNAL ( valueChanged (int)), &dl, SLOT ( slot_hours( int ) ) ); 576 connect ( &spinh, SIGNAL ( valueChanged (int)), &dl, SLOT ( slot_hours( int ) ) );
577 connect ( &spinm, SIGNAL ( valueChanged (int)), &dl, SLOT ( slot_minutes( int ) ) ); 577 connect ( &spinm, SIGNAL ( valueChanged (int)), &dl, SLOT ( slot_minutes( int ) ) );
578 lay.addWidget( &dl); 578 lay.addWidget( &dl);
579 spinh.setValue( mCustomMinutes/60 ); 579 spinh.setValue( mCustomMinutes/60 );
580 spinm.setValue( mCustomMinutes%60 ); 580 spinm.setValue( mCustomMinutes%60 );
581 QPushButton ok ( "Start timer", &dia); 581 QPushButton ok ( "Start timer", &dia);
582 ok.setDefault( true ); 582 ok.setDefault( true );
583 ok.setFont( fo ); 583 ok.setFont( fo );
584 spinh.setFocus(); 584 spinh.setFocus();
585 lay.addWidget( &ok); 585 lay.addWidget( &ok);
586 connect ( &ok, SIGNAL (clicked()), &dia, SLOT ( accept() ) ); 586 connect ( &ok, SIGNAL (clicked()), &dia, SLOT ( accept() ) );
587 dia.resize( dia.sizeHint().width(), dia.sizeHint().height() ); 587 dia.resize( dia.sizeHint().width(), dia.sizeHint().height() );
588 588
589 if ( !dia.exec() ) 589 if ( !dia.exec() )
590 return; 590 return;
591 mCustomText = lEdit.text(); 591 mCustomText = lEdit.text();
592 mCustomMinutes = spinh.value()*60+spinm.value(); 592 mCustomMinutes = spinh.value()*60+spinm.value();
593 if ( mCustomMinutes == 0 ) 593 if ( mCustomMinutes == 0 )
594 mCustomMinutes = 1; 594 mCustomMinutes = 1;
595 if ( mCustomMinutes > 1440 ) 595 if ( mCustomMinutes > 1440 )
596 mCustomMinutes = 1440; 596 mCustomMinutes = 1440;
597 mess += mCustomText; 597 mess += mCustomText;
598 minutes = mCustomMinutes; 598 minutes = mCustomMinutes;
599 mRunningTimerText = mCustomText.stripWhiteSpace (); 599 mRunningTimerText = mCustomText.stripWhiteSpace ();
600 int in = mRunningTimerText.find( " " ); 600 int in = mRunningTimerText.find( " " );
601 mRunningTimerText = mRunningTimerText.left ( in ); 601 mRunningTimerText = mRunningTimerText.left ( in );
602 } 602 }
603 else { 603 else {
604 mess+= QString::number ( minutes ) + ( " minutes are past!"); 604 mess+= QString::number ( minutes ) + ( " minutes are past!");
605 int min = minutes; 605 int min = minutes;
606 if ( min % 60 == 0 ) 606 if ( min % 60 == 0 )
607 mRunningTimerText = QString::number ( min/60 ) + ( " hours"); 607 mRunningTimerText = QString::number ( min/60 ) + ( " hours");
608 else 608 else
609 mRunningTimerText = QString::number ( minutes ) + ( " minutes"); 609 mRunningTimerText = QString::number ( minutes ) + ( " minutes");
610 } 610 }
611 } 611 }
612 //minutes = 1; 612 //minutes = 1;
613 613
614 mRunningTimer = QDateTime::currentDateTime().addSecs( minutes * 60 ); 614 mRunningTimer = QDateTime::currentDateTime().addSecs( minutes * 60 );
615 timerMesssage = mess; 615 timerMesssage = mess;
616 AlarmServer::addAlarm ( mRunningTimer,"koalarm",timerMesssage.latin1()); 616 AlarmServer::addAlarm ( mRunningTimer,"koalarm",timerMesssage.latin1());
617 mTimerTime = 1; 617 mTimerTime = 1;
618} 618}
619 619
620void SimpleAlarmDaemonImpl::writeFile() 620void SimpleAlarmDaemonImpl::writeFile()
621{ 621{
622 QCopEnvelope e("QPE/Application/kopi", "-writeFile"); 622 QCopEnvelope e("QPE/Application/kopi", "-writeFile");
623} 623}
624void SimpleAlarmDaemonImpl::showWN() 624void SimpleAlarmDaemonImpl::showWN()
625{ 625{
626 QCopEnvelope e("QPE/Application/kopi", "-showWN"); 626 QCopEnvelope e("QPE/Application/kopi", "-showWN");
627} 627}
628void SimpleAlarmDaemonImpl::newTodo() 628void SimpleAlarmDaemonImpl::newTodo()
629{ 629{
630 QCopEnvelope e("QPE/Application/kopi", "-newTodo"); 630 QCopEnvelope e("QPE/Application/kopi", "-newTodo");
631} 631}
632 632
633void SimpleAlarmDaemonImpl::newEvent() 633void SimpleAlarmDaemonImpl::newEvent()
634{ 634{
635 QCopEnvelope e("QPE/Application/kopi", "-newEvent"); 635 QCopEnvelope e("QPE/Application/kopi", "-newEvent");
636 636
637} 637}
638void SimpleAlarmDaemonImpl::newMail() 638void SimpleAlarmDaemonImpl::newMail()
639{ 639{
640 QCopEnvelope e("QPE/Application/ompi", "newMail()"); 640 QCopEnvelope e("QPE/Application/ompi", "newMail()");
641} 641}
642void SimpleAlarmDaemonImpl::showAdd() 642void SimpleAlarmDaemonImpl::showAdd()
643{ 643{
644 QCopEnvelope e("QPE/Application/kapi", "raise()"); 644 QCopEnvelope e("QPE/Application/kapi", "raise()");
645} 645}
646void SimpleAlarmDaemonImpl::ringSync() 646void SimpleAlarmDaemonImpl::ringSync()
647{ 647{
648 QCopEnvelope e("QPE/Application/kopi", "-ringSync"); 648 QCopEnvelope e("QPE/Application/kopi", "-ringSync");
649 649
650} 650}
651void SimpleAlarmDaemonImpl::newCountdown() 651void SimpleAlarmDaemonImpl::newCountdown()
652{ 652{
653 //recieve("cal_alarm", 10 ); 653 //recieve("cal_alarm", 10 );
654} 654}
655void SimpleAlarmDaemonImpl::simulate() 655void SimpleAlarmDaemonImpl::simulate()
656{ 656{
657 writeFile(); 657 writeFile();
658 QString filename = getenv("QPEDIR") ; 658 QString filename = getenv("QPEDIR") ;
659 filename += "/pics/kdepim/korganizer/koalarm.wav"; 659 filename += "/pics/kdepim/korganizer/koalarm.wav";
660 startAlarm("Alarm simulation", filename ); 660 startAlarm("Alarm simulation", filename );
661} 661}
662void SimpleAlarmDaemonImpl::showKO() 662void SimpleAlarmDaemonImpl::showKO()
663{ 663{
664 QCopEnvelope e("QPE/Application/kopi", "-showKO"); 664 QCopEnvelope e("QPE/Application/kopi", "-showKO");
665 // testing only 665 // testing only
666 //QCopEnvelope e("QPE/Application/kopi", "nextView()"); 666 //QCopEnvelope e("QPE/Application/kopi", "nextView()");
667 667
668} 668}
669void SimpleAlarmDaemonImpl::showTodo() 669void SimpleAlarmDaemonImpl::showTodo()
670{ 670{
671 QCopEnvelope e("QPE/Application/kopi", "-showTodo"); 671 QCopEnvelope e("QPE/Application/kopi", "-showTodo");
672 672
673} 673}
674void SimpleAlarmDaemonImpl::writeJournal() 674void SimpleAlarmDaemonImpl::writeJournal()
675{ 675{
676 QCopEnvelope e("QPE/Application/kopi", "-showJournal"); 676 QCopEnvelope e("QPE/Application/kopi", "-showJournal");
677 677
678} 678}
679 679
680void SimpleAlarmDaemonImpl::mousePressEvent( QMouseEvent * ) 680void SimpleAlarmDaemonImpl::mousePressEvent( QMouseEvent * )
681{ 681{
682 682
683 mPopUp->popup(mapToGlobal(QPoint (0, -mPopUp->height() ))); 683 mPopUp->popup(mapToGlobal(QPoint (0, -mPopUp->height() )));
684 684
685} 685}
686 686
diff --git a/korganizer/koagendaitem.cpp b/korganizer/koagendaitem.cpp
index 23afe7a..e545ca8 100644
--- a/korganizer/koagendaitem.cpp
+++ b/korganizer/koagendaitem.cpp
@@ -1,808 +1,816 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18*/ 18*/
19 19
20#include <qlabel.h> 20#include <qlabel.h>
21#include <qlayout.h> 21#include <qlayout.h>
22#include <qhbox.h> 22#include <qhbox.h>
23#include <qvbox.h> 23#include <qvbox.h>
24#include <qtooltip.h> 24#include <qtooltip.h>
25#include <qwhatsthis.h> 25#include <qwhatsthis.h>
26#include <qdragobject.h> 26#include <qdragobject.h>
27#include <qdrawutil.h> 27#include <qdrawutil.h>
28#include <qpainter.h> 28#include <qpainter.h>
29 29
30#include <kiconloader.h> 30#include <kiconloader.h>
31#include <kdebug.h> 31#include <kdebug.h>
32#include <kglobal.h> 32#include <kglobal.h>
33#include <klocale.h> 33#include <klocale.h>
34#ifndef DESKTOP_VERSION 34#ifndef DESKTOP_VERSION
35#include <qpe/qpeapplication.h> 35#include <qpe/qpeapplication.h>
36#define AGENDA_ICON_SIZE 5 36#define AGENDA_ICON_SIZE 5
37#else 37#else
38#define AGENDA_ICON_SIZE 7 38#define AGENDA_ICON_SIZE 7
39#endif 39#endif
40#include <libkcal/icaldrag.h> 40#include <libkcal/icaldrag.h>
41#include <libkcal/vcaldrag.h> 41#include <libkcal/vcaldrag.h>
42#include <libkcal/kincidenceformatter.h> 42#include <libkcal/kincidenceformatter.h>
43extern int globalFlagBlockAgenda; 43extern int globalFlagBlockAgenda;
44extern int globalFlagBlockAgendaItemPaint; 44extern int globalFlagBlockAgendaItemPaint;
45extern int globalFlagBlockAgendaItemUpdate; 45extern int globalFlagBlockAgendaItemUpdate;
46 46
47#include "koprefs.h" 47#include "koprefs.h"
48 48
49#include "koagendaitem.h" 49#include "koagendaitem.h"
50//#include "koagendaitem.moc" 50//#include "koagendaitem.moc"
51 51
52 52
53//-------------------------------------------------------------------------- 53//--------------------------------------------------------------------------
54 54
55QToolTipGroup *KOAgendaItem::mToolTipGroup = 0; 55QToolTipGroup *KOAgendaItem::mToolTipGroup = 0;
56 56
57//-------------------------------------------------------------------------- 57//--------------------------------------------------------------------------
58 58
59class KOAgendaItemWhatsThis :public QWhatsThis 59class KOAgendaItemWhatsThis :public QWhatsThis
60{ 60{
61public: 61public:
62 KOAgendaItemWhatsThis( KOAgendaItem* view ) : QWhatsThis( view ),_view (view) { }; 62 KOAgendaItemWhatsThis( KOAgendaItem* view ) : QWhatsThis( view ),_view (view) { };
63 63
64protected: 64protected:
65 virtual QString text( const QPoint& ) 65 virtual QString text( const QPoint& )
66 { 66 {
67 return _view->getWhatsThisText() ; 67 return _view->getWhatsThisText() ;
68 } 68 }
69private: 69private:
70 KOAgendaItem * _view; 70 KOAgendaItem * _view;
71}; 71};
72 72
73KOAgendaItem::KOAgendaItem(Incidence *incidence, QDate qd, QWidget *parent,bool allday, 73KOAgendaItem::KOAgendaItem(Incidence *incidence, QDate qd, QWidget *parent,bool allday,
74 const char *name,WFlags) : 74 const char *name,WFlags) :
75 QWidget(parent, name), mIncidence(incidence), mDate(qd) 75 QWidget(parent, name), mIncidence(incidence), mDate(qd)
76{ 76{
77#ifndef DESKTOP_VERSION 77#ifndef DESKTOP_VERSION
78 //QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold ); 78 //QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold );
79#endif 79#endif
80 mKOAgendaItemWhatsThis = new KOAgendaItemWhatsThis(this); 80 mKOAgendaItemWhatsThis = new KOAgendaItemWhatsThis(this);
81 int wflags = getWFlags() |WRepaintNoErase;// WResizeNoErase 81 int wflags = getWFlags() |WRepaintNoErase;// WResizeNoErase
82 setWFlags ( wflags); 82 setWFlags ( wflags);
83 mAllDay = allday; 83 mAllDay = allday;
84 init ( incidence, qd ); 84 init ( incidence, qd );
85 //setMouseTracking(true); 85 //setMouseTracking(true);
86 //setAcceptDrops(true); 86 //setAcceptDrops(true);
87 xPaintCoord = -1; 87 xPaintCoord = -1;
88 yPaintCoord = -1; 88 yPaintCoord = -1;
89} 89}
90QString KOAgendaItem::getWhatsThisText() 90QString KOAgendaItem::getWhatsThisText()
91{ 91{
92 if ( mIncidence ) 92 if ( mIncidence )
93 return KIncidenceFormatter::instance()->getFormattedText( mIncidence, 93 return KIncidenceFormatter::instance()->getFormattedText( mIncidence,
94 KOPrefs::instance()->mWTshowDetails, 94 KOPrefs::instance()->mWTshowDetails,
95 KOPrefs::instance()->mWTshowCreated, 95 KOPrefs::instance()->mWTshowCreated,
96 KOPrefs::instance()->mWTshowChanged); 96 KOPrefs::instance()->mWTshowChanged);
97 return "KOAgendaItem::getWhatsThisText()::internal error"; 97 return "KOAgendaItem::getWhatsThisText()::internal error";
98} 98}
99void KOAgendaItem::init ( Incidence *incidence, QDate qd ) 99void KOAgendaItem::init ( Incidence *incidence, QDate qd )
100{ 100{
101 mIncidence = incidence; 101 mIncidence = incidence;
102 mDate = qd; 102 mDate = qd;
103 mFirstMultiItem = 0; 103 mFirstMultiItem = 0;
104 mNextMultiItem = 0; 104 mNextMultiItem = 0;
105 mLastMultiItem = 0; 105 mLastMultiItem = 0;
106 computeText(); 106 computeText();
107 107
108 if ( (incidence->type() == "Todo") && 108 if ( (incidence->type() == "Todo") &&
109 ( !((static_cast<Todo*>(incidence))->isCompleted()) && 109 ( !((static_cast<Todo*>(incidence))->isCompleted()) &&
110 ((static_cast<Todo*>(incidence))->dtDue().date() <= QDate::currentDate()) ) ) { 110 ((static_cast<Todo*>(incidence))->dtDue().date() <= QDate::currentDate()) ) ) {
111 if ( (static_cast<Todo*>(incidence))->dtDue() < QDateTime::currentDateTime().date()) 111 if ( (static_cast<Todo*>(incidence))->dtDue() < QDateTime::currentDateTime().date())
112 mBackgroundColor = KOPrefs::instance()->mTodoOverdueColor ; 112 mBackgroundColor = KOPrefs::instance()->mTodoOverdueColor ;
113 else 113 else
114 mBackgroundColor = KOPrefs::instance()->mTodoDueTodayColor; 114 mBackgroundColor = KOPrefs::instance()->mTodoDueTodayColor;
115 } 115 }
116 else { 116 else {
117 QStringList categories = mIncidence->categories(); 117 QStringList categories = mIncidence->categories();
118 QString cat = categories.first(); 118 QString cat = categories.first();
119 if (cat.isEmpty()) { 119 if (cat.isEmpty()) {
120 if ( (incidence->type() == "Todo") &&((static_cast<Todo*>(incidence))->isCompleted()) ) 120 if ( (incidence->type() == "Todo") &&((static_cast<Todo*>(incidence))->isCompleted()) )
121 mBackgroundColor =KOPrefs::instance()->mTodoDoneColor; 121 mBackgroundColor =KOPrefs::instance()->mTodoDoneColor;
122 else 122 else
123 mBackgroundColor =KOPrefs::instance()->mEventColor; 123 mBackgroundColor =KOPrefs::instance()->mEventColor;
124 } else { 124 } else {
125 mBackgroundColor = *KOPrefs::instance()->categoryColor(cat); 125 mBackgroundColor = *KOPrefs::instance()->categoryColor(cat);
126 if ( (incidence->type() == "Todo") &&((static_cast<Todo*>(incidence))->isCompleted()) ) { 126 if ( (incidence->type() == "Todo") &&((static_cast<Todo*>(incidence))->isCompleted()) ) {
127 if ( mBackgroundColor == KOPrefs::instance()->mEventColor ) 127 if ( mBackgroundColor == KOPrefs::instance()->mEventColor )
128 mBackgroundColor =KOPrefs::instance()->mTodoDoneColor; 128 mBackgroundColor =KOPrefs::instance()->mTodoDoneColor;
129 } 129 }
130 } 130 }
131 131
132 } 132 }
133 mColorGroup = QColorGroup( mBackgroundColor.light(), 133 mColorGroup = QColorGroup( mBackgroundColor.light(),
134 mBackgroundColor.dark(),mBackgroundColor.light(), 134 mBackgroundColor.dark(),mBackgroundColor.light(),
135 mBackgroundColor.dark(),mBackgroundColor, black, mBackgroundColor) ; 135 mBackgroundColor.dark(),mBackgroundColor, black, mBackgroundColor) ;
136 setBackgroundColor( mBackgroundColor ); 136 setBackgroundColor( mBackgroundColor );
137 137
138 mConflictItems.clear(); 138 mConflictItems.clear();
139 setCellXY(0,0,1); 139 setCellXY(0,0,1);
140 setCellXWidth(0); 140 setCellXWidth(0);
141 setSubCell(0); 141 setSubCell(0);
142 setSubCells(1); 142 setSubCells(1);
143 setMultiItem(0,0,0); 143 setMultiItem(0,0,0);
144 startMove(); 144 startMove();
145 mSelected = true; 145 mSelected = true;
146 select(false); 146 select(false);
147 QFontMetrics fontinf(KOPrefs::instance()->mAgendaViewFont); 147 QFontMetrics fontinf(KOPrefs::instance()->mAgendaViewFont);
148 mFontPixelSize = fontinf.height();; 148 mFontPixelSize = fontinf.height();;
149 hide(); 149 hide();
150 xPaintCoord = -1; 150 xPaintCoord = -1;
151 yPaintCoord = -1; 151 yPaintCoord = -1;
152} 152}
153 153
154 154
155KOAgendaItem::~KOAgendaItem() 155KOAgendaItem::~KOAgendaItem()
156{ 156{
157 // qDebug("deleteKOAgendaItem::~KOAgendaItem( "); 157 // qDebug("deleteKOAgendaItem::~KOAgendaItem( ");
158 // delete mKOAgendaItemWhatsThis; 158 // delete mKOAgendaItemWhatsThis;
159} 159}
160 160
161void KOAgendaItem::recreateIncidence() 161void KOAgendaItem::recreateIncidence()
162{ 162{
163#if 0 163#if 0
164 Incidence* newInc = mIncidence->clone(); 164 Incidence* newInc = mIncidence->clone();
165 newInc->recreate(); 165 newInc->recreate();
166 if ( mIncidence->doesRecur() ) { 166 if ( mIncidence->doesRecur() ) {
167 mIncidence->addExDate( mDate ); 167 mIncidence->addExDate( mDate );
168 newInc->recurrence()->unsetRecurs(); 168 newInc->recurrence()->unsetRecurs();
169 int len = mIncidence->dtStart().secsTo( ((Event*)mIncidence)->dtEnd()); 169 int len = mIncidence->dtStart().secsTo( ((Event*)mIncidence)->dtEnd());
170 QTime tim = mIncidence->dtStart().time(); 170 QTime tim = mIncidence->dtStart().time();
171 newInc->setDtStart( QDateTime(mDate, tim) ); 171 newInc->setDtStart( QDateTime(mDate, tim) );
172 ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) ); 172 ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) );
173 } 173 }
174#endif 174#endif
175 mIncidence = mIncidence->recreateCloneException( mDate ); 175 mIncidence = mIncidence->recreateCloneException( mDate );
176} 176}
177bool KOAgendaItem::updateIcons(QPainter * p, bool horLayout) 177bool KOAgendaItem::updateIcons(QPainter * p, bool horLayout)
178{ 178{
179 int size = AGENDA_ICON_SIZE; 179 int size = AGENDA_ICON_SIZE;
180 180
181 int yOff = 0; 181 int yOff = 0;
182 int xOff = 0; 182 int xOff = 0;
183 int x = pos().x() +3; 183 int x = pos().x() +3;
184 int y; 184 int y;
185 if ( mAllDay ) 185 if ( mAllDay )
186 y = pos().y()+3; 186 y = pos().y()+3;
187 else 187 else
188 y = mCellYTop * ( height() / cellHeight() ) +3; 188 y = mCellYTop * ( height() / cellHeight() ) +3;
189 if (mIncidence->cancelled()) { 189 if (mIncidence->cancelled()) {
190 int xpos = xOff*( 1 +AGENDA_ICON_SIZE )+x; 190 int xpos = xOff*( 1 +AGENDA_ICON_SIZE )+x;
191 int ypos = yOff*( 1 +AGENDA_ICON_SIZE)+y; 191 int ypos = yOff*( 1 +AGENDA_ICON_SIZE)+y;
192 p->drawLine( xpos, ypos, xpos+AGENDA_ICON_SIZE-1, ypos+AGENDA_ICON_SIZE-1 ); 192 p->drawLine( xpos, ypos, xpos+AGENDA_ICON_SIZE-1, ypos+AGENDA_ICON_SIZE-1 );
193 p->drawLine( xpos, ypos+AGENDA_ICON_SIZE-1, xpos+AGENDA_ICON_SIZE-1, ypos ); 193 p->drawLine( xpos, ypos+AGENDA_ICON_SIZE-1, xpos+AGENDA_ICON_SIZE-1, ypos );
194 if ( horLayout ) 194 if ( horLayout )
195 ++xOff; 195 ++xOff;
196 else 196 else
197 ++yOff; 197 ++yOff;
198 } 198 }
199 if (mIncidence->isAlarmEnabled()) { 199 if (mIncidence->isAlarmEnabled()) {
200 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, red ); 200 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, red );
201 if ( horLayout ) 201 if ( horLayout )
202 ++xOff; 202 ++xOff;
203 else 203 else
204 ++yOff; 204 ++yOff;
205 } 205 }
206 if (mIncidence->recurrence()->doesRecur()) { 206 if (mIncidence->recurrence()->doesRecur()) {
207 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, blue ); 207 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, blue );
208 if ( horLayout ) 208 if ( horLayout )
209 ++xOff; 209 ++xOff;
210 else 210 else
211 ++yOff; 211 ++yOff;
212 } 212 }
213 if (mIncidence->description().length() > 0) { 213 if (mIncidence->description().length() > 0) {
214 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkGreen ); 214 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkGreen );
215 if ( horLayout ) 215 if ( horLayout )
216 ++xOff; 216 ++xOff;
217 else 217 else
218 ++yOff; 218 ++yOff;
219 } 219 }
220 if (mIncidence->isReadOnly()) { 220 if (mIncidence->isReadOnly()) {
221 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, white ); 221 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, white );
222 if ( horLayout ) 222 if ( horLayout )
223 ++xOff; 223 ++xOff;
224 else 224 else
225 ++yOff; 225 ++yOff;
226 } 226 }
227 227
228 if (mIncidence->attendeeCount()>0) { 228 if (mIncidence->attendeeCount()>0) {
229 229
230 if (mIncidence->organizer() == KOPrefs::instance()->email()) { 230 if (mIncidence->organizer() == KOPrefs::instance()->email()) {
231 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, black ); 231 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, black );
232 if ( horLayout ) 232 if ( horLayout )
233 ++xOff; 233 ++xOff;
234 else 234 else
235 ++yOff; 235 ++yOff;
236 } else { 236 } else {
237 Attendee *me = mIncidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); 237 Attendee *me = mIncidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email());
238 if (me!=0) { 238 if (me!=0) {
239 239
240 240
241 } else { 241 } else {
242 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, yellow ); 242 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, yellow );
243 if ( horLayout ) 243 if ( horLayout )
244 ++xOff; 244 ++xOff;
245 else 245 else
246 ++yOff; 246 ++yOff;
247 247
248 } 248 }
249 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkYellow ); 249 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkYellow );
250 if ( horLayout ) 250 if ( horLayout )
251 ++xOff; 251 ++xOff;
252 else 252 else
253 ++yOff; 253 ++yOff;
254 254
255 } 255 }
256 256
257 } 257 }
258 return ( yOff || xOff ); 258 return ( yOff || xOff );
259} 259}
260 260
261 261
262void KOAgendaItem::select(bool selected) 262void KOAgendaItem::select(bool selected)
263{ 263{
264 //qDebug("select %d %d",firstMultiItem(), nextMultiItem() ); 264 //qDebug("select %d %d",firstMultiItem(), nextMultiItem() );
265 if (mSelected == selected) return; 265 if (mSelected == selected) return;
266 mSelected = selected; 266 mSelected = selected;
267 if ( ! isVisible() ) 267 if ( ! isVisible() )
268 return; 268 return;
269 if ( firstMultiItem() ) 269 if ( firstMultiItem() )
270 firstMultiItem()->select( selected ); 270 firstMultiItem()->select( selected );
271 if ( !firstMultiItem() && nextMultiItem() ) { 271 if ( !firstMultiItem() && nextMultiItem() ) {
272 KOAgendaItem * placeItem = nextMultiItem(); 272 KOAgendaItem * placeItem = nextMultiItem();
273 while ( placeItem ) { 273 while ( placeItem ) {
274 placeItem->select( selected ); 274 placeItem->select( selected );
275 placeItem = placeItem->nextMultiItem(); 275 placeItem = placeItem->nextMultiItem();
276 } 276 }
277 } 277 }
278 globalFlagBlockAgendaItemUpdate = 0; 278 globalFlagBlockAgendaItemUpdate = 0;
279 paintMe( selected ); 279 paintMe( selected );
280 globalFlagBlockAgendaItemUpdate = 1; 280 globalFlagBlockAgendaItemUpdate = 1;
281 repaint( false ); 281 repaint( false );
282} 282}
283 283
284 284
285/* 285/*
286 The eventFilter has to filter the mouse events of the agenda item childs. The 286 The eventFilter has to filter the mouse events of the agenda item childs. The
287 events are fed into the event handling method of KOAgendaItem. This allows the 287 events are fed into the event handling method of KOAgendaItem. This allows the
288 KOAgenda to handle the KOAgendaItems by using an eventFilter. 288 KOAgenda to handle the KOAgendaItems by using an eventFilter.
289*/ 289*/
290bool KOAgendaItem::eventFilter ( QObject *object, QEvent *e ) 290bool KOAgendaItem::eventFilter ( QObject *object, QEvent *e )
291{ 291{
292 if (e->type() == QEvent::MouseButtonPress || 292 if (e->type() == QEvent::MouseButtonPress ||
293 e->type() == QEvent::MouseButtonDblClick || 293 e->type() == QEvent::MouseButtonDblClick ||
294 e->type() == QEvent::MouseButtonRelease || 294 e->type() == QEvent::MouseButtonRelease ||
295 e->type() == QEvent::MouseMove) { 295 e->type() == QEvent::MouseMove) {
296 QMouseEvent *me = (QMouseEvent *)e; 296 QMouseEvent *me = (QMouseEvent *)e;
297 QPoint itemPos = this->mapFromGlobal(((QWidget *)object)-> 297 QPoint itemPos = this->mapFromGlobal(((QWidget *)object)->
298 mapToGlobal(me->pos())); 298 mapToGlobal(me->pos()));
299 QMouseEvent returnEvent (e->type(),itemPos,me->button(),me->state()); 299 QMouseEvent returnEvent (e->type(),itemPos,me->button(),me->state());
300 return event(&returnEvent); 300 return event(&returnEvent);
301 } else { 301 } else {
302 return false; 302 return false;
303 } 303 }
304} 304}
305void KOAgendaItem::repaintMe( ) 305void KOAgendaItem::repaintMe( )
306{ 306{
307 paintMe ( mSelected ); 307 paintMe ( mSelected );
308} 308}
309void KOAgendaItem::paintMe( bool selected, QPainter* paint ) 309void KOAgendaItem::paintMe( bool selected, QPainter* paint )
310{ 310{
311 if ( globalFlagBlockAgendaItemUpdate && ! selected) 311 if ( globalFlagBlockAgendaItemUpdate && ! selected)
312 return; 312 return;
313 QPainter pa; 313 QPainter pa;
314 314
315 if ( mSelected ) { 315 if ( mSelected ) {
316 pa.begin( paintPixSel() ); 316 pa.begin( paintPixSel() );
317 } else { 317 } else {
318 if ( mAllDay ) 318 if ( mAllDay )
319 pa.begin( paintPixAllday() ); 319 pa.begin( paintPixAllday() );
320 else 320 else
321 pa.begin( paintPix() ); 321 pa.begin( paintPix() );
322 } 322 }
323 int x, yy, w, h; 323 int x, yy, w, h;
324 float nfh = 7.0; 324 float nfh = 7.0;
325 x = pos().x(); w = width(); h = height (); 325 x = pos().x(); w = width(); h = height ();
326 if ( mAllDay ) 326 if ( mAllDay )
327 yy = y(); 327 yy = y();
328 else 328 else
329 yy = mCellYTop * ( height() / cellHeight() ); 329 yy = mCellYTop * ( height() / cellHeight() );
330 xPaintCoord= x; 330 xPaintCoord= x;
331 yPaintCoord = yy; 331 yPaintCoord = yy;
332 wPaintCoord = width(); 332 wPaintCoord = width();
333 hPaintCoord = height(); 333 hPaintCoord = height();
334 //qDebug("paintMe %s %d %d %d %d",incidence()->summary().latin1(), x, yy, width(), height()); 334 //qDebug("paintMe %s %d %d %d %d",incidence()->summary().latin1(), x, yy, width(), height());
335 if ( paint == 0 ) 335 if ( paint == 0 )
336 paint = &pa; 336 paint = &pa;
337 bool horLayout = ( w < h ); 337 bool horLayout = ( w < h );
338 int maxhei = mFontPixelSize+4; 338 int maxhei = mFontPixelSize+4;
339 if ( horLayout ) 339 if ( horLayout )
340 maxhei += AGENDA_ICON_SIZE -4; 340 maxhei += AGENDA_ICON_SIZE -4;
341 bool small = ( h < maxhei ); 341 bool small = ( h < maxhei );
342 if ( ! small ) 342 if ( ! small )
343 paint->setFont(KOPrefs::instance()->mAgendaViewFont); 343 paint->setFont(KOPrefs::instance()->mAgendaViewFont);
344 else { 344 else {
345 QFont f = KOPrefs::instance()->mAgendaViewFont; 345 QFont f = KOPrefs::instance()->mAgendaViewFont;
346 f.setBold( false ); 346 f.setBold( false );
347 int fh = f.pointSize(); 347 int fh = f.pointSize();
348 nfh = (((float)height())/(float)(mFontPixelSize+4))*fh; 348 nfh = (((float)height())/(float)(mFontPixelSize+4))*fh;
349 if ( nfh < 6 ) 349 if ( nfh < 6 )
350 nfh = 6; 350 nfh = 6;
351 f.setPointSize( nfh ); 351 f.setPointSize( nfh );
352 paint->setFont(f); 352 paint->setFont(f);
353 } 353 }
354 paint->fillRect ( x, yy, w, h, mBackgroundColor ); 354 paint->fillRect ( x, yy, w, h, mBackgroundColor );
355 static const QPixmap completedPxmp = SmallIcon("greenhook16"); 355 static const QPixmap completedPxmp = SmallIcon("greenhook16");
356 static const QPixmap overduePxmp = SmallIcon("redcross16"); 356 static const QPixmap overduePxmp = SmallIcon("redcross16");
357 if ( mIncidence->type() == "Todo" ) { 357 if ( mIncidence->type() == "Todo" ) {
358 Todo* tempTodo = static_cast<Todo*>(mIncidence); 358 Todo* tempTodo = static_cast<Todo*>(mIncidence);
359 int xx = pos().x()+(width()-completedPxmp.width()-3 ); 359 int xx = pos().x()+(width()-completedPxmp.width()-3 );
360 int yyy = yy+3; 360 int yyy = yy+3;
361 if ( tempTodo->isCompleted() ) 361 if ( tempTodo->isCompleted() )
362 paint->drawPixmap ( xx, yyy, completedPxmp ); 362 paint->drawPixmap ( xx, yyy, completedPxmp );
363 else { 363 else {
364 paint->drawPixmap ( xx, yyy, overduePxmp ); 364 paint->drawPixmap ( xx, yyy, overduePxmp );
365 365
366 } 366 }
367 } 367 }
368 bool addIcon = false; 368 bool addIcon = false;
369 if ( ! small || w > 3 * h || h > 3* w ) 369 if ( ! small || w > 3 * h || h > 3* w )
370 addIcon = updateIcons( paint, horLayout ); 370 addIcon = updateIcons( paint, horLayout );
371 371
372 qDrawShadePanel (paint, x, yy, w, h, mColorGroup, selected , 2, 0); 372 qDrawShadePanel (paint, x, yy, w, h, mColorGroup, selected , 2, 0);
373 //qDebug("draw rect %d %d %d %d ",x, yy, w, h ); 373 //qDebug("draw rect %d %d %d %d ",x, yy, w, h );
374 if ( ! small ) { 374 if ( ! small ) {
375 x += 3; yy += 3;w -= 6; h-= 5; 375 x += 3; yy += 3;w -= 6; h-= 5;
376 } else { 376 } else {
377 x += 2; yy += 1;w -= 4; h-= 4; 377 x += 2; yy += 1;w -= 4; h-= 4;
378 if ( nfh < 6.01 ) { 378 if ( nfh < 6.01 ) {
379 yy -= 2; 379 yy -= 2;
380 h += 4; 380 h += 4;
381 } 381 }
382 else 382 else
383 if ( nfh < h -2 ) 383 if ( nfh < h -2 )
384 ++yy; 384 ++yy;
385 } 385 }
386 int align; 386 int align;
387#ifndef DESKTOP_VERSION 387#ifndef DESKTOP_VERSION
388 align = ( AlignLeft|WordBreak|AlignTop); 388 align = ( AlignLeft|WordBreak|AlignTop);
389#else 389#else
390 align = ( AlignLeft|BreakAnywhere|WordBreak|AlignTop); 390 align = ( AlignLeft|BreakAnywhere|WordBreak|AlignTop);
391#endif 391#endif
392 if ( addIcon ) { 392 if ( addIcon ) {
393 if ( ! horLayout ) { 393 if ( ! horLayout ) {
394 x += AGENDA_ICON_SIZE+3; 394 x += AGENDA_ICON_SIZE+3;
395 w -= (AGENDA_ICON_SIZE+3); 395 w -= (AGENDA_ICON_SIZE+3);
396 } 396 }
397 else { 397 else {
398 yy+= AGENDA_ICON_SIZE+2; 398 yy+= AGENDA_ICON_SIZE+2;
399 h -=(AGENDA_ICON_SIZE+3); 399 h -=(AGENDA_ICON_SIZE+3);
400 } 400 }
401 } 401 }
402 int colsum = mBackgroundColor.red() + mBackgroundColor.green() + mBackgroundColor.blue(); 402 int colsum = mBackgroundColor.red() + mBackgroundColor.green() + mBackgroundColor.blue();
403 if ( colsum < 250 ) 403 if ( colsum < 250 )
404 paint->setPen ( white); 404 paint->setPen ( white);
405 if ( x < 0 ) { 405 if ( x < 0 ) {
406 w = w+x-3; 406 w = w+x-3;
407 x = 3; 407 x = 3;
408 if ( w > parentWidget()->width() ){ 408 if ( w > parentWidget()->width() ){
409 w = parentWidget()->width() - 6; 409 w = parentWidget()->width() - 6;
410#ifndef DESKTOP_VERSION 410#ifndef DESKTOP_VERSION
411 align = ( AlignHCenter|WordBreak|AlignTop); 411 align = ( AlignHCenter|WordBreak|AlignTop);
412#else 412#else
413 align = ( AlignHCenter|BreakAnywhere|WordBreak|AlignTop); 413 align = ( AlignHCenter|BreakAnywhere|WordBreak|AlignTop);
414#endif 414#endif
415 415
416 } 416 }
417 } 417 }
418 QRect dr; 418 QRect dr;
419 if ( w + x > parentWidget()->width() ) 419 if ( w + x > parentWidget()->width() )
420 w = parentWidget()->width()-x; 420 w = parentWidget()->width()-x;
421 paint->drawText ( x, yy, w, h, align, mDisplayedText, -1, &dr ); 421 paint->drawText ( x, yy, w, h, align, mDisplayedText, -1, &dr );
422 //qDebug("%d %d %d %d ", x, yy, w, h ); 422 //qDebug("%d %d %d %d ", x, yy, w, h );
423 if ( mIncidence->cancelled() ){ 423 if ( mIncidence->cancelled() ){
424 424
425 425
426 small = ( height() < 20 ); 426 small = ( height() < 20 );
427 427
428 if ( ! small ) { 428 if ( ! small ) {
429 QFontMetrics fm ( paint->font() ); 429 QFontMetrics fm ( paint->font() );
430 paint->drawLine(dr.left(), yy+fm.height()/2, dr.right()-2, yy+fm.height()/2); 430 paint->drawLine(dr.left(), yy+fm.height()/2, dr.right()-2, yy+fm.height()/2);
431 } 431 }
432 432
433 } 433 }
434 pa.end(); 434 pa.end();
435 435
436} 436}
437void KOAgendaItem::resizePixmap( int w , int h ) 437void KOAgendaItem::resizePixmap( int w , int h )
438{ 438{
439 paintPix()->resize( w, h ); 439 paintPix()->resize( w, h );
440 paintPixSel()->resize( w, h ); 440 paintPixSel()->resize( w, h );
441 441
442} 442}
443QPixmap * KOAgendaItem::paintPix() 443QPixmap * KOAgendaItem::paintPix()
444{ 444{
445 static QPixmap* mPaintPix = 0; 445 static QPixmap* mPaintPix = 0;
446 if ( ! mPaintPix ) 446 if ( ! mPaintPix ) {
447 mPaintPix = new QPixmap(1,1); 447 int w = QApplication::desktop()->width();
448 int h = QApplication::desktop()->height();
449 mPaintPix = new QPixmap(w,h);
450 }
448 return mPaintPix ; 451 return mPaintPix ;
449} 452}
450QPixmap * KOAgendaItem::paintPixAllday() 453QPixmap * KOAgendaItem::paintPixAllday()
451{ 454{
452 static QPixmap* mPaintPixA = 0; 455 static QPixmap* mPaintPixA = 0;
453 if ( ! mPaintPixA ) 456 if ( ! mPaintPixA ) {
454 mPaintPixA = new QPixmap(1,1); 457 int w = QApplication::desktop()->width();
458 int h = QApplication::desktop()->height()/3;
459 mPaintPixA = new QPixmap(w,h);
460 }
455 return mPaintPixA ; 461 return mPaintPixA ;
456} 462}
457QPixmap * KOAgendaItem::paintPixSel() 463QPixmap * KOAgendaItem::paintPixSel()
458{ 464{
459 static QPixmap* mPaintPixSel = 0; 465 static QPixmap* mPaintPixSel = 0;
460 if ( ! mPaintPixSel ) 466 if ( ! mPaintPixSel ) {
461 mPaintPixSel = new QPixmap(1,1); 467 int w = QApplication::desktop()->width();
468 int h = QApplication::desktop()->height();
469 mPaintPixSel = new QPixmap(w,h);
470 }
462 return mPaintPixSel ; 471 return mPaintPixSel ;
463} 472}
464void KOAgendaItem::paintEvent ( QPaintEvent *e ) 473void KOAgendaItem::paintEvent ( QPaintEvent *e )
465{ 474{
466 475
467 if ( globalFlagBlockAgendaItemPaint ) 476 if ( globalFlagBlockAgendaItemPaint )
468 return; 477 return;
469 if ( globalFlagBlockAgenda > 0 && globalFlagBlockAgenda < 5 ) 478 if ( globalFlagBlockAgenda > 0 && globalFlagBlockAgenda < 5 )
470 return; 479 return;
471 int yy; 480 int yy;
472 if ( mAllDay ) 481 if ( mAllDay )
473 yy = y(); 482 yy = y();
474 else 483 else
475 yy = mCellYTop * ( height() / cellHeight() ); 484 yy = mCellYTop * ( height() / cellHeight() );
476 int xx = x(); 485 int xx = x();
477 486
478 if ( xPaintCoord != xx || yPaintCoord != yy || 487 if ( xPaintCoord != xx || yPaintCoord != yy ||
479 wPaintCoord != width() || hPaintCoord != height()) { 488 wPaintCoord != width() || hPaintCoord != height()) {
480 xPaintCoord= xx; 489 xPaintCoord= xx;
481 yPaintCoord = yy; 490 yPaintCoord = yy;
482 wPaintCoord = width(); 491 wPaintCoord = width();
483 hPaintCoord = height(); 492 hPaintCoord = height();
484 globalFlagBlockAgendaItemUpdate = 0; 493 globalFlagBlockAgendaItemUpdate = 0;
485 paintMe( mSelected ); 494 paintMe( mSelected );
486 //qDebug("calling paintMe "); 495 //qDebug("calling paintMe ");
487 globalFlagBlockAgendaItemUpdate = 1; 496 globalFlagBlockAgendaItemUpdate = 1;
488 } 497 }
489 int rx, ry, rw, rh; 498 int rx, ry, rw, rh;
490 rx = e->rect().x(); 499 rx = e->rect().x();
491 ry = e->rect().y(); 500 ry = e->rect().y();
492 rw = e->rect().width(); 501 rw = e->rect().width();
493 rh = e->rect().height(); 502 rh = e->rect().height();
494 //qDebug(" paintevent %s %d %d %d %d", mIncidence->summary().latin1(), x(), yy, width(), height()); 503 //qDebug(" paintevent %s %d %d %d %d", mIncidence->summary().latin1(), x(), yy, width(), height());
495 504
496 QPixmap* paintFrom ; 505 QPixmap* paintFrom ;
497 if ( mSelected ) { 506 if ( mSelected ) {
498 paintFrom = paintPixSel(); 507 paintFrom = paintPixSel();
499 } else { 508 } else {
500 if ( mAllDay ) 509 if ( mAllDay )
501 paintFrom = paintPixAllday(); 510 paintFrom = paintPixAllday();
502 else 511 else
503 paintFrom = paintPix(); 512 paintFrom = paintPix();
504 } 513 }
505 xx += rx; 514 xx += rx;
506 515
507 if ( xx < 0 ) { 516 if ( xx < 0 ) {
508 rw = rw + xx; 517 rw = rw + xx;
509 rx -= xx; 518 rx -= xx;
510 xx = 0; 519 xx = 0;
511 if ( rw <= 1 ) { 520 if ( rw <= 1 ) {
512 //qDebug("KOAgendaItem::Width1 <= 1 (%d). Returning. %s",rw,mDisplayedText.latin1()); 521 //qDebug("KOAgendaItem::Width1 <= 1 (%d). Returning. %s",rw,mDisplayedText.latin1());
513 return; 522 return;
514 } 523 }
515 } 524 }
516 if ( paintFrom->width() < xx+rw ) { 525 if ( paintFrom->width() < xx+rw ) {
517 rw = paintFrom->width() - xx; 526 rw = paintFrom->width() - xx;
518 if ( rw <= 1 ) { 527 if ( rw <= 1 ) {
519 //qDebug("KOAgendaItem::Width2 <= 1 (%d). Returning.%s ",rw,mDisplayedText.latin1() ); 528 //qDebug("KOAgendaItem::Width2 <= 1 (%d). Returning.%s ",rw,mDisplayedText.latin1() );
520 return; 529 return;
521 } 530 }
522 } 531 }
523 //qDebug("%d %d %d %d %d %d %d",rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh); 532 //qDebug("%d %d %d %d %d %d %d",rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh);
524 bitBlt (this, rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh ,CopyROP); 533 bitBlt (this, rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh ,CopyROP);
525} 534}
526void KOAgendaItem::computeText() 535void KOAgendaItem::computeText()
527{ 536{
528
529 mDisplayedText = mIncidence->summary(); 537 mDisplayedText = mIncidence->summary();
530 if ( (mIncidence->type() == "Todo") ) { 538 if ( (mIncidence->type() == "Todo") ) {
531 if ( static_cast<Todo*>(mIncidence)->hasDueDate() ) { 539 if ( static_cast<Todo*>(mIncidence)->hasDueDate() ) {
532 if ( static_cast<Todo*>(mIncidence)->dtDue().date() < QDate::currentDate() ) 540 if ( static_cast<Todo*>(mIncidence)->dtDue().date() < QDate::currentDate() )
533 mDisplayedText += i18n(" (") +KGlobal::locale()->formatDate((static_cast<Todo*>(mIncidence))->dtDue().date(), true)+")"; 541 mDisplayedText += i18n(" (") +KGlobal::locale()->formatDate((static_cast<Todo*>(mIncidence))->dtDue().date(), true)+")";
534 else if ( !(mIncidence->doesFloat())) 542 else if ( !(mIncidence->doesFloat()))
535 mDisplayedText += i18n(" (") +KGlobal::locale()->formatTime((static_cast<Todo*>(mIncidence))->dtDue().time())+")"; 543 mDisplayedText += i18n(" (") +KGlobal::locale()->formatTime((static_cast<Todo*>(mIncidence))->dtDue().time())+")";
536 } 544 }
537 } else { 545 } else {
538 if ( !(mIncidence->doesFloat()) && KOPrefs::instance()->mShowTimeInAgenda) 546 if ( !(mIncidence->doesFloat()) && KOPrefs::instance()->mShowTimeInAgenda)
539 mDisplayedText += ": " +KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtStart().time()) + "-" + KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtEnd().time()) ; 547 mDisplayedText += ": " +KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtStart().time()) + " - " + KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtEnd().time()) ;
540 548
541 if ( mAllDay ) { 549 if ( mAllDay ) {
542 if ( mIncidence->dtStart().date().addDays(3) < mIncidence->dtEnd().date() ) { 550 if ( mIncidence->dtStart().date().addDays(3) < mIncidence->dtEnd().date() ) {
543 mDisplayedText += ": " +KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtStart().date(), true) + " - " + KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtEnd().date(), true) ; 551 mDisplayedText += ": " +KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtStart().date(), true) + " - " + KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtEnd().date(), true) ;
544 } 552 }
545 } 553 }
546 554
547 } 555 }
548 556
549 if ( !mIncidence->location().isEmpty() ) { 557 if ( !mIncidence->location().isEmpty() ) {
550 if ( mAllDay ) 558 if ( mAllDay )
551 mDisplayedText += " ("; 559 mDisplayedText += " (";
552 else 560 else
553 mDisplayedText += "\n("; 561 mDisplayedText += "\n(";
554 mDisplayedText += mIncidence->location() +")"; 562 mDisplayedText += mIncidence->location() +")";
555 } 563 }
556 564#ifdef DESKTOP_VERSION
557 QString tipText = mIncidence->summary(); 565 QString tipText = mIncidence->summary();
558 if ( !mIncidence->doesFloat() ) { 566 if ( !mIncidence->doesFloat() ) {
559 if ( mIncidence->type() == "Event" ) { 567 if ( mIncidence->type() == "Event" ) {
560 if ( (static_cast<Event*>(mIncidence))->isMultiDay() ) { 568 if ( (static_cast<Event*>(mIncidence))->isMultiDay() ) {
561 tipText += "\n"+i18n("From: ")+mIncidence->dtStartStr(); 569 tipText += "\n"+i18n("From: ")+mIncidence->dtStartStr();
562 tipText += "\n"+i18n("To: ")+(static_cast<Event*>(mIncidence))->dtEndStr(); 570 tipText += "\n"+i18n("To: ")+(static_cast<Event*>(mIncidence))->dtEndStr();
563 } 571 }
564 else { 572 else {
565 tipText += "\n"+i18n("Time: ")+mIncidence->dtStartTimeStr(); 573 tipText += "\n"+i18n("Time: ")+mIncidence->dtStartTimeStr();
566 tipText += " - "+(static_cast<Event*>(mIncidence))->dtEndTimeStr(); 574 tipText += " - "+(static_cast<Event*>(mIncidence))->dtEndTimeStr();
567 } 575 }
568 } 576 }
569 else if ( mIncidence->type() == "Todo" ) { 577 else if ( mIncidence->type() == "Todo" ) {
570 if (mIncidence->hasStartDate()) 578 if (mIncidence->hasStartDate())
571 tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartStr(); 579 tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartStr();
572 if (((Todo*)mIncidence)->hasDueDate()) 580 if (((Todo*)mIncidence)->hasDueDate())
573 tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueStr(); 581 tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueStr();
574 } 582 }
575 } else if ( mIncidence->type() == "Todo" ) { 583 } else if ( mIncidence->type() == "Todo" ) {
576 if (mIncidence->hasStartDate()) 584 if (mIncidence->hasStartDate())
577 tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartDateStr(); 585 tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartDateStr();
578 if (((Todo*)mIncidence)->hasDueDate()) 586 if (((Todo*)mIncidence)->hasDueDate())
579 tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueDateStr(); 587 tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueDateStr();
580 } 588 }
581 589
582 if (!mIncidence->location().isEmpty()) { 590 if (!mIncidence->location().isEmpty()) {
583 tipText += "\n"+i18n("Location: ")+mIncidence->location(); 591 tipText += "\n"+i18n("Location: ")+mIncidence->location();
584 } 592 }
585 QToolTip::add(this,tipText,toolTipGroup(),""); 593 QToolTip::add(this,tipText,toolTipGroup(),"");
586 594#endif
587} 595}
588void KOAgendaItem::updateItem() 596void KOAgendaItem::updateItem()
589{ 597{
590 computeText(); 598 computeText();
591 599
592 //qDebug("KOAgendaItem:: updateItem() %s %d %d ",incidence()->summary().latin1(), x(), y()); 600 //qDebug("KOAgendaItem:: updateItem() %s %d %d ",incidence()->summary().latin1(), x(), y());
593 paintMe( mSelected ); 601 paintMe( mSelected );
594 repaint( false); 602 repaint( false);
595} 603}
596 604
597void KOAgendaItem::resizeEvent ( QResizeEvent *ev ) 605void KOAgendaItem::resizeEvent ( QResizeEvent *ev )
598{ 606{
599 //qDebug("KOAgendaItem::resizeEvent %s ", mIncidence->summary().latin1()); 607 //qDebug("KOAgendaItem::resizeEvent %s ", mIncidence->summary().latin1());
600 paintMe( mSelected ); 608 paintMe( mSelected );
601 repaint( false ); 609 repaint( false );
602} 610}
603 611
604/* 612/*
605 Return height of item in units of agenda cells 613 Return height of item in units of agenda cells
606*/ 614*/
607int KOAgendaItem::cellHeight() 615int KOAgendaItem::cellHeight()
608{ 616{
609 int ret = mCellYBottom - mCellYTop + 1; 617 int ret = mCellYBottom - mCellYTop + 1;
610 if ( ret <= 0 ) { 618 if ( ret <= 0 ) {
611 ret = 1; 619 ret = 1;
612 mCellYBottom = 0; 620 mCellYBottom = 0;
613 mCellYTop = 0; 621 mCellYTop = 0;
614 } 622 }
615 return ret; 623 return ret;
616} 624}
617 625
618/* 626/*
619 Return height of item in units of agenda cells 627 Return height of item in units of agenda cells
620*/ 628*/
621int KOAgendaItem::cellWidth() 629int KOAgendaItem::cellWidth()
622{ 630{
623 return mCellXWidth - mCellX + 1; 631 return mCellXWidth - mCellX + 1;
624} 632}
625 633
626void KOAgendaItem::setItemDate(QDate qd) 634void KOAgendaItem::setItemDate(QDate qd)
627{ 635{
628 mDate = qd; 636 mDate = qd;
629} 637}
630 638
631void KOAgendaItem::setCellXY(int X, int YTop, int YBottom) 639void KOAgendaItem::setCellXY(int X, int YTop, int YBottom)
632{ 640{
633 mCellX = X; 641 mCellX = X;
634 mCellYTop = YTop; 642 mCellYTop = YTop;
635 mCellYBottom = YBottom; 643 mCellYBottom = YBottom;
636} 644}
637 645
638void KOAgendaItem::setCellXWidth(int xwidth) 646void KOAgendaItem::setCellXWidth(int xwidth)
639{ 647{
640 mCellXWidth = xwidth; 648 mCellXWidth = xwidth;
641} 649}
642 650
643void KOAgendaItem::setCellX(int XLeft, int XRight) 651void KOAgendaItem::setCellX(int XLeft, int XRight)
644{ 652{
645 mCellX = XLeft; 653 mCellX = XLeft;
646 mCellXWidth = XRight; 654 mCellXWidth = XRight;
647} 655}
648 656
649void KOAgendaItem::setCellY(int YTop, int YBottom) 657void KOAgendaItem::setCellY(int YTop, int YBottom)
650{ 658{
651 mCellYTop = YTop; 659 mCellYTop = YTop;
652 mCellYBottom = YBottom; 660 mCellYBottom = YBottom;
653} 661}
654 662
655void KOAgendaItem::setSubCell(int subCell) 663void KOAgendaItem::setSubCell(int subCell)
656{ 664{
657 mSubCell = subCell; 665 mSubCell = subCell;
658} 666}
659 667
660void KOAgendaItem::setSubCells(int subCells) 668void KOAgendaItem::setSubCells(int subCells)
661{ 669{
662 mSubCells = subCells; 670 mSubCells = subCells;
663} 671}
664 672
665void KOAgendaItem::setMultiItem(KOAgendaItem *first,KOAgendaItem *next, 673void KOAgendaItem::setMultiItem(KOAgendaItem *first,KOAgendaItem *next,
666 KOAgendaItem *last) 674 KOAgendaItem *last)
667{ 675{
668 mFirstMultiItem = first; 676 mFirstMultiItem = first;
669 mNextMultiItem = next; 677 mNextMultiItem = next;
670 mLastMultiItem = last; 678 mLastMultiItem = last;
671} 679}
672 680
673void KOAgendaItem::startMove() 681void KOAgendaItem::startMove()
674{ 682{
675 mStartCellX = mCellX; 683 mStartCellX = mCellX;
676 mStartCellXWidth = mCellXWidth; 684 mStartCellXWidth = mCellXWidth;
677 mStartCellYTop = mCellYTop; 685 mStartCellYTop = mCellYTop;
678 mStartCellYBottom = mCellYBottom; 686 mStartCellYBottom = mCellYBottom;
679} 687}
680 688
681void KOAgendaItem::resetMove() 689void KOAgendaItem::resetMove()
682{ 690{
683 mCellX = mStartCellX; 691 mCellX = mStartCellX;
684 mCellXWidth = mStartCellXWidth; 692 mCellXWidth = mStartCellXWidth;
685 mCellYTop = mStartCellYTop; 693 mCellYTop = mStartCellYTop;
686 mCellYBottom = mStartCellYBottom; 694 mCellYBottom = mStartCellYBottom;
687} 695}
688 696
689void KOAgendaItem::moveRelative(int dx, int dy) 697void KOAgendaItem::moveRelative(int dx, int dy)
690{ 698{
691 int newX = cellX() + dx; 699 int newX = cellX() + dx;
692 int newXWidth = cellXWidth() + dx; 700 int newXWidth = cellXWidth() + dx;
693 int newYTop = cellYTop() + dy; 701 int newYTop = cellYTop() + dy;
694 int newYBottom = cellYBottom() + dy; 702 int newYBottom = cellYBottom() + dy;
695 setCellXY(newX,newYTop,newYBottom); 703 setCellXY(newX,newYTop,newYBottom);
696 setCellXWidth(newXWidth); 704 setCellXWidth(newXWidth);
697} 705}
698 706
699void KOAgendaItem::expandTop(int dy) 707void KOAgendaItem::expandTop(int dy)
700{ 708{
701 int newYTop = cellYTop() + dy; 709 int newYTop = cellYTop() + dy;
702 int newYBottom = cellYBottom(); 710 int newYBottom = cellYBottom();
703 if (newYTop > newYBottom) newYTop = newYBottom; 711 if (newYTop > newYBottom) newYTop = newYBottom;
704 setCellY(newYTop, newYBottom); 712 setCellY(newYTop, newYBottom);
705} 713}
706 714
707void KOAgendaItem::expandBottom(int dy) 715void KOAgendaItem::expandBottom(int dy)
708{ 716{
709 int newYTop = cellYTop(); 717 int newYTop = cellYTop();
710 int newYBottom = cellYBottom() + dy; 718 int newYBottom = cellYBottom() + dy;
711 if (newYBottom < newYTop) newYBottom = newYTop; 719 if (newYBottom < newYTop) newYBottom = newYTop;
712 setCellY(newYTop, newYBottom); 720 setCellY(newYTop, newYBottom);
713} 721}
714 722
715void KOAgendaItem::expandLeft(int dx) 723void KOAgendaItem::expandLeft(int dx)
716{ 724{
717 int newX = cellX() + dx; 725 int newX = cellX() + dx;
718 int newXWidth = cellXWidth(); 726 int newXWidth = cellXWidth();
719 if (newX > newXWidth) newX = newXWidth; 727 if (newX > newXWidth) newX = newXWidth;
720 setCellX(newX,newXWidth); 728 setCellX(newX,newXWidth);
721} 729}
722 730
723void KOAgendaItem::expandRight(int dx) 731void KOAgendaItem::expandRight(int dx)
724{ 732{
725 int newX = cellX(); 733 int newX = cellX();
726 int newXWidth = cellXWidth() + dx; 734 int newXWidth = cellXWidth() + dx;
727 if (newXWidth < newX) newXWidth = newX; 735 if (newXWidth < newX) newXWidth = newX;
728 setCellX(newX,newXWidth); 736 setCellX(newX,newXWidth);
729} 737}
730 738
731QToolTipGroup *KOAgendaItem::toolTipGroup() 739QToolTipGroup *KOAgendaItem::toolTipGroup()
732{ 740{
733 if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); 741 if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0);
734 return mToolTipGroup; 742 return mToolTipGroup;
735} 743}
736 744
737void KOAgendaItem::dragEnterEvent( QDragEnterEvent *e ) 745void KOAgendaItem::dragEnterEvent( QDragEnterEvent *e )
738{ 746{
739#ifndef KORG_NODND 747#ifndef KORG_NODND
740 if ( ICalDrag::canDecode( e ) || VCalDrag::canDecode( e ) || 748 if ( ICalDrag::canDecode( e ) || VCalDrag::canDecode( e ) ||
741 !QTextDrag::canDecode( e ) ) { 749 !QTextDrag::canDecode( e ) ) {
742 e->ignore(); 750 e->ignore();
743 return; 751 return;
744 } 752 }
745 e->accept(); 753 e->accept();
746#endif 754#endif
747} 755}
748 756
749void KOAgendaItem::dropEvent( QDropEvent *e ) 757void KOAgendaItem::dropEvent( QDropEvent *e )
750{ 758{
751#ifndef KORG_NODND 759#ifndef KORG_NODND
752 QString text; 760 QString text;
753 if(QTextDrag::decode(e,text)) 761 if(QTextDrag::decode(e,text))
754 { 762 {
755 kdDebug() << "Dropped : " << text << endl; 763 kdDebug() << "Dropped : " << text << endl;
756 QStringList emails = QStringList::split(",",text); 764 QStringList emails = QStringList::split(",",text);
757 for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { 765 for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) {
758 kdDebug() << " Email: " << (*it) << endl; 766 kdDebug() << " Email: " << (*it) << endl;
759 int pos = (*it).find("<"); 767 int pos = (*it).find("<");
760 QString name = (*it).left(pos); 768 QString name = (*it).left(pos);
761 QString email = (*it).mid(pos); 769 QString email = (*it).mid(pos);
762 if (!email.isEmpty()) { 770 if (!email.isEmpty()) {
763 mIncidence->addAttendee(new Attendee(name,email)); 771 mIncidence->addAttendee(new Attendee(name,email));
764 } 772 }
765 } 773 }
766 } 774 }
767#endif 775#endif
768} 776}
769 777
770 778
771QPtrList<KOAgendaItem> KOAgendaItem::conflictItems() 779QPtrList<KOAgendaItem> KOAgendaItem::conflictItems()
772{ 780{
773 return mConflictItems; 781 return mConflictItems;
774} 782}
775 783
776void KOAgendaItem::setConflictItems(QPtrList<KOAgendaItem> ci) 784void KOAgendaItem::setConflictItems(QPtrList<KOAgendaItem> ci)
777{ 785{
778 mConflictItems = ci; 786 mConflictItems = ci;
779 KOAgendaItem *item; 787 KOAgendaItem *item;
780 for ( item=mConflictItems.first(); item != 0; 788 for ( item=mConflictItems.first(); item != 0;
781 item=mConflictItems.next() ) { 789 item=mConflictItems.next() ) {
782 item->addConflictItem(this); 790 item->addConflictItem(this);
783 } 791 }
784} 792}
785 793
786void KOAgendaItem::addConflictItem(KOAgendaItem *ci) 794void KOAgendaItem::addConflictItem(KOAgendaItem *ci)
787{ 795{
788 if (mConflictItems.find(ci)<0) 796 if (mConflictItems.find(ci)<0)
789 mConflictItems.append(ci); 797 mConflictItems.append(ci);
790} 798}
791 799
792bool KOAgendaItem::checkLayout() 800bool KOAgendaItem::checkLayout()
793{ 801{
794 if ( !mConflictItems.count() ) 802 if ( !mConflictItems.count() )
795 return true; 803 return true;
796 int max = 0; 804 int max = 0;
797 KOAgendaItem *item; 805 KOAgendaItem *item;
798 for ( item=mConflictItems.first(); item != 0; 806 for ( item=mConflictItems.first(); item != 0;
799 item=mConflictItems.next() ) { 807 item=mConflictItems.next() ) {
800 if ( item->subCells() > max ) 808 if ( item->subCells() > max )
801 max = item->subCells(); 809 max = item->subCells();
802 } 810 }
803 if ( max > subCells() ) { 811 if ( max > subCells() ) {
804 setSubCells( max ); 812 setSubCells( max );
805 return false; 813 return false;
806 } 814 }
807 return true; 815 return true;
808} 816}
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp
index 4dfb9df..65d6acf 100644
--- a/korganizer/komonthview.cpp
+++ b/korganizer/komonthview.cpp
@@ -1,2002 +1,2015 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18*/ 18*/
19 19
20#include <qpopupmenu.h> 20#include <qpopupmenu.h>
21#include <qfont.h> 21#include <qfont.h>
22#include <qfontmetrics.h> 22#include <qfontmetrics.h>
23#include <qkeycode.h> 23#include <qkeycode.h>
24#include <qhbox.h> 24#include <qhbox.h>
25#include <qvbox.h> 25#include <qvbox.h>
26#include <qwidgetstack.h> 26#include <qwidgetstack.h>
27#include <qpushbutton.h> 27#include <qpushbutton.h>
28#include <qtooltip.h> 28#include <qtooltip.h>
29#include <qpainter.h> 29#include <qpainter.h>
30#include <qtimer.h> 30#include <qtimer.h>
31#include <qwhatsthis.h> 31#include <qwhatsthis.h>
32#ifndef DESKTOP_VERSION 32#ifndef DESKTOP_VERSION
33#include <qpe/qpeapplication.h> 33#include <qpe/qpeapplication.h>
34#else 34#else
35#include <qapplication.h> 35#include <qapplication.h>
36#endif 36#endif
37 37
38#include <kdebug.h> 38#include <kdebug.h>
39#include <klocale.h> 39#include <klocale.h>
40#include <kglobal.h> 40#include <kglobal.h>
41#include <kconfig.h> 41#include <kconfig.h>
42#include <kiconloader.h> 42#include <kiconloader.h>
43 43
44#include <kcalendarsystem.h> 44#include <kcalendarsystem.h>
45 45
46#ifndef KORG_NOPRINTER 46#ifndef KORG_NOPRINTER
47#include "calprinter.h" 47#include "calprinter.h"
48#endif 48#endif
49#include "koprefs.h" 49#include "koprefs.h"
50#ifndef KORG_NOPLUGINS 50#ifndef KORG_NOPLUGINS
51#include "kocore.h" 51#include "kocore.h"
52#endif 52#endif
53#include "koglobals.h" 53#include "koglobals.h"
54#include <libkcal/kincidenceformatter.h> 54#include <libkcal/kincidenceformatter.h>
55 55
56#include "komonthview.h" 56#include "komonthview.h"
57 57
58#define PIXMAP_SIZE 5 58#define PIXMAP_SIZE 5
59#ifdef DESKTOP_VERSION 59#ifdef DESKTOP_VERSION
60QToolTipGroup *MonthViewCell::mToolTipGroup = 0; 60QToolTipGroup *MonthViewCell::mToolTipGroup = 0;
61#endif 61#endif
62class KNOWhatsThis :public QWhatsThis 62class KNOWhatsThis :public QWhatsThis
63{ 63{
64public: 64public:
65 KNOWhatsThis( KNoScrollListBox* sbox ) : QWhatsThis( sbox ), _wid( sbox) { }; 65 KNOWhatsThis( KNoScrollListBox* sbox ) : QWhatsThis( sbox ), _wid( sbox) { };
66 //~KNOWhatsThis( ) {qDebug("~KNOWhatsThis( ) "); }; 66 //~KNOWhatsThis( ) {qDebug("~KNOWhatsThis( ) "); };
67 67
68protected: 68protected:
69 virtual QString text( const QPoint& p) 69 virtual QString text( const QPoint& p)
70 { 70 {
71 return _wid->getWhatsThisText(p) ; 71 return _wid->getWhatsThisText(p) ;
72 }; 72 };
73private: 73private:
74 KNoScrollListBox* _wid; 74 KNoScrollListBox* _wid;
75 75
76}; 76};
77 77
78 78
79KNoScrollListBox::KNoScrollListBox(QWidget *parent,const char *name) 79KNoScrollListBox::KNoScrollListBox(QWidget *parent,const char *name)
80 : QListBox(parent, name, WRepaintNoErase) 80 : QListBox(parent, name, WRepaintNoErase)
81{ 81{
82#ifndef DESKTOP_VERSION 82#ifndef DESKTOP_VERSION
83 QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); 83 QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold );
84#endif 84#endif
85 mWT = new KNOWhatsThis(this); 85 mWT = new KNOWhatsThis(this);
86 resetOnFocusIn = true; 86 resetOnFocusIn = true;
87 setVScrollBarMode(QScrollView::AlwaysOff); 87 setVScrollBarMode(QScrollView::AlwaysOff);
88 setHScrollBarMode(QScrollView::AlwaysOff); 88 setHScrollBarMode(QScrollView::AlwaysOff);
89} 89}
90KNoScrollListBox::~KNoScrollListBox() 90KNoScrollListBox::~KNoScrollListBox()
91{ 91{
92 92
93} 93}
94 94
95 95
96void KNoScrollListBox::focusInEvent ( QFocusEvent * e ) 96void KNoScrollListBox::focusInEvent ( QFocusEvent * e )
97{ 97{
98 QListBox::focusInEvent ( e ); 98 QListBox::focusInEvent ( e );
99 if ( count() ){ 99 if ( count() ){
100 int ci = currentItem(); 100 int ci = currentItem();
101 if ( ci < 0 ) ci = 0; 101 if ( ci < 0 ) ci = 0;
102 102
103 setCurrentItem( ci ); 103 setCurrentItem( ci );
104 setSelected ( ci, true ); 104 setSelected ( ci, true );
105 emit highlighted( item ( ci ) ); 105 emit highlighted( item ( ci ) );
106 106
107 resetOnFocusIn = true; 107 resetOnFocusIn = true;
108 108
109 if ( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) { 109 if ( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) {
110 QListBoxItem *fi = firstItem (); 110 QListBoxItem *fi = firstItem ();
111 if (fi ) { 111 if (fi ) {
112 int ihei = fi->height( this ); 112 int ihei = fi->height( this );
113 int hei = numRows () * ihei; 113 int hei = numRows () * ihei;
114 if ( hei < height() - horizontalScrollBar()->height () ) { 114 if ( hei < height() - horizontalScrollBar()->height () ) {
115 setVScrollBarMode(QScrollView::AlwaysOff); 115 setVScrollBarMode(QScrollView::AlwaysOff);
116 } 116 }
117 else 117 else
118 setVScrollBarMode(QScrollView::Auto); 118 setVScrollBarMode(QScrollView::Auto);
119 if ( ihei *3 > height() ) { 119 if ( ihei *3 > height() ) {
120 setHScrollBarMode(QScrollView::AlwaysOff); 120 setHScrollBarMode(QScrollView::AlwaysOff);
121 } 121 }
122 else { 122 else {
123 setHScrollBarMode(QScrollView::Auto); 123 setHScrollBarMode(QScrollView::Auto);
124 } 124 }
125 } else { 125 } else {
126 setVScrollBarMode(QScrollView::Auto); 126 setVScrollBarMode(QScrollView::Auto);
127 setHScrollBarMode(QScrollView::Auto); 127 setHScrollBarMode(QScrollView::Auto);
128 } 128 }
129 } 129 }
130 } 130 }
131} 131}
132void KNoScrollListBox::focusOutEvent ( QFocusEvent * e ) 132void KNoScrollListBox::focusOutEvent ( QFocusEvent * e )
133{ 133{
134 int i = currentItem (); 134 int i = currentItem ();
135 if ( i >= 0 ) { 135 if ( i >= 0 ) {
136 setSelected ( i, false ); 136 setSelected ( i, false );
137 } 137 }
138 QListBox::focusOutEvent ( e ); 138 QListBox::focusOutEvent ( e );
139 setVScrollBarMode(QScrollView::AlwaysOff); 139 setVScrollBarMode(QScrollView::AlwaysOff);
140 setHScrollBarMode(QScrollView::AlwaysOff); 140 setHScrollBarMode(QScrollView::AlwaysOff);
141} 141}
142 142
143QString KNoScrollListBox::getWhatsThisText(QPoint p) 143QString KNoScrollListBox::getWhatsThisText(QPoint p)
144{ 144{
145 QListBoxItem* item = itemAt ( p ); 145 QListBoxItem* item = itemAt ( p );
146 if ( ! item ) { 146 if ( ! item ) {
147 return i18n("Click in the cell\nto add an event!"); 147 return i18n("Click in the cell\nto add an event!");
148 } 148 }
149 return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence(), 149 return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence(),
150 KOPrefs::instance()->mWTshowDetails, 150 KOPrefs::instance()->mWTshowDetails,
151 KOPrefs::instance()->mWTshowCreated, 151 KOPrefs::instance()->mWTshowCreated,
152 KOPrefs::instance()->mWTshowChanged); 152 KOPrefs::instance()->mWTshowChanged);
153} 153}
154void KNoScrollListBox::keyPressEvent(QKeyEvent *e) 154void KNoScrollListBox::keyPressEvent(QKeyEvent *e)
155{ 155{
156 //qDebug("KNoScrollListBox::keyPressEvent "); 156 //qDebug("KNoScrollListBox::keyPressEvent ");
157 switch(e->key()) { 157 switch(e->key()) {
158 case Key_Right: 158 case Key_Right:
159 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 159 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
160 { 160 {
161 e->ignore(); 161 e->ignore();
162 return; 162 return;
163 } 163 }
164 scrollBy(10,0); 164 scrollBy(10,0);
165 break; 165 break;
166 case Key_Left: 166 case Key_Left:
167 if (e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 167 if (e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
168 { 168 {
169 e->ignore(); 169 e->ignore();
170 return; 170 return;
171 } 171 }
172 scrollBy(-10,0); 172 scrollBy(-10,0);
173 break; 173 break;
174 case Key_Up: 174 case Key_Up:
175 if( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { 175 if( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) {
176 e->ignore(); 176 e->ignore();
177 break; 177 break;
178 } 178 }
179 if ( count() ) { 179 if ( count() ) {
180 if ( currentItem() == 0 ) { 180 if ( currentItem() == 0 ) {
181 emit prevCell(); 181 emit prevCell();
182 } else { 182 } else {
183 setCurrentItem((currentItem()+count()-1)%count()); 183 setCurrentItem((currentItem()+count()-1)%count());
184 if(!itemVisible(currentItem())) { 184 if(!itemVisible(currentItem())) {
185 if((unsigned int) currentItem() == (count()-1)) { 185 if((unsigned int) currentItem() == (count()-1)) {
186 setTopItem(currentItem()-numItemsVisible()+1); 186 setTopItem(currentItem()-numItemsVisible()+1);
187 } else { 187 } else {
188 setTopItem(topItem()-1); 188 setTopItem(topItem()-1);
189 } 189 }
190 } 190 }
191 } 191 }
192 } 192 }
193 break; 193 break;
194 case Key_Down: 194 case Key_Down:
195 if(e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { 195 if(e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) {
196 e->ignore(); 196 e->ignore();
197 break; 197 break;
198 } 198 }
199 if ( count () ) { 199 if ( count () ) {
200 if ( currentItem()+1 == count () ) { 200 if ( currentItem()+1 == count () ) {
201 emit nextCell(); 201 emit nextCell();
202 } else { 202 } else {
203 setCurrentItem((currentItem()+1)%count()); 203 setCurrentItem((currentItem()+1)%count());
204 if(!itemVisible(currentItem())) { 204 if(!itemVisible(currentItem())) {
205 if(currentItem() == 0) { 205 if(currentItem() == 0) {
206 setTopItem(0); 206 setTopItem(0);
207 } else { 207 } else {
208 setTopItem(topItem()+1); 208 setTopItem(topItem()+1);
209 } 209 }
210 } 210 }
211 } 211 }
212 } 212 }
213 break; 213 break;
214 case Key_I: 214 case Key_I:
215 QTimer::singleShot( 1, this, SLOT ( oneDown() ) ); 215 QTimer::singleShot( 1, this, SLOT ( oneDown() ) );
216 e->ignore(); 216 e->ignore();
217 break; 217 break;
218 case Key_Return: 218 case Key_Return:
219 case Key_Enter: 219 case Key_Enter:
220 { 220 {
221 if ( currentItem() >= 0 ) { 221 if ( currentItem() >= 0 ) {
222 emit doubleClicked( item( currentItem() ) ); 222 emit doubleClicked( item( currentItem() ) );
223 e->accept(); 223 e->accept();
224 } else { 224 } else {
225 e->ignore(); 225 e->ignore();
226 } 226 }
227 } 227 }
228 break; 228 break;
229 case Key_Shift: 229 case Key_Shift:
230 emit shiftDown(); 230 emit shiftDown();
231 break; 231 break;
232 default: 232 default:
233 e->ignore(); 233 e->ignore();
234 break; 234 break;
235 } 235 }
236} 236}
237 237
238void KNoScrollListBox::oneDown() 238void KNoScrollListBox::oneDown()
239{ 239{
240 if ( count () ) { 240 if ( count () ) {
241 if ( currentItem()+1 == count () ) { 241 if ( currentItem()+1 == count () ) {
242 emit nextCell(); 242 emit nextCell();
243 } else { 243 } else {
244 resetOnFocusIn = false; 244 resetOnFocusIn = false;
245 setCurrentItem((currentItem()+1)%count()); 245 setCurrentItem((currentItem()+1)%count());
246 if(!itemVisible(currentItem())) { 246 if(!itemVisible(currentItem())) {
247 if(currentItem() == 0) { 247 if(currentItem() == 0) {
248 setTopItem(0); 248 setTopItem(0);
249 } else { 249 } else {
250 setTopItem(topItem()+1); 250 setTopItem(topItem()+1);
251 } 251 }
252 } 252 }
253 } 253 }
254 } 254 }
255} 255}
256void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e) 256void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e)
257{ 257{
258 switch(e->key()) { 258 switch(e->key()) {
259 case Key_Shift: 259 case Key_Shift:
260 emit shiftUp(); 260 emit shiftUp();
261 break; 261 break;
262 default: 262 default:
263 break; 263 break;
264 } 264 }
265} 265}
266 266
267void KNoScrollListBox::mousePressEvent(QMouseEvent *e) 267void KNoScrollListBox::mousePressEvent(QMouseEvent *e)
268{ 268{
269 QListBox::mousePressEvent(e); 269 QListBox::mousePressEvent(e);
270 270
271 if(e->button() == RightButton) { 271 if(e->button() == RightButton) {
272 emit rightClick(); 272 emit rightClick();
273 } 273 }
274} 274}
275 275
276MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s) 276MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s)
277 : QListBoxItem() 277 : QListBoxItem()
278{ 278{
279 mblockRepaint = true; 279 mblockRepaint = true;
280 setText( s ); 280 setText( s );
281 mMultiday = 0; 281 mMultiday = 0;
282 mIncidence = incidence; 282 mIncidence = incidence;
283 mDate = qd; 283 mDate = qd;
284 mRecur = false; 284 mRecur = false;
285 mAlarm = false; 285 mAlarm = false;
286 mReply = false; 286 mReply = false;
287 mInfo = false; 287 mInfo = false;
288 mdayPos = 0; 288 mdayPos = 0;
289 isWeekItem = KOPrefs::instance()->mMonthViewWeek; 289 isWeekItem = KOPrefs::instance()->mMonthViewWeek;
290 //qDebug("NEWWWWWWWWWWWWW "); 290 //qDebug("NEWWWWWWWWWWWWW ");
291} 291}
292void MonthViewItem::recycle( Incidence *incidence, QDate qd, const QString & s) 292void MonthViewItem::recycle( Incidence *incidence, QDate qd, const QString & s)
293{ 293{
294 setText( s ); 294 setText( s );
295 mMultiday = 0; 295 mMultiday = 0;
296 mIncidence = incidence; 296 mIncidence = incidence;
297 mDate = qd; 297 mDate = qd;
298 mRecur = false; 298 mRecur = false;
299 mAlarm = false; 299 mAlarm = false;
300 mReply = false; 300 mReply = false;
301 mInfo = false; 301 mInfo = false;
302 mdayPos = 0; 302 mdayPos = 0;
303 //qDebug("recucleeeeeeeeeeeeeeeee "); 303 //qDebug("recucleeeeeeeeeeeeeeeee ");
304} 304}
305 305
306void MonthViewItem::paint(QPainter *p) 306void MonthViewItem::paint(QPainter *p)
307{ 307{
308 if ( mblockRepaint ) { 308 if ( mblockRepaint ) {
309 //qDebug("block "); 309 //qDebug("block ");
310 return; 310 return;
311 } 311 }
312 //qDebug("NON block "); 312 //qDebug("NON block ");
313#if QT_VERSION >= 0x030000 313#if QT_VERSION >= 0x030000
314 bool sel = isSelected(); 314 bool sel = isSelected();
315#else 315#else
316 bool sel = selected(); 316 bool sel = selected();
317#endif 317#endif
318 318
319 319
320 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) 320 if (KOPrefs::instance()->mMonthViewUsesCategoryColor)
321 { 321 {
322 p->setBackgroundColor( palette().color( QPalette::Normal, \ 322 p->setBackgroundColor( palette().color( QPalette::Normal, \
323 sel ? QColorGroup::Highlight : QColorGroup::Background ) ); 323 sel ? QColorGroup::Highlight : QColorGroup::Background ) );
324 p->eraseRect( 0, 0, listBox()->maxItemWidth(), height( listBox() ) ); 324 p->eraseRect( 0, 0, listBox()->maxItemWidth(), height( listBox() ) );
325 } 325 }
326 int x = 1; 326 int x = 1;
327 //int y = 3;//(height() - mRecurPixmap.height()) /2; 327 //int y = 3;//(height() - mRecurPixmap.height()) /2;
328 int size = PIXMAP_SIZE; 328 int size = PIXMAP_SIZE;
329 if ( QApplication::desktop()->width() < 300 ) 329 if ( QApplication::desktop()->width() < 300 )
330 size = 3; 330 size = 3;
331 int heihei = height( listBox () ); 331 int heihei = height( listBox () );
332 int y = (heihei - size -1 ) /2; 332 int y = (heihei - size -1 ) /2;
333 333
334 if ( KOPrefs::instance()->mMonthShowIcons ) { 334 if ( KOPrefs::instance()->mMonthShowIcons ) {
335 if ( mInfo ) { 335 if ( mInfo ) {
336 p->fillRect ( x, y,size,size, Qt::darkGreen ); 336 p->fillRect ( x, y,size,size, Qt::darkGreen );
337 x += size + 1; 337 x += size + 1;
338 } 338 }
339 if ( mRecur ) { 339 if ( mRecur ) {
340 p->fillRect ( x, y,size,size, Qt::blue ); 340 p->fillRect ( x, y,size,size, Qt::blue );
341 x += size + 1; 341 x += size + 1;
342 } 342 }
343 if ( mAlarm ) { 343 if ( mAlarm ) {
344 p->fillRect ( x, y,size,size, Qt::red ); 344 p->fillRect ( x, y,size,size, Qt::red );
345 x += size + 1; 345 x += size + 1;
346 } 346 }
347 if ( mReply ) { 347 if ( mReply ) {
348 p->fillRect ( x, y,size,size, Qt::yellow ); 348 p->fillRect ( x, y,size,size, Qt::yellow );
349 x += size + 1; 349 x += size + 1;
350 } 350 }
351 } 351 }
352 if ( mMultiday ) { 352 if ( mMultiday ) {
353 int yyy = y+(size/2); 353 int yyy = y+(size/2);
354 int sizeM = size+2; 354 int sizeM = size+2;
355 p->setBrush( QBrush::SolidPattern ); 355 p->setBrush( QBrush::SolidPattern );
356 p->drawLine ( x+1, yyy, x +sizeM +sizeM/2-1, yyy ) ; 356 p->drawLine ( x+1, yyy, x +sizeM +sizeM/2-1, yyy ) ;
357 if ( mMultiday == 2 || mMultiday == 3 ) { 357 if ( mMultiday == 2 || mMultiday == 3 ) {
358 QPointArray pa ( 3 ); 358 QPointArray pa ( 3 );
359 pa.setPoint (0, x, yyy ); 359 pa.setPoint (0, x, yyy );
360 pa.setPoint (1, x+sizeM/2, yyy+sizeM/2 ); 360 pa.setPoint (1, x+sizeM/2, yyy+sizeM/2 );
361 pa.setPoint (2, x+sizeM/2, yyy-sizeM/2 ); 361 pa.setPoint (2, x+sizeM/2, yyy-sizeM/2 );
362 p->drawPolygon( pa ); 362 p->drawPolygon( pa );
363 } 363 }
364 if ( mMultiday == 2 || mMultiday == 1 ) { 364 if ( mMultiday == 2 || mMultiday == 1 ) {
365 QPointArray pa ( 3 ); 365 QPointArray pa ( 3 );
366 pa.setPoint (0, x+sizeM +sizeM/2, yyy ); 366 pa.setPoint (0, x+sizeM +sizeM/2, yyy );
367 pa.setPoint (1, x+sizeM, yyy+sizeM/2 ); 367 pa.setPoint (1, x+sizeM, yyy+sizeM/2 );
368 pa.setPoint (2, x+sizeM, yyy-sizeM/2 ); 368 pa.setPoint (2, x+sizeM, yyy-sizeM/2 );
369 p->drawPolygon( pa ); 369 p->drawPolygon( pa );
370 } 370 }
371 if ( mMultiday == 1 ) { 371 if ( mMultiday == 1 ) {
372 // p->fillRect ( x, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); 372 // p->fillRect ( x, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) );
373 373
374 p->drawLine ( x+1, yyy-sizeM/2, x+1, yyy+sizeM/2 ); 374 p->drawLine ( x+1, yyy-sizeM/2, x+1, yyy+sizeM/2 );
375 } 375 }
376 if ( mMultiday == 3 ) { 376 if ( mMultiday == 3 ) {
377 // p->fillRect ( x+sizeM, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); 377 // p->fillRect ( x+sizeM, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) );
378 p->drawLine ( x+sizeM +sizeM/2-1, yyy-sizeM/2, x+sizeM +sizeM/2-1, yyy+sizeM/2 ); 378 p->drawLine ( x+sizeM +sizeM/2-1, yyy-sizeM/2, x+sizeM +sizeM/2-1, yyy+sizeM/2 );
379 379
380 } 380 }
381 x += sizeM/2 + 1; 381 x += sizeM/2 + 1;
382 x += sizeM + 1; 382 x += sizeM + 1;
383 } 383 }
384 384
385 if ( mIncidence->type() == "Todo" ){ 385 if ( mIncidence->type() == "Todo" ){
386 Todo* td = ( Todo* ) mIncidence; 386 Todo* td = ( Todo* ) mIncidence;
387 if ( td->isCompleted() ) { 387 if ( td->isCompleted() ) {
388 int half = size/2; 388 int half = size/2;
389 p->drawLine ( x, heihei/2, x +half , heihei/2 +half ) ; 389 p->drawLine ( x, heihei/2, x +half , heihei/2 +half ) ;
390 p->drawLine ( x +half , heihei/2 +half , x +half+half +2 , heihei/2 -2 ) ; 390 p->drawLine ( x +half , heihei/2 +half , x +half+half +2 , heihei/2 -2 ) ;
391 x += half+half + 4; 391 x += half+half + 4;
392 392
393 } else { 393 } else {
394 int val = td->percentComplete()/20; 394 int val = td->percentComplete()/20;
395 p->fillRect ( x+1, y-2, val ,size+4,Qt::black ); 395 p->fillRect ( x+1, y-2, val ,size+4,Qt::black );
396 p->drawRect ( x, y-2,7,size+4); 396 p->drawRect ( x, y-2,7,size+4);
397 x += size + 3; 397 x += size + 3;
398 } 398 }
399 } 399 }
400 QFontMetrics fm = p->fontMetrics(); 400 QFontMetrics fm = p->fontMetrics();
401 int yPos; 401 int yPos;
402 int pmheight = size; 402 int pmheight = size;
403 if( pmheight < fm.height() ) 403 if( pmheight < fm.height() )
404 yPos = fm.ascent() + fm.leading()/2; 404 yPos = fm.ascent() + fm.leading()/2;
405 else 405 else
406 yPos = pmheight/2 - fm.height()/2 + fm.ascent(); 406 yPos = pmheight/2 - fm.height()/2 + fm.ascent();
407 p->setPen( palette().color( QPalette::Normal, sel ? \ 407 p->setPen( palette().color( QPalette::Normal, sel ? \
408 QColorGroup::HighlightedText : QColorGroup::Foreground ) ); 408 QColorGroup::HighlightedText : QColorGroup::Foreground ) );
409 p->drawText( x, yPos, text() ); 409 p->drawText( x, yPos, text() );
410 if ( mIncidence->cancelled() ) { 410 if ( mIncidence->cancelled() ) {
411 int wid = fm.width( text() ); 411 int wid = fm.width( text() );
412 p->drawLine( x, heihei/2 ,x+wid, heihei/2 ); 412 p->drawLine( x, heihei/2 ,x+wid, heihei/2 );
413 } 413 }
414 414
415} 415}
416 416
417int MonthViewItem::height(const QListBox *lb) const 417int MonthViewItem::height(const QListBox *lb) const
418{ 418{
419 int ret = 10; 419 int ret = 10;
420 if ( lb ) 420 if ( lb )
421 ret = lb->fontMetrics().lineSpacing()+1; 421 ret = lb->fontMetrics().lineSpacing()+1;
422 return ret; 422 return ret;
423} 423}
424 424
425int MonthViewItem::width(const QListBox *lb) const 425int MonthViewItem::width(const QListBox *lb) const
426{ 426{
427 if( KOPrefs::instance()->mEnableMonthScroll || isWeekItem ) { 427 if( KOPrefs::instance()->mEnableMonthScroll || isWeekItem ) {
428 int size = PIXMAP_SIZE; 428 int size = PIXMAP_SIZE;
429 if ( QApplication::desktop()->width() < 300 ) 429 if ( QApplication::desktop()->width() < 300 )
430 size = 3; 430 size = 3;
431 int x = 1; 431 int x = 1;
432 if ( KOPrefs::instance()->mMonthShowIcons ) { 432 if ( KOPrefs::instance()->mMonthShowIcons ) {
433 if ( mInfo ) { 433 if ( mInfo ) {
434 x += size + 1; 434 x += size + 1;
435 } 435 }
436 if( mRecur ) { 436 if( mRecur ) {
437 x += size+1; 437 x += size+1;
438 } 438 }
439 if( mAlarm ) { 439 if( mAlarm ) {
440 x += size+1; 440 x += size+1;
441 } 441 }
442 if( mReply ) { 442 if( mReply ) {
443 x += size+1; 443 x += size+1;
444 } 444 }
445 } 445 }
446 if( mMultiday ) { 446 if( mMultiday ) {
447 x += size+1+2+size/2; 447 x += size+1+2+size/2;
448 } 448 }
449 return( x + lb->fontMetrics().width( text() ) + 1 ); 449 return( x + lb->fontMetrics().width( text() ) + 1 );
450 } 450 }
451 if ( ! lb ) 451 if ( ! lb )
452 return 10; 452 return 10;
453 //qDebug("ret wid %d ", lb->width()); 453 //qDebug("ret wid %d ", lb->width());
454 return lb->width(); 454 return lb->width();
455} 455}
456 456
457 457
458MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par ) 458MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par )
459 : KNoScrollListBox( par ), 459 : KNoScrollListBox( par ),
460 mMonthView( parent ) 460 mMonthView( parent )
461{ 461{
462 //QVBoxLayout *topLayout = new QVBoxLayout( this ); 462 //QVBoxLayout *topLayout = new QVBoxLayout( this );
463 currentPalette = 0; 463 currentPalette = 0;
464 // mLabel = new QLabel( this );QPushButton 464 // mLabel = new QLabel( this );QPushButton
465 mLabel = new QPushButton( this ); 465 mLabel = new QPushButton( this );
466 //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain ); 466 //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain );
467 //mLabel->setLineWidth( 1 ); 467 //mLabel->setLineWidth( 1 );
468 //mLabel->setAlignment( AlignCenter ); 468 //mLabel->setAlignment( AlignCenter );
469 mLabel->setFlat( true ); 469 mLabel->setFlat( true );
470 mLabel->setFocusPolicy(NoFocus); 470 mLabel->setFocusPolicy(NoFocus);
471 //mItemList = new KNoScrollListBox( this ); 471 //mItemList = new KNoScrollListBox( this );
472 setMinimumSize( 10, 10 ); 472 setMinimumSize( 10, 10 );
473 setFrameStyle( QFrame::Panel | QFrame::Plain ); 473 setFrameStyle( QFrame::Panel | QFrame::Plain );
474 setLineWidth( 1 ); 474 setLineWidth( 1 );
475 //topLayout->addWidget( mItemList ); 475 //topLayout->addWidget( mItemList );
476 mLabel->raise(); 476 mLabel->raise();
477 // QColor( 0,0,255 ) QColor( 160,1600,255 ) 477 // QColor( 0,0,255 ) QColor( 160,1600,255 )
478 mStandardPalette = palette(); 478 mStandardPalette = palette();
479 mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) ); 479 mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) );
480 480
481 enableScrollBars( false ); 481 enableScrollBars( false );
482 updateConfig(); 482 updateConfig();
483 //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() )); 483 //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() ));
484 connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() )); 484 connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() ));
485 connect( this , SIGNAL( doubleClicked( QListBoxItem *) ), 485 connect( this , SIGNAL( doubleClicked( QListBoxItem *) ),
486 SLOT( defaultAction( QListBoxItem * ) ) ); 486 SLOT( defaultAction( QListBoxItem * ) ) );
487 connect( this, SIGNAL( rightButtonPressed( QListBoxItem *, 487 connect( this, SIGNAL( rightButtonPressed( QListBoxItem *,
488 const QPoint &) ), 488 const QPoint &) ),
489 SLOT( contextMenu( QListBoxItem * ) ) ); 489 SLOT( contextMenu( QListBoxItem * ) ) );
490 connect( this, SIGNAL( highlighted( QListBoxItem *) ), 490 connect( this, SIGNAL( highlighted( QListBoxItem *) ),
491 SLOT( selection( QListBoxItem * ) ) ); 491 SLOT( selection( QListBoxItem * ) ) );
492 492
493 /* 493 /*
494 connect( this, SIGNAL( clicked( QListBoxItem * ) ), 494 connect( this, SIGNAL( clicked( QListBoxItem * ) ),
495 SLOT( selection( QListBoxItem * ) ) ); 495 SLOT( selection( QListBoxItem * ) ) );
496 */ 496 */
497} 497}
498#ifdef DESKTOP_VERSION 498#ifdef DESKTOP_VERSION
499QToolTipGroup *MonthViewCell::toolTipGroup() 499QToolTipGroup *MonthViewCell::toolTipGroup()
500{ 500{
501 if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); 501 if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0);
502 return mToolTipGroup; 502 return mToolTipGroup;
503} 503}
504#endif 504#endif
505 505
506void MonthViewCell::setDate( const QDate &date ) 506void MonthViewCell::setDate( const QDate &date )
507{ 507{
508 // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl; 508 // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl;
509 mDate = date; 509 mDate = date;
510 510
511 511
512 512
513 //resizeEvent( 0 ); 513 //resizeEvent( 0 );
514} 514}
515 515
516QDate MonthViewCell::date() const 516QDate MonthViewCell::date() const
517{ 517{
518 return mDate; 518 return mDate;
519} 519}
520 520
521void MonthViewCell::setPrimary( bool primary ) 521void MonthViewCell::setPrimary( bool primary )
522{ 522{
523 mPrimary = primary; 523 mPrimary = primary;
524 //setMyPalette(); 524 //setMyPalette();
525} 525}
526void MonthViewCell::setMyPalette() 526void MonthViewCell::setMyPalette()
527{ 527{
528 528
529 if ( mHoliday) { 529 if ( mHoliday) {
530 if ( currentPalette == 1 ) return; 530 if ( currentPalette == 1 ) return;
531 mLabel->setPalette( QPalette ( mHolidayPalette.color( QPalette::Normal,QColorGroup::Base),mHolidayPalette.color(QPalette::Normal,QColorGroup::Base ) )); 531 mLabel->setPalette( QPalette ( mHolidayPalette.color( QPalette::Normal,QColorGroup::Base),mHolidayPalette.color(QPalette::Normal,QColorGroup::Base ) ));
532 setPalette( mHolidayPalette ); 532 setPalette( mHolidayPalette );
533 //mLabel->setPalette( mHolidayPalette ); 533 //mLabel->setPalette( mHolidayPalette );
534 currentPalette = 1; 534 currentPalette = 1;
535 535
536 } else { 536 } else {
537 if ( mPrimary ) { 537 if ( mPrimary ) {
538 if ( currentPalette == 2 ) return; 538 if ( currentPalette == 2 ) return;
539 mLabel->setPalette( QPalette ( mPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); 539 mLabel->setPalette( QPalette ( mPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) ));
540 //mLabel->setPalette( mPrimaryPalette ); 540 //mLabel->setPalette( mPrimaryPalette );
541 setPalette( mPrimaryPalette ); 541 setPalette( mPrimaryPalette );
542 currentPalette = 2; 542 currentPalette = 2;
543 543
544 } else { 544 } else {
545 if ( currentPalette == 3 ) return; 545 if ( currentPalette == 3 ) return;
546 setPalette( mNonPrimaryPalette ); 546 setPalette( mNonPrimaryPalette );
547 mLabel->setPalette( QPalette ( mNonPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mNonPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); 547 mLabel->setPalette( QPalette ( mNonPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mNonPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) ));
548 //mLabel->setPalette( mNonPrimaryPalette );; 548 //mLabel->setPalette( mNonPrimaryPalette );;
549 currentPalette = 3; 549 currentPalette = 3;
550 } 550 }
551 } 551 }
552 //QPalette pal = palette(); 552 //QPalette pal = palette();
553 553
554 //mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) )); 554 //mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) ));
555} 555}
556QPalette MonthViewCell::getPalette () 556QPalette MonthViewCell::getPalette ()
557{ 557{
558 if ( !KOPrefs::instance()->mMonthViewUsesDayColors ) 558 if ( !KOPrefs::instance()->mMonthViewUsesDayColors )
559 return mStandardPalette; 559 return mStandardPalette;
560 if ( mHoliday) { 560 if ( mHoliday) {
561 return mHolidayPalette ; 561 return mHolidayPalette ;
562 } else { 562 } else {
563 if ( mPrimary ) { 563 if ( mPrimary ) {
564 return mPrimaryPalette ; 564 return mPrimaryPalette ;
565 } 565 }
566 } 566 }
567 return mNonPrimaryPalette; 567 return mNonPrimaryPalette;
568} 568}
569bool MonthViewCell::isPrimary() const 569bool MonthViewCell::isPrimary() const
570{ 570{
571 return mPrimary; 571 return mPrimary;
572} 572}
573 573
574void MonthViewCell::setHoliday( bool holiday ) 574void MonthViewCell::setHoliday( bool holiday )
575{ 575{
576 mHoliday = holiday; 576 mHoliday = holiday;
577 //setMyPalette(); 577 //setMyPalette();
578} 578}
579 579
580void MonthViewCell::setHoliday( const QString &holiday ) 580void MonthViewCell::setHoliday( const QString &holiday )
581{ 581{
582 mHolidayString = holiday; 582 mHolidayString = holiday;
583 583
584 if ( !holiday.isEmpty() ) { 584 if ( !holiday.isEmpty() ) {
585 setHoliday( true ); 585 setHoliday( true );
586 } 586 }
587} 587}
588 588
589void MonthViewCell::startUpdateCell() 589void MonthViewCell::startUpdateCell()
590{ 590{
591 mdayCount = 0; 591 mdayCount = 0;
592 setFocusPolicy(NoFocus); 592 setFocusPolicy(NoFocus);
593 if ( !mMonthView->isUpdatePossible() ) 593 if ( !mMonthView->isUpdatePossible() )
594 return; 594 return;
595 MonthViewItem *mitem = (MonthViewItem*) firstItem (); 595 MonthViewItem *mitem = (MonthViewItem*) firstItem ();
596 while ( mitem ) { 596 while ( mitem ) {
597 mitem->setBlockRepaint( true ); 597 mitem->setBlockRepaint( true );
598 mitem = (MonthViewItem *)mitem->next(); 598 mitem = (MonthViewItem *)mitem->next();
599 } 599 }
600 if ( mAvailItemList.count() > 20 ) { 600 if ( mAvailItemList.count() > 20 ) {
601 mAvailItemList.setAutoDelete( true ); 601 mAvailItemList.setAutoDelete( true );
602 mAvailItemList.clear(); 602 mAvailItemList.clear();
603 mAvailItemList.setAutoDelete( false ); 603 mAvailItemList.setAutoDelete( false );
604 } 604 }
605 /* 605 /*
606 if ( !isVisible() ){ 606 if ( !isVisible() ){
607 return; 607 return;
608 } 608 }
609 */ 609 */
610 // qDebug("MonthViewCell::updateCell() "); 610 // qDebug("MonthViewCell::updateCell() ");
611 setPrimary( mDate.month()%2 ); 611 setPrimary( mDate.month()%2 );
612 setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays); 612 setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays);
613 if ( mDate == QDate::currentDate() ) { 613 if ( mDate == QDate::currentDate() ) {
614 setLineWidth( 3 ); 614 setLineWidth( 3 );
615 } else { 615 } else {
616 setLineWidth( 1 ); 616 setLineWidth( 1 );
617 } 617 }
618 MonthViewItem* CurrentAvailItem = (MonthViewItem*) firstItem (); 618 MonthViewItem* CurrentAvailItem = (MonthViewItem*) firstItem ();
619 //clear(); 619 //clear();
620 while ( CurrentAvailItem ) { 620 while ( CurrentAvailItem ) {
621 MonthViewItem *item = CurrentAvailItem; 621 MonthViewItem *item = CurrentAvailItem;
622 CurrentAvailItem = (MonthViewItem *)item->next(); 622 CurrentAvailItem = (MonthViewItem *)item->next();
623 mAvailItemList.append( item ); 623 mAvailItemList.append( item );
624 takeItem ( item ); 624 takeItem ( item );
625 } 625 }
626 626
627#ifdef DESKTOP_VERSION 627#ifdef DESKTOP_VERSION
628 QToolTip::remove(this); 628 QToolTip::remove(this);
629#endif 629#endif
630 mToolTip.clear(); 630 mToolTip.clear();
631 //qApp->processEvents(); 631 //qApp->processEvents();
632#if 0 632#if 0
633 if ( !mHolidayString.isEmpty() ) { 633 if ( !mHolidayString.isEmpty() ) {
634 MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); 634 MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString );
635 item->setPalette( mHolidayPalette ); 635 item->setPalette( mHolidayPalette );
636 insertItem( item ); 636 insertItem( item );
637 mToolTip.append ( mHolidayString ); 637 mToolTip.append ( mHolidayString );
638 } 638 }
639#endif 639#endif
640} 640}
641 641
642int MonthViewCell::insertEvent(Event *event) 642int MonthViewCell::insertEvent(Event *event)
643{ 643{
644 bool useToolTips = true;
645#ifndef DEKSTOP_VERSION
646 useToolTips = false;
647#endif
644 QString mToolTipText; 648 QString mToolTipText;
645 setFocusPolicy(WheelFocus); 649 setFocusPolicy(WheelFocus);
646 if ( !(event->doesRecur() == Recurrence::rNone) ) { 650 if ( !(event->doesRecur() == Recurrence::rNone) ) {
647 if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) 651 if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily )
648 return mdayCount; 652 return mdayCount;
649 else 653 else
650 if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) 654 if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly )
651 return mdayCount; 655 return mdayCount;
652 } 656 }
653 657
654 if ( event->isHoliday()) { 658 if ( event->isHoliday()) {
655 setHoliday( true ); 659 setHoliday( true );
656 if ( mDate.dayOfWeek() == 7 ) 660 if ( mDate.dayOfWeek() == 7 )
657 setLineWidth( 3 ); 661 setLineWidth( 3 );
658 } 662 }
659 QString text; 663 QString text;
660 int multiday = 0;// 1 = start, 2 = midddle, 3 = end day 664 int multiday = 0;// 1 = start, 2 = midddle, 3 = end day
661 if (event->isMultiDay()) { 665 if (event->isMultiDay()) {
662 QString prefix = "<->";multiday = 2; 666 QString prefix = "<->";multiday = 2;
663 QString time; 667 QString time;
664 if ( event->doesRecur() ) { 668 if ( event->doesRecur() ) {
665 if ( event->recursOn( mDate) ) { 669 if ( event->recursOn( mDate) ) {
666 prefix ="->" ;multiday = 1; 670 prefix ="->" ;multiday = 1;
667 } 671 }
668 else { 672 else {
669 int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); 673 int days = event->dtStart().date().daysTo ( event->dtEnd().date() );
670 if ( event->recursOn( mDate.addDays( -days)) ) { 674 if ( event->recursOn( mDate.addDays( -days)) ) {
671 prefix ="<-" ;multiday = 3; 675 prefix ="<-" ;multiday = 3;
672 } 676 }
673 } 677 }
674 678
675 } else { 679 } else {
676 if (mDate == event->dtStart().date()) { 680 if (mDate == event->dtStart().date()) {
677 prefix ="->" ;multiday = 1; 681 prefix ="->" ;multiday = 1;
678 } else if (mDate == event->dtEnd().date()) { 682 } else if (mDate == event->dtEnd().date()) {
679 prefix ="<-" ;multiday = 3; 683 prefix ="<-" ;multiday = 3;
680 } 684 }
681 } 685 }
682 if ( !event->doesFloat() ) { 686 if ( !event->doesFloat() ) {
683 if ( mDate == event->dtStart().date () ) 687 if ( mDate == event->dtStart().date () )
684 time = KGlobal::locale()->formatTime(event->dtStart().time())+" "; 688 time = KGlobal::locale()->formatTime(event->dtStart().time())+" ";
685 else if ( mDate == event->dtEnd().date () ) 689 else if ( mDate == event->dtEnd().date () )
686 time = KGlobal::locale()->formatTime(event->dtEnd().time())+" "; 690 time = KGlobal::locale()->formatTime(event->dtEnd().time())+" ";
687 691
688 } 692 }
689 text = time + event->summary(); 693 text = time + event->summary();
690 mToolTipText += prefix + text; 694 if ( useToolTips )
695 mToolTipText += prefix + text;
691 } else { 696 } else {
692 if (event->doesFloat()) { 697 if (event->doesFloat()) {
693 text = event->summary(); 698 text = event->summary();
694 mToolTipText += text; 699 if ( useToolTips )
700 mToolTipText += text;
695 } 701 }
696 else { 702 else {
697 text = KGlobal::locale()->formatTime(event->dtStart().time()); 703 text = KGlobal::locale()->formatTime(event->dtStart().time());
698 text += " " + event->summary(); 704 text += " " + event->summary();
699 mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); 705 if ( useToolTips )
706 mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary();
700 } 707 }
701 } 708 }
709 if ( useToolTips && ! event->location().isEmpty() ) {
710 mToolTipText += " (" + event->location() +")";
711 }
702 MonthViewItem *item ; 712 MonthViewItem *item ;
703 713
704 if ( mAvailItemList.count() ) { 714 if ( mAvailItemList.count() ) {
705 item = mAvailItemList.first(); 715 item = mAvailItemList.first();
706 mAvailItemList.remove( item ); 716 mAvailItemList.remove( item );
707 item->recycle( event, mDate, text ); 717 item->recycle( event, mDate, text );
708 } else { 718 } else {
709 item = new MonthViewItem( event, mDate, text ); 719 item = new MonthViewItem( event, mDate, text );
710 } 720 }
711 721
712 QPalette pal; 722 QPalette pal;
713 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { 723 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) {
714 QStringList categories = event->categories(); 724 QStringList categories = event->categories();
715 QString cat = categories.first(); 725 QString cat = categories.first();
716 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { 726 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) {
717 pal = getPalette(); 727 pal = getPalette();
718 if (cat.isEmpty()) { 728 if (cat.isEmpty()) {
719 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); 729 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor);
720 } else { 730 } else {
721 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); 731 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat)));
722 } 732 }
723 733
724 } else { 734 } else {
725 if (cat.isEmpty()) { 735 if (cat.isEmpty()) {
726 pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); 736 pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor);
727 } else { 737 } else {
728 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); 738 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat)));
729 } 739 }
730 } 740 }
731 741
732 } else { 742 } else {
733 pal = mStandardPalette ; 743 pal = mStandardPalette ;
734 } 744 }
735 item->setPalette( pal ); 745 item->setPalette( pal );
736 item->setRecur( event->recurrence()->doesRecur() ); 746 item->setRecur( event->recurrence()->doesRecur() );
737 item->setAlarm( event->isAlarmEnabled() && multiday < 2 ); 747 item->setAlarm( event->isAlarmEnabled() && multiday < 2 );
738 item->setMoreInfo( event->description().length() > 0 ); 748 item->setMoreInfo( event->description().length() > 0 );
739#ifdef DESKTOP_VERSION 749#ifdef DESKTOP_VERSION
740 Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails, 750 Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails,
741 KOPrefs::instance()->email()); 751 KOPrefs::instance()->email());
742 if ( me != 0 ) { 752 if ( me != 0 ) {
743 if ( me->status() == Attendee::NeedsAction && me->RSVP()) 753 if ( me->status() == Attendee::NeedsAction && me->RSVP())
744 item->setReply(true && multiday < 2); 754 item->setReply(true && multiday < 2);
745 else 755 else
746 item->setReply(false); 756 item->setReply(false);
747 } else 757 } else
748 item->setReply(false); 758 item->setReply(false);
749#endif 759#endif
750 item->setMultiDay( multiday ); 760 item->setMultiDay( multiday );
751 if ( multiday ) { 761 if ( multiday ) {
752 insertItem( item ,mdayCount); 762 insertItem( item ,mdayCount);
753 ++mdayCount; 763 ++mdayCount;
754 } else { 764 } else {
755 uint i; 765 uint i;
756 int pos = mdayCount; 766 int pos = mdayCount;
757 for ( i = mdayCount; i < count();++i ) { 767 for ( i = mdayCount; i < count();++i ) {
758 QListBoxItem* it = this->item ( i ); 768 QListBoxItem* it = this->item ( i );
759 if ( text < it->text() ) { 769 if ( text < it->text() ) {
760 pos = i; 770 pos = i;
761 break; 771 break;
762 } 772 }
763 ++pos; 773 ++pos;
764 } 774 }
765 insertItem( item ,pos); 775 insertItem( item ,pos);
766 } 776 }
767 mToolTip.append( mToolTipText ); 777 if ( useToolTips )
778 mToolTip.append( mToolTipText );
768 return mdayCount; 779 return mdayCount;
769} 780}
770void MonthViewCell::insertTodo(Todo *todo) 781void MonthViewCell::insertTodo(Todo *todo)
771{ 782{
772 setFocusPolicy(WheelFocus); 783 setFocusPolicy(WheelFocus);
773 QString text; 784 QString text;
774 if (todo->hasDueDate()) { 785 if (todo->hasDueDate()) {
775 if (!todo->doesFloat()) { 786 if (!todo->doesFloat()) {
776 text += KGlobal::locale()->formatTime(todo->dtDue().time()); 787 text += KGlobal::locale()->formatTime(todo->dtDue().time());
777 text += " "; 788 text += " ";
778 } 789 }
779 } 790 }
780 text += todo->summary(); 791 text += todo->summary();
781 MonthViewItem *item ; 792 MonthViewItem *item ;
782 if ( mAvailItemList.count() ) { 793 if ( mAvailItemList.count() ) {
783 item = mAvailItemList.first(); 794 item = mAvailItemList.first();
784 mAvailItemList.remove( item ); 795 mAvailItemList.remove( item );
785 item->recycle( todo, mDate, text ); 796 item->recycle( todo, mDate, text );
786 } else { 797 } else {
787 item = new MonthViewItem( todo, mDate, text ); 798 item = new MonthViewItem( todo, mDate, text );
788 } 799 }
789 //MonthViewItem *item = new MonthViewItem( todo, mDate, text ); 800 //MonthViewItem *item = new MonthViewItem( todo, mDate, text );
790 //item->setPalette( mStandardPalette ); 801 //item->setPalette( mStandardPalette );
791 QPalette pal; 802 QPalette pal;
792 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { 803 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) {
793 QStringList categories = todo->categories(); 804 QStringList categories = todo->categories();
794 QString cat = categories.first(); 805 QString cat = categories.first();
795 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { 806 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) {
796 pal = getPalette(); 807 pal = getPalette();
797 if (cat.isEmpty()) { 808 if (cat.isEmpty()) {
798 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); 809 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor);
799 } else { 810 } else {
800 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); 811 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat)));
801 } 812 }
802 813
803 } else { 814 } else {
804 if (cat.isEmpty()) { 815 if (cat.isEmpty()) {
805 pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); 816 pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor);
806 } else { 817 } else {
807 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); 818 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat)));
808 } 819 }
809 } 820 }
810 821
811 } else { 822 } else {
812 pal = mStandardPalette ; 823 pal = mStandardPalette ;
813 } 824 }
814 item->setPalette( pal ); 825 item->setPalette( pal );
815 item->setRecur( todo->recurrence()->doesRecur() ); 826 item->setRecur( todo->recurrence()->doesRecur() );
816 item->setAlarm( todo->isAlarmEnabled() ); 827 item->setAlarm( todo->isAlarmEnabled() );
817 item->setMoreInfo( todo->description().length() > 0 ); 828 item->setMoreInfo( todo->description().length() > 0 );
818 insertItem( item , count()); 829 insertItem( item , count());
830#ifdef DESKTOP_VERSION
819 mToolTip.append( text ); 831 mToolTip.append( text );
832#endif
820} 833}
821void MonthViewCell::repaintfinishUpdateCell() 834void MonthViewCell::repaintfinishUpdateCell()
822{ 835{
823 MonthViewItem *mitem = (MonthViewItem*) firstItem (); 836 MonthViewItem *mitem = (MonthViewItem*) firstItem ();
824 while ( mitem ) { 837 while ( mitem ) {
825 mitem->setBlockRepaint( false ); 838 mitem->setBlockRepaint( false );
826 updateItem ( mitem ); 839 updateItem ( mitem );
827 mitem = (MonthViewItem *)mitem->next(); 840 mitem = (MonthViewItem *)mitem->next();
828 } 841 }
829} 842}
830void MonthViewCell::finishUpdateCell() 843void MonthViewCell::finishUpdateCell()
831{ 844{
832 845
833 846
834 847
835#ifdef DESKTOP_VERSION 848#ifdef DESKTOP_VERSION
836 if (mToolTip.count() > 0 ) { 849 if (mToolTip.count() > 0 ) {
837 mToolTip.sort(); 850 mToolTip.sort();
838 QToolTip::add(this,mToolTip.join("\n"),toolTipGroup(),""); 851 QToolTip::add(this,mToolTip.join("\n"),toolTipGroup(),"");
839 } 852 }
840#endif 853#endif
841 //sort(); 854 //sort();
842 //setMyPalette(); 855 //setMyPalette();
843 setMyPalette(); 856 setMyPalette();
844 857
845 resizeEvent( 0 ); 858 resizeEvent( 0 );
846 859
847} 860}
848void MonthViewCell::updateCell() 861void MonthViewCell::updateCell()
849{ 862{
850 //qDebug("MonthViewCell::updateCell() "); 863 //qDebug("MonthViewCell::updateCell() ");
851 if ( !mMonthView->isUpdatePossible() ) 864 if ( !mMonthView->isUpdatePossible() )
852 return; 865 return;
853 startUpdateCell(); 866 startUpdateCell();
854 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); 867 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2);
855 QPtrList<Event> events = mMonthView->calendar()->events( mDate, true ); 868 QPtrList<Event> events = mMonthView->calendar()->events( mDate, true );
856 Event *event; 869 Event *event;
857 for( event = events.first(); event; event = events.next() ) { // for event 870 for( event = events.first(); event; event = events.next() ) { // for event
858 insertEvent(event); 871 insertEvent(event);
859 } 872 }
860 // insert due todos 873 // insert due todos
861 QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); 874 QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate );
862 Todo *todo; 875 Todo *todo;
863 for(todo = todos.first(); todo; todo = todos.next()) { 876 for(todo = todos.first(); todo; todo = todos.next()) {
864 insertTodo( todo ); 877 insertTodo( todo );
865 } 878 }
866 finishUpdateCell(); 879 finishUpdateCell();
867 // if ( isVisible()) 880 // if ( isVisible())
868 //qApp->processEvents(); 881 //qApp->processEvents();
869} 882}
870 883
871void MonthViewCell::updateConfig( bool bigFont ) // = false 884void MonthViewCell::updateConfig( bool bigFont ) // = false
872{ 885{
873 886
874 if ( bigFont ) { 887 if ( bigFont ) {
875 QFont fo = KOPrefs::instance()->mMonthViewFont; 888 QFont fo = KOPrefs::instance()->mMonthViewFont;
876 int ps = fo.pointSize() + 2; 889 int ps = fo.pointSize() + 2;
877 if ( ps < 18 ) 890 if ( ps < 18 )
878 ps += 2; 891 ps += 2;
879 fo.setPointSize( ps ); 892 fo.setPointSize( ps );
880 setFont( fo ); 893 setFont( fo );
881 } else 894 } else
882 setFont( KOPrefs::instance()->mMonthViewFont ); 895 setFont( KOPrefs::instance()->mMonthViewFont );
883 896
884 QFontMetrics fm( font() ); 897 QFontMetrics fm( font() );
885 mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 ); 898 mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 );
886 mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 ); 899 mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 );
887 mHolidayPalette = mStandardPalette; 900 mHolidayPalette = mStandardPalette;
888 mPrimaryPalette = mStandardPalette; 901 mPrimaryPalette = mStandardPalette;
889 mNonPrimaryPalette = mStandardPalette; 902 mNonPrimaryPalette = mStandardPalette;
890 if ( KOPrefs::instance()->mMonthViewUsesDayColors ) { 903 if ( KOPrefs::instance()->mMonthViewUsesDayColors ) {
891 mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor ); 904 mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor );
892 mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor ); 905 mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor );
893 mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark()); 906 mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark());
894 mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark()); 907 mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark());
895 mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor); 908 mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor);
896 mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor); 909 mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor);
897 mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); 910 mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark());
898 mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); 911 mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor);
899 mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); 912 mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor);
900 } 913 }
901 //updateCell(); 914 //updateCell();
902} 915}
903 916
904void MonthViewCell::enableScrollBars( bool enabled ) 917void MonthViewCell::enableScrollBars( bool enabled )
905{ 918{
906 919
907 return; 920 return;
908 if ( enabled ) { 921 if ( enabled ) {
909 QListBoxItem *fi = firstItem (); 922 QListBoxItem *fi = firstItem ();
910 if (fi ) { 923 if (fi ) {
911 int ihei = fi->height( this ); 924 int ihei = fi->height( this );
912 int hei = numRows () * ihei; 925 int hei = numRows () * ihei;
913 if ( hei < height() - horizontalScrollBar()->height () ) { 926 if ( hei < height() - horizontalScrollBar()->height () ) {
914 setVScrollBarMode(QScrollView::AlwaysOff); 927 setVScrollBarMode(QScrollView::AlwaysOff);
915 } 928 }
916 else 929 else
917 setVScrollBarMode(QScrollView::Auto); 930 setVScrollBarMode(QScrollView::Auto);
918 if ( ihei *3 > height() ) { 931 if ( ihei *3 > height() ) {
919 setHScrollBarMode(QScrollView::AlwaysOff); 932 setHScrollBarMode(QScrollView::AlwaysOff);
920 } 933 }
921 else { 934 else {
922 setHScrollBarMode(QScrollView::Auto); 935 setHScrollBarMode(QScrollView::Auto);
923 } 936 }
924 } else { 937 } else {
925 setVScrollBarMode(QScrollView::Auto); 938 setVScrollBarMode(QScrollView::Auto);
926 setHScrollBarMode(QScrollView::Auto); 939 setHScrollBarMode(QScrollView::Auto);
927 } 940 }
928 } else { 941 } else {
929 setVScrollBarMode(QScrollView::AlwaysOff); 942 setVScrollBarMode(QScrollView::AlwaysOff);
930 setHScrollBarMode(QScrollView::AlwaysOff); 943 setHScrollBarMode(QScrollView::AlwaysOff);
931 } 944 }
932} 945}
933 946
934Incidence *MonthViewCell::selectedIncidence() 947Incidence *MonthViewCell::selectedIncidence()
935{ 948{
936 int index = currentItem(); 949 int index = currentItem();
937 if ( index < 0 ) return 0; 950 if ( index < 0 ) return 0;
938 951
939 MonthViewItem *mitem = 952 MonthViewItem *mitem =
940 static_cast<MonthViewItem *>( item( index ) ); 953 static_cast<MonthViewItem *>( item( index ) );
941 954
942 if ( !mitem ) return 0; 955 if ( !mitem ) return 0;
943 956
944 return mitem->incidence(); 957 return mitem->incidence();
945} 958}
946 959
947QDate MonthViewCell::selectedIncidenceDate() 960QDate MonthViewCell::selectedIncidenceDate()
948{ 961{
949 QDate qd; 962 QDate qd;
950 int index = currentItem(); 963 int index = currentItem();
951 if ( index < 0 ) return qd; 964 if ( index < 0 ) return qd;
952 965
953 MonthViewItem *mitem = 966 MonthViewItem *mitem =
954 static_cast<MonthViewItem *>( item( index ) ); 967 static_cast<MonthViewItem *>( item( index ) );
955 968
956 if ( !mitem ) return qd; 969 if ( !mitem ) return qd;
957 970
958 return mitem->incidenceDate(); 971 return mitem->incidenceDate();
959} 972}
960 973
961void MonthViewCell::deselect() 974void MonthViewCell::deselect()
962{ 975{
963 clearSelection(); 976 clearSelection();
964 enableScrollBars( false ); 977 enableScrollBars( false );
965 // updateCell(); 978 // updateCell();
966} 979}
967void MonthViewCell::select() 980void MonthViewCell::select()
968{ 981{
969 ;// updateCell(); 982 ;// updateCell();
970} 983}
971 984
972void MonthViewCell::resizeEvent ( QResizeEvent * e ) 985void MonthViewCell::resizeEvent ( QResizeEvent * e )
973{ 986{
974 if ( !mMonthView->isUpdatePossible() ) 987 if ( !mMonthView->isUpdatePossible() )
975 return; 988 return;
976 //qDebug("++++++++++++++MonthViewCell::resizeEvent %d %d ", width(), height()); 989 //qDebug("++++++++++++++MonthViewCell::resizeEvent %d %d ", width(), height());
977 deselect(); 990 deselect();
978 mLabel->setMaximumHeight( height() - lineWidth()*2 ); 991 mLabel->setMaximumHeight( height() - lineWidth()*2 );
979 992
980 QString text; 993 QString text;
981 mLabel->setText( text ); 994 mLabel->setText( text );
982 bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; 995 bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog;
983 if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { 996 if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) {
984 text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " "; 997 text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " ";
985 mLabel->resize( mLabelBigSize ); 998 mLabel->resize( mLabelBigSize );
986 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); 999 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) );
987 } else { 1000 } else {
988 mLabel->resize( mLabelSize ); 1001 mLabel->resize( mLabelSize );
989 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); 1002 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) );
990 } 1003 }
991 mLabel->setText( text ); 1004 mLabel->setText( text );
992 1005
993 int size = height() - mLabel->height() - lineWidth()-1; 1006 int size = height() - mLabel->height() - lineWidth()-1;
994 //qDebug("LW %d ", lineWidth()); 1007 //qDebug("LW %d ", lineWidth());
995 if ( size > 0 ) 1008 if ( size > 0 )
996 verticalScrollBar()->setMaximumHeight( size ); 1009 verticalScrollBar()->setMaximumHeight( size );
997 size = width() - mLabel->width() -lineWidth()-1; 1010 size = width() - mLabel->width() -lineWidth()-1;
998 if ( size > 0 ) 1011 if ( size > 0 )
999 horizontalScrollBar()->setMaximumWidth( size ); 1012 horizontalScrollBar()->setMaximumWidth( size );
1000 mLabel->move( width()-lineWidth() - mLabel->width(), height()-lineWidth() - mLabel->height() ); 1013 mLabel->move( width()-lineWidth() - mLabel->width(), height()-lineWidth() - mLabel->height() );
1001 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); 1014 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2);
1002 // mItemList->resize ( width(), height () ); 1015 // mItemList->resize ( width(), height () );
1003 if ( e ) 1016 if ( e )
1004 KNoScrollListBox::resizeEvent ( e ); 1017 KNoScrollListBox::resizeEvent ( e );
1005} 1018}
1006 1019
1007void MonthViewCell::defaultAction( QListBoxItem *item ) 1020void MonthViewCell::defaultAction( QListBoxItem *item )
1008{ 1021{
1009 1022
1010 if ( !item ) { 1023 if ( !item ) {
1011 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); 1024 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
1012 emit newEventSignal( dt ); 1025 emit newEventSignal( dt );
1013 return; 1026 return;
1014 } 1027 }
1015 1028
1016 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); 1029 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item );
1017 Incidence *incidence = eventItem->incidence(); 1030 Incidence *incidence = eventItem->incidence();
1018 if ( incidence ) mMonthView->defaultAction( incidence ); 1031 if ( incidence ) mMonthView->defaultAction( incidence );
1019} 1032}
1020void MonthViewCell::showDay() 1033void MonthViewCell::showDay()
1021{ 1034{
1022 emit showDaySignal( date() ); 1035 emit showDaySignal( date() );
1023} 1036}
1024void MonthViewCell::newEvent() 1037void MonthViewCell::newEvent()
1025{ 1038{
1026 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); 1039 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
1027 emit newEventSignal( dt ); 1040 emit newEventSignal( dt );
1028} 1041}
1029void MonthViewCell::cellClicked( QListBoxItem *item ) 1042void MonthViewCell::cellClicked( QListBoxItem *item )
1030{ 1043{
1031 qDebug("CELL "); 1044 qDebug("CELL ");
1032 if ( item == 0 ) { 1045 if ( item == 0 ) {
1033 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); 1046 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
1034 emit newEventSignal( dt ); 1047 emit newEventSignal( dt );
1035 return; 1048 return;
1036 } 1049 }
1037 1050
1038} 1051}
1039 1052
1040void MonthViewCell::contextMenu( QListBoxItem *item ) 1053void MonthViewCell::contextMenu( QListBoxItem *item )
1041{ 1054{
1042 if ( !item ) return; 1055 if ( !item ) return;
1043 1056
1044 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); 1057 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item );
1045 Incidence *incidence = eventItem->incidence(); 1058 Incidence *incidence = eventItem->incidence();
1046 if ( incidence ) mMonthView->showContextMenu( incidence ); 1059 if ( incidence ) mMonthView->showContextMenu( incidence );
1047} 1060}
1048 1061
1049void MonthViewCell::selection( QListBoxItem *item ) 1062void MonthViewCell::selection( QListBoxItem *item )
1050{ 1063{
1051 if ( !item ) return; 1064 if ( !item ) return;
1052 1065
1053 mMonthView->setSelectedCell( this ); 1066 mMonthView->setSelectedCell( this );
1054} 1067}
1055 1068
1056 1069
1057// ******************************************************************************* 1070// *******************************************************************************
1058// ******************************************************************************* 1071// *******************************************************************************
1059// ******************************************************************************* 1072// *******************************************************************************
1060 1073
1061 1074
1062KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) 1075KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name)
1063 : KOEventView( calendar, parent, name ), 1076 : KOEventView( calendar, parent, name ),
1064 mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ), 1077 mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ),
1065 mWidthLongDayLabel( 0 ), mSelectedCell( 0 ) 1078 mWidthLongDayLabel( 0 ), mSelectedCell( 0 )
1066{ 1079{
1067 mFlagKeyPressed = false; 1080 mFlagKeyPressed = false;
1068 mShortDayLabelsM = false; 1081 mShortDayLabelsM = false;
1069 mShortDayLabelsW = false; 1082 mShortDayLabelsW = false;
1070 skipResize = false; 1083 skipResize = false;
1071 clPending = true; 1084 clPending = true;
1072 mNavigatorBar = new NavigatorBar( QDate::currentDate(), this, "useBigPixmaps" ); 1085 mNavigatorBar = new NavigatorBar( QDate::currentDate(), this, "useBigPixmaps" );
1073 mWidStack = new QWidgetStack( this ); 1086 mWidStack = new QWidgetStack( this );
1074 QVBoxLayout* hb = new QVBoxLayout( this ); 1087 QVBoxLayout* hb = new QVBoxLayout( this );
1075 mMonthView = new QWidget( mWidStack ); 1088 mMonthView = new QWidget( mWidStack );
1076 mWeekView = new QWidget( mWidStack ); 1089 mWeekView = new QWidget( mWidStack );
1077#if QT_VERSION >= 0x030000 1090#if QT_VERSION >= 0x030000
1078 mWidStack->addWidget(mMonthView ); 1091 mWidStack->addWidget(mMonthView );
1079 mWidStack->addWidget(mWeekView ); 1092 mWidStack->addWidget(mWeekView );
1080#else 1093#else
1081 mWidStack->addWidget( mMonthView, 1 ); 1094 mWidStack->addWidget( mMonthView, 1 );
1082 mWidStack->addWidget( mWeekView , 1 ); 1095 mWidStack->addWidget( mWeekView , 1 );
1083#endif 1096#endif
1084 hb->addWidget( mNavigatorBar ); 1097 hb->addWidget( mNavigatorBar );
1085 hb->addWidget( mWidStack ); 1098 hb->addWidget( mWidStack );
1086 mShowWeekView = KOPrefs::instance()->mMonthViewWeek; 1099 mShowWeekView = KOPrefs::instance()->mMonthViewWeek;
1087 updatePossible = false; 1100 updatePossible = false;
1088 //updatePossible = true; 1101 //updatePossible = true;
1089 mCells.setAutoDelete( true ); 1102 mCells.setAutoDelete( true );
1090 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; 1103 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ;
1091 mDayLabels.resize( mDaysPerWeek ); 1104 mDayLabels.resize( mDaysPerWeek );
1092 mDayLabelsW.resize( mDaysPerWeek ); 1105 mDayLabelsW.resize( mDaysPerWeek );
1093 QFont bfont = font(); 1106 QFont bfont = font();
1094 if ( QApplication::desktop()->width() < 650 ) { 1107 if ( QApplication::desktop()->width() < 650 ) {
1095 bfont.setPointSize( bfont.pointSize() - 2 ); 1108 bfont.setPointSize( bfont.pointSize() - 2 );
1096 } 1109 }
1097 bfont.setBold( true ); 1110 bfont.setBold( true );
1098 int i; 1111 int i;
1099 1112
1100 for( i = 0; i < mDaysPerWeek; i++ ) { 1113 for( i = 0; i < mDaysPerWeek; i++ ) {
1101 QLabel *label = new QLabel( mMonthView ); 1114 QLabel *label = new QLabel( mMonthView );
1102 label->setFont(bfont); 1115 label->setFont(bfont);
1103 label->setFrameStyle(QFrame::Panel|QFrame::Raised); 1116 label->setFrameStyle(QFrame::Panel|QFrame::Raised);
1104 label->setLineWidth(1); 1117 label->setLineWidth(1);
1105 label->setAlignment(AlignCenter); 1118 label->setAlignment(AlignCenter);
1106 mDayLabels.insert( i, label ); 1119 mDayLabels.insert( i, label );
1107 label = new QLabel( mWeekView ); 1120 label = new QLabel( mWeekView );
1108 label->setFont(bfont); 1121 label->setFont(bfont);
1109 label->setFrameStyle(QFrame::Panel|QFrame::Raised); 1122 label->setFrameStyle(QFrame::Panel|QFrame::Raised);
1110 label->setLineWidth(1); 1123 label->setLineWidth(1);
1111 label->setAlignment(AlignCenter); 1124 label->setAlignment(AlignCenter);
1112 mDayLabelsW.insert( i, label ); 1125 mDayLabelsW.insert( i, label );
1113 } 1126 }
1114 1127
1115 bfont.setBold( false ); 1128 bfont.setBold( false );
1116 mWeekLabels.resize( mNumWeeks+1 ); 1129 mWeekLabels.resize( mNumWeeks+1 );
1117 mWeekLabelsW.resize( 2 ); 1130 mWeekLabelsW.resize( 2 );
1118 for( i = 0; i < mNumWeeks+1; i++ ) { 1131 for( i = 0; i < mNumWeeks+1; i++ ) {
1119 KOWeekButton *label = new KOWeekButton( mMonthView ); 1132 KOWeekButton *label = new KOWeekButton( mMonthView );
1120 label->setFocusPolicy(NoFocus); 1133 label->setFocusPolicy(NoFocus);
1121 label->setFont(bfont); 1134 label->setFont(bfont);
1122 connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); 1135 connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) );
1123 label->setFlat(true); 1136 label->setFlat(true);
1124 QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); 1137 QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed"));
1125 //label->setFrameStyle(QFrame::Panel|QFrame::Raised); 1138 //label->setFrameStyle(QFrame::Panel|QFrame::Raised);
1126 //label->setLineWidth(1); 1139 //label->setLineWidth(1);
1127 //label->setAlignment(AlignCenter); 1140 //label->setAlignment(AlignCenter);
1128 mWeekLabels.insert( i, label ); 1141 mWeekLabels.insert( i, label );
1129 } 1142 }
1130 mWeekLabels[mNumWeeks]->setText( i18n("W")); 1143 mWeekLabels[mNumWeeks]->setText( i18n("W"));
1131 mWeekLabels[mNumWeeks]->setFocusPolicy(WheelFocus); 1144 mWeekLabels[mNumWeeks]->setFocusPolicy(WheelFocus);
1132 QWhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nselect week number")); 1145 QWhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nselect week number"));
1133 1146
1134 for( i = 0; i < 1+1; i++ ) { 1147 for( i = 0; i < 1+1; i++ ) {
1135 KOWeekButton *label = new KOWeekButton( mWeekView ); 1148 KOWeekButton *label = new KOWeekButton( mWeekView );
1136 label->setFocusPolicy(NoFocus); 1149 label->setFocusPolicy(NoFocus);
1137 label->setFont(bfont); 1150 label->setFont(bfont);
1138 connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); 1151 connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) );
1139 label->setFlat(true); 1152 label->setFlat(true);
1140 QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); 1153 QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed"));
1141 //label->setFrameStyle(QFrame::Panel|QFrame::Raised); 1154 //label->setFrameStyle(QFrame::Panel|QFrame::Raised);
1142 //label->setLineWidth(1); 1155 //label->setLineWidth(1);
1143 //label->setAlignment(AlignCenter); 1156 //label->setAlignment(AlignCenter);
1144 mWeekLabelsW.insert( i, label ); 1157 mWeekLabelsW.insert( i, label );
1145 } 1158 }
1146 mWeekLabelsW[1]->setText( i18n("W")); 1159 mWeekLabelsW[1]->setText( i18n("W"));
1147 mWeekLabelsW[1]->setFocusPolicy(WheelFocus); 1160 mWeekLabelsW[1]->setFocusPolicy(WheelFocus);
1148 1161
1149 1162
1150 int row, col; 1163 int row, col;
1151 mCells.resize( mNumCells ); 1164 mCells.resize( mNumCells );
1152 for( row = 0; row < mNumWeeks; ++row ) { 1165 for( row = 0; row < mNumWeeks; ++row ) {
1153 for( col = 0; col < mDaysPerWeek; ++col ) { 1166 for( col = 0; col < mDaysPerWeek; ++col ) {
1154 MonthViewCell *cell = new MonthViewCell( this, mMonthView ); 1167 MonthViewCell *cell = new MonthViewCell( this, mMonthView );
1155 mCells.insert( row * mDaysPerWeek + col, cell ); 1168 mCells.insert( row * mDaysPerWeek + col, cell );
1156 1169
1157 connect( cell, SIGNAL( defaultAction( Incidence * ) ), 1170 connect( cell, SIGNAL( defaultAction( Incidence * ) ),
1158 SLOT( defaultAction( Incidence * ) ) ); 1171 SLOT( defaultAction( Incidence * ) ) );
1159 connect( cell, SIGNAL( newEventSignal( QDateTime ) ), 1172 connect( cell, SIGNAL( newEventSignal( QDateTime ) ),
1160 SIGNAL( newEventSignal( QDateTime ) ) ); 1173 SIGNAL( newEventSignal( QDateTime ) ) );
1161 connect( cell, SIGNAL( showDaySignal( QDate ) ), 1174 connect( cell, SIGNAL( showDaySignal( QDate ) ),
1162 SIGNAL( showDaySignal( QDate ) ) ); 1175 SIGNAL( showDaySignal( QDate ) ) );
1163 connect( cell, SIGNAL( nextCell() ), 1176 connect( cell, SIGNAL( nextCell() ),
1164 SLOT( nextCell() ) ); 1177 SLOT( nextCell() ) );
1165 connect( cell, SIGNAL( prevCell() ), 1178 connect( cell, SIGNAL( prevCell() ),
1166 SLOT( prevCell() ) ); 1179 SLOT( prevCell() ) );
1167 } 1180 }
1168 } 1181 }
1169 mCellsW.resize( mDaysPerWeek ); 1182 mCellsW.resize( mDaysPerWeek );
1170 for( col = 0; col < mDaysPerWeek; ++col ) { 1183 for( col = 0; col < mDaysPerWeek; ++col ) {
1171 MonthViewCell *cell = new MonthViewCell( this, mWeekView ); 1184 MonthViewCell *cell = new MonthViewCell( this, mWeekView );
1172 mCellsW.insert( col, cell ); 1185 mCellsW.insert( col, cell );
1173 1186
1174 connect( cell, SIGNAL( defaultAction( Incidence * ) ), 1187 connect( cell, SIGNAL( defaultAction( Incidence * ) ),
1175 SLOT( defaultAction( Incidence * ) ) ); 1188 SLOT( defaultAction( Incidence * ) ) );
1176 connect( cell, SIGNAL( newEventSignal( QDateTime ) ), 1189 connect( cell, SIGNAL( newEventSignal( QDateTime ) ),
1177 SIGNAL( newEventSignal( QDateTime ) ) ); 1190 SIGNAL( newEventSignal( QDateTime ) ) );
1178 connect( cell, SIGNAL( showDaySignal( QDate ) ), 1191 connect( cell, SIGNAL( showDaySignal( QDate ) ),
1179 SIGNAL( showDaySignal( QDate ) ) ); 1192 SIGNAL( showDaySignal( QDate ) ) );
1180 connect( cell, SIGNAL( nextCell() ), 1193 connect( cell, SIGNAL( nextCell() ),
1181 SLOT( nextCell() ) ); 1194 SLOT( nextCell() ) );
1182 connect( cell, SIGNAL( prevCell() ), 1195 connect( cell, SIGNAL( prevCell() ),
1183 SLOT( prevCell() ) ); 1196 SLOT( prevCell() ) );
1184 cell->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont ); 1197 cell->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont );
1185 } 1198 }
1186 1199
1187 //connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), SLOT( switchView() ) ); 1200 //connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), SLOT( switchView() ) );
1188 mContextMenu = eventPopup(); 1201 mContextMenu = eventPopup();
1189 // updateConfig(); //useless here... 1202 // updateConfig(); //useless here...
1190 // ... but we need mWidthLongDayLabel computed 1203 // ... but we need mWidthLongDayLabel computed
1191 QFontMetrics fontmetric(mDayLabels[0]->font()); 1204 QFontMetrics fontmetric(mDayLabels[0]->font());
1192 mWidthLongDayLabel = 0; 1205 mWidthLongDayLabel = 0;
1193 for (int i = 0; i < 7; i++) { 1206 for (int i = 0; i < 7; i++) {
1194 int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); 1207 int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1));
1195 if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; 1208 if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width;
1196 } 1209 }
1197 1210
1198 //mWeekLabels[mNumWeeks]->setText( i18n("W")); 1211 //mWeekLabels[mNumWeeks]->setText( i18n("W"));
1199 1212
1200#if 0 1213#if 0
1201 if ( mShowWeekView ) 1214 if ( mShowWeekView )
1202 mWidStack->raiseWidget( mWeekView ); 1215 mWidStack->raiseWidget( mWeekView );
1203 else 1216 else
1204 mWidStack->raiseWidget( mMonthView ); 1217 mWidStack->raiseWidget( mMonthView );
1205#endif 1218#endif
1206 1219
1207 emit incidenceSelected( 0 ); 1220 emit incidenceSelected( 0 );
1208 1221
1209 mComputeLayoutTimer = new QTimer( this ); 1222 mComputeLayoutTimer = new QTimer( this );
1210 connect (mComputeLayoutTimer ,SIGNAL(timeout()), this, SLOT ( slotComputeLayout())); 1223 connect (mComputeLayoutTimer ,SIGNAL(timeout()), this, SLOT ( slotComputeLayout()));
1211 1224
1212 1225
1213#ifndef DESKTOP_VERSION 1226#ifndef DESKTOP_VERSION
1214 resize( QApplication::desktop()->size() ); 1227 resize( QApplication::desktop()->size() );
1215#else 1228#else
1216 resize(640, 480 ); 1229 resize(640, 480 );
1217 updatePossible = true; 1230 updatePossible = true;
1218#endif 1231#endif
1219 computeLayout(); 1232 computeLayout();
1220 1233
1221 if ( mShowWeekView ) 1234 if ( mShowWeekView )
1222 mWidStack->raiseWidget( mWeekView ); 1235 mWidStack->raiseWidget( mWeekView );
1223 else 1236 else
1224 mWidStack->raiseWidget( mMonthView ); 1237 mWidStack->raiseWidget( mMonthView );
1225} 1238}
1226 1239
1227KOMonthView::~KOMonthView() 1240KOMonthView::~KOMonthView()
1228{ 1241{
1229 delete mContextMenu; 1242 delete mContextMenu;
1230} 1243}
1231 1244
1232void KOMonthView::selectInternalWeekNum ( int n ) 1245void KOMonthView::selectInternalWeekNum ( int n )
1233{ 1246{
1234 switchView(); 1247 switchView();
1235 if ( !KOPrefs::instance()->mMonthViewWeek ) 1248 if ( !KOPrefs::instance()->mMonthViewWeek )
1236 emit selectMonth (); 1249 emit selectMonth ();
1237 else 1250 else
1238 emit selectWeekNum ( n ); 1251 emit selectWeekNum ( n );
1239} 1252}
1240 1253
1241int KOMonthView::currentWeek() 1254int KOMonthView::currentWeek()
1242{ 1255{
1243 if ( mShowWeekView ) 1256 if ( mShowWeekView )
1244 return mWeekLabelsW[0]->getWeekNum(); 1257 return mWeekLabelsW[0]->getWeekNum();
1245 return mWeekLabels[0]->getWeekNum(); 1258 return mWeekLabels[0]->getWeekNum();
1246} 1259}
1247void KOMonthView::switchView() 1260void KOMonthView::switchView()
1248{ 1261{
1249 if ( selectedCell( ) ) 1262 if ( selectedCell( ) )
1250 selectedCell()->deselect(); 1263 selectedCell()->deselect();
1251 mShowWeekView = !mShowWeekView; 1264 mShowWeekView = !mShowWeekView;
1252 KOPrefs::instance()->mMonthViewWeek = mShowWeekView; 1265 KOPrefs::instance()->mMonthViewWeek = mShowWeekView;
1253 if ( clPending ) { 1266 if ( clPending ) {
1254 computeLayout(); 1267 computeLayout();
1255 updateConfig(); 1268 updateConfig();
1256 } 1269 }
1257 if ( mShowWeekView ) 1270 if ( mShowWeekView )
1258 mWidStack->raiseWidget( mWeekView ); 1271 mWidStack->raiseWidget( mWeekView );
1259 else 1272 else
1260 mWidStack->raiseWidget( mMonthView ); 1273 mWidStack->raiseWidget( mMonthView );
1261 clPending = false; 1274 clPending = false;
1262} 1275}
1263 1276
1264int KOMonthView::maxDatesHint() 1277int KOMonthView::maxDatesHint()
1265{ 1278{
1266 return mNumCells; 1279 return mNumCells;
1267} 1280}
1268 1281
1269int KOMonthView::currentDateCount() 1282int KOMonthView::currentDateCount()
1270{ 1283{
1271 return mNumCells; 1284 return mNumCells;
1272} 1285}
1273 1286
1274QPtrList<Incidence> KOMonthView::selectedIncidences() 1287QPtrList<Incidence> KOMonthView::selectedIncidences()
1275{ 1288{
1276 QPtrList<Incidence> selected; 1289 QPtrList<Incidence> selected;
1277 1290
1278 if ( mSelectedCell ) { 1291 if ( mSelectedCell ) {
1279 Incidence *incidence = mSelectedCell->selectedIncidence(); 1292 Incidence *incidence = mSelectedCell->selectedIncidence();
1280 if ( incidence ) selected.append( incidence ); 1293 if ( incidence ) selected.append( incidence );
1281 } 1294 }
1282 1295
1283 return selected; 1296 return selected;
1284} 1297}
1285 1298
1286DateList KOMonthView::selectedDates() 1299DateList KOMonthView::selectedDates()
1287{ 1300{
1288 DateList selected; 1301 DateList selected;
1289 1302
1290 if ( mSelectedCell ) { 1303 if ( mSelectedCell ) {
1291 QDate qd = mSelectedCell->selectedIncidenceDate(); 1304 QDate qd = mSelectedCell->selectedIncidenceDate();
1292 if ( qd.isValid() ) selected.append( qd ); 1305 if ( qd.isValid() ) selected.append( qd );
1293 } 1306 }
1294 1307
1295 return selected; 1308 return selected;
1296} 1309}
1297 1310
1298void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd, 1311void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd,
1299 const QDate &td) 1312 const QDate &td)
1300{ 1313{
1301#ifndef KORG_NOPRINTER 1314#ifndef KORG_NOPRINTER
1302 calPrinter->preview(CalPrinter::Month, fd, td); 1315 calPrinter->preview(CalPrinter::Month, fd, td);
1303#endif 1316#endif
1304} 1317}
1305 1318
1306void KOMonthView::updateConfig() 1319void KOMonthView::updateConfig()
1307{ 1320{
1308 1321
1309 int mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); 1322 int mWeekStartsMonday = KGlobal::locale()->weekStartsMonday();
1310 1323
1311 if ( mShowWeekView || KOPrefs::instance()->mMonthViewSatSunTog ) { 1324 if ( mShowWeekView || KOPrefs::instance()->mMonthViewSatSunTog ) {
1312 mWeekStartsMonday = true; 1325 mWeekStartsMonday = true;
1313 } 1326 }
1314 QFontMetrics fontmetric(mDayLabels[0]->font()); 1327 QFontMetrics fontmetric(mDayLabels[0]->font());
1315 mWidthLongDayLabel = 0; 1328 mWidthLongDayLabel = 0;
1316 1329
1317 for (int i = 0; i < 7; i++) { 1330 for (int i = 0; i < 7; i++) {
1318 int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); 1331 int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1));
1319 if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; 1332 if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width;
1320 } 1333 }
1321 bool temp = mShowSatSunComp ; 1334 bool temp = mShowSatSunComp ;
1322 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; 1335 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ;
1323 if ( ! mShowWeekView ) { 1336 if ( ! mShowWeekView ) {
1324 if ( temp != KOPrefs::instance()->mMonthViewSatSunTog ) 1337 if ( temp != KOPrefs::instance()->mMonthViewSatSunTog )
1325 computeLayout(); 1338 computeLayout();
1326 } 1339 }
1327 updateDayLabels(); 1340 updateDayLabels();
1328 //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks); 1341 //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks);
1329 //int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks; 1342 //int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks;
1330 //resizeEvent( 0 ); 1343 //resizeEvent( 0 );
1331 for (uint i = 0; i < mCells.count(); ++i) { 1344 for (uint i = 0; i < mCells.count(); ++i) {
1332 mCells[i]->updateConfig(); 1345 mCells[i]->updateConfig();
1333 } 1346 }
1334 1347
1335 for (uint i = 0; i < mCellsW.count(); ++i) { 1348 for (uint i = 0; i < mCellsW.count(); ++i) {
1336 mCellsW[i]->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont); 1349 mCellsW[i]->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont);
1337 } 1350 }
1338#ifdef DESKTOP_VERSION 1351#ifdef DESKTOP_VERSION
1339 MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips); 1352 MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips);
1340#endif 1353#endif
1341 updateView(); 1354 updateView();
1342} 1355}
1343 1356
1344void KOMonthView::updateDayLabels() 1357void KOMonthView::updateDayLabels()
1345{ 1358{
1346 1359
1347 QPtrVector<QLabel> *mDayLabelsT; 1360 QPtrVector<QLabel> *mDayLabelsT;
1348 1361
1349 mDayLabelsT = &mDayLabelsW; 1362 mDayLabelsT = &mDayLabelsW;
1350 for (int i = 0; i < 7; i++) { 1363 for (int i = 0; i < 7; i++) {
1351 { 1364 {
1352 bool show = mShortDayLabelsW; 1365 bool show = mShortDayLabelsW;
1353 if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) 1366 if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() )
1354 show = true; 1367 show = true;
1355 (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); 1368 (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show));
1356 } 1369 }
1357 } 1370 }
1358 mDayLabelsT = &mDayLabels; 1371 mDayLabelsT = &mDayLabels;
1359 for (int i = 0; i < 7; i++) { 1372 for (int i = 0; i < 7; i++) {
1360 if (KGlobal::locale()->weekStartsMonday() || KOPrefs::instance()->mMonthViewSatSunTog ) { 1373 if (KGlobal::locale()->weekStartsMonday() || KOPrefs::instance()->mMonthViewSatSunTog ) {
1361 bool show = mShortDayLabelsM; 1374 bool show = mShortDayLabelsM;
1362 if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) 1375 if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() )
1363 show = true; 1376 show = true;
1364 (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); 1377 (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show));
1365 } else { 1378 } else {
1366 if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabelsM)); 1379 if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabelsM));
1367 else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabelsM)); 1380 else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabelsM));
1368 1381
1369 } 1382 }
1370 } 1383 }
1371 1384
1372} 1385}
1373 1386
1374void KOMonthView::showDates(const QDate &start, const QDate &) 1387void KOMonthView::showDates(const QDate &start, const QDate &)
1375{ 1388{
1376 // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl; 1389 // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl;
1377 1390
1378 QPtrVector<MonthViewCell> *cells; 1391 QPtrVector<MonthViewCell> *cells;
1379 QPtrVector<QLabel> *dayLabels; 1392 QPtrVector<QLabel> *dayLabels;
1380 QPtrVector<KOWeekButton> *weekLabels; 1393 QPtrVector<KOWeekButton> *weekLabels;
1381 int weekNum = 6; 1394 int weekNum = 6;
1382 mStartDate = start; 1395 mStartDate = start;
1383 if ( mShowWeekView ) { 1396 if ( mShowWeekView ) {
1384 weekNum = 1; 1397 weekNum = 1;
1385 cells = &mCellsW; 1398 cells = &mCellsW;
1386 dayLabels = &mDayLabelsW; 1399 dayLabels = &mDayLabelsW;
1387 weekLabels = &mWeekLabelsW; 1400 weekLabels = &mWeekLabelsW;
1388 if ( !KGlobal::locale()->weekStartsMonday() ) { 1401 if ( !KGlobal::locale()->weekStartsMonday() ) {
1389 mStartDate = mStartDate.addDays( 1 ); 1402 mStartDate = mStartDate.addDays( 1 );
1390 } 1403 }
1391 } else { 1404 } else {
1392 cells = &mCells; 1405 cells = &mCells;
1393 dayLabels = &mDayLabels; 1406 dayLabels = &mDayLabels;
1394 weekLabels = &mWeekLabels; 1407 weekLabels = &mWeekLabels;
1395 } 1408 }
1396 1409
1397 int mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); 1410 int mWeekStartsMonday = KGlobal::locale()->weekStartsMonday();
1398 1411
1399 if ( mShowWeekView || KOPrefs::instance()->mMonthViewSatSunTog ) { 1412 if ( mShowWeekView || KOPrefs::instance()->mMonthViewSatSunTog ) {
1400 mWeekStartsMonday = true; 1413 mWeekStartsMonday = true;
1401 } 1414 }
1402 int startWeekDay = mWeekStartsMonday ? 1 : 7; 1415 int startWeekDay = mWeekStartsMonday ? 1 : 7;
1403 1416
1404 while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) { 1417 while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) {
1405 mStartDate = mStartDate.addDays( -1 ); 1418 mStartDate = mStartDate.addDays( -1 );
1406 } 1419 }
1407 bool primary = false; 1420 bool primary = false;
1408 uint i; 1421 uint i;
1409 for( i = 0; i < (*cells).size(); ++i ) { 1422 for( i = 0; i < (*cells).size(); ++i ) {
1410 QDate date = mStartDate.addDays( i ); 1423 QDate date = mStartDate.addDays( i );
1411 (*cells)[i]->setDate( date ); 1424 (*cells)[i]->setDate( date );
1412 1425
1413#ifndef KORG_NOPLUGINS 1426#ifndef KORG_NOPLUGINS
1414 // add holiday, if present 1427 // add holiday, if present
1415 QString hstring(KOCore::self()->holiday(date)); 1428 QString hstring(KOCore::self()->holiday(date));
1416 (*cells)[i]->setHoliday( hstring ); 1429 (*cells)[i]->setHoliday( hstring );
1417#endif 1430#endif
1418 1431
1419 } 1432 }
1420 QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 ); 1433 QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 );
1421 for( i = 0; i < weekNum; ++i ) { 1434 for( i = 0; i < weekNum; ++i ) {
1422 int wno; 1435 int wno;
1423 // remember, according to ISO 8601, the first week of the year is the 1436 // remember, according to ISO 8601, the first week of the year is the
1424 // first week that contains a thursday. Thus we must subtract off 4, 1437 // first week that contains a thursday. Thus we must subtract off 4,
1425 // not just 1. 1438 // not just 1.
1426 int dayOfYear = date.dayOfYear(); 1439 int dayOfYear = date.dayOfYear();
1427 if (dayOfYear % 7 != 0) 1440 if (dayOfYear % 7 != 0)
1428 wno = dayOfYear / 7 + 1; 1441 wno = dayOfYear / 7 + 1;
1429 else 1442 else
1430 wno =dayOfYear / 7; 1443 wno =dayOfYear / 7;
1431 (*weekLabels)[i]->setWeekNum( wno ); 1444 (*weekLabels)[i]->setWeekNum( wno );
1432 date = date.addDays( 7 ); 1445 date = date.addDays( 7 );
1433 } 1446 }
1434 updateView(); 1447 updateView();
1435} 1448}
1436 1449
1437void KOMonthView::showEvents(QPtrList<Event>) 1450void KOMonthView::showEvents(QPtrList<Event>)
1438{ 1451{
1439 qDebug("KOMonthView::selectEvents is not implemented yet. "); 1452 qDebug("KOMonthView::selectEvents is not implemented yet. ");
1440} 1453}
1441 1454
1442void KOMonthView::changeEventDisplay(Event *, int) 1455void KOMonthView::changeEventDisplay(Event *, int)
1443{ 1456{
1444 // this should be re-written to be much more efficient, but this 1457 // this should be re-written to be much more efficient, but this
1445 // quick-and-dirty-hack gets the job done for right now. 1458 // quick-and-dirty-hack gets the job done for right now.
1446 //qDebug("KOMonthView::changeEventDisplay "); 1459 //qDebug("KOMonthView::changeEventDisplay ");
1447 updateView(); 1460 updateView();
1448} 1461}
1449 1462
1450void KOMonthView::updateView() 1463void KOMonthView::updateView()
1451{ 1464{
1452 1465
1453 if ( !updatePossible ) 1466 if ( !updatePossible )
1454 return; 1467 return;
1455 //qDebug("UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU "); 1468 //qDebug("UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU ");
1456 //QTime ti; 1469 //QTime ti;
1457 //ti.start(); 1470 //ti.start();
1458 clearSelection(); 1471 clearSelection();
1459 QPtrVector<MonthViewCell> *cells; 1472 QPtrVector<MonthViewCell> *cells;
1460 if ( mShowWeekView ) { 1473 if ( mShowWeekView ) {
1461 cells = &mCellsW; 1474 cells = &mCellsW;
1462 } else { 1475 } else {
1463 cells = &mCells; 1476 cells = &mCells;
1464 } 1477 }
1465#if 1 1478#if 1
1466 int i; 1479 int i;
1467 int timeSpan = (*cells).size()-1; 1480 int timeSpan = (*cells).size()-1;
1468 if ( KOPrefs::instance()->mMonthViewWeek ) 1481 if ( KOPrefs::instance()->mMonthViewWeek )
1469 timeSpan = 6; 1482 timeSpan = 6;
1470 for( i = 0; i < timeSpan + 1; ++i ) { 1483 for( i = 0; i < timeSpan + 1; ++i ) {
1471 (*cells)[i]->startUpdateCell(); 1484 (*cells)[i]->startUpdateCell();
1472 } 1485 }
1473 1486
1474 QPtrList<Event> events = calendar()->events(); 1487 QPtrList<Event> events = calendar()->events();
1475 Event *event; 1488 Event *event;
1476 QDateTime dt; 1489 QDateTime dt;
1477 bool ok; 1490 bool ok;
1478 QDate endDate = mStartDate.addDays( timeSpan ); 1491 QDate endDate = mStartDate.addDays( timeSpan );
1479 for( event = events.first(); event; event = events.next() ) { // for event 1492 for( event = events.first(); event; event = events.next() ) { // for event
1480 if ( event->doesRecur() ) { 1493 if ( event->doesRecur() ) {
1481 bool last; 1494 bool last;
1482 QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last ); 1495 QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last );
1483 QDateTime incidenceEnd; 1496 QDateTime incidenceEnd;
1484 int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() ); 1497 int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() );
1485 bool invalid = false; 1498 bool invalid = false;
1486 while( true ) { 1499 while( true ) {
1487 if ( incidenceStart.isValid() ) { 1500 if ( incidenceStart.isValid() ) {
1488 incidenceEnd = incidenceStart.addDays( eventlen ); 1501 incidenceEnd = incidenceStart.addDays( eventlen );
1489 int st = incidenceStart.date().daysTo( endDate ); 1502 int st = incidenceStart.date().daysTo( endDate );
1490 if ( st >= 0 ) { // start before timeend 1503 if ( st >= 0 ) { // start before timeend
1491 int end = mStartDate.daysTo( incidenceEnd.date() ); 1504 int end = mStartDate.daysTo( incidenceEnd.date() );
1492 if ( end >= 0 ) { // end after timestart --- got one! 1505 if ( end >= 0 ) { // end after timestart --- got one!
1493 //normalize 1506 //normalize
1494 st = timeSpan - st; 1507 st = timeSpan - st;
1495 if ( st < 0 ) st = 0; 1508 if ( st < 0 ) st = 0;
1496 if ( end > timeSpan ) end = timeSpan; 1509 if ( end > timeSpan ) end = timeSpan;
1497 int iii; 1510 int iii;
1498 //qDebug("found %s %d %d ",event->summary().latin1(), st, end ); 1511 //qDebug("found %s %d %d ",event->summary().latin1(), st, end );
1499 for ( iii = st;iii<= end;++iii) 1512 for ( iii = st;iii<= end;++iii)
1500 (*cells)[iii]->insertEvent( event ); 1513 (*cells)[iii]->insertEvent( event );
1501 } 1514 }
1502 } 1515 }
1503 } else { 1516 } else {
1504 if ( invalid ) 1517 if ( invalid )
1505 break; 1518 break;
1506 invalid = true; 1519 invalid = true;
1507 //qDebug("invalid %s", event->summary().latin1()); 1520 //qDebug("invalid %s", event->summary().latin1());
1508 incidenceStart = QDateTime( mStartDate ).addSecs( -2 );; 1521 incidenceStart = QDateTime( mStartDate ).addSecs( -2 );;
1509 } 1522 }
1510 if ( last ) 1523 if ( last )
1511 break; 1524 break;
1512 bool ok; 1525 bool ok;
1513 incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok ); 1526 incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok );
1514 if ( ! ok ) 1527 if ( ! ok )
1515 break; 1528 break;
1516 if ( incidenceStart.date() > endDate ) 1529 if ( incidenceStart.date() > endDate )
1517 break; 1530 break;
1518 } 1531 }
1519 } else { // no recur 1532 } else { // no recur
1520 int st = event->dtStart().date().daysTo( endDate ); 1533 int st = event->dtStart().date().daysTo( endDate );
1521 if ( st >= 0 ) { // start before timeend 1534 if ( st >= 0 ) { // start before timeend
1522 int end = mStartDate.daysTo( event->dtEnd().date() ); 1535 int end = mStartDate.daysTo( event->dtEnd().date() );
1523 if ( end >= 0 ) { // end after timestart --- got one! 1536 if ( end >= 0 ) { // end after timestart --- got one!
1524 //normalize 1537 //normalize
1525 st = timeSpan - st; 1538 st = timeSpan - st;
1526 if ( st < 0 ) st = 0; 1539 if ( st < 0 ) st = 0;
1527 if ( end > timeSpan ) end = timeSpan; 1540 if ( end > timeSpan ) end = timeSpan;
1528 int iii; 1541 int iii;
1529 for ( iii = st;iii<= end;++iii) 1542 for ( iii = st;iii<= end;++iii)
1530 (*cells)[iii]->insertEvent( event ); 1543 (*cells)[iii]->insertEvent( event );
1531 } 1544 }
1532 } 1545 }
1533 } 1546 }
1534 } 1547 }
1535 // insert due todos 1548 // insert due todos
1536 QPtrList<Todo> todos = calendar()->todos( ); 1549 QPtrList<Todo> todos = calendar()->todos( );
1537 Todo *todo; 1550 Todo *todo;
1538 for(todo = todos.first(); todo; todo = todos.next()) { 1551 for(todo = todos.first(); todo; todo = todos.next()) {
1539 //insertTodo( todo ); 1552 //insertTodo( todo );
1540 if ( todo->hasDueDate() ) { 1553 if ( todo->hasDueDate() ) {
1541 int day = mStartDate.daysTo( todo->dtDue().date() ); 1554 int day = mStartDate.daysTo( todo->dtDue().date() );
1542 if ( day >= 0 && day < timeSpan + 1) { 1555 if ( day >= 0 && day < timeSpan + 1) {
1543 (*cells)[day]->insertTodo( todo ); 1556 (*cells)[day]->insertTodo( todo );
1544 } 1557 }
1545 } 1558 }
1546 } 1559 }
1547 1560
1548 for( i = 0; i < timeSpan+1; ++i ) { 1561 for( i = 0; i < timeSpan+1; ++i ) {
1549 (*cells)[i]->finishUpdateCell(); 1562 (*cells)[i]->finishUpdateCell();
1550 } 1563 }
1551 processSelectionChange(); 1564 processSelectionChange();
1552 //qApp->processEvents(); 1565 //qApp->processEvents();
1553 for( i = 0; i < timeSpan+1; ++i ) { 1566 for( i = 0; i < timeSpan+1; ++i ) {
1554 (*cells)[i]->repaintfinishUpdateCell(); 1567 (*cells)[i]->repaintfinishUpdateCell();
1555 } 1568 }
1556 setKeyBFocus(); 1569 setKeyBFocus();
1557#else 1570#else
1558 // old code 1571 // old code
1559 //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ "); 1572 //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ");
1560 int i; 1573 int i;
1561 for( i = 0; i < (*cells).count(); ++i ) { 1574 for( i = 0; i < (*cells).count(); ++i ) {
1562 (*cells)[i]->updateCell(); 1575 (*cells)[i]->updateCell();
1563 } 1576 }
1564 1577
1565 //qDebug("KOMonthView::updateView() "); 1578 //qDebug("KOMonthView::updateView() ");
1566 processSelectionChange(); 1579 processSelectionChange();
1567 // qDebug("---------------------------------------------------------------------+ "); 1580 // qDebug("---------------------------------------------------------------------+ ");
1568 (*cells)[0]->setFocus(); 1581 (*cells)[0]->setFocus();
1569#endif 1582#endif
1570 1583
1571 //qDebug("update time %d ", ti.elapsed()); 1584 //qDebug("update time %d ", ti.elapsed());
1572} 1585}
1573 1586
1574void KOMonthView::setKeyBoardFocus() 1587void KOMonthView::setKeyBoardFocus()
1575{ 1588{
1576 //qDebug("KOMonthView::setKeyBoardFocus() "); 1589 //qDebug("KOMonthView::setKeyBoardFocus() ");
1577 bool shootAgain = false; 1590 bool shootAgain = false;
1578 if ( mShowWeekView ) { 1591 if ( mShowWeekView ) {
1579 shootAgain = !mWeekLabelsW[1]->hasFocus(); 1592 shootAgain = !mWeekLabelsW[1]->hasFocus();
1580 mWeekLabelsW[1]->setFocus(); 1593 mWeekLabelsW[1]->setFocus();
1581 } 1594 }
1582 else { 1595 else {
1583 shootAgain = !mWeekLabels[mNumWeeks]->hasFocus(); 1596 shootAgain = !mWeekLabels[mNumWeeks]->hasFocus();
1584 mWeekLabels[mNumWeeks]->setFocus(); 1597 mWeekLabels[mNumWeeks]->setFocus();
1585 } 1598 }
1586 if ( shootAgain ) { 1599 if ( shootAgain ) {
1587 QTimer::singleShot( 0, this, SLOT ( setKeyBFocus() ) ); 1600 QTimer::singleShot( 0, this, SLOT ( setKeyBFocus() ) );
1588 } 1601 }
1589} 1602}
1590void KOMonthView::setKeyBFocus() 1603void KOMonthView::setKeyBFocus()
1591{ 1604{
1592 //qDebug("KOMonthView::setKeyBFocus() "); 1605 //qDebug("KOMonthView::setKeyBFocus() ");
1593 QTimer::singleShot( 0, this, SLOT ( setKeyBoardFocus() ) ); 1606 QTimer::singleShot( 0, this, SLOT ( setKeyBoardFocus() ) );
1594} 1607}
1595void KOMonthView::resizeEvent(QResizeEvent * e) 1608void KOMonthView::resizeEvent(QResizeEvent * e)
1596{ 1609{
1597 //qDebug("KOMonthView::resizeEvent %d %d -- %d %d ", e->size().width(), e->size().height(), e->oldSize().width(), e->oldSize().height()); 1610 //qDebug("KOMonthView::resizeEvent %d %d -- %d %d ", e->size().width(), e->size().height(), e->oldSize().width(), e->oldSize().height());
1598 if ( isVisible() ) { 1611 if ( isVisible() ) {
1599 //qDebug("KOMonthView::isVisible "); 1612 //qDebug("KOMonthView::isVisible ");
1600 slotComputeLayout(); 1613 slotComputeLayout();
1601 } else 1614 } else
1602 mComputeLayoutTimer->start( 100 ); 1615 mComputeLayoutTimer->start( 100 );
1603} 1616}
1604 1617
1605void KOMonthView::slotComputeLayout() 1618void KOMonthView::slotComputeLayout()
1606{ 1619{
1607 mComputeLayoutTimer->stop(); 1620 mComputeLayoutTimer->stop();
1608 //qDebug("KOMonthView::Post - resizeEvent %d %d ", width(), height() ); 1621 //qDebug("KOMonthView::Post - resizeEvent %d %d ", width(), height() );
1609 computeLayout(); 1622 computeLayout();
1610 clPending = true; 1623 clPending = true;
1611 setKeyBFocus(); 1624 setKeyBFocus();
1612} 1625}
1613void KOMonthView::computeLayoutWeek() 1626void KOMonthView::computeLayoutWeek()
1614{ 1627{
1615 static int lastWid = 0; 1628 static int lastWid = 0;
1616 static int lastHei = 0; 1629 static int lastHei = 0;
1617 int daysToShow; 1630 int daysToShow;
1618 bool combinedSatSun = false; 1631 bool combinedSatSun = false;
1619 if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { 1632 if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) {
1620 daysToShow = 6; 1633 daysToShow = 6;
1621 combinedSatSun = true; 1634 combinedSatSun = true;
1622 } 1635 }
1623 int tWid = topLevelWidget()->size().width(); 1636 int tWid = topLevelWidget()->size().width();
1624 int tHei = topLevelWidget()->size().height(); 1637 int tHei = topLevelWidget()->size().height();
1625 1638
1626 int wid = width();//e 1639 int wid = width();//e
1627 int hei = height()-1-mNavigatorBar->height(); 1640 int hei = height()-1-mNavigatorBar->height();
1628 1641
1629 if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) 1642 if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei )
1630 return; 1643 return;
1631 1644
1632 if ( lastWid == width() && lastHei == height() ) { 1645 if ( lastWid == width() && lastHei == height() ) {
1633 //qDebug("KOListWeekView::No compute layout needed "); 1646 //qDebug("KOListWeekView::No compute layout needed ");
1634 return; 1647 return;
1635 } 1648 }
1636 lastWid = width(); 1649 lastWid = width();
1637 lastHei = height(); 1650 lastHei = height();
1638 1651
1639 1652
1640 if ( wid < hei ) 1653 if ( wid < hei )
1641 daysToShow = 2; 1654 daysToShow = 2;
1642 else 1655 else
1643 daysToShow = 3; 1656 daysToShow = 3;
1644 mShowSatSunComp = true; 1657 mShowSatSunComp = true;
1645 combinedSatSun = true; 1658 combinedSatSun = true;
1646 1659
1647 //qDebug("KOMonthView::computeLayout() WWW ------------------------------------ "); 1660 //qDebug("KOMonthView::computeLayout() WWW ------------------------------------ ");
1648 QFontMetrics fm ( mWeekLabels[0]->font() ); 1661 QFontMetrics fm ( mWeekLabels[0]->font() );
1649 int weeklabelwid = fm.width( "888" ); 1662 int weeklabelwid = fm.width( "888" );
1650 wid -= weeklabelwid; 1663 wid -= weeklabelwid;
1651 1664
1652 int colWid = wid / daysToShow; 1665 int colWid = wid / daysToShow;
1653 int lastCol = wid - ( colWid*6 ); 1666 int lastCol = wid - ( colWid*6 );
1654 int dayLabelHei = mDayLabelsW[0]->sizeHint().height(); 1667 int dayLabelHei = mDayLabelsW[0]->sizeHint().height();
1655 int cellHei = (hei - (5- daysToShow )*dayLabelHei) /(5- daysToShow ); 1668 int cellHei = (hei - (5- daysToShow )*dayLabelHei) /(5- daysToShow );
1656 int colModulo = wid % daysToShow; 1669 int colModulo = wid % daysToShow;
1657 int rowModulo = (hei- (5- daysToShow )*dayLabelHei) % daysToShow-1; 1670 int rowModulo = (hei- (5- daysToShow )*dayLabelHei) % daysToShow-1;
1658 //qDebug("rowmod %d ", rowModulo); 1671 //qDebug("rowmod %d ", rowModulo);
1659 int i; 1672 int i;
1660 int x,y,w,h; 1673 int x,y,w,h;
1661 x= 0; 1674 x= 0;
1662 y= 0; 1675 y= 0;
1663 w = colWid; 1676 w = colWid;
1664 h = dayLabelHei ; 1677 h = dayLabelHei ;
1665 for ( i = 0; i < 7; i++) { 1678 for ( i = 0; i < 7; i++) {
1666 if ( i && !( i % daysToShow) && i < 6) { 1679 if ( i && !( i % daysToShow) && i < 6) {
1667 y += hei/(5-daysToShow); 1680 y += hei/(5-daysToShow);
1668 x = 0; 1681 x = 0;
1669 w = colWid; 1682 w = colWid;
1670 } 1683 }
1671 if ( ((i) % daysToShow) >= daysToShow-colModulo ) { 1684 if ( ((i) % daysToShow) >= daysToShow-colModulo ) {
1672 ++w; 1685 ++w;
1673 } 1686 }
1674 if ( i >= 5 ) { 1687 if ( i >= 5 ) {
1675 int wi = width() - x - weeklabelwid; 1688 int wi = width() - x - weeklabelwid;
1676 if ( i == 5 ) { 1689 if ( i == 5 ) {
1677 mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,wi/2+wi%2,h); 1690 mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,wi/2+wi%2,h);
1678 } else { 1691 } else {
1679 mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,wi,h); 1692 mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,wi,h);
1680 } 1693 }
1681 x = x - w + wi - (wi/2 ); 1694 x = x - w + wi - (wi/2 );
1682 } 1695 }
1683 else { 1696 else {
1684 int wi = w; 1697 int wi = w;
1685 if ( !(( i+1) % daysToShow)) { 1698 if ( !(( i+1) % daysToShow)) {
1686 wi = width() - x - weeklabelwid; 1699 wi = width() - x - weeklabelwid;
1687 } 1700 }
1688 mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,wi,h); 1701 mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,wi,h);
1689 } 1702 }
1690 x += w; 1703 x += w;
1691 } 1704 }
1692 x= 0; 1705 x= 0;
1693 y= dayLabelHei; 1706 y= dayLabelHei;
1694 w = colWid; 1707 w = colWid;
1695 h = cellHei; 1708 h = cellHei;
1696 int max = 0; 1709 int max = 0;
1697 for ( i = 0; i < mCellsW.count(); ++i) { 1710 for ( i = 0; i < mCellsW.count(); ++i) {
1698 if ( i > 6 ) { 1711 if ( i > 6 ) {
1699 mCellsW[i]->hide(); 1712 mCellsW[i]->hide();
1700 continue; 1713 continue;
1701 } 1714 }
1702 1715
1703 w = colWid; 1716 w = colWid;
1704 if ( ((i) % daysToShow) >= daysToShow-colModulo ) { 1717 if ( ((i) % daysToShow) >= daysToShow-colModulo ) {
1705 ++w; 1718 ++w;
1706 } 1719 }
1707 if ( i == (daysToShow-1-rowModulo)*7) 1720 if ( i == (daysToShow-1-rowModulo)*7)
1708 ++h; 1721 ++h;
1709 1722
1710 if ( i >= 5 ) { 1723 if ( i >= 5 ) {
1711 if ( i ==5 ) { 1724 if ( i ==5 ) {
1712 max = h/2; 1725 max = h/2;
1713 mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,max ); 1726 mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,max );
1714 x -= w ;y += h/2; 1727 x -= w ;y += h/2;
1715 } else { 1728 } else {
1716 if ( ((i-1) % daysToShow) >= daysToShow-colModulo ) { 1729 if ( ((i-1) % daysToShow) >= daysToShow-colModulo ) {
1717 ++w; 1730 ++w;
1718 } 1731 }
1719 max = h-h/2; 1732 max = h-h/2;
1720 mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,max ); 1733 mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,max );
1721 y -= h/2; 1734 y -= h/2;
1722 } 1735 }
1723 } else { 1736 } else {
1724 max = h; 1737 max = h;
1725 mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h ); 1738 mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h );
1726 } 1739 }
1727 1740
1728 1741
1729 x += w; 1742 x += w;
1730 if ( x + w/2 > wid ) { 1743 if ( x + w/2 > wid ) {
1731 x = 0; 1744 x = 0;
1732 y += h+dayLabelHei ; 1745 y += h+dayLabelHei ;
1733 } 1746 }
1734 //mCellsW[i]->dateLabel()->setMaximumHeight( max - mCellsW[i]->lineWidth()*2 ); 1747 //mCellsW[i]->dateLabel()->setMaximumHeight( max - mCellsW[i]->lineWidth()*2 );
1735 } 1748 }
1736 y= dayLabelHei; 1749 y= dayLabelHei;
1737 h = cellHei ; 1750 h = cellHei ;
1738 mWeekLabelsW[0]->setGeometry( 0,y,weeklabelwid,hei-dayLabelHei); 1751 mWeekLabelsW[0]->setGeometry( 0,y,weeklabelwid,hei-dayLabelHei);
1739 mWeekLabelsW[1]->setGeometry( 0,0,weeklabelwid,dayLabelHei); 1752 mWeekLabelsW[1]->setGeometry( 0,0,weeklabelwid,dayLabelHei);
1740 // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); 1753 // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height());
1741 //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); 1754 //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height());
1742 mShortDayLabelsW = mDayLabelsW[0]->width()-2 < mWidthLongDayLabel ; 1755 mShortDayLabelsW = mDayLabelsW[0]->width()-2 < mWidthLongDayLabel ;
1743 updateDayLabels(); 1756 updateDayLabels();
1744 //bool forceUpdate = !updatePossible; 1757 //bool forceUpdate = !updatePossible;
1745 updatePossible = true; 1758 updatePossible = true;
1746 //mWeekLabels[mNumWeeks]->setText( i18n("M")); 1759 //mWeekLabels[mNumWeeks]->setText( i18n("M"));
1747 //if ( forceUpdate ) 1760 //if ( forceUpdate )
1748 // updateView(); 1761 // updateView();
1749} 1762}
1750void KOMonthView::computeLayout() 1763void KOMonthView::computeLayout()
1751{ 1764{
1752 1765
1753 1766
1754 static int lastWid = 0; 1767 static int lastWid = 0;
1755 static int lastHei = 0; 1768 static int lastHei = 0;
1756 1769
1757 if ( mShowWeekView ){ 1770 if ( mShowWeekView ){
1758 computeLayoutWeek(); 1771 computeLayoutWeek();
1759 return; 1772 return;
1760 } 1773 }
1761 int daysToShow = 7; 1774 int daysToShow = 7;
1762 bool combinedSatSun = false; 1775 bool combinedSatSun = false;
1763 if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { 1776 if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) {
1764 daysToShow = 6; 1777 daysToShow = 6;
1765 combinedSatSun = true; 1778 combinedSatSun = true;
1766 } 1779 }
1767 int tWid = topLevelWidget()->size().width(); 1780 int tWid = topLevelWidget()->size().width();
1768 int tHei = topLevelWidget()->size().height(); 1781 int tHei = topLevelWidget()->size().height();
1769 1782
1770 int wid = width();//e 1783 int wid = width();//e
1771 int hei = height()-1-mNavigatorBar->height(); 1784 int hei = height()-1-mNavigatorBar->height();
1772 1785
1773 if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) { 1786 if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) {
1774 return; 1787 return;
1775 } 1788 }
1776 if ( lastWid == width() && lastHei == height() ){ 1789 if ( lastWid == width() && lastHei == height() ){
1777 //qDebug("KOMonthview::No compute layout needed "); 1790 //qDebug("KOMonthview::No compute layout needed ");
1778 return; 1791 return;
1779 } 1792 }
1780 1793
1781 lastWid = width(); 1794 lastWid = width();
1782 lastHei = height(); 1795 lastHei = height();
1783 //qDebug("KOMonthView::computeLayout() MMM ------------------- "); 1796 //qDebug("KOMonthView::computeLayout() MMM ------------------- ");
1784 QFontMetrics fm ( mWeekLabels[0]->font() ); 1797 QFontMetrics fm ( mWeekLabels[0]->font() );
1785 int weeklabelwid = fm.width( "888" ); 1798 int weeklabelwid = fm.width( "888" );
1786 wid -= weeklabelwid; 1799 wid -= weeklabelwid;
1787 1800
1788 int colWid = wid / daysToShow; 1801 int colWid = wid / daysToShow;
1789 int lastCol = wid - ( colWid*6 ); 1802 int lastCol = wid - ( colWid*6 );
1790 int dayLabelHei = mDayLabels[0]->sizeHint().height(); 1803 int dayLabelHei = mDayLabels[0]->sizeHint().height();
1791 int cellHei = (hei - dayLabelHei) /6; 1804 int cellHei = (hei - dayLabelHei) /6;
1792 int colModulo = wid % daysToShow; 1805 int colModulo = wid % daysToShow;
1793 int rowModulo = (hei- dayLabelHei) % 6; 1806 int rowModulo = (hei- dayLabelHei) % 6;
1794 //qDebug("rowmod %d ", rowModulo); 1807 //qDebug("rowmod %d ", rowModulo);
1795 int i; 1808 int i;
1796 int x,y,w,h; 1809 int x,y,w,h;
1797 x= 0; 1810 x= 0;
1798 y= 0; 1811 y= 0;
1799 w = colWid; 1812 w = colWid;
1800 h = dayLabelHei ; 1813 h = dayLabelHei ;
1801 for ( i = 0; i < 7; i++) { 1814 for ( i = 0; i < 7; i++) {
1802 if ( i == daysToShow-colModulo ) 1815 if ( i == daysToShow-colModulo )
1803 ++w; 1816 ++w;
1804 if ( combinedSatSun ) { 1817 if ( combinedSatSun ) {
1805 if ( i >= daysToShow-1 ) { 1818 if ( i >= daysToShow-1 ) {
1806 1819
1807 if ( i == 6 ) 1820 if ( i == 6 )
1808 mDayLabels[i]->setGeometry( x+weeklabelwid,y,width()-x-weeklabelwid,h); 1821 mDayLabels[i]->setGeometry( x+weeklabelwid,y,width()-x-weeklabelwid,h);
1809 else 1822 else
1810 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h); 1823 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h);
1811 x -= w/2 ; 1824 x -= w/2 ;
1812 } 1825 }
1813 else 1826 else
1814 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); 1827 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h);
1815 } else 1828 } else
1816 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); 1829 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h);
1817 x += w; 1830 x += w;
1818 } 1831 }
1819 x= 0; 1832 x= 0;
1820 y= dayLabelHei; 1833 y= dayLabelHei;
1821 w = colWid; 1834 w = colWid;
1822 h = cellHei ; 1835 h = cellHei ;
1823 int max = 0; 1836 int max = 0;
1824 for ( i = 0; i < mCells.count(); ++i) { 1837 for ( i = 0; i < mCells.count(); ++i) {
1825 //qDebug("iii %d ", i); 1838 //qDebug("iii %d ", i);
1826 w = colWid; 1839 w = colWid;
1827 if ( ((i) % 7) >= 7-colModulo ) { 1840 if ( ((i) % 7) >= 7-colModulo ) {
1828 ++w; 1841 ++w;
1829 } 1842 }
1830 if ( i == (6-rowModulo)*7) 1843 if ( i == (6-rowModulo)*7)
1831 ++h; 1844 ++h;
1832 if ( combinedSatSun ) { 1845 if ( combinedSatSun ) {
1833 if ( (i)%7 >= daysToShow-1 ) { 1846 if ( (i)%7 >= daysToShow-1 ) {
1834 if ( (i)%7 == daysToShow-1 ) { 1847 if ( (i)%7 == daysToShow-1 ) {
1835 w = width()-x-weeklabelwid; 1848 w = width()-x-weeklabelwid;
1836 max = h/2; 1849 max = h/2;
1837 mCells[i]->setGeometry ( x+weeklabelwid,y,w,max ); 1850 mCells[i]->setGeometry ( x+weeklabelwid,y,w,max );
1838 x -= w ;y += h/2; 1851 x -= w ;y += h/2;
1839 } else { 1852 } else {
1840 w = width()-x-weeklabelwid; 1853 w = width()-x-weeklabelwid;
1841 max = h-h/2; 1854 max = h-h/2;
1842 mCells[i]->setGeometry ( x+weeklabelwid,y,w,max ); 1855 mCells[i]->setGeometry ( x+weeklabelwid,y,w,max );
1843 y -= h/2; 1856 y -= h/2;
1844 } 1857 }
1845 } else { 1858 } else {
1846 max = h; 1859 max = h;
1847 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); 1860 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h );
1848 } 1861 }
1849 1862
1850 } 1863 }
1851 else { 1864 else {
1852 max = h; 1865 max = h;
1853 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); 1866 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h );
1854 } 1867 }
1855 x += w; 1868 x += w;
1856 if ( x + w/2 > wid ) { 1869 if ( x + w/2 > wid ) {
1857 x = 0; 1870 x = 0;
1858 y += h; 1871 y += h;
1859 } 1872 }
1860 //mCells[i]->dateLabel()->setMaximumHeight( max- mCells[i]->lineWidth()*2 ); 1873 //mCells[i]->dateLabel()->setMaximumHeight( max- mCells[i]->lineWidth()*2 );
1861 } 1874 }
1862 y= dayLabelHei; 1875 y= dayLabelHei;
1863 h = cellHei ; 1876 h = cellHei ;
1864 for ( i = 0; i < 6; i++) { 1877 for ( i = 0; i < 6; i++) {
1865 if ( i == (6-rowModulo)) 1878 if ( i == (6-rowModulo))
1866 ++h; 1879 ++h;
1867 mWeekLabels[i]->setGeometry( 0,y,weeklabelwid,h); 1880 mWeekLabels[i]->setGeometry( 0,y,weeklabelwid,h);
1868 y += h; 1881 y += h;
1869 } 1882 }
1870 mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei); 1883 mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei);
1871 // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); 1884 // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height());
1872 //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); 1885 //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height());
1873 mShortDayLabelsM = mDayLabels[0]->width()-2 < mWidthLongDayLabel ; 1886 mShortDayLabelsM = mDayLabels[0]->width()-2 < mWidthLongDayLabel ;
1874 updateDayLabels(); 1887 updateDayLabels();
1875 //bool forceUpdate = !updatePossible; 1888 //bool forceUpdate = !updatePossible;
1876 updatePossible = true; 1889 updatePossible = true;
1877 //mWeekLabels[mNumWeeks]->setText( i18n("W")); 1890 //mWeekLabels[mNumWeeks]->setText( i18n("W"));
1878} 1891}
1879 1892
1880void KOMonthView::showContextMenu( Incidence *incidence ) 1893void KOMonthView::showContextMenu( Incidence *incidence )
1881{ 1894{
1882 mContextMenu->showIncidencePopup(incidence); 1895 mContextMenu->showIncidencePopup(incidence);
1883 /* 1896 /*
1884 if( incidence && incidence->type() == "Event" ) { 1897 if( incidence && incidence->type() == "Event" ) {
1885 Event *event = static_cast<Event *>(incidence); 1898 Event *event = static_cast<Event *>(incidence);
1886 mContextMenu->showEventPopup(event); 1899 mContextMenu->showEventPopup(event);
1887 } else { 1900 } else {
1888 kdDebug() << "MonthView::showContextMenu(): cast failed." << endl; 1901 kdDebug() << "MonthView::showContextMenu(): cast failed." << endl;
1889 } 1902 }
1890 */ 1903 */
1891} 1904}
1892MonthViewCell * KOMonthView::selectedCell( ) 1905MonthViewCell * KOMonthView::selectedCell( )
1893{ 1906{
1894 return mSelectedCell; 1907 return mSelectedCell;
1895} 1908}
1896void KOMonthView::setSelectedCell( MonthViewCell *cell ) 1909void KOMonthView::setSelectedCell( MonthViewCell *cell )
1897{ 1910{
1898 //qDebug("KOMonthView::setSelectedCell "); 1911 //qDebug("KOMonthView::setSelectedCell ");
1899 if ( mSelectedCell && mSelectedCell != cell ) { 1912 if ( mSelectedCell && mSelectedCell != cell ) {
1900 MonthViewCell * mvc = mSelectedCell; 1913 MonthViewCell * mvc = mSelectedCell;
1901 mSelectedCell = cell; 1914 mSelectedCell = cell;
1902 mvc->deselect(); 1915 mvc->deselect();
1903 } else 1916 } else
1904 mSelectedCell = cell; 1917 mSelectedCell = cell;
1905 // if ( mSelectedCell ) 1918 // if ( mSelectedCell )
1906 // mSelectedCell->select(); 1919 // mSelectedCell->select();
1907 if ( !mSelectedCell ) 1920 if ( !mSelectedCell )
1908 emit incidenceSelected( 0 ); 1921 emit incidenceSelected( 0 );
1909 else 1922 else
1910 emit incidenceSelected( mSelectedCell->selectedIncidence() ); 1923 emit incidenceSelected( mSelectedCell->selectedIncidence() );
1911} 1924}
1912 1925
1913void KOMonthView::processSelectionChange() 1926void KOMonthView::processSelectionChange()
1914{ 1927{
1915 QPtrList<Incidence> incidences = selectedIncidences(); 1928 QPtrList<Incidence> incidences = selectedIncidences();
1916 if (incidences.count() > 0) { 1929 if (incidences.count() > 0) {
1917 emit incidenceSelected( incidences.first() ); 1930 emit incidenceSelected( incidences.first() );
1918 } else { 1931 } else {
1919 emit incidenceSelected( 0 ); 1932 emit incidenceSelected( 0 );
1920 clearSelection(); 1933 clearSelection();
1921 } 1934 }
1922} 1935}
1923 1936
1924void KOMonthView::clearSelection() 1937void KOMonthView::clearSelection()
1925{ 1938{
1926 if ( mSelectedCell ) { 1939 if ( mSelectedCell ) {
1927 mSelectedCell->deselect(); 1940 mSelectedCell->deselect();
1928 mSelectedCell = 0; 1941 mSelectedCell = 0;
1929 } 1942 }
1930} 1943}
1931 1944
1932void KOMonthView::keyReleaseEvent ( QKeyEvent * e) 1945void KOMonthView::keyReleaseEvent ( QKeyEvent * e)
1933{ 1946{
1934 if ( !e->isAutoRepeat() ) { 1947 if ( !e->isAutoRepeat() ) {
1935 mFlagKeyPressed = false; 1948 mFlagKeyPressed = false;
1936 } 1949 }
1937} 1950}
1938 1951
1939void KOMonthView::keyPressEvent ( QKeyEvent * e ) 1952void KOMonthView::keyPressEvent ( QKeyEvent * e )
1940{ 1953{
1941 1954
1942 qApp->processEvents(); 1955 qApp->processEvents();
1943 if ( e->isAutoRepeat() && !mFlagKeyPressed ) { 1956 if ( e->isAutoRepeat() && !mFlagKeyPressed ) {
1944 //e->ignore(); 1957 //e->ignore();
1945 e->accept(); 1958 e->accept();
1946 return; 1959 return;
1947 } 1960 }
1948 if (! e->isAutoRepeat() ) 1961 if (! e->isAutoRepeat() )
1949 mFlagKeyPressed = true; 1962 mFlagKeyPressed = true;
1950 switch(e->key()) { 1963 switch(e->key()) {
1951 case Key_Up: 1964 case Key_Up:
1952 { 1965 {
1953 if ( mShowWeekView ) { 1966 if ( mShowWeekView ) {
1954 emit selectWeekNum ( currentWeek() - 1 ); 1967 emit selectWeekNum ( currentWeek() - 1 );
1955 } 1968 }
1956 else { 1969 else {
1957 emit prevMonth(); 1970 emit prevMonth();
1958 } 1971 }
1959 } 1972 }
1960 e->accept(); 1973 e->accept();
1961 break; 1974 break;
1962 case Key_Down: 1975 case Key_Down:
1963 { 1976 {
1964 if ( mShowWeekView ) { 1977 if ( mShowWeekView ) {
1965 emit selectWeekNum ( currentWeek() +1); 1978 emit selectWeekNum ( currentWeek() +1);
1966 } 1979 }
1967 else { 1980 else {
1968 emit nextMonth(); 1981 emit nextMonth();
1969 } 1982 }
1970 1983
1971 } 1984 }
1972 e->accept(); 1985 e->accept();
1973 break; 1986 break;
1974 case Key_Return: 1987 case Key_Return:
1975 case Key_Enter: 1988 case Key_Enter:
1976 { 1989 {
1977 selectInternalWeekNum ( currentWeek() ); 1990 selectInternalWeekNum ( currentWeek() );
1978 } 1991 }
1979 e->accept(); 1992 e->accept();
1980 break; 1993 break;
1981 case Key_D: 1994 case Key_D:
1982 if ( mSelectedCell ) { 1995 if ( mSelectedCell ) {
1983 mSelectedCell->showDay(); 1996 mSelectedCell->showDay();
1984 e->accept(); 1997 e->accept();
1985 } else { 1998 } else {
1986 e->ignore(); 1999 e->ignore();
1987 } 2000 }
1988 break; 2001 break;
1989 default: 2002 default:
1990 e->ignore(); 2003 e->ignore();
1991 break; 2004 break;
1992 } 2005 }
1993} 2006}
1994 2007
1995void KOMonthView::nextCell() 2008void KOMonthView::nextCell()
1996{ 2009{
1997 bool res = focusNextPrevChild ( true ); 2010 bool res = focusNextPrevChild ( true );
1998} 2011}
1999void KOMonthView::prevCell() 2012void KOMonthView::prevCell()
2000{ 2013{
2001 focusNextPrevChild ( false ); 2014 focusNextPrevChild ( false );
2002} 2015}