summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-10-08 23:38:07 (UTC)
committer zautrix <zautrix>2004-10-08 23:38:07 (UTC)
commit07fdef2c2ea1153d39d7114b3d5bd4abc4f4c861 (patch) (unidiff)
tree03d0e5d20e607e035e17fcdabd6bce789069f41e
parent44169895703beb3e8b1551a313d2d341bf742905 (diff)
downloadkdepimpi-07fdef2c2ea1153d39d7114b3d5bd4abc4f4c861.zip
kdepimpi-07fdef2c2ea1153d39d7114b3d5bd4abc4f4c861.tar.gz
kdepimpi-07fdef2c2ea1153d39d7114b3d5bd4abc4f4c861.tar.bz2
some bugfixes
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addressee.cpp16
-rw-r--r--kabc/addressee.h1
-rw-r--r--kaddressbook/kabcore.cpp8
-rw-r--r--kaddressbook/kabprefs.cpp3
-rw-r--r--kalarmd/simplealarmdaemonapplet.cpp1
-rw-r--r--kmicromail/koprefs.cpp381
-rw-r--r--korganizer/main.cpp6
-rw-r--r--korganizer/mainwindow.cpp6
-rw-r--r--korganizer/mainwindow.h2
-rw-r--r--libkdepim/kpimglobalprefs.cpp10
-rw-r--r--microkde/kstaticdeleter.h6
11 files changed, 40 insertions, 400 deletions
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp
index e571980..19a1845 100644
--- a/kabc/addressee.cpp
+++ b/kabc/addressee.cpp
@@ -1,1902 +1,1918 @@
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 familyName; 54 QString familyName;
55 QString givenName; 55 QString givenName;
56 QString additionalName; 56 QString additionalName;
57 QString prefix; 57 QString prefix;
58 QString suffix; 58 QString suffix;
59 QString nickName; 59 QString nickName;
60 QDateTime birthday; 60 QDateTime birthday;
61 QString mailer; 61 QString mailer;
62 TimeZone timeZone; 62 TimeZone timeZone;
63 Geo geo; 63 Geo geo;
64 QString title; 64 QString title;
65 QString role; 65 QString role;
66 QString organization; 66 QString organization;
67 QString note; 67 QString note;
68 QString productId; 68 QString productId;
69 QDateTime revision; 69 QDateTime revision;
70 QString sortString; 70 QString sortString;
71 QString externalUID; 71 QString externalUID;
72 QString originalExternalUID; 72 QString originalExternalUID;
73 KURL url; 73 KURL url;
74 Secrecy secrecy; 74 Secrecy secrecy;
75 Picture logo; 75 Picture logo;
76 Picture photo; 76 Picture photo;
77 Sound sound; 77 Sound sound;
78 Agent agent; 78 Agent agent;
79 QString mExternalId; 79 QString mExternalId;
80 PhoneNumber::List phoneNumbers; 80 PhoneNumber::List phoneNumbers;
81 Address::List addresses; 81 Address::List addresses;
82 Key::List keys; 82 Key::List keys;
83 QStringList emails; 83 QStringList emails;
84 QStringList categories; 84 QStringList categories;
85 QStringList custom; 85 QStringList custom;
86 int mTempSyncStat; 86 int mTempSyncStat;
87 Resource *resource; 87 Resource *resource;
88 88
89 bool empty :1; 89 bool empty :1;
90 bool changed :1; 90 bool changed :1;
91}; 91};
92 92
93Addressee::Addressee() 93Addressee::Addressee()
94{ 94{
95 mData = new AddresseeData; 95 mData = new AddresseeData;
96 mData->empty = true; 96 mData->empty = true;
97 mData->changed = false; 97 mData->changed = false;
98 mData->resource = 0; 98 mData->resource = 0;
99 mData->mExternalId = ":"; 99 mData->mExternalId = ":";
100 mData->revision = QDateTime ( QDate( 2003,1,1)); 100 mData->revision = QDateTime ( QDate( 2003,1,1));
101 mData->mTempSyncStat = SYNC_TEMPSTATE_INITIAL; 101 mData->mTempSyncStat = SYNC_TEMPSTATE_INITIAL;
102} 102}
103 103
104Addressee::~Addressee() 104Addressee::~Addressee()
105{ 105{
106} 106}
107 107
108Addressee::Addressee( const Addressee &a ) 108Addressee::Addressee( const Addressee &a )
109{ 109{
110 mData = a.mData; 110 mData = a.mData;
111} 111}
112 112
113Addressee &Addressee::operator=( const Addressee &a ) 113Addressee &Addressee::operator=( const Addressee &a )
114{ 114{
115 mData = a.mData; 115 mData = a.mData;
116 return (*this); 116 return (*this);
117} 117}
118 118
119Addressee Addressee::copy() 119Addressee Addressee::copy()
120{ 120{
121 Addressee a; 121 Addressee a;
122 *(a.mData) = *mData; 122 *(a.mData) = *mData;
123 return a; 123 return a;
124} 124}
125 125
126void Addressee::detach() 126void Addressee::detach()
127{ 127{
128 if ( mData.count() == 1 ) return; 128 if ( mData.count() == 1 ) return;
129 *this = copy(); 129 *this = copy();
130} 130}
131 131
132bool Addressee::operator==( const Addressee &a ) const 132bool Addressee::operator==( const Addressee &a ) const
133{ 133{
134 if ( uid() != a.uid() ) return false; 134 if ( uid() != a.uid() ) return false;
135 if ( mData->name != a.mData->name ) return false; 135 if ( mData->name != a.mData->name ) return false;
136 if ( mData->formattedName != a.mData->formattedName ) return false; 136 if ( mData->formattedName != a.mData->formattedName ) return false;
137 if ( mData->familyName != a.mData->familyName ) return false; 137 if ( mData->familyName != a.mData->familyName ) return false;
138 if ( mData->givenName != a.mData->givenName ) return false; 138 if ( mData->givenName != a.mData->givenName ) return false;
139 if ( mData->additionalName != a.mData->additionalName ) return false; 139 if ( mData->additionalName != a.mData->additionalName ) return false;
140 if ( mData->prefix != a.mData->prefix ) return false; 140 if ( mData->prefix != a.mData->prefix ) return false;
141 if ( mData->suffix != a.mData->suffix ) return false; 141 if ( mData->suffix != a.mData->suffix ) return false;
142 if ( mData->nickName != a.mData->nickName ) return false; 142 if ( mData->nickName != a.mData->nickName ) return false;
143 if ( mData->birthday != a.mData->birthday ) return false; 143 if ( mData->birthday != a.mData->birthday ) return false;
144 if ( mData->mailer != a.mData->mailer ) return false; 144 if ( mData->mailer != a.mData->mailer ) return false;
145 if ( mData->timeZone != a.mData->timeZone ) return false; 145 if ( mData->timeZone != a.mData->timeZone ) return false;
146 if ( mData->geo != a.mData->geo ) return false; 146 if ( mData->geo != a.mData->geo ) return false;
147 if ( mData->title != a.mData->title ) return false; 147 if ( mData->title != a.mData->title ) return false;
148 if ( mData->role != a.mData->role ) return false; 148 if ( mData->role != a.mData->role ) return false;
149 if ( mData->organization != a.mData->organization ) return false; 149 if ( mData->organization != a.mData->organization ) return false;
150 if ( mData->note != a.mData->note ) return false; 150 if ( mData->note != a.mData->note ) return false;
151 if ( mData->productId != a.mData->productId ) return false; 151 if ( mData->productId != a.mData->productId ) return false;
152 //if ( mData->revision != a.mData->revision ) return false; 152 //if ( mData->revision != a.mData->revision ) return false;
153 if ( mData->sortString != a.mData->sortString ) return false; 153 if ( mData->sortString != a.mData->sortString ) return false;
154 if ( mData->secrecy != a.mData->secrecy ) return false; 154 if ( mData->secrecy != a.mData->secrecy ) return false;
155 if ( mData->logo != a.mData->logo ) return false; 155 if ( mData->logo != a.mData->logo ) return false;
156 if ( mData->photo != a.mData->photo ) return false; 156 if ( mData->photo != a.mData->photo ) return false;
157 if ( mData->sound != a.mData->sound ) return false; 157 if ( mData->sound != a.mData->sound ) return false;
158 if ( mData->agent != a.mData->agent ) return false; 158 if ( mData->agent != a.mData->agent ) return false;
159 if ( ( mData->url.isValid() || a.mData->url.isValid() ) && 159 if ( ( mData->url.isValid() || a.mData->url.isValid() ) &&
160 ( mData->url != a.mData->url ) ) return false; 160 ( mData->url != a.mData->url ) ) return false;
161 if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false; 161 if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false;
162 if ( mData->addresses != a.mData->addresses ) return false; 162 if ( mData->addresses != a.mData->addresses ) return false;
163 if ( mData->keys != a.mData->keys ) return false; 163 if ( mData->keys != a.mData->keys ) return false;
164 if ( mData->emails != a.mData->emails ) return false; 164 if ( mData->emails != a.mData->emails ) return false;
165 if ( mData->categories != a.mData->categories ) return false; 165 if ( mData->categories != a.mData->categories ) return false;
166 if ( mData->custom != a.mData->custom ) return false; 166 if ( mData->custom != a.mData->custom ) return false;
167 167
168 return true; 168 return true;
169} 169}
170 170
171bool Addressee::operator!=( const Addressee &a ) const 171bool Addressee::operator!=( const Addressee &a ) const
172{ 172{
173 return !( a == *this ); 173 return !( a == *this );
174} 174}
175 175
176bool Addressee::isEmpty() const 176bool Addressee::isEmpty() const
177{ 177{
178 return mData->empty; 178 return mData->empty;
179} 179}
180ulong Addressee::getCsum4List( const QStringList & attList) 180ulong Addressee::getCsum4List( const QStringList & attList)
181{ 181{
182 int max = attList.count(); 182 int max = attList.count();
183 ulong cSum = 0; 183 ulong cSum = 0;
184 int j,k,i; 184 int j,k,i;
185 int add; 185 int add;
186 for ( i = 0; i < max ; ++i ) { 186 for ( i = 0; i < max ; ++i ) {
187 QString s = attList[i]; 187 QString s = attList[i];
188 if ( ! s.isEmpty() ){ 188 if ( ! s.isEmpty() ){
189 j = s.length(); 189 j = s.length();
190 for ( k = 0; k < j; ++k ) { 190 for ( k = 0; k < j; ++k ) {
191 int mul = k +1; 191 int mul = k +1;
192 add = s[k].unicode (); 192 add = s[k].unicode ();
193 if ( k < 16 ) 193 if ( k < 16 )
194 mul = mul * mul; 194 mul = mul * mul;
195 int ii = i+1; 195 int ii = i+1;
196 add = add * mul *ii*ii*ii; 196 add = add * mul *ii*ii*ii;
197 cSum += add; 197 cSum += add;
198 } 198 }
199 } 199 }
200 200
201 } 201 }
202 //QString dump = attList.join(","); 202 //QString dump = attList.join(",");
203 //qDebug("csum: %d %s", cSum,dump.latin1()); 203 //qDebug("csum: %d %s", cSum,dump.latin1());
204 204
205 return cSum; 205 return cSum;
206 206
207} 207}
208void Addressee::computeCsum(const QString &dev) 208void Addressee::computeCsum(const QString &dev)
209{ 209{
210 QStringList l; 210 QStringList l;
211 if ( !mData->name.isEmpty() ) l.append(mData->name); 211 if ( !mData->name.isEmpty() ) l.append(mData->name);
212 if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName ); 212 if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName );
213 if ( !mData->familyName.isEmpty() ) l.append( mData->familyName ); 213 if ( !mData->familyName.isEmpty() ) l.append( mData->familyName );
214 if ( !mData->givenName.isEmpty() ) l.append(mData->givenName ); 214 if ( !mData->givenName.isEmpty() ) l.append(mData->givenName );
215 if ( !mData->additionalName ) l.append( mData->additionalName ); 215 if ( !mData->additionalName ) l.append( mData->additionalName );
216 if ( !mData->prefix.isEmpty() ) l.append( mData->prefix ); 216 if ( !mData->prefix.isEmpty() ) l.append( mData->prefix );
217 if ( !mData->suffix.isEmpty() ) l.append( mData->suffix ); 217 if ( !mData->suffix.isEmpty() ) l.append( mData->suffix );
218 if ( !mData->nickName.isEmpty() ) l.append( mData->nickName ); 218 if ( !mData->nickName.isEmpty() ) l.append( mData->nickName );
219 if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() ); 219 if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() );
220 if ( !mData->mailer.isEmpty() ) l.append( mData->mailer ); 220 if ( !mData->mailer.isEmpty() ) l.append( mData->mailer );
221 if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() ); 221 if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() );
222 if ( mData->geo.isValid() ) l.append( mData->geo.asString() ); 222 if ( mData->geo.isValid() ) l.append( mData->geo.asString() );
223 if ( !mData->title .isEmpty() ) l.append( mData->title ); 223 if ( !mData->title .isEmpty() ) l.append( mData->title );
224 if ( !mData->role.isEmpty() ) l.append( mData->role ); 224 if ( !mData->role.isEmpty() ) l.append( mData->role );
225 if ( !mData->organization.isEmpty() ) l.append( mData->organization ); 225 if ( !mData->organization.isEmpty() ) l.append( mData->organization );
226 if ( !mData->note.isEmpty() ) l.append( mData->note ); 226 if ( !mData->note.isEmpty() ) l.append( mData->note );
227 if ( !mData->productId.isEmpty() ) l.append(mData->productId ); 227 if ( !mData->productId.isEmpty() ) l.append(mData->productId );
228 if ( !mData->sortString.isEmpty() ) l.append( mData->sortString ); 228 if ( !mData->sortString.isEmpty() ) l.append( mData->sortString );
229 if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString()); 229 if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString());
230 // if ( !mData->logo.isEmpty() ) l.append( ); 230 // if ( !mData->logo.isEmpty() ) l.append( );
231 //if ( !mData->photo.isEmpty() ) l.append( ); 231 //if ( !mData->photo.isEmpty() ) l.append( );
232 //if ( !mData->sound.isEmpty() ) l.append( ); 232 //if ( !mData->sound.isEmpty() ) l.append( );
233 //if ( !mData->agent.isEmpty() ) l.append( ); 233 //if ( !mData->agent.isEmpty() ) l.append( );
234 //if ( mData->url.isValid() ) l.append( ); 234 //if ( mData->url.isValid() ) l.append( );
235#if 0 235#if 0
236 if ( !mData->phoneNumbers.isEmpty() ) l.append( ); 236 if ( !mData->phoneNumbers.isEmpty() ) l.append( );
237 if ( !mData->addresses.isEmpty() ) l.append( ); 237 if ( !mData->addresses.isEmpty() ) l.append( );
238 //if ( !mData->keys.isEmpty() ) l.append( ); 238 //if ( !mData->keys.isEmpty() ) l.append( );
239 if ( !mData->emails.isEmpty() ) l.append( ); 239 if ( !mData->emails.isEmpty() ) l.append( );
240 if ( !mData->categories .isEmpty() ) l.append( ); 240 if ( !mData->categories .isEmpty() ) l.append( );
241 if ( !mData->custom.isEmpty() ) l.append( ); 241 if ( !mData->custom.isEmpty() ) l.append( );
242#endif 242#endif
243 KABC::PhoneNumber::List phoneNumbers; 243 KABC::PhoneNumber::List phoneNumbers;
244 KABC::PhoneNumber::List::Iterator phoneIter; 244 KABC::PhoneNumber::List::Iterator phoneIter;
245 245
246 QStringList t; 246 QStringList t;
247 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 247 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
248 ++phoneIter ) 248 ++phoneIter )
249 t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) ); 249 t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) );
250 t.sort(); 250 t.sort();
251 uint iii; 251 uint iii;
252 for ( iii = 0; iii < t.count(); ++iii) 252 for ( iii = 0; iii < t.count(); ++iii)
253 l.append( t[iii] ); 253 l.append( t[iii] );
254 t = mData->emails; 254 t = mData->emails;
255 t.sort(); 255 t.sort();
256 for ( iii = 0; iii < t.count(); ++iii) 256 for ( iii = 0; iii < t.count(); ++iii)
257 l.append( t[iii] ); 257 l.append( t[iii] );
258 t = mData->categories; 258 t = mData->categories;
259 t.sort(); 259 t.sort();
260 for ( iii = 0; iii < t.count(); ++iii) 260 for ( iii = 0; iii < t.count(); ++iii)
261 l.append( t[iii] ); 261 l.append( t[iii] );
262 t = mData->custom; 262 t = mData->custom;
263 t.sort(); 263 t.sort();
264 for ( iii = 0; iii < t.count(); ++iii) 264 for ( iii = 0; iii < t.count(); ++iii)
265 l.append( t[iii] ); 265 l.append( t[iii] );
266 KABC::Address::List::Iterator addressIter; 266 KABC::Address::List::Iterator addressIter;
267 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); 267 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end();
268 ++addressIter ) { 268 ++addressIter ) {
269 t = (*addressIter).asList(); 269 t = (*addressIter).asList();
270 t.sort(); 270 t.sort();
271 for ( iii = 0; iii < t.count(); ++iii) 271 for ( iii = 0; iii < t.count(); ++iii)
272 l.append( t[iii] ); 272 l.append( t[iii] );
273 } 273 }
274 uint cs = getCsum4List(l); 274 uint cs = getCsum4List(l);
275 // qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); 275 // qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() );
276 setCsum( dev, QString::number (cs )); 276 setCsum( dev, QString::number (cs ));
277} 277}
278 278
279void Addressee::mergeContact( const Addressee& ad ) 279void Addressee::mergeContact( const Addressee& ad )
280{ 280{
281 281
282 detach(); 282 detach();
283 if ( mData->name.isEmpty() ) mData->name = ad.mData->name; 283 if ( mData->name.isEmpty() ) mData->name = ad.mData->name;
284 if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName; 284 if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName;
285 if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName; 285 if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName;
286 if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ; 286 if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ;
287 if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName; 287 if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName;
288 if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix; 288 if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix;
289 if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix; 289 if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix;
290 if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName; 290 if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName;
291 if ( !mData->birthday.isValid() ) 291 if ( !mData->birthday.isValid() )
292 if ( ad.mData->birthday.isValid()) 292 if ( ad.mData->birthday.isValid())
293 mData->birthday = ad.mData->birthday; 293 mData->birthday = ad.mData->birthday;
294 if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer; 294 if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer;
295 if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone; 295 if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone;
296 if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo; 296 if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo;
297 if ( mData->title .isEmpty() ) mData->title = ad.mData->title ; 297 if ( mData->title .isEmpty() ) mData->title = ad.mData->title ;
298 if ( mData->role.isEmpty() ) mData->role = ad.mData->role ; 298 if ( mData->role.isEmpty() ) mData->role = ad.mData->role ;
299 if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ; 299 if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ;
300 if ( mData->note.isEmpty() ) mData->note = ad.mData->note ; 300 if ( mData->note.isEmpty() ) mData->note = ad.mData->note ;
301 if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId; 301 if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId;
302 if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString; 302 if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString;
303 if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy; 303 if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy;
304 if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ; 304 if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ;
305 305
306 // pending: 306 // pending:
307 // merging phonenumbers 307 // merging phonenumbers
308 // merging addresses 308 // merging addresses
309 // merging emails; 309 // merging emails;
310 // merging categories; 310 // merging categories;
311 // merging custom; 311 // merging custom;
312 // merging keys 312 // merging keys
313 qDebug("merge contact %s ", ad.uid().latin1()); 313 qDebug("merge contact %s ", ad.uid().latin1());
314 setUid( ad.uid() ); 314 setUid( ad.uid() );
315 setRevision( ad.revision() ); 315 setRevision( ad.revision() );
316} 316}
317 317
318void Addressee::simplifyAddresses()
319{
320 if ( mData->addresses.count() < 3 ) return ;
321 int count = 0;
322 Address::List list;
323 Address::List::Iterator it;
324 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
325 if ( count > 1 )
326 list.append( *it );
327 ++count;
328 }
329 for( it = list.begin(); it != list.end(); ++it ) {
330 removeAddress( (*it) );
331 }
332}
333
318// removes all emails but the first 334// removes all emails but the first
319// needed by phone sync 335// needed by phone sync
320void Addressee::simplifyEmails() 336void Addressee::simplifyEmails()
321{ 337{
322 if ( mData->emails.count() == 0 ) return ; 338 if ( mData->emails.count() == 0 ) return ;
323 QString email = mData->emails.first(); 339 QString email = mData->emails.first();
324 detach(); 340 detach();
325 mData->emails.clear(); 341 mData->emails.clear();
326 mData->emails.append( email ); 342 mData->emails.append( email );
327} 343}
328 344
329void Addressee::simplifyPhoneNumbers() 345void Addressee::simplifyPhoneNumbers()
330{ 346{
331 KABC::PhoneNumber::List removeNumbers; 347 KABC::PhoneNumber::List removeNumbers;
332 KABC::PhoneNumber::List::Iterator phoneIter; 348 KABC::PhoneNumber::List::Iterator phoneIter;
333 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 349 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
334 ++phoneIter ) { 350 ++phoneIter ) {
335 if ( ! ( *phoneIter ).simplifyNumber() ) 351 if ( ! ( *phoneIter ).simplifyNumber() )
336 removeNumbers.append( ( *phoneIter ) ); 352 removeNumbers.append( ( *phoneIter ) );
337 } 353 }
338 for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); 354 for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end();
339 ++phoneIter ) { 355 ++phoneIter ) {
340 removePhoneNumber(( *phoneIter )); 356 removePhoneNumber(( *phoneIter ));
341 } 357 }
342} 358}
343void Addressee::simplifyPhoneNumberTypes() 359void Addressee::simplifyPhoneNumberTypes()
344{ 360{
345 KABC::PhoneNumber::List::Iterator phoneIter; 361 KABC::PhoneNumber::List::Iterator phoneIter;
346 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 362 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
347 ++phoneIter ) 363 ++phoneIter )
348 ( *phoneIter ).simplifyType(); 364 ( *phoneIter ).simplifyType();
349} 365}
350void Addressee::removeID(const QString &prof) 366void Addressee::removeID(const QString &prof)
351{ 367{
352 detach(); 368 detach();
353 mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof); 369 mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof);
354 370
355} 371}
356void Addressee::setID( const QString & prof , const QString & id ) 372void Addressee::setID( const QString & prof , const QString & id )
357{ 373{
358 detach(); 374 detach();
359 mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id ); 375 mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id );
360 //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); 376 //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() );
361} 377}
362void Addressee::setTempSyncStat( int id ) 378void Addressee::setTempSyncStat( int id )
363{ 379{
364 if ( mData->mTempSyncStat == id ) return; 380 if ( mData->mTempSyncStat == id ) return;
365 detach(); 381 detach();
366 mData->mTempSyncStat = id; 382 mData->mTempSyncStat = id;
367} 383}
368int Addressee::tempSyncStat() const 384int Addressee::tempSyncStat() const
369{ 385{
370 return mData->mTempSyncStat; 386 return mData->mTempSyncStat;
371} 387}
372 388
373QString Addressee::getID( const QString & prof) 389QString Addressee::getID( const QString & prof)
374{ 390{
375 return KIdManager::getId ( mData->mExternalId, prof ); 391 return KIdManager::getId ( mData->mExternalId, prof );
376} 392}
377 393
378void Addressee::setCsum( const QString & prof , const QString & id ) 394void Addressee::setCsum( const QString & prof , const QString & id )
379{ 395{
380 detach(); 396 detach();
381 //qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); 397 //qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() );
382 mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id ); 398 mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id );
383 //qDebug("setcsum2 %s ",mData->mExternalId.latin1() ); 399 //qDebug("setcsum2 %s ",mData->mExternalId.latin1() );
384} 400}
385 401
386QString Addressee::getCsum( const QString & prof) 402QString Addressee::getCsum( const QString & prof)
387{ 403{
388 return KIdManager::getCsum ( mData->mExternalId, prof ); 404 return KIdManager::getCsum ( mData->mExternalId, prof );
389} 405}
390 406
391void Addressee::setIDStr( const QString & s ) 407void Addressee::setIDStr( const QString & s )
392{ 408{
393 detach(); 409 detach();
394 mData->mExternalId = s; 410 mData->mExternalId = s;
395} 411}
396 412
397QString Addressee::IDStr() const 413QString Addressee::IDStr() const
398{ 414{
399 return mData->mExternalId; 415 return mData->mExternalId;
400} 416}
401 417
402void Addressee::setExternalUID( const QString &id ) 418void Addressee::setExternalUID( const QString &id )
403{ 419{
404 if ( id == mData->externalUID ) return; 420 if ( id == mData->externalUID ) return;
405 detach(); 421 detach();
406 mData->empty = false; 422 mData->empty = false;
407 mData->externalUID = id; 423 mData->externalUID = id;
408} 424}
409 425
410QString Addressee::externalUID() const 426QString Addressee::externalUID() const
411{ 427{
412 return mData->externalUID; 428 return mData->externalUID;
413} 429}
414void Addressee::setOriginalExternalUID( const QString &id ) 430void Addressee::setOriginalExternalUID( const QString &id )
415{ 431{
416 if ( id == mData->originalExternalUID ) return; 432 if ( id == mData->originalExternalUID ) return;
417 detach(); 433 detach();
418 mData->empty = false; 434 mData->empty = false;
419 //qDebug("*******Set orig uid %s ", id.latin1()); 435 //qDebug("*******Set orig uid %s ", id.latin1());
420 mData->originalExternalUID = id; 436 mData->originalExternalUID = id;
421} 437}
422 438
423QString Addressee::originalExternalUID() const 439QString Addressee::originalExternalUID() const
424{ 440{
425 return mData->originalExternalUID; 441 return mData->originalExternalUID;
426} 442}
427 443
428void Addressee::setUid( const QString &id ) 444void Addressee::setUid( const QString &id )
429{ 445{
430 if ( id == mData->uid ) return; 446 if ( id == mData->uid ) return;
431 detach(); 447 detach();
432 //qDebug("****setuid %s ", id.latin1()); 448 //qDebug("****setuid %s ", id.latin1());
433 mData->empty = false; 449 mData->empty = false;
434 mData->uid = id; 450 mData->uid = id;
435} 451}
436 452
437QString Addressee::uid() const 453QString Addressee::uid() const
438{ 454{
439 if ( mData->uid.isEmpty() ) 455 if ( mData->uid.isEmpty() )
440 mData->uid = KApplication::randomString( 10 ); 456 mData->uid = KApplication::randomString( 10 );
441 457
442 return mData->uid; 458 return mData->uid;
443} 459}
444 460
445QString Addressee::uidLabel() 461QString Addressee::uidLabel()
446{ 462{
447 return i18n("Unique Identifier"); 463 return i18n("Unique Identifier");
448} 464}
449 465
450void Addressee::setName( const QString &name ) 466void Addressee::setName( const QString &name )
451{ 467{
452 if ( name == mData->name ) return; 468 if ( name == mData->name ) return;
453 detach(); 469 detach();
454 mData->empty = false; 470 mData->empty = false;
455 mData->name = name; 471 mData->name = name;
456} 472}
457 473
458QString Addressee::name() const 474QString Addressee::name() const
459{ 475{
460 return mData->name; 476 return mData->name;
461} 477}
462 478
463QString Addressee::nameLabel() 479QString Addressee::nameLabel()
464{ 480{
465 return i18n("Name"); 481 return i18n("Name");
466} 482}
467 483
468 484
469void Addressee::setFormattedName( const QString &formattedName ) 485void Addressee::setFormattedName( const QString &formattedName )
470{ 486{
471 if ( formattedName == mData->formattedName ) return; 487 if ( formattedName == mData->formattedName ) return;
472 detach(); 488 detach();
473 mData->empty = false; 489 mData->empty = false;
474 mData->formattedName = formattedName; 490 mData->formattedName = formattedName;
475} 491}
476 492
477QString Addressee::formattedName() const 493QString Addressee::formattedName() const
478{ 494{
479 return mData->formattedName; 495 return mData->formattedName;
480} 496}
481 497
482QString Addressee::formattedNameLabel() 498QString Addressee::formattedNameLabel()
483{ 499{
484 return i18n("Formatted Name"); 500 return i18n("Formatted Name");
485} 501}
486 502
487 503
488void Addressee::setFamilyName( const QString &familyName ) 504void Addressee::setFamilyName( const QString &familyName )
489{ 505{
490 if ( familyName == mData->familyName ) return; 506 if ( familyName == mData->familyName ) return;
491 detach(); 507 detach();
492 mData->empty = false; 508 mData->empty = false;
493 mData->familyName = familyName; 509 mData->familyName = familyName;
494} 510}
495 511
496QString Addressee::familyName() const 512QString Addressee::familyName() const
497{ 513{
498 return mData->familyName; 514 return mData->familyName;
499} 515}
500 516
501QString Addressee::familyNameLabel() 517QString Addressee::familyNameLabel()
502{ 518{
503 return i18n("Family Name"); 519 return i18n("Family Name");
504} 520}
505 521
506 522
507void Addressee::setGivenName( const QString &givenName ) 523void Addressee::setGivenName( const QString &givenName )
508{ 524{
509 if ( givenName == mData->givenName ) return; 525 if ( givenName == mData->givenName ) return;
510 detach(); 526 detach();
511 mData->empty = false; 527 mData->empty = false;
512 mData->givenName = givenName; 528 mData->givenName = givenName;
513} 529}
514 530
515QString Addressee::givenName() const 531QString Addressee::givenName() const
516{ 532{
517 return mData->givenName; 533 return mData->givenName;
518} 534}
519 535
520QString Addressee::givenNameLabel() 536QString Addressee::givenNameLabel()
521{ 537{
522 return i18n("Given Name"); 538 return i18n("Given Name");
523} 539}
524 540
525 541
526void Addressee::setAdditionalName( const QString &additionalName ) 542void Addressee::setAdditionalName( const QString &additionalName )
527{ 543{
528 if ( additionalName == mData->additionalName ) return; 544 if ( additionalName == mData->additionalName ) return;
529 detach(); 545 detach();
530 mData->empty = false; 546 mData->empty = false;
531 mData->additionalName = additionalName; 547 mData->additionalName = additionalName;
532} 548}
533 549
534QString Addressee::additionalName() const 550QString Addressee::additionalName() const
535{ 551{
536 return mData->additionalName; 552 return mData->additionalName;
537} 553}
538 554
539QString Addressee::additionalNameLabel() 555QString Addressee::additionalNameLabel()
540{ 556{
541 return i18n("Additional Names"); 557 return i18n("Additional Names");
542} 558}
543 559
544 560
545void Addressee::setPrefix( const QString &prefix ) 561void Addressee::setPrefix( const QString &prefix )
546{ 562{
547 if ( prefix == mData->prefix ) return; 563 if ( prefix == mData->prefix ) return;
548 detach(); 564 detach();
549 mData->empty = false; 565 mData->empty = false;
550 mData->prefix = prefix; 566 mData->prefix = prefix;
551} 567}
552 568
553QString Addressee::prefix() const 569QString Addressee::prefix() const
554{ 570{
555 return mData->prefix; 571 return mData->prefix;
556} 572}
557 573
558QString Addressee::prefixLabel() 574QString Addressee::prefixLabel()
559{ 575{
560 return i18n("Honorific Prefixes"); 576 return i18n("Honorific Prefixes");
561} 577}
562 578
563 579
564void Addressee::setSuffix( const QString &suffix ) 580void Addressee::setSuffix( const QString &suffix )
565{ 581{
566 if ( suffix == mData->suffix ) return; 582 if ( suffix == mData->suffix ) return;
567 detach(); 583 detach();
568 mData->empty = false; 584 mData->empty = false;
569 mData->suffix = suffix; 585 mData->suffix = suffix;
570} 586}
571 587
572QString Addressee::suffix() const 588QString Addressee::suffix() const
573{ 589{
574 return mData->suffix; 590 return mData->suffix;
575} 591}
576 592
577QString Addressee::suffixLabel() 593QString Addressee::suffixLabel()
578{ 594{
579 return i18n("Honorific Suffixes"); 595 return i18n("Honorific Suffixes");
580} 596}
581 597
582 598
583void Addressee::setNickName( const QString &nickName ) 599void Addressee::setNickName( const QString &nickName )
584{ 600{
585 if ( nickName == mData->nickName ) return; 601 if ( nickName == mData->nickName ) return;
586 detach(); 602 detach();
587 mData->empty = false; 603 mData->empty = false;
588 mData->nickName = nickName; 604 mData->nickName = nickName;
589} 605}
590 606
591QString Addressee::nickName() const 607QString Addressee::nickName() const
592{ 608{
593 return mData->nickName; 609 return mData->nickName;
594} 610}
595 611
596QString Addressee::nickNameLabel() 612QString Addressee::nickNameLabel()
597{ 613{
598 return i18n("Nick Name"); 614 return i18n("Nick Name");
599} 615}
600 616
601 617
602void Addressee::setBirthday( const QDateTime &birthday ) 618void Addressee::setBirthday( const QDateTime &birthday )
603{ 619{
604 if ( birthday == mData->birthday ) return; 620 if ( birthday == mData->birthday ) return;
605 detach(); 621 detach();
606 mData->empty = false; 622 mData->empty = false;
607 mData->birthday = birthday; 623 mData->birthday = birthday;
608} 624}
609 625
610QDateTime Addressee::birthday() const 626QDateTime Addressee::birthday() const
611{ 627{
612 return mData->birthday; 628 return mData->birthday;
613} 629}
614 630
615QString Addressee::birthdayLabel() 631QString Addressee::birthdayLabel()
616{ 632{
617 return i18n("Birthday"); 633 return i18n("Birthday");
618} 634}
619 635
620 636
621QString Addressee::homeAddressStreetLabel() 637QString Addressee::homeAddressStreetLabel()
622{ 638{
623 return i18n("Home Address Street"); 639 return i18n("Home Address Street");
624} 640}
625 641
626 642
627QString Addressee::homeAddressLocalityLabel() 643QString Addressee::homeAddressLocalityLabel()
628{ 644{
629 return i18n("Home Address Locality"); 645 return i18n("Home Address Locality");
630} 646}
631 647
632 648
633QString Addressee::homeAddressRegionLabel() 649QString Addressee::homeAddressRegionLabel()
634{ 650{
635 return i18n("Home Address Region"); 651 return i18n("Home Address Region");
636} 652}
637 653
638 654
639QString Addressee::homeAddressPostalCodeLabel() 655QString Addressee::homeAddressPostalCodeLabel()
640{ 656{
641 return i18n("Home Address Postal Code"); 657 return i18n("Home Address Postal Code");
642} 658}
643 659
644 660
645QString Addressee::homeAddressCountryLabel() 661QString Addressee::homeAddressCountryLabel()
646{ 662{
647 return i18n("Home Address Country"); 663 return i18n("Home Address Country");
648} 664}
649 665
650 666
651QString Addressee::homeAddressLabelLabel() 667QString Addressee::homeAddressLabelLabel()
652{ 668{
653 return i18n("Home Address Label"); 669 return i18n("Home Address Label");
654} 670}
655 671
656 672
657QString Addressee::businessAddressStreetLabel() 673QString Addressee::businessAddressStreetLabel()
658{ 674{
659 return i18n("Business Address Street"); 675 return i18n("Business Address Street");
660} 676}
661 677
662 678
663QString Addressee::businessAddressLocalityLabel() 679QString Addressee::businessAddressLocalityLabel()
664{ 680{
665 return i18n("Business Address Locality"); 681 return i18n("Business Address Locality");
666} 682}
667 683
668 684
669QString Addressee::businessAddressRegionLabel() 685QString Addressee::businessAddressRegionLabel()
670{ 686{
671 return i18n("Business Address Region"); 687 return i18n("Business Address Region");
672} 688}
673 689
674 690
675QString Addressee::businessAddressPostalCodeLabel() 691QString Addressee::businessAddressPostalCodeLabel()
676{ 692{
677 return i18n("Business Address Postal Code"); 693 return i18n("Business Address Postal Code");
678} 694}
679 695
680 696
681QString Addressee::businessAddressCountryLabel() 697QString Addressee::businessAddressCountryLabel()
682{ 698{
683 return i18n("Business Address Country"); 699 return i18n("Business Address Country");
684} 700}
685 701
686 702
687QString Addressee::businessAddressLabelLabel() 703QString Addressee::businessAddressLabelLabel()
688{ 704{
689 return i18n("Business Address Label"); 705 return i18n("Business Address Label");
690} 706}
691 707
692 708
693QString Addressee::homePhoneLabel() 709QString Addressee::homePhoneLabel()
694{ 710{
695 return i18n("Home Phone"); 711 return i18n("Home Phone");
696} 712}
697 713
698 714
699QString Addressee::businessPhoneLabel() 715QString Addressee::businessPhoneLabel()
700{ 716{
701 return i18n("Business Phone"); 717 return i18n("Business Phone");
702} 718}
703 719
704 720
705QString Addressee::mobilePhoneLabel() 721QString Addressee::mobilePhoneLabel()
706{ 722{
707 return i18n("Mobile Phone"); 723 return i18n("Mobile Phone");
708} 724}
709 725
710 726
711QString Addressee::homeFaxLabel() 727QString Addressee::homeFaxLabel()
712{ 728{
713 return i18n("Home Fax"); 729 return i18n("Home Fax");
714} 730}
715 731
716 732
717QString Addressee::businessFaxLabel() 733QString Addressee::businessFaxLabel()
718{ 734{
719 return i18n("Business Fax"); 735 return i18n("Business Fax");
720} 736}
721 737
722 738
723QString Addressee::carPhoneLabel() 739QString Addressee::carPhoneLabel()
724{ 740{
725 return i18n("Car Phone"); 741 return i18n("Car Phone");
726} 742}
727 743
728 744
729QString Addressee::isdnLabel() 745QString Addressee::isdnLabel()
730{ 746{
731 return i18n("ISDN"); 747 return i18n("ISDN");
732} 748}
733 749
734 750
735QString Addressee::pagerLabel() 751QString Addressee::pagerLabel()
736{ 752{
737 return i18n("Pager"); 753 return i18n("Pager");
738} 754}
739 755
740QString Addressee::sipLabel() 756QString Addressee::sipLabel()
741{ 757{
742 return i18n("SIP"); 758 return i18n("SIP");
743} 759}
744 760
745QString Addressee::emailLabel() 761QString Addressee::emailLabel()
746{ 762{
747 return i18n("Email Address"); 763 return i18n("Email Address");
748} 764}
749 765
750 766
751void Addressee::setMailer( const QString &mailer ) 767void Addressee::setMailer( const QString &mailer )
752{ 768{
753 if ( mailer == mData->mailer ) return; 769 if ( mailer == mData->mailer ) return;
754 detach(); 770 detach();
755 mData->empty = false; 771 mData->empty = false;
756 mData->mailer = mailer; 772 mData->mailer = mailer;
757} 773}
758 774
759QString Addressee::mailer() const 775QString Addressee::mailer() const
760{ 776{
761 return mData->mailer; 777 return mData->mailer;
762} 778}
763 779
764QString Addressee::mailerLabel() 780QString Addressee::mailerLabel()
765{ 781{
766 return i18n("Mail Client"); 782 return i18n("Mail Client");
767} 783}
768 784
769 785
770void Addressee::setTimeZone( const TimeZone &timeZone ) 786void Addressee::setTimeZone( const TimeZone &timeZone )
771{ 787{
772 if ( timeZone == mData->timeZone ) return; 788 if ( timeZone == mData->timeZone ) return;
773 detach(); 789 detach();
774 mData->empty = false; 790 mData->empty = false;
775 mData->timeZone = timeZone; 791 mData->timeZone = timeZone;
776} 792}
777 793
778TimeZone Addressee::timeZone() const 794TimeZone Addressee::timeZone() const
779{ 795{
780 return mData->timeZone; 796 return mData->timeZone;
781} 797}
782 798
783QString Addressee::timeZoneLabel() 799QString Addressee::timeZoneLabel()
784{ 800{
785 return i18n("Time Zone"); 801 return i18n("Time Zone");
786} 802}
787 803
788 804
789void Addressee::setGeo( const Geo &geo ) 805void Addressee::setGeo( const Geo &geo )
790{ 806{
791 if ( geo == mData->geo ) return; 807 if ( geo == mData->geo ) return;
792 detach(); 808 detach();
793 mData->empty = false; 809 mData->empty = false;
794 mData->geo = geo; 810 mData->geo = geo;
795} 811}
796 812
797Geo Addressee::geo() const 813Geo Addressee::geo() const
798{ 814{
799 return mData->geo; 815 return mData->geo;
800} 816}
801 817
802QString Addressee::geoLabel() 818QString Addressee::geoLabel()
803{ 819{
804 return i18n("Geographic Position"); 820 return i18n("Geographic Position");
805} 821}
806 822
807 823
808void Addressee::setTitle( const QString &title ) 824void Addressee::setTitle( const QString &title )
809{ 825{
810 if ( title == mData->title ) return; 826 if ( title == mData->title ) return;
811 detach(); 827 detach();
812 mData->empty = false; 828 mData->empty = false;
813 mData->title = title; 829 mData->title = title;
814} 830}
815 831
816QString Addressee::title() const 832QString Addressee::title() const
817{ 833{
818 return mData->title; 834 return mData->title;
819} 835}
820 836
821QString Addressee::titleLabel() 837QString Addressee::titleLabel()
822{ 838{
823 return i18n("Title"); 839 return i18n("Title");
824} 840}
825 841
826 842
827void Addressee::setRole( const QString &role ) 843void Addressee::setRole( const QString &role )
828{ 844{
829 if ( role == mData->role ) return; 845 if ( role == mData->role ) return;
830 detach(); 846 detach();
831 mData->empty = false; 847 mData->empty = false;
832 mData->role = role; 848 mData->role = role;
833} 849}
834 850
835QString Addressee::role() const 851QString Addressee::role() const
836{ 852{
837 return mData->role; 853 return mData->role;
838} 854}
839 855
840QString Addressee::roleLabel() 856QString Addressee::roleLabel()
841{ 857{
842 return i18n("Role"); 858 return i18n("Role");
843} 859}
844 860
845 861
846void Addressee::setOrganization( const QString &organization ) 862void Addressee::setOrganization( const QString &organization )
847{ 863{
848 if ( organization == mData->organization ) return; 864 if ( organization == mData->organization ) return;
849 detach(); 865 detach();
850 mData->empty = false; 866 mData->empty = false;
851 mData->organization = organization; 867 mData->organization = organization;
852} 868}
853 869
854QString Addressee::organization() const 870QString Addressee::organization() const
855{ 871{
856 return mData->organization; 872 return mData->organization;
857} 873}
858 874
859QString Addressee::organizationLabel() 875QString Addressee::organizationLabel()
860{ 876{
861 return i18n("Organization"); 877 return i18n("Organization");
862} 878}
863 879
864 880
865void Addressee::setNote( const QString &note ) 881void Addressee::setNote( const QString &note )
866{ 882{
867 if ( note == mData->note ) return; 883 if ( note == mData->note ) return;
868 detach(); 884 detach();
869 mData->empty = false; 885 mData->empty = false;
870 mData->note = note; 886 mData->note = note;
871} 887}
872 888
873QString Addressee::note() const 889QString Addressee::note() const
874{ 890{
875 return mData->note; 891 return mData->note;
876} 892}
877 893
878QString Addressee::noteLabel() 894QString Addressee::noteLabel()
879{ 895{
880 return i18n("Note"); 896 return i18n("Note");
881} 897}
882 898
883 899
884void Addressee::setProductId( const QString &productId ) 900void Addressee::setProductId( const QString &productId )
885{ 901{
886 if ( productId == mData->productId ) return; 902 if ( productId == mData->productId ) return;
887 detach(); 903 detach();
888 mData->empty = false; 904 mData->empty = false;
889 mData->productId = productId; 905 mData->productId = productId;
890} 906}
891 907
892QString Addressee::productId() const 908QString Addressee::productId() const
893{ 909{
894 return mData->productId; 910 return mData->productId;
895} 911}
896 912
897QString Addressee::productIdLabel() 913QString Addressee::productIdLabel()
898{ 914{
899 return i18n("Product Identifier"); 915 return i18n("Product Identifier");
900} 916}
901 917
902 918
903void Addressee::setRevision( const QDateTime &revision ) 919void Addressee::setRevision( const QDateTime &revision )
904{ 920{
905 if ( revision == mData->revision ) return; 921 if ( revision == mData->revision ) return;
906 detach(); 922 detach();
907 mData->empty = false; 923 mData->empty = false;
908 mData->revision = revision; 924 mData->revision = revision;
909} 925}
910 926
911QDateTime Addressee::revision() const 927QDateTime Addressee::revision() const
912{ 928{
913 return mData->revision; 929 return mData->revision;
914} 930}
915 931
916QString Addressee::revisionLabel() 932QString Addressee::revisionLabel()
917{ 933{
918 return i18n("Revision Date"); 934 return i18n("Revision Date");
919} 935}
920 936
921 937
922void Addressee::setSortString( const QString &sortString ) 938void Addressee::setSortString( const QString &sortString )
923{ 939{
924 if ( sortString == mData->sortString ) return; 940 if ( sortString == mData->sortString ) return;
925 detach(); 941 detach();
926 mData->empty = false; 942 mData->empty = false;
927 mData->sortString = sortString; 943 mData->sortString = sortString;
928} 944}
929 945
930QString Addressee::sortString() const 946QString Addressee::sortString() const
931{ 947{
932 return mData->sortString; 948 return mData->sortString;
933} 949}
934 950
935QString Addressee::sortStringLabel() 951QString Addressee::sortStringLabel()
936{ 952{
937 return i18n("Sort String"); 953 return i18n("Sort String");
938} 954}
939 955
940 956
941void Addressee::setUrl( const KURL &url ) 957void Addressee::setUrl( const KURL &url )
942{ 958{
943 if ( url == mData->url ) return; 959 if ( url == mData->url ) return;
944 detach(); 960 detach();
945 mData->empty = false; 961 mData->empty = false;
946 mData->url = url; 962 mData->url = url;
947} 963}
948 964
949KURL Addressee::url() const 965KURL Addressee::url() const
950{ 966{
951 return mData->url; 967 return mData->url;
952} 968}
953 969
954QString Addressee::urlLabel() 970QString Addressee::urlLabel()
955{ 971{
956 return i18n("URL"); 972 return i18n("URL");
957} 973}
958 974
959 975
960void Addressee::setSecrecy( const Secrecy &secrecy ) 976void Addressee::setSecrecy( const Secrecy &secrecy )
961{ 977{
962 if ( secrecy == mData->secrecy ) return; 978 if ( secrecy == mData->secrecy ) return;
963 detach(); 979 detach();
964 mData->empty = false; 980 mData->empty = false;
965 mData->secrecy = secrecy; 981 mData->secrecy = secrecy;
966} 982}
967 983
968Secrecy Addressee::secrecy() const 984Secrecy Addressee::secrecy() const
969{ 985{
970 return mData->secrecy; 986 return mData->secrecy;
971} 987}
972 988
973QString Addressee::secrecyLabel() 989QString Addressee::secrecyLabel()
974{ 990{
975 return i18n("Security Class"); 991 return i18n("Security Class");
976} 992}
977 993
978 994
979void Addressee::setLogo( const Picture &logo ) 995void Addressee::setLogo( const Picture &logo )
980{ 996{
981 if ( logo == mData->logo ) return; 997 if ( logo == mData->logo ) return;
982 detach(); 998 detach();
983 mData->empty = false; 999 mData->empty = false;
984 mData->logo = logo; 1000 mData->logo = logo;
985} 1001}
986 1002
987Picture Addressee::logo() const 1003Picture Addressee::logo() const
988{ 1004{
989 return mData->logo; 1005 return mData->logo;
990} 1006}
991 1007
992QString Addressee::logoLabel() 1008QString Addressee::logoLabel()
993{ 1009{
994 return i18n("Logo"); 1010 return i18n("Logo");
995} 1011}
996 1012
997 1013
998void Addressee::setPhoto( const Picture &photo ) 1014void Addressee::setPhoto( const Picture &photo )
999{ 1015{
1000 if ( photo == mData->photo ) return; 1016 if ( photo == mData->photo ) return;
1001 detach(); 1017 detach();
1002 mData->empty = false; 1018 mData->empty = false;
1003 mData->photo = photo; 1019 mData->photo = photo;
1004} 1020}
1005 1021
1006Picture Addressee::photo() const 1022Picture Addressee::photo() const
1007{ 1023{
1008 return mData->photo; 1024 return mData->photo;
1009} 1025}
1010 1026
1011QString Addressee::photoLabel() 1027QString Addressee::photoLabel()
1012{ 1028{
1013 return i18n("Photo"); 1029 return i18n("Photo");
1014} 1030}
1015 1031
1016 1032
1017void Addressee::setSound( const Sound &sound ) 1033void Addressee::setSound( const Sound &sound )
1018{ 1034{
1019 if ( sound == mData->sound ) return; 1035 if ( sound == mData->sound ) return;
1020 detach(); 1036 detach();
1021 mData->empty = false; 1037 mData->empty = false;
1022 mData->sound = sound; 1038 mData->sound = sound;
1023} 1039}
1024 1040
1025Sound Addressee::sound() const 1041Sound Addressee::sound() const
1026{ 1042{
1027 return mData->sound; 1043 return mData->sound;
1028} 1044}
1029 1045
1030QString Addressee::soundLabel() 1046QString Addressee::soundLabel()
1031{ 1047{
1032 return i18n("Sound"); 1048 return i18n("Sound");
1033} 1049}
1034 1050
1035 1051
1036void Addressee::setAgent( const Agent &agent ) 1052void Addressee::setAgent( const Agent &agent )
1037{ 1053{
1038 if ( agent == mData->agent ) return; 1054 if ( agent == mData->agent ) return;
1039 detach(); 1055 detach();
1040 mData->empty = false; 1056 mData->empty = false;
1041 mData->agent = agent; 1057 mData->agent = agent;
1042} 1058}
1043 1059
1044Agent Addressee::agent() const 1060Agent Addressee::agent() const
1045{ 1061{
1046 return mData->agent; 1062 return mData->agent;
1047} 1063}
1048 1064
1049QString Addressee::agentLabel() 1065QString Addressee::agentLabel()
1050{ 1066{
1051 return i18n("Agent"); 1067 return i18n("Agent");
1052} 1068}
1053 1069
1054 1070
1055 1071
1056void Addressee::setNameFromString( const QString &str ) 1072void Addressee::setNameFromString( const QString &str )
1057{ 1073{
1058 setFormattedName( str ); 1074 setFormattedName( str );
1059 setName( str ); 1075 setName( str );
1060 1076
1061 static bool first = true; 1077 static bool first = true;
1062 static QStringList titles; 1078 static QStringList titles;
1063 static QStringList suffixes; 1079 static QStringList suffixes;
1064 static QStringList prefixes; 1080 static QStringList prefixes;
1065 1081
1066 if ( first ) { 1082 if ( first ) {
1067 first = false; 1083 first = false;
1068 titles += i18n( "Dr." ); 1084 titles += i18n( "Dr." );
1069 titles += i18n( "Miss" ); 1085 titles += i18n( "Miss" );
1070 titles += i18n( "Mr." ); 1086 titles += i18n( "Mr." );
1071 titles += i18n( "Mrs." ); 1087 titles += i18n( "Mrs." );
1072 titles += i18n( "Ms." ); 1088 titles += i18n( "Ms." );
1073 titles += i18n( "Prof." ); 1089 titles += i18n( "Prof." );
1074 1090
1075 suffixes += i18n( "I" ); 1091 suffixes += i18n( "I" );
1076 suffixes += i18n( "II" ); 1092 suffixes += i18n( "II" );
1077 suffixes += i18n( "III" ); 1093 suffixes += i18n( "III" );
1078 suffixes += i18n( "Jr." ); 1094 suffixes += i18n( "Jr." );
1079 suffixes += i18n( "Sr." ); 1095 suffixes += i18n( "Sr." );
1080 1096
1081 prefixes += "van"; 1097 prefixes += "van";
1082 prefixes += "von"; 1098 prefixes += "von";
1083 prefixes += "de"; 1099 prefixes += "de";
1084 1100
1085 KConfig config( locateLocal( "config", "kabcrc") ); 1101 KConfig config( locateLocal( "config", "kabcrc") );
1086 config.setGroup( "General" ); 1102 config.setGroup( "General" );
1087 titles += config.readListEntry( "Prefixes" ); 1103 titles += config.readListEntry( "Prefixes" );
1088 titles.remove( "" ); 1104 titles.remove( "" );
1089 prefixes += config.readListEntry( "Inclusions" ); 1105 prefixes += config.readListEntry( "Inclusions" );
1090 prefixes.remove( "" ); 1106 prefixes.remove( "" );
1091 suffixes += config.readListEntry( "Suffixes" ); 1107 suffixes += config.readListEntry( "Suffixes" );
1092 suffixes.remove( "" ); 1108 suffixes.remove( "" );
1093 } 1109 }
1094 1110
1095 // clear all name parts 1111 // clear all name parts
1096 setPrefix( "" ); 1112 setPrefix( "" );
1097 setGivenName( "" ); 1113 setGivenName( "" );
1098 setAdditionalName( "" ); 1114 setAdditionalName( "" );
1099 setFamilyName( "" ); 1115 setFamilyName( "" );
1100 setSuffix( "" ); 1116 setSuffix( "" );
1101 1117
1102 if ( str.isEmpty() ) 1118 if ( str.isEmpty() )
1103 return; 1119 return;
1104 1120
1105 int i = str.find(','); 1121 int i = str.find(',');
1106 if( i < 0 ) { 1122 if( i < 0 ) {
1107 QStringList parts = QStringList::split( " ", str ); 1123 QStringList parts = QStringList::split( " ", str );
1108 int leftOffset = 0; 1124 int leftOffset = 0;
1109 int rightOffset = parts.count() - 1; 1125 int rightOffset = parts.count() - 1;
1110 1126
1111 QString suffix; 1127 QString suffix;
1112 while ( rightOffset >= 0 ) { 1128 while ( rightOffset >= 0 ) {
1113 if ( suffixes.contains( parts[ rightOffset ] ) ) { 1129 if ( suffixes.contains( parts[ rightOffset ] ) ) {
1114 suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); 1130 suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " "));
1115 rightOffset--; 1131 rightOffset--;
1116 } else 1132 } else
1117 break; 1133 break;
1118 } 1134 }
1119 setSuffix( suffix ); 1135 setSuffix( suffix );
1120 1136
1121 if ( rightOffset < 0 ) 1137 if ( rightOffset < 0 )
1122 return; 1138 return;
1123 1139
1124 if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { 1140 if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) {
1125 setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); 1141 setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] );
1126 rightOffset--; 1142 rightOffset--;
1127 } else 1143 } else
1128 setFamilyName( parts[ rightOffset ] ); 1144 setFamilyName( parts[ rightOffset ] );
1129 1145
1130 QString prefix; 1146 QString prefix;
1131 while ( leftOffset < rightOffset ) { 1147 while ( leftOffset < rightOffset ) {
1132 if ( titles.contains( parts[ leftOffset ] ) ) { 1148 if ( titles.contains( parts[ leftOffset ] ) ) {
1133 prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); 1149 prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] );
1134 leftOffset++; 1150 leftOffset++;
1135 } else 1151 } else
1136 break; 1152 break;
1137 } 1153 }
1138 setPrefix( prefix ); 1154 setPrefix( prefix );
1139 1155
1140 if ( leftOffset < rightOffset ) { 1156 if ( leftOffset < rightOffset ) {
1141 setGivenName( parts[ leftOffset ] ); 1157 setGivenName( parts[ leftOffset ] );
1142 leftOffset++; 1158 leftOffset++;
1143 } 1159 }
1144 1160
1145 QString additionalName; 1161 QString additionalName;
1146 while ( leftOffset < rightOffset ) { 1162 while ( leftOffset < rightOffset ) {
1147 additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); 1163 additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] );
1148 leftOffset++; 1164 leftOffset++;
1149 } 1165 }
1150 setAdditionalName( additionalName ); 1166 setAdditionalName( additionalName );
1151 } else { 1167 } else {
1152 QString part1 = str.left( i ); 1168 QString part1 = str.left( i );
1153 QString part2 = str.mid( i + 1 ); 1169 QString part2 = str.mid( i + 1 );
1154 1170
1155 QStringList parts = QStringList::split( " ", part1 ); 1171 QStringList parts = QStringList::split( " ", part1 );
1156 int leftOffset = 0; 1172 int leftOffset = 0;
1157 int rightOffset = parts.count() - 1; 1173 int rightOffset = parts.count() - 1;
1158 1174
1159 QString suffix; 1175 QString suffix;
1160 while ( rightOffset >= 0 ) { 1176 while ( rightOffset >= 0 ) {
1161 if ( suffixes.contains( parts[ rightOffset ] ) ) { 1177 if ( suffixes.contains( parts[ rightOffset ] ) ) {
1162 suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); 1178 suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " "));
1163 rightOffset--; 1179 rightOffset--;
1164 } else 1180 } else
1165 break; 1181 break;
1166 } 1182 }
1167 setSuffix( suffix ); 1183 setSuffix( suffix );
1168 1184
1169 if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { 1185 if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) {
1170 setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); 1186 setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] );
1171 rightOffset--; 1187 rightOffset--;
1172 } else 1188 } else
1173 setFamilyName( parts[ rightOffset ] ); 1189 setFamilyName( parts[ rightOffset ] );
1174 1190
1175 QString prefix; 1191 QString prefix;
1176 while ( leftOffset < rightOffset ) { 1192 while ( leftOffset < rightOffset ) {
1177 if ( titles.contains( parts[ leftOffset ] ) ) { 1193 if ( titles.contains( parts[ leftOffset ] ) ) {
1178 prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); 1194 prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] );
1179 leftOffset++; 1195 leftOffset++;
1180 } else 1196 } else
1181 break; 1197 break;
1182 } 1198 }
1183 1199
1184 parts = QStringList::split( " ", part2 ); 1200 parts = QStringList::split( " ", part2 );
1185 1201
1186 leftOffset = 0; 1202 leftOffset = 0;
1187 rightOffset = parts.count(); 1203 rightOffset = parts.count();
1188 1204
1189 while ( leftOffset < rightOffset ) { 1205 while ( leftOffset < rightOffset ) {
1190 if ( titles.contains( parts[ leftOffset ] ) ) { 1206 if ( titles.contains( parts[ leftOffset ] ) ) {
1191 prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); 1207 prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] );
1192 leftOffset++; 1208 leftOffset++;
1193 } else 1209 } else
1194 break; 1210 break;
1195 } 1211 }
1196 setPrefix( prefix ); 1212 setPrefix( prefix );
1197 1213
1198 if ( leftOffset < rightOffset ) { 1214 if ( leftOffset < rightOffset ) {
1199 setGivenName( parts[ leftOffset ] ); 1215 setGivenName( parts[ leftOffset ] );
1200 leftOffset++; 1216 leftOffset++;
1201 } 1217 }
1202 1218
1203 QString additionalName; 1219 QString additionalName;
1204 while ( leftOffset < rightOffset ) { 1220 while ( leftOffset < rightOffset ) {
1205 additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); 1221 additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] );
1206 leftOffset++; 1222 leftOffset++;
1207 } 1223 }
1208 setAdditionalName( additionalName ); 1224 setAdditionalName( additionalName );
1209 } 1225 }
1210} 1226}
1211 1227
1212QString Addressee::realName() const 1228QString Addressee::realName() const
1213{ 1229{
1214 if ( !formattedName().isEmpty() ) 1230 if ( !formattedName().isEmpty() )
1215 return formattedName(); 1231 return formattedName();
1216 1232
1217 QString n = assembledName(); 1233 QString n = assembledName();
1218 1234
1219 if ( n.isEmpty() ) 1235 if ( n.isEmpty() )
1220 n = name(); 1236 n = name();
1221 1237
1222 return n; 1238 return n;
1223} 1239}
1224 1240
1225QString Addressee::assembledName() const 1241QString Addressee::assembledName() const
1226{ 1242{
1227 QString name = prefix() + " " + givenName() + " " + additionalName() + " " + 1243 QString name = prefix() + " " + givenName() + " " + additionalName() + " " +
1228 familyName() + " " + suffix(); 1244 familyName() + " " + suffix();
1229 1245
1230 return name.simplifyWhiteSpace(); 1246 return name.simplifyWhiteSpace();
1231} 1247}
1232 1248
1233QString Addressee::fullEmail( const QString &email ) const 1249QString Addressee::fullEmail( const QString &email ) const
1234{ 1250{
1235 QString e; 1251 QString e;
1236 if ( email.isNull() ) { 1252 if ( email.isNull() ) {
1237 e = preferredEmail(); 1253 e = preferredEmail();
1238 } else { 1254 } else {
1239 e = email; 1255 e = email;
1240 } 1256 }
1241 if ( e.isEmpty() ) return QString::null; 1257 if ( e.isEmpty() ) return QString::null;
1242 1258
1243 QString text; 1259 QString text;
1244 if ( realName().isEmpty() ) 1260 if ( realName().isEmpty() )
1245 text = e; 1261 text = e;
1246 else 1262 else
1247 text = assembledName() + " <" + e + ">"; 1263 text = assembledName() + " <" + e + ">";
1248 1264
1249 return text; 1265 return text;
1250} 1266}
1251 1267
1252void Addressee::insertEmail( const QString &email, bool preferred ) 1268void Addressee::insertEmail( const QString &email, bool preferred )
1253{ 1269{
1254 detach(); 1270 detach();
1255 1271
1256 QStringList::Iterator it = mData->emails.find( email ); 1272 QStringList::Iterator it = mData->emails.find( email );
1257 1273
1258 if ( it != mData->emails.end() ) { 1274 if ( it != mData->emails.end() ) {
1259 if ( !preferred || it == mData->emails.begin() ) return; 1275 if ( !preferred || it == mData->emails.begin() ) return;
1260 mData->emails.remove( it ); 1276 mData->emails.remove( it );
1261 mData->emails.prepend( email ); 1277 mData->emails.prepend( email );
1262 } else { 1278 } else {
1263 if ( preferred ) { 1279 if ( preferred ) {
1264 mData->emails.prepend( email ); 1280 mData->emails.prepend( email );
1265 } else { 1281 } else {
1266 mData->emails.append( email ); 1282 mData->emails.append( email );
1267 } 1283 }
1268 } 1284 }
1269} 1285}
1270 1286
1271void Addressee::removeEmail( const QString &email ) 1287void Addressee::removeEmail( const QString &email )
1272{ 1288{
1273 detach(); 1289 detach();
1274 1290
1275 QStringList::Iterator it = mData->emails.find( email ); 1291 QStringList::Iterator it = mData->emails.find( email );
1276 if ( it == mData->emails.end() ) return; 1292 if ( it == mData->emails.end() ) return;
1277 1293
1278 mData->emails.remove( it ); 1294 mData->emails.remove( it );
1279} 1295}
1280 1296
1281QString Addressee::preferredEmail() const 1297QString Addressee::preferredEmail() const
1282{ 1298{
1283 if ( mData->emails.count() == 0 ) return QString::null; 1299 if ( mData->emails.count() == 0 ) return QString::null;
1284 else return mData->emails.first(); 1300 else return mData->emails.first();
1285} 1301}
1286 1302
1287QStringList Addressee::emails() const 1303QStringList Addressee::emails() const
1288{ 1304{
1289 return mData->emails; 1305 return mData->emails;
1290} 1306}
1291void Addressee::setEmails( const QStringList& emails ) { 1307void Addressee::setEmails( const QStringList& emails ) {
1292 detach(); 1308 detach();
1293 mData->emails = emails; 1309 mData->emails = emails;
1294} 1310}
1295void Addressee::insertPhoneNumber( const PhoneNumber &phoneNumber ) 1311void Addressee::insertPhoneNumber( const PhoneNumber &phoneNumber )
1296{ 1312{
1297 detach(); 1313 detach();
1298 mData->empty = false; 1314 mData->empty = false;
1299 1315
1300 PhoneNumber::List::Iterator it; 1316 PhoneNumber::List::Iterator it;
1301 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 1317 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
1302 if ( (*it).id() == phoneNumber.id() ) { 1318 if ( (*it).id() == phoneNumber.id() ) {
1303 *it = phoneNumber; 1319 *it = phoneNumber;
1304 return; 1320 return;
1305 } 1321 }
1306 } 1322 }
1307 mData->phoneNumbers.append( phoneNumber ); 1323 mData->phoneNumbers.append( phoneNumber );
1308} 1324}
1309 1325
1310void Addressee::removePhoneNumber( const PhoneNumber &phoneNumber ) 1326void Addressee::removePhoneNumber( const PhoneNumber &phoneNumber )
1311{ 1327{
1312 detach(); 1328 detach();
1313 1329
1314 PhoneNumber::List::Iterator it; 1330 PhoneNumber::List::Iterator it;
1315 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 1331 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
1316 if ( (*it).id() == phoneNumber.id() ) { 1332 if ( (*it).id() == phoneNumber.id() ) {
1317 mData->phoneNumbers.remove( it ); 1333 mData->phoneNumbers.remove( it );
1318 return; 1334 return;
1319 } 1335 }
1320 } 1336 }
1321} 1337}
1322 1338
1323PhoneNumber Addressee::phoneNumber( int type ) const 1339PhoneNumber Addressee::phoneNumber( int type ) const
1324{ 1340{
1325 PhoneNumber phoneNumber( "", type ); 1341 PhoneNumber phoneNumber( "", type );
1326 PhoneNumber::List::ConstIterator it; 1342 PhoneNumber::List::ConstIterator it;
1327 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 1343 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
1328 if ( matchBinaryPatternP( (*it).type(), type ) ) { 1344 if ( matchBinaryPatternP( (*it).type(), type ) ) {
1329 if ( (*it).type() & PhoneNumber::Pref ) 1345 if ( (*it).type() & PhoneNumber::Pref )
1330 return (*it); 1346 return (*it);
1331 else if ( phoneNumber.number().isEmpty() ) 1347 else if ( phoneNumber.number().isEmpty() )
1332 phoneNumber = (*it); 1348 phoneNumber = (*it);
1333 } 1349 }
1334 } 1350 }
1335 1351
1336 return phoneNumber; 1352 return phoneNumber;
1337} 1353}
1338 1354
1339PhoneNumber::List Addressee::phoneNumbers() const 1355PhoneNumber::List Addressee::phoneNumbers() const
1340{ 1356{
1341 return mData->phoneNumbers; 1357 return mData->phoneNumbers;
1342} 1358}
1343 1359
1344PhoneNumber::List Addressee::phoneNumbers( int type ) const 1360PhoneNumber::List Addressee::phoneNumbers( int type ) const
1345{ 1361{
1346 PhoneNumber::List list; 1362 PhoneNumber::List list;
1347 1363
1348 PhoneNumber::List::ConstIterator it; 1364 PhoneNumber::List::ConstIterator it;
1349 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 1365 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
1350 if ( matchBinaryPattern( (*it).type(), type ) ) { 1366 if ( matchBinaryPattern( (*it).type(), type ) ) {
1351 list.append( *it ); 1367 list.append( *it );
1352 } 1368 }
1353 } 1369 }
1354 return list; 1370 return list;
1355} 1371}
1356 1372
1357PhoneNumber Addressee::findPhoneNumber( const QString &id ) const 1373PhoneNumber Addressee::findPhoneNumber( const QString &id ) const
1358{ 1374{
1359 PhoneNumber::List::ConstIterator it; 1375 PhoneNumber::List::ConstIterator it;
1360 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 1376 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
1361 if ( (*it).id() == id ) { 1377 if ( (*it).id() == id ) {
1362 return *it; 1378 return *it;
1363 } 1379 }
1364 } 1380 }
1365 return PhoneNumber(); 1381 return PhoneNumber();
1366} 1382}
1367 1383
1368void Addressee::insertKey( const Key &key ) 1384void Addressee::insertKey( const Key &key )
1369{ 1385{
1370 detach(); 1386 detach();
1371 mData->empty = false; 1387 mData->empty = false;
1372 1388
1373 Key::List::Iterator it; 1389 Key::List::Iterator it;
1374 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { 1390 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
1375 if ( (*it).id() == key.id() ) { 1391 if ( (*it).id() == key.id() ) {
1376 *it = key; 1392 *it = key;
1377 return; 1393 return;
1378 } 1394 }
1379 } 1395 }
1380 mData->keys.append( key ); 1396 mData->keys.append( key );
1381} 1397}
1382 1398
1383void Addressee::removeKey( const Key &key ) 1399void Addressee::removeKey( const Key &key )
1384{ 1400{
1385 detach(); 1401 detach();
1386 1402
1387 Key::List::Iterator it; 1403 Key::List::Iterator it;
1388 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { 1404 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
1389 if ( (*it).id() == key.id() ) { 1405 if ( (*it).id() == key.id() ) {
1390 mData->keys.remove( key ); 1406 mData->keys.remove( key );
1391 return; 1407 return;
1392 } 1408 }
1393 } 1409 }
1394} 1410}
1395 1411
1396Key Addressee::key( int type, QString customTypeString ) const 1412Key Addressee::key( int type, QString customTypeString ) const
1397{ 1413{
1398 Key::List::ConstIterator it; 1414 Key::List::ConstIterator it;
1399 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { 1415 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
1400 if ( (*it).type() == type ) { 1416 if ( (*it).type() == type ) {
1401 if ( type == Key::Custom ) { 1417 if ( type == Key::Custom ) {
1402 if ( customTypeString.isEmpty() ) { 1418 if ( customTypeString.isEmpty() ) {
1403 return *it; 1419 return *it;
1404 } else { 1420 } else {
1405 if ( (*it).customTypeString() == customTypeString ) 1421 if ( (*it).customTypeString() == customTypeString )
1406 return (*it); 1422 return (*it);
1407 } 1423 }
1408 } else { 1424 } else {
1409 return *it; 1425 return *it;
1410 } 1426 }
1411 } 1427 }
1412 } 1428 }
1413 return Key( QString(), type ); 1429 return Key( QString(), type );
1414} 1430}
1415void Addressee::setKeys( const Key::List& list ) { 1431void Addressee::setKeys( const Key::List& list ) {
1416 detach(); 1432 detach();
1417 mData->keys = list; 1433 mData->keys = list;
1418} 1434}
1419 1435
1420Key::List Addressee::keys() const 1436Key::List Addressee::keys() const
1421{ 1437{
1422 return mData->keys; 1438 return mData->keys;
1423} 1439}
1424 1440
1425Key::List Addressee::keys( int type, QString customTypeString ) const 1441Key::List Addressee::keys( int type, QString customTypeString ) const
1426{ 1442{
1427 Key::List list; 1443 Key::List list;
1428 1444
1429 Key::List::ConstIterator it; 1445 Key::List::ConstIterator it;
1430 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { 1446 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
1431 if ( (*it).type() == type ) { 1447 if ( (*it).type() == type ) {
1432 if ( type == Key::Custom ) { 1448 if ( type == Key::Custom ) {
1433 if ( customTypeString.isEmpty() ) { 1449 if ( customTypeString.isEmpty() ) {
1434 list.append(*it); 1450 list.append(*it);
1435 } else { 1451 } else {
1436 if ( (*it).customTypeString() == customTypeString ) 1452 if ( (*it).customTypeString() == customTypeString )
1437 list.append(*it); 1453 list.append(*it);
1438 } 1454 }
1439 } else { 1455 } else {
1440 list.append(*it); 1456 list.append(*it);
1441 } 1457 }
1442 } 1458 }
1443 } 1459 }
1444 return list; 1460 return list;
1445} 1461}
1446 1462
1447Key Addressee::findKey( const QString &id ) const 1463Key Addressee::findKey( const QString &id ) const
1448{ 1464{
1449 Key::List::ConstIterator it; 1465 Key::List::ConstIterator it;
1450 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { 1466 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
1451 if ( (*it).id() == id ) { 1467 if ( (*it).id() == id ) {
1452 return *it; 1468 return *it;
1453 } 1469 }
1454 } 1470 }
1455 return Key(); 1471 return Key();
1456} 1472}
1457 1473
1458QString Addressee::asString() const 1474QString Addressee::asString() const
1459{ 1475{
1460 return "Smith, agent Smith..."; 1476 return "Smith, agent Smith...";
1461} 1477}
1462 1478
1463void Addressee::dump() const 1479void Addressee::dump() const
1464{ 1480{
1465 return; 1481 return;
1466 kdDebug(5700) << "Addressee {" << endl; 1482 kdDebug(5700) << "Addressee {" << endl;
1467 1483
1468 kdDebug(5700) << " Uid: '" << uid() << "'" << endl; 1484 kdDebug(5700) << " Uid: '" << uid() << "'" << endl;
1469 1485
1470 kdDebug(5700) << " Name: '" << name() << "'" << endl; 1486 kdDebug(5700) << " Name: '" << name() << "'" << endl;
1471 kdDebug(5700) << " FormattedName: '" << formattedName() << "'" << endl; 1487 kdDebug(5700) << " FormattedName: '" << formattedName() << "'" << endl;
1472 kdDebug(5700) << " FamilyName: '" << familyName() << "'" << endl; 1488 kdDebug(5700) << " FamilyName: '" << familyName() << "'" << endl;
1473 kdDebug(5700) << " GivenName: '" << givenName() << "'" << endl; 1489 kdDebug(5700) << " GivenName: '" << givenName() << "'" << endl;
1474 kdDebug(5700) << " AdditionalName: '" << additionalName() << "'" << endl; 1490 kdDebug(5700) << " AdditionalName: '" << additionalName() << "'" << endl;
1475 kdDebug(5700) << " Prefix: '" << prefix() << "'" << endl; 1491 kdDebug(5700) << " Prefix: '" << prefix() << "'" << endl;
1476 kdDebug(5700) << " Suffix: '" << suffix() << "'" << endl; 1492 kdDebug(5700) << " Suffix: '" << suffix() << "'" << endl;
1477 kdDebug(5700) << " NickName: '" << nickName() << "'" << endl; 1493 kdDebug(5700) << " NickName: '" << nickName() << "'" << endl;
1478 kdDebug(5700) << " Birthday: '" << birthday().toString() << "'" << endl; 1494 kdDebug(5700) << " Birthday: '" << birthday().toString() << "'" << endl;
1479 kdDebug(5700) << " Mailer: '" << mailer() << "'" << endl; 1495 kdDebug(5700) << " Mailer: '" << mailer() << "'" << endl;
1480 kdDebug(5700) << " TimeZone: '" << timeZone().asString() << "'" << endl; 1496 kdDebug(5700) << " TimeZone: '" << timeZone().asString() << "'" << endl;
1481 kdDebug(5700) << " Geo: '" << geo().asString() << "'" << endl; 1497 kdDebug(5700) << " Geo: '" << geo().asString() << "'" << endl;
1482 kdDebug(5700) << " Title: '" << title() << "'" << endl; 1498 kdDebug(5700) << " Title: '" << title() << "'" << endl;
1483 kdDebug(5700) << " Role: '" << role() << "'" << endl; 1499 kdDebug(5700) << " Role: '" << role() << "'" << endl;
1484 kdDebug(5700) << " Organization: '" << organization() << "'" << endl; 1500 kdDebug(5700) << " Organization: '" << organization() << "'" << endl;
1485 kdDebug(5700) << " Note: '" << note() << "'" << endl; 1501 kdDebug(5700) << " Note: '" << note() << "'" << endl;
1486 kdDebug(5700) << " ProductId: '" << productId() << "'" << endl; 1502 kdDebug(5700) << " ProductId: '" << productId() << "'" << endl;
1487 kdDebug(5700) << " Revision: '" << revision().toString() << "'" << endl; 1503 kdDebug(5700) << " Revision: '" << revision().toString() << "'" << endl;
1488 kdDebug(5700) << " SortString: '" << sortString() << "'" << endl; 1504 kdDebug(5700) << " SortString: '" << sortString() << "'" << endl;
1489 kdDebug(5700) << " Url: '" << url().url() << "'" << endl; 1505 kdDebug(5700) << " Url: '" << url().url() << "'" << endl;
1490 kdDebug(5700) << " Secrecy: '" << secrecy().asString() << "'" << endl; 1506 kdDebug(5700) << " Secrecy: '" << secrecy().asString() << "'" << endl;
1491 kdDebug(5700) << " Logo: '" << logo().asString() << "'" << endl; 1507 kdDebug(5700) << " Logo: '" << logo().asString() << "'" << endl;
1492 kdDebug(5700) << " Photo: '" << photo().asString() << "'" << endl; 1508 kdDebug(5700) << " Photo: '" << photo().asString() << "'" << endl;
1493 kdDebug(5700) << " Sound: '" << sound().asString() << "'" << endl; 1509 kdDebug(5700) << " Sound: '" << sound().asString() << "'" << endl;
1494 kdDebug(5700) << " Agent: '" << agent().asString() << "'" << endl; 1510 kdDebug(5700) << " Agent: '" << agent().asString() << "'" << endl;
1495 1511
1496 kdDebug(5700) << " Emails {" << endl; 1512 kdDebug(5700) << " Emails {" << endl;
1497 QStringList e = emails(); 1513 QStringList e = emails();
1498 QStringList::ConstIterator it; 1514 QStringList::ConstIterator it;
1499 for( it = e.begin(); it != e.end(); ++it ) { 1515 for( it = e.begin(); it != e.end(); ++it ) {
1500 kdDebug(5700) << " " << (*it) << endl; 1516 kdDebug(5700) << " " << (*it) << endl;
1501 } 1517 }
1502 kdDebug(5700) << " }" << endl; 1518 kdDebug(5700) << " }" << endl;
1503 1519
1504 kdDebug(5700) << " PhoneNumbers {" << endl; 1520 kdDebug(5700) << " PhoneNumbers {" << endl;
1505 PhoneNumber::List p = phoneNumbers(); 1521 PhoneNumber::List p = phoneNumbers();
1506 PhoneNumber::List::ConstIterator it2; 1522 PhoneNumber::List::ConstIterator it2;
1507 for( it2 = p.begin(); it2 != p.end(); ++it2 ) { 1523 for( it2 = p.begin(); it2 != p.end(); ++it2 ) {
1508 kdDebug(5700) << " Type: " << int((*it2).type()) << " Number: " << (*it2).number() << endl; 1524 kdDebug(5700) << " Type: " << int((*it2).type()) << " Number: " << (*it2).number() << endl;
1509 } 1525 }
1510 kdDebug(5700) << " }" << endl; 1526 kdDebug(5700) << " }" << endl;
1511 1527
1512 Address::List a = addresses(); 1528 Address::List a = addresses();
1513 Address::List::ConstIterator it3; 1529 Address::List::ConstIterator it3;
1514 for( it3 = a.begin(); it3 != a.end(); ++it3 ) { 1530 for( it3 = a.begin(); it3 != a.end(); ++it3 ) {
1515 (*it3).dump(); 1531 (*it3).dump();
1516 } 1532 }
1517 1533
1518 kdDebug(5700) << " Keys {" << endl; 1534 kdDebug(5700) << " Keys {" << endl;
1519 Key::List k = keys(); 1535 Key::List k = keys();
1520 Key::List::ConstIterator it4; 1536 Key::List::ConstIterator it4;
1521 for( it4 = k.begin(); it4 != k.end(); ++it4 ) { 1537 for( it4 = k.begin(); it4 != k.end(); ++it4 ) {
1522 kdDebug(5700) << " Type: " << int((*it4).type()) << 1538 kdDebug(5700) << " Type: " << int((*it4).type()) <<
1523 " Key: " << (*it4).textData() << 1539 " Key: " << (*it4).textData() <<
1524 " CustomString: " << (*it4).customTypeString() << endl; 1540 " CustomString: " << (*it4).customTypeString() << endl;
1525 } 1541 }
1526 kdDebug(5700) << " }" << endl; 1542 kdDebug(5700) << " }" << endl;
1527 1543
1528 kdDebug(5700) << "}" << endl; 1544 kdDebug(5700) << "}" << endl;
1529} 1545}
1530 1546
1531 1547
1532void Addressee::insertAddress( const Address &address ) 1548void Addressee::insertAddress( const Address &address )
1533{ 1549{
1534 detach(); 1550 detach();
1535 mData->empty = false; 1551 mData->empty = false;
1536 1552
1537 Address::List::Iterator it; 1553 Address::List::Iterator it;
1538 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 1554 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
1539 if ( (*it).id() == address.id() ) { 1555 if ( (*it).id() == address.id() ) {
1540 *it = address; 1556 *it = address;
1541 return; 1557 return;
1542 } 1558 }
1543 } 1559 }
1544 mData->addresses.append( address ); 1560 mData->addresses.append( address );
1545} 1561}
1546 1562
1547void Addressee::removeAddress( const Address &address ) 1563void Addressee::removeAddress( const Address &address )
1548{ 1564{
1549 detach(); 1565 detach();
1550 1566
1551 Address::List::Iterator it; 1567 Address::List::Iterator it;
1552 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 1568 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
1553 if ( (*it).id() == address.id() ) { 1569 if ( (*it).id() == address.id() ) {
1554 mData->addresses.remove( it ); 1570 mData->addresses.remove( it );
1555 return; 1571 return;
1556 } 1572 }
1557 } 1573 }
1558} 1574}
1559 1575
1560Address Addressee::address( int type ) const 1576Address Addressee::address( int type ) const
1561{ 1577{
1562 Address address( type ); 1578 Address address( type );
1563 Address::List::ConstIterator it; 1579 Address::List::ConstIterator it;
1564 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 1580 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
1565 if ( matchBinaryPatternA( (*it).type(), type ) ) { 1581 if ( matchBinaryPatternA( (*it).type(), type ) ) {
1566 if ( (*it).type() & Address::Pref ) 1582 if ( (*it).type() & Address::Pref )
1567 return (*it); 1583 return (*it);
1568 else if ( address.isEmpty() ) 1584 else if ( address.isEmpty() )
1569 address = (*it); 1585 address = (*it);
1570 } 1586 }
1571 } 1587 }
1572 1588
1573 return address; 1589 return address;
1574} 1590}
1575 1591
1576Address::List Addressee::addresses() const 1592Address::List Addressee::addresses() const
1577{ 1593{
1578 return mData->addresses; 1594 return mData->addresses;
1579} 1595}
1580 1596
1581Address::List Addressee::addresses( int type ) const 1597Address::List Addressee::addresses( int type ) const
1582{ 1598{
1583 Address::List list; 1599 Address::List list;
1584 1600
1585 Address::List::ConstIterator it; 1601 Address::List::ConstIterator it;
1586 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 1602 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
1587 if ( matchBinaryPattern( (*it).type(), type ) ) { 1603 if ( matchBinaryPattern( (*it).type(), type ) ) {
1588 list.append( *it ); 1604 list.append( *it );
1589 } 1605 }
1590 } 1606 }
1591 1607
1592 return list; 1608 return list;
1593} 1609}
1594 1610
1595Address Addressee::findAddress( const QString &id ) const 1611Address Addressee::findAddress( const QString &id ) const
1596{ 1612{
1597 Address::List::ConstIterator it; 1613 Address::List::ConstIterator it;
1598 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 1614 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
1599 if ( (*it).id() == id ) { 1615 if ( (*it).id() == id ) {
1600 return *it; 1616 return *it;
1601 } 1617 }
1602 } 1618 }
1603 return Address(); 1619 return Address();
1604} 1620}
1605 1621
1606void Addressee::insertCategory( const QString &c ) 1622void Addressee::insertCategory( const QString &c )
1607{ 1623{
1608 detach(); 1624 detach();
1609 mData->empty = false; 1625 mData->empty = false;
1610 1626
1611 if ( mData->categories.contains( c ) ) return; 1627 if ( mData->categories.contains( c ) ) return;
1612 1628
1613 mData->categories.append( c ); 1629 mData->categories.append( c );
1614} 1630}
1615 1631
1616void Addressee::removeCategory( const QString &c ) 1632void Addressee::removeCategory( const QString &c )
1617{ 1633{
1618 detach(); 1634 detach();
1619 1635
1620 QStringList::Iterator it = mData->categories.find( c ); 1636 QStringList::Iterator it = mData->categories.find( c );
1621 if ( it == mData->categories.end() ) return; 1637 if ( it == mData->categories.end() ) return;
1622 1638
1623 mData->categories.remove( it ); 1639 mData->categories.remove( it );
1624} 1640}
1625 1641
1626bool Addressee::hasCategory( const QString &c ) const 1642bool Addressee::hasCategory( const QString &c ) const
1627{ 1643{
1628 return ( mData->categories.contains( c ) ); 1644 return ( mData->categories.contains( c ) );
1629} 1645}
1630 1646
1631void Addressee::setCategories( const QStringList &c ) 1647void Addressee::setCategories( const QStringList &c )
1632{ 1648{
1633 detach(); 1649 detach();
1634 mData->empty = false; 1650 mData->empty = false;
1635 1651
1636 mData->categories = c; 1652 mData->categories = c;
1637} 1653}
1638 1654
1639QStringList Addressee::categories() const 1655QStringList Addressee::categories() const
1640{ 1656{
1641 return mData->categories; 1657 return mData->categories;
1642} 1658}
1643 1659
1644void Addressee::insertCustom( const QString &app, const QString &name, 1660void Addressee::insertCustom( const QString &app, const QString &name,
1645 const QString &value ) 1661 const QString &value )
1646{ 1662{
1647 if ( value.isNull() || name.isEmpty() || app.isEmpty() ) return; 1663 if ( value.isNull() || name.isEmpty() || app.isEmpty() ) return;
1648 1664
1649 detach(); 1665 detach();
1650 mData->empty = false; 1666 mData->empty = false;
1651 1667
1652 QString qualifiedName = app + "-" + name + ":"; 1668 QString qualifiedName = app + "-" + name + ":";
1653 1669
1654 QStringList::Iterator it; 1670 QStringList::Iterator it;
1655 for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { 1671 for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) {
1656 if ( (*it).startsWith( qualifiedName ) ) { 1672 if ( (*it).startsWith( qualifiedName ) ) {
1657 (*it) = qualifiedName + value; 1673 (*it) = qualifiedName + value;
1658 return; 1674 return;
1659 } 1675 }
1660 } 1676 }
1661 mData->custom.append( qualifiedName + value ); 1677 mData->custom.append( qualifiedName + value );
1662} 1678}
1663 1679
1664void Addressee::removeCustom( const QString &app, const QString &name) 1680void Addressee::removeCustom( const QString &app, const QString &name)
1665{ 1681{
1666 detach(); 1682 detach();
1667 1683
1668 QString qualifiedName = app + "-" + name + ":"; 1684 QString qualifiedName = app + "-" + name + ":";
1669 1685
1670 QStringList::Iterator it; 1686 QStringList::Iterator it;
1671 for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { 1687 for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) {
1672 if ( (*it).startsWith( qualifiedName ) ) { 1688 if ( (*it).startsWith( qualifiedName ) ) {
1673 mData->custom.remove( it ); 1689 mData->custom.remove( it );
1674 return; 1690 return;
1675 } 1691 }
1676 } 1692 }
1677} 1693}
1678 1694
1679QString Addressee::custom( const QString &app, const QString &name ) const 1695QString Addressee::custom( const QString &app, const QString &name ) const
1680{ 1696{
1681 QString qualifiedName = app + "-" + name + ":"; 1697 QString qualifiedName = app + "-" + name + ":";
1682 QString value; 1698 QString value;
1683 1699
1684 QStringList::ConstIterator it; 1700 QStringList::ConstIterator it;
1685 for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { 1701 for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) {
1686 if ( (*it).startsWith( qualifiedName ) ) { 1702 if ( (*it).startsWith( qualifiedName ) ) {
1687 value = (*it).mid( (*it).find( ":" ) + 1 ); 1703 value = (*it).mid( (*it).find( ":" ) + 1 );
1688 break; 1704 break;
1689 } 1705 }
1690 } 1706 }
1691 1707
1692 return value; 1708 return value;
1693} 1709}
1694 1710
1695void Addressee::setCustoms( const QStringList &l ) 1711void Addressee::setCustoms( const QStringList &l )
1696{ 1712{
1697 detach(); 1713 detach();
1698 mData->empty = false; 1714 mData->empty = false;
1699 1715
1700 mData->custom = l; 1716 mData->custom = l;
1701} 1717}
1702 1718
1703QStringList Addressee::customs() const 1719QStringList Addressee::customs() const
1704{ 1720{
1705 return mData->custom; 1721 return mData->custom;
1706} 1722}
1707 1723
1708void Addressee::parseEmailAddress( const QString &rawEmail, QString &fullName, 1724void Addressee::parseEmailAddress( const QString &rawEmail, QString &fullName,
1709 QString &email) 1725 QString &email)
1710{ 1726{
1711 int startPos, endPos, len; 1727 int startPos, endPos, len;
1712 QString partA, partB, result; 1728 QString partA, partB, result;
1713 char endCh = '>'; 1729 char endCh = '>';
1714 1730
1715 startPos = rawEmail.find('<'); 1731 startPos = rawEmail.find('<');
1716 if (startPos < 0) 1732 if (startPos < 0)
1717 { 1733 {
1718 startPos = rawEmail.find('('); 1734 startPos = rawEmail.find('(');
1719 endCh = ')'; 1735 endCh = ')';
1720 } 1736 }
1721 if (startPos < 0) 1737 if (startPos < 0)
1722 { 1738 {
1723 // We couldn't find any separators, so we assume the whole string 1739 // We couldn't find any separators, so we assume the whole string
1724 // is the email address 1740 // is the email address
1725 email = rawEmail; 1741 email = rawEmail;
1726 fullName = ""; 1742 fullName = "";
1727 } 1743 }
1728 else 1744 else
1729 { 1745 {
1730 // We have a start position, try to find an end 1746 // We have a start position, try to find an end
1731 endPos = rawEmail.find(endCh, startPos+1); 1747 endPos = rawEmail.find(endCh, startPos+1);
1732 1748
1733 if (endPos < 0) 1749 if (endPos < 0)
1734 { 1750 {
1735 // We couldn't find the end of the email address. We can only 1751 // We couldn't find the end of the email address. We can only
1736 // assume the entire string is the email address. 1752 // assume the entire string is the email address.
1737 email = rawEmail; 1753 email = rawEmail;
1738 fullName = ""; 1754 fullName = "";
1739 } 1755 }
1740 else 1756 else
1741 { 1757 {
1742 // We have a start and end to the email address 1758 // We have a start and end to the email address
1743 1759
1744 // Grab the name part 1760 // Grab the name part
1745 fullName = rawEmail.left(startPos).stripWhiteSpace(); 1761 fullName = rawEmail.left(startPos).stripWhiteSpace();
1746 1762
1747 // grab the email part 1763 // grab the email part
1748 email = rawEmail.mid(startPos+1, endPos-startPos-1).stripWhiteSpace(); 1764 email = rawEmail.mid(startPos+1, endPos-startPos-1).stripWhiteSpace();
1749 1765
1750 // Check that we do not have any extra characters on the end of the 1766 // Check that we do not have any extra characters on the end of the
1751 // strings 1767 // strings
1752 len = fullName.length(); 1768 len = fullName.length();
1753 if (fullName[0]=='"' && fullName[len-1]=='"') 1769 if (fullName[0]=='"' && fullName[len-1]=='"')
1754 fullName = fullName.mid(1, len-2); 1770 fullName = fullName.mid(1, len-2);
1755 else if (fullName[0]=='<' && fullName[len-1]=='>') 1771 else if (fullName[0]=='<' && fullName[len-1]=='>')
1756 fullName = fullName.mid(1, len-2); 1772 fullName = fullName.mid(1, len-2);
1757 else if (fullName[0]=='(' && fullName[len-1]==')') 1773 else if (fullName[0]=='(' && fullName[len-1]==')')
1758 fullName = fullName.mid(1, len-2); 1774 fullName = fullName.mid(1, len-2);
1759 } 1775 }
1760 } 1776 }
1761} 1777}
1762 1778
1763void Addressee::setResource( Resource *resource ) 1779void Addressee::setResource( Resource *resource )
1764{ 1780{
1765 detach(); 1781 detach();
1766 mData->resource = resource; 1782 mData->resource = resource;
1767} 1783}
1768 1784
1769Resource *Addressee::resource() const 1785Resource *Addressee::resource() const
1770{ 1786{
1771 return mData->resource; 1787 return mData->resource;
1772} 1788}
1773 1789
1774//US 1790//US
1775QString Addressee::resourceLabel() 1791QString Addressee::resourceLabel()
1776{ 1792{
1777 return i18n("Resource"); 1793 return i18n("Resource");
1778} 1794}
1779 1795
1780void Addressee::setChanged( bool value ) 1796void Addressee::setChanged( bool value )
1781{ 1797{
1782 detach(); 1798 detach();
1783 mData->changed = value; 1799 mData->changed = value;
1784} 1800}
1785 1801
1786bool Addressee::changed() const 1802bool Addressee::changed() const
1787{ 1803{
1788 return mData->changed; 1804 return mData->changed;
1789} 1805}
1790 1806
1791QDataStream &KABC::operator<<( QDataStream &s, const Addressee &a ) 1807QDataStream &KABC::operator<<( QDataStream &s, const Addressee &a )
1792{ 1808{
1793 if (!a.mData) return s; 1809 if (!a.mData) return s;
1794 1810
1795 s << a.uid(); 1811 s << a.uid();
1796 1812
1797 s << a.mData->name; 1813 s << a.mData->name;
1798 s << a.mData->formattedName; 1814 s << a.mData->formattedName;
1799 s << a.mData->familyName; 1815 s << a.mData->familyName;
1800 s << a.mData->givenName; 1816 s << a.mData->givenName;
1801 s << a.mData->additionalName; 1817 s << a.mData->additionalName;
1802 s << a.mData->prefix; 1818 s << a.mData->prefix;
1803 s << a.mData->suffix; 1819 s << a.mData->suffix;
1804 s << a.mData->nickName; 1820 s << a.mData->nickName;
1805 s << a.mData->birthday; 1821 s << a.mData->birthday;
1806 s << a.mData->mailer; 1822 s << a.mData->mailer;
1807 s << a.mData->timeZone; 1823 s << a.mData->timeZone;
1808 s << a.mData->geo; 1824 s << a.mData->geo;
1809 s << a.mData->title; 1825 s << a.mData->title;
1810 s << a.mData->role; 1826 s << a.mData->role;
1811 s << a.mData->organization; 1827 s << a.mData->organization;
1812 s << a.mData->note; 1828 s << a.mData->note;
1813 s << a.mData->productId; 1829 s << a.mData->productId;
1814 s << a.mData->revision; 1830 s << a.mData->revision;
1815 s << a.mData->sortString; 1831 s << a.mData->sortString;
1816 s << a.mData->url; 1832 s << a.mData->url;
1817 s << a.mData->secrecy; 1833 s << a.mData->secrecy;
1818 s << a.mData->logo; 1834 s << a.mData->logo;
1819 s << a.mData->photo; 1835 s << a.mData->photo;
1820 s << a.mData->sound; 1836 s << a.mData->sound;
1821 s << a.mData->agent; 1837 s << a.mData->agent;
1822 s << a.mData->phoneNumbers; 1838 s << a.mData->phoneNumbers;
1823 s << a.mData->addresses; 1839 s << a.mData->addresses;
1824 s << a.mData->emails; 1840 s << a.mData->emails;
1825 s << a.mData->categories; 1841 s << a.mData->categories;
1826 s << a.mData->custom; 1842 s << a.mData->custom;
1827 s << a.mData->keys; 1843 s << a.mData->keys;
1828 return s; 1844 return s;
1829} 1845}
1830 1846
1831QDataStream &KABC::operator>>( QDataStream &s, Addressee &a ) 1847QDataStream &KABC::operator>>( QDataStream &s, Addressee &a )
1832{ 1848{
1833 if (!a.mData) return s; 1849 if (!a.mData) return s;
1834 1850
1835 s >> a.mData->uid; 1851 s >> a.mData->uid;
1836 1852
1837 s >> a.mData->name; 1853 s >> a.mData->name;
1838 s >> a.mData->formattedName; 1854 s >> a.mData->formattedName;
1839 s >> a.mData->familyName; 1855 s >> a.mData->familyName;
1840 s >> a.mData->givenName; 1856 s >> a.mData->givenName;
1841 s >> a.mData->additionalName; 1857 s >> a.mData->additionalName;
1842 s >> a.mData->prefix; 1858 s >> a.mData->prefix;
1843 s >> a.mData->suffix; 1859 s >> a.mData->suffix;
1844 s >> a.mData->nickName; 1860 s >> a.mData->nickName;
1845 s >> a.mData->birthday; 1861 s >> a.mData->birthday;
1846 s >> a.mData->mailer; 1862 s >> a.mData->mailer;
1847 s >> a.mData->timeZone; 1863 s >> a.mData->timeZone;
1848 s >> a.mData->geo; 1864 s >> a.mData->geo;
1849 s >> a.mData->title; 1865 s >> a.mData->title;
1850 s >> a.mData->role; 1866 s >> a.mData->role;
1851 s >> a.mData->organization; 1867 s >> a.mData->organization;
1852 s >> a.mData->note; 1868 s >> a.mData->note;
1853 s >> a.mData->productId; 1869 s >> a.mData->productId;
1854 s >> a.mData->revision; 1870 s >> a.mData->revision;
1855 s >> a.mData->sortString; 1871 s >> a.mData->sortString;
1856 s >> a.mData->url; 1872 s >> a.mData->url;
1857 s >> a.mData->secrecy; 1873 s >> a.mData->secrecy;
1858 s >> a.mData->logo; 1874 s >> a.mData->logo;
1859 s >> a.mData->photo; 1875 s >> a.mData->photo;
1860 s >> a.mData->sound; 1876 s >> a.mData->sound;
1861 s >> a.mData->agent; 1877 s >> a.mData->agent;
1862 s >> a.mData->phoneNumbers; 1878 s >> a.mData->phoneNumbers;
1863 s >> a.mData->addresses; 1879 s >> a.mData->addresses;
1864 s >> a.mData->emails; 1880 s >> a.mData->emails;
1865 s >> a.mData->categories; 1881 s >> a.mData->categories;
1866 s >> a.mData->custom; 1882 s >> a.mData->custom;
1867 s >> a.mData->keys; 1883 s >> a.mData->keys;
1868 1884
1869 a.mData->empty = false; 1885 a.mData->empty = false;
1870 1886
1871 return s; 1887 return s;
1872} 1888}
1873bool matchBinaryPattern( int value, int pattern ) 1889bool matchBinaryPattern( int value, int pattern )
1874{ 1890{
1875 /** 1891 /**
1876 We want to match all telephonnumbers/addresses which have the bits in the 1892 We want to match all telephonnumbers/addresses which have the bits in the
1877 pattern set. More are allowed. 1893 pattern set. More are allowed.
1878 if pattern == 0 we have a special handling, then we want only those with 1894 if pattern == 0 we have a special handling, then we want only those with
1879 exactly no bit set. 1895 exactly no bit set.
1880 */ 1896 */
1881 if ( pattern == 0 ) 1897 if ( pattern == 0 )
1882 return ( value == 0 ); 1898 return ( value == 0 );
1883 else 1899 else
1884 return ( pattern == ( pattern & value ) ); 1900 return ( pattern == ( pattern & value ) );
1885} 1901}
1886 1902
1887bool matchBinaryPatternP( int value, int pattern ) 1903bool matchBinaryPatternP( int value, int pattern )
1888{ 1904{
1889 1905
1890 if ( pattern == 0 ) 1906 if ( pattern == 0 )
1891 return ( value == 0 ); 1907 return ( value == 0 );
1892 else 1908 else
1893 return ( (pattern |PhoneNumber::Pref ) == ( value |PhoneNumber::Pref ) ); 1909 return ( (pattern |PhoneNumber::Pref ) == ( value |PhoneNumber::Pref ) );
1894} 1910}
1895bool matchBinaryPatternA( int value, int pattern ) 1911bool matchBinaryPatternA( int value, int pattern )
1896{ 1912{
1897 1913
1898 if ( pattern == 0 ) 1914 if ( pattern == 0 )
1899 return ( value == 0 ); 1915 return ( value == 0 );
1900 else 1916 else
1901 return ( (pattern | Address::Pref) == ( value | Address::Pref ) ); 1917 return ( (pattern | Address::Pref) == ( value | Address::Pref ) );
1902} 1918}
diff --git a/kabc/addressee.h b/kabc/addressee.h
index 4cafa86..44f0629 100644
--- a/kabc/addressee.h
+++ b/kabc/addressee.h
@@ -1,847 +1,848 @@
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 QString IDStr() const; 103 QString IDStr() const;
104 void setID( const QString &, const QString & ); 104 void setID( const QString &, const QString & );
105 QString getID( const QString & ); 105 QString getID( const QString & );
106 void setCsum( const QString &, const QString & ); 106 void setCsum( const QString &, const QString & );
107 QString getCsum( const QString & ); 107 QString getCsum( const QString & );
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 QString externalUID() const; 116 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 ); 119 void mergeContact( const Addressee& ad );
120 void simplifyEmails(); 120 void simplifyEmails();
121 void simplifyAddresses();
121 void simplifyPhoneNumbers(); 122 void simplifyPhoneNumbers();
122 void simplifyPhoneNumberTypes(); 123 void simplifyPhoneNumberTypes();
123 124
124 /** 125 /**
125 Set unique identifier. 126 Set unique identifier.
126 */ 127 */
127 void setUid( const QString &uid ); 128 void setUid( const QString &uid );
128 /** 129 /**
129 Return unique identifier. 130 Return unique identifier.
130 */ 131 */
131 QString uid() const; 132 QString uid() const;
132 /** 133 /**
133 Return translated label for uid field. 134 Return translated label for uid field.
134 */ 135 */
135 static QString uidLabel(); 136 static QString uidLabel();
136 137
137 /** 138 /**
138 Set name. 139 Set name.
139 */ 140 */
140 void setName( const QString &name ); 141 void setName( const QString &name );
141 /** 142 /**
142 Return name. 143 Return name.
143 */ 144 */
144 QString name() const; 145 QString name() const;
145 /** 146 /**
146 Return translated label for name field. 147 Return translated label for name field.
147 */ 148 */
148 static QString nameLabel(); 149 static QString nameLabel();
149 150
150 /** 151 /**
151 Set formatted name. 152 Set formatted name.
152 */ 153 */
153 void setFormattedName( const QString &formattedName ); 154 void setFormattedName( const QString &formattedName );
154 /** 155 /**
155 Return formatted name. 156 Return formatted name.
156 */ 157 */
157 QString formattedName() const; 158 QString formattedName() const;
158 /** 159 /**
159 Return translated label for formattedName field. 160 Return translated label for formattedName field.
160 */ 161 */
161 static QString formattedNameLabel(); 162 static QString formattedNameLabel();
162 163
163 /** 164 /**
164 Set family name. 165 Set family name.
165 */ 166 */
166 void setFamilyName( const QString &familyName ); 167 void setFamilyName( const QString &familyName );
167 /** 168 /**
168 Return family name. 169 Return family name.
169 */ 170 */
170 QString familyName() const; 171 QString familyName() const;
171 /** 172 /**
172 Return translated label for familyName field. 173 Return translated label for familyName field.
173 */ 174 */
174 static QString familyNameLabel(); 175 static QString familyNameLabel();
175 176
176 /** 177 /**
177 Set given name. 178 Set given name.
178 */ 179 */
179 void setGivenName( const QString &givenName ); 180 void setGivenName( const QString &givenName );
180 /** 181 /**
181 Return given name. 182 Return given name.
182 */ 183 */
183 QString givenName() const; 184 QString givenName() const;
184 /** 185 /**
185 Return translated label for givenName field. 186 Return translated label for givenName field.
186 */ 187 */
187 static QString givenNameLabel(); 188 static QString givenNameLabel();
188 189
189 /** 190 /**
190 Set additional names. 191 Set additional names.
191 */ 192 */
192 void setAdditionalName( const QString &additionalName ); 193 void setAdditionalName( const QString &additionalName );
193 /** 194 /**
194 Return additional names. 195 Return additional names.
195 */ 196 */
196 QString additionalName() const; 197 QString additionalName() const;
197 /** 198 /**
198 Return translated label for additionalName field. 199 Return translated label for additionalName field.
199 */ 200 */
200 static QString additionalNameLabel(); 201 static QString additionalNameLabel();
201 202
202 /** 203 /**
203 Set honorific prefixes. 204 Set honorific prefixes.
204 */ 205 */
205 void setPrefix( const QString &prefix ); 206 void setPrefix( const QString &prefix );
206 /** 207 /**
207 Return honorific prefixes. 208 Return honorific prefixes.
208 */ 209 */
209 QString prefix() const; 210 QString prefix() const;
210 /** 211 /**
211 Return translated label for prefix field. 212 Return translated label for prefix field.
212 */ 213 */
213 static QString prefixLabel(); 214 static QString prefixLabel();
214 215
215 /** 216 /**
216 Set honorific suffixes. 217 Set honorific suffixes.
217 */ 218 */
218 void setSuffix( const QString &suffix ); 219 void setSuffix( const QString &suffix );
219 /** 220 /**
220 Return honorific suffixes. 221 Return honorific suffixes.
221 */ 222 */
222 QString suffix() const; 223 QString suffix() const;
223 /** 224 /**
224 Return translated label for suffix field. 225 Return translated label for suffix field.
225 */ 226 */
226 static QString suffixLabel(); 227 static QString suffixLabel();
227 228
228 /** 229 /**
229 Set nick name. 230 Set nick name.
230 */ 231 */
231 void setNickName( const QString &nickName ); 232 void setNickName( const QString &nickName );
232 /** 233 /**
233 Return nick name. 234 Return nick name.
234 */ 235 */
235 QString nickName() const; 236 QString nickName() const;
236 /** 237 /**
237 Return translated label for nickName field. 238 Return translated label for nickName field.
238 */ 239 */
239 static QString nickNameLabel(); 240 static QString nickNameLabel();
240 241
241 /** 242 /**
242 Set birthday. 243 Set birthday.
243 */ 244 */
244 void setBirthday( const QDateTime &birthday ); 245 void setBirthday( const QDateTime &birthday );
245 /** 246 /**
246 Return birthday. 247 Return birthday.
247 */ 248 */
248 QDateTime birthday() const; 249 QDateTime birthday() const;
249 /** 250 /**
250 Return translated label for birthday field. 251 Return translated label for birthday field.
251 */ 252 */
252 static QString birthdayLabel(); 253 static QString birthdayLabel();
253 254
254 /** 255 /**
255 Return translated label for homeAddressStreet field. 256 Return translated label for homeAddressStreet field.
256 */ 257 */
257 static QString homeAddressStreetLabel(); 258 static QString homeAddressStreetLabel();
258 259
259 /** 260 /**
260 Return translated label for homeAddressLocality field. 261 Return translated label for homeAddressLocality field.
261 */ 262 */
262 static QString homeAddressLocalityLabel(); 263 static QString homeAddressLocalityLabel();
263 264
264 /** 265 /**
265 Return translated label for homeAddressRegion field. 266 Return translated label for homeAddressRegion field.
266 */ 267 */
267 static QString homeAddressRegionLabel(); 268 static QString homeAddressRegionLabel();
268 269
269 /** 270 /**
270 Return translated label for homeAddressPostalCode field. 271 Return translated label for homeAddressPostalCode field.
271 */ 272 */
272 static QString homeAddressPostalCodeLabel(); 273 static QString homeAddressPostalCodeLabel();
273 274
274 /** 275 /**
275 Return translated label for homeAddressCountry field. 276 Return translated label for homeAddressCountry field.
276 */ 277 */
277 static QString homeAddressCountryLabel(); 278 static QString homeAddressCountryLabel();
278 279
279 /** 280 /**
280 Return translated label for homeAddressLabel field. 281 Return translated label for homeAddressLabel field.
281 */ 282 */
282 static QString homeAddressLabelLabel(); 283 static QString homeAddressLabelLabel();
283 284
284 /** 285 /**
285 Return translated label for businessAddressStreet field. 286 Return translated label for businessAddressStreet field.
286 */ 287 */
287 static QString businessAddressStreetLabel(); 288 static QString businessAddressStreetLabel();
288 289
289 /** 290 /**
290 Return translated label for businessAddressLocality field. 291 Return translated label for businessAddressLocality field.
291 */ 292 */
292 static QString businessAddressLocalityLabel(); 293 static QString businessAddressLocalityLabel();
293 294
294 /** 295 /**
295 Return translated label for businessAddressRegion field. 296 Return translated label for businessAddressRegion field.
296 */ 297 */
297 static QString businessAddressRegionLabel(); 298 static QString businessAddressRegionLabel();
298 299
299 /** 300 /**
300 Return translated label for businessAddressPostalCode field. 301 Return translated label for businessAddressPostalCode field.
301 */ 302 */
302 static QString businessAddressPostalCodeLabel(); 303 static QString businessAddressPostalCodeLabel();
303 304
304 /** 305 /**
305 Return translated label for businessAddressCountry field. 306 Return translated label for businessAddressCountry field.
306 */ 307 */
307 static QString businessAddressCountryLabel(); 308 static QString businessAddressCountryLabel();
308 309
309 /** 310 /**
310 Return translated label for businessAddressLabel field. 311 Return translated label for businessAddressLabel field.
311 */ 312 */
312 static QString businessAddressLabelLabel(); 313 static QString businessAddressLabelLabel();
313 314
314 /** 315 /**
315 Return translated label for homePhone field. 316 Return translated label for homePhone field.
316 */ 317 */
317 static QString homePhoneLabel(); 318 static QString homePhoneLabel();
318 319
319 /** 320 /**
320 Return translated label for businessPhone field. 321 Return translated label for businessPhone field.
321 */ 322 */
322 static QString businessPhoneLabel(); 323 static QString businessPhoneLabel();
323 324
324 /** 325 /**
325 Return translated label for mobilePhone field. 326 Return translated label for mobilePhone field.
326 */ 327 */
327 static QString mobilePhoneLabel(); 328 static QString mobilePhoneLabel();
328 329
329 /** 330 /**
330 Return translated label for homeFax field. 331 Return translated label for homeFax field.
331 */ 332 */
332 static QString homeFaxLabel(); 333 static QString homeFaxLabel();
333 334
334 /** 335 /**
335 Return translated label for businessFax field. 336 Return translated label for businessFax field.
336 */ 337 */
337 static QString businessFaxLabel(); 338 static QString businessFaxLabel();
338 339
339 /** 340 /**
340 Return translated label for carPhone field. 341 Return translated label for carPhone field.
341 */ 342 */
342 static QString carPhoneLabel(); 343 static QString carPhoneLabel();
343 344
344 /** 345 /**
345 Return translated label for isdn field. 346 Return translated label for isdn field.
346 */ 347 */
347 static QString isdnLabel(); 348 static QString isdnLabel();
348 349
349 /** 350 /**
350 Return translated label for pager field. 351 Return translated label for pager field.
351 */ 352 */
352 static QString pagerLabel(); 353 static QString pagerLabel();
353 354
354 /** 355 /**
355 Return translated label for sip field. 356 Return translated label for sip field.
356 */ 357 */
357 static QString sipLabel(); 358 static QString sipLabel();
358 359
359 /** 360 /**
360 Return translated label for email field. 361 Return translated label for email field.
361 */ 362 */
362 static QString emailLabel(); 363 static QString emailLabel();
363 364
364 /** 365 /**
365 Set mail client. 366 Set mail client.
366 */ 367 */
367 void setMailer( const QString &mailer ); 368 void setMailer( const QString &mailer );
368 /** 369 /**
369 Return mail client. 370 Return mail client.
370 */ 371 */
371 QString mailer() const; 372 QString mailer() const;
372 /** 373 /**
373 Return translated label for mailer field. 374 Return translated label for mailer field.
374 */ 375 */
375 static QString mailerLabel(); 376 static QString mailerLabel();
376 377
377 /** 378 /**
378 Set time zone. 379 Set time zone.
379 */ 380 */
380 void setTimeZone( const TimeZone &timeZone ); 381 void setTimeZone( const TimeZone &timeZone );
381 /** 382 /**
382 Return time zone. 383 Return time zone.
383 */ 384 */
384 TimeZone timeZone() const; 385 TimeZone timeZone() const;
385 /** 386 /**
386 Return translated label for timeZone field. 387 Return translated label for timeZone field.
387 */ 388 */
388 static QString timeZoneLabel(); 389 static QString timeZoneLabel();
389 390
390 /** 391 /**
391 Set geographic position. 392 Set geographic position.
392 */ 393 */
393 void setGeo( const Geo &geo ); 394 void setGeo( const Geo &geo );
394 /** 395 /**
395 Return geographic position. 396 Return geographic position.
396 */ 397 */
397 Geo geo() const; 398 Geo geo() const;
398 /** 399 /**
399 Return translated label for geo field. 400 Return translated label for geo field.
400 */ 401 */
401 static QString geoLabel(); 402 static QString geoLabel();
402 403
403 /** 404 /**
404 Set title. 405 Set title.
405 */ 406 */
406 void setTitle( const QString &title ); 407 void setTitle( const QString &title );
407 /** 408 /**
408 Return title. 409 Return title.
409 */ 410 */
410 QString title() const; 411 QString title() const;
411 /** 412 /**
412 Return translated label for title field. 413 Return translated label for title field.
413 */ 414 */
414 static QString titleLabel(); 415 static QString titleLabel();
415 416
416 /** 417 /**
417 Set role. 418 Set role.
418 */ 419 */
419 void setRole( const QString &role ); 420 void setRole( const QString &role );
420 /** 421 /**
421 Return role. 422 Return role.
422 */ 423 */
423 QString role() const; 424 QString role() const;
424 /** 425 /**
425 Return translated label for role field. 426 Return translated label for role field.
426 */ 427 */
427 static QString roleLabel(); 428 static QString roleLabel();
428 429
429 /** 430 /**
430 Set organization. 431 Set organization.
431 */ 432 */
432 void setOrganization( const QString &organization ); 433 void setOrganization( const QString &organization );
433 /** 434 /**
434 Return organization. 435 Return organization.
435 */ 436 */
436 QString organization() const; 437 QString organization() const;
437 /** 438 /**
438 Return translated label for organization field. 439 Return translated label for organization field.
439 */ 440 */
440 static QString organizationLabel(); 441 static QString organizationLabel();
441 442
442 /** 443 /**
443 Set note. 444 Set note.
444 */ 445 */
445 void setNote( const QString &note ); 446 void setNote( const QString &note );
446 /** 447 /**
447 Return note. 448 Return note.
448 */ 449 */
449 QString note() const; 450 QString note() const;
450 /** 451 /**
451 Return translated label for note field. 452 Return translated label for note field.
452 */ 453 */
453 static QString noteLabel(); 454 static QString noteLabel();
454 455
455 /** 456 /**
456 Set product identifier. 457 Set product identifier.
457 */ 458 */
458 void setProductId( const QString &productId ); 459 void setProductId( const QString &productId );
459 /** 460 /**
460 Return product identifier. 461 Return product identifier.
461 */ 462 */
462 QString productId() const; 463 QString productId() const;
463 /** 464 /**
464 Return translated label for productId field. 465 Return translated label for productId field.
465 */ 466 */
466 static QString productIdLabel(); 467 static QString productIdLabel();
467 468
468 /** 469 /**
469 Set revision date. 470 Set revision date.
470 */ 471 */
471 void setRevision( const QDateTime &revision ); 472 void setRevision( const QDateTime &revision );
472 /** 473 /**
473 Return revision date. 474 Return revision date.
474 */ 475 */
475 QDateTime revision() const; 476 QDateTime revision() const;
476 /** 477 /**
477 Return translated label for revision field. 478 Return translated label for revision field.
478 */ 479 */
479 static QString revisionLabel(); 480 static QString revisionLabel();
480 481
481 /** 482 /**
482 Set sort string. 483 Set sort string.
483 */ 484 */
484 void setSortString( const QString &sortString ); 485 void setSortString( const QString &sortString );
485 /** 486 /**
486 Return sort string. 487 Return sort string.
487 */ 488 */
488 QString sortString() const; 489 QString sortString() const;
489 /** 490 /**
490 Return translated label for sortString field. 491 Return translated label for sortString field.
491 */ 492 */
492 static QString sortStringLabel(); 493 static QString sortStringLabel();
493 494
494 /** 495 /**
495 Set URL. 496 Set URL.
496 */ 497 */
497 void setUrl( const KURL &url ); 498 void setUrl( const KURL &url );
498 /** 499 /**
499 Return URL. 500 Return URL.
500 */ 501 */
501 KURL url() const; 502 KURL url() const;
502 /** 503 /**
503 Return translated label for url field. 504 Return translated label for url field.
504 */ 505 */
505 static QString urlLabel(); 506 static QString urlLabel();
506 507
507 /** 508 /**
508 Set security class. 509 Set security class.
509 */ 510 */
510 void setSecrecy( const Secrecy &secrecy ); 511 void setSecrecy( const Secrecy &secrecy );
511 /** 512 /**
512 Return security class. 513 Return security class.
513 */ 514 */
514 Secrecy secrecy() const; 515 Secrecy secrecy() const;
515 /** 516 /**
516 Return translated label for secrecy field. 517 Return translated label for secrecy field.
517 */ 518 */
518 static QString secrecyLabel(); 519 static QString secrecyLabel();
519 520
520 /** 521 /**
521 Set logo. 522 Set logo.
522 */ 523 */
523 void setLogo( const Picture &logo ); 524 void setLogo( const Picture &logo );
524 /** 525 /**
525 Return logo. 526 Return logo.
526 */ 527 */
527 Picture logo() const; 528 Picture logo() const;
528 /** 529 /**
529 Return translated label for logo field. 530 Return translated label for logo field.
530 */ 531 */
531 static QString logoLabel(); 532 static QString logoLabel();
532 533
533 /** 534 /**
534 Set photo. 535 Set photo.
535 */ 536 */
536 void setPhoto( const Picture &photo ); 537 void setPhoto( const Picture &photo );
537 /** 538 /**
538 Return photo. 539 Return photo.
539 */ 540 */
540 Picture photo() const; 541 Picture photo() const;
541 /** 542 /**
542 Return translated label for photo field. 543 Return translated label for photo field.
543 */ 544 */
544 static QString photoLabel(); 545 static QString photoLabel();
545 546
546 /** 547 /**
547 Set sound. 548 Set sound.
548 */ 549 */
549 void setSound( const Sound &sound ); 550 void setSound( const Sound &sound );
550 /** 551 /**
551 Return sound. 552 Return sound.
552 */ 553 */
553 Sound sound() const; 554 Sound sound() const;
554 /** 555 /**
555 Return translated label for sound field. 556 Return translated label for sound field.
556 */ 557 */
557 static QString soundLabel(); 558 static QString soundLabel();
558 559
559 /** 560 /**
560 Set agent. 561 Set agent.
561 */ 562 */
562 void setAgent( const Agent &agent ); 563 void setAgent( const Agent &agent );
563 /** 564 /**
564 Return agent. 565 Return agent.
565 */ 566 */
566 Agent agent() const; 567 Agent agent() const;
567 /** 568 /**
568 Return translated label for agent field. 569 Return translated label for agent field.
569 */ 570 */
570 static QString agentLabel(); 571 static QString agentLabel();
571 572
572 /** 573 /**
573 Set name fields by parsing the given string and trying to associate the 574 Set name fields by parsing the given string and trying to associate the
574 parts of the string with according fields. This function should probably 575 parts of the string with according fields. This function should probably
575 be a bit more clever. 576 be a bit more clever.
576 */ 577 */
577 void setNameFromString( const QString & ); 578 void setNameFromString( const QString & );
578 579
579 /** 580 /**
580 Return the name of the addressee. This is calculated from all the name 581 Return the name of the addressee. This is calculated from all the name
581 fields. 582 fields.
582 */ 583 */
583 QString realName() const; 584 QString realName() const;
584 585
585 /** 586 /**
586 Return the name that consists of all name parts. 587 Return the name that consists of all name parts.
587 */ 588 */
588 QString assembledName() const; 589 QString assembledName() const;
589 590
590 /** 591 /**
591 Return email address including real name. 592 Return email address including real name.
592 593
593 @param email Email address to be used to construct the full email string. 594 @param email Email address to be used to construct the full email string.
594 If this is QString::null the preferred email address is used. 595 If this is QString::null the preferred email address is used.
595 */ 596 */
596 QString fullEmail( const QString &email=QString::null ) const; 597 QString fullEmail( const QString &email=QString::null ) const;
597 598
598 /** 599 /**
599 Insert an email address. If the email address already exists in this 600 Insert an email address. If the email address already exists in this
600 addressee it is not duplicated. 601 addressee it is not duplicated.
601 602
602 @param email Email address 603 @param email Email address
603 @param preferred Set to true, if this is the preferred email address of 604 @param preferred Set to true, if this is the preferred email address of
604 the addressee. 605 the addressee.
605 */ 606 */
606 void insertEmail( const QString &email, bool preferred=false ); 607 void insertEmail( const QString &email, bool preferred=false );
607 608
608 /** 609 /**
609 Remove email address. If the email address doesn't exist, nothing happens. 610 Remove email address. If the email address doesn't exist, nothing happens.
610 */ 611 */
611 void removeEmail( const QString &email ); 612 void removeEmail( const QString &email );
612 613
613 /** 614 /**
614 Return preferred email address. This is the first email address or the 615 Return preferred email address. This is the first email address or the
615 last one added with @ref insertEmail() with a set preferred parameter. 616 last one added with @ref insertEmail() with a set preferred parameter.
616 */ 617 */
617 QString preferredEmail() const; 618 QString preferredEmail() const;
618 619
619 /** 620 /**
620 Return list of all email addresses. 621 Return list of all email addresses.
621 */ 622 */
622 QStringList emails() const; 623 QStringList emails() const;
623 624
624 /** 625 /**
625 Set the emails to @param. 626 Set the emails to @param.
626 The first email address gets the preferred one! 627 The first email address gets the preferred one!
627 @param list The list of email addresses. 628 @param list The list of email addresses.
628 */ 629 */
629 void setEmails( const QStringList& list); 630 void setEmails( const QStringList& list);
630 631
631 /** 632 /**
632 Insert a phone number. If a phone number with the same id already exists 633 Insert a phone number. If a phone number with the same id already exists
633 in this addressee it is not duplicated. 634 in this addressee it is not duplicated.
634 */ 635 */
635 void insertPhoneNumber( const PhoneNumber &phoneNumber ); 636 void insertPhoneNumber( const PhoneNumber &phoneNumber );
636 637
637 /** 638 /**
638 Remove phone number. If no phone number with the given id exists for this 639 Remove phone number. If no phone number with the given id exists for this
639 addresse nothing happens. 640 addresse nothing happens.
640 */ 641 */
641 void removePhoneNumber( const PhoneNumber &phoneNumber ); 642 void removePhoneNumber( const PhoneNumber &phoneNumber );
642 643
643 /** 644 /**
644 Return phone number, which matches the given type. 645 Return phone number, which matches the given type.
645 */ 646 */
646 PhoneNumber phoneNumber( int type ) const; 647 PhoneNumber phoneNumber( int type ) const;
647 648
648 /** 649 /**
649 Return list of all phone numbers. 650 Return list of all phone numbers.
650 */ 651 */
651 PhoneNumber::List phoneNumbers() const; 652 PhoneNumber::List phoneNumbers() const;
652 653
653 /** 654 /**
654 Return list of phone numbers with a special type. 655 Return list of phone numbers with a special type.
655 */ 656 */
656 PhoneNumber::List phoneNumbers( int type ) const; 657 PhoneNumber::List phoneNumbers( int type ) const;
657 658
658 /** 659 /**
659 Return phone number with the given id. 660 Return phone number with the given id.
660 */ 661 */
661 PhoneNumber findPhoneNumber( const QString &id ) const; 662 PhoneNumber findPhoneNumber( const QString &id ) const;
662 663
663 /** 664 /**
664 Insert a key. If a key with the same id already exists 665 Insert a key. If a key with the same id already exists
665 in this addressee it is not duplicated. 666 in this addressee it is not duplicated.
666 */ 667 */
667 void insertKey( const Key &key ); 668 void insertKey( const Key &key );
668 669
669 /** 670 /**
670 Remove a key. If no key with the given id exists for this 671 Remove a key. If no key with the given id exists for this
671 addresse nothing happens. 672 addresse nothing happens.
672 */ 673 */
673 void removeKey( const Key &key ); 674 void removeKey( const Key &key );
674 675
675 /** 676 /**
676 Return key, which matches the given type. 677 Return key, which matches the given type.
677 If @p type == Key::Custom you can specify a string 678 If @p type == Key::Custom you can specify a string
678 that should match. If you leave the string empty, the first 679 that should match. If you leave the string empty, the first
679 key with a custom value is returned. 680 key with a custom value is returned.
680 */ 681 */
681 Key key( int type, QString customTypeString = QString::null ) const; 682 Key key( int type, QString customTypeString = QString::null ) const;
682 683
683 /** 684 /**
684 Return list of all keys. 685 Return list of all keys.
685 */ 686 */
686 Key::List keys() const; 687 Key::List keys() const;
687 688
688 /** 689 /**
689 Set the list of keys 690 Set the list of keys
690 @param keys The keys to be set. 691 @param keys The keys to be set.
691 */ 692 */
692 void setKeys( const Key::List& keys); 693 void setKeys( const Key::List& keys);
693 694
694 /** 695 /**
695 Return list of keys with a special type. 696 Return list of keys with a special type.
696 If @p type == Key::Custom you can specify a string 697 If @p type == Key::Custom you can specify a string
697 that should match. If you leave the string empty, all custom 698 that should match. If you leave the string empty, all custom
698 keys will be returned. 699 keys will be returned.
699 */ 700 */
700 Key::List keys( int type, QString customTypeString = QString::null ) const; 701 Key::List keys( int type, QString customTypeString = QString::null ) const;
701 702
702 /** 703 /**
703 Return key with the given id. 704 Return key with the given id.
704 */ 705 */
705 Key findKey( const QString &id ) const; 706 Key findKey( const QString &id ) const;
706 707
707 /** 708 /**
708 Insert an address. If an address with the same id already exists 709 Insert an address. If an address with the same id already exists
709 in this addressee it is not duplicated. 710 in this addressee it is not duplicated.
710 */ 711 */
711 void insertAddress( const Address &address ); 712 void insertAddress( const Address &address );
712 713
713 /** 714 /**
714 Remove address. If no address with the given id exists for this 715 Remove address. If no address with the given id exists for this
715 addresse nothing happens. 716 addresse nothing happens.
716 */ 717 */
717 void removeAddress( const Address &address ); 718 void removeAddress( const Address &address );
718 719
719 /** 720 /**
720 Return address, which matches the given type. 721 Return address, which matches the given type.
721 */ 722 */
722 Address address( int type ) const; 723 Address address( int type ) const;
723 724
724 /** 725 /**
725 Return list of all addresses. 726 Return list of all addresses.
726 */ 727 */
727 Address::List addresses() const; 728 Address::List addresses() const;
728 729
729 /** 730 /**
730 Return list of addresses with a special type. 731 Return list of addresses with a special type.
731 */ 732 */
732 Address::List addresses( int type ) const; 733 Address::List addresses( int type ) const;
733 734
734 /** 735 /**
735 Return address with the given id. 736 Return address with the given id.
736 */ 737 */
737 Address findAddress( const QString &id ) const; 738 Address findAddress( const QString &id ) const;
738 739
739 /** 740 /**
740 Insert category. If the category already exists it is not duplicated. 741 Insert category. If the category already exists it is not duplicated.
741 */ 742 */
742 void insertCategory( const QString & ); 743 void insertCategory( const QString & );
743 744
744 /** 745 /**
745 Remove category. 746 Remove category.
746 */ 747 */
747 void removeCategory( const QString & ); 748 void removeCategory( const QString & );
748 749
749 /** 750 /**
750 Return, if addressee has the given category. 751 Return, if addressee has the given category.
751 */ 752 */
752 bool hasCategory( const QString & ) const; 753 bool hasCategory( const QString & ) const;
753 754
754 /** 755 /**
755 Set categories to given value. 756 Set categories to given value.
756 */ 757 */
757 void setCategories( const QStringList & ); 758 void setCategories( const QStringList & );
758 759
759 /** 760 /**
760 Return list of all set categories. 761 Return list of all set categories.
761 */ 762 */
762 QStringList categories() const; 763 QStringList categories() const;
763 764
764 /** 765 /**
765 Insert custom entry. The entry is identified by the name of the inserting 766 Insert custom entry. The entry is identified by the name of the inserting
766 application and a unique name. If an entry with the given app and name 767 application and a unique name. If an entry with the given app and name
767 already exists its value is replaced with the new given value. 768 already exists its value is replaced with the new given value.
768 */ 769 */
769 void insertCustom( const QString &app, const QString &name, 770 void insertCustom( const QString &app, const QString &name,
770 const QString &value ); 771 const QString &value );
771 772
772 /** 773 /**
773 Remove custom entry. 774 Remove custom entry.
774 */ 775 */
775 void removeCustom( const QString &app, const QString &name ); 776 void removeCustom( const QString &app, const QString &name );
776 777
777 /** 778 /**
778 Return value of custom entry, identified by app and entry name. 779 Return value of custom entry, identified by app and entry name.
779 */ 780 */
780 QString custom( const QString &app, const QString &name ) const; 781 QString custom( const QString &app, const QString &name ) const;
781 782
782 /** 783 /**
783 Set all custom entries. 784 Set all custom entries.
784 */ 785 */
785 void setCustoms( const QStringList & ); 786 void setCustoms( const QStringList & );
786 787
787 /** 788 /**
788 Return list of all custom entries. 789 Return list of all custom entries.
789 */ 790 */
790 QStringList customs() const; 791 QStringList customs() const;
791 792
792 /** 793 /**
793 Parse full email address. The result is given back in fullName and email. 794 Parse full email address. The result is given back in fullName and email.
794 */ 795 */
795 static void parseEmailAddress( const QString &rawEmail, QString &fullName, 796 static void parseEmailAddress( const QString &rawEmail, QString &fullName,
796 QString &email ); 797 QString &email );
797 798
798 /** 799 /**
799 Debug output. 800 Debug output.
800 */ 801 */
801 void dump() const; 802 void dump() const;
802 803
803 /** 804 /**
804 Returns string representation of the addressee. 805 Returns string representation of the addressee.
805 */ 806 */
806 QString asString() const; 807 QString asString() const;
807 808
808 /** 809 /**
809 Set resource where the addressee is from. 810 Set resource where the addressee is from.
810 */ 811 */
811 void setResource( Resource *resource ); 812 void setResource( Resource *resource );
812 813
813 /** 814 /**
814 Return pointer to resource. 815 Return pointer to resource.
815 */ 816 */
816 Resource *resource() const; 817 Resource *resource() const;
817 818
818 /** 819 /**
819 Return resourcelabel. 820 Return resourcelabel.
820 */ 821 */
821 //US 822 //US
822 static QString resourceLabel(); 823 static QString resourceLabel();
823 824
824 /** 825 /**
825 Mark addressee as changed. 826 Mark addressee as changed.
826 */ 827 */
827 void setChanged( bool value ); 828 void setChanged( bool value );
828 829
829 /** 830 /**
830 Return whether the addressee is changed. 831 Return whether the addressee is changed.
831 */ 832 */
832 bool changed() const; 833 bool changed() const;
833 834
834 private: 835 private:
835 Addressee copy(); 836 Addressee copy();
836 void detach(); 837 void detach();
837 838
838 struct AddresseeData; 839 struct AddresseeData;
839 mutable KSharedPtr<AddresseeData> mData; 840 mutable KSharedPtr<AddresseeData> mData;
840}; 841};
841 842
842QDataStream &operator<<( QDataStream &, const Addressee & ); 843QDataStream &operator<<( QDataStream &, const Addressee & );
843QDataStream &operator>>( QDataStream &, Addressee & ); 844QDataStream &operator>>( QDataStream &, Addressee & );
844 845
845} 846}
846 847
847#endif 848#endif
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index 939296f..9b059d3 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -1,2901 +1,2903 @@
1/* 1/*
2 This file is part of KAddressbook. 2 This file is part of KAddressbook.
3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> 3 Copyright (c) 2003 Tobias Koenig <tokoe@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/*s 24/*s
25Enhanced Version of the file for platform independent KDE tools. 25Enhanced Version of the file for platform independent KDE tools.
26Copyright (c) 2004 Ulf Schenk 26Copyright (c) 2004 Ulf Schenk
27 27
28$Id$ 28$Id$
29*/ 29*/
30 30
31#include "kabcore.h" 31#include "kabcore.h"
32 32
33#include <stdaddressbook.h> 33#include <stdaddressbook.h>
34#include <klocale.h> 34#include <klocale.h>
35#include <kfiledialog.h> 35#include <kfiledialog.h>
36#include <qtimer.h> 36#include <qtimer.h>
37#include <qlabel.h> 37#include <qlabel.h>
38#include <qregexp.h> 38#include <qregexp.h>
39#include <qlineedit.h> 39#include <qlineedit.h>
40#include <qcheckbox.h> 40#include <qcheckbox.h>
41#include <qpushbutton.h> 41#include <qpushbutton.h>
42#include <qprogressbar.h> 42#include <qprogressbar.h>
43#include <libkdepim/phoneaccess.h> 43#include <libkdepim/phoneaccess.h>
44 44
45#ifndef KAB_EMBEDDED 45#ifndef KAB_EMBEDDED
46#include <qclipboard.h> 46#include <qclipboard.h>
47#include <qdir.h> 47#include <qdir.h>
48#include <qfile.h> 48#include <qfile.h>
49#include <qapplicaton.h> 49#include <qapplicaton.h>
50#include <qprogressbar.h> 50#include <qprogressbar.h>
51#include <qlayout.h> 51#include <qlayout.h>
52#include <qregexp.h> 52#include <qregexp.h>
53#include <qvbox.h> 53#include <qvbox.h>
54#include <kabc/addresseelist.h> 54#include <kabc/addresseelist.h>
55#include <kabc/errorhandler.h> 55#include <kabc/errorhandler.h>
56#include <kabc/resource.h> 56#include <kabc/resource.h>
57#include <kabc/vcardconverter.h> 57#include <kabc/vcardconverter.h>
58#include <kapplication.h> 58#include <kapplication.h>
59#include <kactionclasses.h> 59#include <kactionclasses.h>
60#include <kcmultidialog.h> 60#include <kcmultidialog.h>
61#include <kdebug.h> 61#include <kdebug.h>
62#include <kdeversion.h> 62#include <kdeversion.h>
63#include <kkeydialog.h> 63#include <kkeydialog.h>
64#include <kmessagebox.h> 64#include <kmessagebox.h>
65#include <kprinter.h> 65#include <kprinter.h>
66#include <kprotocolinfo.h> 66#include <kprotocolinfo.h>
67#include <kresources/selectdialog.h> 67#include <kresources/selectdialog.h>
68#include <kstandarddirs.h> 68#include <kstandarddirs.h>
69#include <ktempfile.h> 69#include <ktempfile.h>
70#include <kxmlguiclient.h> 70#include <kxmlguiclient.h>
71#include <kaboutdata.h> 71#include <kaboutdata.h>
72#include <libkdepim/categoryselectdialog.h> 72#include <libkdepim/categoryselectdialog.h>
73 73
74#include "addresseeutil.h" 74#include "addresseeutil.h"
75#include "addresseeeditordialog.h" 75#include "addresseeeditordialog.h"
76#include "extensionmanager.h" 76#include "extensionmanager.h"
77#include "kstdaction.h" 77#include "kstdaction.h"
78#include "kaddressbookservice.h" 78#include "kaddressbookservice.h"
79#include "ldapsearchdialog.h" 79#include "ldapsearchdialog.h"
80#include "printing/printingwizard.h" 80#include "printing/printingwizard.h"
81#else // KAB_EMBEDDED 81#else // KAB_EMBEDDED
82 82
83#include <kapplication.h> 83#include <kapplication.h>
84#include "KDGanttMinimizeSplitter.h" 84#include "KDGanttMinimizeSplitter.h"
85#include "kaddressbookmain.h" 85#include "kaddressbookmain.h"
86#include "kactioncollection.h" 86#include "kactioncollection.h"
87#include "addresseedialog.h" 87#include "addresseedialog.h"
88//US 88//US
89#include <addresseeview.h> 89#include <addresseeview.h>
90 90
91#include <qapp.h> 91#include <qapp.h>
92#include <qmenubar.h> 92#include <qmenubar.h>
93//#include <qtoolbar.h> 93//#include <qtoolbar.h>
94#include <qmessagebox.h> 94#include <qmessagebox.h>
95#include <kdebug.h> 95#include <kdebug.h>
96#include <kiconloader.h> // needed for SmallIcon 96#include <kiconloader.h> // needed for SmallIcon
97#include <kresources/kcmkresources.h> 97#include <kresources/kcmkresources.h>
98#include <ktoolbar.h> 98#include <ktoolbar.h>
99 99
100 100
101//#include <qlabel.h> 101//#include <qlabel.h>
102 102
103 103
104#ifndef DESKTOP_VERSION 104#ifndef DESKTOP_VERSION
105#include <qpe/ir.h> 105#include <qpe/ir.h>
106#include <qpe/qpemenubar.h> 106#include <qpe/qpemenubar.h>
107#include <qtopia/qcopenvelope_qws.h> 107#include <qtopia/qcopenvelope_qws.h>
108#else 108#else
109 109
110#include <qmenubar.h> 110#include <qmenubar.h>
111#endif 111#endif
112 112
113#endif // KAB_EMBEDDED 113#endif // KAB_EMBEDDED
114#include "kcmconfigs/kcmkabconfig.h" 114#include "kcmconfigs/kcmkabconfig.h"
115#include "kcmconfigs/kcmkdepimconfig.h" 115#include "kcmconfigs/kcmkdepimconfig.h"
116#include "kpimglobalprefs.h" 116#include "kpimglobalprefs.h"
117#include "externalapphandler.h" 117#include "externalapphandler.h"
118 118
119 119
120#include <kresources/selectdialog.h> 120#include <kresources/selectdialog.h>
121#include <kmessagebox.h> 121#include <kmessagebox.h>
122 122
123#include <picture.h> 123#include <picture.h>
124#include <resource.h> 124#include <resource.h>
125 125
126//US#include <qsplitter.h> 126//US#include <qsplitter.h>
127#include <qmap.h> 127#include <qmap.h>
128#include <qdir.h> 128#include <qdir.h>
129#include <qfile.h> 129#include <qfile.h>
130#include <qvbox.h> 130#include <qvbox.h>
131#include <qlayout.h> 131#include <qlayout.h>
132#include <qclipboard.h> 132#include <qclipboard.h>
133#include <qtextstream.h> 133#include <qtextstream.h>
134 134
135#include <libkdepim/categoryselectdialog.h> 135#include <libkdepim/categoryselectdialog.h>
136#include <kabc/vcardconverter.h> 136#include <kabc/vcardconverter.h>
137 137
138 138
139#include "addresseeutil.h" 139#include "addresseeutil.h"
140#include "undocmds.h" 140#include "undocmds.h"
141#include "addresseeeditordialog.h" 141#include "addresseeeditordialog.h"
142#include "viewmanager.h" 142#include "viewmanager.h"
143#include "details/detailsviewcontainer.h" 143#include "details/detailsviewcontainer.h"
144#include "kabprefs.h" 144#include "kabprefs.h"
145#include "xxportmanager.h" 145#include "xxportmanager.h"
146#include "incsearchwidget.h" 146#include "incsearchwidget.h"
147#include "jumpbuttonbar.h" 147#include "jumpbuttonbar.h"
148#include "extensionmanager.h" 148#include "extensionmanager.h"
149#include "addresseeconfig.h" 149#include "addresseeconfig.h"
150#include <kcmultidialog.h> 150#include <kcmultidialog.h>
151 151
152#ifdef _WIN32_ 152#ifdef _WIN32_
153 153
154#include "kaimportoldialog.h" 154#include "kaimportoldialog.h"
155#else 155#else
156#include <unistd.h> 156#include <unistd.h>
157#endif 157#endif
158// sync includes 158// sync includes
159#include <libkdepim/ksyncprofile.h> 159#include <libkdepim/ksyncprofile.h>
160#include <libkdepim/ksyncprefsdialog.h> 160#include <libkdepim/ksyncprefsdialog.h>
161 161
162class KAex2phonePrefs : public QDialog 162class KAex2phonePrefs : public QDialog
163{ 163{
164 public: 164 public:
165 KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) : 165 KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) :
166 QDialog( parent, name, true ) 166 QDialog( parent, name, true )
167 { 167 {
168 setCaption( i18n("Export to phone options") ); 168 setCaption( i18n("Export to phone options") );
169 QVBoxLayout* lay = new QVBoxLayout( this ); 169 QVBoxLayout* lay = new QVBoxLayout( this );
170 lay->setSpacing( 3 ); 170 lay->setSpacing( 3 );
171 lay->setMargin( 3 ); 171 lay->setMargin( 3 );
172 QLabel *lab; 172 QLabel *lab;
173 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); 173 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) );
174 lab->setAlignment (AlignHCenter ); 174 lab->setAlignment (AlignHCenter );
175 QHBox* temphb; 175 QHBox* temphb;
176 temphb = new QHBox( this ); 176 temphb = new QHBox( this );
177 new QLabel( i18n("I/O device: "), temphb ); 177 new QLabel( i18n("I/O device: "), temphb );
178 mPhoneDevice = new QLineEdit( temphb); 178 mPhoneDevice = new QLineEdit( temphb);
179 lay->addWidget( temphb ); 179 lay->addWidget( temphb );
180 temphb = new QHBox( this ); 180 temphb = new QHBox( this );
181 new QLabel( i18n("Connection: "), temphb ); 181 new QLabel( i18n("Connection: "), temphb );
182 mPhoneConnection = new QLineEdit( temphb); 182 mPhoneConnection = new QLineEdit( temphb);
183 lay->addWidget( temphb ); 183 lay->addWidget( temphb );
184 temphb = new QHBox( this ); 184 temphb = new QHBox( this );
185 new QLabel( i18n("Model(opt.): "), temphb ); 185 new QLabel( i18n("Model(opt.): "), temphb );
186 mPhoneModel = new QLineEdit( temphb); 186 mPhoneModel = new QLineEdit( temphb);
187 lay->addWidget( temphb ); 187 lay->addWidget( temphb );
188 mWriteToSim= new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this ); 188 mWriteToSim= new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this );
189 lay->addWidget( mWriteToSim ); 189 lay->addWidget( mWriteToSim );
190 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) ); 190 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) );
191 lab->setAlignment (AlignHCenter ); 191 lab->setAlignment (AlignHCenter );
192 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); 192 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this );
193 lay->addWidget( ok ); 193 lay->addWidget( ok );
194 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 194 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
195 lay->addWidget( cancel ); 195 lay->addWidget( cancel );
196 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 196 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
197 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 197 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
198 resize( 220, 240 ); 198 resize( 220, 240 );
199 199
200 } 200 }
201 201
202public: 202public:
203 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; 203 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel;
204 QCheckBox* mWriteToSim; 204 QCheckBox* mWriteToSim;
205}; 205};
206 206
207bool pasteWithNewUid = true; 207bool pasteWithNewUid = true;
208 208
209#ifdef KAB_EMBEDDED 209#ifdef KAB_EMBEDDED
210KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) 210KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name )
211 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), 211 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ),
212 mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ 212 mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/
213 mReadWrite( readWrite ), mModified( false ), mMainWindow(client) 213 mReadWrite( readWrite ), mModified( false ), mMainWindow(client)
214#else //KAB_EMBEDDED 214#else //KAB_EMBEDDED
215KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) 215KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name )
216 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), 216 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ),
217 mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), 217 mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ),
218 mReadWrite( readWrite ), mModified( false ) 218 mReadWrite( readWrite ), mModified( false )
219#endif //KAB_EMBEDDED 219#endif //KAB_EMBEDDED
220{ 220{
221 // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); 221 // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu);
222 // syncManager->setBlockSave(false); 222 // syncManager->setBlockSave(false);
223 mExtensionBarSplitter = 0; 223 mExtensionBarSplitter = 0;
224 mIsPart = !parent->inherits( "KAddressBookMain" ); 224 mIsPart = !parent->inherits( "KAddressBookMain" );
225 225
226 mAddressBook = KABC::StdAddressBook::self(); 226 mAddressBook = KABC::StdAddressBook::self();
227 KABC::StdAddressBook::setAutomaticSave( false ); 227 KABC::StdAddressBook::setAutomaticSave( false );
228 228
229#ifndef KAB_EMBEDDED 229#ifndef KAB_EMBEDDED
230 mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); 230 mAddressBook->setErrorHandler( new KABC::GUIErrorHandler );
231#endif //KAB_EMBEDDED 231#endif //KAB_EMBEDDED
232 232
233 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), 233 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ),
234 SLOT( addressBookChanged() ) ); 234 SLOT( addressBookChanged() ) );
235 235
236#if 0 236#if 0
237 // LP moved to addressbook init method 237 // LP moved to addressbook init method
238 mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, 238 mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization,
239 "X-Department", "KADDRESSBOOK" ); 239 "X-Department", "KADDRESSBOOK" );
240 mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, 240 mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization,
241 "X-Profession", "KADDRESSBOOK" ); 241 "X-Profession", "KADDRESSBOOK" );
242 mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, 242 mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization,
243 "X-AssistantsName", "KADDRESSBOOK" ); 243 "X-AssistantsName", "KADDRESSBOOK" );
244 mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, 244 mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization,
245 "X-ManagersName", "KADDRESSBOOK" ); 245 "X-ManagersName", "KADDRESSBOOK" );
246 mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, 246 mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal,
247 "X-SpousesName", "KADDRESSBOOK" ); 247 "X-SpousesName", "KADDRESSBOOK" );
248 mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, 248 mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal,
249 "X-Office", "KADDRESSBOOK" ); 249 "X-Office", "KADDRESSBOOK" );
250 mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, 250 mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal,
251 "X-IMAddress", "KADDRESSBOOK" ); 251 "X-IMAddress", "KADDRESSBOOK" );
252 mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, 252 mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal,
253 "X-Anniversary", "KADDRESSBOOK" ); 253 "X-Anniversary", "KADDRESSBOOK" );
254 254
255 //US added this field to become compatible with Opie/qtopia addressbook 255 //US added this field to become compatible with Opie/qtopia addressbook
256 // values can be "female" or "male" or "". An empty field represents undefined. 256 // values can be "female" or "male" or "". An empty field represents undefined.
257 mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, 257 mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal,
258 "X-Gender", "KADDRESSBOOK" ); 258 "X-Gender", "KADDRESSBOOK" );
259 mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, 259 mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal,
260 "X-Children", "KADDRESSBOOK" ); 260 "X-Children", "KADDRESSBOOK" );
261 mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, 261 mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal,
262 "X-FreeBusyUrl", "KADDRESSBOOK" ); 262 "X-FreeBusyUrl", "KADDRESSBOOK" );
263#endif 263#endif
264 initGUI(); 264 initGUI();
265 265
266 mIncSearchWidget->setFocus(); 266 mIncSearchWidget->setFocus();
267 267
268 268
269 connect( mViewManager, SIGNAL( selected( const QString& ) ), 269 connect( mViewManager, SIGNAL( selected( const QString& ) ),
270 SLOT( setContactSelected( const QString& ) ) ); 270 SLOT( setContactSelected( const QString& ) ) );
271 connect( mViewManager, SIGNAL( executed( const QString& ) ), 271 connect( mViewManager, SIGNAL( executed( const QString& ) ),
272 SLOT( executeContact( const QString& ) ) ); 272 SLOT( executeContact( const QString& ) ) );
273 273
274 connect( mViewManager, SIGNAL( deleteRequest( ) ), 274 connect( mViewManager, SIGNAL( deleteRequest( ) ),
275 SLOT( deleteContacts( ) ) ); 275 SLOT( deleteContacts( ) ) );
276 connect( mViewManager, SIGNAL( modified() ), 276 connect( mViewManager, SIGNAL( modified() ),
277 SLOT( setModified() ) ); 277 SLOT( setModified() ) );
278 278
279 connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); 279 connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) );
280 connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) ); 280 connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) );
281 281
282 connect( mXXPortManager, SIGNAL( modified() ), 282 connect( mXXPortManager, SIGNAL( modified() ),
283 SLOT( setModified() ) ); 283 SLOT( setModified() ) );
284 284
285 connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), 285 connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ),
286 SLOT( incrementalSearch( const QString& ) ) ); 286 SLOT( incrementalSearch( const QString& ) ) );
287 connect( mIncSearchWidget, SIGNAL( fieldChanged() ), 287 connect( mIncSearchWidget, SIGNAL( fieldChanged() ),
288 mJumpButtonBar, SLOT( recreateButtons() ) ); 288 mJumpButtonBar, SLOT( recreateButtons() ) );
289 289
290 connect( mDetails, SIGNAL( sendEmail( const QString& ) ), 290 connect( mDetails, SIGNAL( sendEmail( const QString& ) ),
291 SLOT( sendMail( const QString& ) ) ); 291 SLOT( sendMail( const QString& ) ) );
292 292
293 293
294 connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&))); 294 connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&)));
295 connect( ExternalAppHandler::instance(), SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)),this, SLOT(requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&))); 295 connect( ExternalAppHandler::instance(), SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)),this, SLOT(requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)));
296 connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&))); 296 connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&)));
297 297
298 298
299#ifndef KAB_EMBEDDED 299#ifndef KAB_EMBEDDED
300 connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), 300 connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ),
301 mXXPortManager, SLOT( importVCard( const KURL& ) ) ); 301 mXXPortManager, SLOT( importVCard( const KURL& ) ) );
302 302
303 connect( mDetails, SIGNAL( browse( const QString& ) ), 303 connect( mDetails, SIGNAL( browse( const QString& ) ),
304 SLOT( browse( const QString& ) ) ); 304 SLOT( browse( const QString& ) ) );
305 305
306 306
307 mAddressBookService = new KAddressBookService( this ); 307 mAddressBookService = new KAddressBookService( this );
308 308
309#endif //KAB_EMBEDDED 309#endif //KAB_EMBEDDED
310 mEditorDialog = 0; 310 mEditorDialog = 0;
311 createAddresseeEditorDialog( this ); 311 createAddresseeEditorDialog( this );
312 setModified( false ); 312 setModified( false );
313} 313}
314 314
315KABCore::~KABCore() 315KABCore::~KABCore()
316{ 316{
317 // save(); 317 // save();
318 //saveSettings(); 318 //saveSettings();
319 //KABPrefs::instance()->writeConfig(); 319 //KABPrefs::instance()->writeConfig();
320 delete AddresseeConfig::instance(); 320 delete AddresseeConfig::instance();
321 mAddressBook = 0; 321 mAddressBook = 0;
322 KABC::StdAddressBook::close(); 322 KABC::StdAddressBook::close();
323
324 delete syncManager;
323 325
324 delete syncManager;
325} 326}
326 327
327void KABCore::restoreSettings() 328void KABCore::restoreSettings()
328{ 329{
329 mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; 330 mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce;
330 331
331 bool state; 332 bool state;
332 333
333 if (mMultipleViewsAtOnce) 334 if (mMultipleViewsAtOnce)
334 state = KABPrefs::instance()->mDetailsPageVisible; 335 state = KABPrefs::instance()->mDetailsPageVisible;
335 else 336 else
336 state = false; 337 state = false;
337 338
338 mActionDetails->setChecked( state ); 339 mActionDetails->setChecked( state );
339 setDetailsVisible( state ); 340 setDetailsVisible( state );
340 341
341 state = KABPrefs::instance()->mJumpButtonBarVisible; 342 state = KABPrefs::instance()->mJumpButtonBarVisible;
342 343
343 mActionJumpBar->setChecked( state ); 344 mActionJumpBar->setChecked( state );
344 setJumpButtonBarVisible( state ); 345 setJumpButtonBarVisible( state );
345/*US 346/*US
346 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; 347 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter;
347 if ( splitterSize.count() == 0 ) { 348 if ( splitterSize.count() == 0 ) {
348 splitterSize.append( width() / 2 ); 349 splitterSize.append( width() / 2 );
349 splitterSize.append( width() / 2 ); 350 splitterSize.append( width() / 2 );
350 } 351 }
351 mMiniSplitter->setSizes( splitterSize ); 352 mMiniSplitter->setSizes( splitterSize );
352 if ( mExtensionBarSplitter ) { 353 if ( mExtensionBarSplitter ) {
353 splitterSize = KABPrefs::instance()->mExtensionsSplitter; 354 splitterSize = KABPrefs::instance()->mExtensionsSplitter;
354 if ( splitterSize.count() == 0 ) { 355 if ( splitterSize.count() == 0 ) {
355 splitterSize.append( width() / 2 ); 356 splitterSize.append( width() / 2 );
356 splitterSize.append( width() / 2 ); 357 splitterSize.append( width() / 2 );
357 } 358 }
358 mExtensionBarSplitter->setSizes( splitterSize ); 359 mExtensionBarSplitter->setSizes( splitterSize );
359 360
360 } 361 }
361*/ 362*/
362 mViewManager->restoreSettings(); 363 mViewManager->restoreSettings();
363 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); 364 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField );
364 mExtensionManager->restoreSettings(); 365 mExtensionManager->restoreSettings();
365#ifdef DESKTOP_VERSION 366#ifdef DESKTOP_VERSION
366 int wid = width(); 367 int wid = width();
367 if ( wid < 10 ) 368 if ( wid < 10 )
368 wid = 400; 369 wid = 400;
369#else 370#else
370 int wid = QApplication::desktop()->width(); 371 int wid = QApplication::desktop()->width();
371 if ( wid < 640 ) 372 if ( wid < 640 )
372 wid = QApplication::desktop()->height(); 373 wid = QApplication::desktop()->height();
373#endif 374#endif
374 QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; 375 QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter;
375 if ( true /*splitterSize.count() == 0*/ ) { 376 if ( true /*splitterSize.count() == 0*/ ) {
376 splitterSize.append( wid / 2 ); 377 splitterSize.append( wid / 2 );
377 splitterSize.append( wid / 2 ); 378 splitterSize.append( wid / 2 );
378 } 379 }
379 mMiniSplitter->setSizes( splitterSize ); 380 mMiniSplitter->setSizes( splitterSize );
380 if ( mExtensionBarSplitter ) { 381 if ( mExtensionBarSplitter ) {
381 //splitterSize = KABPrefs::instance()->mExtensionsSplitter; 382 //splitterSize = KABPrefs::instance()->mExtensionsSplitter;
382 if ( true /*splitterSize.count() == 0*/ ) { 383 if ( true /*splitterSize.count() == 0*/ ) {
383 splitterSize.append( wid / 2 ); 384 splitterSize.append( wid / 2 );
384 splitterSize.append( wid / 2 ); 385 splitterSize.append( wid / 2 );
385 } 386 }
386 mExtensionBarSplitter->setSizes( splitterSize ); 387 mExtensionBarSplitter->setSizes( splitterSize );
387 388
388 } 389 }
389 390
390 391
391} 392}
392 393
393void KABCore::saveSettings() 394void KABCore::saveSettings()
394{ 395{
395 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); 396 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked();
396 if ( mExtensionBarSplitter ) 397 if ( mExtensionBarSplitter )
397 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 398 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
398 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); 399 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked();
399 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); 400 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes();
400#ifndef KAB_EMBEDDED 401#ifndef KAB_EMBEDDED
401 402
402 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 403 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
403 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); 404 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes();
404#endif //KAB_EMBEDDED 405#endif //KAB_EMBEDDED
405 mExtensionManager->saveSettings(); 406 mExtensionManager->saveSettings();
406 mViewManager->saveSettings(); 407 mViewManager->saveSettings();
407 408
408 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); 409 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem();
409} 410}
410 411
411KABC::AddressBook *KABCore::addressBook() const 412KABC::AddressBook *KABCore::addressBook() const
412{ 413{
413 return mAddressBook; 414 return mAddressBook;
414} 415}
415 416
416KConfig *KABCore::config() 417KConfig *KABCore::config()
417{ 418{
418#ifndef KAB_EMBEDDED 419#ifndef KAB_EMBEDDED
419 return KABPrefs::instance()->config(); 420 return KABPrefs::instance()->config();
420#else //KAB_EMBEDDED 421#else //KAB_EMBEDDED
421 return KABPrefs::instance()->getConfig(); 422 return KABPrefs::instance()->getConfig();
422#endif //KAB_EMBEDDED 423#endif //KAB_EMBEDDED
423} 424}
424 425
425KActionCollection *KABCore::actionCollection() const 426KActionCollection *KABCore::actionCollection() const
426{ 427{
427 return mGUIClient->actionCollection(); 428 return mGUIClient->actionCollection();
428} 429}
429 430
430KABC::Field *KABCore::currentSearchField() const 431KABC::Field *KABCore::currentSearchField() const
431{ 432{
432 if (mIncSearchWidget) 433 if (mIncSearchWidget)
433 return mIncSearchWidget->currentField(); 434 return mIncSearchWidget->currentField();
434 else 435 else
435 return 0; 436 return 0;
436} 437}
437 438
438QStringList KABCore::selectedUIDs() const 439QStringList KABCore::selectedUIDs() const
439{ 440{
440 return mViewManager->selectedUids(); 441 return mViewManager->selectedUids();
441} 442}
442 443
443KABC::Resource *KABCore::requestResource( QWidget *parent ) 444KABC::Resource *KABCore::requestResource( QWidget *parent )
444{ 445{
445 QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); 446 QPtrList<KABC::Resource> kabcResources = addressBook()->resources();
446 447
447 QPtrList<KRES::Resource> kresResources; 448 QPtrList<KRES::Resource> kresResources;
448 QPtrListIterator<KABC::Resource> resIt( kabcResources ); 449 QPtrListIterator<KABC::Resource> resIt( kabcResources );
449 KABC::Resource *resource; 450 KABC::Resource *resource;
450 while ( ( resource = resIt.current() ) != 0 ) { 451 while ( ( resource = resIt.current() ) != 0 ) {
451 ++resIt; 452 ++resIt;
452 if ( !resource->readOnly() ) { 453 if ( !resource->readOnly() ) {
453 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 454 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
454 if ( res ) 455 if ( res )
455 kresResources.append( res ); 456 kresResources.append( res );
456 } 457 }
457 } 458 }
458 459
459 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); 460 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent );
460 return static_cast<KABC::Resource*>( res ); 461 return static_cast<KABC::Resource*>( res );
461} 462}
462 463
463#ifndef KAB_EMBEDDED 464#ifndef KAB_EMBEDDED
464KAboutData *KABCore::createAboutData() 465KAboutData *KABCore::createAboutData()
465#else //KAB_EMBEDDED 466#else //KAB_EMBEDDED
466void KABCore::createAboutData() 467void KABCore::createAboutData()
467#endif //KAB_EMBEDDED 468#endif //KAB_EMBEDDED
468{ 469{
469#ifndef KAB_EMBEDDED 470#ifndef KAB_EMBEDDED
470 KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), 471 KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ),
471 "3.1", I18N_NOOP( "The KDE Address Book" ), 472 "3.1", I18N_NOOP( "The KDE Address Book" ),
472 KAboutData::License_GPL_V2, 473 KAboutData::License_GPL_V2,
473 I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); 474 I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) );
474 about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); 475 about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" );
475 about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); 476 about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) );
476 about->addAuthor( "Cornelius Schumacher", 477 about->addAuthor( "Cornelius Schumacher",
477 I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), 478 I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ),
478 "schumacher@kde.org" ); 479 "schumacher@kde.org" );
479 about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), 480 about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ),
480 "mpilone@slac.com" ); 481 "mpilone@slac.com" );
481 about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); 482 about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) );
482 about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); 483 about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) );
483 about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), 484 about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ),
484 "michel@klaralvdalens-datakonsult.se" ); 485 "michel@klaralvdalens-datakonsult.se" );
485 about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), 486 about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ),
486 "hansen@kde.org" ); 487 "hansen@kde.org" );
487 488
488 return about; 489 return about;
489#endif //KAB_EMBEDDED 490#endif //KAB_EMBEDDED
490 491
491 QString version; 492 QString version;
492#include <../version> 493#include <../version>
493 QMessageBox::about( this, "About KAddressbook/Pi", 494 QMessageBox::about( this, "About KAddressbook/Pi",
494 "KAddressbook/Platform-independent\n" 495 "KAddressbook/Platform-independent\n"
495 "(KA/Pi) " +version + " - " + 496 "(KA/Pi) " +version + " - " +
496#ifdef DESKTOP_VERSION 497#ifdef DESKTOP_VERSION
497 "Desktop Edition\n" 498 "Desktop Edition\n"
498#else 499#else
499 "PDA-Edition\n" 500 "PDA-Edition\n"
500 "for: Zaurus 5500 / 7x0 / 8x0\n" 501 "for: Zaurus 5500 / 7x0 / 8x0\n"
501#endif 502#endif
502 503
503 "(c) 2004 Ulf Schenk\n" 504 "(c) 2004 Ulf Schenk\n"
504 "(c) 2004 Lutz Rogowski\n" 505 "(c) 2004 Lutz Rogowski\n"
505 "(c) 1997-2003, The KDE PIM Team\n" 506 "(c) 1997-2003, The KDE PIM Team\n"
506 "Tobias Koenig Current maintainer\ntokoe@kde.org\n" 507 "Tobias Koenig Current maintainer\ntokoe@kde.org\n"
507 "Don Sanders Original author\n" 508 "Don Sanders Original author\n"
508 "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n" 509 "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n"
509 "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n" 510 "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n"
510 "Greg Stern DCOP interface\n" 511 "Greg Stern DCOP interface\n"
511 "Mark Westcot Contact pinning\n" 512 "Mark Westcot Contact pinning\n"
512 "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" 513 "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n"
513 "Steffen Hansen LDAP Lookup\nhansen@kde.org\n" 514 "Steffen Hansen LDAP Lookup\nhansen@kde.org\n"
514#ifdef _WIN32_ 515#ifdef _WIN32_
515 "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" 516 "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n"
516#endif 517#endif
517 ); 518 );
518} 519}
519 520
520void KABCore::setContactSelected( const QString &uid ) 521void KABCore::setContactSelected( const QString &uid )
521{ 522{
522 KABC::Addressee addr = mAddressBook->findByUid( uid ); 523 KABC::Addressee addr = mAddressBook->findByUid( uid );
523 if ( !mDetails->isHidden() ) 524 if ( !mDetails->isHidden() )
524 mDetails->setAddressee( addr ); 525 mDetails->setAddressee( addr );
525 526
526 if ( !addr.isEmpty() ) { 527 if ( !addr.isEmpty() ) {
527 emit contactSelected( addr.formattedName() ); 528 emit contactSelected( addr.formattedName() );
528 KABC::Picture pic = addr.photo(); 529 KABC::Picture pic = addr.photo();
529 if ( pic.isIntern() ) { 530 if ( pic.isIntern() ) {
530//US emit contactSelected( pic.data() ); 531//US emit contactSelected( pic.data() );
531//US instead use: 532//US instead use:
532 QPixmap px; 533 QPixmap px;
533 if (pic.data().isNull() != true) 534 if (pic.data().isNull() != true)
534 { 535 {
535 px.convertFromImage(pic.data()); 536 px.convertFromImage(pic.data());
536 } 537 }
537 538
538 emit contactSelected( px ); 539 emit contactSelected( px );
539 } 540 }
540 } 541 }
541 542
542 543
543 mExtensionManager->setSelectionChanged(); 544 mExtensionManager->setSelectionChanged();
544 545
545 // update the actions 546 // update the actions
546 bool selected = !uid.isEmpty(); 547 bool selected = !uid.isEmpty();
547 548
548 if ( mReadWrite ) { 549 if ( mReadWrite ) {
549 mActionCut->setEnabled( selected ); 550 mActionCut->setEnabled( selected );
550 mActionPaste->setEnabled( selected ); 551 mActionPaste->setEnabled( selected );
551 } 552 }
552 553
553 mActionCopy->setEnabled( selected ); 554 mActionCopy->setEnabled( selected );
554 mActionDelete->setEnabled( selected ); 555 mActionDelete->setEnabled( selected );
555 mActionEditAddressee->setEnabled( selected ); 556 mActionEditAddressee->setEnabled( selected );
556 mActionMail->setEnabled( selected ); 557 mActionMail->setEnabled( selected );
557 mActionMailVCard->setEnabled( selected ); 558 mActionMailVCard->setEnabled( selected );
558 //if (mActionBeam) 559 //if (mActionBeam)
559 //mActionBeam->setEnabled( selected ); 560 //mActionBeam->setEnabled( selected );
560 561
561 if (mActionBeamVCard) 562 if (mActionBeamVCard)
562 mActionBeamVCard->setEnabled( selected ); 563 mActionBeamVCard->setEnabled( selected );
563 564
564 mActionExport2phone->setEnabled( selected ); 565 mActionExport2phone->setEnabled( selected );
565 mActionWhoAmI->setEnabled( selected ); 566 mActionWhoAmI->setEnabled( selected );
566 mActionCategories->setEnabled( selected ); 567 mActionCategories->setEnabled( selected );
567} 568}
568 569
569void KABCore::sendMail() 570void KABCore::sendMail()
570{ 571{
571 sendMail( mViewManager->selectedEmails().join( ", " ) ); 572 sendMail( mViewManager->selectedEmails().join( ", " ) );
572} 573}
573 574
574void KABCore::sendMail( const QString& emaillist ) 575void KABCore::sendMail( const QString& emaillist )
575{ 576{
576 // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " 577 // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... "
577 if (emaillist.contains(",") > 0) 578 if (emaillist.contains(",") > 0)
578 ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); 579 ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null );
579 else 580 else
580 ExternalAppHandler::instance()->mailToOneContact( emaillist ); 581 ExternalAppHandler::instance()->mailToOneContact( emaillist );
581} 582}
582 583
583 584
584 585
585void KABCore::mailVCard() 586void KABCore::mailVCard()
586{ 587{
587 QStringList uids = mViewManager->selectedUids(); 588 QStringList uids = mViewManager->selectedUids();
588 if ( !uids.isEmpty() ) 589 if ( !uids.isEmpty() )
589 mailVCard( uids ); 590 mailVCard( uids );
590} 591}
591 592
592void KABCore::mailVCard( const QStringList& uids ) 593void KABCore::mailVCard( const QStringList& uids )
593{ 594{
594 QStringList urls; 595 QStringList urls;
595 596
596// QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); 597// QString tmpdir = locateLocal("tmp", KGlobal::getAppName());
597 598
598 QString dirName = "/tmp/" + KApplication::randomString( 8 ); 599 QString dirName = "/tmp/" + KApplication::randomString( 8 );
599 600
600 601
601 602
602 QDir().mkdir( dirName, true ); 603 QDir().mkdir( dirName, true );
603 604
604 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 605 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
605 KABC::Addressee a = mAddressBook->findByUid( *it ); 606 KABC::Addressee a = mAddressBook->findByUid( *it );
606 607
607 if ( a.isEmpty() ) 608 if ( a.isEmpty() )
608 continue; 609 continue;
609 610
610 QString name = a.givenName() + "_" + a.familyName() + ".vcf"; 611 QString name = a.givenName() + "_" + a.familyName() + ".vcf";
611 612
612 QString fileName = dirName + "/" + name; 613 QString fileName = dirName + "/" + name;
613 614
614 QFile outFile(fileName); 615 QFile outFile(fileName);
615 616
616 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully 617 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully
617 KABC::VCardConverter converter; 618 KABC::VCardConverter converter;
618 QString vcard; 619 QString vcard;
619 620
620 converter.addresseeToVCard( a, vcard ); 621 converter.addresseeToVCard( a, vcard );
621 622
622 QTextStream t( &outFile ); // use a text stream 623 QTextStream t( &outFile ); // use a text stream
623 t.setEncoding( QTextStream::UnicodeUTF8 ); 624 t.setEncoding( QTextStream::UnicodeUTF8 );
624 t << vcard; 625 t << vcard;
625 626
626 outFile.close(); 627 outFile.close();
627 628
628 urls.append( fileName ); 629 urls.append( fileName );
629 } 630 }
630 } 631 }
631 632
632 bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); 633 bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") );
633 634
634 635
635/*US 636/*US
636 kapp->invokeMailer( QString::null, QString::null, QString::null, 637 kapp->invokeMailer( QString::null, QString::null, QString::null,
637 QString::null, // subject 638 QString::null, // subject
638 QString::null, // body 639 QString::null, // body
639 QString::null, 640 QString::null,
640 urls ); // attachments 641 urls ); // attachments
641*/ 642*/
642 643
643} 644}
644 645
645/** 646/**
646 Beams the "WhoAmI contact. 647 Beams the "WhoAmI contact.
647*/ 648*/
648void KABCore::beamMySelf() 649void KABCore::beamMySelf()
649{ 650{
650 KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); 651 KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI();
651 if (!a.isEmpty()) 652 if (!a.isEmpty())
652 { 653 {
653 QStringList uids; 654 QStringList uids;
654 uids << a.uid(); 655 uids << a.uid();
655 656
656 beamVCard(uids); 657 beamVCard(uids);
657 } else { 658 } else {
658 KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); 659 KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) );
659 660
660 661
661 } 662 }
662} 663}
663 664
664void KABCore::export2phone() 665void KABCore::export2phone()
665{ 666{
666 667
667 KAex2phonePrefs ex2phone; 668 KAex2phonePrefs ex2phone;
668 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); 669 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection );
669 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); 670 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice );
670 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); 671 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel );
671 672
672 if ( !ex2phone.exec() ) { 673 if ( !ex2phone.exec() ) {
673 return; 674 return;
674 } 675 }
675 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); 676 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text();
676 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); 677 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text();
677 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); 678 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text();
678 679
679 680
680 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, 681 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice,
681 KPimGlobalPrefs::instance()->mEx2PhoneConnection, 682 KPimGlobalPrefs::instance()->mEx2PhoneConnection,
682 KPimGlobalPrefs::instance()->mEx2PhoneModel ); 683 KPimGlobalPrefs::instance()->mEx2PhoneModel );
683 684
684 QStringList uids = mViewManager->selectedUids(); 685 QStringList uids = mViewManager->selectedUids();
685 if ( uids.isEmpty() ) 686 if ( uids.isEmpty() )
686 return; 687 return;
687 688
688#ifdef _WIN32_ 689#ifdef _WIN32_
689 QString fileName = locateLocal("tmp", "tempfile.vcf"); 690 QString fileName = locateLocal("tmp", "tempfile.vcf");
690#else 691#else
691 QString fileName = "/tmp/kdepimtemp.vcf"; 692 QString fileName = "/tmp/kdepimtemp.vcf";
692#endif 693#endif
693 694
694 KABC::VCardConverter converter; 695 KABC::VCardConverter converter;
695 QString description; 696 QString description;
696 QString datastream; 697 QString datastream;
697 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 698 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
698 KABC::Addressee a = mAddressBook->findByUid( *it ); 699 KABC::Addressee a = mAddressBook->findByUid( *it );
699 700
700 if ( a.isEmpty() ) 701 if ( a.isEmpty() )
701 continue; 702 continue;
702 a.simplifyEmails(); 703 a.simplifyEmails();
703 a.simplifyPhoneNumbers(); 704 a.simplifyPhoneNumbers();
704 a.simplifyPhoneNumberTypes(); 705 a.simplifyPhoneNumberTypes();
706 a.simplifyAddresses();
705 707
706 if (description.isEmpty()) 708 if (description.isEmpty())
707 description = a.formattedName(); 709 description = a.formattedName();
708 QString vcard; 710 QString vcard;
709 QString vcardnew; 711 QString vcardnew;
710 converter.addresseeToVCard( a, vcard ); 712 converter.addresseeToVCard( a, vcard );
711 int start = 0; 713 int start = 0;
712 int next; 714 int next;
713 while ( (next = vcard.find("TYPE=", start) )>= 0 ) { 715 while ( (next = vcard.find("TYPE=", start) )>= 0 ) {
714 int semi = vcard.find(";", next); 716 int semi = vcard.find(";", next);
715 int dopp = vcard.find(":", next); 717 int dopp = vcard.find(":", next);
716 int sep; 718 int sep;
717 if ( semi < dopp && semi >= 0 ) 719 if ( semi < dopp && semi >= 0 )
718 sep = semi ; 720 sep = semi ;
719 else 721 else
720 sep = dopp; 722 sep = dopp;
721 vcardnew +=vcard.mid( start, next - start); 723 vcardnew +=vcard.mid( start, next - start);
722 vcardnew +=vcard.mid( next+5,sep -next -5 ).upper(); 724 vcardnew +=vcard.mid( next+5,sep -next -5 ).upper();
723 start = sep; 725 start = sep;
724 } 726 }
725 vcardnew += vcard.mid( start,vcard.length() ); 727 vcardnew += vcard.mid( start,vcard.length() );
726 vcard = ""; 728 vcard = "";
727 start = 0; 729 start = 0;
728 while ( (next = vcardnew.find("ADR", start) )>= 0 ) { 730 while ( (next = vcardnew.find("ADR", start) )>= 0 ) {
729 int sep = vcardnew.find(":", next); 731 int sep = vcardnew.find(":", next);
730 vcard +=vcardnew.mid( start, next - start+3); 732 vcard +=vcardnew.mid( start, next - start+3);
731 start = sep; 733 start = sep;
732 } 734 }
733 vcard += vcardnew.mid( start,vcardnew.length() ); 735 vcard += vcardnew.mid( start,vcardnew.length() );
734 vcard.replace ( QRegExp(";;;") , "" ); 736 vcard.replace ( QRegExp(";;;") , "" );
735 vcard.replace ( QRegExp(";;") , "" ); 737 vcard.replace ( QRegExp(";;") , "" );
736 datastream += vcard; 738 datastream += vcard;
737 739
738 } 740 }
739 QFile outFile(fileName); 741 QFile outFile(fileName);
740 if ( outFile.open(IO_WriteOnly) ) { 742 if ( outFile.open(IO_WriteOnly) ) {
741 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); 743 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" );
742 QTextStream t( &outFile ); // use a text stream 744 QTextStream t( &outFile ); // use a text stream
743 t.setEncoding( QTextStream::UnicodeUTF8 ); 745 t.setEncoding( QTextStream::UnicodeUTF8 );
744 t <<datastream; 746 t <<datastream;
745 outFile.close(); 747 outFile.close();
746 if ( PhoneAccess::writeToPhone( fileName ) ) 748 if ( PhoneAccess::writeToPhone( fileName ) )
747 qDebug("Export okay "); 749 qDebug("Export okay ");
748 else 750 else
749 qDebug("Error export contacts "); 751 qDebug("Error export contacts ");
750 752
751 } else { 753 } else {
752 qDebug("Error open temp file "); 754 qDebug("Error open temp file ");
753 return; 755 return;
754 } 756 }
755 757
756 758
757#if 0 759#if 0
758 760
759 setCaption( i18n("Writing to phone...")); 761 setCaption( i18n("Writing to phone..."));
760 if ( PhoneFormat::writeToPhone( cal ) ) 762 if ( PhoneFormat::writeToPhone( cal ) )
761 setCaption( i18n("Export to phone successful!")); 763 setCaption( i18n("Export to phone successful!"));
762 else 764 else
763 setCaption( i18n("Error exporting to phone!")); 765 setCaption( i18n("Error exporting to phone!"));
764#endif 766#endif
765 767
766 768
767} 769}
768void KABCore::beamVCard() 770void KABCore::beamVCard()
769{ 771{
770 QStringList uids = mViewManager->selectedUids(); 772 QStringList uids = mViewManager->selectedUids();
771 if ( !uids.isEmpty() ) 773 if ( !uids.isEmpty() )
772 beamVCard( uids ); 774 beamVCard( uids );
773} 775}
774 776
775 777
776void KABCore::beamVCard(const QStringList& uids) 778void KABCore::beamVCard(const QStringList& uids)
777{ 779{
778/*US 780/*US
779 QString beamFilename; 781 QString beamFilename;
780 Opie::OPimContact c; 782 Opie::OPimContact c;
781 if ( actionPersonal->isOn() ) { 783 if ( actionPersonal->isOn() ) {
782 beamFilename = addressbookPersonalVCardName(); 784 beamFilename = addressbookPersonalVCardName();
783 if ( !QFile::exists( beamFilename ) ) 785 if ( !QFile::exists( beamFilename ) )
784 return; // can't beam a non-existent file 786 return; // can't beam a non-existent file
785 Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, 787 Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null,
786 beamFilename ); 788 beamFilename );
787 Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); 789 Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true );
788 Opie::OPimContactAccess::List allList = access->allRecords(); 790 Opie::OPimContactAccess::List allList = access->allRecords();
789 Opie::OPimContactAccess::List::Iterator it = allList.begin(); // Just take first 791 Opie::OPimContactAccess::List::Iterator it = allList.begin(); // Just take first
790 c = *it; 792 c = *it;
791 793
792 delete access; 794 delete access;
793 } else { 795 } else {
794 unlink( beamfile ); // delete if exists 796 unlink( beamfile ); // delete if exists
795 mkdir("/tmp/obex/", 0755); 797 mkdir("/tmp/obex/", 0755);
796 c = m_abView -> currentEntry(); 798 c = m_abView -> currentEntry();
797 Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, 799 Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null,
798 beamfile ); 800 beamfile );
799 Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); 801 Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true );
800 access->add( c ); 802 access->add( c );
801 access->save(); 803 access->save();
802 delete access; 804 delete access;
803 805
804 beamFilename = beamfile; 806 beamFilename = beamfile;
805 } 807 }
806 808
807 owarn << "Beaming: " << beamFilename << oendl; 809 owarn << "Beaming: " << beamFilename << oendl;
808*/ 810*/
809 811
810#if 0 812#if 0
811 QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); 813 QString tmpdir = locateLocal("tmp", KGlobal::getAppName());
812 814
813 QString dirName = tmpdir + "/" + KApplication::randomString( 8 ); 815 QString dirName = tmpdir + "/" + KApplication::randomString( 8 );
814 816
815 QString name = "contact.vcf"; 817 QString name = "contact.vcf";
816 818
817 QString fileName = dirName + "/" + name; 819 QString fileName = dirName + "/" + name;
818#endif 820#endif
819 // LR: we should use the /tmp dir, because: /tmp = RAM, (HOME)/kdepim = flash memory 821 // LR: we should use the /tmp dir, because: /tmp = RAM, (HOME)/kdepim = flash memory
820 // 822 //
821 QString fileName = "/tmp/kapibeamfile.vcf"; 823 QString fileName = "/tmp/kapibeamfile.vcf";
822 824
823 825
824 //QDir().mkdir( dirName, true ); 826 //QDir().mkdir( dirName, true );
825 827
826 828
827 KABC::VCardConverter converter; 829 KABC::VCardConverter converter;
828 QString description; 830 QString description;
829 QString datastream; 831 QString datastream;
830 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 832 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
831 KABC::Addressee a = mAddressBook->findByUid( *it ); 833 KABC::Addressee a = mAddressBook->findByUid( *it );
832 834
833 if ( a.isEmpty() ) 835 if ( a.isEmpty() )
834 continue; 836 continue;
835 837
836 if (description.isEmpty()) 838 if (description.isEmpty())
837 description = a.formattedName(); 839 description = a.formattedName();
838 840
839 QString vcard; 841 QString vcard;
840 converter.addresseeToVCard( a, vcard ); 842 converter.addresseeToVCard( a, vcard );
841 int start = 0; 843 int start = 0;
842 int next; 844 int next;
843 while ( (next = vcard.find("TYPE=", start) )>= 0 ) { 845 while ( (next = vcard.find("TYPE=", start) )>= 0 ) {
844 int semi = vcard.find(";", next); 846 int semi = vcard.find(";", next);
845 int dopp = vcard.find(":", next); 847 int dopp = vcard.find(":", next);
846 int sep; 848 int sep;
847 if ( semi < dopp && semi >= 0 ) 849 if ( semi < dopp && semi >= 0 )
848 sep = semi ; 850 sep = semi ;
849 else 851 else
850 sep = dopp; 852 sep = dopp;
851 datastream +=vcard.mid( start, next - start); 853 datastream +=vcard.mid( start, next - start);
852 datastream +=vcard.mid( next+5,sep -next -5 ).upper(); 854 datastream +=vcard.mid( next+5,sep -next -5 ).upper();
853 start = sep; 855 start = sep;
854 } 856 }
855 datastream += vcard.mid( start,vcard.length() ); 857 datastream += vcard.mid( start,vcard.length() );
856 } 858 }
857#ifndef DESKTOP_VERSION 859#ifndef DESKTOP_VERSION
858 QFile outFile(fileName); 860 QFile outFile(fileName);
859 if ( outFile.open(IO_WriteOnly) ) { 861 if ( outFile.open(IO_WriteOnly) ) {
860 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); 862 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" );
861 QTextStream t( &outFile ); // use a text stream 863 QTextStream t( &outFile ); // use a text stream
862 t.setEncoding( QTextStream::UnicodeUTF8 ); 864 t.setEncoding( QTextStream::UnicodeUTF8 );
863 t <<datastream; 865 t <<datastream;
864 outFile.close(); 866 outFile.close();
865 Ir *ir = new Ir( this ); 867 Ir *ir = new Ir( this );
866 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); 868 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) );
867 ir->send( fileName, description, "text/x-vCard" ); 869 ir->send( fileName, description, "text/x-vCard" );
868 } else { 870 } else {
869 qDebug("Error open temp beam file "); 871 qDebug("Error open temp beam file ");
870 return; 872 return;
871 } 873 }
872#endif 874#endif
873 875
874} 876}
875 877
876void KABCore::beamDone( Ir *ir ) 878void KABCore::beamDone( Ir *ir )
877{ 879{
878#ifndef DESKTOP_VERSION 880#ifndef DESKTOP_VERSION
879 delete ir; 881 delete ir;
880#endif 882#endif
881} 883}
882 884
883 885
884void KABCore::browse( const QString& url ) 886void KABCore::browse( const QString& url )
885{ 887{
886#ifndef KAB_EMBEDDED 888#ifndef KAB_EMBEDDED
887 kapp->invokeBrowser( url ); 889 kapp->invokeBrowser( url );
888#else //KAB_EMBEDDED 890#else //KAB_EMBEDDED
889 qDebug("KABCore::browse must be fixed"); 891 qDebug("KABCore::browse must be fixed");
890#endif //KAB_EMBEDDED 892#endif //KAB_EMBEDDED
891} 893}
892 894
893void KABCore::selectAllContacts() 895void KABCore::selectAllContacts()
894{ 896{
895 mViewManager->setSelected( QString::null, true ); 897 mViewManager->setSelected( QString::null, true );
896} 898}
897 899
898void KABCore::deleteContacts() 900void KABCore::deleteContacts()
899{ 901{
900 QStringList uidList = mViewManager->selectedUids(); 902 QStringList uidList = mViewManager->selectedUids();
901 deleteContacts( uidList ); 903 deleteContacts( uidList );
902} 904}
903 905
904void KABCore::deleteContacts( const QStringList &uids ) 906void KABCore::deleteContacts( const QStringList &uids )
905{ 907{
906 if ( uids.count() > 0 ) { 908 if ( uids.count() > 0 ) {
907 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); 909 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids );
908 UndoStack::instance()->push( command ); 910 UndoStack::instance()->push( command );
909 RedoStack::instance()->clear(); 911 RedoStack::instance()->clear();
910 912
911 // now if we deleted anything, refresh 913 // now if we deleted anything, refresh
912 setContactSelected( QString::null ); 914 setContactSelected( QString::null );
913 setModified( true ); 915 setModified( true );
914 } 916 }
915} 917}
916 918
917void KABCore::copyContacts() 919void KABCore::copyContacts()
918{ 920{
919 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 921 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
920 922
921 QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); 923 QString clipText = AddresseeUtil::addresseesToClipboard( addrList );
922 924
923 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; 925 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl;
924 926
925 QClipboard *cb = QApplication::clipboard(); 927 QClipboard *cb = QApplication::clipboard();
926 cb->setText( clipText ); 928 cb->setText( clipText );
927} 929}
928 930
929void KABCore::cutContacts() 931void KABCore::cutContacts()
930{ 932{
931 QStringList uidList = mViewManager->selectedUids(); 933 QStringList uidList = mViewManager->selectedUids();
932 934
933//US if ( uidList.size() > 0 ) { 935//US if ( uidList.size() > 0 ) {
934 if ( uidList.count() > 0 ) { 936 if ( uidList.count() > 0 ) {
935 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); 937 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList );
936 UndoStack::instance()->push( command ); 938 UndoStack::instance()->push( command );
937 RedoStack::instance()->clear(); 939 RedoStack::instance()->clear();
938 940
939 setModified( true ); 941 setModified( true );
940 } 942 }
941} 943}
942 944
943void KABCore::pasteContacts() 945void KABCore::pasteContacts()
944{ 946{
945 QClipboard *cb = QApplication::clipboard(); 947 QClipboard *cb = QApplication::clipboard();
946 948
947 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); 949 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() );
948 950
949 pasteContacts( list ); 951 pasteContacts( list );
950} 952}
951 953
952void KABCore::pasteContacts( KABC::Addressee::List &list ) 954void KABCore::pasteContacts( KABC::Addressee::List &list )
953{ 955{
954 KABC::Resource *resource = requestResource( this ); 956 KABC::Resource *resource = requestResource( this );
955 KABC::Addressee::List::Iterator it; 957 KABC::Addressee::List::Iterator it;
956 for ( it = list.begin(); it != list.end(); ++it ) 958 for ( it = list.begin(); it != list.end(); ++it )
957 (*it).setResource( resource ); 959 (*it).setResource( resource );
958 960
959 PwPasteCommand *command = new PwPasteCommand( this, list ); 961 PwPasteCommand *command = new PwPasteCommand( this, list );
960 UndoStack::instance()->push( command ); 962 UndoStack::instance()->push( command );
961 RedoStack::instance()->clear(); 963 RedoStack::instance()->clear();
962 964
963 setModified( true ); 965 setModified( true );
964} 966}
965 967
966void KABCore::setWhoAmI() 968void KABCore::setWhoAmI()
967{ 969{
968 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 970 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
969 971
970 if ( addrList.count() > 1 ) { 972 if ( addrList.count() > 1 ) {
971 KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); 973 KMessageBox::sorry( this, i18n( "Please select only one contact." ) );
972 return; 974 return;
973 } 975 }
974 976
975 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); 977 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) );
976 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) 978 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes )
977 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); 979 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] );
978} 980}
979 981
980void KABCore::setCategories() 982void KABCore::setCategories()
981{ 983{
982 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); 984 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true );
983 if ( !dlg.exec() ) 985 if ( !dlg.exec() )
984 return; 986 return;
985 987
986 bool merge = false; 988 bool merge = false;
987 QString msg = i18n( "Merge with existing categories?" ); 989 QString msg = i18n( "Merge with existing categories?" );
988 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) 990 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes )
989 merge = true; 991 merge = true;
990 992
991 QStringList categories = dlg.selectedCategories(); 993 QStringList categories = dlg.selectedCategories();
992 994
993 QStringList uids = mViewManager->selectedUids(); 995 QStringList uids = mViewManager->selectedUids();
994 QStringList::Iterator it; 996 QStringList::Iterator it;
995 for ( it = uids.begin(); it != uids.end(); ++it ) { 997 for ( it = uids.begin(); it != uids.end(); ++it ) {
996 KABC::Addressee addr = mAddressBook->findByUid( *it ); 998 KABC::Addressee addr = mAddressBook->findByUid( *it );
997 if ( !addr.isEmpty() ) { 999 if ( !addr.isEmpty() ) {
998 if ( !merge ) 1000 if ( !merge )
999 addr.setCategories( categories ); 1001 addr.setCategories( categories );
1000 else { 1002 else {
1001 QStringList addrCategories = addr.categories(); 1003 QStringList addrCategories = addr.categories();
1002 QStringList::Iterator catIt; 1004 QStringList::Iterator catIt;
1003 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { 1005 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) {
1004 if ( !addrCategories.contains( *catIt ) ) 1006 if ( !addrCategories.contains( *catIt ) )
1005 addrCategories.append( *catIt ); 1007 addrCategories.append( *catIt );
1006 } 1008 }
1007 addr.setCategories( addrCategories ); 1009 addr.setCategories( addrCategories );
1008 } 1010 }
1009 1011
1010 mAddressBook->insertAddressee( addr ); 1012 mAddressBook->insertAddressee( addr );
1011 } 1013 }
1012 } 1014 }
1013 1015
1014 if ( uids.count() > 0 ) 1016 if ( uids.count() > 0 )
1015 setModified( true ); 1017 setModified( true );
1016} 1018}
1017 1019
1018void KABCore::setSearchFields( const KABC::Field::List &fields ) 1020void KABCore::setSearchFields( const KABC::Field::List &fields )
1019{ 1021{
1020 mIncSearchWidget->setFields( fields ); 1022 mIncSearchWidget->setFields( fields );
1021} 1023}
1022 1024
1023void KABCore::incrementalSearch( const QString& text ) 1025void KABCore::incrementalSearch( const QString& text )
1024{ 1026{
1025 mViewManager->doSearch( text, mIncSearchWidget->currentField() ); 1027 mViewManager->doSearch( text, mIncSearchWidget->currentField() );
1026} 1028}
1027 1029
1028void KABCore::setModified() 1030void KABCore::setModified()
1029{ 1031{
1030 setModified( true ); 1032 setModified( true );
1031} 1033}
1032 1034
1033void KABCore::setModifiedWOrefresh() 1035void KABCore::setModifiedWOrefresh()
1034{ 1036{
1035 // qDebug("KABCore::setModifiedWOrefresh() "); 1037 // qDebug("KABCore::setModifiedWOrefresh() ");
1036 mModified = true; 1038 mModified = true;
1037 mActionSave->setEnabled( mModified ); 1039 mActionSave->setEnabled( mModified );
1038#ifdef DESKTOP_VERSION 1040#ifdef DESKTOP_VERSION
1039 mDetails->refreshView(); 1041 mDetails->refreshView();
1040#endif 1042#endif
1041 1043
1042} 1044}
1043void KABCore::setModified( bool modified ) 1045void KABCore::setModified( bool modified )
1044{ 1046{
1045 mModified = modified; 1047 mModified = modified;
1046 mActionSave->setEnabled( mModified ); 1048 mActionSave->setEnabled( mModified );
1047 1049
1048 if ( modified ) 1050 if ( modified )
1049 mJumpButtonBar->recreateButtons(); 1051 mJumpButtonBar->recreateButtons();
1050 1052
1051 mViewManager->refreshView(); 1053 mViewManager->refreshView();
1052 mDetails->refreshView(); 1054 mDetails->refreshView();
1053 1055
1054} 1056}
1055 1057
1056bool KABCore::modified() const 1058bool KABCore::modified() const
1057{ 1059{
1058 return mModified; 1060 return mModified;
1059} 1061}
1060 1062
1061void KABCore::contactModified( const KABC::Addressee &addr ) 1063void KABCore::contactModified( const KABC::Addressee &addr )
1062{ 1064{
1063 1065
1064 Command *command = 0; 1066 Command *command = 0;
1065 QString uid; 1067 QString uid;
1066 1068
1067 // check if it exists already 1069 // check if it exists already
1068 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); 1070 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() );
1069 if ( origAddr.isEmpty() ) 1071 if ( origAddr.isEmpty() )
1070 command = new PwNewCommand( mAddressBook, addr ); 1072 command = new PwNewCommand( mAddressBook, addr );
1071 else { 1073 else {
1072 command = new PwEditCommand( mAddressBook, origAddr, addr ); 1074 command = new PwEditCommand( mAddressBook, origAddr, addr );
1073 uid = addr.uid(); 1075 uid = addr.uid();
1074 } 1076 }
1075 1077
1076 UndoStack::instance()->push( command ); 1078 UndoStack::instance()->push( command );
1077 RedoStack::instance()->clear(); 1079 RedoStack::instance()->clear();
1078 1080
1079 setModified( true ); 1081 setModified( true );
1080} 1082}
1081 1083
1082void KABCore::newContact() 1084void KABCore::newContact()
1083{ 1085{
1084 1086
1085 1087
1086 QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); 1088 QPtrList<KABC::Resource> kabcResources = mAddressBook->resources();
1087 1089
1088 QPtrList<KRES::Resource> kresResources; 1090 QPtrList<KRES::Resource> kresResources;
1089 QPtrListIterator<KABC::Resource> it( kabcResources ); 1091 QPtrListIterator<KABC::Resource> it( kabcResources );
1090 KABC::Resource *resource; 1092 KABC::Resource *resource;
1091 while ( ( resource = it.current() ) != 0 ) { 1093 while ( ( resource = it.current() ) != 0 ) {
1092 ++it; 1094 ++it;
1093 if ( !resource->readOnly() ) { 1095 if ( !resource->readOnly() ) {
1094 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 1096 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
1095 if ( res ) 1097 if ( res )
1096 kresResources.append( res ); 1098 kresResources.append( res );
1097 } 1099 }
1098 } 1100 }
1099 1101
1100 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); 1102 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this );
1101 resource = static_cast<KABC::Resource*>( res ); 1103 resource = static_cast<KABC::Resource*>( res );
1102 1104
1103 if ( resource ) { 1105 if ( resource ) {
1104 KABC::Addressee addr; 1106 KABC::Addressee addr;
1105 addr.setResource( resource ); 1107 addr.setResource( resource );
1106 mEditorDialog->setAddressee( addr ); 1108 mEditorDialog->setAddressee( addr );
1107 KApplication::execDialog ( mEditorDialog ); 1109 KApplication::execDialog ( mEditorDialog );
1108 1110
1109 } else 1111 } else
1110 return; 1112 return;
1111 1113
1112 // mEditorDict.insert( dialog->addressee().uid(), dialog ); 1114 // mEditorDict.insert( dialog->addressee().uid(), dialog );
1113 1115
1114 1116
1115} 1117}
1116 1118
1117void KABCore::addEmail( QString aStr ) 1119void KABCore::addEmail( QString aStr )
1118{ 1120{
1119#ifndef KAB_EMBEDDED 1121#ifndef KAB_EMBEDDED
1120 QString fullName, email; 1122 QString fullName, email;
1121 1123
1122 KABC::Addressee::parseEmailAddress( aStr, fullName, email ); 1124 KABC::Addressee::parseEmailAddress( aStr, fullName, email );
1123 1125
1124 // Try to lookup the addressee matching the email address 1126 // Try to lookup the addressee matching the email address
1125 bool found = false; 1127 bool found = false;
1126 QStringList emailList; 1128 QStringList emailList;
1127 KABC::AddressBook::Iterator it; 1129 KABC::AddressBook::Iterator it;
1128 for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { 1130 for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) {
1129 emailList = (*it).emails(); 1131 emailList = (*it).emails();
1130 if ( emailList.contains( email ) > 0 ) { 1132 if ( emailList.contains( email ) > 0 ) {
1131 found = true; 1133 found = true;
1132 (*it).setNameFromString( fullName ); 1134 (*it).setNameFromString( fullName );
1133 editContact( (*it).uid() ); 1135 editContact( (*it).uid() );
1134 } 1136 }
1135 } 1137 }
1136 1138
1137 if ( !found ) { 1139 if ( !found ) {
1138 KABC::Addressee addr; 1140 KABC::Addressee addr;
1139 addr.setNameFromString( fullName ); 1141 addr.setNameFromString( fullName );
1140 addr.insertEmail( email, true ); 1142 addr.insertEmail( email, true );
1141 1143
1142 mAddressBook->insertAddressee( addr ); 1144 mAddressBook->insertAddressee( addr );
1143 mViewManager->refreshView( addr.uid() ); 1145 mViewManager->refreshView( addr.uid() );
1144 editContact( addr.uid() ); 1146 editContact( addr.uid() );
1145 } 1147 }
1146#else //KAB_EMBEDDED 1148#else //KAB_EMBEDDED
1147 qDebug("KABCore::addEmail finsih method"); 1149 qDebug("KABCore::addEmail finsih method");
1148#endif //KAB_EMBEDDED 1150#endif //KAB_EMBEDDED
1149} 1151}
1150 1152
1151void KABCore::importVCard( const KURL &url, bool showPreview ) 1153void KABCore::importVCard( const KURL &url, bool showPreview )
1152{ 1154{
1153 mXXPortManager->importVCard( url, showPreview ); 1155 mXXPortManager->importVCard( url, showPreview );
1154} 1156}
1155void KABCore::importFromOL() 1157void KABCore::importFromOL()
1156{ 1158{
1157#ifdef _WIN32_ 1159#ifdef _WIN32_
1158 KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); 1160 KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this );
1159 idgl->exec(); 1161 idgl->exec();
1160 KABC::Addressee::List list = idgl->getAddressList(); 1162 KABC::Addressee::List list = idgl->getAddressList();
1161 if ( list.count() > 0 ) { 1163 if ( list.count() > 0 ) {
1162 KABC::Addressee::List listNew; 1164 KABC::Addressee::List listNew;
1163 KABC::Addressee::List listExisting; 1165 KABC::Addressee::List listExisting;
1164 KABC::Addressee::List::Iterator it; 1166 KABC::Addressee::List::Iterator it;
1165 KABC::AddressBook::Iterator iter; 1167 KABC::AddressBook::Iterator iter;
1166 for ( it = list.begin(); it != list.end(); ++it ) { 1168 for ( it = list.begin(); it != list.end(); ++it ) {
1167 if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) 1169 if ( mAddressBook->findByUid((*it).uid() ).isEmpty())
1168 listNew.append( (*it) ); 1170 listNew.append( (*it) );
1169 else 1171 else
1170 listExisting.append( (*it) ); 1172 listExisting.append( (*it) );
1171 } 1173 }
1172 if ( listExisting.count() > 0 ) 1174 if ( listExisting.count() > 0 )
1173 KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); 1175 KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() ));
1174 if ( listNew.count() > 0 ) { 1176 if ( listNew.count() > 0 ) {
1175 pasteWithNewUid = false; 1177 pasteWithNewUid = false;
1176 pasteContacts( listNew ); 1178 pasteContacts( listNew );
1177 pasteWithNewUid = true; 1179 pasteWithNewUid = true;
1178 } 1180 }
1179 } 1181 }
1180 delete idgl; 1182 delete idgl;
1181#endif 1183#endif
1182} 1184}
1183 1185
1184void KABCore::importVCard( const QString &vCard, bool showPreview ) 1186void KABCore::importVCard( const QString &vCard, bool showPreview )
1185{ 1187{
1186 mXXPortManager->importVCard( vCard, showPreview ); 1188 mXXPortManager->importVCard( vCard, showPreview );
1187} 1189}
1188 1190
1189//US added a second method without defaultparameter 1191//US added a second method without defaultparameter
1190void KABCore::editContact2() { 1192void KABCore::editContact2() {
1191 editContact( QString::null ); 1193 editContact( QString::null );
1192} 1194}
1193 1195
1194void KABCore::editContact( const QString &uid ) 1196void KABCore::editContact( const QString &uid )
1195{ 1197{
1196 1198
1197 if ( mExtensionManager->isQuickEditVisible() ) 1199 if ( mExtensionManager->isQuickEditVisible() )
1198 return; 1200 return;
1199 1201
1200 // First, locate the contact entry 1202 // First, locate the contact entry
1201 QString localUID = uid; 1203 QString localUID = uid;
1202 if ( localUID.isNull() ) { 1204 if ( localUID.isNull() ) {
1203 QStringList uidList = mViewManager->selectedUids(); 1205 QStringList uidList = mViewManager->selectedUids();
1204 if ( uidList.count() > 0 ) 1206 if ( uidList.count() > 0 )
1205 localUID = *( uidList.at( 0 ) ); 1207 localUID = *( uidList.at( 0 ) );
1206 } 1208 }
1207 1209
1208 KABC::Addressee addr = mAddressBook->findByUid( localUID ); 1210 KABC::Addressee addr = mAddressBook->findByUid( localUID );
1209 if ( !addr.isEmpty() ) { 1211 if ( !addr.isEmpty() ) {
1210 mEditorDialog->setAddressee( addr ); 1212 mEditorDialog->setAddressee( addr );
1211 KApplication::execDialog ( mEditorDialog ); 1213 KApplication::execDialog ( mEditorDialog );
1212 } 1214 }
1213} 1215}
1214 1216
1215/** 1217/**
1216 Shows or edits the detail view for the given uid. If the uid is QString::null, 1218 Shows or edits the detail view for the given uid. If the uid is QString::null,
1217 the method will try to find a selected addressee in the view. 1219 the method will try to find a selected addressee in the view.
1218 */ 1220 */
1219void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) 1221void KABCore::executeContact( const QString &uid /*US = QString::null*/ )
1220{ 1222{
1221 if ( mMultipleViewsAtOnce ) 1223 if ( mMultipleViewsAtOnce )
1222 { 1224 {
1223 editContact( uid ); 1225 editContact( uid );
1224 } 1226 }
1225 else 1227 else
1226 { 1228 {
1227 setDetailsVisible( true ); 1229 setDetailsVisible( true );
1228 mActionDetails->setChecked(true); 1230 mActionDetails->setChecked(true);
1229 } 1231 }
1230 1232
1231} 1233}
1232 1234
1233void KABCore::save() 1235void KABCore::save()
1234{ 1236{
1235 if (syncManager->blockSave()) 1237 if (syncManager->blockSave())
1236 return; 1238 return;
1237 if ( !mModified ) 1239 if ( !mModified )
1238 return; 1240 return;
1239 1241
1240 syncManager->setBlockSave(true); 1242 syncManager->setBlockSave(true);
1241 QString text = i18n( "There was an error while attempting to save\n the " 1243 QString text = i18n( "There was an error while attempting to save\n the "
1242 "address book. Please check that some \nother application is " 1244 "address book. Please check that some \nother application is "
1243 "not using it. " ); 1245 "not using it. " );
1244 statusMessage(i18n("Saving addressbook ... ")); 1246 statusMessage(i18n("Saving addressbook ... "));
1245#ifndef KAB_EMBEDDED 1247#ifndef KAB_EMBEDDED
1246 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); 1248 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook );
1247 if ( !b || !b->save() ) { 1249 if ( !b || !b->save() ) {
1248 KMessageBox::error( this, text, i18n( "Unable to Save" ) ); 1250 KMessageBox::error( this, text, i18n( "Unable to Save" ) );
1249 } 1251 }
1250#else //KAB_EMBEDDED 1252#else //KAB_EMBEDDED
1251 KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); 1253 KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook );
1252 if ( !b || !b->save() ) { 1254 if ( !b || !b->save() ) {
1253 QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); 1255 QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok"));
1254 } 1256 }
1255#endif //KAB_EMBEDDED 1257#endif //KAB_EMBEDDED
1256 1258
1257 statusMessage(i18n("Addressbook saved!")); 1259 statusMessage(i18n("Addressbook saved!"));
1258 setModified( false ); 1260 setModified( false );
1259 syncManager->setBlockSave(false); 1261 syncManager->setBlockSave(false);
1260} 1262}
1261 1263
1262void KABCore::statusMessage(QString mess , int time ) 1264void KABCore::statusMessage(QString mess , int time )
1263{ 1265{
1264 //topLevelWidget()->setCaption( mess ); 1266 //topLevelWidget()->setCaption( mess );
1265 // pending setting timer to revome message 1267 // pending setting timer to revome message
1266} 1268}
1267void KABCore::undo() 1269void KABCore::undo()
1268{ 1270{
1269 UndoStack::instance()->undo(); 1271 UndoStack::instance()->undo();
1270 1272
1271 // Refresh the view 1273 // Refresh the view
1272 mViewManager->refreshView(); 1274 mViewManager->refreshView();
1273} 1275}
1274 1276
1275void KABCore::redo() 1277void KABCore::redo()
1276{ 1278{
1277 RedoStack::instance()->redo(); 1279 RedoStack::instance()->redo();
1278 1280
1279 // Refresh the view 1281 // Refresh the view
1280 mViewManager->refreshView(); 1282 mViewManager->refreshView();
1281} 1283}
1282 1284
1283void KABCore::setJumpButtonBarVisible( bool visible ) 1285void KABCore::setJumpButtonBarVisible( bool visible )
1284{ 1286{
1285 if (mMultipleViewsAtOnce) 1287 if (mMultipleViewsAtOnce)
1286 { 1288 {
1287 if ( visible ) 1289 if ( visible )
1288 mJumpButtonBar->show(); 1290 mJumpButtonBar->show();
1289 else 1291 else
1290 mJumpButtonBar->hide(); 1292 mJumpButtonBar->hide();
1291 } 1293 }
1292 else 1294 else
1293 { 1295 {
1294 // show the jumpbar only if "the details are hidden" == "viewmanager are shown" 1296 // show the jumpbar only if "the details are hidden" == "viewmanager are shown"
1295 if (mViewManager->isVisible()) 1297 if (mViewManager->isVisible())
1296 { 1298 {
1297 if ( visible ) 1299 if ( visible )
1298 mJumpButtonBar->show(); 1300 mJumpButtonBar->show();
1299 else 1301 else
1300 mJumpButtonBar->hide(); 1302 mJumpButtonBar->hide();
1301 } 1303 }
1302 else 1304 else
1303 { 1305 {
1304 mJumpButtonBar->hide(); 1306 mJumpButtonBar->hide();
1305 } 1307 }
1306 } 1308 }
1307} 1309}
1308 1310
1309 1311
1310void KABCore::setDetailsToState() 1312void KABCore::setDetailsToState()
1311{ 1313{
1312 setDetailsVisible( mActionDetails->isChecked() ); 1314 setDetailsVisible( mActionDetails->isChecked() );
1313} 1315}
1314 1316
1315 1317
1316 1318
1317void KABCore::setDetailsVisible( bool visible ) 1319void KABCore::setDetailsVisible( bool visible )
1318{ 1320{
1319 if (visible && mDetails->isHidden()) 1321 if (visible && mDetails->isHidden())
1320 { 1322 {
1321 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 1323 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
1322 if ( addrList.count() > 0 ) 1324 if ( addrList.count() > 0 )
1323 mDetails->setAddressee( addrList[ 0 ] ); 1325 mDetails->setAddressee( addrList[ 0 ] );
1324 } 1326 }
1325 1327
1326 // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between 1328 // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between
1327 // the listview and the detailview. We do that by changing the splitbar size. 1329 // the listview and the detailview. We do that by changing the splitbar size.
1328 if (mMultipleViewsAtOnce) 1330 if (mMultipleViewsAtOnce)
1329 { 1331 {
1330 if ( visible ) 1332 if ( visible )
1331 mDetails->show(); 1333 mDetails->show();
1332 else 1334 else
1333 mDetails->hide(); 1335 mDetails->hide();
1334 } 1336 }
1335 else 1337 else
1336 { 1338 {
1337 if ( visible ) { 1339 if ( visible ) {
1338 mViewManager->hide(); 1340 mViewManager->hide();
1339 mDetails->show(); 1341 mDetails->show();
1340 } 1342 }
1341 else { 1343 else {
1342 mViewManager->show(); 1344 mViewManager->show();
1343 mDetails->hide(); 1345 mDetails->hide();
1344 } 1346 }
1345 setJumpButtonBarVisible( !visible ); 1347 setJumpButtonBarVisible( !visible );
1346 } 1348 }
1347 1349
1348} 1350}
1349 1351
1350void KABCore::extensionChanged( int id ) 1352void KABCore::extensionChanged( int id )
1351{ 1353{
1352 //change the details view only for non desktop systems 1354 //change the details view only for non desktop systems
1353#ifndef DESKTOP_VERSION 1355#ifndef DESKTOP_VERSION
1354 1356
1355 if (id == 0) 1357 if (id == 0)
1356 { 1358 {
1357 //the user disabled the extension. 1359 //the user disabled the extension.
1358 1360
1359 if (mMultipleViewsAtOnce) 1361 if (mMultipleViewsAtOnce)
1360 { // enable detailsview again 1362 { // enable detailsview again
1361 setDetailsVisible( true ); 1363 setDetailsVisible( true );
1362 mActionDetails->setChecked( true ); 1364 mActionDetails->setChecked( true );
1363 } 1365 }
1364 else 1366 else
1365 { //go back to the listview 1367 { //go back to the listview
1366 setDetailsVisible( false ); 1368 setDetailsVisible( false );
1367 mActionDetails->setChecked( false ); 1369 mActionDetails->setChecked( false );
1368 mActionDetails->setEnabled(true); 1370 mActionDetails->setEnabled(true);
1369 } 1371 }
1370 1372
1371 } 1373 }
1372 else 1374 else
1373 { 1375 {
1374 //the user enabled the extension. 1376 //the user enabled the extension.
1375 setDetailsVisible( false ); 1377 setDetailsVisible( false );
1376 mActionDetails->setChecked( false ); 1378 mActionDetails->setChecked( false );
1377 1379
1378 if (!mMultipleViewsAtOnce) 1380 if (!mMultipleViewsAtOnce)
1379 { 1381 {
1380 mActionDetails->setEnabled(false); 1382 mActionDetails->setEnabled(false);
1381 } 1383 }
1382 1384
1383 mExtensionManager->setSelectionChanged(); 1385 mExtensionManager->setSelectionChanged();
1384 1386
1385 } 1387 }
1386 1388
1387#endif// DESKTOP_VERSION 1389#endif// DESKTOP_VERSION
1388 1390
1389} 1391}
1390 1392
1391 1393
1392void KABCore::extensionModified( const KABC::Addressee::List &list ) 1394void KABCore::extensionModified( const KABC::Addressee::List &list )
1393{ 1395{
1394 1396
1395 if ( list.count() != 0 ) { 1397 if ( list.count() != 0 ) {
1396 KABC::Addressee::List::ConstIterator it; 1398 KABC::Addressee::List::ConstIterator it;
1397 for ( it = list.begin(); it != list.end(); ++it ) 1399 for ( it = list.begin(); it != list.end(); ++it )
1398 mAddressBook->insertAddressee( *it ); 1400 mAddressBook->insertAddressee( *it );
1399 if ( list.count() > 1 ) 1401 if ( list.count() > 1 )
1400 setModified(); 1402 setModified();
1401 else 1403 else
1402 setModifiedWOrefresh(); 1404 setModifiedWOrefresh();
1403 } 1405 }
1404 if ( list.count() == 0 ) 1406 if ( list.count() == 0 )
1405 mViewManager->refreshView(); 1407 mViewManager->refreshView();
1406 else 1408 else
1407 mViewManager->refreshView( list[ 0 ].uid() ); 1409 mViewManager->refreshView( list[ 0 ].uid() );
1408 1410
1409 1411
1410 1412
1411} 1413}
1412 1414
1413QString KABCore::getNameByPhone( const QString &phone ) 1415QString KABCore::getNameByPhone( const QString &phone )
1414{ 1416{
1415#ifndef KAB_EMBEDDED 1417#ifndef KAB_EMBEDDED
1416 QRegExp r( "[/*/-/ ]" ); 1418 QRegExp r( "[/*/-/ ]" );
1417 QString localPhone( phone ); 1419 QString localPhone( phone );
1418 1420
1419 bool found = false; 1421 bool found = false;
1420 QString ownerName = ""; 1422 QString ownerName = "";
1421 KABC::AddressBook::Iterator iter; 1423 KABC::AddressBook::Iterator iter;
1422 KABC::PhoneNumber::List::Iterator phoneIter; 1424 KABC::PhoneNumber::List::Iterator phoneIter;
1423 KABC::PhoneNumber::List phoneList; 1425 KABC::PhoneNumber::List phoneList;
1424 for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { 1426 for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) {
1425 phoneList = (*iter).phoneNumbers(); 1427 phoneList = (*iter).phoneNumbers();
1426 for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); 1428 for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() );
1427 ++phoneIter) { 1429 ++phoneIter) {
1428 // Get rid of separator chars so just the numbers are compared. 1430 // Get rid of separator chars so just the numbers are compared.
1429 if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { 1431 if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) {
1430 ownerName = (*iter).formattedName(); 1432 ownerName = (*iter).formattedName();
1431 found = true; 1433 found = true;
1432 } 1434 }
1433 } 1435 }
1434 } 1436 }
1435 1437
1436 return ownerName; 1438 return ownerName;
1437#else //KAB_EMBEDDED 1439#else //KAB_EMBEDDED
1438 qDebug("KABCore::getNameByPhone finsih method"); 1440 qDebug("KABCore::getNameByPhone finsih method");
1439 return ""; 1441 return "";
1440#endif //KAB_EMBEDDED 1442#endif //KAB_EMBEDDED
1441 1443
1442} 1444}
1443 1445
1444void KABCore::openConfigDialog() 1446void KABCore::openConfigDialog()
1445{ 1447{
1446 KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); 1448 KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true );
1447 KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); 1449 KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" );
1448 ConfigureDialog->addModule(kabcfg ); 1450 ConfigureDialog->addModule(kabcfg );
1449 KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); 1451 KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" );
1450 ConfigureDialog->addModule(kdelibcfg ); 1452 ConfigureDialog->addModule(kdelibcfg );
1451 1453
1452 connect( ConfigureDialog, SIGNAL( applyClicked() ), 1454 connect( ConfigureDialog, SIGNAL( applyClicked() ),
1453 this, SLOT( configurationChanged() ) ); 1455 this, SLOT( configurationChanged() ) );
1454 connect( ConfigureDialog, SIGNAL( okClicked() ), 1456 connect( ConfigureDialog, SIGNAL( okClicked() ),
1455 this, SLOT( configurationChanged() ) ); 1457 this, SLOT( configurationChanged() ) );
1456 saveSettings(); 1458 saveSettings();
1457#ifndef DESKTOP_VERSION 1459#ifndef DESKTOP_VERSION
1458 ConfigureDialog->showMaximized(); 1460 ConfigureDialog->showMaximized();
1459#endif 1461#endif
1460 if ( ConfigureDialog->exec() ) 1462 if ( ConfigureDialog->exec() )
1461 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); 1463 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") );
1462 delete ConfigureDialog; 1464 delete ConfigureDialog;
1463} 1465}
1464 1466
1465void KABCore::openLDAPDialog() 1467void KABCore::openLDAPDialog()
1466{ 1468{
1467#ifndef KAB_EMBEDDED 1469#ifndef KAB_EMBEDDED
1468 if ( !mLdapSearchDialog ) { 1470 if ( !mLdapSearchDialog ) {
1469 mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); 1471 mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this );
1470 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, 1472 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager,
1471 SLOT( refreshView() ) ); 1473 SLOT( refreshView() ) );
1472 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, 1474 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this,
1473 SLOT( setModified() ) ); 1475 SLOT( setModified() ) );
1474 } else 1476 } else
1475 mLdapSearchDialog->restoreSettings(); 1477 mLdapSearchDialog->restoreSettings();
1476 1478
1477 if ( mLdapSearchDialog->isOK() ) 1479 if ( mLdapSearchDialog->isOK() )
1478 mLdapSearchDialog->exec(); 1480 mLdapSearchDialog->exec();
1479#else //KAB_EMBEDDED 1481#else //KAB_EMBEDDED
1480 qDebug("KABCore::openLDAPDialog() finsih method"); 1482 qDebug("KABCore::openLDAPDialog() finsih method");
1481#endif //KAB_EMBEDDED 1483#endif //KAB_EMBEDDED
1482} 1484}
1483 1485
1484void KABCore::print() 1486void KABCore::print()
1485{ 1487{
1486#ifndef KAB_EMBEDDED 1488#ifndef KAB_EMBEDDED
1487 KPrinter printer; 1489 KPrinter printer;
1488 if ( !printer.setup( this ) ) 1490 if ( !printer.setup( this ) )
1489 return; 1491 return;
1490 1492
1491 KABPrinting::PrintingWizard wizard( &printer, mAddressBook, 1493 KABPrinting::PrintingWizard wizard( &printer, mAddressBook,
1492 mViewManager->selectedUids(), this ); 1494 mViewManager->selectedUids(), this );
1493 1495
1494 wizard.exec(); 1496 wizard.exec();
1495#else //KAB_EMBEDDED 1497#else //KAB_EMBEDDED
1496 qDebug("KABCore::print() finsih method"); 1498 qDebug("KABCore::print() finsih method");
1497#endif //KAB_EMBEDDED 1499#endif //KAB_EMBEDDED
1498 1500
1499} 1501}
1500 1502
1501 1503
1502void KABCore::addGUIClient( KXMLGUIClient *client ) 1504void KABCore::addGUIClient( KXMLGUIClient *client )
1503{ 1505{
1504 if ( mGUIClient ) 1506 if ( mGUIClient )
1505 mGUIClient->insertChildClient( client ); 1507 mGUIClient->insertChildClient( client );
1506 else 1508 else
1507 KMessageBox::error( this, "no KXMLGUICLient"); 1509 KMessageBox::error( this, "no KXMLGUICLient");
1508} 1510}
1509 1511
1510 1512
1511void KABCore::configurationChanged() 1513void KABCore::configurationChanged()
1512{ 1514{
1513 mExtensionManager->reconfigure(); 1515 mExtensionManager->reconfigure();
1514} 1516}
1515 1517
1516void KABCore::addressBookChanged() 1518void KABCore::addressBookChanged()
1517{ 1519{
1518/*US 1520/*US
1519 QDictIterator<AddresseeEditorDialog> it( mEditorDict ); 1521 QDictIterator<AddresseeEditorDialog> it( mEditorDict );
1520 while ( it.current() ) { 1522 while ( it.current() ) {
1521 if ( it.current()->dirty() ) { 1523 if ( it.current()->dirty() ) {
1522 QString text = i18n( "Data has been changed externally. Unsaved " 1524 QString text = i18n( "Data has been changed externally. Unsaved "
1523 "changes will be lost." ); 1525 "changes will be lost." );
1524 KMessageBox::information( this, text ); 1526 KMessageBox::information( this, text );
1525 } 1527 }
1526 it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); 1528 it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) );
1527 ++it; 1529 ++it;
1528 } 1530 }
1529*/ 1531*/
1530 if (mEditorDialog) 1532 if (mEditorDialog)
1531 { 1533 {
1532 if (mEditorDialog->dirty()) 1534 if (mEditorDialog->dirty())
1533 { 1535 {
1534 QString text = i18n( "Data has been changed externally. Unsaved " 1536 QString text = i18n( "Data has been changed externally. Unsaved "
1535 "changes will be lost." ); 1537 "changes will be lost." );
1536 KMessageBox::information( this, text ); 1538 KMessageBox::information( this, text );
1537 } 1539 }
1538 QString currentuid = mEditorDialog->addressee().uid(); 1540 QString currentuid = mEditorDialog->addressee().uid();
1539 mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); 1541 mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) );
1540 } 1542 }
1541 mViewManager->refreshView(); 1543 mViewManager->refreshView();
1542// mDetails->refreshView(); 1544// mDetails->refreshView();
1543 1545
1544 1546
1545} 1547}
1546 1548
1547AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, 1549AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent,
1548 const char *name ) 1550 const char *name )
1549{ 1551{
1550 1552
1551 if ( mEditorDialog == 0 ) { 1553 if ( mEditorDialog == 0 ) {
1552 mEditorDialog = new AddresseeEditorDialog( this, parent, 1554 mEditorDialog = new AddresseeEditorDialog( this, parent,
1553 name ? name : "editorDialog" ); 1555 name ? name : "editorDialog" );
1554 1556
1555 1557
1556 connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), 1558 connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ),
1557 SLOT( contactModified( const KABC::Addressee& ) ) ); 1559 SLOT( contactModified( const KABC::Addressee& ) ) );
1558 //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), 1560 //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ),
1559 // SLOT( slotEditorDestroyed( const QString& ) ) ; 1561 // SLOT( slotEditorDestroyed( const QString& ) ) ;
1560 } 1562 }
1561 1563
1562 return mEditorDialog; 1564 return mEditorDialog;
1563} 1565}
1564 1566
1565void KABCore::slotEditorDestroyed( const QString &uid ) 1567void KABCore::slotEditorDestroyed( const QString &uid )
1566{ 1568{
1567 //mEditorDict.remove( uid ); 1569 //mEditorDict.remove( uid );
1568} 1570}
1569 1571
1570void KABCore::initGUI() 1572void KABCore::initGUI()
1571{ 1573{
1572#ifndef KAB_EMBEDDED 1574#ifndef KAB_EMBEDDED
1573 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1575 QHBoxLayout *topLayout = new QHBoxLayout( this );
1574 topLayout->setSpacing( KDialogBase::spacingHint() ); 1576 topLayout->setSpacing( KDialogBase::spacingHint() );
1575 1577
1576 mExtensionBarSplitter = new QSplitter( this ); 1578 mExtensionBarSplitter = new QSplitter( this );
1577 mExtensionBarSplitter->setOrientation( Qt::Vertical ); 1579 mExtensionBarSplitter->setOrientation( Qt::Vertical );
1578 1580
1579 mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); 1581 mDetailsSplitter = new QSplitter( mExtensionBarSplitter );
1580 1582
1581 QVBox *viewSpace = new QVBox( mDetailsSplitter ); 1583 QVBox *viewSpace = new QVBox( mDetailsSplitter );
1582 mIncSearchWidget = new IncSearchWidget( viewSpace ); 1584 mIncSearchWidget = new IncSearchWidget( viewSpace );
1583 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 1585 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1584 SLOT( incrementalSearch( const QString& ) ) ); 1586 SLOT( incrementalSearch( const QString& ) ) );
1585 1587
1586 mViewManager = new ViewManager( this, viewSpace ); 1588 mViewManager = new ViewManager( this, viewSpace );
1587 viewSpace->setStretchFactor( mViewManager, 1 ); 1589 viewSpace->setStretchFactor( mViewManager, 1 );
1588 1590
1589 mDetails = new ViewContainer( mDetailsSplitter ); 1591 mDetails = new ViewContainer( mDetailsSplitter );
1590 1592
1591 mJumpButtonBar = new JumpButtonBar( this, this ); 1593 mJumpButtonBar = new JumpButtonBar( this, this );
1592 1594
1593 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); 1595 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter );
1594 1596
1595 topLayout->addWidget( mExtensionBarSplitter ); 1597 topLayout->addWidget( mExtensionBarSplitter );
1596 topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); 1598 topLayout->setStretchFactor( mExtensionBarSplitter, 100 );
1597 topLayout->addWidget( mJumpButtonBar ); 1599 topLayout->addWidget( mJumpButtonBar );
1598 topLayout->setStretchFactor( mJumpButtonBar, 1 ); 1600 topLayout->setStretchFactor( mJumpButtonBar, 1 );
1599 1601
1600 mXXPortManager = new XXPortManager( this, this ); 1602 mXXPortManager = new XXPortManager( this, this );
1601 1603
1602#else //KAB_EMBEDDED 1604#else //KAB_EMBEDDED
1603 //US initialize viewMenu before settingup viewmanager. 1605 //US initialize viewMenu before settingup viewmanager.
1604 // Viewmanager needs this menu to plugin submenues. 1606 // Viewmanager needs this menu to plugin submenues.
1605 viewMenu = new QPopupMenu( this ); 1607 viewMenu = new QPopupMenu( this );
1606 settingsMenu = new QPopupMenu( this ); 1608 settingsMenu = new QPopupMenu( this );
1607 //filterMenu = new QPopupMenu( this ); 1609 //filterMenu = new QPopupMenu( this );
1608 ImportMenu = new QPopupMenu( this ); 1610 ImportMenu = new QPopupMenu( this );
1609 ExportMenu = new QPopupMenu( this ); 1611 ExportMenu = new QPopupMenu( this );
1610 syncMenu = new QPopupMenu( this ); 1612 syncMenu = new QPopupMenu( this );
1611 changeMenu= new QPopupMenu( this ); 1613 changeMenu= new QPopupMenu( this );
1612 1614
1613//US since we have no splitter for the embedded system, setup 1615//US since we have no splitter for the embedded system, setup
1614// a layout with two frames. One left and one right. 1616// a layout with two frames. One left and one right.
1615 1617
1616 QBoxLayout *topLayout; 1618 QBoxLayout *topLayout;
1617 1619
1618 // = new QHBoxLayout( this ); 1620 // = new QHBoxLayout( this );
1619// QBoxLayout *topLayout = (QBoxLayout*)layout(); 1621// QBoxLayout *topLayout = (QBoxLayout*)layout();
1620 1622
1621// QWidget *mainBox = new QWidget( this ); 1623// QWidget *mainBox = new QWidget( this );
1622// QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); 1624// QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox);
1623 1625
1624#ifdef DESKTOP_VERSION 1626#ifdef DESKTOP_VERSION
1625 topLayout = new QHBoxLayout( this ); 1627 topLayout = new QHBoxLayout( this );
1626 1628
1627 1629
1628 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 1630 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
1629 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 1631 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
1630 1632
1631 topLayout->addWidget(mMiniSplitter ); 1633 topLayout->addWidget(mMiniSplitter );
1632 1634
1633 mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); 1635 mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter );
1634 mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 1636 mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
1635 mViewManager = new ViewManager( this, mExtensionBarSplitter ); 1637 mViewManager = new ViewManager( this, mExtensionBarSplitter );
1636 mDetails = new ViewContainer( mMiniSplitter ); 1638 mDetails = new ViewContainer( mMiniSplitter );
1637 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); 1639 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter );
1638#else 1640#else
1639 if ( QApplication::desktop()->width() > 480 ) { 1641 if ( QApplication::desktop()->width() > 480 ) {
1640 topLayout = new QHBoxLayout( this ); 1642 topLayout = new QHBoxLayout( this );
1641 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 1643 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
1642 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 1644 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
1643 } else { 1645 } else {
1644 1646
1645 topLayout = new QHBoxLayout( this ); 1647 topLayout = new QHBoxLayout( this );
1646 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); 1648 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this);
1647 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 1649 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
1648 } 1650 }
1649 1651
1650 topLayout->addWidget(mMiniSplitter ); 1652 topLayout->addWidget(mMiniSplitter );
1651 mViewManager = new ViewManager( this, mMiniSplitter ); 1653 mViewManager = new ViewManager( this, mMiniSplitter );
1652 mDetails = new ViewContainer( mMiniSplitter ); 1654 mDetails = new ViewContainer( mMiniSplitter );
1653 1655
1654 1656
1655 mExtensionManager = new ExtensionManager( this, mMiniSplitter ); 1657 mExtensionManager = new ExtensionManager( this, mMiniSplitter );
1656#endif 1658#endif
1657 //eh->hide(); 1659 //eh->hide();
1658 // topLayout->addWidget(mExtensionManager ); 1660 // topLayout->addWidget(mExtensionManager );
1659 1661
1660 1662
1661/*US 1663/*US
1662#ifndef KAB_NOSPLITTER 1664#ifndef KAB_NOSPLITTER
1663 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1665 QHBoxLayout *topLayout = new QHBoxLayout( this );
1664//US topLayout->setSpacing( KDialogBase::spacingHint() ); 1666//US topLayout->setSpacing( KDialogBase::spacingHint() );
1665 topLayout->setSpacing( 10 ); 1667 topLayout->setSpacing( 10 );
1666 1668
1667 mDetailsSplitter = new QSplitter( this ); 1669 mDetailsSplitter = new QSplitter( this );
1668 1670
1669 QVBox *viewSpace = new QVBox( mDetailsSplitter ); 1671 QVBox *viewSpace = new QVBox( mDetailsSplitter );
1670 1672
1671 mViewManager = new ViewManager( this, viewSpace ); 1673 mViewManager = new ViewManager( this, viewSpace );
1672 viewSpace->setStretchFactor( mViewManager, 1 ); 1674 viewSpace->setStretchFactor( mViewManager, 1 );
1673 1675
1674 mDetails = new ViewContainer( mDetailsSplitter ); 1676 mDetails = new ViewContainer( mDetailsSplitter );
1675 1677
1676 topLayout->addWidget( mDetailsSplitter ); 1678 topLayout->addWidget( mDetailsSplitter );
1677 topLayout->setStretchFactor( mDetailsSplitter, 100 ); 1679 topLayout->setStretchFactor( mDetailsSplitter, 100 );
1678#else //KAB_NOSPLITTER 1680#else //KAB_NOSPLITTER
1679 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1681 QHBoxLayout *topLayout = new QHBoxLayout( this );
1680//US topLayout->setSpacing( KDialogBase::spacingHint() ); 1682//US topLayout->setSpacing( KDialogBase::spacingHint() );
1681 topLayout->setSpacing( 10 ); 1683 topLayout->setSpacing( 10 );
1682 1684
1683// mDetailsSplitter = new QSplitter( this ); 1685// mDetailsSplitter = new QSplitter( this );
1684 1686
1685 QVBox *viewSpace = new QVBox( this ); 1687 QVBox *viewSpace = new QVBox( this );
1686 1688
1687 mViewManager = new ViewManager( this, viewSpace ); 1689 mViewManager = new ViewManager( this, viewSpace );
1688 viewSpace->setStretchFactor( mViewManager, 1 ); 1690 viewSpace->setStretchFactor( mViewManager, 1 );
1689 1691
1690 mDetails = new ViewContainer( this ); 1692 mDetails = new ViewContainer( this );
1691 1693
1692 topLayout->addWidget( viewSpace ); 1694 topLayout->addWidget( viewSpace );
1693// topLayout->setStretchFactor( mDetailsSplitter, 100 ); 1695// topLayout->setStretchFactor( mDetailsSplitter, 100 );
1694 topLayout->addWidget( mDetails ); 1696 topLayout->addWidget( mDetails );
1695#endif //KAB_NOSPLITTER 1697#endif //KAB_NOSPLITTER
1696*/ 1698*/
1697 1699
1698 syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); 1700 syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu);
1699 syncManager->setBlockSave(false); 1701 syncManager->setBlockSave(false);
1700 1702
1701 connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); 1703 connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) );
1702 connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); 1704 connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) );
1703 syncManager->setDefaultFileName( sentSyncFile()); 1705 syncManager->setDefaultFileName( sentSyncFile());
1704 //connect(syncManager , SIGNAL( ), this, SLOT( ) ); 1706 //connect(syncManager , SIGNAL( ), this, SLOT( ) );
1705 1707
1706#endif //KAB_EMBEDDED 1708#endif //KAB_EMBEDDED
1707 initActions(); 1709 initActions();
1708 1710
1709#ifdef KAB_EMBEDDED 1711#ifdef KAB_EMBEDDED
1710 addActionsManually(); 1712 addActionsManually();
1711 //US make sure the export and import menues are initialized before creating the xxPortManager. 1713 //US make sure the export and import menues are initialized before creating the xxPortManager.
1712 mXXPortManager = new XXPortManager( this, this ); 1714 mXXPortManager = new XXPortManager( this, this );
1713 1715
1714 // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); 1716 // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() );
1715 //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); 1717 //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget);
1716 // mActionQuit->plug ( mMainWindow->toolBar()); 1718 // mActionQuit->plug ( mMainWindow->toolBar());
1717 //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); 1719 //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() );
1718 //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); 1720 //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget);
1719 // mIncSearchWidget->hide(); 1721 // mIncSearchWidget->hide();
1720 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 1722 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1721 SLOT( incrementalSearch( const QString& ) ) ); 1723 SLOT( incrementalSearch( const QString& ) ) );
1722 1724
1723 1725
1724 mJumpButtonBar = new JumpButtonBar( this, this ); 1726 mJumpButtonBar = new JumpButtonBar( this, this );
1725 1727
1726 topLayout->addWidget( mJumpButtonBar ); 1728 topLayout->addWidget( mJumpButtonBar );
1727//US topLayout->setStretchFactor( mJumpButtonBar, 10 ); 1729//US topLayout->setStretchFactor( mJumpButtonBar, 10 );
1728 1730
1729// mMainWindow->getIconToolBar()->raise(); 1731// mMainWindow->getIconToolBar()->raise();
1730 1732
1731#endif //KAB_EMBEDDED 1733#endif //KAB_EMBEDDED
1732 1734
1733} 1735}
1734void KABCore::initActions() 1736void KABCore::initActions()
1735{ 1737{
1736//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); 1738//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart);
1737 1739
1738#ifndef KAB_EMBEDDED 1740#ifndef KAB_EMBEDDED
1739 connect( QApplication::clipboard(), SIGNAL( dataChanged() ), 1741 connect( QApplication::clipboard(), SIGNAL( dataChanged() ),
1740 SLOT( clipboardDataChanged() ) ); 1742 SLOT( clipboardDataChanged() ) );
1741#endif //KAB_EMBEDDED 1743#endif //KAB_EMBEDDED
1742 1744
1743 // file menu 1745 // file menu
1744 if ( mIsPart ) { 1746 if ( mIsPart ) {
1745 mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this, 1747 mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this,
1746 SLOT( sendMail() ), actionCollection(), 1748 SLOT( sendMail() ), actionCollection(),
1747 "kaddressbook_mail" ); 1749 "kaddressbook_mail" );
1748 mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this, 1750 mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this,
1749 SLOT( print() ), actionCollection(), "kaddressbook_print" ); 1751 SLOT( print() ), actionCollection(), "kaddressbook_print" );
1750 1752
1751 } else { 1753 } else {
1752 mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); 1754 mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() );
1753 mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); 1755 mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() );
1754 } 1756 }
1755 1757
1756 1758
1757 mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, 1759 mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this,
1758 SLOT( save() ), actionCollection(), "file_sync" ); 1760 SLOT( save() ), actionCollection(), "file_sync" );
1759 1761
1760 mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, 1762 mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this,
1761 SLOT( newContact() ), actionCollection(), "file_new_contact" ); 1763 SLOT( newContact() ), actionCollection(), "file_new_contact" );
1762 1764
1763 mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, 1765 mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0,
1764 this, SLOT( mailVCard() ), 1766 this, SLOT( mailVCard() ),
1765 actionCollection(), "file_mail_vcard"); 1767 actionCollection(), "file_mail_vcard");
1766 1768
1767 mActionExport2phone = new KAction( i18n( "Selected to phone" ), "ex2phone", 0, this, 1769 mActionExport2phone = new KAction( i18n( "Selected to phone" ), "ex2phone", 0, this,
1768 SLOT( export2phone() ), actionCollection(), 1770 SLOT( export2phone() ), actionCollection(),
1769 "kaddressbook_ex2phone" ); 1771 "kaddressbook_ex2phone" );
1770 1772
1771 mActionBeamVCard = 0; 1773 mActionBeamVCard = 0;
1772 mActionBeam = 0; 1774 mActionBeam = 0;
1773 1775
1774#ifndef DESKTOP_VERSION 1776#ifndef DESKTOP_VERSION
1775 if ( Ir::supported() ) { 1777 if ( Ir::supported() ) {
1776 mActionBeamVCard = new KAction( i18n( "Beam selected v&Card(s)" ), "beam", 0, this, 1778 mActionBeamVCard = new KAction( i18n( "Beam selected v&Card(s)" ), "beam", 0, this,
1777 SLOT( beamVCard() ), actionCollection(), 1779 SLOT( beamVCard() ), actionCollection(),
1778 "kaddressbook_beam_vcard" ); 1780 "kaddressbook_beam_vcard" );
1779 1781
1780 mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, 1782 mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this,
1781 SLOT( beamMySelf() ), actionCollection(), 1783 SLOT( beamMySelf() ), actionCollection(),
1782 "kaddressbook_beam_myself" ); 1784 "kaddressbook_beam_myself" );
1783 } 1785 }
1784#endif 1786#endif
1785 1787
1786 mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, 1788 mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0,
1787 this, SLOT( editContact2() ), 1789 this, SLOT( editContact2() ),
1788 actionCollection(), "file_properties" ); 1790 actionCollection(), "file_properties" );
1789 1791
1790#ifdef KAB_EMBEDDED 1792#ifdef KAB_EMBEDDED
1791 // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); 1793 // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() );
1792 mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, 1794 mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0,
1793 mMainWindow, SLOT( exit() ), 1795 mMainWindow, SLOT( exit() ),
1794 actionCollection(), "quit" ); 1796 actionCollection(), "quit" );
1795#endif //KAB_EMBEDDED 1797#endif //KAB_EMBEDDED
1796 1798
1797 // edit menu 1799 // edit menu
1798 if ( mIsPart ) { 1800 if ( mIsPart ) {
1799 mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, 1801 mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this,
1800 SLOT( copyContacts() ), actionCollection(), 1802 SLOT( copyContacts() ), actionCollection(),
1801 "kaddressbook_copy" ); 1803 "kaddressbook_copy" );
1802 mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, 1804 mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this,
1803 SLOT( cutContacts() ), actionCollection(), 1805 SLOT( cutContacts() ), actionCollection(),
1804 "kaddressbook_cut" ); 1806 "kaddressbook_cut" );
1805 mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, 1807 mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this,
1806 SLOT( pasteContacts() ), actionCollection(), 1808 SLOT( pasteContacts() ), actionCollection(),
1807 "kaddressbook_paste" ); 1809 "kaddressbook_paste" );
1808 mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, 1810 mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this,
1809 SLOT( selectAllContacts() ), actionCollection(), 1811 SLOT( selectAllContacts() ), actionCollection(),
1810 "kaddressbook_select_all" ); 1812 "kaddressbook_select_all" );
1811 mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, 1813 mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this,
1812 SLOT( undo() ), actionCollection(), 1814 SLOT( undo() ), actionCollection(),
1813 "kaddressbook_undo" ); 1815 "kaddressbook_undo" );
1814 mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, 1816 mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z,
1815 this, SLOT( redo() ), actionCollection(), 1817 this, SLOT( redo() ), actionCollection(),
1816 "kaddressbook_redo" ); 1818 "kaddressbook_redo" );
1817 } else { 1819 } else {
1818 mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); 1820 mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() );
1819 mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); 1821 mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() );
1820 mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); 1822 mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() );
1821 mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); 1823 mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() );
1822 mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); 1824 mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() );
1823 mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); 1825 mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() );
1824 } 1826 }
1825 1827
1826 mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", 1828 mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete",
1827 Key_Delete, this, SLOT( deleteContacts() ), 1829 Key_Delete, this, SLOT( deleteContacts() ),
1828 actionCollection(), "edit_delete" ); 1830 actionCollection(), "edit_delete" );
1829 1831
1830 mActionUndo->setEnabled( false ); 1832 mActionUndo->setEnabled( false );
1831 mActionRedo->setEnabled( false ); 1833 mActionRedo->setEnabled( false );
1832 1834
1833 // settings menu 1835 // settings menu
1834#ifdef KAB_EMBEDDED 1836#ifdef KAB_EMBEDDED
1835//US special menuentry to configure the addressbook resources. On KDE 1837//US special menuentry to configure the addressbook resources. On KDE
1836// you do that through the control center !!! 1838// you do that through the control center !!!
1837 mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, 1839 mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this,
1838 SLOT( configureResources() ), actionCollection(), 1840 SLOT( configureResources() ), actionCollection(),
1839 "kaddressbook_configure_resources" ); 1841 "kaddressbook_configure_resources" );
1840#endif //KAB_EMBEDDED 1842#endif //KAB_EMBEDDED
1841 1843
1842 if ( mIsPart ) { 1844 if ( mIsPart ) {
1843 mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, 1845 mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this,
1844 SLOT( openConfigDialog() ), actionCollection(), 1846 SLOT( openConfigDialog() ), actionCollection(),
1845 "kaddressbook_configure" ); 1847 "kaddressbook_configure" );
1846 1848
1847 mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, 1849 mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0,
1848 this, SLOT( configureKeyBindings() ), actionCollection(), 1850 this, SLOT( configureKeyBindings() ), actionCollection(),
1849 "kaddressbook_configure_shortcuts" ); 1851 "kaddressbook_configure_shortcuts" );
1850#ifdef KAB_EMBEDDED 1852#ifdef KAB_EMBEDDED
1851 mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); 1853 mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() );
1852 mActionConfigureToolbars->setEnabled( false ); 1854 mActionConfigureToolbars->setEnabled( false );
1853#endif //KAB_EMBEDDED 1855#endif //KAB_EMBEDDED
1854 1856
1855 } else { 1857 } else {
1856 mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); 1858 mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() );
1857 1859
1858 mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); 1860 mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() );
1859 } 1861 }
1860 1862
1861 mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, 1863 mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0,
1862 actionCollection(), "options_show_jump_bar" ); 1864 actionCollection(), "options_show_jump_bar" );
1863 connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); 1865 connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) );
1864 1866
1865 mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, 1867 mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0,
1866 actionCollection(), "options_show_details" ); 1868 actionCollection(), "options_show_details" );
1867 connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); 1869 connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) );
1868 1870
1869 // misc 1871 // misc
1870 // only enable LDAP lookup if we can handle the protocol 1872 // only enable LDAP lookup if we can handle the protocol
1871#ifndef KAB_EMBEDDED 1873#ifndef KAB_EMBEDDED
1872 if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { 1874 if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) {
1873 new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, 1875 new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0,
1874 this, SLOT( openLDAPDialog() ), actionCollection(), 1876 this, SLOT( openLDAPDialog() ), actionCollection(),
1875 "ldap_lookup" ); 1877 "ldap_lookup" );
1876 } 1878 }
1877#else //KAB_EMBEDDED 1879#else //KAB_EMBEDDED
1878 //qDebug("KABCore::initActions() LDAP has to be implemented"); 1880 //qDebug("KABCore::initActions() LDAP has to be implemented");
1879#endif //KAB_EMBEDDED 1881#endif //KAB_EMBEDDED
1880 1882
1881 1883
1882 mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, 1884 mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this,
1883 SLOT( setWhoAmI() ), actionCollection(), 1885 SLOT( setWhoAmI() ), actionCollection(),
1884 "set_personal" ); 1886 "set_personal" );
1885 1887
1886 1888
1887 1889
1888 1890
1889 mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, 1891 mActionCategories = new KAction( i18n( "Set Categories" ), 0, this,
1890 SLOT( setCategories() ), actionCollection(), 1892 SLOT( setCategories() ), actionCollection(),
1891 "edit_set_categories" ); 1893 "edit_set_categories" );
1892 1894
1893 mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, 1895 mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this,
1894 SLOT( removeVoice() ), actionCollection(), 1896 SLOT( removeVoice() ), actionCollection(),
1895 "remove_voice" ); 1897 "remove_voice" );
1896 mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, 1898 mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this,
1897 SLOT( importFromOL() ), actionCollection(), 1899 SLOT( importFromOL() ), actionCollection(),
1898 "import_OL" ); 1900 "import_OL" );
1899#ifdef KAB_EMBEDDED 1901#ifdef KAB_EMBEDDED
1900 mActionLicence = new KAction( i18n( "Licence" ), 0, 1902 mActionLicence = new KAction( i18n( "Licence" ), 0,
1901 this, SLOT( showLicence() ), actionCollection(), 1903 this, SLOT( showLicence() ), actionCollection(),
1902 "licence_about_data" ); 1904 "licence_about_data" );
1903 mActionFaq = new KAction( i18n( "Faq" ), 0, 1905 mActionFaq = new KAction( i18n( "Faq" ), 0,
1904 this, SLOT( faq() ), actionCollection(), 1906 this, SLOT( faq() ), actionCollection(),
1905 "faq_about_data" ); 1907 "faq_about_data" );
1906 1908
1907 mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, 1909 mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0,
1908 this, SLOT( createAboutData() ), actionCollection(), 1910 this, SLOT( createAboutData() ), actionCollection(),
1909 "kaddressbook_about_data" ); 1911 "kaddressbook_about_data" );
1910#endif //KAB_EMBEDDED 1912#endif //KAB_EMBEDDED
1911 1913
1912 clipboardDataChanged(); 1914 clipboardDataChanged();
1913 connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); 1915 connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) );
1914 connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); 1916 connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) );
1915} 1917}
1916 1918
1917//US we need this function, to plug all actions into the correct menues. 1919//US we need this function, to plug all actions into the correct menues.
1918// KDE uses a XML format to plug the actions, but we work her without this overhead. 1920// KDE uses a XML format to plug the actions, but we work her without this overhead.
1919void KABCore::addActionsManually() 1921void KABCore::addActionsManually()
1920{ 1922{
1921//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); 1923//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart);
1922 1924
1923#ifdef KAB_EMBEDDED 1925#ifdef KAB_EMBEDDED
1924 QPopupMenu *fileMenu = new QPopupMenu( this ); 1926 QPopupMenu *fileMenu = new QPopupMenu( this );
1925 QPopupMenu *editMenu = new QPopupMenu( this ); 1927 QPopupMenu *editMenu = new QPopupMenu( this );
1926 QPopupMenu *helpMenu = new QPopupMenu( this ); 1928 QPopupMenu *helpMenu = new QPopupMenu( this );
1927 1929
1928 KToolBar* tb = mMainWindow->toolBar(); 1930 KToolBar* tb = mMainWindow->toolBar();
1929 1931
1930#ifdef DESKTOP_VERSION 1932#ifdef DESKTOP_VERSION
1931 QMenuBar* mb = mMainWindow->menuBar(); 1933 QMenuBar* mb = mMainWindow->menuBar();
1932 1934
1933 //US setup menubar. 1935 //US setup menubar.
1934 //Disable the following block if you do not want to have a menubar. 1936 //Disable the following block if you do not want to have a menubar.
1935 mb->insertItem( "&File", fileMenu ); 1937 mb->insertItem( "&File", fileMenu );
1936 mb->insertItem( "&Edit", editMenu ); 1938 mb->insertItem( "&Edit", editMenu );
1937 mb->insertItem( "&View", viewMenu ); 1939 mb->insertItem( "&View", viewMenu );
1938 mb->insertItem( "&Settings", settingsMenu ); 1940 mb->insertItem( "&Settings", settingsMenu );
1939 mb->insertItem( i18n("Synchronize"), syncMenu ); 1941 mb->insertItem( i18n("Synchronize"), syncMenu );
1940 mb->insertItem( "&Change selected", changeMenu ); 1942 mb->insertItem( "&Change selected", changeMenu );
1941 mb->insertItem( "&Help", helpMenu ); 1943 mb->insertItem( "&Help", helpMenu );
1942 mIncSearchWidget = new IncSearchWidget( tb ); 1944 mIncSearchWidget = new IncSearchWidget( tb );
1943 // tb->insertWidget(-1, 0, mIncSearchWidget); 1945 // tb->insertWidget(-1, 0, mIncSearchWidget);
1944 1946
1945#else 1947#else
1946 //US setup toolbar 1948 //US setup toolbar
1947 QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); 1949 QPEMenuBar *menuBarTB = new QPEMenuBar( tb );
1948 QPopupMenu *popupBarTB = new QPopupMenu( this ); 1950 QPopupMenu *popupBarTB = new QPopupMenu( this );
1949 menuBarTB->insertItem( "ME", popupBarTB); 1951 menuBarTB->insertItem( "ME", popupBarTB);
1950 tb->insertWidget(-1, 0, menuBarTB); 1952 tb->insertWidget(-1, 0, menuBarTB);
1951 mIncSearchWidget = new IncSearchWidget( tb ); 1953 mIncSearchWidget = new IncSearchWidget( tb );
1952 1954
1953 tb->enableMoving(false); 1955 tb->enableMoving(false);
1954 popupBarTB->insertItem( "&File", fileMenu ); 1956 popupBarTB->insertItem( "&File", fileMenu );
1955 popupBarTB->insertItem( "&Edit", editMenu ); 1957 popupBarTB->insertItem( "&Edit", editMenu );
1956 popupBarTB->insertItem( "&View", viewMenu ); 1958 popupBarTB->insertItem( "&View", viewMenu );
1957 popupBarTB->insertItem( "&Settings", settingsMenu ); 1959 popupBarTB->insertItem( "&Settings", settingsMenu );
1958 popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); 1960 popupBarTB->insertItem( i18n("Synchronize"), syncMenu );
1959 mViewManager->getFilterAction()->plug ( popupBarTB); 1961 mViewManager->getFilterAction()->plug ( popupBarTB);
1960 popupBarTB->insertItem( "&Change selected", changeMenu ); 1962 popupBarTB->insertItem( "&Change selected", changeMenu );
1961 popupBarTB->insertItem( "&Help", helpMenu ); 1963 popupBarTB->insertItem( "&Help", helpMenu );
1962 if (QApplication::desktop()->width() > 320 ) { 1964 if (QApplication::desktop()->width() > 320 ) {
1963 // mViewManager->getFilterAction()->plug ( tb); 1965 // mViewManager->getFilterAction()->plug ( tb);
1964 } 1966 }
1965#endif 1967#endif
1966 // mActionQuit->plug ( mMainWindow->toolBar()); 1968 // mActionQuit->plug ( mMainWindow->toolBar());
1967 1969
1968 1970
1969 1971
1970 //US Now connect the actions with the menue entries. 1972 //US Now connect the actions with the menue entries.
1971 mActionPrint->plug( fileMenu ); 1973 mActionPrint->plug( fileMenu );
1972 mActionMail->plug( fileMenu ); 1974 mActionMail->plug( fileMenu );
1973 fileMenu->insertSeparator(); 1975 fileMenu->insertSeparator();
1974 1976
1975 mActionNewContact->plug( fileMenu ); 1977 mActionNewContact->plug( fileMenu );
1976 mActionNewContact->plug( tb ); 1978 mActionNewContact->plug( tb );
1977 1979
1978 mActionEditAddressee->plug( fileMenu ); 1980 mActionEditAddressee->plug( fileMenu );
1979 if ((KGlobal::getDesktopSize() > KGlobal::Small ) || 1981 if ((KGlobal::getDesktopSize() > KGlobal::Small ) ||
1980 (!KABPrefs::instance()->mMultipleViewsAtOnce )) 1982 (!KABPrefs::instance()->mMultipleViewsAtOnce ))
1981 mActionEditAddressee->plug( tb ); 1983 mActionEditAddressee->plug( tb );
1982 1984
1983 fileMenu->insertSeparator(); 1985 fileMenu->insertSeparator();
1984 mActionSave->plug( fileMenu ); 1986 mActionSave->plug( fileMenu );
1985 fileMenu->insertItem( "&Import", ImportMenu ); 1987 fileMenu->insertItem( "&Import", ImportMenu );
1986 fileMenu->insertItem( "&Export", ExportMenu ); 1988 fileMenu->insertItem( "&Export", ExportMenu );
1987 fileMenu->insertSeparator(); 1989 fileMenu->insertSeparator();
1988 mActionMailVCard->plug( fileMenu ); 1990 mActionMailVCard->plug( fileMenu );
1989#ifndef DESKTOP_VERSION 1991#ifndef DESKTOP_VERSION
1990 if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu ); 1992 if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu );
1991 if ( Ir::supported() ) mActionBeam->plug(fileMenu ); 1993 if ( Ir::supported() ) mActionBeam->plug(fileMenu );
1992#endif 1994#endif
1993 fileMenu->insertSeparator(); 1995 fileMenu->insertSeparator();
1994 mActionQuit->plug( fileMenu ); 1996 mActionQuit->plug( fileMenu );
1995#ifdef _WIN32_ 1997#ifdef _WIN32_
1996 mActionImportOL->plug( ImportMenu ); 1998 mActionImportOL->plug( ImportMenu );
1997#endif 1999#endif
1998 // edit menu 2000 // edit menu
1999 mActionUndo->plug( editMenu ); 2001 mActionUndo->plug( editMenu );
2000 mActionRedo->plug( editMenu ); 2002 mActionRedo->plug( editMenu );
2001 editMenu->insertSeparator(); 2003 editMenu->insertSeparator();
2002 mActionCut->plug( editMenu ); 2004 mActionCut->plug( editMenu );
2003 mActionCopy->plug( editMenu ); 2005 mActionCopy->plug( editMenu );
2004 mActionPaste->plug( editMenu ); 2006 mActionPaste->plug( editMenu );
2005 mActionDelete->plug( editMenu ); 2007 mActionDelete->plug( editMenu );
2006 editMenu->insertSeparator(); 2008 editMenu->insertSeparator();
2007 mActionSelectAll->plug( editMenu ); 2009 mActionSelectAll->plug( editMenu );
2008 2010
2009 mActionRemoveVoice->plug( changeMenu ); 2011 mActionRemoveVoice->plug( changeMenu );
2010 // settings menu 2012 // settings menu
2011//US special menuentry to configure the addressbook resources. On KDE 2013//US special menuentry to configure the addressbook resources. On KDE
2012// you do that through the control center !!! 2014// you do that through the control center !!!
2013 mActionConfigResources->plug( settingsMenu ); 2015 mActionConfigResources->plug( settingsMenu );
2014 settingsMenu->insertSeparator(); 2016 settingsMenu->insertSeparator();
2015 2017
2016 mActionConfigKAddressbook->plug( settingsMenu ); 2018 mActionConfigKAddressbook->plug( settingsMenu );
2017 2019
2018 if ( mIsPart ) { 2020 if ( mIsPart ) {
2019 mActionConfigShortcuts->plug( settingsMenu ); 2021 mActionConfigShortcuts->plug( settingsMenu );
2020 mActionConfigureToolbars->plug( settingsMenu ); 2022 mActionConfigureToolbars->plug( settingsMenu );
2021 2023
2022 } else { 2024 } else {
2023 mActionKeyBindings->plug( settingsMenu ); 2025 mActionKeyBindings->plug( settingsMenu );
2024 } 2026 }
2025 2027
2026 settingsMenu->insertSeparator(); 2028 settingsMenu->insertSeparator();
2027 2029
2028 mActionJumpBar->plug( settingsMenu ); 2030 mActionJumpBar->plug( settingsMenu );
2029 mActionDetails->plug( settingsMenu ); 2031 mActionDetails->plug( settingsMenu );
2030 if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) 2032 if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop )
2031 mActionDetails->plug( tb ); 2033 mActionDetails->plug( tb );
2032 settingsMenu->insertSeparator(); 2034 settingsMenu->insertSeparator();
2033 2035
2034 mActionWhoAmI->plug( settingsMenu ); 2036 mActionWhoAmI->plug( settingsMenu );
2035 mActionCategories->plug( settingsMenu ); 2037 mActionCategories->plug( settingsMenu );
2036 2038
2037 mActionLicence->plug( helpMenu ); 2039 mActionLicence->plug( helpMenu );
2038 mActionFaq->plug( helpMenu ); 2040 mActionFaq->plug( helpMenu );
2039 mActionAboutKAddressbook->plug( helpMenu ); 2041 mActionAboutKAddressbook->plug( helpMenu );
2040 2042
2041 if (KGlobal::getDesktopSize() > KGlobal::Small ) { 2043 if (KGlobal::getDesktopSize() > KGlobal::Small ) {
2042 2044
2043 mActionSave->plug( tb ); 2045 mActionSave->plug( tb );
2044 mViewManager->getFilterAction()->plug ( tb); 2046 mViewManager->getFilterAction()->plug ( tb);
2045 if (KGlobal::getDesktopSize() == KGlobal::Desktop ) { 2047 if (KGlobal::getDesktopSize() == KGlobal::Desktop ) {
2046 mActionUndo->plug( tb ); 2048 mActionUndo->plug( tb );
2047 mActionDelete->plug( tb ); 2049 mActionDelete->plug( tb );
2048 mActionRedo->plug( tb ); 2050 mActionRedo->plug( tb );
2049 } 2051 }
2050 } 2052 }
2051 //mActionQuit->plug ( tb ); 2053 //mActionQuit->plug ( tb );
2052 // tb->insertWidget(-1, 0, mIncSearchWidget, 6); 2054 // tb->insertWidget(-1, 0, mIncSearchWidget, 6);
2053 2055
2054 //US link the searchwidget first to this. 2056 //US link the searchwidget first to this.
2055 // The real linkage to the toolbar happens later. 2057 // The real linkage to the toolbar happens later.
2056//US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); 2058//US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE);
2057//US tb->insertItem( mIncSearchWidget ); 2059//US tb->insertItem( mIncSearchWidget );
2058/*US 2060/*US
2059 mIncSearchWidget = new IncSearchWidget( tb ); 2061 mIncSearchWidget = new IncSearchWidget( tb );
2060 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 2062 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
2061 SLOT( incrementalSearch( const QString& ) ) ); 2063 SLOT( incrementalSearch( const QString& ) ) );
2062 2064
2063 mJumpButtonBar = new JumpButtonBar( this, this ); 2065 mJumpButtonBar = new JumpButtonBar( this, this );
2064 2066
2065//US topLayout->addWidget( mJumpButtonBar ); 2067//US topLayout->addWidget( mJumpButtonBar );
2066 this->layout()->add( mJumpButtonBar ); 2068 this->layout()->add( mJumpButtonBar );
2067*/ 2069*/
2068 2070
2069#endif //KAB_EMBEDDED 2071#endif //KAB_EMBEDDED
2070 2072
2071 mActionExport2phone->plug( ExportMenu ); 2073 mActionExport2phone->plug( ExportMenu );
2072 connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); 2074 connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) );
2073 syncManager->fillSyncMenu(); 2075 syncManager->fillSyncMenu();
2074 2076
2075} 2077}
2076void KABCore::showLicence() 2078void KABCore::showLicence()
2077{ 2079{
2078 KApplication::showLicence(); 2080 KApplication::showLicence();
2079} 2081}
2080void KABCore::removeVoice() 2082void KABCore::removeVoice()
2081{ 2083{
2082 if ( KMessageBox::questionYesNo( this, i18n("After importing, phone numbers\nmay have two or more types.\n(E.g. work+voice)\nThese numbers are shown as \"other\".\nClick Yes to remove the voice type\nfrom numbers with more than one type.\n\nRemove voice type?") ) == KMessageBox::No ) 2084 if ( KMessageBox::questionYesNo( this, i18n("After importing, phone numbers\nmay have two or more types.\n(E.g. work+voice)\nThese numbers are shown as \"other\".\nClick Yes to remove the voice type\nfrom numbers with more than one type.\n\nRemove voice type?") ) == KMessageBox::No )
2083 return; 2085 return;
2084 KABC::Addressee::List list = mViewManager->selectedAddressees(); 2086 KABC::Addressee::List list = mViewManager->selectedAddressees();
2085 KABC::Addressee::List::Iterator it; 2087 KABC::Addressee::List::Iterator it;
2086 for ( it = list.begin(); it != list.end(); ++it ) { 2088 for ( it = list.begin(); it != list.end(); ++it ) {
2087 PhoneNumber::List phoneNumbers = (*it).phoneNumbers(); 2089 PhoneNumber::List phoneNumbers = (*it).phoneNumbers();
2088 PhoneNumber::List::Iterator phoneIt; 2090 PhoneNumber::List::Iterator phoneIt;
2089 bool found = false; 2091 bool found = false;
2090 for ( phoneIt = phoneNumbers.begin(); phoneIt != phoneNumbers.end(); ++phoneIt ) { 2092 for ( phoneIt = phoneNumbers.begin(); phoneIt != phoneNumbers.end(); ++phoneIt ) {
2091 if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found 2093 if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found
2092 if ((*phoneIt).type() - PhoneNumber::Voice ) { 2094 if ((*phoneIt).type() - PhoneNumber::Voice ) {
2093 (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice ); 2095 (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice );
2094 (*it).insertPhoneNumber( (*phoneIt) ); 2096 (*it).insertPhoneNumber( (*phoneIt) );
2095 found = true; 2097 found = true;
2096 } 2098 }
2097 } 2099 }
2098 2100
2099 } 2101 }
2100 if ( found ) 2102 if ( found )
2101 contactModified((*it) ); 2103 contactModified((*it) );
2102 } 2104 }
2103} 2105}
2104 2106
2105 2107
2106 2108
2107void KABCore::clipboardDataChanged() 2109void KABCore::clipboardDataChanged()
2108{ 2110{
2109 2111
2110 if ( mReadWrite ) 2112 if ( mReadWrite )
2111 mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); 2113 mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() );
2112 2114
2113} 2115}
2114 2116
2115void KABCore::updateActionMenu() 2117void KABCore::updateActionMenu()
2116{ 2118{
2117 UndoStack *undo = UndoStack::instance(); 2119 UndoStack *undo = UndoStack::instance();
2118 RedoStack *redo = RedoStack::instance(); 2120 RedoStack *redo = RedoStack::instance();
2119 2121
2120 if ( undo->isEmpty() ) 2122 if ( undo->isEmpty() )
2121 mActionUndo->setText( i18n( "Undo" ) ); 2123 mActionUndo->setText( i18n( "Undo" ) );
2122 else 2124 else
2123 mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); 2125 mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) );
2124 2126
2125 mActionUndo->setEnabled( !undo->isEmpty() ); 2127 mActionUndo->setEnabled( !undo->isEmpty() );
2126 2128
2127 if ( !redo->top() ) 2129 if ( !redo->top() )
2128 mActionRedo->setText( i18n( "Redo" ) ); 2130 mActionRedo->setText( i18n( "Redo" ) );
2129 else 2131 else
2130 mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); 2132 mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) );
2131 2133
2132 mActionRedo->setEnabled( !redo->isEmpty() ); 2134 mActionRedo->setEnabled( !redo->isEmpty() );
2133} 2135}
2134 2136
2135void KABCore::configureKeyBindings() 2137void KABCore::configureKeyBindings()
2136{ 2138{
2137#ifndef KAB_EMBEDDED 2139#ifndef KAB_EMBEDDED
2138 KKeyDialog::configure( actionCollection(), true ); 2140 KKeyDialog::configure( actionCollection(), true );
2139#else //KAB_EMBEDDED 2141#else //KAB_EMBEDDED
2140 qDebug("KABCore::configureKeyBindings() not implemented"); 2142 qDebug("KABCore::configureKeyBindings() not implemented");
2141#endif //KAB_EMBEDDED 2143#endif //KAB_EMBEDDED
2142} 2144}
2143 2145
2144#ifdef KAB_EMBEDDED 2146#ifdef KAB_EMBEDDED
2145void KABCore::configureResources() 2147void KABCore::configureResources()
2146{ 2148{
2147 KRES::KCMKResources dlg( this, "" , 0 ); 2149 KRES::KCMKResources dlg( this, "" , 0 );
2148 2150
2149 if ( !dlg.exec() ) 2151 if ( !dlg.exec() )
2150 return; 2152 return;
2151 KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); 2153 KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") );
2152} 2154}
2153#endif //KAB_EMBEDDED 2155#endif //KAB_EMBEDDED
2154 2156
2155 2157
2156/* this method will be called through the QCop interface from Ko/Pi to select addresses 2158/* this method will be called through the QCop interface from Ko/Pi to select addresses
2157 * for the attendees list of an event. 2159 * for the attendees list of an event.
2158 */ 2160 */
2159void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) 2161void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid)
2160{ 2162{
2161 QStringList nameList; 2163 QStringList nameList;
2162 QStringList emailList; 2164 QStringList emailList;
2163 QStringList uidList; 2165 QStringList uidList;
2164 2166
2165 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); 2167 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this);
2166 uint i=0; 2168 uint i=0;
2167 for (i=0; i < list.count(); i++) 2169 for (i=0; i < list.count(); i++)
2168 { 2170 {
2169 nameList.append(list[i].realName()); 2171 nameList.append(list[i].realName());
2170 emailList.append(list[i].preferredEmail()); 2172 emailList.append(list[i].preferredEmail());
2171 uidList.append(list[i].uid()); 2173 uidList.append(list[i].uid());
2172 } 2174 }
2173 2175
2174 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); 2176 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList);
2175 2177
2176} 2178}
2177 2179
2178/* this method will be called through the QCop interface from Ko/Pi to select birthdays 2180/* this method will be called through the QCop interface from Ko/Pi to select birthdays
2179 * to put them into the calendar. 2181 * to put them into the calendar.
2180 */ 2182 */
2181void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid) 2183void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid)
2182{ 2184{
2183 // qDebug("KABCore::requestForBirthdayList"); 2185 // qDebug("KABCore::requestForBirthdayList");
2184 QStringList birthdayList; 2186 QStringList birthdayList;
2185 QStringList anniversaryList; 2187 QStringList anniversaryList;
2186 QStringList realNameList; 2188 QStringList realNameList;
2187 QStringList preferredEmailList; 2189 QStringList preferredEmailList;
2188 QStringList assembledNameList; 2190 QStringList assembledNameList;
2189 QStringList uidList; 2191 QStringList uidList;
2190 2192
2191 KABC::AddressBook::Iterator it; 2193 KABC::AddressBook::Iterator it;
2192 2194
2193 int count = 0; 2195 int count = 0;
2194 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2196 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2195 ++count; 2197 ++count;
2196 } 2198 }
2197 QProgressBar bar(count,0 ); 2199 QProgressBar bar(count,0 );
2198 int w = 300; 2200 int w = 300;
2199 if ( QApplication::desktop()->width() < 320 ) 2201 if ( QApplication::desktop()->width() < 320 )
2200 w = 220; 2202 w = 220;
2201 int h = bar.sizeHint().height() ; 2203 int h = bar.sizeHint().height() ;
2202 int dw = QApplication::desktop()->width(); 2204 int dw = QApplication::desktop()->width();
2203 int dh = QApplication::desktop()->height(); 2205 int dh = QApplication::desktop()->height();
2204 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2206 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2205 bar.show(); 2207 bar.show();
2206 bar.setCaption (i18n("collecting birthdays - close to abort!") ); 2208 bar.setCaption (i18n("collecting birthdays - close to abort!") );
2207 qApp->processEvents(); 2209 qApp->processEvents();
2208 2210
2209 QDate bday; 2211 QDate bday;
2210 QString anni; 2212 QString anni;
2211 QString formattedbday; 2213 QString formattedbday;
2212 2214
2213 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) 2215 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it )
2214 { 2216 {
2215 if ( ! bar.isVisible() ) 2217 if ( ! bar.isVisible() )
2216 return; 2218 return;
2217 bar.setProgress( count++ ); 2219 bar.setProgress( count++ );
2218 qApp->processEvents(); 2220 qApp->processEvents();
2219 bday = (*it).birthday().date(); 2221 bday = (*it).birthday().date();
2220 anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" ); 2222 anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" );
2221 2223
2222 if ( bday.isValid() || !anni.isEmpty()) 2224 if ( bday.isValid() || !anni.isEmpty())
2223 { 2225 {
2224 if (bday.isValid()) 2226 if (bday.isValid())
2225 formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate); 2227 formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate);
2226 else 2228 else
2227 formattedbday = "NOTVALID"; 2229 formattedbday = "NOTVALID";
2228 if (anni.isEmpty()) 2230 if (anni.isEmpty())
2229 anni = "INVALID"; 2231 anni = "INVALID";
2230 2232
2231 birthdayList.append(formattedbday); 2233 birthdayList.append(formattedbday);
2232 anniversaryList.append(anni); //should be ISODate 2234 anniversaryList.append(anni); //should be ISODate
2233 realNameList.append((*it).realName()); 2235 realNameList.append((*it).realName());
2234 preferredEmailList.append((*it).preferredEmail()); 2236 preferredEmailList.append((*it).preferredEmail());
2235 assembledNameList.append((*it).assembledName()); 2237 assembledNameList.append((*it).assembledName());
2236 uidList.append((*it).uid()); 2238 uidList.append((*it).uid());
2237 2239
2238 qDebug("found birthday in KA/Pi: %s,%s,%s,%s: %s, %s", (*it).realName().latin1(), (*it).preferredEmail().latin1(), (*it).assembledName().latin1(), (*it).uid().latin1(), formattedbday.latin1(), anni.latin1() ); 2240 qDebug("found birthday in KA/Pi: %s,%s,%s,%s: %s, %s", (*it).realName().latin1(), (*it).preferredEmail().latin1(), (*it).assembledName().latin1(), (*it).uid().latin1(), formattedbday.latin1(), anni.latin1() );
2239 } 2241 }
2240 } 2242 }
2241 2243
2242 bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList); 2244 bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList);
2243 2245
2244} 2246}
2245 2247
2246/* this method will be called through the QCop interface from other apps to show details of a contact. 2248/* this method will be called through the QCop interface from other apps to show details of a contact.
2247 */ 2249 */
2248void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) 2250void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid)
2249{ 2251{
2250 qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); 2252 qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1());
2251 2253
2252 QString foundUid = QString::null; 2254 QString foundUid = QString::null;
2253 if ( ! uid.isEmpty() ) { 2255 if ( ! uid.isEmpty() ) {
2254 Addressee adrr = mAddressBook->findByUid( uid ); 2256 Addressee adrr = mAddressBook->findByUid( uid );
2255 if ( !adrr.isEmpty() ) { 2257 if ( !adrr.isEmpty() ) {
2256 foundUid = uid; 2258 foundUid = uid;
2257 } 2259 }
2258 if ( email == "sendbacklist" ) { 2260 if ( email == "sendbacklist" ) {
2259 //qDebug("ssssssssssssssssssssssend "); 2261 //qDebug("ssssssssssssssssssssssend ");
2260 QStringList nameList; 2262 QStringList nameList;
2261 QStringList emailList; 2263 QStringList emailList;
2262 QStringList uidList; 2264 QStringList uidList;
2263 nameList.append(adrr.realName()); 2265 nameList.append(adrr.realName());
2264 emailList = adrr.emails(); 2266 emailList = adrr.emails();
2265 uidList.append( adrr.preferredEmail()); 2267 uidList.append( adrr.preferredEmail());
2266 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); 2268 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList);
2267 return; 2269 return;
2268 } 2270 }
2269 2271
2270 } 2272 }
2271 2273
2272 if ( email == "sendbacklist" ) 2274 if ( email == "sendbacklist" )
2273 return; 2275 return;
2274 if (foundUid.isEmpty()) 2276 if (foundUid.isEmpty())
2275 { 2277 {
2276 //find the uid of the person first 2278 //find the uid of the person first
2277 Addressee::List namelist; 2279 Addressee::List namelist;
2278 Addressee::List emaillist; 2280 Addressee::List emaillist;
2279 2281
2280 if (!name.isEmpty()) 2282 if (!name.isEmpty())
2281 namelist = mAddressBook->findByName( name ); 2283 namelist = mAddressBook->findByName( name );
2282 2284
2283 if (!email.isEmpty()) 2285 if (!email.isEmpty())
2284 emaillist = mAddressBook->findByEmail( email ); 2286 emaillist = mAddressBook->findByEmail( email );
2285 qDebug("count %d %d ", namelist.count(),emaillist.count() ); 2287 qDebug("count %d %d ", namelist.count(),emaillist.count() );
2286 //check if we have a match in Namelist and Emaillist 2288 //check if we have a match in Namelist and Emaillist
2287 if ((namelist.count() == 0) && (emaillist.count() > 0)) { 2289 if ((namelist.count() == 0) && (emaillist.count() > 0)) {
2288 foundUid = emaillist[0].uid(); 2290 foundUid = emaillist[0].uid();
2289 } 2291 }
2290 else if ((namelist.count() > 0) && (emaillist.count() == 0)) 2292 else if ((namelist.count() > 0) && (emaillist.count() == 0))
2291 foundUid = namelist[0].uid(); 2293 foundUid = namelist[0].uid();
2292 else 2294 else
2293 { 2295 {
2294 for (int i = 0; i < namelist.count(); i++) 2296 for (int i = 0; i < namelist.count(); i++)
2295 { 2297 {
2296 for (int j = 0; j < emaillist.count(); j++) 2298 for (int j = 0; j < emaillist.count(); j++)
2297 { 2299 {
2298 if (namelist[i] == emaillist[j]) 2300 if (namelist[i] == emaillist[j])
2299 { 2301 {
2300 foundUid = namelist[i].uid(); 2302 foundUid = namelist[i].uid();
2301 } 2303 }
2302 } 2304 }
2303 } 2305 }
2304 } 2306 }
2305 } 2307 }
2306 else 2308 else
2307 { 2309 {
2308 foundUid = uid; 2310 foundUid = uid;
2309 } 2311 }
2310 2312
2311 if (!foundUid.isEmpty()) 2313 if (!foundUid.isEmpty())
2312 { 2314 {
2313 2315
2314 // raise Ka/Pi if it is in the background 2316 // raise Ka/Pi if it is in the background
2315#ifndef DESKTOP_VERSION 2317#ifndef DESKTOP_VERSION
2316#ifndef KORG_NODCOP 2318#ifndef KORG_NODCOP
2317 //QCopEnvelope e("QPE/Application/kapi", "raise()"); 2319 //QCopEnvelope e("QPE/Application/kapi", "raise()");
2318#endif 2320#endif
2319#endif 2321#endif
2320 2322
2321 mMainWindow->showMaximized(); 2323 mMainWindow->showMaximized();
2322 mMainWindow-> raise(); 2324 mMainWindow-> raise();
2323 2325
2324 mViewManager->setSelected( "", false); 2326 mViewManager->setSelected( "", false);
2325 mViewManager->refreshView( "" ); 2327 mViewManager->refreshView( "" );
2326 mViewManager->setSelected( foundUid, true ); 2328 mViewManager->setSelected( foundUid, true );
2327 mViewManager->refreshView( foundUid ); 2329 mViewManager->refreshView( foundUid );
2328 2330
2329 if ( !mMultipleViewsAtOnce ) 2331 if ( !mMultipleViewsAtOnce )
2330 { 2332 {
2331 setDetailsVisible( true ); 2333 setDetailsVisible( true );
2332 mActionDetails->setChecked(true); 2334 mActionDetails->setChecked(true);
2333 } 2335 }
2334 } 2336 }
2335} 2337}
2336 2338
2337 2339
2338void KABCore::faq() 2340void KABCore::faq()
2339{ 2341{
2340 KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); 2342 KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" );
2341} 2343}
2342 2344
2343#include <libkcal/syncdefines.h> 2345#include <libkcal/syncdefines.h>
2344 2346
2345KABC::Addressee KABCore::getLastSyncAddressee() 2347KABC::Addressee KABCore::getLastSyncAddressee()
2346{ 2348{
2347 Addressee lse; 2349 Addressee lse;
2348 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2350 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2349 2351
2350 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 2352 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
2351 lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); 2353 lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice );
2352 if (lse.isEmpty()) { 2354 if (lse.isEmpty()) {
2353 qDebug("Creating new last-syncAddressee "); 2355 qDebug("Creating new last-syncAddressee ");
2354 lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); 2356 lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice );
2355 QString sum = ""; 2357 QString sum = "";
2356 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) 2358 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL )
2357 sum = "E: "; 2359 sum = "E: ";
2358 lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); 2360 lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event"));
2359 lse.setRevision( mLastAddressbookSync ); 2361 lse.setRevision( mLastAddressbookSync );
2360 lse.setCategories( i18n("SyncEvent") ); 2362 lse.setCategories( i18n("SyncEvent") );
2361 mAddressBook->insertAddressee( lse ); 2363 mAddressBook->insertAddressee( lse );
2362 } 2364 }
2363 return lse; 2365 return lse;
2364} 2366}
2365int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) 2367int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full )
2366{ 2368{
2367 2369
2368 //void setZaurusId(int id); 2370 //void setZaurusId(int id);
2369 // int zaurusId() const; 2371 // int zaurusId() const;
2370 // void setZaurusUid(int id); 2372 // void setZaurusUid(int id);
2371 // int zaurusUid() const; 2373 // int zaurusUid() const;
2372 // void setZaurusStat(int id); 2374 // void setZaurusStat(int id);
2373 // int zaurusStat() const; 2375 // int zaurusStat() const;
2374 // 0 equal 2376 // 0 equal
2375 // 1 take local 2377 // 1 take local
2376 // 2 take remote 2378 // 2 take remote
2377 // 3 cancel 2379 // 3 cancel
2378 QDateTime lastSync = mLastAddressbookSync; 2380 QDateTime lastSync = mLastAddressbookSync;
2379 QDateTime localMod = local->revision(); 2381 QDateTime localMod = local->revision();
2380 QDateTime remoteMod = remote->revision(); 2382 QDateTime remoteMod = remote->revision();
2381 2383
2382 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2384 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2383 2385
2384 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2386 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2385 bool remCh, locCh; 2387 bool remCh, locCh;
2386 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); 2388 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
2387 2389
2388 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); 2390 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() );
2389 locCh = ( localMod > mLastAddressbookSync ); 2391 locCh = ( localMod > mLastAddressbookSync );
2390 if ( !remCh && ! locCh ) { 2392 if ( !remCh && ! locCh ) {
2391 //qDebug("both not changed "); 2393 //qDebug("both not changed ");
2392 lastSync = localMod.addDays(1); 2394 lastSync = localMod.addDays(1);
2393 if ( mode <= SYNC_PREF_ASK ) 2395 if ( mode <= SYNC_PREF_ASK )
2394 return 0; 2396 return 0;
2395 } else { 2397 } else {
2396 if ( locCh ) { 2398 if ( locCh ) {
2397 //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); 2399 //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1());
2398 lastSync = localMod.addDays( -1 ); 2400 lastSync = localMod.addDays( -1 );
2399 if ( !remCh ) 2401 if ( !remCh )
2400 remoteMod =( lastSync.addDays( -1 ) ); 2402 remoteMod =( lastSync.addDays( -1 ) );
2401 } else { 2403 } else {
2402 //qDebug(" not loc changed "); 2404 //qDebug(" not loc changed ");
2403 lastSync = localMod.addDays( 1 ); 2405 lastSync = localMod.addDays( 1 );
2404 if ( remCh ) 2406 if ( remCh )
2405 remoteMod =( lastSync.addDays( 1 ) ); 2407 remoteMod =( lastSync.addDays( 1 ) );
2406 2408
2407 } 2409 }
2408 } 2410 }
2409 full = true; 2411 full = true;
2410 if ( mode < SYNC_PREF_ASK ) 2412 if ( mode < SYNC_PREF_ASK )
2411 mode = SYNC_PREF_ASK; 2413 mode = SYNC_PREF_ASK;
2412 } else { 2414 } else {
2413 if ( localMod == remoteMod ) 2415 if ( localMod == remoteMod )
2414 return 0; 2416 return 0;
2415 2417
2416 } 2418 }
2417 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); 2419 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() );
2418 2420
2419 //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , localMod, remote->lastModified().toString().latin1(), remoteMod); 2421 //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , localMod, remote->lastModified().toString().latin1(), remoteMod);
2420 //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); 2422 //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() );
2421 //full = true; //debug only 2423 //full = true; //debug only
2422 if ( full ) { 2424 if ( full ) {
2423 bool equ = ( (*local) == (*remote) ); 2425 bool equ = ( (*local) == (*remote) );
2424 if ( equ ) { 2426 if ( equ ) {
2425 //qDebug("equal "); 2427 //qDebug("equal ");
2426 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2428 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2427 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); 2429 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) );
2428 } 2430 }
2429 if ( mode < SYNC_PREF_FORCE_LOCAL ) 2431 if ( mode < SYNC_PREF_FORCE_LOCAL )
2430 return 0; 2432 return 0;
2431 2433
2432 }//else //debug only 2434 }//else //debug only
2433 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 2435 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
2434 } 2436 }
2435 int result; 2437 int result;
2436 bool localIsNew; 2438 bool localIsNew;
2437 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() ); 2439 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() );
2438 2440
2439 if ( full && mode < SYNC_PREF_NEWEST ) 2441 if ( full && mode < SYNC_PREF_NEWEST )
2440 mode = SYNC_PREF_ASK; 2442 mode = SYNC_PREF_ASK;
2441 2443
2442 switch( mode ) { 2444 switch( mode ) {
2443 case SYNC_PREF_LOCAL: 2445 case SYNC_PREF_LOCAL:
2444 if ( lastSync > remoteMod ) 2446 if ( lastSync > remoteMod )
2445 return 1; 2447 return 1;
2446 if ( lastSync > localMod ) 2448 if ( lastSync > localMod )
2447 return 2; 2449 return 2;
2448 return 1; 2450 return 1;
2449 break; 2451 break;
2450 case SYNC_PREF_REMOTE: 2452 case SYNC_PREF_REMOTE:
2451 if ( lastSync > remoteMod ) 2453 if ( lastSync > remoteMod )
2452 return 1; 2454 return 1;
2453 if ( lastSync > localMod ) 2455 if ( lastSync > localMod )
2454 return 2; 2456 return 2;
2455 return 2; 2457 return 2;
2456 break; 2458 break;
2457 case SYNC_PREF_NEWEST: 2459 case SYNC_PREF_NEWEST:
2458 if ( localMod > remoteMod ) 2460 if ( localMod > remoteMod )
2459 return 1; 2461 return 1;
2460 else 2462 else
2461 return 2; 2463 return 2;
2462 break; 2464 break;
2463 case SYNC_PREF_ASK: 2465 case SYNC_PREF_ASK:
2464 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 2466 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
2465 if ( lastSync > remoteMod ) 2467 if ( lastSync > remoteMod )
2466 return 1; 2468 return 1;
2467 if ( lastSync > localMod ) 2469 if ( lastSync > localMod )
2468 return 2; 2470 return 2;
2469 localIsNew = localMod >= remoteMod; 2471 localIsNew = localMod >= remoteMod;
2470 //qDebug("conflict! ************************************** "); 2472 //qDebug("conflict! ************************************** ");
2471 { 2473 {
2472 KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this ); 2474 KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this );
2473 result = acd.executeD(localIsNew); 2475 result = acd.executeD(localIsNew);
2474 return result; 2476 return result;
2475 } 2477 }
2476 break; 2478 break;
2477 case SYNC_PREF_FORCE_LOCAL: 2479 case SYNC_PREF_FORCE_LOCAL:
2478 return 1; 2480 return 1;
2479 break; 2481 break;
2480 case SYNC_PREF_FORCE_REMOTE: 2482 case SYNC_PREF_FORCE_REMOTE:
2481 return 2; 2483 return 2;
2482 break; 2484 break;
2483 2485
2484 default: 2486 default:
2485 // SYNC_PREF_TAKE_BOTH not implemented 2487 // SYNC_PREF_TAKE_BOTH not implemented
2486 break; 2488 break;
2487 } 2489 }
2488 return 0; 2490 return 0;
2489} 2491}
2490 2492
2491 2493
2492bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) 2494bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode)
2493{ 2495{
2494 bool syncOK = true; 2496 bool syncOK = true;
2495 int addedAddressee = 0; 2497 int addedAddressee = 0;
2496 int addedAddresseeR = 0; 2498 int addedAddresseeR = 0;
2497 int deletedAddresseeR = 0; 2499 int deletedAddresseeR = 0;
2498 int deletedAddresseeL = 0; 2500 int deletedAddresseeL = 0;
2499 int changedLocal = 0; 2501 int changedLocal = 0;
2500 int changedRemote = 0; 2502 int changedRemote = 0;
2501 2503
2502 QString mCurrentSyncName = syncManager->getCurrentSyncName(); 2504 QString mCurrentSyncName = syncManager->getCurrentSyncName();
2503 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2505 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2504 2506
2505 //QPtrList<Addressee> el = local->rawAddressees(); 2507 //QPtrList<Addressee> el = local->rawAddressees();
2506 Addressee addresseeR; 2508 Addressee addresseeR;
2507 QString uid; 2509 QString uid;
2508 int take; 2510 int take;
2509 Addressee addresseeL; 2511 Addressee addresseeL;
2510 Addressee addresseeRSync; 2512 Addressee addresseeRSync;
2511 Addressee addresseeLSync; 2513 Addressee addresseeLSync;
2512 // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); 2514 // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees();
2513 //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); 2515 //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees();
2514 bool fullDateRange = false; 2516 bool fullDateRange = false;
2515 local->resetTempSyncStat(); 2517 local->resetTempSyncStat();
2516 mLastAddressbookSync = QDateTime::currentDateTime(); 2518 mLastAddressbookSync = QDateTime::currentDateTime();
2517 QDateTime modifiedCalendar = mLastAddressbookSync;; 2519 QDateTime modifiedCalendar = mLastAddressbookSync;;
2518 addresseeLSync = getLastSyncAddressee(); 2520 addresseeLSync = getLastSyncAddressee();
2519 qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); 2521 qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1());
2520 addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); 2522 addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName );
2521 if ( !addresseeR.isEmpty() ) { 2523 if ( !addresseeR.isEmpty() ) {
2522 addresseeRSync = addresseeR; 2524 addresseeRSync = addresseeR;
2523 remote->removeAddressee(addresseeR ); 2525 remote->removeAddressee(addresseeR );
2524 2526
2525 } else { 2527 } else {
2526 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2528 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2527 addresseeRSync = addresseeLSync ; 2529 addresseeRSync = addresseeLSync ;
2528 } else { 2530 } else {
2529 qDebug("FULLDATE 1"); 2531 qDebug("FULLDATE 1");
2530 fullDateRange = true; 2532 fullDateRange = true;
2531 Addressee newAdd; 2533 Addressee newAdd;
2532 addresseeRSync = newAdd; 2534 addresseeRSync = newAdd;
2533 addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); 2535 addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee"));
2534 addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); 2536 addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName );
2535 addresseeRSync.setRevision( mLastAddressbookSync ); 2537 addresseeRSync.setRevision( mLastAddressbookSync );
2536 addresseeRSync.setCategories( i18n("SyncAddressee") ); 2538 addresseeRSync.setCategories( i18n("SyncAddressee") );
2537 } 2539 }
2538 } 2540 }
2539 if ( addresseeLSync.revision() == mLastAddressbookSync ) { 2541 if ( addresseeLSync.revision() == mLastAddressbookSync ) {
2540 qDebug("FULLDATE 2"); 2542 qDebug("FULLDATE 2");
2541 fullDateRange = true; 2543 fullDateRange = true;
2542 } 2544 }
2543 if ( ! fullDateRange ) { 2545 if ( ! fullDateRange ) {
2544 if ( addresseeLSync.revision() != addresseeRSync.revision() ) { 2546 if ( addresseeLSync.revision() != addresseeRSync.revision() ) {
2545 2547
2546 // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); 2548 // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() );
2547 //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); 2549 //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec());
2548 fullDateRange = true; 2550 fullDateRange = true;
2549 qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); 2551 qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() );
2550 } 2552 }
2551 } 2553 }
2552 // fullDateRange = true; // debug only! 2554 // fullDateRange = true; // debug only!
2553 if ( fullDateRange ) 2555 if ( fullDateRange )
2554 mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); 2556 mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365);
2555 else 2557 else
2556 mLastAddressbookSync = addresseeLSync.revision(); 2558 mLastAddressbookSync = addresseeLSync.revision();
2557 // for resyncing if own file has changed 2559 // for resyncing if own file has changed
2558 // PENDING fixme later when implemented 2560 // PENDING fixme later when implemented
2559#if 0 2561#if 0
2560 if ( mCurrentSyncDevice == "deleteaftersync" ) { 2562 if ( mCurrentSyncDevice == "deleteaftersync" ) {
2561 mLastAddressbookSync = loadedFileVersion; 2563 mLastAddressbookSync = loadedFileVersion;
2562 qDebug("setting mLastAddressbookSync "); 2564 qDebug("setting mLastAddressbookSync ");
2563 } 2565 }
2564#endif 2566#endif
2565 2567
2566 //qDebug("*************************** "); 2568 //qDebug("*************************** ");
2567 // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); 2569 // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() );
2568 QStringList er = remote->uidList(); 2570 QStringList er = remote->uidList();
2569 Addressee inR ;//= er.first(); 2571 Addressee inR ;//= er.first();
2570 Addressee inL; 2572 Addressee inL;
2571 2573
2572 syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); 2574 syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count());
2573 2575
2574 int modulo = (er.count()/10)+1; 2576 int modulo = (er.count()/10)+1;
2575 int incCounter = 0; 2577 int incCounter = 0;
2576 while ( incCounter < er.count()) { 2578 while ( incCounter < er.count()) {
2577 if (syncManager->isProgressBarCanceled()) 2579 if (syncManager->isProgressBarCanceled())
2578 return false; 2580 return false;
2579 if ( incCounter % modulo == 0 ) 2581 if ( incCounter % modulo == 0 )
2580 syncManager->showProgressBar(incCounter); 2582 syncManager->showProgressBar(incCounter);
2581 2583
2582 uid = er[ incCounter ]; 2584 uid = er[ incCounter ];
2583 bool skipIncidence = false; 2585 bool skipIncidence = false;
2584 if ( uid.left(19) == QString("last-syncAddressee-") ) 2586 if ( uid.left(19) == QString("last-syncAddressee-") )
2585 skipIncidence = true; 2587 skipIncidence = true;
2586 QString idS,OidS; 2588 QString idS,OidS;
2587 qApp->processEvents(); 2589 qApp->processEvents();
2588 if ( !skipIncidence ) { 2590 if ( !skipIncidence ) {
2589 inL = local->findByUid( uid ); 2591 inL = local->findByUid( uid );
2590 inR = remote->findByUid( uid ); 2592 inR = remote->findByUid( uid );
2591 //inL.setResource( 0 ); 2593 //inL.setResource( 0 );
2592 //inR.setResource( 0 ); 2594 //inR.setResource( 0 );
2593 if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars 2595 if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars
2594 if ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) { 2596 if ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) {
2595 //qDebug("take %d %s ", take, inL.summary().latin1()); 2597 //qDebug("take %d %s ", take, inL.summary().latin1());
2596 if ( take == 3 ) 2598 if ( take == 3 )
2597 return false; 2599 return false;
2598 if ( take == 1 ) {// take local 2600 if ( take == 1 ) {// take local
2599 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2601 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2600 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 2602 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
2601 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 2603 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
2602 local->insertAddressee( inL, false ); 2604 local->insertAddressee( inL, false );
2603 idS = inR.externalUID(); 2605 idS = inR.externalUID();
2604 OidS = inR.originalExternalUID(); 2606 OidS = inR.originalExternalUID();
2605 } 2607 }
2606 else 2608 else
2607 idS = inR.IDStr(); 2609 idS = inR.IDStr();
2608 remote->removeAddressee( inR ); 2610 remote->removeAddressee( inR );
2609 inR = inL; 2611 inR = inL;
2610 inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 2612 inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
2611 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2613 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2612 inR.setOriginalExternalUID( OidS ); 2614 inR.setOriginalExternalUID( OidS );
2613 inR.setExternalUID( idS ); 2615 inR.setExternalUID( idS );
2614 } else { 2616 } else {
2615 inR.setIDStr( idS ); 2617 inR.setIDStr( idS );
2616 } 2618 }
2617 inR.setResource( 0 ); 2619 inR.setResource( 0 );
2618 remote->insertAddressee( inR , false); 2620 remote->insertAddressee( inR , false);
2619 ++changedRemote; 2621 ++changedRemote;
2620 } else { // take == 2 take remote 2622 } else { // take == 2 take remote
2621 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2623 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2622 if ( inR.revision().date().year() < 2004 ) 2624 if ( inR.revision().date().year() < 2004 )
2623 inR.setRevision( modifiedCalendar ); 2625 inR.setRevision( modifiedCalendar );
2624 } 2626 }
2625 idS = inL.IDStr(); 2627 idS = inL.IDStr();
2626 local->removeAddressee( inL ); 2628 local->removeAddressee( inL );
2627 inL = inR; 2629 inL = inR;
2628 inL.setIDStr( idS ); 2630 inL.setIDStr( idS );
2629 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2631 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2630 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 2632 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
2631 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 2633 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
2632 } 2634 }
2633 inL.setResource( 0 ); 2635 inL.setResource( 0 );
2634 local->insertAddressee( inL , false ); 2636 local->insertAddressee( inL , false );
2635 ++changedLocal; 2637 ++changedLocal;
2636 } 2638 }
2637 } 2639 }
2638 } else { // no conflict 2640 } else { // no conflict
2639 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2641 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2640 QString des = addresseeLSync.note(); 2642 QString des = addresseeLSync.note();
2641 if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 2643 if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
2642 inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 2644 inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE );
2643 remote->insertAddressee( inR, false ); 2645 remote->insertAddressee( inR, false );
2644 ++deletedAddresseeR; 2646 ++deletedAddresseeR;
2645 } else { 2647 } else {
2646 inR.setRevision( modifiedCalendar ); 2648 inR.setRevision( modifiedCalendar );
2647 remote->insertAddressee( inR, false ); 2649 remote->insertAddressee( inR, false );
2648 inL = inR; 2650 inL = inR;
2649 inL.setResource( 0 ); 2651 inL.setResource( 0 );
2650 local->insertAddressee( inL , false); 2652 local->insertAddressee( inL , false);
2651 ++addedAddressee; 2653 ++addedAddressee;
2652 } 2654 }
2653 } else { 2655 } else {
2654 if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { 2656 if ( inR.revision() > mLastAddressbookSync || mode == 5 ) {
2655 inR.setRevision( modifiedCalendar ); 2657 inR.setRevision( modifiedCalendar );
2656 remote->insertAddressee( inR, false ); 2658 remote->insertAddressee( inR, false );
2657 inR.setResource( 0 ); 2659 inR.setResource( 0 );
2658 local->insertAddressee( inR, false ); 2660 local->insertAddressee( inR, false );
2659 ++addedAddressee; 2661 ++addedAddressee;
2660 } else { 2662 } else {
2661 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); 2663 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR);
2662 remote->removeAddressee( inR ); 2664 remote->removeAddressee( inR );
2663 ++deletedAddresseeR; 2665 ++deletedAddresseeR;
2664 } 2666 }
2665 } 2667 }
2666 } 2668 }
2667 } 2669 }
2668 ++incCounter; 2670 ++incCounter;
2669 } 2671 }
2670 er.clear(); 2672 er.clear();
2671 QStringList el = local->uidList(); 2673 QStringList el = local->uidList();
2672 modulo = (el.count()/10)+1; 2674 modulo = (el.count()/10)+1;
2673 2675
2674 syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); 2676 syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count());
2675 incCounter = 0; 2677 incCounter = 0;
2676 while ( incCounter < el.count()) { 2678 while ( incCounter < el.count()) {
2677 qApp->processEvents(); 2679 qApp->processEvents();
2678 if (syncManager->isProgressBarCanceled()) 2680 if (syncManager->isProgressBarCanceled())
2679 return false; 2681 return false;
2680 if ( incCounter % modulo == 0 ) 2682 if ( incCounter % modulo == 0 )
2681 syncManager->showProgressBar(incCounter); 2683 syncManager->showProgressBar(incCounter);
2682 uid = el[ incCounter ]; 2684 uid = el[ incCounter ];
2683 bool skipIncidence = false; 2685 bool skipIncidence = false;
2684 if ( uid.left(19) == QString("last-syncAddressee-") ) 2686 if ( uid.left(19) == QString("last-syncAddressee-") )
2685 skipIncidence = true; 2687 skipIncidence = true;
2686 if ( !skipIncidence ) { 2688 if ( !skipIncidence ) {
2687 inL = local->findByUid( uid ); 2689 inL = local->findByUid( uid );
2688 inR = remote->findByUid( uid ); 2690 inR = remote->findByUid( uid );
2689 if ( inR.isEmpty() ) { 2691 if ( inR.isEmpty() ) {
2690 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2692 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2691 if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 2693 if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
2692 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); 2694 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
2693 local->removeAddressee( inL ); 2695 local->removeAddressee( inL );
2694 ++deletedAddresseeL; 2696 ++deletedAddresseeL;
2695 } else { 2697 } else {
2696 if ( ! syncManager->mWriteBackExistingOnly ) { 2698 if ( ! syncManager->mWriteBackExistingOnly ) {
2697 inL.removeID(mCurrentSyncDevice ); 2699 inL.removeID(mCurrentSyncDevice );
2698 ++addedAddresseeR; 2700 ++addedAddresseeR;
2699 inL.setRevision( modifiedCalendar ); 2701 inL.setRevision( modifiedCalendar );
2700 local->insertAddressee( inL, false ); 2702 local->insertAddressee( inL, false );
2701 inR = inL; 2703 inR = inL;
2702 inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); 2704 inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL );
2703 inR.setResource( 0 ); 2705 inR.setResource( 0 );
2704 remote->insertAddressee( inR, false ); 2706 remote->insertAddressee( inR, false );
2705 } 2707 }
2706 } 2708 }
2707 } else { 2709 } else {
2708 if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { 2710 if ( inL.revision() < mLastAddressbookSync && mode != 4 ) {
2709 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); 2711 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
2710 local->removeAddressee( inL ); 2712 local->removeAddressee( inL );
2711 ++deletedAddresseeL; 2713 ++deletedAddresseeL;
2712 } else { 2714 } else {
2713 if ( ! syncManager->mWriteBackExistingOnly ) { 2715 if ( ! syncManager->mWriteBackExistingOnly ) {
2714 ++addedAddresseeR; 2716 ++addedAddresseeR;
2715 inL.setRevision( modifiedCalendar ); 2717 inL.setRevision( modifiedCalendar );
2716 local->insertAddressee( inL, false ); 2718 local->insertAddressee( inL, false );
2717 inR = inL; 2719 inR = inL;
2718 inR.setResource( 0 ); 2720 inR.setResource( 0 );
2719 remote->insertAddressee( inR, false ); 2721 remote->insertAddressee( inR, false );
2720 } 2722 }
2721 } 2723 }
2722 } 2724 }
2723 } 2725 }
2724 } 2726 }
2725 ++incCounter; 2727 ++incCounter;
2726 } 2728 }
2727 el.clear(); 2729 el.clear();
2728 syncManager->hideProgressBar(); 2730 syncManager->hideProgressBar();
2729 mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); 2731 mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 );
2730 // get rid of micro seconds 2732 // get rid of micro seconds
2731 QTime t = mLastAddressbookSync.time(); 2733 QTime t = mLastAddressbookSync.time();
2732 mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); 2734 mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) );
2733 addresseeLSync.setRevision( mLastAddressbookSync ); 2735 addresseeLSync.setRevision( mLastAddressbookSync );
2734 addresseeRSync.setRevision( mLastAddressbookSync ); 2736 addresseeRSync.setRevision( mLastAddressbookSync );
2735 addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; 2737 addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ;
2736 addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); 2738 addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName );
2737 addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; 2739 addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ;
2738 addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); 2740 addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") );
2739 addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; 2741 addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ;
2740 addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); 2742 addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() );
2741 addresseeRSync.setNote( "" ) ; 2743 addresseeRSync.setNote( "" ) ;
2742 addresseeLSync.setNote( "" ); 2744 addresseeLSync.setNote( "" );
2743 2745
2744 if ( mGlobalSyncMode == SYNC_MODE_NORMAL) 2746 if ( mGlobalSyncMode == SYNC_MODE_NORMAL)
2745 remote->insertAddressee( addresseeRSync, false ); 2747 remote->insertAddressee( addresseeRSync, false );
2746 local->insertAddressee( addresseeLSync, false ); 2748 local->insertAddressee( addresseeLSync, false );
2747 QString mes; 2749 QString mes;
2748 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR ); 2750 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR );
2749 if ( syncManager->mShowSyncSummary ) { 2751 if ( syncManager->mShowSyncSummary ) {
2750 KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") ); 2752 KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") );
2751 } 2753 }
2752 qDebug( mes ); 2754 qDebug( mes );
2753 return syncOK; 2755 return syncOK;
2754} 2756}
2755 2757
2756 2758
2757//this is a overwritten callbackmethods from the syncinterface 2759//this is a overwritten callbackmethods from the syncinterface
2758bool KABCore::sync(KSyncManager* manager, QString filename, int mode) 2760bool KABCore::sync(KSyncManager* manager, QString filename, int mode)
2759{ 2761{
2760 2762
2761 //pending prepare addresseeview for output 2763 //pending prepare addresseeview for output
2762 //pending detect, if remote file has REV field. if not switch to external sync 2764 //pending detect, if remote file has REV field. if not switch to external sync
2763 mGlobalSyncMode = SYNC_MODE_NORMAL; 2765 mGlobalSyncMode = SYNC_MODE_NORMAL;
2764 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 2766 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
2765 2767
2766 AddressBook abLocal(filename,"syncContact"); 2768 AddressBook abLocal(filename,"syncContact");
2767 bool syncOK = false; 2769 bool syncOK = false;
2768 if ( abLocal.load() ) { 2770 if ( abLocal.load() ) {
2769 qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); 2771 qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode );
2770 bool external = false; 2772 bool external = false;
2771 bool isXML = false; 2773 bool isXML = false;
2772 if ( filename.right(4) == ".xml") { 2774 if ( filename.right(4) == ".xml") {
2773 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 2775 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
2774 isXML = true; 2776 isXML = true;
2775 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice ); 2777 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice );
2776 } else { 2778 } else {
2777 Addressee lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); 2779 Addressee lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice );
2778 if ( ! lse.isEmpty() ) { 2780 if ( ! lse.isEmpty() ) {
2779 if ( lse.familyName().left(4) == "!E: " ) 2781 if ( lse.familyName().left(4) == "!E: " )
2780 external = true; 2782 external = true;
2781 } else { 2783 } else {
2782 bool found = false; 2784 bool found = false;
2783 AddressBook::Iterator it; 2785 AddressBook::Iterator it;
2784 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 2786 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
2785 if ( (*it).revision().date().year() > 2003 ) { 2787 if ( (*it).revision().date().year() > 2003 ) {
2786 found = true; 2788 found = true;
2787 break; 2789 break;
2788 } 2790 }
2789 } 2791 }
2790 external = ! found; 2792 external = ! found;
2791 } 2793 }
2792 2794
2793 if ( external ) { 2795 if ( external ) {
2794 qDebug("Setting vcf mode to external "); 2796 qDebug("Setting vcf mode to external ");
2795 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 2797 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
2796 AddressBook::Iterator it; 2798 AddressBook::Iterator it;
2797 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 2799 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
2798 (*it).setID( mCurrentSyncDevice, (*it).uid() ); 2800 (*it).setID( mCurrentSyncDevice, (*it).uid() );
2799 (*it).computeCsum( mCurrentSyncDevice ); 2801 (*it).computeCsum( mCurrentSyncDevice );
2800 } 2802 }
2801 } 2803 }
2802 } 2804 }
2803 //AddressBook::Iterator it; 2805 //AddressBook::Iterator it;
2804 //QStringList vcards; 2806 //QStringList vcards;
2805 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 2807 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
2806 // qDebug("Name %s ", (*it).familyName().latin1()); 2808 // qDebug("Name %s ", (*it).familyName().latin1());
2807 //} 2809 //}
2808 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); 2810 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode );
2809 if ( syncOK ) { 2811 if ( syncOK ) {
2810 if ( syncManager->mWriteBackFile ) 2812 if ( syncManager->mWriteBackFile )
2811 { 2813 {
2812 if ( external ) 2814 if ( external )
2813 abLocal.removeSyncAddressees( !isXML); 2815 abLocal.removeSyncAddressees( !isXML);
2814 qDebug("Saving remote AB "); 2816 qDebug("Saving remote AB ");
2815 abLocal.saveAB(); 2817 abLocal.saveAB();
2816 if ( isXML ) { 2818 if ( isXML ) {
2817 // afterwrite processing 2819 // afterwrite processing
2818 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); 2820 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice );
2819 } 2821 }
2820 } 2822 }
2821 } 2823 }
2822 setModified(); 2824 setModified();
2823 2825
2824 } 2826 }
2825 if ( syncOK ) 2827 if ( syncOK )
2826 mViewManager->refreshView(); 2828 mViewManager->refreshView();
2827 return syncOK; 2829 return syncOK;
2828#if 0 2830#if 0
2829 2831
2830 if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { 2832 if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) {
2831 getEventViewerDialog()->setSyncMode( true ); 2833 getEventViewerDialog()->setSyncMode( true );
2832 syncOK = synchronizeCalendar( mCalendar, calendar, mode ); 2834 syncOK = synchronizeCalendar( mCalendar, calendar, mode );
2833 getEventViewerDialog()->setSyncMode( false ); 2835 getEventViewerDialog()->setSyncMode( false );
2834 if ( syncOK ) { 2836 if ( syncOK ) {
2835 if ( KOPrefs::instance()->mWriteBackFile ) 2837 if ( KOPrefs::instance()->mWriteBackFile )
2836 { 2838 {
2837 storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); 2839 storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) );
2838 storage->save(); 2840 storage->save();
2839 } 2841 }
2840 } 2842 }
2841 setModified(); 2843 setModified();
2842 } 2844 }
2843 2845
2844#endif 2846#endif
2845} 2847}
2846 2848
2847 2849
2848//this is a overwritten callbackmethods from the syncinterface 2850//this is a overwritten callbackmethods from the syncinterface
2849bool KABCore::syncExternal(KSyncManager* manager, QString resource) 2851bool KABCore::syncExternal(KSyncManager* manager, QString resource)
2850{ 2852{
2851 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 2853 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
2852 2854
2853 AddressBook abLocal( resource,"syncContact"); 2855 AddressBook abLocal( resource,"syncContact");
2854 bool syncOK = false; 2856 bool syncOK = false;
2855 if ( abLocal.load() ) { 2857 if ( abLocal.load() ) {
2856 qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); 2858 qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1());
2857 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 2859 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
2858 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice ); 2860 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice );
2859 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); 2861 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs );
2860 if ( syncOK ) { 2862 if ( syncOK ) {
2861 if ( syncManager->mWriteBackFile ) { 2863 if ( syncManager->mWriteBackFile ) {
2862 abLocal.saveAB(); 2864 abLocal.saveAB();
2863 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); 2865 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice );
2864 } 2866 }
2865 } 2867 }
2866 setModified(); 2868 setModified();
2867 } 2869 }
2868 if ( syncOK ) 2870 if ( syncOK )
2869 mViewManager->refreshView(); 2871 mViewManager->refreshView();
2870 return syncOK; 2872 return syncOK;
2871 2873
2872} 2874}
2873 2875
2874void KABCore::getFile( bool success ) 2876void KABCore::getFile( bool success )
2875{ 2877{
2876 QTimer::singleShot( 15000, this , SLOT ( setCaptionBack())); 2878 QTimer::singleShot( 15000, this , SLOT ( setCaptionBack()));
2877 if ( ! success ) { 2879 if ( ! success ) {
2878 setCaption( i18n("Error receiving file. Nothing changed!") ); 2880 setCaption( i18n("Error receiving file. Nothing changed!") );
2879 return; 2881 return;
2880 } 2882 }
2881 mAddressBook->importFromFile( sentSyncFile() ); 2883 mAddressBook->importFromFile( sentSyncFile() );
2882 topLevelWidget()->setCaption( i18n("Pi-Sync successful!") ); 2884 topLevelWidget()->setCaption( i18n("Pi-Sync successful!") );
2883 mViewManager->refreshView(); 2885 mViewManager->refreshView();
2884} 2886}
2885void KABCore::syncFileRequest() 2887void KABCore::syncFileRequest()
2886{ 2888{
2887 mAddressBook->export2File( sentSyncFile() ); 2889 mAddressBook->export2File( sentSyncFile() );
2888} 2890}
2889QString KABCore::sentSyncFile() 2891QString KABCore::sentSyncFile()
2890{ 2892{
2891#ifdef _WIN32_ 2893#ifdef _WIN32_
2892 return locateLocal( "tmp", "copysyncab.vcf" ); 2894 return locateLocal( "tmp", "copysyncab.vcf" );
2893#else 2895#else
2894 return QString( "/tmp/copysyncab.vcf" ); 2896 return QString( "/tmp/copysyncab.vcf" );
2895#endif 2897#endif
2896} 2898}
2897 2899
2898void KABCore::setCaptionBack() 2900void KABCore::setCaptionBack()
2899{ 2901{
2900 topLevelWidget()->setCaption( i18n("KAddressbook/Pi") ); 2902 topLevelWidget()->setCaption( i18n("KAddressbook/Pi") );
2901} 2903}
diff --git a/kaddressbook/kabprefs.cpp b/kaddressbook/kabprefs.cpp
index 552c933..dded2bf 100644
--- a/kaddressbook/kabprefs.cpp
+++ b/kaddressbook/kabprefs.cpp
@@ -1,132 +1,133 @@
1/* 1/*
2 This file is part of KAddressBook. 2 This file is part of KAddressBook.
3 Copyright (c) 2002 Mike Pilone <mpilone@slac.com> 3 Copyright (c) 2002 Mike Pilone <mpilone@slac.com>
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//US#ifdef KAB_EMBEDDED 24//US#ifdef KAB_EMBEDDED
25//#include <qstring.h> 25//#include <qstring.h>
26//#endif //KAB_EMBEDDED 26//#endif //KAB_EMBEDDED
27 27
28 28
29#include <kconfig.h> 29#include <kconfig.h>
30#include <klocale.h> 30#include <klocale.h>
31#include <kstaticdeleter.h> 31#include <kstaticdeleter.h>
32//US#include <kdebug.h> // defines kdDebug() 32//US#include <kdebug.h> // defines kdDebug()
33 33
34#include "kabprefs.h" 34#include "kabprefs.h"
35 35
36KABPrefs *KABPrefs::sInstance = 0; 36KABPrefs *KABPrefs::sInstance = 0;
37static KStaticDeleter<KABPrefs> staticDeleter; 37static KStaticDeleter<KABPrefs> staticDeleter;
38 38
39KABPrefs::KABPrefs() 39KABPrefs::KABPrefs()
40 : KPimPrefs("kaddressbookrc") 40 : KPimPrefs("kaddressbookrc")
41{ 41{
42 KPrefs::setCurrentGroup( "Views" ); 42 KPrefs::setCurrentGroup( "Views" );
43 addItemBool( "HonorSingleClick", &mHonorSingleClick, false ); 43 addItemBool( "HonorSingleClick", &mHonorSingleClick, false );
44 44
45 KPrefs::setCurrentGroup( "General" ); 45 KPrefs::setCurrentGroup( "General" );
46 addItemBool( "AutomaticNameParsing", &mAutomaticNameParsing, true ); 46 addItemBool( "AutomaticNameParsing", &mAutomaticNameParsing, true );
47 addItemInt( "CurrentIncSearchField", &mCurrentIncSearchField, 0 ); 47 addItemInt( "CurrentIncSearchField", &mCurrentIncSearchField, 0 );
48 48
49#ifdef KAB_EMBEDDED 49#ifdef KAB_EMBEDDED
50 addItemBool("AskForQuit",&mAskForQuit,true); 50 addItemBool("AskForQuit",&mAskForQuit,true);
51 addItemBool("ToolBarHor",&mToolBarHor, true ); 51 addItemBool("ToolBarHor",&mToolBarHor, true );
52 addItemBool("ToolBarUp",&mToolBarUp, false ); 52 addItemBool("ToolBarUp",&mToolBarUp, false );
53 addItemBool("SearchWithReturn",&mSearchWithReturn, true ); 53 addItemBool("SearchWithReturn",&mSearchWithReturn, true );
54 54
55 55
56#endif //KAB_EMBEDDED 56#endif //KAB_EMBEDDED
57 57
58 KPrefs::setCurrentGroup( "MainWindow" ); 58 KPrefs::setCurrentGroup( "MainWindow" );
59 addItemBool( "JumpButtonBarVisible", &mJumpButtonBarVisible, false ); 59 addItemBool( "JumpButtonBarVisible", &mJumpButtonBarVisible, false );
60 addItemBool( "DetailsPageVisible", &mDetailsPageVisible, true ); 60 addItemBool( "DetailsPageVisible", &mDetailsPageVisible, true );
61 addItemIntList( "ExtensionsSplitter", &mExtensionsSplitter ); 61 addItemIntList( "ExtensionsSplitter", &mExtensionsSplitter );
62 addItemIntList( "DetailsSplitter", &mDetailsSplitter ); 62 addItemIntList( "DetailsSplitter", &mDetailsSplitter );
63 addItemBool( "MultipleViewsAtOnce", &mMultipleViewsAtOnce, true ); 63 addItemBool( "MultipleViewsAtOnce", &mMultipleViewsAtOnce, true );
64 64
65 65
66 KPrefs::setCurrentGroup( "Extensions_General" ); 66 KPrefs::setCurrentGroup( "Extensions_General" );
67 QStringList defaultExtensions; 67 QStringList defaultExtensions;
68 defaultExtensions << "merge"; 68 defaultExtensions << "merge";
69 defaultExtensions << "distribution_list_editor"; 69 defaultExtensions << "distribution_list_editor";
70 addItemInt( "CurrentExtension", &mCurrentExtension, 0 ); 70 addItemInt( "CurrentExtension", &mCurrentExtension, 0 );
71 addItemStringList( "ActiveExtensions", &mActiveExtensions, defaultExtensions ); 71 addItemStringList( "ActiveExtensions", &mActiveExtensions, defaultExtensions );
72 72
73 KPrefs::setCurrentGroup( "Views" ); 73 KPrefs::setCurrentGroup( "Views" );
74 QString defaultView = i18n( "Default Table View" ); 74 QString defaultView = i18n( "Default Table View" );
75 addItemString( "CurrentView", &mCurrentView, defaultView ); 75 addItemString( "CurrentView", &mCurrentView, defaultView );
76 addItemStringList( "ViewNames", &mViewNames, defaultView ); 76 addItemStringList( "ViewNames", &mViewNames, defaultView );
77 77
78 KPrefs::setCurrentGroup( "Filters" ); 78 KPrefs::setCurrentGroup( "Filters" );
79 addItemInt( "CurrentFilter", &mCurrentFilter, 0 ); 79 addItemInt( "CurrentFilter", &mCurrentFilter, 0 );
80 80
81} 81}
82 82
83KABPrefs::~KABPrefs() 83KABPrefs::~KABPrefs()
84{ 84{
85 //qDebug("KABPrefs::~KABPrefs() ");
85} 86}
86 87
87KABPrefs *KABPrefs::instance() 88KABPrefs *KABPrefs::instance()
88{ 89{
89 if ( !sInstance ) { 90 if ( !sInstance ) {
90#ifdef KAB_EMBEDDED 91#ifdef KAB_EMBEDDED
91 sInstance = staticDeleter.setObject( new KABPrefs() ); 92 sInstance = staticDeleter.setObject( new KABPrefs() );
92#else //KAB_EMBEDDED 93#else //KAB_EMBEDDED
93 //US the following line has changed ???. Why 94 //US the following line has changed ???. Why
94 staticDeleter.setObject( sInstance, new KABPrefs() ); 95 staticDeleter.setObject( sInstance, new KABPrefs() );
95#endif //KAB_EMBEDDED 96#endif //KAB_EMBEDDED
96 sInstance->readConfig(); 97 sInstance->readConfig();
97 } 98 }
98 99
99 return sInstance; 100 return sInstance;
100} 101}
101 102
102void KABPrefs::setCategoryDefaults() 103void KABPrefs::setCategoryDefaults()
103{ 104{
104 mCustomCategories.clear(); 105 mCustomCategories.clear();
105 106
106 mCustomCategories << i18n( "Business" ) << i18n( "Family" ) << i18n( "School" ) 107 mCustomCategories << i18n( "Business" ) << i18n( "Family" ) << i18n( "School" )
107 << i18n( "Customer" ) << i18n( "Friend" ); 108 << i18n( "Customer" ) << i18n( "Friend" );
108} 109}
109 110
110 // US introduce a nonconst way to return the config object. 111 // US introduce a nonconst way to return the config object.
111KConfig* KABPrefs::getConfig() 112KConfig* KABPrefs::getConfig()
112{ 113{
113 return config(); 114 return config();
114} 115}
115 116
116 117
117/*US 118/*US
118void KABPrefs::usrSetDefaults() 119void KABPrefs::usrSetDefaults()
119{ 120{
120 KPimPrefs::usrSetDefaults(); 121 KPimPrefs::usrSetDefaults();
121} 122}
122 123
123void KABPrefs::usrReadConfig() 124void KABPrefs::usrReadConfig()
124{ 125{
125 KPimPrefs::usrReadConfig(); 126 KPimPrefs::usrReadConfig();
126} 127}
127 128
128void KABPrefs::usrWriteConfig() 129void KABPrefs::usrWriteConfig()
129{ 130{
130 KPimPrefs::usrWriteConfig(); 131 KPimPrefs::usrWriteConfig();
131} 132}
132*/ 133*/
diff --git a/kalarmd/simplealarmdaemonapplet.cpp b/kalarmd/simplealarmdaemonapplet.cpp
index bb89606..7e8125d 100644
--- a/kalarmd/simplealarmdaemonapplet.cpp
+++ b/kalarmd/simplealarmdaemonapplet.cpp
@@ -1,58 +1,57 @@
1#include "simplealarmdaemonapplet.h" 1#include "simplealarmdaemonapplet.h"
2 2
3#include "simplealarmdaemonimpl.h" 3#include "simplealarmdaemonimpl.h"
4 4
5#include <qpe/global.h>
6#include <qcopchannel_qws.h> 5#include <qcopchannel_qws.h>
7#include <qlabel.h> 6#include <qlabel.h>
8#include <qapp.h> 7#include <qapp.h>
9#include <qpe/resource.h> 8#include <qpe/resource.h>
10SimpleAlarmDaemonApplet::SimpleAlarmDaemonApplet() 9SimpleAlarmDaemonApplet::SimpleAlarmDaemonApplet()
11 : mApplet( 0 ), ref( 0 ) 10 : mApplet( 0 ), ref( 0 )
12{ 11{
13 12
14} 13}
15 14
16SimpleAlarmDaemonApplet::~SimpleAlarmDaemonApplet() 15SimpleAlarmDaemonApplet::~SimpleAlarmDaemonApplet()
17{ 16{
18 delete mApplet; 17 delete mApplet;
19} 18}
20 19
21 20
22QWidget *SimpleAlarmDaemonApplet::applet( QWidget *parent ) 21QWidget *SimpleAlarmDaemonApplet::applet( QWidget *parent )
23{ 22{
24 if ( !mApplet ) { 23 if ( !mApplet ) {
25 mApplet = new SimpleAlarmDaemonImpl( parent ); 24 mApplet = new SimpleAlarmDaemonImpl( parent );
26 if ( QApplication::desktop()->width() < 480 ) 25 if ( QApplication::desktop()->width() < 480 )
27 mApplet->setPixmap( Resource::loadPixmap( "ko16" ) ); 26 mApplet->setPixmap( Resource::loadPixmap( "ko16" ) );
28 else 27 else
29 mApplet->setPixmap( Resource::loadPixmap( "ko24" ) ); 28 mApplet->setPixmap( Resource::loadPixmap( "ko24" ) );
30 QCopChannel* c = new QCopChannel("koalarm",mApplet , "channel" ) ; 29 QCopChannel* c = new QCopChannel("koalarm",mApplet , "channel" ) ;
31 QObject::connect( c, SIGNAL (received ( const QCString &, const QByteArray & )),mApplet, SLOT(recieve( const QCString&, const QByteArray& ))); 30 QObject::connect( c, SIGNAL (received ( const QCString &, const QByteArray & )),mApplet, SLOT(recieve( const QCString&, const QByteArray& )));
32 mApplet->show(); 31 mApplet->show();
33 } 32 }
34 return mApplet; 33 return mApplet;
35} 34}
36 35
37int SimpleAlarmDaemonApplet::position() const 36int SimpleAlarmDaemonApplet::position() const
38{ 37{
39 return 7; 38 return 7;
40} 39}
41 40
42QRESULT SimpleAlarmDaemonApplet::queryInterface( const QUuid &uuid, QUnknownInterface **iface ) 41QRESULT SimpleAlarmDaemonApplet::queryInterface( const QUuid &uuid, QUnknownInterface **iface )
43{ 42{
44 *iface = 0; 43 *iface = 0;
45 if ( uuid == IID_QUnknown ) 44 if ( uuid == IID_QUnknown )
46 *iface = this; 45 *iface = this;
47 else if ( uuid == IID_TaskbarApplet ) 46 else if ( uuid == IID_TaskbarApplet )
48 *iface = this; 47 *iface = this;
49 48
50 if ( *iface ) 49 if ( *iface )
51 (*iface)->addRef(); 50 (*iface)->addRef();
52 return QS_OK; 51 return QS_OK;
53} 52}
54 53
55Q_EXPORT_INTERFACE() 54Q_EXPORT_INTERFACE()
56{ 55{
57 Q_CREATE_INSTANCE( SimpleAlarmDaemonApplet ) 56 Q_CREATE_INSTANCE( SimpleAlarmDaemonApplet )
58} 57}
diff --git a/kmicromail/koprefs.cpp b/kmicromail/koprefs.cpp
index 6484c45..c0200ff 100644
--- a/kmicromail/koprefs.cpp
+++ b/kmicromail/koprefs.cpp
@@ -1,507 +1,128 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 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 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 <time.h> 24#include <time.h>
25#ifndef _WIN32_ 25#ifndef _WIN32_
26#include <unistd.h> 26#include <unistd.h>
27#endif 27#endif
28#include <qdir.h> 28#include <qdir.h>
29#include <qtextstream.h> 29#include <qtextstream.h>
30#include <qtextcodec.h> 30#include <qtextcodec.h>
31#include <qstring.h> 31#include <qstring.h>
32#include <qregexp.h> 32#include <qregexp.h>
33#include <qfont.h> 33#include <qfont.h>
34#include <qcolor.h> 34#include <qcolor.h>
35#include <qstringlist.h> 35#include <qstringlist.h>
36#include <stdlib.h> 36#include <stdlib.h>
37 37
38#include <kglobal.h> 38#include <kglobal.h>
39#include <kconfig.h> 39#include <kconfig.h>
40#include <klocale.h> 40#include <klocale.h>
41#include <kdebug.h> 41#include <kdebug.h>
42#include <kemailsettings.h> 42#include <kemailsettings.h>
43#include <kstaticdeleter.h> 43#include <kstaticdeleter.h>
44 44
45#include "koprefs.h" 45#include "koprefs.h"
46#include "mainwindow.h" 46#include "mainwindow.h"
47 47
48 48
49KOPrefs *KOPrefs::mInstance = 0; 49KOPrefs *KOPrefs::mInstance = 0;
50static KStaticDeleter<KOPrefs> insd; 50static KStaticDeleter<KOPrefs> insd;
51 51
52KOPrefs::KOPrefs() : 52KOPrefs::KOPrefs() :
53 KPimPrefs("kopiemailrc") 53 KPimPrefs("kopiemailrc")
54{ 54{
55 mAppFont = QFont("helvetica",12); 55 mAppFont = QFont("helvetica",12);
56 mComposeFont = QFont("helvetica",12); 56 mComposeFont = QFont("helvetica",12);
57 mReadFont = QFont("helvetica",12); 57 mReadFont = QFont("helvetica",12);
58 58
59 KPrefs::setCurrentGroup("General"); 59 KPrefs::setCurrentGroup("General");
60 addItemString("SenderName",&mName,i18n ("Please set at") ); 60 addItemString("SenderName",&mName,i18n ("Please set at") );
61 addItemString("SenderEmail",&mEmail,i18n ("Settings@General TAB") ); 61 addItemString("SenderEmail",&mEmail,i18n ("Settings@General TAB") );
62 addItemBool("ViewMailAsHtml",&mViewAsHtml,false); 62 addItemBool("ViewMailAsHtml",&mViewAsHtml,false);
63 addItemBool("SendMailLater",&mSendLater,true); 63 addItemBool("SendMailLater",&mSendLater,true);
64 addItemBool("UseKapi",&mUseKapi,false); 64 addItemBool("UseKapi",&mUseKapi,false);
65 65
66 KPrefs::setCurrentGroup("Fonts"); 66 KPrefs::setCurrentGroup("Fonts");
67 addItemFont("Application Font",&mAppFont); 67 addItemFont("Application Font",&mAppFont);
68 addItemFont("Compose Font",&mComposeFont); 68 addItemFont("Compose Font",&mComposeFont);
69 addItemFont("Read Font",&mReadFont); 69 addItemFont("Read Font",&mReadFont);
70 70
71#if 0
72 mTimeBarFont = QFont("helvetica",10);//,QFont::Bold);
73 mDefaultViewFont = QFont("helvetica",10);
74 mDefaultMonthViewFont = QFont("helvetica",8);
75 mMarcusBainsFont= QFont("helvetica",10);
76 mDateNavigatorFont= QFont("helvetica",10, QFont::Bold);
77 mEditBoxFont = QFont("helvetica",12);
78 mJornalViewFont = QFont("helvetica",12);
79
80 KPrefs::setCurrentGroup("General");
81 addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false);
82
83 addItemBool("ShowIconNewTodo",&mShowIconNewTodo,true);
84 addItemBool("ShowIconNewEvent",&mShowIconNewEvent,true);
85 addItemBool("ShowIconSearch",&mShowIconSearch,true);
86 addItemBool("ShowIconList",&mShowIconList,true);
87 addItemBool("ShowIconDay1",&mShowIconDay1,true);
88 addItemBool("ShowIconDay5",&mShowIconDay5,true);
89 addItemBool("ShowIconDay7",&mShowIconDay7,true);
90 addItemBool("ShowIconMonth",&mShowIconMonth,true);
91 addItemBool("ShowIconTodoview",&mShowIconTodoview,true);
92 addItemBool("ShowIconBackFast",&mShowIconBackFast,true);
93 addItemBool("ShowIconBack",&mShowIconBack,true);
94 addItemBool("ShowIconToday",&mShowIconToday,true);
95 addItemBool("ShowIconForward",&mShowIconForward,true);
96 addItemBool("ShowIconForwardFast",&mShowIconForwardFast,true);
97 addItemBool("ShowIconWhatsThis",&mShowIconWhatsThis,false);
98 addItemBool("ShowIconNextDays",&mShowIconNextDays,true);
99 addItemBool("ShowIconNext",&mShowIconNext,true);
100 addItemBool("ShowIconJournal",&mShowIconJournal,true);
101 addItemBool("ShowIconStretch",&mShowIconStretch,true);
102 addItemBool("LanguageChanged",&mLanguageChanged,false);
103
104 addItemBool("AskForQuit",&mAskForQuit,false);
105
106#ifndef DESKTOP_VERSION
107 addItemBool("ShowFullMenu",&mShowFullMenu,false);
108#else
109 addItemBool("ShowFullMenu",&mShowFullMenu,true);
110#endif
111 addItemBool("ToolBarHor",&mToolBarHor, true );
112 addItemBool("ToolBarUp",&mToolBarUp, false );
113 addItemBool("ToolBarMiniIcons",&mToolBarMiniIcons, false );
114 addItemInt("Whats Next Days",&mWhatsNextDays,3);
115 addItemInt("Whats Next Prios",&mWhatsNextPrios,1);
116
117 addItemBool("ShowTodoInAgenda",&mShowTodoInAgenda,true);
118 addItemBool("ShowCompletedTodo",&mShowCompletedTodo,true);
119 addItemInt("AllDay Size",&mAllDaySize,28);
120 QString defAlarm = KGlobal::iconLoader()->iconPath()+"koalarm.wav";
121 addItemString("DefaultAlarmFile",&mDefaultAlarmFile,defAlarm );
122
123 addItemStringList("LocationDefaults",&mLocationDefaults );
124 addItemStringList("EventSummary User",&mEventSummaryUser);
125 addItemStringList("TodoSummary User",&mTodoSummaryUser);
126
127 addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false);
128 addItemBool("Enable Project View",&mEnableProjectView,false);
129 addItemBool("Auto Save",&mAutoSave,false);
130 addItemInt("Auto Save Interval",&mAutoSaveInterval,3);
131 addItemBool("Confirm Deletes",&mConfirm,true);
132 addItemString("Archive File",&mArchiveFile);
133 addItemString("Html Export File",&mHtmlExportFile,
134 QDir::homeDirPath() + "/" + i18n("Default export file", "calendar.html"));
135 addItemBool("Html With Save",&mHtmlWithSave,false);
136
137 KPrefs::setCurrentGroup("Personal Settings");
138
139 addItemInt("Mail Client",&mMailClient,MailClientKMail);
140 addItemBool("Use Control Center Email",&mEmailControlCenter,false);
141 addItemBool("Bcc",&mBcc,false);
142
143 KPrefs::setCurrentGroup("Time & Date");
144
145 // addItemString("Time Zone",&mTimeZone,"+0100");
146 addItemString("TimeZoneName",&mTimeZoneId,i18n ("+01:00 Europe/Oslo(CET)") );
147 // addItemInt("TimeZoneOffset",&mTimeZoneOffset,60);
148 addItemBool("UseDaylightsaving",&mUseDaylightsaving,true);
149 addItemInt("DaylightsavingStart",&mDaylightsavingStart,90);
150 addItemInt("DaylightsavingEnd",&mDaylightsavingEnd,304);
151
152
153 addItemInt("Default Start Time",&mStartTime,10);
154 addItemInt("Default Duration",&mDefaultDuration,2);
155 addItemInt("Default Alarm Time",&mAlarmTime,3);
156 addItemInt("Daylight Savings",&mDaylightSavings,0);
157 KPrefs::setCurrentGroup("AlarmSettings");
158 addItemInt("AlarmPlayBeeps",&mAlarmPlayBeeps,20);
159 addItemInt("AlarmSuspendTime",&mAlarmSuspendTime,7);
160 addItemInt("AlarmSuspendCount",&mAlarmSuspendCount,5);
161 addItemInt("AlarmBeepInterval",&mAlarmBeepInterval,3);
162
163
164 KPrefs::setCurrentGroup("Calendar");
165
166 addItemInt("Default Calendar Format",&mDefaultFormat,FormatICalendar);
167
168 KPrefs::setCurrentGroup("Fonts");
169 // qDebug(" KPrefs::setCurrentGroup(Fonts); ");
170 addItemFont("TimeBar Font",&mTimeBarFont);
171 addItemFont("MonthView Font",&mMonthViewFont);
172 addItemFont("AgendaView Font",&mAgendaViewFont);
173 addItemFont("MarcusBains Font",&mMarcusBainsFont);
174 addItemFont("TimeLabels Font",&mTimeLabelsFont);
175 addItemFont("TodoView Font",&mTodoViewFont);
176 addItemFont("ListView Font",&mListViewFont);
177 addItemFont("DateNavigator Font",&mDateNavigatorFont);
178 addItemFont("EditBox Font",&mEditBoxFont);
179 addItemFont("JournalView Font",&mJornalViewFont);
180 addItemFont("WhatsNextView Font",&mWhatsNextFont);
181 addItemFont("EventView Font",&mEventViewFont);
182
183// KPrefs::setCurrentGroup("SyncProfiles");
184// addItemString("LocalMachineName",&mLocalMachineName, "undefined");
185// addItemStringList("SyncProfileNames",&mSyncProfileNames);
186// addItemStringList("ExternSyncProfiles",&mExternSyncProfileNames);
187
188 KPrefs::setCurrentGroup("RemoteSyncing");
189// addItemBool("UsePasswd",&mUsePassWd,false);
190// addItemBool("WriteBackFile",&mWriteBackFile,true);
191// addItemBool("WriteBackExistingOnly",&mWriteBackExistingOnly,false);
192// addItemBool("AskForPreferences",&mAskForPreferences,true);
193// addItemBool("ShowSyncSummary",&mShowSyncSummary,true);
194 addItemBool("ShowSyncEvents",&mShowSyncEvents,false);
195 addItemInt("LastSyncTime",&mLastSyncTime,0);
196 addItemInt("SyncAlgoPrefs",&mSyncAlgoPrefs,3);
197 addItemInt("RingSyncAlgoPrefs",&mRingSyncAlgoPrefs,3);
198
199#ifdef _WIN32_
200 QString hdp= locateLocal("data","korganizer")+"\\\\";
201#else
202 QString hdp= locateLocal("data","korganizer")+"/";
203#endif
204// addItemString("RemoteIP",&mRemoteIP, "192.168.0.65");
205// addItemString("RemoteUser",&mRemoteUser, "zaurus");
206// addItemString("RemotePassWd",&mRemotePassWd, "");
207// addItemString("RemoteFile", &mRemoteFile, hdp+"mycalendar.ics");
208// addItemString("LocalTempFile",&mLocalTempFile, "/tmp/tempsyncfile.ics" );
209
210
211 KPrefs::setCurrentGroup("LoadSaveFileNames");
212
213 addItemString("LastImportFile", &mLastImportFile ,hdp +"import.ics" );
214 addItemString("LastVcalFile", &mLastVcalFile ,hdp +"export.vcs" );
215 addItemString("LastSaveFile", &mLastSaveFile ,hdp +"mybackup.ics" );
216 addItemString("LastLoadFile", &mLastLoadFile ,hdp +"mybackup.ics" );
217 addItemString("LastSyncedLocalFile", &mLastSyncedLocalFile ,hdp +"lastsync.ics" );
218
219
220 KPrefs::setCurrentGroup("Locale");
221 addItemInt("PreferredLanguage",&mPreferredLanguage,0);
222 addItemInt("PreferredTime",&mPreferredTime,0);
223 addItemInt("PreferredDate",&mPreferredDate,0);
224 addItemBool("WeekStartsOnSunday",&mWeekStartsOnSunday,false);
225 addItemBool("QuickSavingWOUnicode",&mUseQuicksave,false);
226 addItemBool("ShortDateInViewer",&mShortDateInViewer,false);
227 addItemString("UserDateFormatLong", &mUserDateFormatLong, "%A %d %b %y");
228 addItemString("UserDateFormatShort", &mUserDateFormatShort, "%aK %d.%m.%y");
229
230
231 KPrefs::setCurrentGroup("Colors");
232 addItemColor("Holiday Color",&mHolidayColor,defaultHolidayColor);
233 addItemColor("Highlight Color",&mHighlightColor,defaultHighlightColor);
234 addItemColor("Event Color",&mEventColor,mDefaultCategoryColor);
235 addItemColor("Agenda Background Color",&mAgendaBgColor,defaultAgendaBgColor);
236 addItemColor("WorkingHours Color",&mWorkingHoursColor,defaultWorkingHoursColor);
237 addItemColor("Todo due today Color",&mTodoDueTodayColor,defaultTodoDueTodayColor);
238 addItemColor("Todo overdue Color",&mTodoOverdueColor,defaultTodoOverdueColor);
239 addItemColor("MonthViewEvenColor",&mMonthViewEvenColor,QColor( 160,160,255 ));
240 addItemColor("MonthViewOddColor",&mMonthViewOddColor,QColor( 160,255,160 ));
241 addItemColor("MonthViewHolidayColor",&mMonthViewHolidayColor,QColor( 255,160,160 ));
242 addItemBool("MonthViewUsesDayColors",&mMonthViewUsesDayColors,true);
243 addItemBool("MonthViewSatSunTog",&mMonthViewSatSunTog,true);
244 addItemBool("HightlightDateTimeEdit",&mHightlightDateTimeEdit,false);
245 addItemColor("AppColor1",&mAppColor1,QColor( 130,170,255 ));
246 addItemColor("AppColor2",&mAppColor2,QColor( 174,216,255 ));
247 addItemBool("UseAppColors",&mUseAppColors,false);
248
249
250
251 KPrefs::setCurrentGroup("Views");
252 addItemInt("Hour Size",&mHourSize,8);
253 addItemBool("Show Daily Recurrences",&mDailyRecur,true);
254 addItemBool("Show Weekly Recurrences",&mWeeklyRecur,true);
255 addItemBool("Show Month Daily Recurrences",&mMonthDailyRecur,true);
256 addItemBool("Show Month Weekly Recurrences",&mMonthWeeklyRecur,true);
257 addItemBool("ShowShortMonthName",&mMonthShowShort,false);
258 addItemBool("ShowIconsInMonthCell",&mMonthShowIcons,true);
259 addItemBool("Enable ToolTips",&mEnableToolTips,false);
260 addItemBool("Enable MonthView ScrollBars",&mEnableMonthScroll,false);
261 addItemBool("Marcus Bains shows seconds",&mMarcusBainsShowSeconds,false);
262 addItemBool("Show Marcus Bains",&mMarcusBainsEnabled,true);
263 addItemBool("EditOnDoubleClick",&mEditOnDoubleClick,true);
264 addItemBool("ViewChangeHoldFullscreen",&mViewChangeHoldFullscreen,false);
265 addItemBool("ViewChangeHoldNonFullscreen",&mViewChangeHoldNonFullscreen,false);
266 addItemBool("CenterOnCurrentTime",&mCenterOnCurrentTime,false);
267 addItemBool("SetTimeToDayStartAt",&mSetTimeToDayStartAt,true);
268 addItemBool("HighlightCurrentDay",&mHighlightCurrentDay,true);
269 addItemBool("WNViewShowsParents",&mWNViewShowsParents,true);
270 addItemBool("WNViewShowLocation",&mWNViewShowLocation,false);
271 addItemBool("UseHighlightLightColor",&mUseHighlightLightColor,false);
272 addItemBool("ListViewMonthTimespan",&mListViewMonthTimespan,true);
273 addItemBool("TodoViewUsesCatColors",&mTodoViewUsesCatColors,false);
274 addItemBool("TodoViewShowsPercentage",&mTodoViewShowsPercentage,false);
275 addItemBool("TodoViewUsesSmallFont",&mTodoViewUsesSmallFont,false);
276 addItemBool("TodoViewUsesForegroundColor",&mTodoViewUsesForegroundColor,false);
277 addItemBool("MonthViewUsesForegroundColor",&mMonthViewUsesForegroundColor,false);
278#ifdef DESKTOP_VERSION
279 addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,true);
280#else
281 addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,false);
282#endif
283 addItemInt("Day Begins",&mDayBegins,7);
284 addItemInt("Working Hours Start",&mWorkingHoursStart,8);
285 addItemInt("Working Hours End",&mWorkingHoursEnd,17);
286 addItemBool("Exclude Holidays",&mExcludeHolidays,true);
287 addItemBool("Exclude Saturdays",&mExcludeSaturdays,true);
288
289 addItemBool("Month View Uses Category Color",&mMonthViewUsesCategoryColor,false);
290 addItemBool("Full View Month",&mFullViewMonth,true);
291 addItemBool("Full View Todo",&mFullViewTodo,true);
292 addItemBool("Quick Todo",&mEnableQuickTodo,false);
293
294 addItemInt("Next X Days",&mNextXDays,3);
295
296 KPrefs::setCurrentGroup("Printer");
297
298 KPrefs::setCurrentGroup("Layout");
299
300 addItemBool("CompactDialogs",&mCompactDialogs,false);
301 addItemBool("VerticalScreen",&mVerticalScreen,true);
302
303 KPrefs::setCurrentGroup("KOrganizer Plugins");
304
305 addItemStringList("SelectedPlugins",&mSelectedPlugins,"holidays");
306
307 KPrefs::setCurrentGroup("Group Scheduling");
308
309 addItemInt("IMIPScheduler",&mIMIPScheduler,IMIPKMail);
310 addItemInt("IMIPSend",&mIMIPSend,IMIPdirectsend);
311 addItemStringList("AdditionalMails",&mAdditionalMails,"");
312 addItemInt("IMIP auto refresh",&mIMIPAutoRefresh,neverAuto);
313 addItemInt("IMIP auto insert request",&mIMIPAutoInsertRequest,neverAuto);
314 addItemInt("IMIP auto insert reply",&mIMIPAutoInsertReply,neverAuto);
315 addItemInt("IMIP auto FreeBusy",&mIMIPAutoFreeBusy,neverAuto);
316 addItemInt("IMIP auto save FreeBusy",&mIMIPAutoFreeBusyReply,neverAuto);
317
318 KPrefs::setCurrentGroup( "Editors" );
319
320 addItemStringList( "EventTemplates", &mEventTemplates );
321 addItemStringList( "TodoTemplates", &mTodoTemplates );
322
323 addItemInt("DestinationPolicy",&mDestination,standardDestination);
324
325#endif
326 71
327} 72}
328 73
329 74
330KOPrefs::~KOPrefs() 75KOPrefs::~KOPrefs()
331{ 76{
332 if (mInstance == this) 77 if (mInstance == this)
333 mInstance = insd.setObject(0); 78 mInstance = insd.setObject(0);
334#if 0 79
335 setLocaleDict( 0 );
336 if ( mLocaleDict )
337 delete mLocaleDict;
338 //qDebug("KOPrefs::~KOPrefs() ");
339#endif
340} 80}
341 81
342 82
343KOPrefs *KOPrefs::instance() 83KOPrefs *KOPrefs::instance()
344{ 84{
345 if (!mInstance) { 85 if (!mInstance) {
346 mInstance = insd.setObject(new KOPrefs()); 86 mInstance = insd.setObject(new KOPrefs());
347 mInstance->readConfig(); 87 mInstance->readConfig();
348 } 88 }
349 89
350 return mInstance; 90 return mInstance;
351} 91}
352 92
353void KOPrefs::usrSetDefaults() 93void KOPrefs::usrSetDefaults()
354{ 94{
355 95
356} 96}
357 97
358void KOPrefs::fillMailDefaults() 98void KOPrefs::fillMailDefaults()
359{ 99{
360 if (mName.isEmpty()) mName = i18n("Anonymous"); 100 if (mName.isEmpty()) mName = i18n("Anonymous");
361 if (mEmail.isEmpty()) mEmail = i18n("nobody@nowhere"); 101 if (mEmail.isEmpty()) mEmail = i18n("nobody@nowhere");
362} 102}
363 103
364void KOPrefs::setTimeZoneIdDefault() 104void KOPrefs::setTimeZoneIdDefault()
365{ 105{
366 mTimeZoneId = i18n("+01:00 Europe/Oslo(CET)"); 106 mTimeZoneId = i18n("+01:00 Europe/Oslo(CET)");
367} 107}
368 108
369 109
370void KOPrefs::usrReadConfig() 110void KOPrefs::usrReadConfig()
371{ 111{
372#if 0
373 mLocaleDict = 0;
374 // pending LR fix translation
375 // qDebug("KOPrefs::usrReadConfig() fix translation ");
376 if ( mPreferredLanguage > 0 && mPreferredLanguage < 4 ) {
377 if ( mPreferredLanguage == 1 ) {
378 mLocaleDict = new QDict<QString>;
379 int i = 0;
380 QString fw ( germanwords[i] [0]);
381 while ( !fw.isEmpty() ) {
382 mLocaleDict->insert( fw, new QString (germanwords[i] [1] ));
383 ++i;
384 fw = germanwords[i] [0];
385 }
386
387 setLocaleDict( mLocaleDict );
388 } else {
389 QString fileName ;
390 if ( mPreferredLanguage == 3 )
391 fileName = MainWindow::resourcePath()+"usertranslation.txt";
392 else if ( mPreferredLanguage == 2 )
393 fileName = MainWindow::resourcePath()+"frenchtranslation.txt";
394 QFile file( fileName );
395 if (file.open( IO_ReadOnly ) ) {
396 QTextStream ts( &file );
397 ts.setEncoding( QTextStream::Latin1 );
398 //ts.setCodec( QTextCodec::latin1 );
399 QString text = ts.read();
400 file.close();
401 text.replace( QRegExp("\\\\n"), "\n" );
402 QString line;
403 QString we;
404 QString wt;
405 int br = 0;
406 int nbr;
407 nbr = text.find ( "},", br );
408 line = text.mid( br, nbr - br );
409 br = nbr+1;
410 int se, ee, st, et;
411 mLocaleDict = new QDict<QString>;
412 QString end = "{ \"\",\"\" }";
413 while ( (line != end) && (br > 1) ) {
414 //qDebug("%d *%s* ", br, line.latin1());
415 se = line.find("\"")+1;
416 et = line.findRev("\"",-1);
417 ee = line.find("\",\"");
418 st = ee+3;
419 we = line.mid( se, ee-se );
420 wt = line.mid( st, et-st );
421 //qDebug("*%s* *%s* ", we.latin1(), wt.latin1());
422 mLocaleDict->insert( we, new QString (wt) );
423 nbr = text.find ( "}", br );
424 line = text.mid( br, nbr - br );
425 br = nbr+1;
426 }
427 //qDebug("end *%s* ", end.latin1());
428
429 setLocaleDict( mLocaleDict );
430 } else {
431 qDebug("KO: Cannot find translation file %s",fileName.latin1() );
432 }
433
434 }
435 }
436 config()->setGroup("General");
437
438 mCustomCategories = config()->readListEntry("Custom Categories");
439 if ( KOPrefs::instance()->mLanguageChanged ) {
440 mLocationDefaults.clear();
441 mEventSummaryUser.clear();
442 mTodoSummaryUser.clear();
443 }
444 if (mLocationDefaults.isEmpty()) {
445 mLocationDefaults << i18n("Home") << i18n("Office") << i18n("Library") << i18n("School") << i18n("Doctor") << i18n("Beach")
446 << i18n("University") << i18n("Restaurant") << i18n("Bar") << i18n("Conference room") << i18n("Cinema") << i18n("Lake") << i18n("Kindergarten")
447 << i18n("Germany") << i18n("Sweden") << i18n("Forest") << i18n("Desert") << i18n("Kitchen") ;
448 // << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("")
449 mLocationDefaults.sort();
450 }
451
452 if (mEventSummaryUser.isEmpty()) {
453 mEventSummaryUser = getDefaultList() ;
454 }
455 if (mTodoSummaryUser.isEmpty()) {
456 mTodoSummaryUser = getDefaultList() ;
457 }
458
459 if (mCustomCategories.isEmpty()) setCategoryDefaults();
460
461 config()->setGroup("Personal Settings");
462 mName = config()->readEntry("user_name","");
463 mEmail = config()->readEntry("user_email","");
464 fillMailDefaults();
465 112
466 config()->setGroup("Category Colors");
467 QStringList::Iterator it;
468 for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) {
469 setCategoryColor(*it,config()->readColorEntry(*it,&mDefaultCategoryColor));
470
471 }
472
473 if (mTimeZoneId.isEmpty()) {
474 setTimeZoneIdDefault();
475 }
476#endif
477 KPimPrefs::usrReadConfig(); 113 KPimPrefs::usrReadConfig();
478} 114}
479 115
480 116
481void KOPrefs::usrWriteConfig() 117void KOPrefs::usrWriteConfig()
482{ 118{
483#if 0
484 config()->setGroup("General");
485 config()->writeEntry("Custom Categories",mCustomCategories);
486
487 config()->setGroup("Personal Settings");
488 config()->writeEntry("user_name",mName);
489 config()->writeEntry("user_email",mEmail);
490 119
491 config()->setGroup("Category Colors");
492 QDictIterator<QColor> it(mCategoryColors);
493 while (it.current()) {
494 config()->writeEntry(it.currentKey(),*(it.current()));
495 ++it;
496 }
497
498#endif
499 KPimPrefs::usrWriteConfig(); 120 KPimPrefs::usrWriteConfig();
500} 121}
501 122
502 123
503 124
504KConfig* KOPrefs::getConfig() 125KConfig* KOPrefs::getConfig()
505{ 126{
506 return config(); 127 return config();
507} 128}
diff --git a/korganizer/main.cpp b/korganizer/main.cpp
index 7f9b5c6..16186c0 100644
--- a/korganizer/main.cpp
+++ b/korganizer/main.cpp
@@ -1,102 +1,108 @@
1 1
2 2
3#ifndef DESKTOP_VERSION 3#ifndef DESKTOP_VERSION
4#include <qpe/qpeapplication.h> 4#include <qpe/qpeapplication.h>
5#include <qcopchannel_qws.h>
5#include <qpe/global.h> 6#include <qpe/global.h>
6#include <stdlib.h> 7#include <stdlib.h>
7#else 8#else
8#include <qapplication.h> 9#include <qapplication.h>
9#include <qstring.h> 10#include <qstring.h>
10#include <qwindowsstyle.h> 11#include <qwindowsstyle.h>
11#include <qplatinumstyle.h> 12#include <qplatinumstyle.h>
12#include <qsgistyle.h> 13#include <qsgistyle.h>
13#endif 14#endif
14 15
15#include <qdir.h> 16#include <qdir.h>
16#include <kstandarddirs.h> 17#include <kstandarddirs.h>
17#include <kglobal.h> 18#include <kglobal.h>
18#include <stdio.h> 19#include <stdio.h>
19#include "mainwindow.h" 20#include "mainwindow.h"
20 21
21int main( int argc, char **argv ) 22int main( int argc, char **argv )
22{ 23{
23#ifndef DESKTOP_VERSION 24#ifndef DESKTOP_VERSION
24 QPEApplication a( argc, argv ); 25 QPEApplication a( argc, argv );
25 a.setKeepRunning (); 26 a.setKeepRunning ();
26#else 27#else
27 QApplication a( argc, argv ); 28 QApplication a( argc, argv );
28 QApplication::setStyle( new QPlatinumStyle ()); 29 QApplication::setStyle( new QPlatinumStyle ());
29 QString hdir = QDir::homeDirPath(); 30 QString hdir = QDir::homeDirPath();
30 // there is a bug when creating dirs for WIN 98 31 // there is a bug when creating dirs for WIN 98
31 // it is difficult to fix, because we have no WIN 98 runnung 32 // it is difficult to fix, because we have no WIN 98 runnung
32 // such that we try it to create the dirs at startup here 33 // such that we try it to create the dirs at startup here
33 if ( hdir == "C:\\" ) { // win 98 or ME 34 if ( hdir == "C:\\" ) { // win 98 or ME
34 QDir app_dir; 35 QDir app_dir;
35 if ( !app_dir.exists("C:\\kdepim") ) 36 if ( !app_dir.exists("C:\\kdepim") )
36 app_dir.mkdir ("C:\\kdepim"); 37 app_dir.mkdir ("C:\\kdepim");
37 if ( !app_dir.exists("C:\\kdepim\\apps") ) 38 if ( !app_dir.exists("C:\\kdepim\\apps") )
38 app_dir.mkdir ("C:\\kdepim\\apps"); 39 app_dir.mkdir ("C:\\kdepim\\apps");
39 if ( !app_dir.exists("C:\\kdepim\\config") ) 40 if ( !app_dir.exists("C:\\kdepim\\config") )
40 app_dir.mkdir ("C:\\kdepim\\config"); 41 app_dir.mkdir ("C:\\kdepim\\config");
41 if ( !app_dir.exists("C:\\kdepim\\apps\\korganizer") ) 42 if ( !app_dir.exists("C:\\kdepim\\apps\\korganizer") )
42 app_dir.mkdir ("C:\\kdepim\\apps\\korganizer"); 43 app_dir.mkdir ("C:\\kdepim\\apps\\korganizer");
43 } 44 }
44#endif 45#endif
45 bool exitHelp = false; 46 bool exitHelp = false;
46 if ( argc > 1 ) { 47 if ( argc > 1 ) {
47 QString command = argv[1]; 48 QString command = argv[1];
48 if ( command == "-help" ){ 49 if ( command == "-help" ){
49 printf("KO/Pi command line commands:\n"); 50 printf("KO/Pi command line commands:\n");
50 printf(" no command: Start KO/Pi in usual way\n"); 51 printf(" no command: Start KO/Pi in usual way\n");
51 printf(" -help: This output\n"); 52 printf(" -help: This output\n");
52 printf("Next Option: Open or Show after start:\n"); 53 printf("Next Option: Open or Show after start:\n");
53 printf(" -newTodo: New Todo dialog\n"); 54 printf(" -newTodo: New Todo dialog\n");
54 printf(" -newEvent: New Event dialog\n"); 55 printf(" -newEvent: New Event dialog\n");
55 printf(" -showList: List view\n"); 56 printf(" -showList: List view\n");
56 printf(" -showDay: Day view\n"); 57 printf(" -showDay: Day view\n");
57 printf(" -showWWeek: Work Week view\n"); 58 printf(" -showWWeek: Work Week view\n");
58 printf(" -showWeek: Week view\n"); 59 printf(" -showWeek: Week view\n");
59 printf(" -showTodo: Todo view\n"); 60 printf(" -showTodo: Todo view\n");
60 printf(" -showJournal: Journal view\n"); 61 printf(" -showJournal: Journal view\n");
61 printf(" -showKO: Next Days view\n"); 62 printf(" -showKO: Next Days view\n");
62 printf(" -showWNext: What's Next view\n"); 63 printf(" -showWNext: What's Next view\n");
63 printf(" -showNextXView: Next X View\n"); 64 printf(" -showNextXView: Next X View\n");
64 printf(" -new[Y] and -show[X] may be used togehther\n"); 65 printf(" -new[Y] and -show[X] may be used togehther\n");
65 printf(" KO/Pi is exiting now. Bye!\n"); 66 printf(" KO/Pi is exiting now. Bye!\n");
66 exitHelp = true; 67 exitHelp = true;
67 } 68 }
68 } 69 }
69 if ( ! exitHelp ) { 70 if ( ! exitHelp ) {
70 KGlobal::setAppName( "korganizer" ); 71 KGlobal::setAppName( "korganizer" );
71 QString fileName ; 72 QString fileName ;
72#ifndef DESKTOP_VERSION 73#ifndef DESKTOP_VERSION
73 fileName = getenv("QPEDIR"); 74 fileName = getenv("QPEDIR");
74 KGlobal::iconLoader()->setIconPath( fileName +"/pics/kdepim/korganizer/"); 75 KGlobal::iconLoader()->setIconPath( fileName +"/pics/kdepim/korganizer/");
75#else 76#else
76 fileName = qApp->applicationDirPath () + "/kdepim/korganizer/"; 77 fileName = qApp->applicationDirPath () + "/kdepim/korganizer/";
77 KGlobal::iconLoader()->setIconPath(QDir::convertSeparators(fileName)); 78 KGlobal::iconLoader()->setIconPath(QDir::convertSeparators(fileName));
78#endif 79#endif
79 KStandardDirs::setAppDir( QDir::convertSeparators(locateLocal("data", "korganizer"))); 80 KStandardDirs::setAppDir( QDir::convertSeparators(locateLocal("data", "korganizer")));
80 MainWindow m; 81 MainWindow m;
81#ifndef DESKTOP_VERSION 82#ifndef DESKTOP_VERSION
83 QCopChannel* c1 = new QCopChannel("QPE/Application/datebook",&m, "channel" ) ;
84 QObject::connect( c1, SIGNAL (received ( const QCString &, const QByteArray & )),&m, SLOT(recieve( const QCString&, const QByteArray& )));
82 QObject::connect( &a, SIGNAL (appMessage ( const QCString &, const QByteArray & )),&m, SLOT(recieve( const QCString&, const QByteArray& ))); 85 QObject::connect( &a, SIGNAL (appMessage ( const QCString &, const QByteArray & )),&m, SLOT(recieve( const QCString&, const QByteArray& )));
83 a.showMainWidget(&m ); 86 a.showMainWidget(&m );
84#else 87#else
85 a.setMainWidget(&m ); 88 a.setMainWidget(&m );
86 m.show(); 89 m.show();
87 //m.resize( 800, 600 ); 90 //m.resize( 800, 600 );
88 QObject::connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit())); 91 QObject::connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit()));
89#endif 92#endif
90 if ( argc > 1 ) { 93 if ( argc > 1 ) {
91 QCString command = argv[1]; 94 QCString command = argv[1];
92 if ( argc > 2 ) 95 if ( argc > 2 )
93 command += argv[2]; 96 command += argv[2];
94 qApp->processEvents(); 97 qApp->processEvents();
95 m.recieve(command, QByteArray() ); 98 m.recieve(command, QByteArray() );
96 99
97 } 100 }
98 a.exec(); 101 a.exec();
102#ifndef DESKTOP_VERSION
103 delete c1;
104#endif
99 105
100 } 106 }
101 qDebug("KO: Bye! "); 107 qDebug("KO: Bye! ");
102} 108}
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index 2d17986..3c16458 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -1,1835 +1,1831 @@
1#include <stdlib.h> 1#include <stdlib.h>
2 2
3#include <qaction.h> 3#include <qaction.h>
4#include <qpopupmenu.h> 4#include <qpopupmenu.h>
5#include <qpainter.h> 5#include <qpainter.h>
6#include <qwhatsthis.h> 6#include <qwhatsthis.h>
7#include <qpushbutton.h> 7#include <qpushbutton.h>
8#include <qmessagebox.h> 8#include <qmessagebox.h>
9#include <qlineedit.h> 9#include <qlineedit.h>
10#include <qtextcodec.h> 10#include <qtextcodec.h>
11#include <qfile.h> 11#include <qfile.h>
12#include <qdir.h> 12#include <qdir.h>
13#include <qapp.h> 13#include <qapp.h>
14#include <qfileinfo.h> 14#include <qfileinfo.h>
15#include <qlabel.h> 15#include <qlabel.h>
16#include <qspinbox.h> 16#include <qspinbox.h>
17#include <qcheckbox.h> 17#include <qcheckbox.h>
18#include <qmap.h> 18#include <qmap.h>
19#include <qwmatrix.h> 19#include <qwmatrix.h>
20#include <qtextbrowser.h> 20#include <qtextbrowser.h>
21#include <qtextstream.h> 21#include <qtextstream.h>
22#ifndef DESKTOP_VERSION 22#ifndef DESKTOP_VERSION
23#include <qpe/global.h> 23#include <qpe/global.h>
24#include <qpe/qpemenubar.h> 24#include <qpe/qpemenubar.h>
25#include <qpe/qpetoolbar.h> 25#include <qpe/qpetoolbar.h>
26#include <qpe/resource.h> 26#include <qpe/resource.h>
27#include <qpe/qpeapplication.h> 27#include <qpe/qpeapplication.h>
28#include <qtopia/alarmserver.h> 28#include <qtopia/alarmserver.h>
29#include <qtopia/qcopenvelope_qws.h> 29#include <qtopia/qcopenvelope_qws.h>
30#include <unistd.h> // for sleep 30#include <unistd.h> // for sleep
31#else 31#else
32#include <qmenubar.h> 32#include <qmenubar.h>
33#include <qtoolbar.h> 33#include <qtoolbar.h>
34#include <qapplication.h> 34#include <qapplication.h>
35//#include <resource.h> 35//#include <resource.h>
36 36
37#endif 37#endif
38#include <libkcal/calendarlocal.h> 38#include <libkcal/calendarlocal.h>
39#include <libkcal/todo.h> 39#include <libkcal/todo.h>
40#include <libkcal/phoneformat.h> 40#include <libkcal/phoneformat.h>
41#include <libkdepim/ksyncprofile.h> 41#include <libkdepim/ksyncprofile.h>
42#include <libkdepim/phoneaccess.h> 42#include <libkdepim/phoneaccess.h>
43#include <libkcal/kincidenceformatter.h> 43#include <libkcal/kincidenceformatter.h>
44#include <libkdepim/kpimglobalprefs.h> 44#include <libkdepim/kpimglobalprefs.h>
45 45
46#include "calendarview.h" 46#include "calendarview.h"
47#include "koviewmanager.h" 47#include "koviewmanager.h"
48#include "datenavigator.h" 48#include "datenavigator.h"
49#include "koagendaview.h" 49#include "koagendaview.h"
50#include "koagenda.h" 50#include "koagenda.h"
51#include "kodialogmanager.h" 51#include "kodialogmanager.h"
52#include "kdialogbase.h" 52#include "kdialogbase.h"
53#include "kapplication.h" 53#include "kapplication.h"
54#include "kofilterview.h" 54#include "kofilterview.h"
55#include "kstandarddirs.h" 55#include "kstandarddirs.h"
56#include "koprefs.h" 56#include "koprefs.h"
57#include "kfiledialog.h" 57#include "kfiledialog.h"
58#include "koglobals.h" 58#include "koglobals.h"
59#include "kglobal.h" 59#include "kglobal.h"
60#include "klocale.h" 60#include "klocale.h"
61#include "kconfig.h" 61#include "kconfig.h"
62#include "simplealarmclient.h" 62#include "simplealarmclient.h"
63#include "externalapphandler.h" 63#include "externalapphandler.h"
64 64
65using namespace KCal; 65using namespace KCal;
66#ifndef _WIN32_ 66#ifndef _WIN32_
67#include <unistd.h> 67#include <unistd.h>
68#else 68#else
69#include "koimportoldialog.h" 69#include "koimportoldialog.h"
70#endif 70#endif
71#include "mainwindow.h" 71#include "mainwindow.h"
72 72
73class KOex2phonePrefs : public QDialog 73class KOex2phonePrefs : public QDialog
74{ 74{
75 public: 75 public:
76 KOex2phonePrefs( QWidget *parent=0, const char *name=0 ) : 76 KOex2phonePrefs( QWidget *parent=0, const char *name=0 ) :
77 QDialog( parent, name, true ) 77 QDialog( parent, name, true )
78 { 78 {
79 setCaption( i18n("Export to phone options") ); 79 setCaption( i18n("Export to phone options") );
80 QVBoxLayout* lay = new QVBoxLayout( this ); 80 QVBoxLayout* lay = new QVBoxLayout( this );
81 lay->setSpacing( 3 ); 81 lay->setSpacing( 3 );
82 lay->setMargin( 3 ); 82 lay->setMargin( 3 );
83 QLabel *lab; 83 QLabel *lab;
84 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); 84 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) );
85 lab->setAlignment (AlignHCenter ); 85 lab->setAlignment (AlignHCenter );
86 QHBox* temphb; 86 QHBox* temphb;
87 temphb = new QHBox( this ); 87 temphb = new QHBox( this );
88 new QLabel( i18n("I/O device: "), temphb ); 88 new QLabel( i18n("I/O device: "), temphb );
89 mPhoneDevice = new QLineEdit( temphb); 89 mPhoneDevice = new QLineEdit( temphb);
90 lay->addWidget( temphb ); 90 lay->addWidget( temphb );
91 temphb = new QHBox( this ); 91 temphb = new QHBox( this );
92 new QLabel( i18n("Connection: "), temphb ); 92 new QLabel( i18n("Connection: "), temphb );
93 mPhoneConnection = new QLineEdit( temphb); 93 mPhoneConnection = new QLineEdit( temphb);
94 lay->addWidget( temphb ); 94 lay->addWidget( temphb );
95 temphb = new QHBox( this ); 95 temphb = new QHBox( this );
96 new QLabel( i18n("Model(opt.): "), temphb ); 96 new QLabel( i18n("Model(opt.): "), temphb );
97 mPhoneModel = new QLineEdit( temphb); 97 mPhoneModel = new QLineEdit( temphb);
98 lay->addWidget( temphb ); 98 lay->addWidget( temphb );
99 mWriteBackFuture= new QCheckBox( i18n("Write back events in future only"), this ); 99 mWriteBackFuture= new QCheckBox( i18n("Write back events in future only"), this );
100 mWriteBackFuture->setChecked( true ); 100 mWriteBackFuture->setChecked( true );
101 lay->addWidget( mWriteBackFuture ); 101 lay->addWidget( mWriteBackFuture );
102 temphb = new QHBox( this ); 102 temphb = new QHBox( this );
103 new QLabel( i18n("Max. weeks in future: ") , temphb ); 103 new QLabel( i18n("Max. weeks in future: ") , temphb );
104 mWriteBackFutureWeeks= new QSpinBox(1,104, 1, temphb); 104 mWriteBackFutureWeeks= new QSpinBox(1,104, 1, temphb);
105 mWriteBackFutureWeeks->setValue( 8 ); 105 mWriteBackFutureWeeks->setValue( 8 );
106 lay->addWidget( temphb ); 106 lay->addWidget( temphb );
107 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ntodo/calendar data on phone!"), this ) ); 107 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ntodo/calendar data on phone!"), this ) );
108 lab->setAlignment (AlignHCenter ); 108 lab->setAlignment (AlignHCenter );
109 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); 109 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this );
110 lay->addWidget( ok ); 110 lay->addWidget( ok );
111 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 111 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
112 lay->addWidget( cancel ); 112 lay->addWidget( cancel );
113 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 113 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
114 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 114 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
115 resize( 220, 240 ); 115 resize( 220, 240 );
116 116
117 } 117 }
118 118
119public: 119public:
120 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; 120 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel;
121 QCheckBox* mWriteBackFuture; 121 QCheckBox* mWriteBackFuture;
122 QSpinBox* mWriteBackFutureWeeks; 122 QSpinBox* mWriteBackFutureWeeks;
123}; 123};
124 124
125int globalFlagBlockStartup; 125int globalFlagBlockStartup;
126MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) : 126MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) :
127 QMainWindow( parent, name ) 127 QMainWindow( parent, name )
128{ 128{
129 129
130#ifdef DESKTOP_VERSION 130#ifdef DESKTOP_VERSION
131 setFont( QFont("Arial"), 14 ); 131 setFont( QFont("Arial"), 14 );
132#endif 132#endif
133 mServerSocket = 0;
134 mClosed = false; 133 mClosed = false;
135 //QString confFile = KStandardDirs::appDir() + "config/korganizerrc"; 134 //QString confFile = KStandardDirs::appDir() + "config/korganizerrc";
136 QString confFile = locateLocal("config","korganizerrc"); 135 QString confFile = locateLocal("config","korganizerrc");
137 QFileInfo finf ( confFile ); 136 QFileInfo finf ( confFile );
138 bool showWarning = !finf.exists(); 137 bool showWarning = !finf.exists();
139 setIcon(SmallIcon( "ko24" ) ); 138 setIcon(SmallIcon( "ko24" ) );
140 mBlockAtStartup = true; 139 mBlockAtStartup = true;
141 mFlagKeyPressed = false; 140 mFlagKeyPressed = false;
142 setCaption("KOrganizer/Pi"); 141 setCaption("KOrganizer/Pi");
143 KOPrefs *p = KOPrefs::instance(); 142 KOPrefs *p = KOPrefs::instance();
144 KPimGlobalPrefs::instance()->setGlobalConfig(); 143 KPimGlobalPrefs::instance()->setGlobalConfig();
145 if ( p->mHourSize > 18 ) 144 if ( p->mHourSize > 18 )
146 p->mHourSize = 18; 145 p->mHourSize = 18;
147 QMainWindow::ToolBarDock tbd; 146 QMainWindow::ToolBarDock tbd;
148 if ( p->mToolBarHor ) { 147 if ( p->mToolBarHor ) {
149 if ( p->mToolBarUp ) 148 if ( p->mToolBarUp )
150 tbd = Bottom; 149 tbd = Bottom;
151 else 150 else
152 tbd = Top; 151 tbd = Top;
153 } 152 }
154 else { 153 else {
155 if ( p->mToolBarUp ) 154 if ( p->mToolBarUp )
156 tbd = Right; 155 tbd = Right;
157 else 156 else
158 tbd = Left; 157 tbd = Left;
159 } 158 }
160 if ( KOPrefs::instance()->mUseAppColors ) 159 if ( KOPrefs::instance()->mUseAppColors )
161 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 160 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
162 globalFlagBlockStartup = 1; 161 globalFlagBlockStartup = 1;
163 iconToolBar = new QPEToolBar( this ); 162 iconToolBar = new QPEToolBar( this );
164 addToolBar (iconToolBar , tbd ); 163 addToolBar (iconToolBar , tbd );
165 mCalendarModifiedFlag = false; 164 mCalendarModifiedFlag = false;
166 165
167 QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this ); 166 QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this );
168 splash->setAlignment ( AlignCenter ); 167 splash->setAlignment ( AlignCenter );
169 setCentralWidget( splash ); 168 setCentralWidget( splash );
170#ifndef DESKTOP_VERSION 169#ifndef DESKTOP_VERSION
171 showMaximized(); 170 showMaximized();
172#endif 171#endif
173 //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ()); 172 //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ());
174 setDefaultPreferences(); 173 setDefaultPreferences();
175 mCalendar = new CalendarLocal(); 174 mCalendar = new CalendarLocal();
176 mView = new CalendarView( mCalendar, this,"mCalendar " ); 175 mView = new CalendarView( mCalendar, this,"mCalendar " );
177 mView->hide(); 176 mView->hide();
178 //mView->resize(splash->size() ); 177 //mView->resize(splash->size() );
179 initActions(); 178 initActions();
180 mSyncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)mView, KSyncManager::KOPI, KOPrefs::instance(), syncMenu); 179 mSyncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)mView, KSyncManager::KOPI, KOPrefs::instance(), syncMenu);
181 mSyncManager->setBlockSave(false); 180 mSyncManager->setBlockSave(false);
182 mView->setSyncManager(mSyncManager); 181 mView->setSyncManager(mSyncManager);
183#ifndef DESKTOP_VERSION 182#ifndef DESKTOP_VERSION
184 iconToolBar->show(); 183 iconToolBar->show();
185 qApp->processEvents(); 184 qApp->processEvents();
186#endif 185#endif
187 //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ()); 186 //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ());
188 int vh = height() ; 187 int vh = height() ;
189 int vw = width(); 188 int vw = width();
190 //qDebug("Toolbar hei %d ",iconToolBar->height() ); 189 //qDebug("Toolbar hei %d ",iconToolBar->height() );
191 if ( iconToolBar->orientation () == Qt:: Horizontal ) { 190 if ( iconToolBar->orientation () == Qt:: Horizontal ) {
192 vh -= iconToolBar->height(); 191 vh -= iconToolBar->height();
193 } else { 192 } else {
194 vw -= iconToolBar->height(); 193 vw -= iconToolBar->height();
195 } 194 }
196 //mView->setMaximumSize( splash->size() ); 195 //mView->setMaximumSize( splash->size() );
197 //mView->resize( splash->size() ); 196 //mView->resize( splash->size() );
198 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); 197 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
199 mView->readSettings(); 198 mView->readSettings();
200 bool newFile = false; 199 bool newFile = false;
201 if( !QFile::exists( defaultFileName() ) ) { 200 if( !QFile::exists( defaultFileName() ) ) {
202 QFileInfo finfo ( defaultFileName() ); 201 QFileInfo finfo ( defaultFileName() );
203 QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics"); 202 QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics");
204 qDebug("oldfile %s ", oldFile.latin1()); 203 qDebug("oldfile %s ", oldFile.latin1());
205 QString message = "You are starting KO/Pi for the\nfirst time after updating to a\nversion >= 1.9.1. The location of the\ndefault calendar file has changed.\nA mycalendar.ics file was detected\nat the old location.\nThis file will be loaded now\nand stored at the new location!\n(Config file location has changed, too!)\nPlease read menu Help-What's New!\n"; 204 QString message = "You are starting KO/Pi for the\nfirst time after updating to a\nversion >= 1.9.1. The location of the\ndefault calendar file has changed.\nA mycalendar.ics file was detected\nat the old location.\nThis file will be loaded now\nand stored at the new location!\n(Config file location has changed, too!)\nPlease read menu Help-What's New!\n";
206 finfo.setFile( oldFile ); 205 finfo.setFile( oldFile );
207 if (finfo.exists() ) { 206 if (finfo.exists() ) {
208 KMessageBox::information( this, message); 207 KMessageBox::information( this, message);
209 mView->openCalendar( oldFile ); 208 mView->openCalendar( oldFile );
210 qApp->processEvents(); 209 qApp->processEvents();
211 } else { 210 } else {
212 oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics"); 211 oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics");
213 finfo.setFile( oldFile ); 212 finfo.setFile( oldFile );
214 if (finfo.exists() ) { 213 if (finfo.exists() ) {
215 KMessageBox::information( this, message); 214 KMessageBox::information( this, message);
216 mView->openCalendar( oldFile ); 215 mView->openCalendar( oldFile );
217 qApp->processEvents(); 216 qApp->processEvents();
218 } 217 }
219 } 218 }
220 mView->saveCalendar( defaultFileName() ); 219 mView->saveCalendar( defaultFileName() );
221 newFile = true; 220 newFile = true;
222 } 221 }
223 222
224 QTime neededSaveTime = QDateTime::currentDateTime().time(); 223 QTime neededSaveTime = QDateTime::currentDateTime().time();
225 mView->openCalendar( defaultFileName() ); 224 mView->openCalendar( defaultFileName() );
226 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 225 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
227 qDebug("KO: Calendar loading time: %d ms",msNeeded ); 226 qDebug("KO: Calendar loading time: %d ms",msNeeded );
228 227
229 if ( KOPrefs::instance()->mLanguageChanged ) { 228 if ( KOPrefs::instance()->mLanguageChanged ) {
230 KOPrefs::instance()->setCategoryDefaults(); 229 KOPrefs::instance()->setCategoryDefaults();
231 int count = mView->addCategories(); 230 int count = mView->addCategories();
232 KOPrefs::instance()->mLanguageChanged = false; 231 KOPrefs::instance()->mLanguageChanged = false;
233 } 232 }
234 processIncidenceSelection( 0 ); 233 processIncidenceSelection( 0 );
235 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ), 234 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ),
236 SLOT( processIncidenceSelection( Incidence * ) ) ); 235 SLOT( processIncidenceSelection( Incidence * ) ) );
237 connect( mView, SIGNAL( modifiedChanged( bool ) ), 236 connect( mView, SIGNAL( modifiedChanged( bool ) ),
238 SLOT( slotModifiedChanged( bool ) ) ); 237 SLOT( slotModifiedChanged( bool ) ) );
239 238
240 239
241 connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) ); 240 connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) );
242 mView->setModified( false ); 241 mView->setModified( false );
243 mBlockAtStartup = false; 242 mBlockAtStartup = false;
244 mView->setModified( false ); 243 mView->setModified( false );
245 setCentralWidget( mView ); 244 setCentralWidget( mView );
246 globalFlagBlockStartup = 0; 245 globalFlagBlockStartup = 0;
247 mView->show(); 246 mView->show();
248 delete splash; 247 delete splash;
249 if ( newFile ) 248 if ( newFile )
250 mView->updateConfig(); 249 mView->updateConfig();
251 // qApp->processEvents(); 250 // qApp->processEvents();
252 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); 251 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
253 //fillSyncMenu(); 252 //fillSyncMenu();
254 253
255 254
256 connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) ); 255 connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) );
257 connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); 256 connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) );
258 connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); 257 connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) );
259 mSyncManager->setDefaultFileName( defaultFileName()); 258 mSyncManager->setDefaultFileName( defaultFileName());
260 connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) ); 259 connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) );
261 mSyncManager->fillSyncMenu(); 260 mSyncManager->fillSyncMenu();
262 261
263 262
264 263
265 mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins ); 264 mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins );
266 if ( showWarning ) { 265 if ( showWarning ) {
267 KMessageBox::information( this, 266 KMessageBox::information( this,
268 "You are starting KO/Pi for the first time.\nPlease read menu: Help-What's New,\nif you did an update!\nPlease choose your timezone in the \nConfigure Dialog TAB Time Zone!\nPlease choose your language\nin the TAB Locale!\nYou get the Configure Dialog\nvia Menu: Actions - Configure....\nClick OK to show the Configure Dialog!\n", "KO/Pi information"); 267 "You are starting KO/Pi for the first time.\nPlease read menu: Help-What's New,\nif you did an update!\nPlease choose your timezone in the \nConfigure Dialog TAB Time Zone!\nPlease choose your language\nin the TAB Locale!\nYou get the Configure Dialog\nvia Menu: Actions - Configure....\nClick OK to show the Configure Dialog!\n", "KO/Pi information");
269 qApp->processEvents(); 268 qApp->processEvents();
270 mView->dialogManager()->showSyncOptions(); 269 mView->dialogManager()->showSyncOptions();
271 } 270 }
272 271
273 //US listen for result adressed from Ka/Pi 272 //US listen for result adressed from Ka/Pi
274#ifndef DESKTOP_VERSION 273#ifndef DESKTOP_VERSION
275 connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); 274 connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & )));
276#endif 275#endif
277} 276}
278MainWindow::~MainWindow() 277MainWindow::~MainWindow()
279{ 278{
280 //qDebug("MainWindow::~MainWindow() "); 279 //qDebug("MainWindow::~MainWindow() ");
281 //save toolbar location 280 //save toolbar location
282 delete mServerSocket;
283 delete mCalendar; 281 delete mCalendar;
284 delete KOPrefs::instance(); 282 delete mSyncManager;
285 delete KIncidenceFormatter::instance();
286 283
287 284
288} 285}
289void MainWindow::showMaximized () 286void MainWindow::showMaximized ()
290{ 287{
291#ifndef DESKTOP_VERSION 288#ifndef DESKTOP_VERSION
292 if ( ! globalFlagBlockStartup ) 289 if ( ! globalFlagBlockStartup )
293 if ( mClosed ) 290 if ( mClosed )
294 mView->goToday(); 291 mView->goToday();
295#endif 292#endif
296 QWidget::showMaximized () ; 293 QWidget::showMaximized () ;
297 mClosed = false; 294 mClosed = false;
298} 295}
299void MainWindow::closeEvent( QCloseEvent* ce ) 296void MainWindow::closeEvent( QCloseEvent* ce )
300{ 297{
301 298
302 299
303 300
304 if ( ! KOPrefs::instance()->mAskForQuit ) { 301 if ( ! KOPrefs::instance()->mAskForQuit ) {
305 saveOnClose(); 302 saveOnClose();
306 mClosed = true; 303 mClosed = true;
307 ce->accept(); 304 ce->accept();
308 return; 305 return;
309 306
310 } 307 }
311 308
312 switch( QMessageBox::information( this, "KO/Pi", 309 switch( QMessageBox::information( this, "KO/Pi",
313 i18n("Do you really want\nto close KO/Pi?"), 310 i18n("Do you really want\nto close KO/Pi?"),
314 i18n("Close"), i18n("No"), 311 i18n("Close"), i18n("No"),
315 0, 0 ) ) { 312 0, 0 ) ) {
316 case 0: 313 case 0:
317 saveOnClose(); 314 saveOnClose();
318 mClosed = true; 315 mClosed = true;
319 ce->accept(); 316 ce->accept();
320 break; 317 break;
321 case 1: 318 case 1:
322 ce->ignore(); 319 ce->ignore();
323 break; 320 break;
324 case 2: 321 case 2:
325 322
326 default: 323 default:
327 break; 324 break;
328 } 325 }
329 326
330 327
331} 328}
332 329
333void MainWindow::recieve( const QCString& cmsg, const QByteArray& data ) 330void MainWindow::recieve( const QCString& cmsg, const QByteArray& data )
334{ 331{
335 QDataStream stream( data, IO_ReadOnly ); 332 QDataStream stream( data, IO_ReadOnly );
336 // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" ); 333 // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" );
337 //QString datamess; 334 //QString datamess;
338 //qDebug("message "); 335 //qDebug("message ");
339 qDebug("KO: QCOP message received: %s ", cmsg.data() ); 336 qDebug("KO: QCOP message received: %s ", cmsg.data() );
340 337
341 if ( cmsg == "-writeFile" ) { 338 if ( cmsg == "-writeFile" ) {
342 // I made from the "-writeFile" an "-writeAlarm" 339 // I made from the "-writeFile" an "-writeAlarm"
343 mView->viewManager()->showWhatsNextView(); 340 mView->viewManager()->showWhatsNextView();
344 mCalendar->checkAlarmForIncidence( 0, true); 341 mCalendar->checkAlarmForIncidence( 0, true);
345 showMaximized(); 342 showMaximized();
346 raise(); 343 raise();
347 return; 344 return;
348 } 345 }
349 346
350 if ( cmsg == "-writeFile" ) { 347 if ( cmsg == "-writeFile" ) {
351 // I made from the "-writeFile" an "-writeAlarm" 348 // I made from the "-writeFile" an "-writeAlarm"
352 mView->viewManager()->showWhatsNextView(); 349 mView->viewManager()->showWhatsNextView();
353 mCalendar->checkAlarmForIncidence( 0, true); 350 mCalendar->checkAlarmForIncidence( 0, true);
354 showMaximized(); 351 showMaximized();
355 raise(); 352 raise();
356 return; 353 return;
357 354
358 } 355 }
359 if ( cmsg == "-writeFileSilent" ) { 356 if ( cmsg == "-writeFileSilent" ) {
360 // I made from the "-writeFile" an "-writeAlarm" 357 // I made from the "-writeFile" an "-writeAlarm"
361 // mView->viewManager()->showWhatsNextView(); 358 // mView->viewManager()->showWhatsNextView();
362 mCalendar->checkAlarmForIncidence( 0, true); 359 mCalendar->checkAlarmForIncidence( 0, true);
363 //showMaximized(); 360 //showMaximized();
364 //raise(); 361 //raise();
365 hide(); 362 hide();
366 return; 363 return;
367 } 364 }
368 if ( cmsg == "-newCountdown" ) { 365 if ( cmsg == "-newCountdown" ) {
369 qDebug("newCountdown "); 366 qDebug("newCountdown ");
370 367
371 } 368 }
372 QString msg ; 369 QString msg ;
373 QString allmsg = cmsg; 370 QString allmsg = cmsg;
374 while ( allmsg.length() > 0 ) { 371 while ( allmsg.length() > 0 ) {
375 int nextC = allmsg.find( "-", 1 ); 372 int nextC = allmsg.find( "-", 1 );
376 if ( nextC == -1 ) { 373 if ( nextC == -1 ) {
377 msg = allmsg; 374 msg = allmsg;
378 allmsg = ""; 375 allmsg = "";
379 } else{ 376 } else{
380 msg = allmsg.left( nextC ); 377 msg = allmsg.left( nextC );
381 allmsg = allmsg.mid( nextC, allmsg.length()-nextC ); 378 allmsg = allmsg.mid( nextC, allmsg.length()-nextC );
382 } 379 }
383 //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() ); 380 //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() );
384 if ( msg == "-newEvent" ) { 381 if ( msg == "-newEvent" ) {
385 mView->newEvent(); 382 mView->newEvent();
386 } 383 }
387 if ( msg == "-newTodo" ) { 384 if ( msg == "-newTodo" ) {
388 mView->newTodo(); 385 mView->newTodo();
389 386
390 } 387 }
391 if ( msg == "-showWN" ) { 388 if ( msg == "-showWN" ) {
392 mView->viewManager()->showWhatsNextView(); 389 mView->viewManager()->showWhatsNextView();
393 } 390 }
394 if ( msg == "-showTodo" ) { 391 if ( msg == "-showTodo" ) {
395 mView->viewManager()->showTodoView(); 392 mView->viewManager()->showTodoView();
396 } 393 }
397 if ( msg == "-showList" ) { 394 if ( msg == "-showList" ) {
398 mView->viewManager()->showListView(); 395 mView->viewManager()->showListView();
399 } 396 }
400 else if ( msg == "-showDay" ) { 397 else if ( msg == "-showDay" ) {
401 mView->viewManager()->showDayView(); 398 mView->viewManager()->showDayView();
402 } 399 }
403 else if ( msg == "-showWWeek" ) { 400 else if ( msg == "-showWWeek" ) {
404 mView->viewManager()->showWorkWeekView(); 401 mView->viewManager()->showWorkWeekView();
405 } 402 }
406 else if ( msg == "-ringSync" ) { 403 else if ( msg == "-ringSync" ) {
407 mSyncManager->multiSync( false ); 404 mSyncManager->multiSync( false );
408 } 405 }
409 else if ( msg == "-showWeek" ) { 406 else if ( msg == "-showWeek" ) {
410 mView->viewManager()->showWeekView(); 407 mView->viewManager()->showWeekView();
411 } 408 }
412 else if ( msg == "-showTodo" ) { 409 else if ( msg == "-showTodo" ) {
413 mView->viewManager()->showTodoView(); 410 mView->viewManager()->showTodoView();
414 } 411 }
415 else if ( msg == "-showJournal" ) { 412 else if ( msg == "-showJournal" ) {
416 mView->dateNavigator()->selectDates( 1 ); 413 mView->dateNavigator()->selectDates( 1 );
417 mView->dateNavigator()->selectToday(); 414 mView->dateNavigator()->selectToday();
418 mView->viewManager()->showJournalView(); 415 mView->viewManager()->showJournalView();
419 } 416 }
420 else if ( msg == "-showKO" ) { 417 else if ( msg == "-showKO" ) {
421 mView->viewManager()->showNextXView(); 418 mView->viewManager()->showNextXView();
422 } 419 }
423 else if ( msg == "-showWNext" || msg == "nextView()" ) { 420 else if ( msg == "-showWNext" || msg == "nextView()" ) {
424 mView->viewManager()->showWhatsNextView(); 421 mView->viewManager()->showWhatsNextView();
425 } 422 }
426 else if ( msg == "-showNextXView" ) { 423 else if ( msg == "-showNextXView" ) {
427 mView->viewManager()->showNextXView(); 424 mView->viewManager()->showNextXView();
428 } 425 }
429 426
430 427
431 } 428 }
432 429
433 showMaximized(); 430 showMaximized();
434 raise(); 431 raise();
435} 432}
436 433
437QPixmap MainWindow::loadPixmap( QString name ) 434QPixmap MainWindow::loadPixmap( QString name )
438{ 435{
439 return SmallIcon( name ); 436 return SmallIcon( name );
440 437
441} 438}
442void MainWindow::initActions() 439void MainWindow::initActions()
443{ 440{
444 //KOPrefs::instance()->mShowFullMenu 441 //KOPrefs::instance()->mShowFullMenu
445 iconToolBar->clear(); 442 iconToolBar->clear();
446 KOPrefs *p = KOPrefs::instance(); 443 KOPrefs *p = KOPrefs::instance();
447 //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar ); 444 //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar );
448 445
449 QPopupMenu *viewMenu = new QPopupMenu( this ); 446 QPopupMenu *viewMenu = new QPopupMenu( this );
450 QPopupMenu *actionMenu = new QPopupMenu( this ); 447 QPopupMenu *actionMenu = new QPopupMenu( this );
451 QPopupMenu *importMenu = new QPopupMenu( this ); 448 QPopupMenu *importMenu = new QPopupMenu( this );
452 selectFilterMenu = new QPopupMenu( this ); 449 selectFilterMenu = new QPopupMenu( this );
453 selectFilterMenu->setCheckable( true ); 450 selectFilterMenu->setCheckable( true );
454 syncMenu = new QPopupMenu( this ); 451 syncMenu = new QPopupMenu( this );
455 configureAgendaMenu = new QPopupMenu( this ); 452 configureAgendaMenu = new QPopupMenu( this );
456 configureToolBarMenu = new QPopupMenu( this ); 453 configureToolBarMenu = new QPopupMenu( this );
457 QPopupMenu *helpMenu = new QPopupMenu( this ); 454 QPopupMenu *helpMenu = new QPopupMenu( this );
458 if ( KOPrefs::instance()->mShowFullMenu ) { 455 if ( KOPrefs::instance()->mShowFullMenu ) {
459 QMenuBar *menuBar1; 456 QMenuBar *menuBar1;
460 menuBar1 = menuBar(); 457 menuBar1 = menuBar();
461 menuBar1->insertItem( i18n("File"), importMenu ); 458 menuBar1->insertItem( i18n("File"), importMenu );
462 menuBar1->insertItem( i18n("View"), viewMenu ); 459 menuBar1->insertItem( i18n("View"), viewMenu );
463 menuBar1->insertItem( i18n("Actions"), actionMenu ); 460 menuBar1->insertItem( i18n("Actions"), actionMenu );
464 menuBar1->insertItem( i18n("Synchronize"), syncMenu ); 461 menuBar1->insertItem( i18n("Synchronize"), syncMenu );
465 menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu ); 462 menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu );
466 //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu ); 463 //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu );
467 menuBar1->insertItem( i18n("Filter"),selectFilterMenu ); 464 menuBar1->insertItem( i18n("Filter"),selectFilterMenu );
468 menuBar1->insertItem( i18n("Help"), helpMenu ); 465 menuBar1->insertItem( i18n("Help"), helpMenu );
469 } else { 466 } else {
470 QPEMenuBar *menuBar1; 467 QPEMenuBar *menuBar1;
471 menuBar1 = new QPEMenuBar( iconToolBar ); 468 menuBar1 = new QPEMenuBar( iconToolBar );
472 QPopupMenu *menuBar = new QPopupMenu( this ); 469 QPopupMenu *menuBar = new QPopupMenu( this );
473 menuBar1->insertItem( i18n("ME"), menuBar); 470 menuBar1->insertItem( i18n("ME"), menuBar);
474 menuBar->insertItem( i18n("File"), importMenu ); 471 menuBar->insertItem( i18n("File"), importMenu );
475 menuBar->insertItem( i18n("View"), viewMenu ); 472 menuBar->insertItem( i18n("View"), viewMenu );
476 menuBar->insertItem( i18n("Actions"), actionMenu ); 473 menuBar->insertItem( i18n("Actions"), actionMenu );
477 menuBar->insertItem( i18n("Synchronize"), syncMenu ); 474 menuBar->insertItem( i18n("Synchronize"), syncMenu );
478 menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu ); 475 menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu );
479 menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu ); 476 menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu );
480 menuBar->insertItem( i18n("Filter"),selectFilterMenu ); 477 menuBar->insertItem( i18n("Filter"),selectFilterMenu );
481 menuBar->insertItem( i18n("Help"), helpMenu ); 478 menuBar->insertItem( i18n("Help"), helpMenu );
482 //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() ); 479 //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() );
483 menuBar1->setMaximumSize( menuBar1->sizeHint( )); 480 menuBar1->setMaximumSize( menuBar1->sizeHint( ));
484 } 481 }
485 connect ( syncMenu, SIGNAL( activated ( int ) ), this, SLOT (slotSyncMenu( int ) ) );
486 connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); 482 connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) );
487 connect ( selectFilterMenu, SIGNAL( aboutToShow () ), this, SLOT (fillFilterMenu() ) ); 483 connect ( selectFilterMenu, SIGNAL( aboutToShow () ), this, SLOT (fillFilterMenu() ) );
488 484
489 // ****************** 485 // ******************
490 QAction *action; 486 QAction *action;
491 QIconSet icon; 487 QIconSet icon;
492 // QPopupMenu *configureMenu= new QPopupMenu( menuBar ); 488 // QPopupMenu *configureMenu= new QPopupMenu( menuBar );
493 configureToolBarMenu->setCheckable( true ); 489 configureToolBarMenu->setCheckable( true );
494 490
495 QString pathString = ""; 491 QString pathString = "";
496 if ( !p->mToolBarMiniIcons ) { 492 if ( !p->mToolBarMiniIcons ) {
497 if ( QApplication::desktop()->width() < 480 ) 493 if ( QApplication::desktop()->width() < 480 )
498 pathString += "icons16/"; 494 pathString += "icons16/";
499 } else 495 } else
500 pathString += "iconsmini/"; 496 pathString += "iconsmini/";
501 configureAgendaMenu->setCheckable( true ); 497 configureAgendaMenu->setCheckable( true );
502 configureAgendaMenu->insertItem(i18n("Toggle Allday"), 1 ); 498 configureAgendaMenu->insertItem(i18n("Toggle Allday"), 1 );
503 configureAgendaMenu->insertSeparator(); 499 configureAgendaMenu->insertSeparator();
504 configureAgendaMenu->insertItem(i18n("Tiny"), 4 ); 500 configureAgendaMenu->insertItem(i18n("Tiny"), 4 );
505 configureAgendaMenu->insertItem(i18n("Small"), 6 ); 501 configureAgendaMenu->insertItem(i18n("Small"), 6 );
506 configureAgendaMenu->insertItem(i18n("Medium"), 8 ); 502 configureAgendaMenu->insertItem(i18n("Medium"), 8 );
507 configureAgendaMenu->insertItem(i18n("Normal"), 10 ); 503 configureAgendaMenu->insertItem(i18n("Normal"), 10 );
508 configureAgendaMenu->insertItem(i18n("Large"), 12 ); 504 configureAgendaMenu->insertItem(i18n("Large"), 12 );
509 configureAgendaMenu->insertItem(i18n("Big"), 14 ); 505 configureAgendaMenu->insertItem(i18n("Big"), 14 );
510 configureAgendaMenu->insertItem(i18n("Bigger"), 16 ); 506 configureAgendaMenu->insertItem(i18n("Bigger"), 16 );
511 configureAgendaMenu->insertItem(i18n("Biggest"), 18 ); 507 configureAgendaMenu->insertItem(i18n("Biggest"), 18 );
512 //configureMenu->insertItem( "AgendaSize",configureAgendaMenu ); 508 //configureMenu->insertItem( "AgendaSize",configureAgendaMenu );
513 509
514 icon = loadPixmap( pathString + "configure" ); 510 icon = loadPixmap( pathString + "configure" );
515 action = new QAction( i18n("Configure"),icon, i18n("Configure..."), 0, this ); 511 action = new QAction( i18n("Configure"),icon, i18n("Configure..."), 0, this );
516 action->addTo( actionMenu ); 512 action->addTo( actionMenu );
517 connect( action, SIGNAL( activated() ), 513 connect( action, SIGNAL( activated() ),
518 mView, SLOT( edit_options() ) ); 514 mView, SLOT( edit_options() ) );
519 actionMenu->insertSeparator(); 515 actionMenu->insertSeparator();
520 icon = loadPixmap( pathString + "newevent" ); 516 icon = loadPixmap( pathString + "newevent" );
521 configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 ); 517 configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 );
522 configureToolBarMenu->insertSeparator(); 518 configureToolBarMenu->insertSeparator();
523 configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 ); 519 configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 );
524 QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this ); 520 QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this );
525 ne_action->addTo( actionMenu ); 521 ne_action->addTo( actionMenu );
526 connect( ne_action, SIGNAL( activated() ), 522 connect( ne_action, SIGNAL( activated() ),
527 mView, SLOT( newEvent() ) ); 523 mView, SLOT( newEvent() ) );
528 icon = loadPixmap( pathString + "newtodo" ); 524 icon = loadPixmap( pathString + "newtodo" );
529 configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 ); 525 configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 );
530 QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this ); 526 QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this );
531 nt_action->addTo( actionMenu ); 527 nt_action->addTo( actionMenu );
532 connect( nt_action, SIGNAL( activated() ), 528 connect( nt_action, SIGNAL( activated() ),
533 mView, SLOT( newTodo() ) ); 529 mView, SLOT( newTodo() ) );
534 icon = loadPixmap( pathString + "navi" ); 530 icon = loadPixmap( pathString + "navi" );
535 action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this ); 531 action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this );
536 action->addTo( viewMenu ); 532 action->addTo( viewMenu );
537 connect( action, SIGNAL( activated() ), 533 connect( action, SIGNAL( activated() ),
538 mView, SLOT( toggleDateNavigatorWidget() ) ); 534 mView, SLOT( toggleDateNavigatorWidget() ) );
539 icon = loadPixmap( pathString + "filter" ); 535 icon = loadPixmap( pathString + "filter" );
540 action = new QAction( i18n("Toggle FilterView"), icon, i18n("Toggle FilterView"), 0, this ); 536 action = new QAction( i18n("Toggle FilterView"), icon, i18n("Toggle FilterView"), 0, this );
541 action->addTo( viewMenu ); 537 action->addTo( viewMenu );
542 connect( action, SIGNAL( activated() ), 538 connect( action, SIGNAL( activated() ),
543 mView, SLOT( toggleFilter() ) ); 539 mView, SLOT( toggleFilter() ) );
544 540
545 541
546 viewMenu->insertSeparator(); 542 viewMenu->insertSeparator();
547 icon = loadPixmap( pathString + "picker" ); 543 icon = loadPixmap( pathString + "picker" );
548 action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this ); 544 action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this );
549 action->addTo( viewMenu ); 545 action->addTo( viewMenu );
550 connect( action, SIGNAL( activated() ), 546 connect( action, SIGNAL( activated() ),
551 mView, SLOT( showDatePicker() ) ); 547 mView, SLOT( showDatePicker() ) );
552 action->addTo( iconToolBar ); 548 action->addTo( iconToolBar );
553 viewMenu->insertSeparator(); 549 viewMenu->insertSeparator();
554 icon = loadPixmap( pathString + "list" ); 550 icon = loadPixmap( pathString + "list" );
555 configureToolBarMenu->insertItem(icon, i18n("List View"), 30 ); 551 configureToolBarMenu->insertItem(icon, i18n("List View"), 30 );
556 QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this ); 552 QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this );
557 showlist_action->addTo( viewMenu ); 553 showlist_action->addTo( viewMenu );
558 connect( showlist_action, SIGNAL( activated() ), 554 connect( showlist_action, SIGNAL( activated() ),
559 mView->viewManager(), SLOT( showListView() ) ); 555 mView->viewManager(), SLOT( showListView() ) );
560 556
561 557
562 icon = loadPixmap( pathString + "day" ); 558 icon = loadPixmap( pathString + "day" );
563 configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 ); 559 configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 );
564 QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this ); 560 QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this );
565 day1_action->addTo( viewMenu ); 561 day1_action->addTo( viewMenu );
566 // action->addTo( toolBar ); 562 // action->addTo( toolBar );
567 connect( day1_action, SIGNAL( activated() ), 563 connect( day1_action, SIGNAL( activated() ),
568 mView->viewManager(), SLOT( showDayView() ) ); 564 mView->viewManager(), SLOT( showDayView() ) );
569 565
570 icon = loadPixmap( pathString + "workweek" ); 566 icon = loadPixmap( pathString + "workweek" );
571 configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 ); 567 configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 );
572 QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this ); 568 QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this );
573 day5_action->addTo( viewMenu ); 569 day5_action->addTo( viewMenu );
574 connect( day5_action, SIGNAL( activated() ), 570 connect( day5_action, SIGNAL( activated() ),
575 mView->viewManager(), SLOT( showWorkWeekView() ) ); 571 mView->viewManager(), SLOT( showWorkWeekView() ) );
576 572
577 icon = loadPixmap( pathString + "week" ); 573 icon = loadPixmap( pathString + "week" );
578 configureToolBarMenu->insertItem(icon, i18n("Week"), 60 ); 574 configureToolBarMenu->insertItem(icon, i18n("Week"), 60 );
579 QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this ); 575 QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this );
580 day7_action->addTo( viewMenu ); 576 day7_action->addTo( viewMenu );
581 connect( day7_action, SIGNAL( activated() ), 577 connect( day7_action, SIGNAL( activated() ),
582 mView->viewManager(), SLOT( showWeekView() ) ); 578 mView->viewManager(), SLOT( showWeekView() ) );
583 579
584 icon = loadPixmap( pathString + "month" ); 580 icon = loadPixmap( pathString + "month" );
585 configureToolBarMenu->insertItem(icon, i18n("Month"), 70 ); 581 configureToolBarMenu->insertItem(icon, i18n("Month"), 70 );
586 QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this ); 582 QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this );
587 month_action->addTo( viewMenu ); 583 month_action->addTo( viewMenu );
588 connect( month_action, SIGNAL( activated() ), 584 connect( month_action, SIGNAL( activated() ),
589 mView->viewManager(), SLOT( showMonthView() ) ); 585 mView->viewManager(), SLOT( showMonthView() ) );
590 586
591 icon = loadPixmap( pathString + "todo" ); 587 icon = loadPixmap( pathString + "todo" );
592 configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 ); 588 configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 );
593 QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this ); 589 QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this );
594 todoview_action->addTo( viewMenu ); 590 todoview_action->addTo( viewMenu );
595 connect( todoview_action, SIGNAL( activated() ), 591 connect( todoview_action, SIGNAL( activated() ),
596 mView->viewManager(), SLOT( showTodoView() ) ); 592 mView->viewManager(), SLOT( showTodoView() ) );
597 593
598 icon = loadPixmap( pathString + "journal" ); 594 icon = loadPixmap( pathString + "journal" );
599 configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 ); 595 configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 );
600 QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this ); 596 QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this );
601 viewjournal_action->addTo( viewMenu ); 597 viewjournal_action->addTo( viewMenu );
602 connect( viewjournal_action, SIGNAL( activated() ), 598 connect( viewjournal_action, SIGNAL( activated() ),
603 mView->viewManager(), SLOT( showJournalView() ) ); 599 mView->viewManager(), SLOT( showJournalView() ) );
604 600
605 icon = loadPixmap( pathString + "xdays" ); 601 icon = loadPixmap( pathString + "xdays" );
606 configureToolBarMenu->insertItem(icon, i18n("Next days"), 100,4 ); 602 configureToolBarMenu->insertItem(icon, i18n("Next days"), 100,4 );
607 QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this ); 603 QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this );
608 xdays_action->addTo( viewMenu ); 604 xdays_action->addTo( viewMenu );
609 connect( xdays_action, SIGNAL( activated() ), 605 connect( xdays_action, SIGNAL( activated() ),
610 mView->viewManager(), SLOT( showNextXView() ) ); 606 mView->viewManager(), SLOT( showNextXView() ) );
611 607
612 icon = loadPixmap( pathString + "whatsnext" ); 608 icon = loadPixmap( pathString + "whatsnext" );
613 configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110, 4 ); 609 configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110, 4 );
614 QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this ); 610 QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this );
615 whatsnext_action->addTo( viewMenu ); 611 whatsnext_action->addTo( viewMenu );
616 connect( whatsnext_action, SIGNAL( activated() ), 612 connect( whatsnext_action, SIGNAL( activated() ),
617 mView->viewManager(), SLOT( showWhatsNextView() ) ); 613 mView->viewManager(), SLOT( showWhatsNextView() ) );
618 614
619#if 0 615#if 0
620 action = new QAction( "view_timespan", "Time Span", 0, this ); 616 action = new QAction( "view_timespan", "Time Span", 0, this );
621 action->addTo( viewMenu ); 617 action->addTo( viewMenu );
622 connect( action, SIGNAL( activated() ), 618 connect( action, SIGNAL( activated() ),
623 mView->viewManager(), SLOT( showTimeSpanView() ) ); 619 mView->viewManager(), SLOT( showTimeSpanView() ) );
624#endif 620#endif
625 621
626 mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0, 622 mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0,
627 this ); 623 this );
628 mNewSubTodoAction->addTo( actionMenu ); 624 mNewSubTodoAction->addTo( actionMenu );
629 connect( mNewSubTodoAction, SIGNAL( activated() ), 625 connect( mNewSubTodoAction, SIGNAL( activated() ),
630 mView, SLOT( newSubTodo() ) ); 626 mView, SLOT( newSubTodo() ) );
631 627
632 actionMenu->insertSeparator(); 628 actionMenu->insertSeparator();
633 629
634 mShowAction = new QAction( "show_incidence", i18n("Show..."), 0, this ); 630 mShowAction = new QAction( "show_incidence", i18n("Show..."), 0, this );
635 mShowAction->addTo( actionMenu ); 631 mShowAction->addTo( actionMenu );
636 connect( mShowAction, SIGNAL( activated() ), 632 connect( mShowAction, SIGNAL( activated() ),
637 mView, SLOT( showIncidence() ) ); 633 mView, SLOT( showIncidence() ) );
638 634
639 mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this ); 635 mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this );
640 mEditAction->addTo( actionMenu ); 636 mEditAction->addTo( actionMenu );
641 connect( mEditAction, SIGNAL( activated() ), 637 connect( mEditAction, SIGNAL( activated() ),
642 mView, SLOT( editIncidence() ) ); 638 mView, SLOT( editIncidence() ) );
643 639
644 mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this ); 640 mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this );
645 mDeleteAction->addTo( actionMenu ); 641 mDeleteAction->addTo( actionMenu );
646 connect( mDeleteAction, SIGNAL( activated() ), 642 connect( mDeleteAction, SIGNAL( activated() ),
647 mView, SLOT( deleteIncidence() ) ); 643 mView, SLOT( deleteIncidence() ) );
648 644
649 645
650 mCloneAction = new QAction( "clone_incidence", i18n("Clone..."), 0, this ); 646 mCloneAction = new QAction( "clone_incidence", i18n("Clone..."), 0, this );
651 mCloneAction->addTo( actionMenu ); 647 mCloneAction->addTo( actionMenu );
652 connect( mCloneAction, SIGNAL( activated() ), 648 connect( mCloneAction, SIGNAL( activated() ),
653 mView, SLOT( cloneIncidence() ) ); 649 mView, SLOT( cloneIncidence() ) );
654 mMoveAction = new QAction( "Move_incidence", i18n("Move..."), 0, this ); 650 mMoveAction = new QAction( "Move_incidence", i18n("Move..."), 0, this );
655 mMoveAction->addTo( actionMenu ); 651 mMoveAction->addTo( actionMenu );
656 connect( mMoveAction, SIGNAL( activated() ), 652 connect( mMoveAction, SIGNAL( activated() ),
657 mView, SLOT( moveIncidence() ) ); 653 mView, SLOT( moveIncidence() ) );
658 mBeamAction = new QAction( "Beam_incidence", i18n("Beam..."), 0, this ); 654 mBeamAction = new QAction( "Beam_incidence", i18n("Beam..."), 0, this );
659 mBeamAction->addTo( actionMenu ); 655 mBeamAction->addTo( actionMenu );
660 connect( mBeamAction, SIGNAL( activated() ), 656 connect( mBeamAction, SIGNAL( activated() ),
661 mView, SLOT( beamIncidence() ) ); 657 mView, SLOT( beamIncidence() ) );
662 mCancelAction = new QAction( "Cancel_incidence", i18n("Toggle Cancel"), 0, this ); 658 mCancelAction = new QAction( "Cancel_incidence", i18n("Toggle Cancel"), 0, this );
663 mCancelAction->addTo( actionMenu ); 659 mCancelAction->addTo( actionMenu );
664 connect( mCancelAction, SIGNAL( activated() ), 660 connect( mCancelAction, SIGNAL( activated() ),
665 mView, SLOT( toggleCancelIncidence() ) ); 661 mView, SLOT( toggleCancelIncidence() ) );
666 662
667 actionMenu->insertSeparator(); 663 actionMenu->insertSeparator();
668 664
669 action = new QAction( "purge_completed", i18n("Purge Completed"), 0, 665 action = new QAction( "purge_completed", i18n("Purge Completed"), 0,
670 this ); 666 this );
671 action->addTo( actionMenu ); 667 action->addTo( actionMenu );
672 connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) ); 668 connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) );
673 669
674 icon = loadPixmap( pathString + "search" ); 670 icon = loadPixmap( pathString + "search" );
675 QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this ); 671 QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this );
676 configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 4); 672 configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 4);
677 search_action->addTo( actionMenu ); 673 search_action->addTo( actionMenu );
678 connect( search_action, SIGNAL( activated() ), 674 connect( search_action, SIGNAL( activated() ),
679 mView->dialogManager(), SLOT( showSearchDialog() ) ); 675 mView->dialogManager(), SLOT( showSearchDialog() ) );
680 676
681 icon = loadPixmap( pathString + "today" ); 677 icon = loadPixmap( pathString + "today" );
682 configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130); 678 configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130);
683 QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this ); 679 QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this );
684 today_action->addTo( actionMenu ); 680 today_action->addTo( actionMenu );
685 connect( today_action, SIGNAL( activated() ), 681 connect( today_action, SIGNAL( activated() ),
686 mView, SLOT( goToday() ) ); 682 mView, SLOT( goToday() ) );
687 683
688 if ( KOPrefs::instance()->mShowFullMenu ) { 684 if ( KOPrefs::instance()->mShowFullMenu ) {
689 actionMenu->insertSeparator(); 685 actionMenu->insertSeparator();
690 actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu ); 686 actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu );
691 687
692 } 688 }
693 // actionMenu->insertSeparator(); 689 // actionMenu->insertSeparator();
694 action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0, 690 action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0,
695 this ); 691 this );
696 action->addTo( importMenu ); 692 action->addTo( importMenu );
697 connect( action, SIGNAL( activated() ), SLOT( importIcal() ) ); 693 connect( action, SIGNAL( activated() ), SLOT( importIcal() ) );
698 action = new QAction( "import_quick", i18n("Import last file"), 0, 694 action = new QAction( "import_quick", i18n("Import last file"), 0,
699 this ); 695 this );
700 action->addTo( importMenu ); 696 action->addTo( importMenu );
701 connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) ); 697 connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) );
702 importMenu->insertSeparator(); 698 importMenu->insertSeparator();
703 action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0, 699 action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0,
704 this ); 700 this );
705 action->addTo( importMenu ); 701 action->addTo( importMenu );
706 connect( action, SIGNAL( activated() ), SLOT( importBday() ) ); 702 connect( action, SIGNAL( activated() ), SLOT( importBday() ) );
707#ifndef DESKTOP_VERSION 703#ifndef DESKTOP_VERSION
708 importMenu->insertSeparator(); 704 importMenu->insertSeparator();
709 action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0, 705 action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0,
710 this ); 706 this );
711 action->addTo( importMenu ); 707 action->addTo( importMenu );
712 connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) ); 708 connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) );
713#else 709#else
714#ifdef _WIN32_ 710#ifdef _WIN32_
715 importMenu->insertSeparator(); 711 importMenu->insertSeparator();
716 action = new QAction( "import_ol", i18n("Import from OL"), 0, 712 action = new QAction( "import_ol", i18n("Import from OL"), 0,
717 this ); 713 this );
718 action->addTo( importMenu ); 714 action->addTo( importMenu );
719 connect( action, SIGNAL( activated() ), SLOT( importOL() ) ); 715 connect( action, SIGNAL( activated() ), SLOT( importOL() ) );
720#endif 716#endif
721#endif 717#endif
722 718
723 importMenu->insertSeparator(); 719 importMenu->insertSeparator();
724 action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0, 720 action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0,
725 this ); 721 this );
726 action->addTo( importMenu ); 722 action->addTo( importMenu );
727 connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) ); 723 connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) );
728 724
729 action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0, 725 action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0,
730 this ); 726 this );
731 action->addTo( importMenu ); 727 action->addTo( importMenu );
732 connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) ); 728 connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) );
733 729
734 importMenu->insertSeparator(); 730 importMenu->insertSeparator();
735 action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0, 731 action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0,
736 this ); 732 this );
737 action->addTo( importMenu ); connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) ); 733 action->addTo( importMenu ); connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) );
738 734
739 735
740 //LR 736 //LR
741 QPopupMenu *ex2phone = new QPopupMenu( this ); 737 QPopupMenu *ex2phone = new QPopupMenu( this );
742 ex2phone->insertItem(i18n("Complete calendar..."), 1 ); 738 ex2phone->insertItem(i18n("Complete calendar..."), 1 );
743 ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); 739 ex2phone->insertItem(i18n("Filtered calendar..."), 2 );
744 connect( ex2phone, SIGNAL( activated(int) ), this, SLOT( exportToPhone( int)) ); 740 connect( ex2phone, SIGNAL( activated(int) ), this, SLOT( exportToPhone( int)) );
745 importMenu->insertItem( i18n("Export to phone"), ex2phone ); 741 importMenu->insertItem( i18n("Export to phone"), ex2phone );
746 742
747 importMenu->insertSeparator(); 743 importMenu->insertSeparator();
748 action = new QAction( "manage cat", i18n("Manage new categories..."), 0, 744 action = new QAction( "manage cat", i18n("Manage new categories..."), 0,
749 this ); 745 this );
750 action->addTo( importMenu ); 746 action->addTo( importMenu );
751 connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) ); 747 connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) );
752#ifndef DESKTOP_VERSION 748#ifndef DESKTOP_VERSION
753 importMenu->insertSeparator(); 749 importMenu->insertSeparator();
754 action = new QAction( "beam all", i18n("Beam complete calendar..."), 0, 750 action = new QAction( "beam all", i18n("Beam complete calendar..."), 0,
755 this ); 751 this );
756 action->addTo( importMenu ); 752 action->addTo( importMenu );
757 connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) ); 753 connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) );
758 754
759 action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0, 755 action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0,
760 this ); 756 this );
761 action->addTo( importMenu ); 757 action->addTo( importMenu );
762 connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) ); 758 connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) );
763#else 759#else
764 importMenu->insertSeparator(); 760 importMenu->insertSeparator();
765 icon = loadPixmap( pathString + "print" ); 761 icon = loadPixmap( pathString + "print" );
766 action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this ); 762 action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this );
767 action->addTo( importMenu ); 763 action->addTo( importMenu );
768 connect( action, SIGNAL( activated() ), 764 connect( action, SIGNAL( activated() ),
769 this, SLOT( printCal() ) ); 765 this, SLOT( printCal() ) );
770 766
771 icon = loadPixmap( pathString + "print" ); 767 icon = loadPixmap( pathString + "print" );
772 action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this ); 768 action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this );
773 action->addTo( importMenu ); 769 action->addTo( importMenu );
774 connect( action, SIGNAL( activated() ), 770 connect( action, SIGNAL( activated() ),
775 this, SLOT( printSel() ) ); 771 this, SLOT( printSel() ) );
776#endif 772#endif
777 importMenu->insertSeparator(); 773 importMenu->insertSeparator();
778 action = new QAction( "beam all", i18n("Save"), 0, 774 action = new QAction( "beam all", i18n("Save"), 0,
779 this ); 775 this );
780 action->addTo( importMenu ); 776 action->addTo( importMenu );
781 connect( action, SIGNAL( activated() ), this, SLOT( save() ) ); 777 connect( action, SIGNAL( activated() ), this, SLOT( save() ) );
782 action = new QAction( "beam all", i18n("Exit (+save)"), 0, 778 action = new QAction( "beam all", i18n("Exit (+save)"), 0,
783 this ); 779 this );
784 action->addTo( importMenu ); 780 action->addTo( importMenu );
785 connect( action, SIGNAL( activated() ), this, SLOT( close() ) ); 781 connect( action, SIGNAL( activated() ), this, SLOT( close() ) );
786 782
787 //menuBar->insertItem( "Configure",configureMenu ); 783 //menuBar->insertItem( "Configure",configureMenu );
788 //configureMenu->insertItem( "Toolbar",configureToolBarMenu ); 784 //configureMenu->insertItem( "Toolbar",configureToolBarMenu );
789 icon = loadPixmap( "korganizer/korganizer" ); 785 icon = loadPixmap( "korganizer/korganizer" );
790 action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this ); 786 action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this );
791 action->addTo( helpMenu ); 787 action->addTo( helpMenu );
792 connect( action, SIGNAL( activated() ), 788 connect( action, SIGNAL( activated() ),
793 SLOT( keyBindings() ) ); 789 SLOT( keyBindings() ) );
794 action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this ); 790 action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this );
795 action->addTo( helpMenu ); 791 action->addTo( helpMenu );
796 connect( action, SIGNAL( activated() ), 792 connect( action, SIGNAL( activated() ),
797 SLOT( features() ) ); 793 SLOT( features() ) );
798 action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this ); 794 action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this );
799 action->addTo( helpMenu ); 795 action->addTo( helpMenu );
800 connect( action, SIGNAL( activated() ), 796 connect( action, SIGNAL( activated() ),
801 SLOT( aboutAutoSaving() ) ); 797 SLOT( aboutAutoSaving() ) );
802 action = new QAction( "Problemd", i18n("Known Problems..."), 0,this ); 798 action = new QAction( "Problemd", i18n("Known Problems..."), 0,this );
803 action->addTo( helpMenu ); 799 action->addTo( helpMenu );
804 connect( action, SIGNAL( activated() ), 800 connect( action, SIGNAL( activated() ),
805 SLOT( aboutKnownBugs() ) ); 801 SLOT( aboutKnownBugs() ) );
806 action = new QAction( "Translate Howto", i18n("User translation..."), 0,this ); 802 action = new QAction( "Translate Howto", i18n("User translation..."), 0,this );
807 action->addTo( helpMenu ); 803 action->addTo( helpMenu );
808 connect( action, SIGNAL( activated() ), 804 connect( action, SIGNAL( activated() ),
809 SLOT( usertrans() ) ); 805 SLOT( usertrans() ) );
810 action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this ); 806 action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this );
811 action->addTo( helpMenu ); 807 action->addTo( helpMenu );
812 connect( action, SIGNAL( activated() ), 808 connect( action, SIGNAL( activated() ),
813 SLOT( synchowto() ) ); 809 SLOT( synchowto() ) );
814 action = new QAction( "Whats New", i18n("What's new?"), 0,this ); 810 action = new QAction( "Whats New", i18n("What's new?"), 0,this );
815 action->addTo( helpMenu ); 811 action->addTo( helpMenu );
816 connect( action, SIGNAL( activated() ), 812 connect( action, SIGNAL( activated() ),
817 SLOT( whatsNew() ) ); 813 SLOT( whatsNew() ) );
818 action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this ); 814 action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this );
819 action->addTo( helpMenu ); 815 action->addTo( helpMenu );
820 connect( action, SIGNAL( activated() ), 816 connect( action, SIGNAL( activated() ),
821 SLOT( faq() ) ); 817 SLOT( faq() ) );
822 818
823 819
824 action = new QAction( "about", i18n("About..."), 0, this ); 820 action = new QAction( "about", i18n("About..."), 0, this );
825 action->addTo( helpMenu ); 821 action->addTo( helpMenu );
826 connect( action, SIGNAL( activated() ), 822 connect( action, SIGNAL( activated() ),
827 SLOT( about() ) ); 823 SLOT( about() ) );
828 action = new QAction( "licence", i18n("Licence..."), 0, this ); 824 action = new QAction( "licence", i18n("Licence..."), 0, this );
829 action->addTo( helpMenu ); 825 action->addTo( helpMenu );
830 connect( action, SIGNAL( activated() ), 826 connect( action, SIGNAL( activated() ),
831 SLOT( licence() ) ); 827 SLOT( licence() ) );
832 //menuBar->insertSeparator(); 828 //menuBar->insertSeparator();
833 829
834 // ****************************************************** 830 // ******************************************************
835 // menubar icons 831 // menubar icons
836 832
837 833
838 iconToolBar->setHorizontalStretchable (true ); 834 iconToolBar->setHorizontalStretchable (true );
839 //menuBar->insertItem( iconToolBar ); 835 //menuBar->insertItem( iconToolBar );
840 //xdays_action 836 //xdays_action
841 if (p-> mShowIconNewEvent) 837 if (p-> mShowIconNewEvent)
842 ne_action->addTo( iconToolBar ); 838 ne_action->addTo( iconToolBar );
843 if (p->mShowIconNewTodo ) 839 if (p->mShowIconNewTodo )
844 nt_action->addTo( iconToolBar ); 840 nt_action->addTo( iconToolBar );
845 if (p-> mShowIconSearch) 841 if (p-> mShowIconSearch)
846 search_action->addTo( iconToolBar ); 842 search_action->addTo( iconToolBar );
847 if (p-> mShowIconNext) 843 if (p-> mShowIconNext)
848 whatsnext_action->addTo( iconToolBar ); 844 whatsnext_action->addTo( iconToolBar );
849 if (p-> mShowIconNextDays) 845 if (p-> mShowIconNextDays)
850 xdays_action->addTo( iconToolBar ); 846 xdays_action->addTo( iconToolBar );
851 if (p-> mShowIconList) 847 if (p-> mShowIconList)
852 showlist_action->addTo( iconToolBar ); 848 showlist_action->addTo( iconToolBar );
853 if (p-> mShowIconDay1) 849 if (p-> mShowIconDay1)
854 day1_action->addTo( iconToolBar ); 850 day1_action->addTo( iconToolBar );
855 if (p-> mShowIconDay5) 851 if (p-> mShowIconDay5)
856 day5_action->addTo( iconToolBar ); 852 day5_action->addTo( iconToolBar );
857 if (p-> mShowIconDay7) 853 if (p-> mShowIconDay7)
858 day7_action->addTo( iconToolBar ); 854 day7_action->addTo( iconToolBar );
859 if (p-> mShowIconMonth) 855 if (p-> mShowIconMonth)
860 month_action->addTo( iconToolBar ); 856 month_action->addTo( iconToolBar );
861 if (p-> mShowIconTodoview) 857 if (p-> mShowIconTodoview)
862 todoview_action->addTo( iconToolBar ); 858 todoview_action->addTo( iconToolBar );
863 if (p-> mShowIconJournal) 859 if (p-> mShowIconJournal)
864 viewjournal_action->addTo( iconToolBar ); 860 viewjournal_action->addTo( iconToolBar );
865 icon = loadPixmap( pathString + "2leftarrowB" ); 861 icon = loadPixmap( pathString + "2leftarrowB" );
866 configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200, 14); 862 configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200, 14);
867 if (p-> mShowIconBackFast) { 863 if (p-> mShowIconBackFast) {
868 action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this ); 864 action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this );
869 connect( action, SIGNAL( activated() ), 865 connect( action, SIGNAL( activated() ),
870 mView, SLOT( goPreviousMonth() ) ); 866 mView, SLOT( goPreviousMonth() ) );
871 action->addTo( iconToolBar ); 867 action->addTo( iconToolBar );
872 } 868 }
873 icon = loadPixmap( pathString + "1leftarrowB" ); 869 icon = loadPixmap( pathString + "1leftarrowB" );
874 configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210,15); 870 configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210,15);
875 if (p-> mShowIconBack) { 871 if (p-> mShowIconBack) {
876 action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this ); 872 action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this );
877 connect( action, SIGNAL( activated() ), 873 connect( action, SIGNAL( activated() ),
878 mView, SLOT( goPrevious() ) ); 874 mView, SLOT( goPrevious() ) );
879 action->addTo( iconToolBar ); 875 action->addTo( iconToolBar );
880 } 876 }
881 if (p-> mShowIconToday) 877 if (p-> mShowIconToday)
882 today_action->addTo( iconToolBar ); 878 today_action->addTo( iconToolBar );
883 icon = loadPixmap( pathString + "1rightarrowB" ); 879 icon = loadPixmap( pathString + "1rightarrowB" );
884 configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220); 880 configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220);
885 if (p-> mShowIconForward) { 881 if (p-> mShowIconForward) {
886 action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this ); 882 action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this );
887 connect( action, SIGNAL( activated() ), 883 connect( action, SIGNAL( activated() ),
888 mView, SLOT( goNext() ) ); 884 mView, SLOT( goNext() ) );
889 action->addTo( iconToolBar ); 885 action->addTo( iconToolBar );
890 } 886 }
891 icon = loadPixmap( pathString + "2rightarrowB" ); 887 icon = loadPixmap( pathString + "2rightarrowB" );
892 configureToolBarMenu->insertItem(icon, i18n("Next month"), 230); 888 configureToolBarMenu->insertItem(icon, i18n("Next month"), 230);
893 if (p-> mShowIconForwardFast) { 889 if (p-> mShowIconForwardFast) {
894 action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this ); 890 action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this );
895 connect( action, SIGNAL( activated() ), 891 connect( action, SIGNAL( activated() ),
896 mView, SLOT( goNextMonth() ) ); 892 mView, SLOT( goNextMonth() ) );
897 action->addTo( iconToolBar ); 893 action->addTo( iconToolBar );
898 } 894 }
899 895
900 896
901 configureToolBarMenu->insertItem(i18n("What's This?"), 300); 897 configureToolBarMenu->insertItem(i18n("What's This?"), 300);
902 898
903 if (p-> mShowIconNewEvent) 899 if (p-> mShowIconNewEvent)
904 configureToolBarMenu->setItemChecked( 10, true ); 900 configureToolBarMenu->setItemChecked( 10, true );
905 if (p->mShowIconNewTodo ) 901 if (p->mShowIconNewTodo )
906 configureToolBarMenu->setItemChecked( 20, true ); 902 configureToolBarMenu->setItemChecked( 20, true );
907 if (p-> mShowIconSearch) 903 if (p-> mShowIconSearch)
908 configureToolBarMenu->setItemChecked( 120, true ); 904 configureToolBarMenu->setItemChecked( 120, true );
909 if (p-> mShowIconList) 905 if (p-> mShowIconList)
910 configureToolBarMenu->setItemChecked( 30, true ); 906 configureToolBarMenu->setItemChecked( 30, true );
911 if (p-> mShowIconDay1) 907 if (p-> mShowIconDay1)
912 configureToolBarMenu->setItemChecked( 40, true ); 908 configureToolBarMenu->setItemChecked( 40, true );
913 if (p-> mShowIconDay5) 909 if (p-> mShowIconDay5)
914 configureToolBarMenu->setItemChecked( 50, true ); 910 configureToolBarMenu->setItemChecked( 50, true );
915 if (p-> mShowIconDay7) 911 if (p-> mShowIconDay7)
916 configureToolBarMenu->setItemChecked( 60, true ); 912 configureToolBarMenu->setItemChecked( 60, true );
917 if (p-> mShowIconMonth) 913 if (p-> mShowIconMonth)
918 configureToolBarMenu->setItemChecked( 70, true ); 914 configureToolBarMenu->setItemChecked( 70, true );
919 if (p-> mShowIconTodoview) 915 if (p-> mShowIconTodoview)
920 configureToolBarMenu->setItemChecked( 80, true ); 916 configureToolBarMenu->setItemChecked( 80, true );
921 if (p-> mShowIconBackFast) 917 if (p-> mShowIconBackFast)
922 configureToolBarMenu->setItemChecked( 200, true ); 918 configureToolBarMenu->setItemChecked( 200, true );
923 if (p-> mShowIconBack) 919 if (p-> mShowIconBack)
924 configureToolBarMenu->setItemChecked( 210, true ); 920 configureToolBarMenu->setItemChecked( 210, true );
925 if (p-> mShowIconToday) 921 if (p-> mShowIconToday)
926 configureToolBarMenu->setItemChecked( 130, true ); 922 configureToolBarMenu->setItemChecked( 130, true );
927 if (p-> mShowIconForward) 923 if (p-> mShowIconForward)
928 configureToolBarMenu->setItemChecked( 220, true ); 924 configureToolBarMenu->setItemChecked( 220, true );
929 if (p-> mShowIconForwardFast) 925 if (p-> mShowIconForwardFast)
930 configureToolBarMenu->setItemChecked( 230, true ); 926 configureToolBarMenu->setItemChecked( 230, true );
931 if (p-> mShowIconNextDays) 927 if (p-> mShowIconNextDays)
932 configureToolBarMenu->setItemChecked( 100, true ); 928 configureToolBarMenu->setItemChecked( 100, true );
933 if (p-> mShowIconNext) 929 if (p-> mShowIconNext)
934 configureToolBarMenu->setItemChecked( 110, true ); 930 configureToolBarMenu->setItemChecked( 110, true );
935 if (p-> mShowIconJournal) 931 if (p-> mShowIconJournal)
936 configureToolBarMenu->setItemChecked( 90, true ); 932 configureToolBarMenu->setItemChecked( 90, true );
937 if (p-> mShowIconWhatsThis) 933 if (p-> mShowIconWhatsThis)
938 configureToolBarMenu->setItemChecked( 300, true ); 934 configureToolBarMenu->setItemChecked( 300, true );
939 935
940 QLabel* dummy = new QLabel( iconToolBar ); 936 QLabel* dummy = new QLabel( iconToolBar );
941 dummy->setBackgroundColor( iconToolBar->backgroundColor() ); 937 dummy->setBackgroundColor( iconToolBar->backgroundColor() );
942 if (!p-> mShowIconStretch) 938 if (!p-> mShowIconStretch)
943 iconToolBar->setStretchableWidget ( dummy ) ; 939 iconToolBar->setStretchableWidget ( dummy ) ;
944 else 940 else
945 configureToolBarMenu->setItemChecked( 5, true ); 941 configureToolBarMenu->setItemChecked( 5, true );
946 if (p-> mShowIconWhatsThis) 942 if (p-> mShowIconWhatsThis)
947 QWhatsThis::whatsThisButton ( iconToolBar ); 943 QWhatsThis::whatsThisButton ( iconToolBar );
948 connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) ); 944 connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) );
949 configureAgenda( p->mHourSize ); 945 configureAgenda( p->mHourSize );
950 connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) ); 946 connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) );
951} 947}
952 948
953void MainWindow::exportToPhone( int mode ) 949void MainWindow::exportToPhone( int mode )
954{ 950{
955 951
956 //ex2phone->insertItem(i18n("Complete calendar..."), 1 ); 952 //ex2phone->insertItem(i18n("Complete calendar..."), 1 );
957 //ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); 953 //ex2phone->insertItem(i18n("Filtered calendar..."), 2 );
958 KOex2phonePrefs ex2phone; 954 KOex2phonePrefs ex2phone;
959 955
960 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); 956 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection );
961 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); 957 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice );
962 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); 958 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel );
963 if ( mode == 1 ) 959 if ( mode == 1 )
964 ex2phone.setCaption(i18n("Export complete calendar")); 960 ex2phone.setCaption(i18n("Export complete calendar"));
965 if ( mode == 2 ) 961 if ( mode == 2 )
966 ex2phone.setCaption(i18n("Export filtered calendar")); 962 ex2phone.setCaption(i18n("Export filtered calendar"));
967 963
968 if ( !ex2phone.exec() ) { 964 if ( !ex2phone.exec() ) {
969 return; 965 return;
970 } 966 }
971 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); 967 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text();
972 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); 968 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text();
973 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); 969 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text();
974 970
975 int inFuture = 0; 971 int inFuture = 0;
976 if ( ex2phone.mWriteBackFuture->isChecked() ) 972 if ( ex2phone.mWriteBackFuture->isChecked() )
977 inFuture = ex2phone.mWriteBackFutureWeeks->value(); 973 inFuture = ex2phone.mWriteBackFutureWeeks->value();
978 QPtrList<Incidence> delSel; 974 QPtrList<Incidence> delSel;
979 if ( mode == 1 ) 975 if ( mode == 1 )
980 delSel = mCalendar->rawIncidences(); 976 delSel = mCalendar->rawIncidences();
981 if ( mode == 2 ) 977 if ( mode == 2 )
982 delSel = mCalendar->incidences(); 978 delSel = mCalendar->incidences();
983 CalendarLocal* cal = new CalendarLocal(); 979 CalendarLocal* cal = new CalendarLocal();
984 cal->setLocalTime(); 980 cal->setLocalTime();
985 Incidence *incidence = delSel.first(); 981 Incidence *incidence = delSel.first();
986 QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); 982 QDateTime cur = QDateTime::currentDateTime().addDays( -7 );
987 QDateTime end = cur.addDays( ( inFuture +1 ) *7 ); 983 QDateTime end = cur.addDays( ( inFuture +1 ) *7 );
988 while ( incidence ) { 984 while ( incidence ) {
989 if ( incidence->type() != "Journal" ) { 985 if ( incidence->type() != "Journal" ) {
990 bool add = true; 986 bool add = true;
991 if ( inFuture ) { 987 if ( inFuture ) {
992 QDateTime dt; 988 QDateTime dt;
993 if ( incidence->type() == "Todo" ) { 989 if ( incidence->type() == "Todo" ) {
994 Todo * t = (Todo*)incidence; 990 Todo * t = (Todo*)incidence;
995 if ( t->hasDueDate() ) 991 if ( t->hasDueDate() )
996 dt = t->dtDue(); 992 dt = t->dtDue();
997 else 993 else
998 dt = cur.addSecs( 62 ); 994 dt = cur.addSecs( 62 );
999 } 995 }
1000 else { 996 else {
1001 bool ok; 997 bool ok;
1002 dt = incidence->getNextOccurence( cur, &ok ); 998 dt = incidence->getNextOccurence( cur, &ok );
1003 if ( !ok ) 999 if ( !ok )
1004 dt = cur.addSecs( -62 ); 1000 dt = cur.addSecs( -62 );
1005 } 1001 }
1006 if ( dt < cur || dt > end ) { 1002 if ( dt < cur || dt > end ) {
1007 add = false; 1003 add = false;
1008 } 1004 }
1009 } 1005 }
1010 if ( add ) { 1006 if ( add ) {
1011 Incidence *in = incidence->clone(); 1007 Incidence *in = incidence->clone();
1012 cal->addIncidence( in ); 1008 cal->addIncidence( in );
1013 } 1009 }
1014 } 1010 }
1015 incidence = delSel.next(); 1011 incidence = delSel.next();
1016 } 1012 }
1017 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, 1013 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice,
1018 KPimGlobalPrefs::instance()->mEx2PhoneConnection, 1014 KPimGlobalPrefs::instance()->mEx2PhoneConnection,
1019 KPimGlobalPrefs::instance()->mEx2PhoneModel ); 1015 KPimGlobalPrefs::instance()->mEx2PhoneModel );
1020 1016
1021 setCaption( i18n("Writing to phone...")); 1017 setCaption( i18n("Writing to phone..."));
1022 if ( PhoneFormat::writeToPhone( cal ) ) 1018 if ( PhoneFormat::writeToPhone( cal ) )
1023 setCaption( i18n("Export to phone successful!")); 1019 setCaption( i18n("Export to phone successful!"));
1024 else 1020 else
1025 setCaption( i18n("Error exporting to phone!")); 1021 setCaption( i18n("Error exporting to phone!"));
1026 delete cal; 1022 delete cal;
1027} 1023}
1028 1024
1029 1025
1030void MainWindow::setDefaultPreferences() 1026void MainWindow::setDefaultPreferences()
1031{ 1027{
1032 KOPrefs *p = KOPrefs::instance(); 1028 KOPrefs *p = KOPrefs::instance();
1033 1029
1034 p->mCompactDialogs = true; 1030 p->mCompactDialogs = true;
1035 p->mConfirm = true; 1031 p->mConfirm = true;
1036 // p->mEnableQuickTodo = false; 1032 // p->mEnableQuickTodo = false;
1037 1033
1038} 1034}
1039 1035
1040QString MainWindow::resourcePath() 1036QString MainWindow::resourcePath()
1041{ 1037{
1042 return KGlobal::iconLoader()->iconPath(); 1038 return KGlobal::iconLoader()->iconPath();
1043} 1039}
1044 1040
1045void MainWindow::displayText( QString text ,QString cap ) 1041void MainWindow::displayText( QString text ,QString cap )
1046{ 1042{
1047 QDialog dia( this, "name", true ); ; 1043 QDialog dia( this, "name", true ); ;
1048 dia.setCaption( cap ); 1044 dia.setCaption( cap );
1049 QVBoxLayout* lay = new QVBoxLayout( &dia ); 1045 QVBoxLayout* lay = new QVBoxLayout( &dia );
1050 lay->setSpacing( 3 ); 1046 lay->setSpacing( 3 );
1051 lay->setMargin( 3 ); 1047 lay->setMargin( 3 );
1052 QTextBrowser tb ( &dia ); 1048 QTextBrowser tb ( &dia );
1053 lay->addWidget( &tb ); 1049 lay->addWidget( &tb );
1054 tb.setText( text ); 1050 tb.setText( text );
1055#ifdef DESKTOP_VERSION 1051#ifdef DESKTOP_VERSION
1056 dia.resize( 640, 480); 1052 dia.resize( 640, 480);
1057#else 1053#else
1058 dia.showMaximized(); 1054 dia.showMaximized();
1059#endif 1055#endif
1060 dia.exec(); 1056 dia.exec();
1061} 1057}
1062void MainWindow::displayFile( QString fn, QString cap ) 1058void MainWindow::displayFile( QString fn, QString cap )
1063{ 1059{
1064 QString fileName = resourcePath() + fn; 1060 QString fileName = resourcePath() + fn;
1065 QString text; 1061 QString text;
1066 QFile file( fileName ); 1062 QFile file( fileName );
1067 if (!file.open( IO_ReadOnly ) ) { 1063 if (!file.open( IO_ReadOnly ) ) {
1068 return ; 1064 return ;
1069 1065
1070 } 1066 }
1071 QTextStream ts( &file ); 1067 QTextStream ts( &file );
1072 text = ts.read(); 1068 text = ts.read();
1073 file.close(); 1069 file.close();
1074 displayText( text, cap); 1070 displayText( text, cap);
1075} 1071}
1076void MainWindow::features() 1072void MainWindow::features()
1077{ 1073{
1078 1074
1079 displayFile( "featuresKOPI.txt",i18n("KO/Pi Features and hints") ); 1075 displayFile( "featuresKOPI.txt",i18n("KO/Pi Features and hints") );
1080} 1076}
1081 1077
1082void MainWindow::usertrans() 1078void MainWindow::usertrans()
1083{ 1079{
1084 1080
1085 displayFile( "usertranslationHOWTO.txt",i18n("KO/Pi User translation HowTo") ); 1081 displayFile( "usertranslationHOWTO.txt",i18n("KO/Pi User translation HowTo") );
1086} 1082}
1087 1083
1088void MainWindow::synchowto() 1084void MainWindow::synchowto()
1089{ 1085{
1090#if 0 1086#if 0
1091 QPtrList<Incidence> er = mCalendar->rawIncidences(); 1087 QPtrList<Incidence> er = mCalendar->rawIncidences();
1092 Incidence* inR = er.first(); 1088 Incidence* inR = er.first();
1093 VCalFormat vf; 1089 VCalFormat vf;
1094 QString strout; 1090 QString strout;
1095 while ( inR ) { 1091 while ( inR ) {
1096 if ( inR->type() == "Todo" ) 1092 if ( inR->type() == "Todo" )
1097 strout = vf.todoToString( (Todo *) inR ); 1093 strout = vf.todoToString( (Todo *) inR );
1098 if ( inR->type() == "Event" ) 1094 if ( inR->type() == "Event" )
1099 strout = vf.eventToString( (Event *) inR ); 1095 strout = vf.eventToString( (Event *) inR );
1100 qDebug("incidence: \n%s\n ente\n\n",strout.latin1() ); 1096 qDebug("incidence: \n%s\n ente\n\n",strout.latin1() );
1101 inR = er.next(); 1097 inR = er.next();
1102 } 1098 }
1103#endif 1099#endif
1104 displayFile( "howtoSYNC.txt",i18n("KO/Pi Synchronization HowTo") ); 1100 displayFile( "howtoSYNC.txt",i18n("KO/Pi Synchronization HowTo") );
1105} 1101}
1106void MainWindow::faq() 1102void MainWindow::faq()
1107{ 1103{
1108 displayFile( "kopiFAQ.txt",i18n("KO/Pi FAQ") ); 1104 displayFile( "kopiFAQ.txt",i18n("KO/Pi FAQ") );
1109 1105
1110} 1106}
1111void MainWindow::whatsNew() 1107void MainWindow::whatsNew()
1112{ 1108{
1113 displayFile( "kopiWhatsNew.txt",i18n("KO/Pi Version Info") ); 1109 displayFile( "kopiWhatsNew.txt",i18n("KO/Pi Version Info") );
1114 1110
1115} 1111}
1116void MainWindow::licence() 1112void MainWindow::licence()
1117{ 1113{
1118 KApplication::showLicence(); 1114 KApplication::showLicence();
1119 1115
1120} 1116}
1121void MainWindow::about() 1117void MainWindow::about()
1122{ 1118{
1123 QString version; 1119 QString version;
1124#include <../version> 1120#include <../version>
1125 QMessageBox::about( this, i18n("About KOrganizer/Pi"), 1121 QMessageBox::about( this, i18n("About KOrganizer/Pi"),
1126 i18n("KOrganizer/Platform-independent\n") + 1122 i18n("KOrganizer/Platform-independent\n") +
1127 "(KO/Pi) " + version + " - " + 1123 "(KO/Pi) " + version + " - " +
1128 1124
1129#ifdef DESKTOP_VERSION 1125#ifdef DESKTOP_VERSION
1130 i18n("Desktop Edition\n") + 1126 i18n("Desktop Edition\n") +
1131#else 1127#else
1132 i18n("PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n") + 1128 i18n("PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n") +
1133#endif 1129#endif
1134 i18n("(c) 2004 Lutz Rogowski\nEmail:lutz@pi-sync.net\nKO/Pi is based on KOrganizer\n(c) 2002,2003 Cornelius Schumacher\nEmail: schumacher@kde.org\nKOrganizer/Pi is licensed\nunder the GPL.\nKO/Pi can be compiled for\nLinux, Zaurus-PDA and Windows\nwww.korganizer.org\nwww.pi-sync.net\n") ); 1130 i18n("(c) 2004 Lutz Rogowski\nEmail:lutz@pi-sync.net\nKO/Pi is based on KOrganizer\n(c) 2002,2003 Cornelius Schumacher\nEmail: schumacher@kde.org\nKOrganizer/Pi is licensed\nunder the GPL.\nKO/Pi can be compiled for\nLinux, Zaurus-PDA and Windows\nwww.korganizer.org\nwww.pi-sync.net\n") );
1135} 1131}
1136void MainWindow::keyBindings() 1132void MainWindow::keyBindings()
1137{ 1133{
1138 QString cap = i18n("Key bindings KOrganizer/Pi"); 1134 QString cap = i18n("Key bindings KOrganizer/Pi");
1139 QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") + 1135 QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") +
1140 i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+ 1136 i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+
1141 i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") + 1137 i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") +
1142 i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+ 1138 i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+
1143 i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+ 1139 i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+
1144 i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+ 1140 i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+
1145 i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+ 1141 i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+
1146 i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+ 1142 i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+
1147 i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+ 1143 i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+
1148 i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+ 1144 i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+
1149 i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+ 1145 i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+
1150 i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+ 1146 i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+
1151 i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+ 1147 i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+
1152 i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+ 1148 i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+
1153 i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+ 1149 i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+
1154 i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+ 1150 i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+
1155 i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+ 1151 i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+
1156 i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+ 1152 i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+
1157 i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+ 1153 i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+
1158 i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+ 1154 i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+
1159 i18n("<p><h3>In agenda view:</h3></p>\n") + 1155 i18n("<p><h3>In agenda view:</h3></p>\n") +
1160 i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+ 1156 i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+
1161 i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+ 1157 i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+
1162 i18n("<p><h3>In todo view:</h3></p>\n") + 1158 i18n("<p><h3>In todo view:</h3></p>\n") +
1163 i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+ 1159 i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+
1164 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ 1160 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+
1165 i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+ 1161 i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+
1166 i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+ 1162 i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+
1167 i18n("<p><h3>In list view:</h3></p>\n") + 1163 i18n("<p><h3>In list view:</h3></p>\n") +
1168 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ 1164 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+
1169 i18n("<p><b>return</b>: Select item+one step down</p>\n")+ 1165 i18n("<p><b>return</b>: Select item+one step down</p>\n")+
1170 i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+ 1166 i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+
1171 i18n("<p><b>up/down</b>: Next/prev item</p>\n")+ 1167 i18n("<p><b>up/down</b>: Next/prev item</p>\n")+
1172 i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+ 1168 i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+
1173 i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+ 1169 i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+
1174 i18n("<p><h3>In event/todo viewer:</h3></p>\n") + 1170 i18n("<p><h3>In event/todo viewer:</h3></p>\n") +
1175 i18n("<p><b>I,C</b>: Close dialog.</p>\n")+ 1171 i18n("<p><b>I,C</b>: Close dialog.</p>\n")+
1176 i18n("<p><b>A</b>: Show agenda view.</p>\n")+ 1172 i18n("<p><b>A</b>: Show agenda view.</p>\n")+
1177 i18n("<p><b>E</b>: Edit item</p>\n") + 1173 i18n("<p><b>E</b>: Edit item</p>\n") +
1178 i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") + 1174 i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") +
1179 i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") + 1175 i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") +
1180 i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+ 1176 i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+
1181 i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+ 1177 i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+
1182 i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+ 1178 i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+
1183 i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+ 1179 i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+
1184 i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+ 1180 i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+
1185 i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") + 1181 i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") +
1186 i18n("<p><b>White</b>: Item readonly</p>\n"); 1182 i18n("<p><b>White</b>: Item readonly</p>\n");
1187 displayText( text, cap); 1183 displayText( text, cap);
1188 1184
1189} 1185}
1190void MainWindow::aboutAutoSaving() 1186void MainWindow::aboutAutoSaving()
1191{ 1187{
1192 QMessageBox* msg; 1188 QMessageBox* msg;
1193 msg = new QMessageBox( i18n("Auto Saving in KOrganizer/Pi"), 1189 msg = new QMessageBox( i18n("Auto Saving in KOrganizer/Pi"),
1194 i18n("After changing something, the data is\nautomatically saved to the file\n~/kdepim/apps/korganizer/mycalendar.ics\nafter (configureable) three minutes.\nFor safety reasons there is one autosaving\nafter 10 minutes (of idle time) again. The \ndata is saved automatically when closing KO/Pi\nYou can create a backup file \nwith: File - Save Calendar Backup\n"), QMessageBox::NoIcon, 1190 i18n("After changing something, the data is\nautomatically saved to the file\n~/kdepim/apps/korganizer/mycalendar.ics\nafter (configureable) three minutes.\nFor safety reasons there is one autosaving\nafter 10 minutes (of idle time) again. The \ndata is saved automatically when closing KO/Pi\nYou can create a backup file \nwith: File - Save Calendar Backup\n"), QMessageBox::NoIcon,
1195 QMessageBox::Ok, 1191 QMessageBox::Ok,
1196 QMessageBox::NoButton, 1192 QMessageBox::NoButton,
1197 QMessageBox::NoButton); 1193 QMessageBox::NoButton);
1198 msg->exec(); 1194 msg->exec();
1199 delete msg; 1195 delete msg;
1200 1196
1201 1197
1202} 1198}
1203void MainWindow::aboutKnownBugs() 1199void MainWindow::aboutKnownBugs()
1204{ 1200{
1205 QMessageBox* msg; 1201 QMessageBox* msg;
1206 msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"), 1202 msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"),
1207 i18n("1) Importing *.vcs or *.ics files from\nother applications may not work properly,\nif there are events with properties\nKO/Pi does not support.\n")+ 1203 i18n("1) Importing *.vcs or *.ics files from\nother applications may not work properly,\nif there are events with properties\nKO/Pi does not support.\n")+
1208 i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+ 1204 i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+
1209 i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.net\n") + 1205 i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.net\n") +
1210 i18n("\nor report them in the bugtracker on\n") + 1206 i18n("\nor report them in the bugtracker on\n") +
1211 i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"), 1207 i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"),
1212 QMessageBox::NoIcon, 1208 QMessageBox::NoIcon,
1213 QMessageBox::Ok, 1209 QMessageBox::Ok,
1214 QMessageBox::NoButton, 1210 QMessageBox::NoButton,
1215 QMessageBox::NoButton); 1211 QMessageBox::NoButton);
1216 msg->exec(); 1212 msg->exec();
1217 delete msg; 1213 delete msg;
1218 1214
1219} 1215}
1220 1216
1221QString MainWindow::defaultFileName() 1217QString MainWindow::defaultFileName()
1222{ 1218{
1223 return locateLocal( "data", "korganizer/mycalendar.ics" ); 1219 return locateLocal( "data", "korganizer/mycalendar.ics" );
1224} 1220}
1225QString MainWindow::syncFileName() 1221QString MainWindow::syncFileName()
1226{ 1222{
1227#ifdef _WIN32_ 1223#ifdef _WIN32_
1228 return locateLocal( "tmp", "synccalendar.ics" ); 1224 return locateLocal( "tmp", "synccalendar.ics" );
1229#else 1225#else
1230 return QString( "/tmp/kopitempfile.ics" ); 1226 return QString( "/tmp/kopitempfile.ics" );
1231#endif 1227#endif
1232} 1228}
1233 1229
1234void MainWindow::processIncidenceSelection( Incidence *incidence ) 1230void MainWindow::processIncidenceSelection( Incidence *incidence )
1235{ 1231{
1236 if ( !incidence ) { 1232 if ( !incidence ) {
1237 enableIncidenceActions( false ); 1233 enableIncidenceActions( false );
1238 1234
1239 mNewSubTodoAction->setEnabled( false ); 1235 mNewSubTodoAction->setEnabled( false );
1240 setCaptionToDates(); 1236 setCaptionToDates();
1241 return; 1237 return;
1242 1238
1243 } 1239 }
1244 1240
1245 //KGlobal::locale()->formatDateTime(nextA, true); 1241 //KGlobal::locale()->formatDateTime(nextA, true);
1246 QString startString = ""; 1242 QString startString = "";
1247 if ( incidence->type() != "Todo" ) { 1243 if ( incidence->type() != "Todo" ) {
1248 if ( incidence->dtStart().date() < incidence->dtEnd().date() ) { 1244 if ( incidence->dtStart().date() < incidence->dtEnd().date() ) {
1249 if ( incidence->doesFloat() ) { 1245 if ( incidence->doesFloat() ) {
1250 startString += ": "+incidence->dtStartDateStr( true ); 1246 startString += ": "+incidence->dtStartDateStr( true );
1251 startString += " --- "+((Event*)incidence)->dtEndDateStr( true ); 1247 startString += " --- "+((Event*)incidence)->dtEndDateStr( true );
1252 1248
1253 } else { 1249 } else {
1254 startString = ": "+incidence->dtStartStr(true); 1250 startString = ": "+incidence->dtStartStr(true);
1255 startString += " --- "+((Event*)incidence)->dtEndStr(true); 1251 startString += " --- "+((Event*)incidence)->dtEndStr(true);
1256 1252
1257 } 1253 }
1258 1254
1259 } else { 1255 } else {
1260 if ( incidence->dtStart().time() != incidence->dtEnd().time() ) 1256 if ( incidence->dtStart().time() != incidence->dtEnd().time() )
1261 startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+ 1257 startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+
1262 "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time()); 1258 "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time());
1263 startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true); 1259 startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true);
1264 } 1260 }
1265 1261
1266 } 1262 }
1267 else 1263 else
1268 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed"); 1264 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed");
1269 if ( !incidence->location().isEmpty() ) 1265 if ( !incidence->location().isEmpty() )
1270 startString += " (" +incidence->location()+")"; 1266 startString += " (" +incidence->location()+")";
1271 setCaption( incidence->summary()+startString); 1267 setCaption( incidence->summary()+startString);
1272 1268
1273 enableIncidenceActions( true ); 1269 enableIncidenceActions( true );
1274 1270
1275 if ( incidence->type() == "Event" ) { 1271 if ( incidence->type() == "Event" ) {
1276 mShowAction->setText( i18n("Show Event...") ); 1272 mShowAction->setText( i18n("Show Event...") );
1277 mEditAction->setText( i18n("Edit Event...") ); 1273 mEditAction->setText( i18n("Edit Event...") );
1278 mDeleteAction->setText( i18n("Delete Event...") ); 1274 mDeleteAction->setText( i18n("Delete Event...") );
1279 1275
1280 mNewSubTodoAction->setEnabled( false ); 1276 mNewSubTodoAction->setEnabled( false );
1281 } else if ( incidence->type() == "Todo" ) { 1277 } else if ( incidence->type() == "Todo" ) {
1282 mShowAction->setText( i18n("Show Todo...") ); 1278 mShowAction->setText( i18n("Show Todo...") );
1283 mEditAction->setText( i18n("Edit Todo...") ); 1279 mEditAction->setText( i18n("Edit Todo...") );
1284 mDeleteAction->setText( i18n("Delete Todo...") ); 1280 mDeleteAction->setText( i18n("Delete Todo...") );
1285 1281
1286 mNewSubTodoAction->setEnabled( true ); 1282 mNewSubTodoAction->setEnabled( true );
1287 } else { 1283 } else {
1288 mShowAction->setText( i18n("Show...") ); 1284 mShowAction->setText( i18n("Show...") );
1289 mShowAction->setText( i18n("Edit...") ); 1285 mShowAction->setText( i18n("Edit...") );
1290 mShowAction->setText( i18n("Delete...") ); 1286 mShowAction->setText( i18n("Delete...") );
1291 1287
1292 mNewSubTodoAction->setEnabled( false ); 1288 mNewSubTodoAction->setEnabled( false );
1293 } 1289 }
1294} 1290}
1295 1291
1296void MainWindow::enableIncidenceActions( bool enabled ) 1292void MainWindow::enableIncidenceActions( bool enabled )
1297{ 1293{
1298 mShowAction->setEnabled( enabled ); 1294 mShowAction->setEnabled( enabled );
1299 mEditAction->setEnabled( enabled ); 1295 mEditAction->setEnabled( enabled );
1300 mDeleteAction->setEnabled( enabled ); 1296 mDeleteAction->setEnabled( enabled );
1301 1297
1302 mCloneAction->setEnabled( enabled ); 1298 mCloneAction->setEnabled( enabled );
1303 mMoveAction->setEnabled( enabled ); 1299 mMoveAction->setEnabled( enabled );
1304 mBeamAction->setEnabled( enabled ); 1300 mBeamAction->setEnabled( enabled );
1305 mCancelAction->setEnabled( enabled ); 1301 mCancelAction->setEnabled( enabled );
1306} 1302}
1307 1303
1308void MainWindow::importOL() 1304void MainWindow::importOL()
1309{ 1305{
1310#ifdef _WIN32_ 1306#ifdef _WIN32_
1311 KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this ); 1307 KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this );
1312 id->exec(); 1308 id->exec();
1313 delete id; 1309 delete id;
1314 mView->updateView(); 1310 mView->updateView();
1315#endif 1311#endif
1316} 1312}
1317void MainWindow::importBday() 1313void MainWindow::importBday()
1318{ 1314{
1319 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1315 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1320 i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), 1316 i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"),
1321 i18n("Import!"), i18n("Cancel"), 0, 1317 i18n("Import!"), i18n("Cancel"), 0,
1322 0, 1 ); 1318 0, 1 );
1323 if ( result == 0 ) { 1319 if ( result == 0 ) {
1324 mView->importBday(); 1320 mView->importBday();
1325 1321
1326 } 1322 }
1327 1323
1328 1324
1329} 1325}
1330void MainWindow::importQtopia() 1326void MainWindow::importQtopia()
1331{ 1327{
1332#ifndef DESKTOP_VERSION 1328#ifndef DESKTOP_VERSION
1333 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1329 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1334 i18n("When importing a calendar twice\nduplicated events will be ignored!\nYou can create a backup file with\nFile - Save Calendar Backup\nto revert importing"), 1330 i18n("When importing a calendar twice\nduplicated events will be ignored!\nYou can create a backup file with\nFile - Save Calendar Backup\nto revert importing"),
1335 i18n("Import!"), i18n("Cancel"), 0, 1331 i18n("Import!"), i18n("Cancel"), 0,
1336 0, 1 ); 1332 0, 1 );
1337 if ( result == 0 ) { 1333 if ( result == 0 ) {
1338 QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); 1334 QString datebook = Global::applicationFileName( "datebook", "datebook.xml");
1339 QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); 1335 QString todolist = Global::applicationFileName( "todolist", "todolist.xml");
1340 QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; 1336 QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml";
1341 mView->importQtopia( categories, datebook, todolist ); 1337 mView->importQtopia( categories, datebook, todolist );
1342 } 1338 }
1343#else 1339#else
1344 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1340 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1345 i18n("Not supported \non desktop!\n"), 1341 i18n("Not supported \non desktop!\n"),
1346 i18n("Ok"), i18n("Cancel"), 0, 1342 i18n("Ok"), i18n("Cancel"), 0,
1347 0, 1 ); 1343 0, 1 );
1348 1344
1349#endif 1345#endif
1350} 1346}
1351 1347
1352void MainWindow::saveOnClose() 1348void MainWindow::saveOnClose()
1353{ 1349{
1354 KOPrefs *p = KOPrefs::instance(); 1350 KOPrefs *p = KOPrefs::instance();
1355 p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); 1351 p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal );
1356 p->mToolBarUp = iconToolBar->x() > width()/2 || 1352 p->mToolBarUp = iconToolBar->x() > width()/2 ||
1357 iconToolBar->y() > height()/2; 1353 iconToolBar->y() > height()/2;
1358 mView->writeSettings(); 1354 mView->writeSettings();
1359 if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName())) 1355 if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName()))
1360 save(); 1356 save();
1361} 1357}
1362void MainWindow::slotModifiedChanged( bool changed ) 1358void MainWindow::slotModifiedChanged( bool changed )
1363{ 1359{
1364 if ( mBlockAtStartup ) 1360 if ( mBlockAtStartup )
1365 return; 1361 return;
1366 int msec; 1362 int msec;
1367 // we store the changes after 1 minute, 1363 // we store the changes after 1 minute,
1368 // and for safety reasons after 10 minutes again 1364 // and for safety reasons after 10 minutes again
1369 if ( !mSyncManager->blockSave() ) 1365 if ( !mSyncManager->blockSave() )
1370 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; 1366 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000;
1371 else 1367 else
1372 msec = 1000 * 600; 1368 msec = 1000 * 600;
1373 mSaveTimer.start( msec, true ); // 1 minute 1369 mSaveTimer.start( msec, true ); // 1 minute
1374 qDebug("KO: Saving File in %d secs!", msec/1000); 1370 qDebug("KO: Saving File in %d secs!", msec/1000);
1375 mCalendarModifiedFlag = true; 1371 mCalendarModifiedFlag = true;
1376} 1372}
1377void MainWindow::save() 1373void MainWindow::save()
1378{ 1374{
1379 if ( mSyncManager->blockSave() ) 1375 if ( mSyncManager->blockSave() )
1380 return; 1376 return;
1381 mSyncManager->setBlockSave(true); 1377 mSyncManager->setBlockSave(true);
1382 if ( mView->checkFileVersion( defaultFileName()) ) { 1378 if ( mView->checkFileVersion( defaultFileName()) ) {
1383 1379
1384 QTime neededSaveTime = QDateTime::currentDateTime().time(); 1380 QTime neededSaveTime = QDateTime::currentDateTime().time();
1385 setCaption(i18n("KO/Pi:Saving Data to File ..." )); 1381 setCaption(i18n("KO/Pi:Saving Data to File ..." ));
1386 qDebug("KO: Start saving data to file!"); 1382 qDebug("KO: Start saving data to file!");
1387 mView->saveCalendar( defaultFileName() ); 1383 mView->saveCalendar( defaultFileName() );
1388 1384
1389 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 1385 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
1390 qDebug("KO: Needed %d ms for saving.",msNeeded ); 1386 qDebug("KO: Needed %d ms for saving.",msNeeded );
1391 QString savemes; 1387 QString savemes;
1392 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); 1388 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 );
1393 setCaption(savemes); 1389 setCaption(savemes);
1394 } else 1390 } else
1395 setCaption(i18n("Saving cancelled!")); 1391 setCaption(i18n("Saving cancelled!"));
1396 mCalendarModifiedFlag = false; 1392 mCalendarModifiedFlag = false;
1397 mSyncManager->setBlockSave( false ); 1393 mSyncManager->setBlockSave( false );
1398} 1394}
1399 1395
1400void MainWindow::keyReleaseEvent ( QKeyEvent * e) 1396void MainWindow::keyReleaseEvent ( QKeyEvent * e)
1401{ 1397{
1402 if ( !e->isAutoRepeat() ) { 1398 if ( !e->isAutoRepeat() ) {
1403 mFlagKeyPressed = false; 1399 mFlagKeyPressed = false;
1404 } 1400 }
1405} 1401}
1406void MainWindow::keyPressEvent ( QKeyEvent * e ) 1402void MainWindow::keyPressEvent ( QKeyEvent * e )
1407{ 1403{
1408 qApp->processEvents(); 1404 qApp->processEvents();
1409 if ( e->isAutoRepeat() && !mFlagKeyPressed ) { 1405 if ( e->isAutoRepeat() && !mFlagKeyPressed ) {
1410 e->ignore(); 1406 e->ignore();
1411 // qDebug(" ignore %d",e->isAutoRepeat() ); 1407 // qDebug(" ignore %d",e->isAutoRepeat() );
1412 return; 1408 return;
1413 } 1409 }
1414 if (! e->isAutoRepeat() ) 1410 if (! e->isAutoRepeat() )
1415 mFlagKeyPressed = true; 1411 mFlagKeyPressed = true;
1416 KOPrefs *p = KOPrefs::instance(); 1412 KOPrefs *p = KOPrefs::instance();
1417 bool showSelectedDates = false; 1413 bool showSelectedDates = false;
1418 int size; 1414 int size;
1419 int pro = 0; 1415 int pro = 0;
1420 //qDebug("MainWindow::keyPressEvent "); 1416 //qDebug("MainWindow::keyPressEvent ");
1421 switch ( e->key() ) { 1417 switch ( e->key() ) {
1422 case Qt::Key_Right: 1418 case Qt::Key_Right:
1423 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) 1419 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton)
1424 mView->goNextMonth(); 1420 mView->goNextMonth();
1425 else 1421 else
1426 mView->goNext(); 1422 mView->goNext();
1427 showSelectedDates = true; 1423 showSelectedDates = true;
1428 break; 1424 break;
1429 case Qt::Key_Left: 1425 case Qt::Key_Left:
1430 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1426 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1431 mView->goPreviousMonth(); 1427 mView->goPreviousMonth();
1432 else 1428 else
1433 mView->goPrevious(); 1429 mView->goPrevious();
1434 showSelectedDates = true; 1430 showSelectedDates = true;
1435 break; 1431 break;
1436 case Qt::Key_Down: 1432 case Qt::Key_Down:
1437 mView->viewManager()->agendaView()->scrollOneHourDown(); 1433 mView->viewManager()->agendaView()->scrollOneHourDown();
1438 break; 1434 break;
1439 case Qt::Key_Up: 1435 case Qt::Key_Up:
1440 mView->viewManager()->agendaView()->scrollOneHourUp(); 1436 mView->viewManager()->agendaView()->scrollOneHourUp();
1441 break; 1437 break;
1442 case Qt::Key_I: 1438 case Qt::Key_I:
1443 mView->showIncidence(); 1439 mView->showIncidence();
1444 break; 1440 break;
1445 case Qt::Key_Delete: 1441 case Qt::Key_Delete:
1446 case Qt::Key_Backspace: 1442 case Qt::Key_Backspace:
1447 mView->deleteIncidence(); 1443 mView->deleteIncidence();
1448 break; 1444 break;
1449 case Qt::Key_D: 1445 case Qt::Key_D:
1450 mView->viewManager()->showDayView(); 1446 mView->viewManager()->showDayView();
1451 showSelectedDates = true; 1447 showSelectedDates = true;
1452 break; 1448 break;
1453 case Qt::Key_O: 1449 case Qt::Key_O:
1454 mView->toggleFilerEnabled( ); 1450 mView->toggleFilerEnabled( );
1455 break; 1451 break;
1456 case Qt::Key_0: 1452 case Qt::Key_0:
1457 case Qt::Key_1: 1453 case Qt::Key_1:
1458 case Qt::Key_2: 1454 case Qt::Key_2:
1459 case Qt::Key_3: 1455 case Qt::Key_3:
1460 case Qt::Key_4: 1456 case Qt::Key_4:
1461 case Qt::Key_5: 1457 case Qt::Key_5:
1462 case Qt::Key_6: 1458 case Qt::Key_6:
1463 case Qt::Key_7: 1459 case Qt::Key_7:
1464 case Qt::Key_8: 1460 case Qt::Key_8:
1465 case Qt::Key_9: 1461 case Qt::Key_9:
1466 pro = e->key()-48; 1462 pro = e->key()-48;
1467 if ( pro == 0 ) 1463 if ( pro == 0 )
1468 pro = 10; 1464 pro = 10;
1469 if ( e->state() == Qt::ControlButton) 1465 if ( e->state() == Qt::ControlButton)
1470 pro += 10; 1466 pro += 10;
1471 break; 1467 break;
1472 case Qt::Key_M: 1468 case Qt::Key_M:
1473 mView->viewManager()->showMonthView(); 1469 mView->viewManager()->showMonthView();
1474 showSelectedDates = true; 1470 showSelectedDates = true;
1475 break; 1471 break;
1476 case Qt::Key_Insert: 1472 case Qt::Key_Insert:
1477 mView->newEvent(); 1473 mView->newEvent();
1478 break; 1474 break;
1479 case Qt::Key_S : 1475 case Qt::Key_S :
1480 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) 1476 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton)
1481 mView->newSubTodo(); 1477 mView->newSubTodo();
1482 else 1478 else
1483 mView->dialogManager()->showSearchDialog(); 1479 mView->dialogManager()->showSearchDialog();
1484 break; 1480 break;
1485 case Qt::Key_Y : 1481 case Qt::Key_Y :
1486 case Qt::Key_Z : 1482 case Qt::Key_Z :
1487 mView->viewManager()->showWorkWeekView(); 1483 mView->viewManager()->showWorkWeekView();
1488 showSelectedDates = true; 1484 showSelectedDates = true;
1489 break; 1485 break;
1490 case Qt::Key_U : 1486 case Qt::Key_U :
1491 mView->viewManager()->showWeekView(); 1487 mView->viewManager()->showWeekView();
1492 showSelectedDates = true; 1488 showSelectedDates = true;
1493 break; 1489 break;
1494 case Qt::Key_H : 1490 case Qt::Key_H :
1495 keyBindings(); 1491 keyBindings();
1496 break; 1492 break;
1497 case Qt::Key_W: 1493 case Qt::Key_W:
1498 mView->viewManager()->showWhatsNextView(); 1494 mView->viewManager()->showWhatsNextView();
1499 break; 1495 break;
1500 case Qt::Key_L: 1496 case Qt::Key_L:
1501 mView->viewManager()->showListView(); 1497 mView->viewManager()->showListView();
1502 break; 1498 break;
1503 case Qt::Key_N: 1499 case Qt::Key_N:
1504 mView->viewManager()->showNextXView(); 1500 mView->viewManager()->showNextXView();
1505 showSelectedDates = true; 1501 showSelectedDates = true;
1506 break; 1502 break;
1507 case Qt::Key_V: 1503 case Qt::Key_V:
1508 mView->viewManager()->showTodoView(); 1504 mView->viewManager()->showTodoView();
1509 break; 1505 break;
1510 case Qt::Key_C: 1506 case Qt::Key_C:
1511 mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() ); 1507 mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() );
1512 break; 1508 break;
1513 case Qt::Key_P: 1509 case Qt::Key_P:
1514 mView->showDatePicker( ); 1510 mView->showDatePicker( );
1515 break; 1511 break;
1516 case Qt::Key_F: 1512 case Qt::Key_F:
1517 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1513 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1518 mView->editFilters(); 1514 mView->editFilters();
1519 else 1515 else
1520 mView->toggleFilter(); 1516 mView->toggleFilter();
1521 break; 1517 break;
1522 case Qt::Key_X: 1518 case Qt::Key_X:
1523 mView->toggleDateNavigatorWidget(); 1519 mView->toggleDateNavigatorWidget();
1524 break; 1520 break;
1525 case Qt::Key_Space: 1521 case Qt::Key_Space:
1526 mView->toggleExpand(); 1522 mView->toggleExpand();
1527 break; 1523 break;
1528 case Qt::Key_A: 1524 case Qt::Key_A:
1529 mView->toggleAllDaySize(); 1525 mView->toggleAllDaySize();
1530 break; 1526 break;
1531 case Qt::Key_T: 1527 case Qt::Key_T:
1532 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1528 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1533 mView->newTodo(); 1529 mView->newTodo();
1534 else { 1530 else {
1535 mView->goToday(); 1531 mView->goToday();
1536 showSelectedDates = true; 1532 showSelectedDates = true;
1537 } 1533 }
1538 break; 1534 break;
1539 case Qt::Key_J: 1535 case Qt::Key_J:
1540 mView->viewManager()->showJournalView(); 1536 mView->viewManager()->showJournalView();
1541 break; 1537 break;
1542 case Qt::Key_B: 1538 case Qt::Key_B:
1543 mView->editIncidenceDescription();; 1539 mView->editIncidenceDescription();;
1544 break; 1540 break;
1545 // case Qt::Key_Return: 1541 // case Qt::Key_Return:
1546 case Qt::Key_E: 1542 case Qt::Key_E:
1547 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1543 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1548 mView->newEvent(); 1544 mView->newEvent();
1549 else 1545 else
1550 mView->editIncidence(); 1546 mView->editIncidence();
1551 break; 1547 break;
1552 case Qt::Key_Plus: 1548 case Qt::Key_Plus:
1553 size = p->mHourSize +2; 1549 size = p->mHourSize +2;
1554 if ( size <= 18 ) 1550 if ( size <= 18 )
1555 configureAgenda( size ); 1551 configureAgenda( size );
1556 break; 1552 break;
1557 case Qt::Key_Minus: 1553 case Qt::Key_Minus:
1558 size = p->mHourSize - 2; 1554 size = p->mHourSize - 2;
1559 if ( size >= 4 ) 1555 if ( size >= 4 )
1560 configureAgenda( size ); 1556 configureAgenda( size );
1561 break; 1557 break;
1562 1558
1563 1559
1564 default: 1560 default:
1565 e->ignore(); 1561 e->ignore();
1566 } 1562 }
1567 if ( pro > 0 ) { 1563 if ( pro > 0 ) {
1568 mView->selectFilter( pro-1 ); 1564 mView->selectFilter( pro-1 );
1569 } 1565 }
1570 if ( showSelectedDates ) { 1566 if ( showSelectedDates ) {
1571 ;// setCaptionToDates(); 1567 ;// setCaptionToDates();
1572 } 1568 }
1573 1569
1574} 1570}
1575 1571
1576void MainWindow::fillFilterMenu() 1572void MainWindow::fillFilterMenu()
1577{ 1573{
1578 selectFilterMenu->clear(); 1574 selectFilterMenu->clear();
1579 bool disable = false; 1575 bool disable = false;
1580 if ( mView->filterView()->filtersEnabled() ) { 1576 if ( mView->filterView()->filtersEnabled() ) {
1581 selectFilterMenu->insertItem(i18n ( "Turn filter off" ), 0 ); 1577 selectFilterMenu->insertItem(i18n ( "Turn filter off" ), 0 );
1582 } 1578 }
1583 else { 1579 else {
1584 selectFilterMenu->insertItem(i18n ( "Turn filter on" ), 0 ); 1580 selectFilterMenu->insertItem(i18n ( "Turn filter on" ), 0 );
1585 disable = true; 1581 disable = true;
1586 } 1582 }
1587 selectFilterMenu->insertSeparator(); 1583 selectFilterMenu->insertSeparator();
1588 QPtrList<CalFilter> fili = mView->filters(); 1584 QPtrList<CalFilter> fili = mView->filters();
1589 CalFilter *curfilter = mView->filterView()->selectedFilter(); 1585 CalFilter *curfilter = mView->filterView()->selectedFilter();
1590 CalFilter *filter = fili.first(); 1586 CalFilter *filter = fili.first();
1591 int iii = 1; 1587 int iii = 1;
1592 while(filter) { 1588 while(filter) {
1593 selectFilterMenu->insertItem( filter->name(), iii ); 1589 selectFilterMenu->insertItem( filter->name(), iii );
1594 if ( filter == curfilter) 1590 if ( filter == curfilter)
1595 selectFilterMenu->setItemChecked( iii, true ); 1591 selectFilterMenu->setItemChecked( iii, true );
1596 if ( disable ) 1592 if ( disable )
1597 selectFilterMenu->setItemEnabled( iii, false ); 1593 selectFilterMenu->setItemEnabled( iii, false );
1598 filter = fili.next(); 1594 filter = fili.next();
1599 ++iii; 1595 ++iii;
1600 } 1596 }
1601} 1597}
1602void MainWindow::selectFilter( int fil ) 1598void MainWindow::selectFilter( int fil )
1603{ 1599{
1604 if ( fil == 0 ) { 1600 if ( fil == 0 ) {
1605 mView->toggleFilerEnabled( ); 1601 mView->toggleFilerEnabled( );
1606 } else { 1602 } else {
1607 mView->selectFilter( fil-1 ); 1603 mView->selectFilter( fil-1 );
1608 } 1604 }
1609} 1605}
1610void MainWindow::configureToolBar( int item ) 1606void MainWindow::configureToolBar( int item )
1611{ 1607{
1612 1608
1613 configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) ); 1609 configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) );
1614 KOPrefs *p = KOPrefs::instance(); 1610 KOPrefs *p = KOPrefs::instance();
1615 p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 ); 1611 p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 );
1616 p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 ); 1612 p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 );
1617 p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 ); 1613 p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 );
1618 p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 ); 1614 p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 );
1619 p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 ); 1615 p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 );
1620 p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 ); 1616 p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 );
1621 p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 ); 1617 p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 );
1622 p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 ); 1618 p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 );
1623 p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 ); 1619 p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 );
1624 p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 ); 1620 p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 );
1625 p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 ); 1621 p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 );
1626 p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 ); 1622 p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 );
1627 p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 ); 1623 p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 );
1628 p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 ); 1624 p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 );
1629 p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 ); 1625 p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 );
1630 p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 ); 1626 p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 );
1631 p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 ); 1627 p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 );
1632 p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 ); 1628 p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 );
1633 p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 ); 1629 p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 );
1634 // initActions(); 1630 // initActions();
1635} 1631}
1636 1632
1637void MainWindow::setCaptionToDates() 1633void MainWindow::setCaptionToDates()
1638{ 1634{
1639 QString selDates; 1635 QString selDates;
1640 selDates = KGlobal::locale()->formatDate(mView->startDate(), true); 1636 selDates = KGlobal::locale()->formatDate(mView->startDate(), true);
1641 if (mView->startDate() < mView->endDate() ) 1637 if (mView->startDate() < mView->endDate() )
1642 selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true); 1638 selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true);
1643 setCaption( i18n("Dates: ") + selDates ); 1639 setCaption( i18n("Dates: ") + selDates );
1644 1640
1645} 1641}
1646// parameter item == 0: reinit 1642// parameter item == 0: reinit
1647void MainWindow::configureAgenda( int item ) 1643void MainWindow::configureAgenda( int item )
1648{ 1644{
1649 1645
1650 KOPrefs *p = KOPrefs::instance(); 1646 KOPrefs *p = KOPrefs::instance();
1651 1647
1652 int i; 1648 int i;
1653 if ( item == 1 ) { 1649 if ( item == 1 ) {
1654 mView->toggleAllDaySize(); 1650 mView->toggleAllDaySize();
1655 return; 1651 return;
1656 } 1652 }
1657 // do not allow 4 for widgets higher than 480 1653 // do not allow 4 for widgets higher than 480
1658 // if ( QApplication::desktop()->height() > 480 ) { 1654 // if ( QApplication::desktop()->height() > 480 ) {
1659// if ( item == 4 ) 1655// if ( item == 4 )
1660// item = 6; 1656// item = 6;
1661// } 1657// }
1662 for ( i = 4; i <= 18; i= i+2 ) 1658 for ( i = 4; i <= 18; i= i+2 )
1663 configureAgendaMenu->setItemChecked( i, false ); 1659 configureAgendaMenu->setItemChecked( i, false );
1664 configureAgendaMenu->setItemChecked( item, true ); 1660 configureAgendaMenu->setItemChecked( item, true );
1665 if ( p->mHourSize == item ) 1661 if ( p->mHourSize == item )
1666 return; 1662 return;
1667 p->mHourSize=item; 1663 p->mHourSize=item;
1668 mView->viewManager()->agendaView()->updateConfig(); 1664 mView->viewManager()->agendaView()->updateConfig();
1669} 1665}
1670 1666
1671void MainWindow::saveCalendar() 1667void MainWindow::saveCalendar()
1672{ 1668{
1673 QString fn = KOPrefs::instance()->mLastSaveFile; 1669 QString fn = KOPrefs::instance()->mLastSaveFile;
1674 fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this ); 1670 fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this );
1675 1671
1676 if ( fn == "" ) 1672 if ( fn == "" )
1677 return; 1673 return;
1678 QFileInfo info; 1674 QFileInfo info;
1679 info.setFile( fn ); 1675 info.setFile( fn );
1680 QString mes; 1676 QString mes;
1681 bool createbup = true; 1677 bool createbup = true;
1682 if ( info. exists() ) { 1678 if ( info. exists() ) {
1683 mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ; 1679 mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ;
1684 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 1680 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
1685 i18n("Overwrite!"), i18n("Cancel"), 0, 1681 i18n("Overwrite!"), i18n("Cancel"), 0,
1686 0, 1 ); 1682 0, 1 );
1687 if ( result != 0 ) { 1683 if ( result != 0 ) {
1688 createbup = false; 1684 createbup = false;
1689 } 1685 }
1690 } 1686 }
1691 if ( createbup ) { 1687 if ( createbup ) {
1692 mView->saveCalendar( fn ); 1688 mView->saveCalendar( fn );
1693 mes = i18n("KO/Pi:Saved %1").arg(fn); 1689 mes = i18n("KO/Pi:Saved %1").arg(fn);
1694 KOPrefs::instance()->mLastSaveFile = fn; 1690 KOPrefs::instance()->mLastSaveFile = fn;
1695 setCaption(mes); 1691 setCaption(mes);
1696 } 1692 }
1697} 1693}
1698void MainWindow::loadCalendar() 1694void MainWindow::loadCalendar()
1699{ 1695{
1700 1696
1701 QString fn = KOPrefs::instance()->mLastLoadFile; 1697 QString fn = KOPrefs::instance()->mLastLoadFile;
1702 fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this ); 1698 fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this );
1703 1699
1704 if ( fn == "" ) 1700 if ( fn == "" )
1705 return; 1701 return;
1706 QFileInfo info; 1702 QFileInfo info;
1707 info.setFile( fn ); 1703 info.setFile( fn );
1708 QString mess; 1704 QString mess;
1709 bool loadbup = true; 1705 bool loadbup = true;
1710 if ( info. exists() ) { 1706 if ( info. exists() ) {
1711 mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 1707 mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
1712 int result = QMessageBox::warning( this, "KO/Pi: Warning!", 1708 int result = QMessageBox::warning( this, "KO/Pi: Warning!",
1713 mess, 1709 mess,
1714 i18n("Load!"), i18n("Cancel"), 0, 1710 i18n("Load!"), i18n("Cancel"), 0,
1715 0, 1 ); 1711 0, 1 );
1716 if ( result != 0 ) { 1712 if ( result != 0 ) {
1717 loadbup = false; 1713 loadbup = false;
1718 } 1714 }
1719 } else { 1715 } else {
1720 QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1716 QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1721 i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0, 1717 i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0,
1722 0, 1 ); 1718 0, 1 );
1723 1719
1724 return; 1720 return;
1725 } 1721 }
1726 if ( loadbup ) { 1722 if ( loadbup ) {
1727 mView->openCalendar( fn ); 1723 mView->openCalendar( fn );
1728 KOPrefs::instance()->mLastLoadFile = fn; 1724 KOPrefs::instance()->mLastLoadFile = fn;
1729 mess = i18n("KO/Pi:Loaded %1").arg(fn) ; 1725 mess = i18n("KO/Pi:Loaded %1").arg(fn) ;
1730 setCaption(mess); 1726 setCaption(mess);
1731 } 1727 }
1732 1728
1733} 1729}
1734void MainWindow::quickImportIcal() 1730void MainWindow::quickImportIcal()
1735{ 1731{
1736 importFile( KOPrefs::instance()->mLastImportFile, false ); 1732 importFile( KOPrefs::instance()->mLastImportFile, false );
1737} 1733}
1738void MainWindow::importFile( QString fn, bool quick ) 1734void MainWindow::importFile( QString fn, bool quick )
1739{ 1735{
1740 QFileInfo info; 1736 QFileInfo info;
1741 info.setFile( fn ); 1737 info.setFile( fn );
1742 QString mess; 1738 QString mess;
1743 bool loadbup = true; 1739 bool loadbup = true;
1744 if ( !info. exists() ) { 1740 if ( !info. exists() ) {
1745 mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30)); 1741 mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30));
1746 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1742 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1747 mess ); 1743 mess );
1748 return; 1744 return;
1749 } 1745 }
1750 int result = 0; 1746 int result = 0;
1751 if ( !quick ) { 1747 if ( !quick ) {
1752 mess = i18n( "Import file \n...%1\nfrom:\n%2\nDuplicated entries\nwill not be imported!\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 1748 mess = i18n( "Import file \n...%1\nfrom:\n%2\nDuplicated entries\nwill not be imported!\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
1753 result = QMessageBox::warning( this, "KO/Pi: Warning!", 1749 result = QMessageBox::warning( this, "KO/Pi: Warning!",
1754 mess, 1750 mess,
1755 "Import", "Cancel", 0, 1751 "Import", "Cancel", 0,
1756 0, 1 ); 1752 0, 1 );
1757 } 1753 }
1758 if ( result == 0 ) { 1754 if ( result == 0 ) {
1759 if ( mView->openCalendar( fn, true )) { 1755 if ( mView->openCalendar( fn, true )) {
1760 KOPrefs::instance()->mLastImportFile = fn; 1756 KOPrefs::instance()->mLastImportFile = fn;
1761 setCaption(i18n("Imported file successfully")); 1757 setCaption(i18n("Imported file successfully"));
1762 } else { 1758 } else {
1763 setCaption(i18n("Error importing file")); 1759 setCaption(i18n("Error importing file"));
1764 } 1760 }
1765 } 1761 }
1766} 1762}
1767 1763
1768void MainWindow::importIcal() 1764void MainWindow::importIcal()
1769{ 1765{
1770 1766
1771 QString fn =KOPrefs::instance()->mLastImportFile; 1767 QString fn =KOPrefs::instance()->mLastImportFile;
1772 1768
1773 fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this ); 1769 fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this );
1774 if ( fn == "" ) 1770 if ( fn == "" )
1775 return; 1771 return;
1776 importFile( fn, true ); 1772 importFile( fn, true );
1777 1773
1778} 1774}
1779 1775
1780void MainWindow::exportVCalendar() 1776void MainWindow::exportVCalendar()
1781{ 1777{
1782 QString fn = KOPrefs::instance()->mLastVcalFile; 1778 QString fn = KOPrefs::instance()->mLastVcalFile;
1783 fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); 1779 fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this );
1784 if ( fn == "" ) 1780 if ( fn == "" )
1785 return; 1781 return;
1786 QFileInfo info; 1782 QFileInfo info;
1787 info.setFile( fn ); 1783 info.setFile( fn );
1788 QString mes; 1784 QString mes;
1789 bool createbup = true; 1785 bool createbup = true;
1790 if ( info. exists() ) { 1786 if ( info. exists() ) {
1791 mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); 1787 mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) );
1792 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 1788 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
1793 i18n("Overwrite!"), i18n("Cancel"), 0, 1789 i18n("Overwrite!"), i18n("Cancel"), 0,
1794 0, 1 ); 1790 0, 1 );
1795 if ( result != 0 ) { 1791 if ( result != 0 ) {
1796 createbup = false; 1792 createbup = false;
1797 } 1793 }
1798 } 1794 }
1799 if ( createbup ) { 1795 if ( createbup ) {
1800 if ( mView->exportVCalendar( fn ) ) { 1796 if ( mView->exportVCalendar( fn ) ) {
1801 KOPrefs::instance()->mLastVcalFile = fn; 1797 KOPrefs::instance()->mLastVcalFile = fn;
1802 if ( fn.length() > 20 ) 1798 if ( fn.length() > 20 )
1803 mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ; 1799 mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ;
1804 else 1800 else
1805 mes = i18n("KO/Pi:Exported to %1").arg(fn ); 1801 mes = i18n("KO/Pi:Exported to %1").arg(fn );
1806 setCaption(mes); 1802 setCaption(mes);
1807 } 1803 }
1808 } 1804 }
1809 1805
1810} 1806}
1811 1807
1812void MainWindow::syncFileRequest() 1808void MainWindow::syncFileRequest()
1813{ 1809{
1814 save(); 1810 save();
1815} 1811}
1816void MainWindow::getFile( bool success ) 1812void MainWindow::getFile( bool success )
1817{ 1813{
1818 if ( ! success ) { 1814 if ( ! success ) {
1819 setCaption( i18n("Error receiving file. Nothing changed!") ); 1815 setCaption( i18n("Error receiving file. Nothing changed!") );
1820 return; 1816 return;
1821 } 1817 }
1822 mView->openCalendar( defaultFileName() ); 1818 mView->openCalendar( defaultFileName() );
1823 setCaption( i18n("Pi-Sync successful!") ); 1819 setCaption( i18n("Pi-Sync successful!") );
1824} 1820}
1825 1821
1826void MainWindow::printSel( ) 1822void MainWindow::printSel( )
1827{ 1823{
1828 mView->viewManager()->agendaView()->agenda()->printSelection(); 1824 mView->viewManager()->agendaView()->agenda()->printSelection();
1829} 1825}
1830 1826
1831void MainWindow::printCal() 1827void MainWindow::printCal()
1832{ 1828{
1833 mView->print();//mCp->showDialog(); 1829 mView->print();//mCp->showDialog();
1834} 1830}
1835 1831
diff --git a/korganizer/mainwindow.h b/korganizer/mainwindow.h
index ee7bd87..e3383ed 100644
--- a/korganizer/mainwindow.h
+++ b/korganizer/mainwindow.h
@@ -1,130 +1,128 @@
1#ifndef KORGE_MAINWINDOW_H 1#ifndef KORGE_MAINWINDOW_H
2#define KORGE_MAINWINDOW_H 2#define KORGE_MAINWINDOW_H
3 3
4#include <qmainwindow.h> 4#include <qmainwindow.h>
5#include <qtimer.h> 5#include <qtimer.h>
6#include <qdict.h> 6#include <qdict.h>
7#include <qfile.h> 7#include <qfile.h>
8#include <qtextstream.h> 8#include <qtextstream.h>
9#include <qregexp.h> 9#include <qregexp.h>
10 10
11#include <libkcal/incidence.h> 11#include <libkcal/incidence.h>
12#include "simplealarmclient.h" 12#include "simplealarmclient.h"
13#include <ksyncmanager.h> 13#include <ksyncmanager.h>
14 14
15class QAction; 15class QAction;
16class CalendarView; 16class CalendarView;
17class KSyncProfile; 17class KSyncProfile;
18#ifdef DESKTOP_VERSION 18#ifdef DESKTOP_VERSION
19 19
20#define QPEToolBar QToolBar 20#define QPEToolBar QToolBar
21#define QPEMenuBar QMenuBar 21#define QPEMenuBar QMenuBar
22#endif 22#endif
23class QPEToolBar; 23class QPEToolBar;
24 24
25 25
26namespace KCal { 26namespace KCal {
27class CalendarLocal; 27class CalendarLocal;
28} 28}
29 29
30using namespace KCal; 30using namespace KCal;
31 31
32class MainWindow : public QMainWindow 32class MainWindow : public QMainWindow
33{ 33{
34 Q_OBJECT 34 Q_OBJECT
35 public: 35 public:
36 MainWindow( QWidget *parent = 0, const char *name = 0, QString command = ""); 36 MainWindow( QWidget *parent = 0, const char *name = 0, QString command = "");
37 ~MainWindow(); 37 ~MainWindow();
38 public slots: 38 public slots:
39 virtual void showMaximized (); 39 virtual void showMaximized ();
40 void configureAgenda( int ); 40 void configureAgenda( int );
41 void recieve( const QCString& msg, const QByteArray& data ); 41 void recieve( const QCString& msg, const QByteArray& data );
42 static QString defaultFileName(); 42 static QString defaultFileName();
43 static QString syncFileName(); 43 static QString syncFileName();
44 static QString resourcePath(); 44 static QString resourcePath();
45 protected slots: 45 protected slots:
46 void setCaptionToDates(); 46 void setCaptionToDates();
47 void about(); 47 void about();
48 void licence(); 48 void licence();
49 void faq(); 49 void faq();
50 void usertrans(); 50 void usertrans();
51 void features(); 51 void features();
52 void synchowto(); 52 void synchowto();
53 void whatsNew(); 53 void whatsNew();
54 void keyBindings(); 54 void keyBindings();
55 void aboutAutoSaving();; 55 void aboutAutoSaving();;
56 void aboutKnownBugs(); 56 void aboutKnownBugs();
57 57
58 void processIncidenceSelection( Incidence * ); 58 void processIncidenceSelection( Incidence * );
59 59
60 void importQtopia(); 60 void importQtopia();
61 void importBday(); 61 void importBday();
62 void importOL(); 62 void importOL();
63 void importIcal(); 63 void importIcal();
64 void importFile( QString, bool ); 64 void importFile( QString, bool );
65 void quickImportIcal(); 65 void quickImportIcal();
66 66
67 void slotModifiedChanged( bool ); 67 void slotModifiedChanged( bool );
68 68
69 void save(); 69 void save();
70 void configureToolBar( int ); 70 void configureToolBar( int );
71 void printSel(); 71 void printSel();
72 void printCal(); 72 void printCal();
73 void saveCalendar(); 73 void saveCalendar();
74 void loadCalendar(); 74 void loadCalendar();
75 void exportVCalendar(); 75 void exportVCalendar();
76 void fillFilterMenu(); 76 void fillFilterMenu();
77 void selectFilter( int ); 77 void selectFilter( int );
78 void exportToPhone( int ); 78 void exportToPhone( int );
79 79
80 80
81 protected: 81 protected:
82 void displayText( QString, QString); 82 void displayText( QString, QString);
83 void displayFile( QString, QString); 83 void displayFile( QString, QString);
84 84
85 void enableIncidenceActions( bool ); 85 void enableIncidenceActions( bool );
86 86
87 private slots: 87 private slots:
88 QSocket* piSocket; 88 QSocket* piSocket;
89 QString piFileString; 89 QString piFileString;
90 QTime piTime; 90 QTime piTime;
91 void getFile( bool ); 91 void getFile( bool );
92 void syncFileRequest(); 92 void syncFileRequest();
93 private: 93 private:
94 KSyncManager* mSyncManager; 94 KSyncManager* mSyncManager;
95 //QTimer* mTimerCommandSocket;
96 KServerSocket * mServerSocket;
97 bool mClosed; 95 bool mClosed;
98 void saveOnClose(); 96 void saveOnClose();
99 bool mFlagKeyPressed; 97 bool mFlagKeyPressed;
100 bool mBlockAtStartup; 98 bool mBlockAtStartup;
101 QPEToolBar *iconToolBar; 99 QPEToolBar *iconToolBar;
102 void initActions(); 100 void initActions();
103 void setDefaultPreferences(); 101 void setDefaultPreferences();
104 void keyPressEvent ( QKeyEvent * ) ; 102 void keyPressEvent ( QKeyEvent * ) ;
105 void keyReleaseEvent ( QKeyEvent * ) ; 103 void keyReleaseEvent ( QKeyEvent * ) ;
106 QPopupMenu *configureToolBarMenu; 104 QPopupMenu *configureToolBarMenu;
107 QPopupMenu *selectFilterMenu; 105 QPopupMenu *selectFilterMenu;
108 QPopupMenu *configureAgendaMenu, *syncMenu; 106 QPopupMenu *configureAgendaMenu, *syncMenu;
109 CalendarLocal *mCalendar; 107 CalendarLocal *mCalendar;
110 CalendarView *mView; 108 CalendarView *mView;
111 QAction *mNewSubTodoAction; 109 QAction *mNewSubTodoAction;
112 110
113 QAction *mShowAction; 111 QAction *mShowAction;
114 QAction *mEditAction; 112 QAction *mEditAction;
115 QAction *mDeleteAction; 113 QAction *mDeleteAction;
116 QAction *mCloneAction; 114 QAction *mCloneAction;
117 QAction *mMoveAction; 115 QAction *mMoveAction;
118 QAction *mBeamAction; 116 QAction *mBeamAction;
119 QAction *mCancelAction; 117 QAction *mCancelAction;
120 118
121 void closeEvent( QCloseEvent* ce ); 119 void closeEvent( QCloseEvent* ce );
122 SimpleAlarmClient mAlarmClient; 120 SimpleAlarmClient mAlarmClient;
123 QTimer mSaveTimer; 121 QTimer mSaveTimer;
124 //bool mBlockSaveFlag; 122 //bool mBlockSaveFlag;
125 bool mCalendarModifiedFlag; 123 bool mCalendarModifiedFlag;
126 QPixmap loadPixmap( QString ); 124 QPixmap loadPixmap( QString );
127}; 125};
128 126
129 127
130#endif 128#endif
diff --git a/libkdepim/kpimglobalprefs.cpp b/libkdepim/kpimglobalprefs.cpp
index b71e18d..5081b26 100644
--- a/libkdepim/kpimglobalprefs.cpp
+++ b/libkdepim/kpimglobalprefs.cpp
@@ -1,140 +1,138 @@
1/* 1/*
2 This file is part of libkdepim. 2 This file is part of libkdepim.
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/* 24/*
25Enhanced Version of the file for platform independent KDE tools. 25Enhanced Version of the file for platform independent KDE tools.
26Copyright (c) 2004 Ulf Schenk 26Copyright (c) 2004 Ulf Schenk
27 27
28$Id$ 28$Id$
29*/ 29*/
30 30
31#include <kglobal.h> 31#include <kglobal.h>
32#include <kconfig.h> 32#include <kconfig.h>
33#include <klocale.h> 33#include <klocale.h>
34#include <kdebug.h> 34#include <kdebug.h>
35#include <kstaticdeleter.h> 35#include <kstaticdeleter.h>
36 36
37#include <qregexp.h> 37#include <qregexp.h>
38#include "kpimglobalprefs.h" 38#include "kpimglobalprefs.h"
39 39
40KPimGlobalPrefs *KPimGlobalPrefs::sInstance = 0; 40KPimGlobalPrefs *KPimGlobalPrefs::sInstance = 0;
41static KStaticDeleter<KPimGlobalPrefs> staticDeleter; 41static KStaticDeleter<KPimGlobalPrefs> staticDeleter;
42 42
43 43
44KPimGlobalPrefs::KPimGlobalPrefs( const QString &name ) 44KPimGlobalPrefs::KPimGlobalPrefs( const QString &name )
45 : KPrefs("microkdeglobalrc") 45 : KPrefs("microkdeglobalrc")
46{ 46{
47 47
48 KPrefs::setCurrentGroup("Locale"); 48 KPrefs::setCurrentGroup("Locale");
49 addItemInt("PreferredLanguage",&mPreferredLanguage,0); 49 addItemInt("PreferredLanguage",&mPreferredLanguage,0);
50 addItemInt("PreferredTime",&mPreferredTime,0); 50 addItemInt("PreferredTime",&mPreferredTime,0);
51 addItemInt("PreferredDate",&mPreferredDate,0); 51 addItemInt("PreferredDate",&mPreferredDate,0);
52 addItemBool("WeekStartsOnSunday",&mWeekStartsOnSunday,false); 52 addItemBool("WeekStartsOnSunday",&mWeekStartsOnSunday,false);
53 //addItemBool("QuickSavingWOUnicode",&mUseQuicksave,false); 53 //addItemBool("QuickSavingWOUnicode",&mUseQuicksave,false);
54 // addItemBool("ShortDateInViewer",&mShortDateInViewer,false); 54 // addItemBool("ShortDateInViewer",&mShortDateInViewer,false);
55 addItemString("UserDateFormatLong", &mUserDateFormatLong, "%A %d %b %y"); 55 addItemString("UserDateFormatLong", &mUserDateFormatLong, "%A %d %b %y");
56 addItemString("UserDateFormatShort", &mUserDateFormatShort, "%aK %d.%m.%y"); 56 addItemString("UserDateFormatShort", &mUserDateFormatShort, "%aK %d.%m.%y");
57 57
58 KPrefs::setCurrentGroup("Time & Date"); 58 KPrefs::setCurrentGroup("Time & Date");
59 59
60 addItemString("TimeZoneName",&mTimeZoneId,i18n ("+01:00 Europe/Oslo(CET)") ); 60 addItemString("TimeZoneName",&mTimeZoneId,i18n ("+01:00 Europe/Oslo(CET)") );
61 addItemBool("UseDaylightsaving",&mUseDaylightsaving,true); 61 addItemBool("UseDaylightsaving",&mUseDaylightsaving,true);
62 addItemInt("DaylightsavingStart",&mDaylightsavingStart,90); 62 addItemInt("DaylightsavingStart",&mDaylightsavingStart,90);
63 addItemInt("DaylightsavingEnd",&mDaylightsavingEnd,304); 63 addItemInt("DaylightsavingEnd",&mDaylightsavingEnd,304);
64 64
65
66
67
68 KPrefs::setCurrentGroup( "ExternalApplications" ); 65 KPrefs::setCurrentGroup( "ExternalApplications" );
69 66
70 addItemInt( "EmailChannelType", &mEmailClient, OMPI_EMC ); 67 addItemInt( "EmailChannelType", &mEmailClient, OMPI_EMC );
71 addItemString( "EmailChannel", &mEmailOtherChannel, "" ); 68 addItemString( "EmailChannel", &mEmailOtherChannel, "" );
72 addItemString( "EmailChannelMessage", &mEmailOtherMessage, "" ); 69 addItemString( "EmailChannelMessage", &mEmailOtherMessage, "" );
73 addItemString( "EmailChannelParameters", &mEmailOtherMessageParameters, "" ); 70 addItemString( "EmailChannelParameters", &mEmailOtherMessageParameters, "" );
74 addItemString( "EmailChannelMessage2", &mEmailOtherMessage2, "" ); 71 addItemString( "EmailChannelMessage2", &mEmailOtherMessage2, "" );
75 addItemString( "EmailChannelParameters2", &mEmailOtherMessageParameters2, "" ); 72 addItemString( "EmailChannelParameters2", &mEmailOtherMessageParameters2, "" );
76 73
77 addItemInt( "PhoneChannelType", &mPhoneClient, KPPI_PHC ); 74 addItemInt( "PhoneChannelType", &mPhoneClient, KPPI_PHC );
78 addItemString( "PhoneChannel", &mPhoneOtherChannel, "" ); 75 addItemString( "PhoneChannel", &mPhoneOtherChannel, "" );
79 addItemString( "PhoneChannelMessage", &mPhoneOtherMessage, "" ); 76 addItemString( "PhoneChannelMessage", &mPhoneOtherMessage, "" );
80 addItemString( "PhoneChannelParameters", &mPhoneOtherMessageParameters, "" ); 77 addItemString( "PhoneChannelParameters", &mPhoneOtherMessageParameters, "" );
81 78
82 addItemInt( "FaxChannelType", &mFaxClient, NONE_FAC ); 79 addItemInt( "FaxChannelType", &mFaxClient, NONE_FAC );
83 addItemString( "FaxChannel", &mFaxOtherChannel, "" ); 80 addItemString( "FaxChannel", &mFaxOtherChannel, "" );
84 addItemString( "FaxChannelMessage", &mFaxOtherMessage, "" ); 81 addItemString( "FaxChannelMessage", &mFaxOtherMessage, "" );
85 addItemString( "FaxChannelParameters", &mFaxOtherMessageParameters, "" ); 82 addItemString( "FaxChannelParameters", &mFaxOtherMessageParameters, "" );
86 83
87 addItemInt( "SMSChannelType", &mSMSClient, NONE_SMC ); 84 addItemInt( "SMSChannelType", &mSMSClient, NONE_SMC );
88 addItemString( "SMSChannel", &mSMSOtherChannel, "" ); 85 addItemString( "SMSChannel", &mSMSOtherChannel, "" );
89 addItemString( "SMSChannelMessage", &mSMSOtherMessage, "" ); 86 addItemString( "SMSChannelMessage", &mSMSOtherMessage, "" );
90 addItemString( "SMSChannelParameters", &mSMSOtherMessageParameters, "" ); 87 addItemString( "SMSChannelParameters", &mSMSOtherMessageParameters, "" );
91 88
92 addItemInt( "PagerChannelType", &mPagerClient, NONE_PAC ); 89 addItemInt( "PagerChannelType", &mPagerClient, NONE_PAC );
93 addItemString( "PagerChannel", &mPagerOtherChannel, "" ); 90 addItemString( "PagerChannel", &mPagerOtherChannel, "" );
94 addItemString( "PagerChannelMessage", &mPagerOtherMessage, "" ); 91 addItemString( "PagerChannelMessage", &mPagerOtherMessage, "" );
95 addItemString( "PagerChannelParameters", &mPagerOtherMessageParameters, "" ); 92 addItemString( "PagerChannelParameters", &mPagerOtherMessageParameters, "" );
96 93
97 addItemInt( "SIPChannelType", &mSipClient, NONE_SIC ); 94 addItemInt( "SIPChannelType", &mSipClient, NONE_SIC );
98 addItemString( "SIPChannel", &mSipOtherChannel, "" ); 95 addItemString( "SIPChannel", &mSipOtherChannel, "" );
99 addItemString( "SIPChannelMessage", &mSipOtherMessage, "" ); 96 addItemString( "SIPChannelMessage", &mSipOtherMessage, "" );
100 addItemString( "SIPChannelParameters", &mSipOtherMessageParameters, "" ); 97 addItemString( "SIPChannelParameters", &mSipOtherMessageParameters, "" );
101 98
102
103 KPrefs::setCurrentGroup( "PhoneAccess" ); 99 KPrefs::setCurrentGroup( "PhoneAccess" );
104 addItemString("Ex2PhoneDevice",&mEx2PhoneDevice,"/dev/ircomm"); 100 addItemString("Ex2PhoneDevice",&mEx2PhoneDevice,"/dev/ircomm");
105 addItemString("Ex2PhoneConnection",&mEx2PhoneConnection,"irda"); 101 addItemString("Ex2PhoneConnection",&mEx2PhoneConnection,"irda");
106 addItemString("Ex2PhoneModel",&mEx2PhoneModel,"6310i"); 102 addItemString("Ex2PhoneModel",&mEx2PhoneModel,"6310i");
107 103
108
109} 104}
110 105
106
111void KPimGlobalPrefs::setGlobalConfig() 107void KPimGlobalPrefs::setGlobalConfig()
112{ 108{
113 109
114 KGlobal::locale()->setHore24Format( !mPreferredTime ); 110 KGlobal::locale()->setHore24Format( !mPreferredTime );
115 KGlobal::locale()->setWeekStartMonday( !mWeekStartsOnSunday ); 111 KGlobal::locale()->setWeekStartMonday( !mWeekStartsOnSunday );
116 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)mPreferredDate ); 112 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)mPreferredDate );
117 KGlobal::locale()->setLanguage( mPreferredLanguage ); 113 KGlobal::locale()->setLanguage( mPreferredLanguage );
118 QString dummy = mUserDateFormatLong; 114 QString dummy = mUserDateFormatLong;
119 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); 115 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") ));
120 dummy = mUserDateFormatShort; 116 dummy = mUserDateFormatShort;
121 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); 117 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") ));
122 KGlobal::locale()->setDaylightSaving( mUseDaylightsaving, 118 KGlobal::locale()->setDaylightSaving( mUseDaylightsaving,
123 mDaylightsavingStart, 119 mDaylightsavingStart,
124 mDaylightsavingEnd ); 120 mDaylightsavingEnd );
125 KGlobal::locale()->setTimezone( mTimeZoneId ); 121 KGlobal::locale()->setTimezone( mTimeZoneId );
126 122
127} 123}
128KPimGlobalPrefs::~KPimGlobalPrefs() 124KPimGlobalPrefs::~KPimGlobalPrefs()
129{ 125{
126 //qDebug("KPimGlobalPrefs::~KPimGlobalPrefs() ");
127 writeConfig();
130} 128}
131 129
132KPimGlobalPrefs *KPimGlobalPrefs::instance() 130KPimGlobalPrefs *KPimGlobalPrefs::instance()
133{ 131{
134 if ( !sInstance ) { 132 if ( !sInstance ) {
135 sInstance = staticDeleter.setObject( new KPimGlobalPrefs() ); 133 sInstance = staticDeleter.setObject( new KPimGlobalPrefs() );
136 sInstance->readConfig(); 134 sInstance->readConfig();
137 } 135 }
138 136
139 return sInstance; 137 return sInstance;
140} 138}
diff --git a/microkde/kstaticdeleter.h b/microkde/kstaticdeleter.h
index 190f3e4..dfd3929 100644
--- a/microkde/kstaticdeleter.h
+++ b/microkde/kstaticdeleter.h
@@ -1,35 +1,37 @@
1/* 1/*
2 * This file is part of the KDE Libraries 2 * This file is part of the KDE Libraries
3 * Copyright (C) 2000 Stephan Kulow <coolo@kde.org> 3 * Copyright (C) 2000 Stephan Kulow <coolo@kde.org>
4 * 2001 KDE Team 4 * 2001 KDE Team
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
23#ifndef _KSTATIC_DELETER_H_ 23#ifndef _KSTATIC_DELETER_H_
24#define _KSTATIC_DELETER_H_ 24#define _KSTATIC_DELETER_H_
25 25
26template<class type> 26template<class type>
27class KStaticDeleter 27class KStaticDeleter
28{ 28{
29 public: 29 public:
30 KStaticDeleter() {}; 30 KStaticDeleter() {};
31 type *setObject( type *obj, bool isArray = false) { return obj; } 31 type *setObject( type *obj, bool isArray = false) { _mobj = obj;return obj; }
32 virtual ~KStaticDeleter() {}; 32 virtual ~KStaticDeleter() {delete _mobj;};
33 private:
34 type* _mobj;
33}; 35};
34 36
35#endif 37#endif