author | zautrix <zautrix> | 2005-01-18 09:31:59 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-01-18 09:31:59 (UTC) |
commit | 2d6776d79732f6771885a549de5c37f9e75f7641 (patch) (unidiff) | |
tree | 5dc2abf48a99e2a35f8e1458f731b3ef9210ac7e | |
parent | 522486966ecf041a6e49913b6e420d58d4284837 (diff) | |
download | kdepimpi-2d6776d79732f6771885a549de5c37f9e75f7641.zip kdepimpi-2d6776d79732f6771885a549de5c37f9e75f7641.tar.gz kdepimpi-2d6776d79732f6771885a549de5c37f9e75f7641.tar.bz2 |
fixed merging
-rw-r--r-- | kabc/addressee.cpp | 111 | ||||
-rw-r--r-- | kabc/plugins/sharpdtm/sharpdtmconverter.cpp | 20 | ||||
-rw-r--r-- | kaddressbook/kabcore.cpp | 32 |
3 files changed, 94 insertions, 69 deletions
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp index 3b238f5..82b4b9b 100644 --- a/kabc/addressee.cpp +++ b/kabc/addressee.cpp | |||
@@ -1,1942 +1,1953 @@ | |||
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 | /* |
23 | Enhanced Version of the file for platform independent KDE tools. | 23 | Enhanced Version of the file for platform independent KDE tools. |
24 | Copyright (c) 2004 Ulf Schenk | 24 | Copyright (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 | ||
43 | using namespace KABC; | 43 | using namespace KABC; |
44 | 44 | ||
45 | static bool matchBinaryPattern( int value, int pattern ); | 45 | static bool matchBinaryPattern( int value, int pattern ); |
46 | static bool matchBinaryPatternA( int value, int pattern ); | 46 | static bool matchBinaryPatternA( int value, int pattern ); |
47 | static bool matchBinaryPatternP( int value, int pattern ); | 47 | static bool matchBinaryPatternP( int value, int pattern ); |
48 | 48 | ||
49 | struct Addressee::AddresseeData : public KShared | 49 | struct 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 | bool tagged :1; | 91 | bool tagged :1; |
92 | }; | 92 | }; |
93 | 93 | ||
94 | Addressee::Addressee() | 94 | Addressee::Addressee() |
95 | { | 95 | { |
96 | mData = new AddresseeData; | 96 | mData = new AddresseeData; |
97 | mData->empty = true; | 97 | mData->empty = true; |
98 | mData->changed = false; | 98 | mData->changed = false; |
99 | mData->resource = 0; | 99 | mData->resource = 0; |
100 | mData->mExternalId = ":"; | 100 | mData->mExternalId = ":"; |
101 | mData->revision = QDateTime ( QDate( 2003,1,1)); | 101 | mData->revision = QDateTime ( QDate( 2003,1,1)); |
102 | mData->mTempSyncStat = SYNC_TEMPSTATE_INITIAL; | 102 | mData->mTempSyncStat = SYNC_TEMPSTATE_INITIAL; |
103 | } | 103 | } |
104 | 104 | ||
105 | Addressee::~Addressee() | 105 | Addressee::~Addressee() |
106 | { | 106 | { |
107 | } | 107 | } |
108 | 108 | ||
109 | Addressee::Addressee( const Addressee &a ) | 109 | Addressee::Addressee( const Addressee &a ) |
110 | { | 110 | { |
111 | mData = a.mData; | 111 | mData = a.mData; |
112 | } | 112 | } |
113 | 113 | ||
114 | Addressee &Addressee::operator=( const Addressee &a ) | 114 | Addressee &Addressee::operator=( const Addressee &a ) |
115 | { | 115 | { |
116 | mData = a.mData; | 116 | mData = a.mData; |
117 | return (*this); | 117 | return (*this); |
118 | } | 118 | } |
119 | 119 | ||
120 | Addressee Addressee::copy() | 120 | Addressee Addressee::copy() |
121 | { | 121 | { |
122 | Addressee a; | 122 | Addressee a; |
123 | *(a.mData) = *mData; | 123 | *(a.mData) = *mData; |
124 | return a; | 124 | return a; |
125 | } | 125 | } |
126 | 126 | ||
127 | void Addressee::detach() | 127 | void Addressee::detach() |
128 | { | 128 | { |
129 | if ( mData.count() == 1 ) return; | 129 | if ( mData.count() == 1 ) return; |
130 | *this = copy(); | 130 | *this = copy(); |
131 | } | 131 | } |
132 | 132 | ||
133 | bool Addressee::operator==( const Addressee &a ) const | 133 | bool Addressee::operator==( const Addressee &a ) const |
134 | { | 134 | { |
135 | if ( uid() != a.uid() ) return false; | 135 | if ( uid() != a.uid() ) return false; |
136 | if ( mData->name != a.mData->name ) return false; | 136 | if ( mData->name != a.mData->name ) return false; |
137 | if ( mData->formattedName != a.mData->formattedName ) return false; | 137 | if ( mData->formattedName != a.mData->formattedName ) return false; |
138 | if ( mData->familyName != a.mData->familyName ) return false; | 138 | if ( mData->familyName != a.mData->familyName ) return false; |
139 | if ( mData->givenName != a.mData->givenName ) return false; | 139 | if ( mData->givenName != a.mData->givenName ) return false; |
140 | if ( mData->additionalName != a.mData->additionalName ) return false; | 140 | if ( mData->additionalName != a.mData->additionalName ) return false; |
141 | if ( mData->prefix != a.mData->prefix ) return false; | 141 | if ( mData->prefix != a.mData->prefix ) return false; |
142 | if ( mData->suffix != a.mData->suffix ) return false; | 142 | if ( mData->suffix != a.mData->suffix ) return false; |
143 | if ( mData->nickName != a.mData->nickName ) return false; | 143 | if ( mData->nickName != a.mData->nickName ) return false; |
144 | if ( mData->birthday != a.mData->birthday ) return false; | 144 | if ( mData->birthday != a.mData->birthday ) return false; |
145 | if ( mData->mailer != a.mData->mailer ) return false; | 145 | if ( mData->mailer != a.mData->mailer ) return false; |
146 | if ( mData->timeZone != a.mData->timeZone ) return false; | 146 | if ( mData->timeZone != a.mData->timeZone ) return false; |
147 | if ( mData->geo != a.mData->geo ) return false; | 147 | if ( mData->geo != a.mData->geo ) return false; |
148 | if ( mData->title != a.mData->title ) return false; | 148 | if ( mData->title != a.mData->title ) return false; |
149 | if ( mData->role != a.mData->role ) return false; | 149 | if ( mData->role != a.mData->role ) return false; |
150 | if ( mData->organization != a.mData->organization ) return false; | 150 | if ( mData->organization != a.mData->organization ) return false; |
151 | if ( mData->note != a.mData->note ) return false; | 151 | if ( mData->note != a.mData->note ) return false; |
152 | if ( mData->productId != a.mData->productId ) return false; | 152 | if ( mData->productId != a.mData->productId ) return false; |
153 | //if ( mData->revision != a.mData->revision ) return false; | 153 | //if ( mData->revision != a.mData->revision ) return false; |
154 | if ( mData->sortString != a.mData->sortString ) return false; | 154 | if ( mData->sortString != a.mData->sortString ) return false; |
155 | if ( mData->secrecy != a.mData->secrecy ) return false; | 155 | if ( mData->secrecy != a.mData->secrecy ) return false; |
156 | if ( mData->logo != a.mData->logo ) return false; | 156 | if ( mData->logo != a.mData->logo ) return false; |
157 | if ( mData->photo != a.mData->photo ) return false; | 157 | if ( mData->photo != a.mData->photo ) return false; |
158 | if ( mData->sound != a.mData->sound ) return false; | 158 | if ( mData->sound != a.mData->sound ) return false; |
159 | if ( mData->agent != a.mData->agent ) return false; | 159 | if ( mData->agent != a.mData->agent ) return false; |
160 | if ( ( mData->url.isValid() || a.mData->url.isValid() ) && | 160 | if ( ( mData->url.isValid() || a.mData->url.isValid() ) && |
161 | ( mData->url != a.mData->url ) ) return false; | 161 | ( mData->url != a.mData->url ) ) return false; |
162 | if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false; | 162 | if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false; |
163 | if ( mData->addresses != a.mData->addresses ) return false; | 163 | if ( mData->addresses != a.mData->addresses ) return false; |
164 | if ( mData->keys != a.mData->keys ) return false; | 164 | if ( mData->keys != a.mData->keys ) return false; |
165 | if ( mData->emails != a.mData->emails ) return false; | 165 | if ( mData->emails != a.mData->emails ) return false; |
166 | if ( mData->categories != a.mData->categories ) return false; | 166 | if ( mData->categories != a.mData->categories ) return false; |
167 | if ( mData->custom != a.mData->custom ) return false; | 167 | if ( mData->custom != a.mData->custom ) return false; |
168 | 168 | ||
169 | return true; | 169 | return true; |
170 | } | 170 | } |
171 | 171 | ||
172 | bool Addressee::operator!=( const Addressee &a ) const | 172 | bool Addressee::operator!=( const Addressee &a ) const |
173 | { | 173 | { |
174 | return !( a == *this ); | 174 | return !( a == *this ); |
175 | } | 175 | } |
176 | 176 | ||
177 | bool Addressee::isEmpty() const | 177 | bool Addressee::isEmpty() const |
178 | { | 178 | { |
179 | return mData->empty; | 179 | return mData->empty; |
180 | } | 180 | } |
181 | ulong Addressee::getCsum4List( const QStringList & attList) | 181 | ulong Addressee::getCsum4List( const QStringList & attList) |
182 | { | 182 | { |
183 | int max = attList.count(); | 183 | int max = attList.count(); |
184 | ulong cSum = 0; | 184 | ulong cSum = 0; |
185 | int j,k,i; | 185 | int j,k,i; |
186 | int add; | 186 | int add; |
187 | for ( i = 0; i < max ; ++i ) { | 187 | for ( i = 0; i < max ; ++i ) { |
188 | QString s = attList[i]; | 188 | QString s = attList[i]; |
189 | if ( ! s.isEmpty() ){ | 189 | if ( ! s.isEmpty() ){ |
190 | j = s.length(); | 190 | j = s.length(); |
191 | for ( k = 0; k < j; ++k ) { | 191 | for ( k = 0; k < j; ++k ) { |
192 | int mul = k +1; | 192 | int mul = k +1; |
193 | add = s[k].unicode (); | 193 | add = s[k].unicode (); |
194 | if ( k < 16 ) | 194 | if ( k < 16 ) |
195 | mul = mul * mul; | 195 | mul = mul * mul; |
196 | int ii = i+1; | 196 | int ii = i+1; |
197 | add = add * mul *ii*ii*ii; | 197 | add = add * mul *ii*ii*ii; |
198 | cSum += add; | 198 | cSum += add; |
199 | } | 199 | } |
200 | } | 200 | } |
201 | 201 | ||
202 | } | 202 | } |
203 | //QString dump = attList.join(","); | 203 | //QString dump = attList.join(","); |
204 | //qDebug("csum: %d %s", cSum,dump.latin1()); | 204 | //qDebug("csum: %d %s", cSum,dump.latin1()); |
205 | 205 | ||
206 | return cSum; | 206 | return cSum; |
207 | 207 | ||
208 | } | 208 | } |
209 | void Addressee::computeCsum(const QString &dev) | 209 | void Addressee::computeCsum(const QString &dev) |
210 | { | 210 | { |
211 | QStringList l; | 211 | QStringList l; |
212 | //if ( !mData->name.isEmpty() ) l.append(mData->name); | 212 | //if ( !mData->name.isEmpty() ) l.append(mData->name); |
213 | //if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName ); | 213 | //if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName ); |
214 | if ( !mData->familyName.isEmpty() ) l.append( mData->familyName ); | 214 | if ( !mData->familyName.isEmpty() ) l.append( mData->familyName ); |
215 | if ( !mData->givenName.isEmpty() ) l.append(mData->givenName ); | 215 | if ( !mData->givenName.isEmpty() ) l.append(mData->givenName ); |
216 | if ( !mData->additionalName.isEmpty() ) l.append( mData->additionalName ); | 216 | if ( !mData->additionalName.isEmpty() ) l.append( mData->additionalName ); |
217 | if ( !mData->prefix.isEmpty() ) l.append( mData->prefix ); | 217 | if ( !mData->prefix.isEmpty() ) l.append( mData->prefix ); |
218 | if ( !mData->suffix.isEmpty() ) l.append( mData->suffix ); | 218 | if ( !mData->suffix.isEmpty() ) l.append( mData->suffix ); |
219 | if ( !mData->nickName.isEmpty() ) l.append( mData->nickName ); | 219 | if ( !mData->nickName.isEmpty() ) l.append( mData->nickName ); |
220 | if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() ); | 220 | if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() ); |
221 | if ( !mData->mailer.isEmpty() ) l.append( mData->mailer ); | 221 | if ( !mData->mailer.isEmpty() ) l.append( mData->mailer ); |
222 | if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() ); | 222 | if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() ); |
223 | if ( mData->geo.isValid() ) l.append( mData->geo.asString() ); | 223 | if ( mData->geo.isValid() ) l.append( mData->geo.asString() ); |
224 | if ( !mData->title .isEmpty() ) l.append( mData->title ); | 224 | if ( !mData->title .isEmpty() ) l.append( mData->title ); |
225 | if ( !mData->role.isEmpty() ) l.append( mData->role ); | 225 | if ( !mData->role.isEmpty() ) l.append( mData->role ); |
226 | if ( !mData->organization.isEmpty() ) l.append( mData->organization ); | 226 | if ( !mData->organization.isEmpty() ) l.append( mData->organization ); |
227 | if ( !mData->note.isEmpty() ) l.append( mData->note ); | 227 | if ( !mData->note.isEmpty() ) l.append( mData->note ); |
228 | if ( !mData->productId.isEmpty() ) l.append(mData->productId ); | 228 | if ( !mData->productId.isEmpty() ) l.append(mData->productId ); |
229 | if ( !mData->sortString.isEmpty() ) l.append( mData->sortString ); | 229 | if ( !mData->sortString.isEmpty() ) l.append( mData->sortString ); |
230 | if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString()); | 230 | if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString()); |
231 | // if ( !mData->logo.isEmpty() ) l.append( ); | 231 | // if ( !mData->logo.isEmpty() ) l.append( ); |
232 | //if ( !mData->photo.isEmpty() ) l.append( ); | 232 | //if ( !mData->photo.isEmpty() ) l.append( ); |
233 | //if ( !mData->sound.isEmpty() ) l.append( ); | 233 | //if ( !mData->sound.isEmpty() ) l.append( ); |
234 | //if ( !mData->agent.isEmpty() ) l.append( ); | 234 | //if ( !mData->agent.isEmpty() ) l.append( ); |
235 | if ( mData->url.isValid() ) | 235 | if ( mData->url.isValid() ) |
236 | if ( ! mData->url.path().isEmpty()) l.append( mData->url.path() ); | 236 | if ( ! mData->url.path().isEmpty()) l.append( mData->url.path() ); |
237 | KABC::PhoneNumber::List phoneNumbers; | 237 | KABC::PhoneNumber::List phoneNumbers; |
238 | KABC::PhoneNumber::List::Iterator phoneIter; | 238 | KABC::PhoneNumber::List::Iterator phoneIter; |
239 | 239 | ||
240 | QStringList t; | 240 | QStringList t; |
241 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | 241 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); |
242 | ++phoneIter ) | 242 | ++phoneIter ) |
243 | t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) ); | 243 | t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) ); |
244 | t.sort(); | 244 | t.sort(); |
245 | uint iii; | 245 | uint iii; |
246 | for ( iii = 0; iii < t.count(); ++iii) | 246 | for ( iii = 0; iii < t.count(); ++iii) |
247 | l.append( t[iii] ); | 247 | l.append( t[iii] ); |
248 | t = mData->emails; | 248 | t = mData->emails; |
249 | t.sort(); | 249 | t.sort(); |
250 | for ( iii = 0; iii < t.count(); ++iii) | 250 | for ( iii = 0; iii < t.count(); ++iii) |
251 | l.append( t[iii] ); | 251 | l.append( t[iii] ); |
252 | t = mData->categories; | 252 | t = mData->categories; |
253 | t.sort(); | 253 | t.sort(); |
254 | for ( iii = 0; iii < t.count(); ++iii) | 254 | for ( iii = 0; iii < t.count(); ++iii) |
255 | l.append( t[iii] ); | 255 | l.append( t[iii] ); |
256 | t = mData->custom; | 256 | t = mData->custom; |
257 | t.sort(); | 257 | t.sort(); |
258 | for ( iii = 0; iii < t.count(); ++iii) | 258 | for ( iii = 0; iii < t.count(); ++iii) |
259 | if ( t[iii].left( 25 ) != "KADDRESSBOOK-X-ExternalID" ) { | 259 | if ( t[iii].left( 25 ) != "KADDRESSBOOK-X-ExternalID" ) { |
260 | int find = t[iii].find (':')+1; | 260 | int find = t[iii].find (':')+1; |
261 | //qDebug("lennnn %d %d ", find, t[iii].length()); | 261 | //qDebug("lennnn %d %d ", find, t[iii].length()); |
262 | if ( find < t[iii].length()) | 262 | if ( find < t[iii].length()) |
263 | l.append( t[iii] ); | 263 | l.append( t[iii] ); |
264 | 264 | ||
265 | } | 265 | } |
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 | 275 | ||
276 | #if 0 | 276 | #if 0 |
277 | for ( iii = 0; iii < l.count(); ++iii) | 277 | for ( iii = 0; iii < l.count(); ++iii) |
278 | qDebug("%d***%s***",iii,l[iii].latin1()); | 278 | qDebug("%d***%s***",iii,l[iii].latin1()); |
279 | qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); | 279 | qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); |
280 | #endif | 280 | #endif |
281 | 281 | ||
282 | setCsum( dev, QString::number (cs )); | 282 | setCsum( dev, QString::number (cs )); |
283 | } | 283 | } |
284 | 284 | ||
285 | void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false) | 285 | void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false) |
286 | { | 286 | { |
287 | // merge all standard non-outlook fields. | ||
288 | //if isSubSet (e.g. mobile phone sync) merge all fields | ||
287 | 289 | ||
288 | detach(); | 290 | detach(); |
289 | if ( mData->name.isEmpty() ) mData->name = ad.mData->name; | 291 | if ( isSubSet ) { |
290 | if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName; | 292 | if ( mData->name.isEmpty() ) mData->name = ad.mData->name; |
291 | if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName; | 293 | if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName; |
292 | if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ; | 294 | if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName; |
293 | if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName; | 295 | if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ; |
294 | if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix; | 296 | if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName; |
295 | if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix; | 297 | if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix; |
296 | if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName; | 298 | if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix; |
297 | if ( !mData->birthday.isValid() ) | 299 | if ( mData->title .isEmpty() ) mData->title = ad.mData->title ; |
298 | if ( ad.mData->birthday.isValid()) | 300 | if ( mData->role.isEmpty() ) mData->role = ad.mData->role ; |
299 | mData->birthday = ad.mData->birthday; | 301 | if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName; |
302 | if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ; | ||
303 | if ( mData->note.isEmpty() ) mData->note = ad.mData->note ; | ||
304 | if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy; | ||
305 | if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ; | ||
306 | if ( !mData->birthday.isValid() ) | ||
307 | if ( ad.mData->birthday.isValid()) | ||
308 | mData->birthday = ad.mData->birthday; | ||
309 | |||
310 | } | ||
300 | if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer; | 311 | if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer; |
301 | if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone; | 312 | if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone; |
302 | if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo; | 313 | if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo; |
303 | if ( mData->title .isEmpty() ) mData->title = ad.mData->title ; | ||
304 | if ( mData->role.isEmpty() ) mData->role = ad.mData->role ; | ||
305 | if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ; | ||
306 | if ( mData->note.isEmpty() ) mData->note = ad.mData->note ; | ||
307 | if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId; | 314 | if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId; |
308 | if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString; | 315 | if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString; |
309 | if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy; | ||
310 | if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ; | ||
311 | QStringList t; | 316 | QStringList t; |
312 | QStringList tAD; | 317 | QStringList tAD; |
313 | uint iii; | 318 | uint iii; |
314 | 319 | ||
315 | // ********** phone numbers | 320 | // ********** phone numbers |
316 | PhoneNumber::List phoneAD = ad.phoneNumbers(); | 321 | if ( isSubSet ) { |
317 | PhoneNumber::List::Iterator phoneItAD; | 322 | PhoneNumber::List phoneAD = ad.phoneNumbers(); |
318 | for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) { | 323 | PhoneNumber::List::Iterator phoneItAD; |
319 | bool found = false; | 324 | for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) { |
320 | PhoneNumber::List::Iterator it; | 325 | bool found = false; |
321 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 326 | PhoneNumber::List::Iterator it; |
322 | if ( ( *phoneItAD ).contains( (*it) ) ) { | 327 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
323 | found = true; | 328 | if ( ( *phoneItAD ).contains( (*it) ) ) { |
324 | (*it).setType( ( *phoneItAD ).type() ); | 329 | found = true; |
325 | (*it).setNumber( ( *phoneItAD ).number() ); | 330 | (*it).setType( ( *phoneItAD ).type() ); |
326 | break; | 331 | (*it).setNumber( ( *phoneItAD ).number() ); |
332 | break; | ||
333 | } | ||
327 | } | 334 | } |
335 | // if ( isSubSet && ! found ) | ||
336 | if ( ! found ) // LR try this one... | ||
337 | mData->phoneNumbers.append( *phoneItAD ); | ||
328 | } | 338 | } |
329 | // if ( isSubSet && ! found ) | ||
330 | if ( ! found ) // LR try this one... | ||
331 | mData->phoneNumbers.append( *phoneItAD ); | ||
332 | } | 339 | } |
333 | if ( isSubSet ) { | 340 | if ( isSubSet ) { |
334 | // ************* emails; | 341 | // ************* emails; |
335 | t = mData->emails; | 342 | t = mData->emails; |
336 | tAD = ad.mData->emails; | 343 | tAD = ad.mData->emails; |
337 | for ( iii = 0; iii < tAD.count(); ++iii) | 344 | for ( iii = 0; iii < tAD.count(); ++iii) |
338 | if ( !t.contains(tAD[iii] ) ) | 345 | if ( !t.contains(tAD[iii] ) ) |
339 | mData->emails.append( tAD[iii] ); | 346 | mData->emails.append( tAD[iii] ); |
340 | } | 347 | } |
341 | 348 | ||
342 | // ************* categories; | 349 | // ************* categories; |
343 | t = mData->categories; | 350 | if ( isSubSet ) { |
344 | tAD = ad.mData->categories; | 351 | t = mData->categories; |
345 | for ( iii = 0; iii < tAD.count(); ++iii) | 352 | tAD = ad.mData->categories; |
346 | if ( !t.contains(tAD[iii] ) ) | 353 | for ( iii = 0; iii < tAD.count(); ++iii) |
347 | mData->categories.append( tAD[iii] ); | 354 | if ( !t.contains(tAD[iii] ) ) |
355 | mData->categories.append( tAD[iii] ); | ||
356 | } | ||
348 | QStringList::ConstIterator it; | 357 | QStringList::ConstIterator it; |
349 | for( it = ad.mData->custom.begin(); it != ad.mData->custom.end(); ++it ) { | 358 | for( it = ad.mData->custom.begin(); it != ad.mData->custom.end(); ++it ) { |
350 | QString qualifiedName = (*it).left( (*it).find( ":" )); | 359 | QString qualifiedName = (*it).left( (*it).find( ":" )); |
351 | bool found = false; | 360 | bool found = false; |
352 | QStringList::ConstIterator itL; | 361 | QStringList::ConstIterator itL; |
353 | for( itL = mData->custom.begin(); itL != mData->custom.end(); ++itL ) { | 362 | for( itL = mData->custom.begin(); itL != mData->custom.end(); ++itL ) { |
354 | if ( (*itL).startsWith( qualifiedName ) ) { | 363 | if ( (*itL).startsWith( qualifiedName ) ) { |
355 | found = true; | 364 | found = true; |
356 | break; | 365 | break; |
357 | } | 366 | } |
358 | } | 367 | } |
359 | if ( ! found ) { | 368 | if ( ! found ) { |
360 | mData->custom.append( *it ); | 369 | mData->custom.append( *it ); |
361 | } | 370 | } |
362 | } | 371 | } |
363 | if ( mData->logo.undefined() && !ad.mData->logo.undefined() ) mData->logo = ad.mData->logo; | 372 | if ( mData->logo.undefined() && !ad.mData->logo.undefined() ) mData->logo = ad.mData->logo; |
364 | if ( mData->photo.undefined() && !ad.mData->photo.undefined() ) mData->photo = ad.mData->photo; | 373 | if ( mData->photo.undefined() && !ad.mData->photo.undefined() ) mData->photo = ad.mData->photo; |
365 | if ( !mData->sound.isIntern() ) { | 374 | if ( !mData->sound.isIntern() ) { |
366 | if ( mData->sound.url().isEmpty() ) { | 375 | if ( mData->sound.url().isEmpty() ) { |
367 | mData->sound = ad.mData->sound; | 376 | mData->sound = ad.mData->sound; |
368 | } | 377 | } |
369 | } | 378 | } |
370 | if ( !mData->agent.isIntern() ) { | 379 | if ( !mData->agent.isIntern() ) { |
371 | if ( mData->agent.url().isEmpty() ) { | 380 | if ( mData->agent.url().isEmpty() ) { |
372 | mData->agent = ad.mData->agent; | 381 | mData->agent = ad.mData->agent; |
373 | } | 382 | } |
374 | } | 383 | } |
375 | { | 384 | { |
376 | Key::List::Iterator itA; | 385 | Key::List::Iterator itA; |
377 | for( itA = ad.mData->keys.begin(); itA != ad.mData->keys.end(); ++itA ) { | 386 | for( itA = ad.mData->keys.begin(); itA != ad.mData->keys.end(); ++itA ) { |
378 | bool found = false; | 387 | bool found = false; |
379 | Key::List::Iterator it; | 388 | Key::List::Iterator it; |
380 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 389 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
381 | if ( (*it) == (*itA)) { | 390 | if ( (*it) == (*itA)) { |
382 | found = true; | 391 | found = true; |
383 | break; | 392 | break; |
384 | 393 | ||
385 | } | 394 | } |
386 | } | 395 | } |
387 | if ( ! found ) { | 396 | if ( ! found ) { |
388 | mData->keys.append( *itA ); | 397 | mData->keys.append( *itA ); |
389 | } | 398 | } |
390 | } | 399 | } |
391 | } | 400 | } |
392 | KABC::Address::List::Iterator addressIterA; | 401 | if ( isSubSet ) { |
393 | for ( addressIterA = ad.mData->addresses.begin(); addressIterA != ad.mData->addresses.end(); ++addressIterA ) { | 402 | KABC::Address::List::Iterator addressIterA; |
394 | bool found = false; | 403 | for ( addressIterA = ad.mData->addresses.begin(); addressIterA != ad.mData->addresses.end(); ++addressIterA ) { |
395 | KABC::Address::List::Iterator addressIter; | 404 | bool found = false; |
396 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); | 405 | KABC::Address::List::Iterator addressIter; |
397 | ++addressIter ) { | 406 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); |
398 | if ( (*addressIter) == (*addressIterA)) { | 407 | ++addressIter ) { |
399 | found = true; | 408 | if ( (*addressIter) == (*addressIterA)) { |
400 | (*addressIter).setType( (*addressIterA).type() ); | 409 | found = true; |
401 | break; | 410 | (*addressIter).setType( (*addressIterA).type() ); |
402 | } | 411 | break; |
412 | } | ||
403 | 413 | ||
404 | } | 414 | } |
405 | if ( isSubSet && ! found ) { | 415 | if ( isSubSet && ! found ) { |
406 | mData->addresses.append( *addressIterA ); | 416 | mData->addresses.append( *addressIterA ); |
417 | } | ||
407 | } | 418 | } |
408 | } | 419 | } |
409 | //qDebug("merge contact %s ", ad.uid().latin1()); | 420 | //qDebug("merge contact %s ", ad.uid().latin1()); |
410 | setUid( ad.uid() ); | 421 | setUid( ad.uid() ); |
411 | setRevision( ad.revision() ); | 422 | setRevision( ad.revision() ); |
412 | } | 423 | } |
413 | 424 | ||
414 | bool Addressee::removeVoice() | 425 | bool Addressee::removeVoice() |
415 | { | 426 | { |
416 | PhoneNumber::List phoneN = phoneNumbers(); | 427 | PhoneNumber::List phoneN = phoneNumbers(); |
417 | PhoneNumber::List::Iterator phoneIt; | 428 | PhoneNumber::List::Iterator phoneIt; |
418 | bool found = false; | 429 | bool found = false; |
419 | for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { | 430 | for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { |
420 | if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found | 431 | if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found |
421 | if ((*phoneIt).type() - PhoneNumber::Voice ) { | 432 | if ((*phoneIt).type() - PhoneNumber::Voice ) { |
422 | (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice ); | 433 | (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice ); |
423 | insertPhoneNumber( (*phoneIt) ); | 434 | insertPhoneNumber( (*phoneIt) ); |
424 | found = true; | 435 | found = true; |
425 | } | 436 | } |
426 | } | 437 | } |
427 | 438 | ||
428 | } | 439 | } |
429 | return found; | 440 | return found; |
430 | } | 441 | } |
431 | 442 | ||
432 | bool Addressee::containsAdr(const Addressee& ad ) | 443 | bool Addressee::containsAdr(const Addressee& ad ) |
433 | { | 444 | { |
434 | if ( ! ad.mData->familyName.isEmpty() ) if ( mData->familyName != ad.mData->familyName) return false; | 445 | if ( ! ad.mData->familyName.isEmpty() ) if ( mData->familyName != ad.mData->familyName) return false; |
435 | if ( ! ad.mData->givenName.isEmpty() )if ( mData->givenName != ad.mData->givenName ) return false; | 446 | if ( ! ad.mData->givenName.isEmpty() )if ( mData->givenName != ad.mData->givenName ) return false; |
436 | if ( ad.mData->url.isValid() ) if (mData->url != ad.mData->url) return false ; | 447 | if ( ad.mData->url.isValid() ) if (mData->url != ad.mData->url) return false ; |
437 | if ( ! ad.mData->role.isEmpty() ) if (mData->role != ad.mData->role) return false ; | 448 | if ( ! ad.mData->role.isEmpty() ) if (mData->role != ad.mData->role) return false ; |
438 | if ( ! ad.mData->organization.isEmpty() ) if (mData->organization != ad.mData->organization) return false ; | 449 | if ( ! ad.mData->organization.isEmpty() ) if (mData->organization != ad.mData->organization) return false ; |
439 | if ( ! ad.mData->note.isEmpty() ) if (mData->note != ad.mData->note) return false ; | 450 | if ( ! ad.mData->note.isEmpty() ) if (mData->note != ad.mData->note) return false ; |
440 | if ( ! ad.mData->title .isEmpty() ) if (mData->title != ad.mData->title ) return false ; | 451 | if ( ! ad.mData->title .isEmpty() ) if (mData->title != ad.mData->title ) return false ; |
441 | 452 | ||
442 | // compare phone numbers | 453 | // compare phone numbers |
443 | PhoneNumber::List phoneN = ad.phoneNumbers(); | 454 | PhoneNumber::List phoneN = ad.phoneNumbers(); |
444 | PhoneNumber::List::Iterator phoneIt; | 455 | PhoneNumber::List::Iterator phoneIt; |
445 | bool found = false; | 456 | bool found = false; |
446 | for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { | 457 | for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { |
447 | bool found = false; | 458 | bool found = false; |
448 | PhoneNumber::List phoneL = ad.phoneNumbers(); | 459 | PhoneNumber::List phoneL = ad.phoneNumbers(); |
449 | PhoneNumber::List::Iterator phoneItL; | 460 | PhoneNumber::List::Iterator phoneItL; |
450 | for ( phoneItL = phoneL.begin(); phoneItL != phoneL.end(); ++phoneItL ) { | 461 | for ( phoneItL = phoneL.begin(); phoneItL != phoneL.end(); ++phoneItL ) { |
451 | if ( ( *phoneItL ).number() == ( *phoneIt ).number() ) { | 462 | if ( ( *phoneItL ).number() == ( *phoneIt ).number() ) { |
452 | found = true; | 463 | found = true; |
453 | break; | 464 | break; |
454 | } | 465 | } |
455 | } | 466 | } |
456 | if ( ! found ) | 467 | if ( ! found ) |
457 | return false; | 468 | return false; |
458 | } | 469 | } |
459 | return true; | 470 | return true; |
460 | 471 | ||
461 | } | 472 | } |
462 | void Addressee::simplifyAddresses() | 473 | void Addressee::simplifyAddresses() |
463 | { | 474 | { |
464 | 475 | ||
465 | 476 | ||
466 | Address::List list; | 477 | Address::List list; |
467 | Address::List::Iterator it; | 478 | Address::List::Iterator it; |
468 | Address::List::Iterator it2; | 479 | Address::List::Iterator it2; |
469 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 480 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
470 | it2 = it; | 481 | it2 = it; |
471 | ++it2; | 482 | ++it2; |
472 | for( ; it2 != mData->addresses.end(); ++it2 ) { | 483 | for( ; it2 != mData->addresses.end(); ++it2 ) { |
473 | if ( (*it) == (*it2) ) { | 484 | if ( (*it) == (*it2) ) { |
474 | list.append( *it ); | 485 | list.append( *it ); |
475 | break; | 486 | break; |
476 | } | 487 | } |
477 | } | 488 | } |
478 | } | 489 | } |
479 | for( it = list.begin(); it != list.end(); ++it ) { | 490 | for( it = list.begin(); it != list.end(); ++it ) { |
480 | removeAddress( (*it) ); | 491 | removeAddress( (*it) ); |
481 | } | 492 | } |
482 | 493 | ||
483 | list.clear(); | 494 | list.clear(); |
484 | int max = 2; | 495 | int max = 2; |
485 | if ( mData->url.isValid() ) | 496 | if ( mData->url.isValid() ) |
486 | max = 1; | 497 | max = 1; |
487 | if ( mData->addresses.count() <= max ) return ; | 498 | if ( mData->addresses.count() <= max ) return ; |
488 | int count = 0; | 499 | int count = 0; |
489 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 500 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
490 | if ( count >= max ) | 501 | if ( count >= max ) |
491 | list.append( *it ); | 502 | list.append( *it ); |
492 | ++count; | 503 | ++count; |
493 | } | 504 | } |
494 | for( it = list.begin(); it != list.end(); ++it ) { | 505 | for( it = list.begin(); it != list.end(); ++it ) { |
495 | removeAddress( (*it) ); | 506 | removeAddress( (*it) ); |
496 | } | 507 | } |
497 | } | 508 | } |
498 | 509 | ||
499 | // removes all emails but the first | 510 | // removes all emails but the first |
500 | // needed by phone sync | 511 | // needed by phone sync |
501 | void Addressee::simplifyEmails() | 512 | void Addressee::simplifyEmails() |
502 | { | 513 | { |
503 | if ( mData->emails.count() == 0 ) return ; | 514 | if ( mData->emails.count() == 0 ) return ; |
504 | QString email = mData->emails.first(); | 515 | QString email = mData->emails.first(); |
505 | detach(); | 516 | detach(); |
506 | mData->emails.clear(); | 517 | mData->emails.clear(); |
507 | mData->emails.append( email ); | 518 | mData->emails.append( email ); |
508 | } | 519 | } |
509 | 520 | ||
510 | void Addressee::simplifyPhoneNumbers() | 521 | void Addressee::simplifyPhoneNumbers() |
511 | { | 522 | { |
512 | int max = 4; | 523 | int max = 4; |
513 | int inList = mData->phoneNumbers.count(); | 524 | int inList = mData->phoneNumbers.count(); |
514 | KABC::PhoneNumber::List removeNumbers; | 525 | KABC::PhoneNumber::List removeNumbers; |
515 | KABC::PhoneNumber::List::Iterator phoneIter; | 526 | KABC::PhoneNumber::List::Iterator phoneIter; |
516 | if ( inList > max ) { | 527 | if ( inList > max ) { |
517 | // delete non-preferred numbers | 528 | // delete non-preferred numbers |
518 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | 529 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); |
519 | ++phoneIter ) { | 530 | ++phoneIter ) { |
520 | if ( inList > max ) { | 531 | if ( inList > max ) { |
521 | if ( ! (( *phoneIter ).type() & PhoneNumber::Pref )) { | 532 | if ( ! (( *phoneIter ).type() & PhoneNumber::Pref )) { |
522 | removeNumbers.append( ( *phoneIter ) ); | 533 | removeNumbers.append( ( *phoneIter ) ); |
523 | --inList; | 534 | --inList; |
524 | } | 535 | } |
525 | } else | 536 | } else |
526 | break; | 537 | break; |
527 | } | 538 | } |
528 | for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); | 539 | for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); |
529 | ++phoneIter ) { | 540 | ++phoneIter ) { |
530 | removePhoneNumber(( *phoneIter )); | 541 | removePhoneNumber(( *phoneIter )); |
531 | } | 542 | } |
532 | // delete preferred numbers | 543 | // delete preferred numbers |
533 | if ( inList > max ) { | 544 | if ( inList > max ) { |
534 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | 545 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); |
535 | ++phoneIter ) { | 546 | ++phoneIter ) { |
536 | if ( inList > max ) { | 547 | if ( inList > max ) { |
537 | removeNumbers.append( ( *phoneIter ) ); | 548 | removeNumbers.append( ( *phoneIter ) ); |
538 | --inList; | 549 | --inList; |
539 | } else | 550 | } else |
540 | break; | 551 | break; |
541 | } | 552 | } |
542 | for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); | 553 | for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); |
543 | ++phoneIter ) { | 554 | ++phoneIter ) { |
544 | removePhoneNumber(( *phoneIter )); | 555 | removePhoneNumber(( *phoneIter )); |
545 | } | 556 | } |
546 | } | 557 | } |
547 | } | 558 | } |
548 | // remove non-numeric characters | 559 | // remove non-numeric characters |
549 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | 560 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); |
550 | ++phoneIter ) { | 561 | ++phoneIter ) { |
551 | if ( ! ( *phoneIter ).simplifyNumber() ) | 562 | if ( ! ( *phoneIter ).simplifyNumber() ) |
552 | removeNumbers.append( ( *phoneIter ) ); | 563 | removeNumbers.append( ( *phoneIter ) ); |
553 | } | 564 | } |
554 | for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); | 565 | for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); |
555 | ++phoneIter ) { | 566 | ++phoneIter ) { |
556 | removePhoneNumber(( *phoneIter )); | 567 | removePhoneNumber(( *phoneIter )); |
557 | } | 568 | } |
558 | } | 569 | } |
559 | void Addressee::simplifyPhoneNumberTypes() | 570 | void Addressee::simplifyPhoneNumberTypes() |
560 | { | 571 | { |
561 | KABC::PhoneNumber::List::Iterator phoneIter; | 572 | KABC::PhoneNumber::List::Iterator phoneIter; |
562 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | 573 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); |
563 | ++phoneIter ) | 574 | ++phoneIter ) |
564 | ( *phoneIter ).simplifyType(); | 575 | ( *phoneIter ).simplifyType(); |
565 | } | 576 | } |
566 | void Addressee::removeID(const QString &prof) | 577 | void Addressee::removeID(const QString &prof) |
567 | { | 578 | { |
568 | detach(); | 579 | detach(); |
569 | if ( prof.isEmpty() ) | 580 | if ( prof.isEmpty() ) |
570 | mData->mExternalId = ":"; | 581 | mData->mExternalId = ":"; |
571 | else | 582 | else |
572 | mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof); | 583 | mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof); |
573 | 584 | ||
574 | } | 585 | } |
575 | void Addressee::setID( const QString & prof , const QString & id ) | 586 | void Addressee::setID( const QString & prof , const QString & id ) |
576 | { | 587 | { |
577 | detach(); | 588 | detach(); |
578 | mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id ); | 589 | mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id ); |
579 | //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); | 590 | //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); |
580 | } | 591 | } |
581 | void Addressee::setTempSyncStat( int id ) | 592 | void Addressee::setTempSyncStat( int id ) |
582 | { | 593 | { |
583 | if ( mData->mTempSyncStat == id ) return; | 594 | if ( mData->mTempSyncStat == id ) return; |
584 | detach(); | 595 | detach(); |
585 | mData->mTempSyncStat = id; | 596 | mData->mTempSyncStat = id; |
586 | } | 597 | } |
587 | int Addressee::tempSyncStat() const | 598 | int Addressee::tempSyncStat() const |
588 | { | 599 | { |
589 | return mData->mTempSyncStat; | 600 | return mData->mTempSyncStat; |
590 | } | 601 | } |
591 | 602 | ||
592 | const QString Addressee::getID( const QString & prof) const | 603 | const QString Addressee::getID( const QString & prof) const |
593 | { | 604 | { |
594 | return KIdManager::getId ( mData->mExternalId, prof ); | 605 | return KIdManager::getId ( mData->mExternalId, prof ); |
595 | } | 606 | } |
596 | 607 | ||
597 | void Addressee::setCsum( const QString & prof , const QString & id ) | 608 | void Addressee::setCsum( const QString & prof , const QString & id ) |
598 | { | 609 | { |
599 | detach(); | 610 | detach(); |
600 | //qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); | 611 | //qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); |
601 | mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id ); | 612 | mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id ); |
602 | //qDebug("setcsum2 %s ",mData->mExternalId.latin1() ); | 613 | //qDebug("setcsum2 %s ",mData->mExternalId.latin1() ); |
603 | } | 614 | } |
604 | 615 | ||
605 | const QString Addressee::getCsum( const QString & prof) const | 616 | const QString Addressee::getCsum( const QString & prof) const |
606 | { | 617 | { |
607 | return KIdManager::getCsum ( mData->mExternalId, prof ); | 618 | return KIdManager::getCsum ( mData->mExternalId, prof ); |
608 | } | 619 | } |
609 | 620 | ||
610 | void Addressee::setIDStr( const QString & s ) | 621 | void Addressee::setIDStr( const QString & s ) |
611 | { | 622 | { |
612 | detach(); | 623 | detach(); |
613 | mData->mExternalId = s; | 624 | mData->mExternalId = s; |
614 | } | 625 | } |
615 | 626 | ||
616 | const QString Addressee::IDStr() const | 627 | const QString Addressee::IDStr() const |
617 | { | 628 | { |
618 | return mData->mExternalId; | 629 | return mData->mExternalId; |
619 | } | 630 | } |
620 | 631 | ||
621 | void Addressee::setExternalUID( const QString &id ) | 632 | void Addressee::setExternalUID( const QString &id ) |
622 | { | 633 | { |
623 | if ( id == mData->externalUID ) return; | 634 | if ( id == mData->externalUID ) return; |
624 | detach(); | 635 | detach(); |
625 | mData->empty = false; | 636 | mData->empty = false; |
626 | mData->externalUID = id; | 637 | mData->externalUID = id; |
627 | } | 638 | } |
628 | 639 | ||
629 | const QString Addressee::externalUID() const | 640 | const QString Addressee::externalUID() const |
630 | { | 641 | { |
631 | return mData->externalUID; | 642 | return mData->externalUID; |
632 | } | 643 | } |
633 | void Addressee::setOriginalExternalUID( const QString &id ) | 644 | void Addressee::setOriginalExternalUID( const QString &id ) |
634 | { | 645 | { |
635 | if ( id == mData->originalExternalUID ) return; | 646 | if ( id == mData->originalExternalUID ) return; |
636 | detach(); | 647 | detach(); |
637 | mData->empty = false; | 648 | mData->empty = false; |
638 | //qDebug("*******Set orig uid %s ", id.latin1()); | 649 | //qDebug("*******Set orig uid %s ", id.latin1()); |
639 | mData->originalExternalUID = id; | 650 | mData->originalExternalUID = id; |
640 | } | 651 | } |
641 | 652 | ||
642 | QString Addressee::originalExternalUID() const | 653 | QString Addressee::originalExternalUID() const |
643 | { | 654 | { |
644 | return mData->originalExternalUID; | 655 | return mData->originalExternalUID; |
645 | } | 656 | } |
646 | 657 | ||
647 | void Addressee::setUid( const QString &id ) | 658 | void Addressee::setUid( const QString &id ) |
648 | { | 659 | { |
649 | if ( id == mData->uid ) return; | 660 | if ( id == mData->uid ) return; |
650 | detach(); | 661 | detach(); |
651 | //qDebug("****setuid %s ", id.latin1()); | 662 | //qDebug("****setuid %s ", id.latin1()); |
652 | mData->empty = false; | 663 | mData->empty = false; |
653 | mData->uid = id; | 664 | mData->uid = id; |
654 | } | 665 | } |
655 | 666 | ||
656 | const QString Addressee::uid() const | 667 | const QString Addressee::uid() const |
657 | { | 668 | { |
658 | if ( mData->uid.isEmpty() ) | 669 | if ( mData->uid.isEmpty() ) |
659 | mData->uid = KApplication::randomString( 10 ); | 670 | mData->uid = KApplication::randomString( 10 ); |
660 | 671 | ||
661 | return mData->uid; | 672 | return mData->uid; |
662 | } | 673 | } |
663 | 674 | ||
664 | QString Addressee::uidLabel() | 675 | QString Addressee::uidLabel() |
665 | { | 676 | { |
666 | return i18n("Unique Identifier"); | 677 | return i18n("Unique Identifier"); |
667 | } | 678 | } |
668 | 679 | ||
669 | void Addressee::setName( const QString &name ) | 680 | void Addressee::setName( const QString &name ) |
670 | { | 681 | { |
671 | if ( name == mData->name ) return; | 682 | if ( name == mData->name ) return; |
672 | detach(); | 683 | detach(); |
673 | mData->empty = false; | 684 | mData->empty = false; |
674 | mData->name = name; | 685 | mData->name = name; |
675 | } | 686 | } |
676 | 687 | ||
677 | QString Addressee::name() const | 688 | QString Addressee::name() const |
678 | { | 689 | { |
679 | return mData->name; | 690 | return mData->name; |
680 | } | 691 | } |
681 | 692 | ||
682 | QString Addressee::nameLabel() | 693 | QString Addressee::nameLabel() |
683 | { | 694 | { |
684 | return i18n("Name"); | 695 | return i18n("Name"); |
685 | } | 696 | } |
686 | 697 | ||
687 | 698 | ||
688 | void Addressee::setFormattedName( const QString &formattedName ) | 699 | void Addressee::setFormattedName( const QString &formattedName ) |
689 | { | 700 | { |
690 | if ( formattedName == mData->formattedName ) return; | 701 | if ( formattedName == mData->formattedName ) return; |
691 | detach(); | 702 | detach(); |
692 | mData->empty = false; | 703 | mData->empty = false; |
693 | mData->formattedName = formattedName; | 704 | mData->formattedName = formattedName; |
694 | } | 705 | } |
695 | 706 | ||
696 | QString Addressee::formattedName() const | 707 | QString Addressee::formattedName() const |
697 | { | 708 | { |
698 | return mData->formattedName; | 709 | return mData->formattedName; |
699 | } | 710 | } |
700 | 711 | ||
701 | QString Addressee::formattedNameLabel() | 712 | QString Addressee::formattedNameLabel() |
702 | { | 713 | { |
703 | return i18n("Formatted Name"); | 714 | return i18n("Formatted Name"); |
704 | } | 715 | } |
705 | 716 | ||
706 | 717 | ||
707 | void Addressee::setFamilyName( const QString &familyName ) | 718 | void Addressee::setFamilyName( const QString &familyName ) |
708 | { | 719 | { |
709 | if ( familyName == mData->familyName ) return; | 720 | if ( familyName == mData->familyName ) return; |
710 | detach(); | 721 | detach(); |
711 | mData->empty = false; | 722 | mData->empty = false; |
712 | mData->familyName = familyName; | 723 | mData->familyName = familyName; |
713 | } | 724 | } |
714 | 725 | ||
715 | QString Addressee::familyName() const | 726 | QString Addressee::familyName() const |
716 | { | 727 | { |
717 | return mData->familyName; | 728 | return mData->familyName; |
718 | } | 729 | } |
719 | 730 | ||
720 | QString Addressee::familyNameLabel() | 731 | QString Addressee::familyNameLabel() |
721 | { | 732 | { |
722 | return i18n("Family Name"); | 733 | return i18n("Family Name"); |
723 | } | 734 | } |
724 | 735 | ||
725 | 736 | ||
726 | void Addressee::setGivenName( const QString &givenName ) | 737 | void Addressee::setGivenName( const QString &givenName ) |
727 | { | 738 | { |
728 | if ( givenName == mData->givenName ) return; | 739 | if ( givenName == mData->givenName ) return; |
729 | detach(); | 740 | detach(); |
730 | mData->empty = false; | 741 | mData->empty = false; |
731 | mData->givenName = givenName; | 742 | mData->givenName = givenName; |
732 | } | 743 | } |
733 | 744 | ||
734 | QString Addressee::givenName() const | 745 | QString Addressee::givenName() const |
735 | { | 746 | { |
736 | return mData->givenName; | 747 | return mData->givenName; |
737 | } | 748 | } |
738 | 749 | ||
739 | QString Addressee::givenNameLabel() | 750 | QString Addressee::givenNameLabel() |
740 | { | 751 | { |
741 | return i18n("Given Name"); | 752 | return i18n("Given Name"); |
742 | } | 753 | } |
743 | 754 | ||
744 | 755 | ||
745 | void Addressee::setAdditionalName( const QString &additionalName ) | 756 | void Addressee::setAdditionalName( const QString &additionalName ) |
746 | { | 757 | { |
747 | if ( additionalName == mData->additionalName ) return; | 758 | if ( additionalName == mData->additionalName ) return; |
748 | detach(); | 759 | detach(); |
749 | mData->empty = false; | 760 | mData->empty = false; |
750 | mData->additionalName = additionalName; | 761 | mData->additionalName = additionalName; |
751 | } | 762 | } |
752 | 763 | ||
753 | QString Addressee::additionalName() const | 764 | QString Addressee::additionalName() const |
754 | { | 765 | { |
755 | return mData->additionalName; | 766 | return mData->additionalName; |
756 | } | 767 | } |
757 | 768 | ||
758 | QString Addressee::additionalNameLabel() | 769 | QString Addressee::additionalNameLabel() |
759 | { | 770 | { |
760 | return i18n("Additional Names"); | 771 | return i18n("Additional Names"); |
761 | } | 772 | } |
762 | 773 | ||
763 | 774 | ||
764 | void Addressee::setPrefix( const QString &prefix ) | 775 | void Addressee::setPrefix( const QString &prefix ) |
765 | { | 776 | { |
766 | if ( prefix == mData->prefix ) return; | 777 | if ( prefix == mData->prefix ) return; |
767 | detach(); | 778 | detach(); |
768 | mData->empty = false; | 779 | mData->empty = false; |
769 | mData->prefix = prefix; | 780 | mData->prefix = prefix; |
770 | } | 781 | } |
771 | 782 | ||
772 | QString Addressee::prefix() const | 783 | QString Addressee::prefix() const |
773 | { | 784 | { |
774 | return mData->prefix; | 785 | return mData->prefix; |
775 | } | 786 | } |
776 | 787 | ||
777 | QString Addressee::prefixLabel() | 788 | QString Addressee::prefixLabel() |
778 | { | 789 | { |
779 | return i18n("Honorific Prefixes"); | 790 | return i18n("Honorific Prefixes"); |
780 | } | 791 | } |
781 | 792 | ||
782 | 793 | ||
783 | void Addressee::setSuffix( const QString &suffix ) | 794 | void Addressee::setSuffix( const QString &suffix ) |
784 | { | 795 | { |
785 | if ( suffix == mData->suffix ) return; | 796 | if ( suffix == mData->suffix ) return; |
786 | detach(); | 797 | detach(); |
787 | mData->empty = false; | 798 | mData->empty = false; |
788 | mData->suffix = suffix; | 799 | mData->suffix = suffix; |
789 | } | 800 | } |
790 | 801 | ||
791 | QString Addressee::suffix() const | 802 | QString Addressee::suffix() const |
792 | { | 803 | { |
793 | return mData->suffix; | 804 | return mData->suffix; |
794 | } | 805 | } |
795 | 806 | ||
796 | QString Addressee::suffixLabel() | 807 | QString Addressee::suffixLabel() |
797 | { | 808 | { |
798 | return i18n("Honorific Suffixes"); | 809 | return i18n("Honorific Suffixes"); |
799 | } | 810 | } |
800 | 811 | ||
801 | 812 | ||
802 | void Addressee::setNickName( const QString &nickName ) | 813 | void Addressee::setNickName( const QString &nickName ) |
803 | { | 814 | { |
804 | if ( nickName == mData->nickName ) return; | 815 | if ( nickName == mData->nickName ) return; |
805 | detach(); | 816 | detach(); |
806 | mData->empty = false; | 817 | mData->empty = false; |
807 | mData->nickName = nickName; | 818 | mData->nickName = nickName; |
808 | } | 819 | } |
809 | 820 | ||
810 | QString Addressee::nickName() const | 821 | QString Addressee::nickName() const |
811 | { | 822 | { |
812 | return mData->nickName; | 823 | return mData->nickName; |
813 | } | 824 | } |
814 | 825 | ||
815 | QString Addressee::nickNameLabel() | 826 | QString Addressee::nickNameLabel() |
816 | { | 827 | { |
817 | return i18n("Nick Name"); | 828 | return i18n("Nick Name"); |
818 | } | 829 | } |
819 | 830 | ||
820 | 831 | ||
821 | void Addressee::setBirthday( const QDateTime &birthday ) | 832 | void Addressee::setBirthday( const QDateTime &birthday ) |
822 | { | 833 | { |
823 | if ( birthday == mData->birthday ) return; | 834 | if ( birthday == mData->birthday ) return; |
824 | detach(); | 835 | detach(); |
825 | mData->empty = false; | 836 | mData->empty = false; |
826 | mData->birthday = birthday; | 837 | mData->birthday = birthday; |
827 | } | 838 | } |
828 | 839 | ||
829 | QDateTime Addressee::birthday() const | 840 | QDateTime Addressee::birthday() const |
830 | { | 841 | { |
831 | return mData->birthday; | 842 | return mData->birthday; |
832 | } | 843 | } |
833 | 844 | ||
834 | QString Addressee::birthdayLabel() | 845 | QString Addressee::birthdayLabel() |
835 | { | 846 | { |
836 | return i18n("Birthday"); | 847 | return i18n("Birthday"); |
837 | } | 848 | } |
838 | 849 | ||
839 | 850 | ||
840 | QString Addressee::homeAddressStreetLabel() | 851 | QString Addressee::homeAddressStreetLabel() |
841 | { | 852 | { |
842 | return i18n("Home Address Street"); | 853 | return i18n("Home Address Street"); |
843 | } | 854 | } |
844 | 855 | ||
845 | 856 | ||
846 | QString Addressee::homeAddressLocalityLabel() | 857 | QString Addressee::homeAddressLocalityLabel() |
847 | { | 858 | { |
848 | return i18n("Home Address Locality"); | 859 | return i18n("Home Address Locality"); |
849 | } | 860 | } |
850 | 861 | ||
851 | 862 | ||
852 | QString Addressee::homeAddressRegionLabel() | 863 | QString Addressee::homeAddressRegionLabel() |
853 | { | 864 | { |
854 | return i18n("Home Address Region"); | 865 | return i18n("Home Address Region"); |
855 | } | 866 | } |
856 | 867 | ||
857 | 868 | ||
858 | QString Addressee::homeAddressPostalCodeLabel() | 869 | QString Addressee::homeAddressPostalCodeLabel() |
859 | { | 870 | { |
860 | return i18n("Home Address Postal Code"); | 871 | return i18n("Home Address Postal Code"); |
861 | } | 872 | } |
862 | 873 | ||
863 | 874 | ||
864 | QString Addressee::homeAddressCountryLabel() | 875 | QString Addressee::homeAddressCountryLabel() |
865 | { | 876 | { |
866 | return i18n("Home Address Country"); | 877 | return i18n("Home Address Country"); |
867 | } | 878 | } |
868 | 879 | ||
869 | 880 | ||
870 | QString Addressee::homeAddressLabelLabel() | 881 | QString Addressee::homeAddressLabelLabel() |
871 | { | 882 | { |
872 | return i18n("Home Address Label"); | 883 | return i18n("Home Address Label"); |
873 | } | 884 | } |
874 | 885 | ||
875 | 886 | ||
876 | QString Addressee::businessAddressStreetLabel() | 887 | QString Addressee::businessAddressStreetLabel() |
877 | { | 888 | { |
878 | return i18n("Business Address Street"); | 889 | return i18n("Business Address Street"); |
879 | } | 890 | } |
880 | 891 | ||
881 | 892 | ||
882 | QString Addressee::businessAddressLocalityLabel() | 893 | QString Addressee::businessAddressLocalityLabel() |
883 | { | 894 | { |
884 | return i18n("Business Address Locality"); | 895 | return i18n("Business Address Locality"); |
885 | } | 896 | } |
886 | 897 | ||
887 | 898 | ||
888 | QString Addressee::businessAddressRegionLabel() | 899 | QString Addressee::businessAddressRegionLabel() |
889 | { | 900 | { |
890 | return i18n("Business Address Region"); | 901 | return i18n("Business Address Region"); |
891 | } | 902 | } |
892 | 903 | ||
893 | 904 | ||
894 | QString Addressee::businessAddressPostalCodeLabel() | 905 | QString Addressee::businessAddressPostalCodeLabel() |
895 | { | 906 | { |
896 | return i18n("Business Address Postal Code"); | 907 | return i18n("Business Address Postal Code"); |
897 | } | 908 | } |
898 | 909 | ||
899 | 910 | ||
900 | QString Addressee::businessAddressCountryLabel() | 911 | QString Addressee::businessAddressCountryLabel() |
901 | { | 912 | { |
902 | return i18n("Business Address Country"); | 913 | return i18n("Business Address Country"); |
903 | } | 914 | } |
904 | 915 | ||
905 | 916 | ||
906 | QString Addressee::businessAddressLabelLabel() | 917 | QString Addressee::businessAddressLabelLabel() |
907 | { | 918 | { |
908 | return i18n("Business Address Label"); | 919 | return i18n("Business Address Label"); |
909 | } | 920 | } |
910 | 921 | ||
911 | 922 | ||
912 | QString Addressee::homePhoneLabel() | 923 | QString Addressee::homePhoneLabel() |
913 | { | 924 | { |
914 | return i18n("Home Phone"); | 925 | return i18n("Home Phone"); |
915 | } | 926 | } |
916 | 927 | ||
917 | 928 | ||
918 | QString Addressee::businessPhoneLabel() | 929 | QString Addressee::businessPhoneLabel() |
919 | { | 930 | { |
920 | return i18n("Business Phone"); | 931 | return i18n("Business Phone"); |
921 | } | 932 | } |
922 | 933 | ||
923 | 934 | ||
924 | QString Addressee::mobilePhoneLabel() | 935 | QString Addressee::mobilePhoneLabel() |
925 | { | 936 | { |
926 | return i18n("Mobile Phone"); | 937 | return i18n("Mobile Phone"); |
927 | } | 938 | } |
928 | 939 | ||
929 | 940 | ||
930 | QString Addressee::homeFaxLabel() | 941 | QString Addressee::homeFaxLabel() |
931 | { | 942 | { |
932 | return i18n("Home Fax"); | 943 | return i18n("Home Fax"); |
933 | } | 944 | } |
934 | 945 | ||
935 | 946 | ||
936 | QString Addressee::businessFaxLabel() | 947 | QString Addressee::businessFaxLabel() |
937 | { | 948 | { |
938 | return i18n("Business Fax"); | 949 | return i18n("Business Fax"); |
939 | } | 950 | } |
940 | 951 | ||
941 | 952 | ||
942 | QString Addressee::carPhoneLabel() | 953 | QString Addressee::carPhoneLabel() |
943 | { | 954 | { |
944 | return i18n("Car Phone"); | 955 | return i18n("Car Phone"); |
945 | } | 956 | } |
946 | 957 | ||
947 | 958 | ||
948 | QString Addressee::isdnLabel() | 959 | QString Addressee::isdnLabel() |
949 | { | 960 | { |
950 | return i18n("ISDN"); | 961 | return i18n("ISDN"); |
951 | } | 962 | } |
952 | 963 | ||
953 | 964 | ||
954 | QString Addressee::pagerLabel() | 965 | QString Addressee::pagerLabel() |
955 | { | 966 | { |
956 | return i18n("Pager"); | 967 | return i18n("Pager"); |
957 | } | 968 | } |
958 | 969 | ||
959 | QString Addressee::sipLabel() | 970 | QString Addressee::sipLabel() |
960 | { | 971 | { |
961 | return i18n("SIP"); | 972 | return i18n("SIP"); |
962 | } | 973 | } |
963 | 974 | ||
964 | QString Addressee::emailLabel() | 975 | QString Addressee::emailLabel() |
965 | { | 976 | { |
966 | return i18n("Email Address"); | 977 | return i18n("Email Address"); |
967 | } | 978 | } |
968 | 979 | ||
969 | 980 | ||
970 | void Addressee::setMailer( const QString &mailer ) | 981 | void Addressee::setMailer( const QString &mailer ) |
971 | { | 982 | { |
972 | if ( mailer == mData->mailer ) return; | 983 | if ( mailer == mData->mailer ) return; |
973 | detach(); | 984 | detach(); |
974 | mData->empty = false; | 985 | mData->empty = false; |
975 | mData->mailer = mailer; | 986 | mData->mailer = mailer; |
976 | } | 987 | } |
977 | 988 | ||
978 | QString Addressee::mailer() const | 989 | QString Addressee::mailer() const |
979 | { | 990 | { |
980 | return mData->mailer; | 991 | return mData->mailer; |
981 | } | 992 | } |
982 | 993 | ||
983 | QString Addressee::mailerLabel() | 994 | QString Addressee::mailerLabel() |
984 | { | 995 | { |
985 | return i18n("Mail Client"); | 996 | return i18n("Mail Client"); |
986 | } | 997 | } |
987 | 998 | ||
988 | 999 | ||
989 | void Addressee::setTimeZone( const TimeZone &timeZone ) | 1000 | void Addressee::setTimeZone( const TimeZone &timeZone ) |
990 | { | 1001 | { |
991 | if ( timeZone == mData->timeZone ) return; | 1002 | if ( timeZone == mData->timeZone ) return; |
992 | detach(); | 1003 | detach(); |
993 | mData->empty = false; | 1004 | mData->empty = false; |
994 | mData->timeZone = timeZone; | 1005 | mData->timeZone = timeZone; |
995 | } | 1006 | } |
996 | 1007 | ||
997 | TimeZone Addressee::timeZone() const | 1008 | TimeZone Addressee::timeZone() const |
998 | { | 1009 | { |
999 | return mData->timeZone; | 1010 | return mData->timeZone; |
1000 | } | 1011 | } |
1001 | 1012 | ||
1002 | QString Addressee::timeZoneLabel() | 1013 | QString Addressee::timeZoneLabel() |
1003 | { | 1014 | { |
1004 | return i18n("Time Zone"); | 1015 | return i18n("Time Zone"); |
1005 | } | 1016 | } |
1006 | 1017 | ||
1007 | 1018 | ||
1008 | void Addressee::setGeo( const Geo &geo ) | 1019 | void Addressee::setGeo( const Geo &geo ) |
1009 | { | 1020 | { |
1010 | if ( geo == mData->geo ) return; | 1021 | if ( geo == mData->geo ) return; |
1011 | detach(); | 1022 | detach(); |
1012 | mData->empty = false; | 1023 | mData->empty = false; |
1013 | mData->geo = geo; | 1024 | mData->geo = geo; |
1014 | } | 1025 | } |
1015 | 1026 | ||
1016 | Geo Addressee::geo() const | 1027 | Geo Addressee::geo() const |
1017 | { | 1028 | { |
1018 | return mData->geo; | 1029 | return mData->geo; |
1019 | } | 1030 | } |
1020 | 1031 | ||
1021 | QString Addressee::geoLabel() | 1032 | QString Addressee::geoLabel() |
1022 | { | 1033 | { |
1023 | return i18n("Geographic Position"); | 1034 | return i18n("Geographic Position"); |
1024 | } | 1035 | } |
1025 | 1036 | ||
1026 | 1037 | ||
1027 | void Addressee::setTitle( const QString &title ) | 1038 | void Addressee::setTitle( const QString &title ) |
1028 | { | 1039 | { |
1029 | if ( title == mData->title ) return; | 1040 | if ( title == mData->title ) return; |
1030 | detach(); | 1041 | detach(); |
1031 | mData->empty = false; | 1042 | mData->empty = false; |
1032 | mData->title = title; | 1043 | mData->title = title; |
1033 | } | 1044 | } |
1034 | 1045 | ||
1035 | QString Addressee::title() const | 1046 | QString Addressee::title() const |
1036 | { | 1047 | { |
1037 | return mData->title; | 1048 | return mData->title; |
1038 | } | 1049 | } |
1039 | 1050 | ||
1040 | QString Addressee::titleLabel() | 1051 | QString Addressee::titleLabel() |
1041 | { | 1052 | { |
1042 | return i18n("Title"); | 1053 | return i18n("Title"); |
1043 | } | 1054 | } |
1044 | 1055 | ||
1045 | 1056 | ||
1046 | void Addressee::setRole( const QString &role ) | 1057 | void Addressee::setRole( const QString &role ) |
1047 | { | 1058 | { |
1048 | if ( role == mData->role ) return; | 1059 | if ( role == mData->role ) return; |
1049 | detach(); | 1060 | detach(); |
1050 | mData->empty = false; | 1061 | mData->empty = false; |
1051 | mData->role = role; | 1062 | mData->role = role; |
1052 | } | 1063 | } |
1053 | 1064 | ||
1054 | QString Addressee::role() const | 1065 | QString Addressee::role() const |
1055 | { | 1066 | { |
1056 | return mData->role; | 1067 | return mData->role; |
1057 | } | 1068 | } |
1058 | 1069 | ||
1059 | QString Addressee::roleLabel() | 1070 | QString Addressee::roleLabel() |
1060 | { | 1071 | { |
1061 | return i18n("Role"); | 1072 | return i18n("Role"); |
1062 | } | 1073 | } |
1063 | 1074 | ||
1064 | 1075 | ||
1065 | void Addressee::setOrganization( const QString &organization ) | 1076 | void Addressee::setOrganization( const QString &organization ) |
1066 | { | 1077 | { |
1067 | if ( organization == mData->organization ) return; | 1078 | if ( organization == mData->organization ) return; |
1068 | detach(); | 1079 | detach(); |
1069 | mData->empty = false; | 1080 | mData->empty = false; |
1070 | mData->organization = organization; | 1081 | mData->organization = organization; |
1071 | } | 1082 | } |
1072 | 1083 | ||
1073 | QString Addressee::organization() const | 1084 | QString Addressee::organization() const |
1074 | { | 1085 | { |
1075 | return mData->organization; | 1086 | return mData->organization; |
1076 | } | 1087 | } |
1077 | 1088 | ||
1078 | QString Addressee::organizationLabel() | 1089 | QString Addressee::organizationLabel() |
1079 | { | 1090 | { |
1080 | return i18n("Organization"); | 1091 | return i18n("Organization"); |
1081 | } | 1092 | } |
1082 | 1093 | ||
1083 | 1094 | ||
1084 | void Addressee::setNote( const QString ¬e ) | 1095 | void Addressee::setNote( const QString ¬e ) |
1085 | { | 1096 | { |
1086 | if ( note == mData->note ) return; | 1097 | if ( note == mData->note ) return; |
1087 | detach(); | 1098 | detach(); |
1088 | mData->empty = false; | 1099 | mData->empty = false; |
1089 | mData->note = note; | 1100 | mData->note = note; |
1090 | } | 1101 | } |
1091 | 1102 | ||
1092 | QString Addressee::note() const | 1103 | QString Addressee::note() const |
1093 | { | 1104 | { |
1094 | return mData->note; | 1105 | return mData->note; |
1095 | } | 1106 | } |
1096 | 1107 | ||
1097 | QString Addressee::noteLabel() | 1108 | QString Addressee::noteLabel() |
1098 | { | 1109 | { |
1099 | return i18n("Note"); | 1110 | return i18n("Note"); |
1100 | } | 1111 | } |
1101 | 1112 | ||
1102 | 1113 | ||
1103 | void Addressee::setProductId( const QString &productId ) | 1114 | void Addressee::setProductId( const QString &productId ) |
1104 | { | 1115 | { |
1105 | if ( productId == mData->productId ) return; | 1116 | if ( productId == mData->productId ) return; |
1106 | detach(); | 1117 | detach(); |
1107 | mData->empty = false; | 1118 | mData->empty = false; |
1108 | mData->productId = productId; | 1119 | mData->productId = productId; |
1109 | } | 1120 | } |
1110 | 1121 | ||
1111 | QString Addressee::productId() const | 1122 | QString Addressee::productId() const |
1112 | { | 1123 | { |
1113 | return mData->productId; | 1124 | return mData->productId; |
1114 | } | 1125 | } |
1115 | 1126 | ||
1116 | QString Addressee::productIdLabel() | 1127 | QString Addressee::productIdLabel() |
1117 | { | 1128 | { |
1118 | return i18n("Product Identifier"); | 1129 | return i18n("Product Identifier"); |
1119 | } | 1130 | } |
1120 | 1131 | ||
1121 | 1132 | ||
1122 | void Addressee::setRevision( const QDateTime &revision ) | 1133 | void Addressee::setRevision( const QDateTime &revision ) |
1123 | { | 1134 | { |
1124 | if ( revision == mData->revision ) return; | 1135 | if ( revision == mData->revision ) return; |
1125 | detach(); | 1136 | detach(); |
1126 | mData->empty = false; | 1137 | mData->empty = false; |
1127 | mData->revision = QDateTime( revision.date(), | 1138 | mData->revision = QDateTime( revision.date(), |
1128 | QTime (revision.time().hour(), | 1139 | QTime (revision.time().hour(), |
1129 | revision.time().minute(), | 1140 | revision.time().minute(), |
1130 | revision.time().second())); | 1141 | revision.time().second())); |
1131 | } | 1142 | } |
1132 | 1143 | ||
1133 | QDateTime Addressee::revision() const | 1144 | QDateTime Addressee::revision() const |
1134 | { | 1145 | { |
1135 | return mData->revision; | 1146 | return mData->revision; |
1136 | } | 1147 | } |
1137 | 1148 | ||
1138 | QString Addressee::revisionLabel() | 1149 | QString Addressee::revisionLabel() |
1139 | { | 1150 | { |
1140 | return i18n("Revision Date"); | 1151 | return i18n("Revision Date"); |
1141 | } | 1152 | } |
1142 | 1153 | ||
1143 | 1154 | ||
1144 | void Addressee::setSortString( const QString &sortString ) | 1155 | void Addressee::setSortString( const QString &sortString ) |
1145 | { | 1156 | { |
1146 | if ( sortString == mData->sortString ) return; | 1157 | if ( sortString == mData->sortString ) return; |
1147 | detach(); | 1158 | detach(); |
1148 | mData->empty = false; | 1159 | mData->empty = false; |
1149 | mData->sortString = sortString; | 1160 | mData->sortString = sortString; |
1150 | } | 1161 | } |
1151 | 1162 | ||
1152 | QString Addressee::sortString() const | 1163 | QString Addressee::sortString() const |
1153 | { | 1164 | { |
1154 | return mData->sortString; | 1165 | return mData->sortString; |
1155 | } | 1166 | } |
1156 | 1167 | ||
1157 | QString Addressee::sortStringLabel() | 1168 | QString Addressee::sortStringLabel() |
1158 | { | 1169 | { |
1159 | return i18n("Sort String"); | 1170 | return i18n("Sort String"); |
1160 | } | 1171 | } |
1161 | 1172 | ||
1162 | 1173 | ||
1163 | void Addressee::setUrl( const KURL &url ) | 1174 | void Addressee::setUrl( const KURL &url ) |
1164 | { | 1175 | { |
1165 | if ( url == mData->url ) return; | 1176 | if ( url == mData->url ) return; |
1166 | detach(); | 1177 | detach(); |
1167 | mData->empty = false; | 1178 | mData->empty = false; |
1168 | mData->url = url; | 1179 | mData->url = url; |
1169 | } | 1180 | } |
1170 | 1181 | ||
1171 | KURL Addressee::url() const | 1182 | KURL Addressee::url() const |
1172 | { | 1183 | { |
1173 | return mData->url; | 1184 | return mData->url; |
1174 | } | 1185 | } |
1175 | 1186 | ||
1176 | QString Addressee::urlLabel() | 1187 | QString Addressee::urlLabel() |
1177 | { | 1188 | { |
1178 | return i18n("URL"); | 1189 | return i18n("URL"); |
1179 | } | 1190 | } |
1180 | 1191 | ||
1181 | 1192 | ||
1182 | void Addressee::setSecrecy( const Secrecy &secrecy ) | 1193 | void Addressee::setSecrecy( const Secrecy &secrecy ) |
1183 | { | 1194 | { |
1184 | if ( secrecy == mData->secrecy ) return; | 1195 | if ( secrecy == mData->secrecy ) return; |
1185 | detach(); | 1196 | detach(); |
1186 | mData->empty = false; | 1197 | mData->empty = false; |
1187 | mData->secrecy = secrecy; | 1198 | mData->secrecy = secrecy; |
1188 | } | 1199 | } |
1189 | 1200 | ||
1190 | Secrecy Addressee::secrecy() const | 1201 | Secrecy Addressee::secrecy() const |
1191 | { | 1202 | { |
1192 | return mData->secrecy; | 1203 | return mData->secrecy; |
1193 | } | 1204 | } |
1194 | 1205 | ||
1195 | QString Addressee::secrecyLabel() | 1206 | QString Addressee::secrecyLabel() |
1196 | { | 1207 | { |
1197 | return i18n("Security Class"); | 1208 | return i18n("Security Class"); |
1198 | } | 1209 | } |
1199 | 1210 | ||
1200 | 1211 | ||
1201 | void Addressee::setLogo( const Picture &logo ) | 1212 | void Addressee::setLogo( const Picture &logo ) |
1202 | { | 1213 | { |
1203 | if ( logo == mData->logo ) return; | 1214 | if ( logo == mData->logo ) return; |
1204 | detach(); | 1215 | detach(); |
1205 | mData->empty = false; | 1216 | mData->empty = false; |
1206 | mData->logo = logo; | 1217 | mData->logo = logo; |
1207 | } | 1218 | } |
1208 | 1219 | ||
1209 | Picture Addressee::logo() const | 1220 | Picture Addressee::logo() const |
1210 | { | 1221 | { |
1211 | return mData->logo; | 1222 | return mData->logo; |
1212 | } | 1223 | } |
1213 | 1224 | ||
1214 | QString Addressee::logoLabel() | 1225 | QString Addressee::logoLabel() |
1215 | { | 1226 | { |
1216 | return i18n("Logo"); | 1227 | return i18n("Logo"); |
1217 | } | 1228 | } |
1218 | 1229 | ||
1219 | 1230 | ||
1220 | void Addressee::setPhoto( const Picture &photo ) | 1231 | void Addressee::setPhoto( const Picture &photo ) |
1221 | { | 1232 | { |
1222 | if ( photo == mData->photo ) return; | 1233 | if ( photo == mData->photo ) return; |
1223 | detach(); | 1234 | detach(); |
1224 | mData->empty = false; | 1235 | mData->empty = false; |
1225 | mData->photo = photo; | 1236 | mData->photo = photo; |
1226 | } | 1237 | } |
1227 | 1238 | ||
1228 | Picture Addressee::photo() const | 1239 | Picture Addressee::photo() const |
1229 | { | 1240 | { |
1230 | return mData->photo; | 1241 | return mData->photo; |
1231 | } | 1242 | } |
1232 | 1243 | ||
1233 | QString Addressee::photoLabel() | 1244 | QString Addressee::photoLabel() |
1234 | { | 1245 | { |
1235 | return i18n("Photo"); | 1246 | return i18n("Photo"); |
1236 | } | 1247 | } |
1237 | 1248 | ||
1238 | 1249 | ||
1239 | void Addressee::setSound( const Sound &sound ) | 1250 | void Addressee::setSound( const Sound &sound ) |
1240 | { | 1251 | { |
1241 | if ( sound == mData->sound ) return; | 1252 | if ( sound == mData->sound ) return; |
1242 | detach(); | 1253 | detach(); |
1243 | mData->empty = false; | 1254 | mData->empty = false; |
1244 | mData->sound = sound; | 1255 | mData->sound = sound; |
1245 | } | 1256 | } |
1246 | 1257 | ||
1247 | Sound Addressee::sound() const | 1258 | Sound Addressee::sound() const |
1248 | { | 1259 | { |
1249 | return mData->sound; | 1260 | return mData->sound; |
1250 | } | 1261 | } |
1251 | 1262 | ||
1252 | QString Addressee::soundLabel() | 1263 | QString Addressee::soundLabel() |
1253 | { | 1264 | { |
1254 | return i18n("Sound"); | 1265 | return i18n("Sound"); |
1255 | } | 1266 | } |
1256 | 1267 | ||
1257 | 1268 | ||
1258 | void Addressee::setAgent( const Agent &agent ) | 1269 | void Addressee::setAgent( const Agent &agent ) |
1259 | { | 1270 | { |
1260 | if ( agent == mData->agent ) return; | 1271 | if ( agent == mData->agent ) return; |
1261 | detach(); | 1272 | detach(); |
1262 | mData->empty = false; | 1273 | mData->empty = false; |
1263 | mData->agent = agent; | 1274 | mData->agent = agent; |
1264 | } | 1275 | } |
1265 | 1276 | ||
1266 | Agent Addressee::agent() const | 1277 | Agent Addressee::agent() const |
1267 | { | 1278 | { |
1268 | return mData->agent; | 1279 | return mData->agent; |
1269 | } | 1280 | } |
1270 | 1281 | ||
1271 | QString Addressee::agentLabel() | 1282 | QString Addressee::agentLabel() |
1272 | { | 1283 | { |
1273 | return i18n("Agent"); | 1284 | return i18n("Agent"); |
1274 | } | 1285 | } |
1275 | 1286 | ||
1276 | 1287 | ||
1277 | 1288 | ||
1278 | void Addressee::setNameFromString( const QString &str ) | 1289 | void Addressee::setNameFromString( const QString &str ) |
1279 | { | 1290 | { |
1280 | setFormattedName( str ); | 1291 | setFormattedName( str ); |
1281 | setName( str ); | 1292 | setName( str ); |
1282 | 1293 | ||
1283 | static bool first = true; | 1294 | static bool first = true; |
1284 | static QStringList titles; | 1295 | static QStringList titles; |
1285 | static QStringList suffixes; | 1296 | static QStringList suffixes; |
1286 | static QStringList prefixes; | 1297 | static QStringList prefixes; |
1287 | 1298 | ||
1288 | if ( first ) { | 1299 | if ( first ) { |
1289 | first = false; | 1300 | first = false; |
1290 | titles += i18n( "Dr." ); | 1301 | titles += i18n( "Dr." ); |
1291 | titles += i18n( "Miss" ); | 1302 | titles += i18n( "Miss" ); |
1292 | titles += i18n( "Mr." ); | 1303 | titles += i18n( "Mr." ); |
1293 | titles += i18n( "Mrs." ); | 1304 | titles += i18n( "Mrs." ); |
1294 | titles += i18n( "Ms." ); | 1305 | titles += i18n( "Ms." ); |
1295 | titles += i18n( "Prof." ); | 1306 | titles += i18n( "Prof." ); |
1296 | 1307 | ||
1297 | suffixes += i18n( "I" ); | 1308 | suffixes += i18n( "I" ); |
1298 | suffixes += i18n( "II" ); | 1309 | suffixes += i18n( "II" ); |
1299 | suffixes += i18n( "III" ); | 1310 | suffixes += i18n( "III" ); |
1300 | suffixes += i18n( "Jr." ); | 1311 | suffixes += i18n( "Jr." ); |
1301 | suffixes += i18n( "Sr." ); | 1312 | suffixes += i18n( "Sr." ); |
1302 | 1313 | ||
1303 | prefixes += "van"; | 1314 | prefixes += "van"; |
1304 | prefixes += "von"; | 1315 | prefixes += "von"; |
1305 | prefixes += "de"; | 1316 | prefixes += "de"; |
1306 | 1317 | ||
1307 | KConfig config( locateLocal( "config", "kabcrc") ); | 1318 | KConfig config( locateLocal( "config", "kabcrc") ); |
1308 | config.setGroup( "General" ); | 1319 | config.setGroup( "General" ); |
1309 | titles += config.readListEntry( "Prefixes" ); | 1320 | titles += config.readListEntry( "Prefixes" ); |
1310 | titles.remove( "" ); | 1321 | titles.remove( "" ); |
1311 | prefixes += config.readListEntry( "Inclusions" ); | 1322 | prefixes += config.readListEntry( "Inclusions" ); |
1312 | prefixes.remove( "" ); | 1323 | prefixes.remove( "" ); |
1313 | suffixes += config.readListEntry( "Suffixes" ); | 1324 | suffixes += config.readListEntry( "Suffixes" ); |
1314 | suffixes.remove( "" ); | 1325 | suffixes.remove( "" ); |
1315 | } | 1326 | } |
1316 | 1327 | ||
1317 | // clear all name parts | 1328 | // clear all name parts |
1318 | setPrefix( "" ); | 1329 | setPrefix( "" ); |
1319 | setGivenName( "" ); | 1330 | setGivenName( "" ); |
1320 | setAdditionalName( "" ); | 1331 | setAdditionalName( "" ); |
1321 | setFamilyName( "" ); | 1332 | setFamilyName( "" ); |
1322 | setSuffix( "" ); | 1333 | setSuffix( "" ); |
1323 | 1334 | ||
1324 | if ( str.isEmpty() ) | 1335 | if ( str.isEmpty() ) |
1325 | return; | 1336 | return; |
1326 | 1337 | ||
1327 | int i = str.find(','); | 1338 | int i = str.find(','); |
1328 | if( i < 0 ) { | 1339 | if( i < 0 ) { |
1329 | QStringList parts = QStringList::split( " ", str ); | 1340 | QStringList parts = QStringList::split( " ", str ); |
1330 | int leftOffset = 0; | 1341 | int leftOffset = 0; |
1331 | int rightOffset = parts.count() - 1; | 1342 | int rightOffset = parts.count() - 1; |
1332 | 1343 | ||
1333 | QString suffix; | 1344 | QString suffix; |
1334 | while ( rightOffset >= 0 ) { | 1345 | while ( rightOffset >= 0 ) { |
1335 | if ( suffixes.contains( parts[ rightOffset ] ) ) { | 1346 | if ( suffixes.contains( parts[ rightOffset ] ) ) { |
1336 | suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); | 1347 | suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); |
1337 | rightOffset--; | 1348 | rightOffset--; |
1338 | } else | 1349 | } else |
1339 | break; | 1350 | break; |
1340 | } | 1351 | } |
1341 | setSuffix( suffix ); | 1352 | setSuffix( suffix ); |
1342 | 1353 | ||
1343 | if ( rightOffset < 0 ) | 1354 | if ( rightOffset < 0 ) |
1344 | return; | 1355 | return; |
1345 | 1356 | ||
1346 | if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { | 1357 | if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { |
1347 | setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); | 1358 | setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); |
1348 | rightOffset--; | 1359 | rightOffset--; |
1349 | } else | 1360 | } else |
1350 | setFamilyName( parts[ rightOffset ] ); | 1361 | setFamilyName( parts[ rightOffset ] ); |
1351 | 1362 | ||
1352 | QString prefix; | 1363 | QString prefix; |
1353 | while ( leftOffset < rightOffset ) { | 1364 | while ( leftOffset < rightOffset ) { |
1354 | if ( titles.contains( parts[ leftOffset ] ) ) { | 1365 | if ( titles.contains( parts[ leftOffset ] ) ) { |
1355 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 1366 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
1356 | leftOffset++; | 1367 | leftOffset++; |
1357 | } else | 1368 | } else |
1358 | break; | 1369 | break; |
1359 | } | 1370 | } |
1360 | setPrefix( prefix ); | 1371 | setPrefix( prefix ); |
1361 | 1372 | ||
1362 | if ( leftOffset < rightOffset ) { | 1373 | if ( leftOffset < rightOffset ) { |
1363 | setGivenName( parts[ leftOffset ] ); | 1374 | setGivenName( parts[ leftOffset ] ); |
1364 | leftOffset++; | 1375 | leftOffset++; |
1365 | } | 1376 | } |
1366 | 1377 | ||
1367 | QString additionalName; | 1378 | QString additionalName; |
1368 | while ( leftOffset < rightOffset ) { | 1379 | while ( leftOffset < rightOffset ) { |
1369 | additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 1380 | additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
1370 | leftOffset++; | 1381 | leftOffset++; |
1371 | } | 1382 | } |
1372 | setAdditionalName( additionalName ); | 1383 | setAdditionalName( additionalName ); |
1373 | } else { | 1384 | } else { |
1374 | QString part1 = str.left( i ); | 1385 | QString part1 = str.left( i ); |
1375 | QString part2 = str.mid( i + 1 ); | 1386 | QString part2 = str.mid( i + 1 ); |
1376 | 1387 | ||
1377 | QStringList parts = QStringList::split( " ", part1 ); | 1388 | QStringList parts = QStringList::split( " ", part1 ); |
1378 | int leftOffset = 0; | 1389 | int leftOffset = 0; |
1379 | int rightOffset = parts.count() - 1; | 1390 | int rightOffset = parts.count() - 1; |
1380 | 1391 | ||
1381 | QString suffix; | 1392 | QString suffix; |
1382 | while ( rightOffset >= 0 ) { | 1393 | while ( rightOffset >= 0 ) { |
1383 | if ( suffixes.contains( parts[ rightOffset ] ) ) { | 1394 | if ( suffixes.contains( parts[ rightOffset ] ) ) { |
1384 | suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); | 1395 | suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); |
1385 | rightOffset--; | 1396 | rightOffset--; |
1386 | } else | 1397 | } else |
1387 | break; | 1398 | break; |
1388 | } | 1399 | } |
1389 | setSuffix( suffix ); | 1400 | setSuffix( suffix ); |
1390 | 1401 | ||
1391 | if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { | 1402 | if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { |
1392 | setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); | 1403 | setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); |
1393 | rightOffset--; | 1404 | rightOffset--; |
1394 | } else | 1405 | } else |
1395 | setFamilyName( parts[ rightOffset ] ); | 1406 | setFamilyName( parts[ rightOffset ] ); |
1396 | 1407 | ||
1397 | QString prefix; | 1408 | QString prefix; |
1398 | while ( leftOffset < rightOffset ) { | 1409 | while ( leftOffset < rightOffset ) { |
1399 | if ( titles.contains( parts[ leftOffset ] ) ) { | 1410 | if ( titles.contains( parts[ leftOffset ] ) ) { |
1400 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 1411 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
1401 | leftOffset++; | 1412 | leftOffset++; |
1402 | } else | 1413 | } else |
1403 | break; | 1414 | break; |
1404 | } | 1415 | } |
1405 | 1416 | ||
1406 | parts = QStringList::split( " ", part2 ); | 1417 | parts = QStringList::split( " ", part2 ); |
1407 | 1418 | ||
1408 | leftOffset = 0; | 1419 | leftOffset = 0; |
1409 | rightOffset = parts.count(); | 1420 | rightOffset = parts.count(); |
1410 | 1421 | ||
1411 | while ( leftOffset < rightOffset ) { | 1422 | while ( leftOffset < rightOffset ) { |
1412 | if ( titles.contains( parts[ leftOffset ] ) ) { | 1423 | if ( titles.contains( parts[ leftOffset ] ) ) { |
1413 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 1424 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
1414 | leftOffset++; | 1425 | leftOffset++; |
1415 | } else | 1426 | } else |
1416 | break; | 1427 | break; |
1417 | } | 1428 | } |
1418 | setPrefix( prefix ); | 1429 | setPrefix( prefix ); |
1419 | 1430 | ||
1420 | if ( leftOffset < rightOffset ) { | 1431 | if ( leftOffset < rightOffset ) { |
1421 | setGivenName( parts[ leftOffset ] ); | 1432 | setGivenName( parts[ leftOffset ] ); |
1422 | leftOffset++; | 1433 | leftOffset++; |
1423 | } | 1434 | } |
1424 | 1435 | ||
1425 | QString additionalName; | 1436 | QString additionalName; |
1426 | while ( leftOffset < rightOffset ) { | 1437 | while ( leftOffset < rightOffset ) { |
1427 | additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 1438 | additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
1428 | leftOffset++; | 1439 | leftOffset++; |
1429 | } | 1440 | } |
1430 | setAdditionalName( additionalName ); | 1441 | setAdditionalName( additionalName ); |
1431 | } | 1442 | } |
1432 | } | 1443 | } |
1433 | 1444 | ||
1434 | QString Addressee::realName() const | 1445 | QString Addressee::realName() const |
1435 | { | 1446 | { |
1436 | if ( !formattedName().isEmpty() ) | 1447 | if ( !formattedName().isEmpty() ) |
1437 | return formattedName(); | 1448 | return formattedName(); |
1438 | 1449 | ||
1439 | QString n = assembledName(); | 1450 | QString n = assembledName(); |
1440 | 1451 | ||
1441 | if ( n.isEmpty() ) | 1452 | if ( n.isEmpty() ) |
1442 | n = name(); | 1453 | n = name(); |
1443 | 1454 | ||
1444 | return n; | 1455 | return n; |
1445 | } | 1456 | } |
1446 | 1457 | ||
1447 | QString Addressee::assembledName() const | 1458 | QString Addressee::assembledName() const |
1448 | { | 1459 | { |
1449 | QString name = prefix() + " " + givenName() + " " + additionalName() + " " + | 1460 | QString name = prefix() + " " + givenName() + " " + additionalName() + " " + |
1450 | familyName() + " " + suffix(); | 1461 | familyName() + " " + suffix(); |
1451 | 1462 | ||
1452 | return name.simplifyWhiteSpace(); | 1463 | return name.simplifyWhiteSpace(); |
1453 | } | 1464 | } |
1454 | 1465 | ||
1455 | QString Addressee::fullEmail( const QString &email ) const | 1466 | QString Addressee::fullEmail( const QString &email ) const |
1456 | { | 1467 | { |
1457 | QString e; | 1468 | QString e; |
1458 | if ( email.isNull() ) { | 1469 | if ( email.isNull() ) { |
1459 | e = preferredEmail(); | 1470 | e = preferredEmail(); |
1460 | } else { | 1471 | } else { |
1461 | e = email; | 1472 | e = email; |
1462 | } | 1473 | } |
1463 | if ( e.isEmpty() ) return QString::null; | 1474 | if ( e.isEmpty() ) return QString::null; |
1464 | 1475 | ||
1465 | QString text; | 1476 | QString text; |
1466 | if ( realName().isEmpty() ) | 1477 | if ( realName().isEmpty() ) |
1467 | text = e; | 1478 | text = e; |
1468 | else | 1479 | else |
1469 | text = assembledName() + " <" + e + ">"; | 1480 | text = assembledName() + " <" + e + ">"; |
1470 | 1481 | ||
1471 | return text; | 1482 | return text; |
1472 | } | 1483 | } |
1473 | 1484 | ||
1474 | void Addressee::insertEmail( const QString &email, bool preferred ) | 1485 | void Addressee::insertEmail( const QString &email, bool preferred ) |
1475 | { | 1486 | { |
1476 | detach(); | 1487 | detach(); |
1477 | 1488 | ||
1478 | QStringList::Iterator it = mData->emails.find( email ); | 1489 | QStringList::Iterator it = mData->emails.find( email ); |
1479 | 1490 | ||
1480 | if ( it != mData->emails.end() ) { | 1491 | if ( it != mData->emails.end() ) { |
1481 | if ( !preferred || it == mData->emails.begin() ) return; | 1492 | if ( !preferred || it == mData->emails.begin() ) return; |
1482 | mData->emails.remove( it ); | 1493 | mData->emails.remove( it ); |
1483 | mData->emails.prepend( email ); | 1494 | mData->emails.prepend( email ); |
1484 | } else { | 1495 | } else { |
1485 | if ( preferred ) { | 1496 | if ( preferred ) { |
1486 | mData->emails.prepend( email ); | 1497 | mData->emails.prepend( email ); |
1487 | } else { | 1498 | } else { |
1488 | mData->emails.append( email ); | 1499 | mData->emails.append( email ); |
1489 | } | 1500 | } |
1490 | } | 1501 | } |
1491 | } | 1502 | } |
1492 | 1503 | ||
1493 | void Addressee::removeEmail( const QString &email ) | 1504 | void Addressee::removeEmail( const QString &email ) |
1494 | { | 1505 | { |
1495 | detach(); | 1506 | detach(); |
1496 | 1507 | ||
1497 | QStringList::Iterator it = mData->emails.find( email ); | 1508 | QStringList::Iterator it = mData->emails.find( email ); |
1498 | if ( it == mData->emails.end() ) return; | 1509 | if ( it == mData->emails.end() ) return; |
1499 | 1510 | ||
1500 | mData->emails.remove( it ); | 1511 | mData->emails.remove( it ); |
1501 | } | 1512 | } |
1502 | 1513 | ||
1503 | QString Addressee::preferredEmail() const | 1514 | QString Addressee::preferredEmail() const |
1504 | { | 1515 | { |
1505 | if ( mData->emails.count() == 0 ) return QString::null; | 1516 | if ( mData->emails.count() == 0 ) return QString::null; |
1506 | else return mData->emails.first(); | 1517 | else return mData->emails.first(); |
1507 | } | 1518 | } |
1508 | 1519 | ||
1509 | QStringList Addressee::emails() const | 1520 | QStringList Addressee::emails() const |
1510 | { | 1521 | { |
1511 | return mData->emails; | 1522 | return mData->emails; |
1512 | } | 1523 | } |
1513 | void Addressee::setEmails( const QStringList& emails ) { | 1524 | void Addressee::setEmails( const QStringList& emails ) { |
1514 | detach(); | 1525 | detach(); |
1515 | mData->emails = emails; | 1526 | mData->emails = emails; |
1516 | } | 1527 | } |
1517 | void Addressee::insertPhoneNumber( const PhoneNumber &phoneNumber ) | 1528 | void Addressee::insertPhoneNumber( const PhoneNumber &phoneNumber ) |
1518 | { | 1529 | { |
1519 | detach(); | 1530 | detach(); |
1520 | mData->empty = false; | 1531 | mData->empty = false; |
1521 | 1532 | ||
1522 | PhoneNumber::List::Iterator it; | 1533 | PhoneNumber::List::Iterator it; |
1523 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1534 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1524 | if ( (*it).id() == phoneNumber.id() ) { | 1535 | if ( (*it).id() == phoneNumber.id() ) { |
1525 | *it = phoneNumber; | 1536 | *it = phoneNumber; |
1526 | return; | 1537 | return; |
1527 | } | 1538 | } |
1528 | } | 1539 | } |
1529 | mData->phoneNumbers.append( phoneNumber ); | 1540 | mData->phoneNumbers.append( phoneNumber ); |
1530 | } | 1541 | } |
1531 | 1542 | ||
1532 | void Addressee::removePhoneNumber( const PhoneNumber &phoneNumber ) | 1543 | void Addressee::removePhoneNumber( const PhoneNumber &phoneNumber ) |
1533 | { | 1544 | { |
1534 | detach(); | 1545 | detach(); |
1535 | 1546 | ||
1536 | PhoneNumber::List::Iterator it; | 1547 | PhoneNumber::List::Iterator it; |
1537 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1548 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1538 | if ( (*it).id() == phoneNumber.id() ) { | 1549 | if ( (*it).id() == phoneNumber.id() ) { |
1539 | mData->phoneNumbers.remove( it ); | 1550 | mData->phoneNumbers.remove( it ); |
1540 | return; | 1551 | return; |
1541 | } | 1552 | } |
1542 | } | 1553 | } |
1543 | } | 1554 | } |
1544 | 1555 | ||
1545 | PhoneNumber Addressee::phoneNumber( int type ) const | 1556 | PhoneNumber Addressee::phoneNumber( int type ) const |
1546 | { | 1557 | { |
1547 | PhoneNumber phoneNumber( "", type ); | 1558 | PhoneNumber phoneNumber( "", type ); |
1548 | PhoneNumber::List::ConstIterator it; | 1559 | PhoneNumber::List::ConstIterator it; |
1549 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1560 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1550 | if ( matchBinaryPatternP( (*it).type(), type ) ) { | 1561 | if ( matchBinaryPatternP( (*it).type(), type ) ) { |
1551 | if ( (*it).type() & PhoneNumber::Pref ) | 1562 | if ( (*it).type() & PhoneNumber::Pref ) |
1552 | return (*it); | 1563 | return (*it); |
1553 | else if ( phoneNumber.number().isEmpty() ) | 1564 | else if ( phoneNumber.number().isEmpty() ) |
1554 | phoneNumber = (*it); | 1565 | phoneNumber = (*it); |
1555 | } | 1566 | } |
1556 | } | 1567 | } |
1557 | 1568 | ||
1558 | return phoneNumber; | 1569 | return phoneNumber; |
1559 | } | 1570 | } |
1560 | 1571 | ||
1561 | PhoneNumber::List Addressee::phoneNumbers() const | 1572 | PhoneNumber::List Addressee::phoneNumbers() const |
1562 | { | 1573 | { |
1563 | return mData->phoneNumbers; | 1574 | return mData->phoneNumbers; |
1564 | } | 1575 | } |
1565 | 1576 | ||
1566 | PhoneNumber::List Addressee::phoneNumbers( int type ) const | 1577 | PhoneNumber::List Addressee::phoneNumbers( int type ) const |
1567 | { | 1578 | { |
1568 | PhoneNumber::List list; | 1579 | PhoneNumber::List list; |
1569 | 1580 | ||
1570 | PhoneNumber::List::ConstIterator it; | 1581 | PhoneNumber::List::ConstIterator it; |
1571 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1582 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1572 | if ( matchBinaryPattern( (*it).type(), type ) ) { | 1583 | if ( matchBinaryPattern( (*it).type(), type ) ) { |
1573 | list.append( *it ); | 1584 | list.append( *it ); |
1574 | } | 1585 | } |
1575 | } | 1586 | } |
1576 | return list; | 1587 | return list; |
1577 | } | 1588 | } |
1578 | 1589 | ||
1579 | PhoneNumber Addressee::findPhoneNumber( const QString &id ) const | 1590 | PhoneNumber Addressee::findPhoneNumber( const QString &id ) const |
1580 | { | 1591 | { |
1581 | PhoneNumber::List::ConstIterator it; | 1592 | PhoneNumber::List::ConstIterator it; |
1582 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1593 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1583 | if ( (*it).id() == id ) { | 1594 | if ( (*it).id() == id ) { |
1584 | return *it; | 1595 | return *it; |
1585 | } | 1596 | } |
1586 | } | 1597 | } |
1587 | return PhoneNumber(); | 1598 | return PhoneNumber(); |
1588 | } | 1599 | } |
1589 | 1600 | ||
1590 | void Addressee::insertKey( const Key &key ) | 1601 | void Addressee::insertKey( const Key &key ) |
1591 | { | 1602 | { |
1592 | detach(); | 1603 | detach(); |
1593 | mData->empty = false; | 1604 | mData->empty = false; |
1594 | 1605 | ||
1595 | Key::List::Iterator it; | 1606 | Key::List::Iterator it; |
1596 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1607 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1597 | if ( (*it).id() == key.id() ) { | 1608 | if ( (*it).id() == key.id() ) { |
1598 | *it = key; | 1609 | *it = key; |
1599 | return; | 1610 | return; |
1600 | } | 1611 | } |
1601 | } | 1612 | } |
1602 | mData->keys.append( key ); | 1613 | mData->keys.append( key ); |
1603 | } | 1614 | } |
1604 | 1615 | ||
1605 | void Addressee::removeKey( const Key &key ) | 1616 | void Addressee::removeKey( const Key &key ) |
1606 | { | 1617 | { |
1607 | detach(); | 1618 | detach(); |
1608 | 1619 | ||
1609 | Key::List::Iterator it; | 1620 | Key::List::Iterator it; |
1610 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1621 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1611 | if ( (*it).id() == key.id() ) { | 1622 | if ( (*it).id() == key.id() ) { |
1612 | mData->keys.remove( key ); | 1623 | mData->keys.remove( key ); |
1613 | return; | 1624 | return; |
1614 | } | 1625 | } |
1615 | } | 1626 | } |
1616 | } | 1627 | } |
1617 | 1628 | ||
1618 | Key Addressee::key( int type, QString customTypeString ) const | 1629 | Key Addressee::key( int type, QString customTypeString ) const |
1619 | { | 1630 | { |
1620 | Key::List::ConstIterator it; | 1631 | Key::List::ConstIterator it; |
1621 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1632 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1622 | if ( (*it).type() == type ) { | 1633 | if ( (*it).type() == type ) { |
1623 | if ( type == Key::Custom ) { | 1634 | if ( type == Key::Custom ) { |
1624 | if ( customTypeString.isEmpty() ) { | 1635 | if ( customTypeString.isEmpty() ) { |
1625 | return *it; | 1636 | return *it; |
1626 | } else { | 1637 | } else { |
1627 | if ( (*it).customTypeString() == customTypeString ) | 1638 | if ( (*it).customTypeString() == customTypeString ) |
1628 | return (*it); | 1639 | return (*it); |
1629 | } | 1640 | } |
1630 | } else { | 1641 | } else { |
1631 | return *it; | 1642 | return *it; |
1632 | } | 1643 | } |
1633 | } | 1644 | } |
1634 | } | 1645 | } |
1635 | return Key( QString(), type ); | 1646 | return Key( QString(), type ); |
1636 | } | 1647 | } |
1637 | void Addressee::setKeys( const Key::List& list ) { | 1648 | void Addressee::setKeys( const Key::List& list ) { |
1638 | detach(); | 1649 | detach(); |
1639 | mData->keys = list; | 1650 | mData->keys = list; |
1640 | } | 1651 | } |
1641 | 1652 | ||
1642 | Key::List Addressee::keys() const | 1653 | Key::List Addressee::keys() const |
1643 | { | 1654 | { |
1644 | return mData->keys; | 1655 | return mData->keys; |
1645 | } | 1656 | } |
1646 | 1657 | ||
1647 | Key::List Addressee::keys( int type, QString customTypeString ) const | 1658 | Key::List Addressee::keys( int type, QString customTypeString ) const |
1648 | { | 1659 | { |
1649 | Key::List list; | 1660 | Key::List list; |
1650 | 1661 | ||
1651 | Key::List::ConstIterator it; | 1662 | Key::List::ConstIterator it; |
1652 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1663 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1653 | if ( (*it).type() == type ) { | 1664 | if ( (*it).type() == type ) { |
1654 | if ( type == Key::Custom ) { | 1665 | if ( type == Key::Custom ) { |
1655 | if ( customTypeString.isEmpty() ) { | 1666 | if ( customTypeString.isEmpty() ) { |
1656 | list.append(*it); | 1667 | list.append(*it); |
1657 | } else { | 1668 | } else { |
1658 | if ( (*it).customTypeString() == customTypeString ) | 1669 | if ( (*it).customTypeString() == customTypeString ) |
1659 | list.append(*it); | 1670 | list.append(*it); |
1660 | } | 1671 | } |
1661 | } else { | 1672 | } else { |
1662 | list.append(*it); | 1673 | list.append(*it); |
1663 | } | 1674 | } |
1664 | } | 1675 | } |
1665 | } | 1676 | } |
1666 | return list; | 1677 | return list; |
1667 | } | 1678 | } |
1668 | 1679 | ||
1669 | Key Addressee::findKey( const QString &id ) const | 1680 | Key Addressee::findKey( const QString &id ) const |
1670 | { | 1681 | { |
1671 | Key::List::ConstIterator it; | 1682 | Key::List::ConstIterator it; |
1672 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1683 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1673 | if ( (*it).id() == id ) { | 1684 | if ( (*it).id() == id ) { |
1674 | return *it; | 1685 | return *it; |
1675 | } | 1686 | } |
1676 | } | 1687 | } |
1677 | return Key(); | 1688 | return Key(); |
1678 | } | 1689 | } |
1679 | 1690 | ||
1680 | QString Addressee::asString() const | 1691 | QString Addressee::asString() const |
1681 | { | 1692 | { |
1682 | return "Smith, agent Smith..."; | 1693 | return "Smith, agent Smith..."; |
1683 | } | 1694 | } |
1684 | 1695 | ||
1685 | void Addressee::dump() const | 1696 | void Addressee::dump() const |
1686 | { | 1697 | { |
1687 | return; | 1698 | return; |
1688 | #if 0 | 1699 | #if 0 |
1689 | kdDebug(5700) << "Addressee {" << endl; | 1700 | kdDebug(5700) << "Addressee {" << endl; |
1690 | 1701 | ||
1691 | kdDebug(5700) << " Uid: '" << uid() << "'" << endl; | 1702 | kdDebug(5700) << " Uid: '" << uid() << "'" << endl; |
1692 | 1703 | ||
1693 | kdDebug(5700) << " Name: '" << name() << "'" << endl; | 1704 | kdDebug(5700) << " Name: '" << name() << "'" << endl; |
1694 | kdDebug(5700) << " FormattedName: '" << formattedName() << "'" << endl; | 1705 | kdDebug(5700) << " FormattedName: '" << formattedName() << "'" << endl; |
1695 | kdDebug(5700) << " FamilyName: '" << familyName() << "'" << endl; | 1706 | kdDebug(5700) << " FamilyName: '" << familyName() << "'" << endl; |
1696 | kdDebug(5700) << " GivenName: '" << givenName() << "'" << endl; | 1707 | kdDebug(5700) << " GivenName: '" << givenName() << "'" << endl; |
1697 | kdDebug(5700) << " AdditionalName: '" << additionalName() << "'" << endl; | 1708 | kdDebug(5700) << " AdditionalName: '" << additionalName() << "'" << endl; |
1698 | kdDebug(5700) << " Prefix: '" << prefix() << "'" << endl; | 1709 | kdDebug(5700) << " Prefix: '" << prefix() << "'" << endl; |
1699 | kdDebug(5700) << " Suffix: '" << suffix() << "'" << endl; | 1710 | kdDebug(5700) << " Suffix: '" << suffix() << "'" << endl; |
1700 | kdDebug(5700) << " NickName: '" << nickName() << "'" << endl; | 1711 | kdDebug(5700) << " NickName: '" << nickName() << "'" << endl; |
1701 | kdDebug(5700) << " Birthday: '" << birthday().toString() << "'" << endl; | 1712 | kdDebug(5700) << " Birthday: '" << birthday().toString() << "'" << endl; |
1702 | kdDebug(5700) << " Mailer: '" << mailer() << "'" << endl; | 1713 | kdDebug(5700) << " Mailer: '" << mailer() << "'" << endl; |
1703 | kdDebug(5700) << " TimeZone: '" << timeZone().asString() << "'" << endl; | 1714 | kdDebug(5700) << " TimeZone: '" << timeZone().asString() << "'" << endl; |
1704 | kdDebug(5700) << " Geo: '" << geo().asString() << "'" << endl; | 1715 | kdDebug(5700) << " Geo: '" << geo().asString() << "'" << endl; |
1705 | kdDebug(5700) << " Title: '" << title() << "'" << endl; | 1716 | kdDebug(5700) << " Title: '" << title() << "'" << endl; |
1706 | kdDebug(5700) << " Role: '" << role() << "'" << endl; | 1717 | kdDebug(5700) << " Role: '" << role() << "'" << endl; |
1707 | kdDebug(5700) << " Organization: '" << organization() << "'" << endl; | 1718 | kdDebug(5700) << " Organization: '" << organization() << "'" << endl; |
1708 | kdDebug(5700) << " Note: '" << note() << "'" << endl; | 1719 | kdDebug(5700) << " Note: '" << note() << "'" << endl; |
1709 | kdDebug(5700) << " ProductId: '" << productId() << "'" << endl; | 1720 | kdDebug(5700) << " ProductId: '" << productId() << "'" << endl; |
1710 | kdDebug(5700) << " Revision: '" << revision().toString() << "'" << endl; | 1721 | kdDebug(5700) << " Revision: '" << revision().toString() << "'" << endl; |
1711 | kdDebug(5700) << " SortString: '" << sortString() << "'" << endl; | 1722 | kdDebug(5700) << " SortString: '" << sortString() << "'" << endl; |
1712 | kdDebug(5700) << " Url: '" << url().url() << "'" << endl; | 1723 | kdDebug(5700) << " Url: '" << url().url() << "'" << endl; |
1713 | kdDebug(5700) << " Secrecy: '" << secrecy().asString() << "'" << endl; | 1724 | kdDebug(5700) << " Secrecy: '" << secrecy().asString() << "'" << endl; |
1714 | kdDebug(5700) << " Logo: '" << logo().asString() << "'" << endl; | 1725 | kdDebug(5700) << " Logo: '" << logo().asString() << "'" << endl; |
1715 | kdDebug(5700) << " Photo: '" << photo().asString() << "'" << endl; | 1726 | kdDebug(5700) << " Photo: '" << photo().asString() << "'" << endl; |
1716 | kdDebug(5700) << " Sound: '" << sound().asString() << "'" << endl; | 1727 | kdDebug(5700) << " Sound: '" << sound().asString() << "'" << endl; |
1717 | kdDebug(5700) << " Agent: '" << agent().asString() << "'" << endl; | 1728 | kdDebug(5700) << " Agent: '" << agent().asString() << "'" << endl; |
1718 | 1729 | ||
1719 | kdDebug(5700) << " Emails {" << endl; | 1730 | kdDebug(5700) << " Emails {" << endl; |
1720 | QStringList e = emails(); | 1731 | QStringList e = emails(); |
1721 | QStringList::ConstIterator it; | 1732 | QStringList::ConstIterator it; |
1722 | for( it = e.begin(); it != e.end(); ++it ) { | 1733 | for( it = e.begin(); it != e.end(); ++it ) { |
1723 | kdDebug(5700) << " " << (*it) << endl; | 1734 | kdDebug(5700) << " " << (*it) << endl; |
1724 | } | 1735 | } |
1725 | kdDebug(5700) << " }" << endl; | 1736 | kdDebug(5700) << " }" << endl; |
1726 | 1737 | ||
1727 | kdDebug(5700) << " PhoneNumbers {" << endl; | 1738 | kdDebug(5700) << " PhoneNumbers {" << endl; |
1728 | PhoneNumber::List p = phoneNumbers(); | 1739 | PhoneNumber::List p = phoneNumbers(); |
1729 | PhoneNumber::List::ConstIterator it2; | 1740 | PhoneNumber::List::ConstIterator it2; |
1730 | for( it2 = p.begin(); it2 != p.end(); ++it2 ) { | 1741 | for( it2 = p.begin(); it2 != p.end(); ++it2 ) { |
1731 | kdDebug(5700) << " Type: " << int((*it2).type()) << " Number: " << (*it2).number() << endl; | 1742 | kdDebug(5700) << " Type: " << int((*it2).type()) << " Number: " << (*it2).number() << endl; |
1732 | } | 1743 | } |
1733 | kdDebug(5700) << " }" << endl; | 1744 | kdDebug(5700) << " }" << endl; |
1734 | 1745 | ||
1735 | Address::List a = addresses(); | 1746 | Address::List a = addresses(); |
1736 | Address::List::ConstIterator it3; | 1747 | Address::List::ConstIterator it3; |
1737 | for( it3 = a.begin(); it3 != a.end(); ++it3 ) { | 1748 | for( it3 = a.begin(); it3 != a.end(); ++it3 ) { |
1738 | (*it3).dump(); | 1749 | (*it3).dump(); |
1739 | } | 1750 | } |
1740 | 1751 | ||
1741 | kdDebug(5700) << " Keys {" << endl; | 1752 | kdDebug(5700) << " Keys {" << endl; |
1742 | Key::List k = keys(); | 1753 | Key::List k = keys(); |
1743 | Key::List::ConstIterator it4; | 1754 | Key::List::ConstIterator it4; |
1744 | for( it4 = k.begin(); it4 != k.end(); ++it4 ) { | 1755 | for( it4 = k.begin(); it4 != k.end(); ++it4 ) { |
1745 | kdDebug(5700) << " Type: " << int((*it4).type()) << | 1756 | kdDebug(5700) << " Type: " << int((*it4).type()) << |
1746 | " Key: " << (*it4).textData() << | 1757 | " Key: " << (*it4).textData() << |
1747 | " CustomString: " << (*it4).customTypeString() << endl; | 1758 | " CustomString: " << (*it4).customTypeString() << endl; |
1748 | } | 1759 | } |
1749 | kdDebug(5700) << " }" << endl; | 1760 | kdDebug(5700) << " }" << endl; |
1750 | 1761 | ||
1751 | kdDebug(5700) << "}" << endl; | 1762 | kdDebug(5700) << "}" << endl; |
1752 | #endif | 1763 | #endif |
1753 | } | 1764 | } |
1754 | 1765 | ||
1755 | 1766 | ||
1756 | void Addressee::insertAddress( const Address &address ) | 1767 | void Addressee::insertAddress( const Address &address ) |
1757 | { | 1768 | { |
1758 | detach(); | 1769 | detach(); |
1759 | mData->empty = false; | 1770 | mData->empty = false; |
1760 | 1771 | ||
1761 | Address::List::Iterator it; | 1772 | Address::List::Iterator it; |
1762 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 1773 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1763 | if ( (*it).id() == address.id() ) { | 1774 | if ( (*it).id() == address.id() ) { |
1764 | *it = address; | 1775 | *it = address; |
1765 | return; | 1776 | return; |
1766 | } | 1777 | } |
1767 | } | 1778 | } |
1768 | mData->addresses.append( address ); | 1779 | mData->addresses.append( address ); |
1769 | } | 1780 | } |
1770 | 1781 | ||
1771 | void Addressee::removeAddress( const Address &address ) | 1782 | void Addressee::removeAddress( const Address &address ) |
1772 | { | 1783 | { |
1773 | detach(); | 1784 | detach(); |
1774 | 1785 | ||
1775 | Address::List::Iterator it; | 1786 | Address::List::Iterator it; |
1776 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 1787 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1777 | if ( (*it).id() == address.id() ) { | 1788 | if ( (*it).id() == address.id() ) { |
1778 | mData->addresses.remove( it ); | 1789 | mData->addresses.remove( it ); |
1779 | return; | 1790 | return; |
1780 | } | 1791 | } |
1781 | } | 1792 | } |
1782 | } | 1793 | } |
1783 | 1794 | ||
1784 | Address Addressee::address( int type ) const | 1795 | Address Addressee::address( int type ) const |
1785 | { | 1796 | { |
1786 | Address address( type ); | 1797 | Address address( type ); |
1787 | Address::List::ConstIterator it; | 1798 | Address::List::ConstIterator it; |
1788 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 1799 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1789 | if ( matchBinaryPatternA( (*it).type(), type ) ) { | 1800 | if ( matchBinaryPatternA( (*it).type(), type ) ) { |
1790 | if ( (*it).type() & Address::Pref ) | 1801 | if ( (*it).type() & Address::Pref ) |
1791 | return (*it); | 1802 | return (*it); |
1792 | else if ( address.isEmpty() ) | 1803 | else if ( address.isEmpty() ) |
1793 | address = (*it); | 1804 | address = (*it); |
1794 | } | 1805 | } |
1795 | } | 1806 | } |
1796 | 1807 | ||
1797 | return address; | 1808 | return address; |
1798 | } | 1809 | } |
1799 | 1810 | ||
1800 | Address::List Addressee::addresses() const | 1811 | Address::List Addressee::addresses() const |
1801 | { | 1812 | { |
1802 | return mData->addresses; | 1813 | return mData->addresses; |
1803 | } | 1814 | } |
1804 | 1815 | ||
1805 | Address::List Addressee::addresses( int type ) const | 1816 | Address::List Addressee::addresses( int type ) const |
1806 | { | 1817 | { |
1807 | Address::List list; | 1818 | Address::List list; |
1808 | 1819 | ||
1809 | Address::List::ConstIterator it; | 1820 | Address::List::ConstIterator it; |
1810 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 1821 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1811 | if ( matchBinaryPattern( (*it).type(), type ) ) { | 1822 | if ( matchBinaryPattern( (*it).type(), type ) ) { |
1812 | list.append( *it ); | 1823 | list.append( *it ); |
1813 | } | 1824 | } |
1814 | } | 1825 | } |
1815 | 1826 | ||
1816 | return list; | 1827 | return list; |
1817 | } | 1828 | } |
1818 | 1829 | ||
1819 | Address Addressee::findAddress( const QString &id ) const | 1830 | Address Addressee::findAddress( const QString &id ) const |
1820 | { | 1831 | { |
1821 | Address::List::ConstIterator it; | 1832 | Address::List::ConstIterator it; |
1822 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 1833 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1823 | if ( (*it).id() == id ) { | 1834 | if ( (*it).id() == id ) { |
1824 | return *it; | 1835 | return *it; |
1825 | } | 1836 | } |
1826 | } | 1837 | } |
1827 | return Address(); | 1838 | return Address(); |
1828 | } | 1839 | } |
1829 | 1840 | ||
1830 | void Addressee::insertCategory( const QString &c ) | 1841 | void Addressee::insertCategory( const QString &c ) |
1831 | { | 1842 | { |
1832 | detach(); | 1843 | detach(); |
1833 | mData->empty = false; | 1844 | mData->empty = false; |
1834 | 1845 | ||
1835 | if ( mData->categories.contains( c ) ) return; | 1846 | if ( mData->categories.contains( c ) ) return; |
1836 | 1847 | ||
1837 | mData->categories.append( c ); | 1848 | mData->categories.append( c ); |
1838 | } | 1849 | } |
1839 | 1850 | ||
1840 | void Addressee::removeCategory( const QString &c ) | 1851 | void Addressee::removeCategory( const QString &c ) |
1841 | { | 1852 | { |
1842 | detach(); | 1853 | detach(); |
1843 | 1854 | ||
1844 | QStringList::Iterator it = mData->categories.find( c ); | 1855 | QStringList::Iterator it = mData->categories.find( c ); |
1845 | if ( it == mData->categories.end() ) return; | 1856 | if ( it == mData->categories.end() ) return; |
1846 | 1857 | ||
1847 | mData->categories.remove( it ); | 1858 | mData->categories.remove( it ); |
1848 | } | 1859 | } |
1849 | 1860 | ||
1850 | bool Addressee::hasCategory( const QString &c ) const | 1861 | bool Addressee::hasCategory( const QString &c ) const |
1851 | { | 1862 | { |
1852 | return ( mData->categories.contains( c ) ); | 1863 | return ( mData->categories.contains( c ) ); |
1853 | } | 1864 | } |
1854 | 1865 | ||
1855 | void Addressee::setCategories( const QStringList &c ) | 1866 | void Addressee::setCategories( const QStringList &c ) |
1856 | { | 1867 | { |
1857 | detach(); | 1868 | detach(); |
1858 | mData->empty = false; | 1869 | mData->empty = false; |
1859 | 1870 | ||
1860 | mData->categories = c; | 1871 | mData->categories = c; |
1861 | } | 1872 | } |
1862 | 1873 | ||
1863 | QStringList Addressee::categories() const | 1874 | QStringList Addressee::categories() const |
1864 | { | 1875 | { |
1865 | return mData->categories; | 1876 | return mData->categories; |
1866 | } | 1877 | } |
1867 | 1878 | ||
1868 | void Addressee::insertCustom( const QString &app, const QString &name, | 1879 | void Addressee::insertCustom( const QString &app, const QString &name, |
1869 | const QString &value ) | 1880 | const QString &value ) |
1870 | { | 1881 | { |
1871 | if ( value.isNull() || name.isEmpty() || app.isEmpty() ) return; | 1882 | if ( value.isNull() || name.isEmpty() || app.isEmpty() ) return; |
1872 | 1883 | ||
1873 | detach(); | 1884 | detach(); |
1874 | mData->empty = false; | 1885 | mData->empty = false; |
1875 | 1886 | ||
1876 | QString qualifiedName = app + "-" + name + ":"; | 1887 | QString qualifiedName = app + "-" + name + ":"; |
1877 | 1888 | ||
1878 | QStringList::Iterator it; | 1889 | QStringList::Iterator it; |
1879 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { | 1890 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { |
1880 | if ( (*it).startsWith( qualifiedName ) ) { | 1891 | if ( (*it).startsWith( qualifiedName ) ) { |
1881 | (*it) = qualifiedName + value; | 1892 | (*it) = qualifiedName + value; |
1882 | return; | 1893 | return; |
1883 | } | 1894 | } |
1884 | } | 1895 | } |
1885 | mData->custom.append( qualifiedName + value ); | 1896 | mData->custom.append( qualifiedName + value ); |
1886 | } | 1897 | } |
1887 | 1898 | ||
1888 | void Addressee::removeCustom( const QString &app, const QString &name) | 1899 | void Addressee::removeCustom( const QString &app, const QString &name) |
1889 | { | 1900 | { |
1890 | detach(); | 1901 | detach(); |
1891 | 1902 | ||
1892 | QString qualifiedName = app + "-" + name + ":"; | 1903 | QString qualifiedName = app + "-" + name + ":"; |
1893 | 1904 | ||
1894 | QStringList::Iterator it; | 1905 | QStringList::Iterator it; |
1895 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { | 1906 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { |
1896 | if ( (*it).startsWith( qualifiedName ) ) { | 1907 | if ( (*it).startsWith( qualifiedName ) ) { |
1897 | mData->custom.remove( it ); | 1908 | mData->custom.remove( it ); |
1898 | return; | 1909 | return; |
1899 | } | 1910 | } |
1900 | } | 1911 | } |
1901 | } | 1912 | } |
1902 | 1913 | ||
1903 | QString Addressee::custom( const QString &app, const QString &name ) const | 1914 | QString Addressee::custom( const QString &app, const QString &name ) const |
1904 | { | 1915 | { |
1905 | QString qualifiedName = app + "-" + name + ":"; | 1916 | QString qualifiedName = app + "-" + name + ":"; |
1906 | QString value; | 1917 | QString value; |
1907 | 1918 | ||
1908 | QStringList::ConstIterator it; | 1919 | QStringList::ConstIterator it; |
1909 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { | 1920 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { |
1910 | if ( (*it).startsWith( qualifiedName ) ) { | 1921 | if ( (*it).startsWith( qualifiedName ) ) { |
1911 | value = (*it).mid( (*it).find( ":" ) + 1 ); | 1922 | value = (*it).mid( (*it).find( ":" ) + 1 ); |
1912 | break; | 1923 | break; |
1913 | } | 1924 | } |
1914 | } | 1925 | } |
1915 | 1926 | ||
1916 | return value; | 1927 | return value; |
1917 | } | 1928 | } |
1918 | 1929 | ||
1919 | void Addressee::setCustoms( const QStringList &l ) | 1930 | void Addressee::setCustoms( const QStringList &l ) |
1920 | { | 1931 | { |
1921 | detach(); | 1932 | detach(); |
1922 | mData->empty = false; | 1933 | mData->empty = false; |
1923 | 1934 | ||
1924 | mData->custom = l; | 1935 | mData->custom = l; |
1925 | } | 1936 | } |
1926 | 1937 | ||
1927 | QStringList Addressee::customs() const | 1938 | QStringList Addressee::customs() const |
1928 | { | 1939 | { |
1929 | return mData->custom; | 1940 | return mData->custom; |
1930 | } | 1941 | } |
1931 | 1942 | ||
1932 | void Addressee::parseEmailAddress( const QString &rawEmail, QString &fullName, | 1943 | void Addressee::parseEmailAddress( const QString &rawEmail, QString &fullName, |
1933 | QString &email) | 1944 | QString &email) |
1934 | { | 1945 | { |
1935 | int startPos, endPos, len; | 1946 | int startPos, endPos, len; |
1936 | QString partA, partB, result; | 1947 | QString partA, partB, result; |
1937 | char endCh = '>'; | 1948 | char endCh = '>'; |
1938 | 1949 | ||
1939 | startPos = rawEmail.find('<'); | 1950 | startPos = rawEmail.find('<'); |
1940 | if (startPos < 0) | 1951 | if (startPos < 0) |
1941 | { | 1952 | { |
1942 | startPos = rawEmail.find('('); | 1953 | startPos = rawEmail.find('('); |
diff --git a/kabc/plugins/sharpdtm/sharpdtmconverter.cpp b/kabc/plugins/sharpdtm/sharpdtmconverter.cpp index ae4cfbb..8165b4c 100644 --- a/kabc/plugins/sharpdtm/sharpdtmconverter.cpp +++ b/kabc/plugins/sharpdtm/sharpdtmconverter.cpp | |||
@@ -1,482 +1,486 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkabc. | 2 | This file is part of libkabc. |
3 | Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> | 3 | Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library 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 GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | /* | 21 | /* |
22 | Enhanced Version of the file for platform independent KDE tools. | 22 | Enhanced Version of the file for platform independent KDE tools. |
23 | Copyright (c) 2004 Ulf Schenk | 23 | Copyright (c) 2004 Ulf Schenk |
24 | 24 | ||
25 | $Id$ | 25 | $Id$ |
26 | */ | 26 | */ |
27 | 27 | ||
28 | #include "kglobal.h" | 28 | #include "kglobal.h" |
29 | #include <qregexp.h> | 29 | #include <qregexp.h> |
30 | 30 | ||
31 | 31 | ||
32 | #include "sharpdtmconverter.h" | 32 | #include "sharpdtmconverter.h" |
33 | 33 | ||
34 | #include <sl/slcategories.h> | 34 | #include <sl/slcategories.h> |
35 | #include <libkdepim/ksyncprofile.h> | 35 | #include <libkdepim/ksyncprofile.h> |
36 | //US #include <qpe/categoryselect.h> | 36 | //US #include <qpe/categoryselect.h> |
37 | 37 | ||
38 | 38 | ||
39 | using namespace KABC; | 39 | using namespace KABC; |
40 | using namespace SlCategory; | 40 | using namespace SlCategory; |
41 | 41 | ||
42 | SharpDTMConverter::SharpDTMConverter() : catDB(0) | 42 | SharpDTMConverter::SharpDTMConverter() : catDB(0) |
43 | { | 43 | { |
44 | } | 44 | } |
45 | 45 | ||
46 | SharpDTMConverter::~SharpDTMConverter() | 46 | SharpDTMConverter::~SharpDTMConverter() |
47 | { | 47 | { |
48 | deinit(); | 48 | deinit(); |
49 | } | 49 | } |
50 | 50 | ||
51 | bool SharpDTMConverter::init() | 51 | bool SharpDTMConverter::init() |
52 | { | 52 | { |
53 | catDB = new SlCategory::SlCategories(); | 53 | catDB = new SlCategory::SlCategories(); |
54 | 54 | ||
55 | if (!catDB) | 55 | if (!catDB) |
56 | return false; | 56 | return false; |
57 | 57 | ||
58 | // catDB->load( categoryFileName() ); | 58 | // catDB->load( categoryFileName() ); |
59 | return true; | 59 | return true; |
60 | } | 60 | } |
61 | 61 | ||
62 | void SharpDTMConverter::deinit() | 62 | void SharpDTMConverter::deinit() |
63 | { | 63 | { |
64 | if (catDB) | 64 | if (catDB) |
65 | { | 65 | { |
66 | delete catDB; | 66 | delete catDB; |
67 | catDB = 0; | 67 | catDB = 0; |
68 | } | 68 | } |
69 | } | 69 | } |
70 | 70 | ||
71 | bool SharpDTMConverter::sharpToAddressee( const CardId &contact, const SlZDataBase* database, Addressee &addr ) | 71 | bool SharpDTMConverter::sharpToAddressee( const CardId &contact, const SlZDataBase* database, Addressee &addr ) |
72 | { | 72 | { |
73 | SlZDataBase* db = (SlZDataBase*)database; | 73 | SlZDataBase* db = (SlZDataBase*)database; |
74 | 74 | ||
75 | // for syncing: we need setting of the two fields | 75 | // for syncing: we need setting of the two fields |
76 | addr.setExternalUID( QString::number( contact ) ); | 76 | addr.setExternalUID( QString::number( contact ) ); |
77 | addr.setOriginalExternalUID( QString::number( contact ) ); | 77 | addr.setOriginalExternalUID( QString::number( contact ) ); |
78 | addr.setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); | 78 | addr.setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); |
79 | 79 | ||
80 | 80 | ||
81 | // name | 81 | // name |
82 | //qDebug("SharpDTMConverter::sharpToAddressee check if the fileAs transformation works!!"); | 82 | //qDebug("SharpDTMConverter::sharpToAddressee check if the fileAs transformation works!!"); |
83 | addr.setFormattedName(db->readField(ZdbAdrs::FileAs)); // needs fix | 83 | addr.setFormattedName(db->readField(ZdbAdrs::FileAs)); |
84 | addr.setName(db->readField(ZdbAdrs::FullName)); | ||
84 | 85 | ||
85 | addr.setFamilyName( db->readField(ZdbAdrs::LastName) ); | 86 | addr.setFamilyName( db->readField(ZdbAdrs::LastName) ); |
86 | addr.setGivenName( db->readField(ZdbAdrs::FirstName) ); | 87 | addr.setGivenName( db->readField(ZdbAdrs::FirstName) ); |
87 | addr.setAdditionalName( db->readField(ZdbAdrs::MiddleName) ); | 88 | addr.setAdditionalName( db->readField(ZdbAdrs::MiddleName) ); |
88 | addr.setPrefix( db->readField(ZdbAdrs::Title) ); | 89 | addr.setPrefix( db->readField(ZdbAdrs::Title) ); |
89 | addr.setSuffix( db->readField(ZdbAdrs::Suffix) ); | 90 | addr.setSuffix( db->readField(ZdbAdrs::Suffix) ); |
90 | 91 | ||
91 | 92 | ||
92 | QString emailstr = db->readField(ZdbAdrs::Emails); | 93 | QString emailstr = db->readField(ZdbAdrs::Emails); |
93 | emailstr.replace( QRegExp(","), " " ); | 94 | emailstr.replace( QRegExp(","), " " ); |
94 | emailstr.replace( QRegExp(";"), " " ); | 95 | emailstr.replace( QRegExp(";"), " " ); |
95 | emailstr.replace( QRegExp(":"), " " ); | 96 | emailstr.replace( QRegExp(":"), " " ); |
96 | //qDebug("SharpDTMConverter::sharpToAddressee whats the character to seperate the emailadresses? %s ", emailstr.latin1()); | 97 | //qDebug("SharpDTMConverter::sharpToAddressee whats the character to seperate the emailadresses? %s ", emailstr.latin1()); |
97 | QStringList emails = QStringList::split(" ", emailstr.simplifyWhiteSpace()); | 98 | QStringList emails = QStringList::split(" ", emailstr.simplifyWhiteSpace()); |
98 | bool defE = false; | 99 | bool defE = false; |
99 | bool found = false; | 100 | bool found = false; |
100 | for ( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) { | 101 | for ( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) { |
101 | if (found ) | 102 | if (found ) |
102 | defE = false; | 103 | defE = false; |
103 | else | 104 | else |
104 | found = defE = ((*it).lower() == db->readField(ZdbAdrs::DefaultEmail).lower()); | 105 | found = defE = ((*it).lower() == db->readField(ZdbAdrs::DefaultEmail).lower()); |
105 | addr.insertEmail( *it, defE ); | 106 | addr.insertEmail( *it, defE ); |
106 | } | 107 | } |
107 | if ( ! found ) | 108 | if ( ! found ) |
108 | if (!db->readField(ZdbAdrs::DefaultEmail).isEmpty()) | 109 | if (!db->readField(ZdbAdrs::DefaultEmail).isEmpty()) |
109 | addr.insertEmail(db->readField(ZdbAdrs::DefaultEmail), true); | 110 | addr.insertEmail(db->readField(ZdbAdrs::DefaultEmail), true); |
110 | 111 | ||
111 | // home | 112 | // home |
112 | if ((!db->readField(ZdbAdrs::HomeStreet).isEmpty()) || | 113 | if ((!db->readField(ZdbAdrs::HomeStreet).isEmpty()) || |
113 | (!db->readField(ZdbAdrs::HomeCity).isEmpty()) || | 114 | (!db->readField(ZdbAdrs::HomeCity).isEmpty()) || |
114 | (!db->readField(ZdbAdrs::HomeState).isEmpty()) || | 115 | (!db->readField(ZdbAdrs::HomeState).isEmpty()) || |
115 | (!db->readField(ZdbAdrs::HomeZip).isEmpty()) || | 116 | (!db->readField(ZdbAdrs::HomeZip).isEmpty()) || |
116 | (!db->readField(ZdbAdrs::HomeCountry).isEmpty())) | 117 | (!db->readField(ZdbAdrs::HomeCountry).isEmpty())) |
117 | { | 118 | { |
118 | Address homeaddress; | 119 | Address homeaddress; |
119 | homeaddress.setType(Address::Home); | 120 | homeaddress.setType(Address::Home); |
120 | //US homeaddress.setPostOfficeBox( "" ); | 121 | //US homeaddress.setPostOfficeBox( "" ); |
121 | //US homeaddress.setExtended( "" ); | 122 | //US homeaddress.setExtended( "" ); |
122 | homeaddress.setStreet( db->readField(ZdbAdrs::HomeStreet).replace( QRegExp("\\r"), "")); | 123 | homeaddress.setStreet( db->readField(ZdbAdrs::HomeStreet).replace( QRegExp("\\r"), "")); |
123 | homeaddress.setLocality( db->readField(ZdbAdrs::HomeCity) ); | 124 | homeaddress.setLocality( db->readField(ZdbAdrs::HomeCity) ); |
124 | homeaddress.setRegion( db->readField(ZdbAdrs::HomeState) ); | 125 | homeaddress.setRegion( db->readField(ZdbAdrs::HomeState) ); |
125 | homeaddress.setPostalCode( db->readField(ZdbAdrs::HomeZip) ); | 126 | homeaddress.setPostalCode( db->readField(ZdbAdrs::HomeZip) ); |
126 | homeaddress.setCountry( db->readField(ZdbAdrs::HomeCountry) ); | 127 | homeaddress.setCountry( db->readField(ZdbAdrs::HomeCountry) ); |
127 | 128 | ||
128 | addr.insertAddress( homeaddress ); | 129 | addr.insertAddress( homeaddress ); |
129 | } | 130 | } |
130 | 131 | ||
131 | if (!db->readField(ZdbAdrs::HomePhone).isEmpty()) | 132 | if (!db->readField(ZdbAdrs::HomePhone).isEmpty()) |
132 | { | 133 | { |
133 | PhoneNumber homephone; | 134 | PhoneNumber homephone; |
134 | homephone.setType( PhoneNumber::Home ); | 135 | homephone.setType( PhoneNumber::Home ); |
135 | homephone.setNumber( db->readField(ZdbAdrs::HomePhone) ); | 136 | homephone.setNumber( db->readField(ZdbAdrs::HomePhone) ); |
136 | addr.insertPhoneNumber( homephone ); | 137 | addr.insertPhoneNumber( homephone ); |
137 | } | 138 | } |
138 | 139 | ||
139 | if (!db->readField(ZdbAdrs::HomeFax).isEmpty()) | 140 | if (!db->readField(ZdbAdrs::HomeFax).isEmpty()) |
140 | { | 141 | { |
141 | PhoneNumber homefax; | 142 | PhoneNumber homefax; |
142 | homefax.setType( PhoneNumber::Home | PhoneNumber::Fax ); | 143 | homefax.setType( PhoneNumber::Home | PhoneNumber::Fax ); |
143 | homefax.setNumber( db->readField(ZdbAdrs::HomeFax) ); | 144 | homefax.setNumber( db->readField(ZdbAdrs::HomeFax) ); |
144 | addr.insertPhoneNumber( homefax ); | 145 | addr.insertPhoneNumber( homefax ); |
145 | } | 146 | } |
146 | 147 | ||
147 | if (!db->readField(ZdbAdrs::HomeMobile).isEmpty()) | 148 | if (!db->readField(ZdbAdrs::HomeMobile).isEmpty()) |
148 | { | 149 | { |
149 | PhoneNumber homemobile; | 150 | PhoneNumber homemobile; |
150 | homemobile.setType( PhoneNumber::Home | PhoneNumber::Cell ); | 151 | homemobile.setType( PhoneNumber::Home | PhoneNumber::Cell ); |
151 | homemobile.setNumber( db->readField(ZdbAdrs::HomeMobile) ); | 152 | homemobile.setNumber( db->readField(ZdbAdrs::HomeMobile) ); |
152 | addr.insertPhoneNumber( homemobile ); | 153 | addr.insertPhoneNumber( homemobile ); |
153 | } | 154 | } |
154 | 155 | ||
155 | addr.setUrl( db->readField(ZdbAdrs::HomeWebPage) ); | 156 | addr.setUrl( db->readField(ZdbAdrs::HomeWebPage) ); |
156 | 157 | ||
157 | 158 | ||
158 | // business | 159 | // business |
159 | if ((!db->readField(ZdbAdrs::BusinessStreet).isEmpty()) || | 160 | if ((!db->readField(ZdbAdrs::BusinessStreet).isEmpty()) || |
160 | (!db->readField(ZdbAdrs::BusinessCity).isEmpty()) || | 161 | (!db->readField(ZdbAdrs::BusinessCity).isEmpty()) || |
161 | (!db->readField(ZdbAdrs::BusinessState).isEmpty()) || | 162 | (!db->readField(ZdbAdrs::BusinessState).isEmpty()) || |
162 | (!db->readField(ZdbAdrs::BusinessZip).isEmpty()) || | 163 | (!db->readField(ZdbAdrs::BusinessZip).isEmpty()) || |
163 | (!db->readField(ZdbAdrs::BusinessCountry).isEmpty())) | 164 | (!db->readField(ZdbAdrs::BusinessCountry).isEmpty())) |
164 | { | 165 | { |
165 | Address businessaddress; | 166 | Address businessaddress; |
166 | businessaddress.setType(Address::Work); | 167 | businessaddress.setType(Address::Work); |
167 | //US businessaddress.setPostOfficeBox( "" ); | 168 | //US businessaddress.setPostOfficeBox( "" ); |
168 | //US businessaddress.setExtended( "" ); | 169 | //US businessaddress.setExtended( "" ); |
169 | businessaddress.setStreet( db->readField(ZdbAdrs::BusinessStreet).replace( QRegExp("\\r"), "") ); | 170 | businessaddress.setStreet( db->readField(ZdbAdrs::BusinessStreet).replace( QRegExp("\\r"), "") ); |
170 | businessaddress.setLocality( db->readField(ZdbAdrs::BusinessCity) ); | 171 | businessaddress.setLocality( db->readField(ZdbAdrs::BusinessCity) ); |
171 | businessaddress.setRegion( db->readField(ZdbAdrs::BusinessState) ); | 172 | businessaddress.setRegion( db->readField(ZdbAdrs::BusinessState) ); |
172 | businessaddress.setPostalCode( db->readField(ZdbAdrs::BusinessZip) ); | 173 | businessaddress.setPostalCode( db->readField(ZdbAdrs::BusinessZip) ); |
173 | businessaddress.setCountry( db->readField(ZdbAdrs::BusinessCountry) ); | 174 | businessaddress.setCountry( db->readField(ZdbAdrs::BusinessCountry) ); |
174 | 175 | ||
175 | addr.insertAddress( businessaddress ); | 176 | addr.insertAddress( businessaddress ); |
176 | } | 177 | } |
177 | 178 | ||
178 | 179 | ||
179 | if (!db->readField(ZdbAdrs::BusinessPhone).isEmpty()) | 180 | if (!db->readField(ZdbAdrs::BusinessPhone).isEmpty()) |
180 | { | 181 | { |
181 | PhoneNumber businessphone; | 182 | PhoneNumber businessphone; |
182 | businessphone.setType( PhoneNumber::Work ); | 183 | businessphone.setType( PhoneNumber::Work ); |
183 | businessphone.setNumber( db->readField(ZdbAdrs::BusinessPhone) ); | 184 | businessphone.setNumber( db->readField(ZdbAdrs::BusinessPhone) ); |
184 | addr.insertPhoneNumber( businessphone ); | 185 | addr.insertPhoneNumber( businessphone ); |
185 | } | 186 | } |
186 | 187 | ||
187 | if (!db->readField(ZdbAdrs::BusinessFax).isEmpty()) | 188 | if (!db->readField(ZdbAdrs::BusinessFax).isEmpty()) |
188 | { | 189 | { |
189 | PhoneNumber businessfax; | 190 | PhoneNumber businessfax; |
190 | businessfax.setType( PhoneNumber::Work | PhoneNumber::Fax ); | 191 | businessfax.setType( PhoneNumber::Work | PhoneNumber::Fax ); |
191 | businessfax.setNumber( db->readField(ZdbAdrs::BusinessFax) ); | 192 | businessfax.setNumber( db->readField(ZdbAdrs::BusinessFax) ); |
192 | addr.insertPhoneNumber( businessfax ); | 193 | addr.insertPhoneNumber( businessfax ); |
193 | } | 194 | } |
194 | 195 | ||
195 | if (!db->readField(ZdbAdrs::BusinessMobile).isEmpty()) | 196 | if (!db->readField(ZdbAdrs::BusinessMobile).isEmpty()) |
196 | { | 197 | { |
197 | PhoneNumber businessmobile; | 198 | PhoneNumber businessmobile; |
198 | businessmobile.setType( PhoneNumber::Work | PhoneNumber::Cell ); | 199 | businessmobile.setType( PhoneNumber::Work | PhoneNumber::Cell ); |
199 | businessmobile.setNumber( db->readField(ZdbAdrs::BusinessMobile) ); | 200 | businessmobile.setNumber( db->readField(ZdbAdrs::BusinessMobile) ); |
200 | addr.insertPhoneNumber( businessmobile ); | 201 | addr.insertPhoneNumber( businessmobile ); |
201 | } | 202 | } |
202 | 203 | ||
203 | if (!db->readField(ZdbAdrs::BusinessPager).isEmpty()) | 204 | if (!db->readField(ZdbAdrs::BusinessPager).isEmpty()) |
204 | { | 205 | { |
205 | PhoneNumber businesspager; | 206 | PhoneNumber businesspager; |
206 | businesspager.setType( PhoneNumber::Work | PhoneNumber::Pager ); | 207 | businesspager.setType( PhoneNumber::Work | PhoneNumber::Pager ); |
207 | businesspager.setNumber( db->readField(ZdbAdrs::BusinessPager) ); | 208 | businesspager.setNumber( db->readField(ZdbAdrs::BusinessPager) ); |
208 | addr.insertPhoneNumber( businesspager ); | 209 | addr.insertPhoneNumber( businesspager ); |
209 | } | 210 | } |
210 | 211 | ||
211 | addr.setRole( db->readField(ZdbAdrs::JobTitle) ); | 212 | addr.setRole( db->readField(ZdbAdrs::JobTitle) ); |
212 | addr.setOrganization( db->readField(ZdbAdrs::Company) ); | 213 | addr.setOrganization( db->readField(ZdbAdrs::Company) ); |
213 | addr.insertCustom( "KADDRESSBOOK", "X-Profession", db->readField(ZdbAdrs::Profession) ); | 214 | addr.insertCustom( "KADDRESSBOOK", "X-Profession", db->readField(ZdbAdrs::Profession) ); |
214 | addr.insertCustom( "KADDRESSBOOK", "X-AssistantsName", db->readField(ZdbAdrs::Assistant) ); | 215 | addr.insertCustom( "KADDRESSBOOK", "X-AssistantsName", db->readField(ZdbAdrs::Assistant) ); |
215 | addr.insertCustom( "KADDRESSBOOK", "X-Department", db->readField(ZdbAdrs::Department) ); | 216 | addr.insertCustom( "KADDRESSBOOK", "X-Department", db->readField(ZdbAdrs::Department) ); |
216 | addr.insertCustom( "KADDRESSBOOK", "X-ManagersName", db->readField(ZdbAdrs::Manager) ); | 217 | addr.insertCustom( "KADDRESSBOOK", "X-ManagersName", db->readField(ZdbAdrs::Manager) ); |
217 | addr.insertCustom( "KADDRESSBOOK", "X-Office", db->readField(ZdbAdrs::Office) ); | 218 | addr.insertCustom( "KADDRESSBOOK", "X-Office", db->readField(ZdbAdrs::Office) ); |
218 | 219 | ||
219 | //personal | 220 | //personal |
220 | addr.insertCustom( "KADDRESSBOOK", "X-SpousesName", db->readField(ZdbAdrs::Spouse) ); | 221 | addr.insertCustom( "KADDRESSBOOK", "X-SpousesName", db->readField(ZdbAdrs::Spouse) ); |
221 | 222 | ||
222 | QString gen = db->readField(ZdbAdrs::Gender); | 223 | QString gen = db->readField(ZdbAdrs::Gender); |
223 | //qDebug("SharpDTMConverter::sharpToAddressee pleas check that gender works!! : Gender: %s", gen.latin1()); | 224 | //qDebug("SharpDTMConverter::sharpToAddressee pleas check that gender works!! : Gender: %s", gen.latin1()); |
224 | //qDebug("SharpDTMConverter::sharpToAddressee: may be int db->readUshortField(\"ZdbAdrs::Gender\") is here better suited"); | 225 | //qDebug("SharpDTMConverter::sharpToAddressee: may be int db->readUshortField(\"ZdbAdrs::Gender\") is here better suited"); |
225 | 226 | if (gen == "1") | |
226 | if (gen == "male") | ||
227 | addr.insertCustom( "KADDRESSBOOK", "X-Gender", "male"); | 227 | addr.insertCustom( "KADDRESSBOOK", "X-Gender", "male"); |
228 | else if (gen == "female") | 228 | else if (gen == "2") |
229 | addr.insertCustom( "KADDRESSBOOK", "X-Gender", "female"); | 229 | addr.insertCustom( "KADDRESSBOOK", "X-Gender", "female"); |
230 | else | ||
231 | addr.insertCustom( "KADDRESSBOOK", "X-Gender", "undef"); | ||
230 | 232 | ||
231 | 233 | ||
232 | QDate ann = KGlobal::locale()->readDate( db->readField(ZdbAdrs::Anniversary) ); | 234 | QDate ann = KGlobal::locale()->readDate( db->readField(ZdbAdrs::Anniversary) ); |
233 | if (ann.isValid()) { | 235 | if (ann.isValid()) { |
234 | QString dt = KGlobal::locale()->formatDate(ann, true, KLocale::ISODate); | 236 | QString dt = KGlobal::locale()->formatDate(ann, true, KLocale::ISODate); |
235 | //qDebug("qtopiaToAddressee annyversary found:%s", dt.latin1()); | 237 | //qDebug("qtopiaToAddressee annyversary found:%s", dt.latin1()); |
236 | addr.insertCustom( "KADDRESSBOOK", "X-Anniversary", dt); | 238 | addr.insertCustom( "KADDRESSBOOK", "X-Anniversary", dt); |
237 | } | 239 | } else |
240 | addr.insertCustom( "KADDRESSBOOK", "X-Anniversary", " "); | ||
241 | |||
238 | 242 | ||
239 | 243 | ||
240 | addr.insertCustom( "KADDRESSBOOK", "X-Children", db->readField(ZdbAdrs::Children) ); | 244 | addr.insertCustom( "KADDRESSBOOK", "X-Children", db->readField(ZdbAdrs::Children) ); |
241 | 245 | ||
242 | 246 | ||
243 | QDate birthd = KGlobal::locale()->readDate( db->readField(ZdbAdrs::Birthday) ); | 247 | QDate birthd = KGlobal::locale()->readDate( db->readField(ZdbAdrs::Birthday) ); |
244 | //qDebug("birtd %s ", birthd.toString().latin1()); | 248 | //qDebug("birtd %s ", birthd.toString().latin1()); |
245 | if (birthd.isValid()) | 249 | if (birthd.isValid()) |
246 | addr.setBirthday( birthd ); | 250 | addr.setBirthday( birthd ); |
247 | 251 | ||
248 | addr.setNickName( db->readField(ZdbAdrs::Nickname) ); | 252 | addr.setNickName( db->readField(ZdbAdrs::Nickname) ); |
249 | 253 | ||
250 | // others | 254 | // others |
251 | //US I put opies BusinessWebPage into Ka/Pi's notes block, because no other native field is available. | 255 | //US I put opies BusinessWebPage into Ka/Pi's notes block, because no other native field is available. |
252 | //QString notes = db->readField(ZdbAdrs::Notes); | 256 | //QString notes = db->readField(ZdbAdrs::Notes); |
253 | //notes += "\nBusinessWebPage: " + db->readField(ZdbAdrs::BusinessWebPage) + "\n"; | 257 | //notes += "\nBusinessWebPage: " + db->readField(ZdbAdrs::BusinessWebPage) + "\n"; |
254 | if ( addr.url().isEmpty() ) | 258 | if ( addr.url().isEmpty() ) |
255 | addr.setUrl( db->readField(ZdbAdrs::BusinessWebPage) ); | 259 | addr.setUrl( db->readField(ZdbAdrs::BusinessWebPage) ); |
256 | addr.setNote( db->readField(ZdbAdrs::Notes).replace( QRegExp("\\r"), "")); | 260 | addr.setNote( db->readField(ZdbAdrs::Notes).replace( QRegExp("\\r"), "")); |
257 | 261 | ||
258 | 262 | ||
259 | 263 | ||
260 | //US QString groups() const { return find( Qtopia::Groups ); } | 264 | //US QString groups() const { return find( Qtopia::Groups ); } |
261 | //US QStringList groupList() const; | 265 | //US QStringList groupList() const; |
262 | 266 | ||
263 | //qDebug("SharpDTMConverter::sharpToAddressee please check that the categories will be converted" ); | 267 | //qDebug("SharpDTMConverter::sharpToAddressee please check that the categories will be converted" ); |
264 | QArray<int> catArray = db->readCategories(); | 268 | QArray<int> catArray = db->readCategories(); |
265 | QString cat; | 269 | QString cat; |
266 | 270 | ||
267 | for ( unsigned int i=0; i < catArray.size(); i++ ) { | 271 | for ( unsigned int i=0; i < catArray.size(); i++ ) { |
268 | cat = catDB->label(catArray[i]); | 272 | cat = catDB->label(catArray[i]); |
269 | if ( cat.isEmpty() ) | 273 | if ( cat.isEmpty() ) |
270 | addr.insertCategory(QString::number(catArray[i])); | 274 | addr.insertCategory(QString::number(catArray[i])); |
271 | else | 275 | else |
272 | addr.insertCategory( cat ); | 276 | addr.insertCategory( cat ); |
273 | } | 277 | } |
274 | 278 | ||
275 | return true; | 279 | return true; |
276 | } | 280 | } |
277 | 281 | ||
278 | bool SharpDTMConverter::addresseeToSharp( const Addressee &addr, SlZDataBase* database , const CardId &contact ) | 282 | bool SharpDTMConverter::addresseeToSharp( const Addressee &addr, SlZDataBase* database , const CardId &contact ) |
279 | { | 283 | { |
280 | bool cellHome = false, cellWork = false; | 284 | bool cellHome = false, cellWork = false; |
281 | // name | 285 | // name |
282 | database->writeField(ZdbAdrs::LastName, addr.familyName()); | 286 | database->writeField(ZdbAdrs::LastName, addr.familyName()); |
283 | database->writeField(ZdbAdrs::FirstName, addr.givenName()); | 287 | database->writeField(ZdbAdrs::FirstName, addr.givenName()); |
284 | database->writeField(ZdbAdrs::MiddleName, addr.additionalName()); | 288 | database->writeField(ZdbAdrs::MiddleName, addr.additionalName()); |
285 | database->writeField(ZdbAdrs::Title, addr.prefix()); | 289 | database->writeField(ZdbAdrs::Title, addr.prefix()); |
286 | database->writeField(ZdbAdrs::Suffix, addr.suffix()); | 290 | database->writeField(ZdbAdrs::Suffix, addr.suffix()); |
287 | 291 | ||
288 | //qDebug("SharpDTMConverter::addresseeToSharp check if the fileAs transformation works!!\n%s",addr.formattedName().latin1() ); | 292 | //qDebug("SharpDTMConverter::addresseeToSharp check if the fileAs transformation works!!\n%s",addr.formattedName().latin1() ); |
289 | QString formattedName = addr.formattedName(); | 293 | QString formattedName = addr.formattedName(); |
290 | if ( formattedName.isEmpty() ) { | 294 | if ( formattedName.isEmpty() ) { |
291 | if ( !addr.familyName().isEmpty() ) { | 295 | if ( !addr.familyName().isEmpty() ) { |
292 | formattedName = addr.familyName(); | 296 | formattedName = addr.familyName(); |
293 | if ( !addr.givenName().isEmpty() ) { | 297 | if ( !addr.givenName().isEmpty() ) { |
294 | formattedName += ", "; | 298 | formattedName += ", "; |
295 | formattedName += addr.givenName(); | 299 | formattedName += addr.givenName(); |
296 | } | 300 | } |
297 | } else | 301 | } else |
298 | formattedName = addr.givenName(); | 302 | formattedName = addr.givenName(); |
299 | } | 303 | } |
300 | database->writeField(ZdbAdrs::FileAs, formattedName); | 304 | database->writeField(ZdbAdrs::FileAs, formattedName); |
301 | database->writeField(ZdbAdrs::FullName, formattedName); | 305 | database->writeField(ZdbAdrs::FullName, addr.name()); |
302 | 306 | ||
303 | 307 | ||
304 | //qDebug("SharpDTMConverter::addresseeToSharp check which seperator we need here for the emails!!"); | 308 | //qDebug("SharpDTMConverter::addresseeToSharp check which seperator we need here for the emails!!"); |
305 | //qDebug("SharpDTMConverter::addresseeToSharp its probably the same from sharpToAddressee"); | 309 | //qDebug("SharpDTMConverter::addresseeToSharp its probably the same from sharpToAddressee"); |
306 | QString emails = addr.emails().join(" "); | 310 | QString emails = addr.emails().join(" "); |
307 | database->writeField(ZdbAdrs::Emails, emails ); | 311 | database->writeField(ZdbAdrs::Emails, emails ); |
308 | 312 | ||
309 | database->writeField(ZdbAdrs::DefaultEmail, addr.preferredEmail() ); | 313 | database->writeField(ZdbAdrs::DefaultEmail, addr.preferredEmail() ); |
310 | // home | 314 | // home |
311 | const Address homeaddress = addr.address(Address::Home); | 315 | const Address homeaddress = addr.address(Address::Home); |
312 | database->writeField(ZdbAdrs::HomeStreet, homeaddress.street()); | 316 | database->writeField(ZdbAdrs::HomeStreet, homeaddress.street()); |
313 | database->writeField(ZdbAdrs::HomeCity, homeaddress.locality()); | 317 | database->writeField(ZdbAdrs::HomeCity, homeaddress.locality()); |
314 | database->writeField(ZdbAdrs::HomeState, homeaddress.region()); | 318 | database->writeField(ZdbAdrs::HomeState, homeaddress.region()); |
315 | database->writeField(ZdbAdrs::HomeZip, homeaddress.postalCode()); | 319 | database->writeField(ZdbAdrs::HomeZip, homeaddress.postalCode()); |
316 | database->writeField(ZdbAdrs::HomeCountry, homeaddress.country()); | 320 | database->writeField(ZdbAdrs::HomeCountry, homeaddress.country()); |
317 | 321 | ||
318 | PhoneNumber homephone = addr.phoneNumber( PhoneNumber::Home ); | 322 | PhoneNumber homephone = addr.phoneNumber( PhoneNumber::Home ); |
319 | database->writeField(ZdbAdrs::HomePhone, homephone.number()); | 323 | database->writeField(ZdbAdrs::HomePhone, homephone.number()); |
320 | PhoneNumber homefax = addr.phoneNumber( PhoneNumber::Home | PhoneNumber::Fax ); | 324 | PhoneNumber homefax = addr.phoneNumber( PhoneNumber::Home | PhoneNumber::Fax ); |
321 | database->writeField(ZdbAdrs::HomeFax, homefax.number()); | 325 | database->writeField(ZdbAdrs::HomeFax, homefax.number()); |
322 | PhoneNumber homemobile = addr.phoneNumber( PhoneNumber::Home | PhoneNumber::Cell ); | 326 | PhoneNumber homemobile = addr.phoneNumber( PhoneNumber::Home | PhoneNumber::Cell ); |
323 | database->writeField(ZdbAdrs::HomeMobile, homemobile.number()); | 327 | database->writeField(ZdbAdrs::HomeMobile, homemobile.number()); |
324 | if (!homemobile.number().isEmpty()) { | 328 | if (!homemobile.number().isEmpty()) { |
325 | cellHome = true; | 329 | cellHome = true; |
326 | } | 330 | } |
327 | database->writeField(ZdbAdrs::HomeWebPage, addr.url().url()); | 331 | database->writeField(ZdbAdrs::HomeWebPage, addr.url().url()); |
328 | // business | 332 | // business |
329 | const Address businessaddress = addr.address(Address::Work); | 333 | const Address businessaddress = addr.address(Address::Work); |
330 | //qDebug("write business address "); | 334 | //qDebug("write business address "); |
331 | database->writeField(ZdbAdrs::BusinessStreet, businessaddress.street()); | 335 | database->writeField(ZdbAdrs::BusinessStreet, businessaddress.street()); |
332 | database->writeField(ZdbAdrs::BusinessCity, businessaddress.locality()); | 336 | database->writeField(ZdbAdrs::BusinessCity, businessaddress.locality()); |
333 | database->writeField(ZdbAdrs::BusinessState, businessaddress.region()); | 337 | database->writeField(ZdbAdrs::BusinessState, businessaddress.region()); |
334 | database->writeField(ZdbAdrs::BusinessZip, businessaddress.postalCode()); | 338 | database->writeField(ZdbAdrs::BusinessZip, businessaddress.postalCode()); |
335 | database->writeField(ZdbAdrs::BusinessCountry, businessaddress.country()); | 339 | database->writeField(ZdbAdrs::BusinessCountry, businessaddress.country()); |
336 | 340 | ||
337 | PhoneNumber businessphone = addr.phoneNumber( PhoneNumber::Work ); | 341 | PhoneNumber businessphone = addr.phoneNumber( PhoneNumber::Work ); |
338 | database->writeField(ZdbAdrs::BusinessPhone, businessphone.number()); | 342 | database->writeField(ZdbAdrs::BusinessPhone, businessphone.number()); |
339 | 343 | ||
340 | PhoneNumber businessfax = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Fax ); | 344 | PhoneNumber businessfax = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Fax ); |
341 | database->writeField(ZdbAdrs::BusinessFax, businessfax.number()); | 345 | database->writeField(ZdbAdrs::BusinessFax, businessfax.number()); |
342 | 346 | ||
343 | PhoneNumber businessmobile = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Cell ); | 347 | PhoneNumber businessmobile = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Cell ); |
344 | database->writeField(ZdbAdrs::BusinessMobile, businessmobile.number()); | 348 | database->writeField(ZdbAdrs::BusinessMobile, businessmobile.number()); |
345 | if (!businessmobile.number().isEmpty()) { | 349 | if (!businessmobile.number().isEmpty()) { |
346 | cellWork = true; | 350 | cellWork = true; |
347 | } | 351 | } |
348 | PhoneNumber mobile = addr.phoneNumber( PhoneNumber::Cell ); | 352 | PhoneNumber mobile = addr.phoneNumber( PhoneNumber::Cell ); |
349 | if (! mobile.number().isEmpty()) { | 353 | if (! mobile.number().isEmpty()) { |
350 | if ( ! cellHome ) | 354 | if ( ! cellHome ) |
351 | database->writeField(ZdbAdrs::HomeMobile, mobile.number()); | 355 | database->writeField(ZdbAdrs::HomeMobile, mobile.number()); |
352 | else if (! cellWork ) | 356 | else if (! cellWork ) |
353 | database->writeField(ZdbAdrs::BusinessMobile, mobile.number()); | 357 | database->writeField(ZdbAdrs::BusinessMobile, mobile.number()); |
354 | } | 358 | } |
355 | 359 | ||
356 | PhoneNumber businesspager = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Pager ); | 360 | PhoneNumber businesspager = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Pager ); |
357 | database->writeField(ZdbAdrs::BusinessPager, businesspager.number()); | 361 | database->writeField(ZdbAdrs::BusinessPager, businesspager.number()); |
358 | 362 | ||
359 | database->writeField(ZdbAdrs::JobTitle, addr.role()); | 363 | database->writeField(ZdbAdrs::JobTitle, addr.role()); |
360 | database->writeField(ZdbAdrs::Company, addr.organization()); | 364 | database->writeField(ZdbAdrs::Company, addr.organization()); |
361 | 365 | ||
362 | database->writeField(ZdbAdrs::Profession, addr.custom( "KADDRESSBOOK", "X-Profession" )); | 366 | database->writeField(ZdbAdrs::Profession, addr.custom( "KADDRESSBOOK", "X-Profession" )); |
363 | database->writeField(ZdbAdrs::Assistant, addr.custom( "KADDRESSBOOK", "X-AssistantsName" )); | 367 | database->writeField(ZdbAdrs::Assistant, addr.custom( "KADDRESSBOOK", "X-AssistantsName" )); |
364 | database->writeField(ZdbAdrs::Department, addr.custom( "KADDRESSBOOK", "X-Department" )); | 368 | database->writeField(ZdbAdrs::Department, addr.custom( "KADDRESSBOOK", "X-Department" )); |
365 | database->writeField(ZdbAdrs::Manager, addr.custom( "KADDRESSBOOK", "X-ManagersName" )); | 369 | database->writeField(ZdbAdrs::Manager, addr.custom( "KADDRESSBOOK", "X-ManagersName" )); |
366 | database->writeField(ZdbAdrs::Office, addr.custom( "KADDRESSBOOK", "X-Office" )); | 370 | database->writeField(ZdbAdrs::Office, addr.custom( "KADDRESSBOOK", "X-Office" )); |
367 | 371 | ||
368 | //personal | 372 | //personal |
369 | database->writeField(ZdbAdrs::Spouse, addr.custom( "KADDRESSBOOK", "X-Spouse" )); | 373 | database->writeField(ZdbAdrs::Spouse, addr.custom( "KADDRESSBOOK", "X-Spouse" )); |
370 | 374 | ||
371 | QString gt = addr.custom( "KADDRESSBOOK", "X-Gender" ); | 375 | QString gt = addr.custom( "KADDRESSBOOK", "X-Gender" ); |
372 | //qDebug("SharpDTMConverter::addresseeToSharp please check that gender works!! : Gender: %s", gt.latin1()); | 376 | //qDebug("SharpDTMConverter::addresseeToSharp please check that gender works!! : Gender: %s", gt.latin1()); |
373 | //qDebug("SharpDTMConverter::addresseeToSharp: may be writeField(\"ZdbAdrs::Gender\", ushort) is here better suited?"); | 377 | //qDebug("SharpDTMConverter::addresseeToSharp: may be writeField(\"ZdbAdrs::Gender\", ushort) is here better suited?"); |
374 | //qDebug("SharpDTMConverter::addresseeToSharp: check also the reverse functionality in sharpToAddressee"); | 378 | //qDebug("SharpDTMConverter::addresseeToSharp: check also the reverse functionality in sharpToAddressee"); |
375 | if (gt == "male") | 379 | if (gt == "male") |
376 | database->writeField(ZdbAdrs::Gender, "male"); | 380 | database->writeField(ZdbAdrs::Gender, "1"); |
377 | else if (gt == "female") | 381 | else if (gt == "female") |
378 | database->writeField(ZdbAdrs::Gender, "female"); | 382 | database->writeField(ZdbAdrs::Gender, "2"); |
379 | else | 383 | else |
380 | database->writeField(ZdbAdrs::Gender, ""); | 384 | database->writeField(ZdbAdrs::Gender, ""); |
381 | 385 | ||
382 | QString dateS ; | 386 | QString dateS ; |
383 | QDate dt = KGlobal::locale()->readDate(addr.custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); // = Qt::ISODate | 387 | QDate dt = KGlobal::locale()->readDate(addr.custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); // = Qt::ISODate |
384 | if ( dt.isValid() ) { | 388 | if ( dt.isValid() ) { |
385 | dateS = KGlobal::locale()->formatDate(dt, true ); | 389 | dateS = KGlobal::locale()->formatDate(dt, true ); |
386 | } | 390 | } |
387 | database->writeField(ZdbAdrs::Anniversary, dateS ); | 391 | database->writeField(ZdbAdrs::Anniversary, dateS ); |
388 | database->writeField(ZdbAdrs::Children, addr.custom( "KADDRESSBOOK", "X-Children" )); | 392 | database->writeField(ZdbAdrs::Children, addr.custom( "KADDRESSBOOK", "X-Children" )); |
389 | dt = addr.birthday().date(); | 393 | dt = addr.birthday().date(); |
390 | dateS = ""; | 394 | dateS = ""; |
391 | if ( dt.isValid() ) { | 395 | if ( dt.isValid() ) { |
392 | dateS = KGlobal::locale()->formatDate(dt, true ); | 396 | dateS = KGlobal::locale()->formatDate(dt, true ); |
393 | } | 397 | } |
394 | database->writeField(ZdbAdrs::Birthday, dateS); | 398 | database->writeField(ZdbAdrs::Birthday, dateS); |
395 | database->writeField(ZdbAdrs::Nickname, addr.nickName()); | 399 | database->writeField(ZdbAdrs::Nickname, addr.nickName()); |
396 | 400 | ||
397 | // other | 401 | // other |
398 | database->writeField(ZdbAdrs::Notes, addr.note()); | 402 | database->writeField(ZdbAdrs::Notes, addr.note()); |
399 | 403 | ||
400 | //US QString groups() const { return find( Qtopia::Groups ); } | 404 | //US QString groups() const { return find( Qtopia::Groups ); } |
401 | //US QStringList groupList() const; | 405 | //US QStringList groupList() const; |
402 | 406 | ||
403 | 407 | ||
404 | //qDebug("SharpDTMConverter::addresseeToSharp please check if category transformation works"); | 408 | //qDebug("SharpDTMConverter::addresseeToSharp please check if category transformation works"); |
405 | 409 | ||
406 | return true; | 410 | return true; |
407 | } | 411 | } |
408 | 412 | ||
409 | 413 | ||
410 | bool SharpDTMConverter::setCategories( const Addressee &addr, SlZDataBase* database , const CardId &contact ) | 414 | bool SharpDTMConverter::setCategories( const Addressee &addr, SlZDataBase* database , const CardId &contact ) |
411 | { | 415 | { |
412 | QStringList list = addr.categories(); | 416 | QStringList list = addr.categories(); |
413 | 417 | ||
414 | QArray<int> ids(list.count()); | 418 | QArray<int> ids(list.count()); |
415 | uint index = 0; | 419 | uint index = 0; |
416 | for(uint i=0; i<ids.size(); i++){ | 420 | for(uint i=0; i<ids.size(); i++){ |
417 | if(catDB->exists(list[i])){ | 421 | if(catDB->exists(list[i])){ |
418 | ids[index] = catDB->id(list[i]); | 422 | ids[index] = catDB->id(list[i]); |
419 | qDebug("set ex cat %d %s ",ids[index] , list[i].latin1()); | 423 | qDebug("set ex cat %d %s ",ids[index] , list[i].latin1()); |
420 | index++; | 424 | index++; |
421 | } else { | 425 | } else { |
422 | ids[index] = catDB->addCategory(list[i]); | 426 | ids[index] = catDB->addCategory(list[i]); |
423 | qDebug("add new cat %d %s ",ids[index] , list[i].latin1()); | 427 | qDebug("add new cat %d %s ",ids[index] , list[i].latin1()); |
424 | index++; | 428 | index++; |
425 | } | 429 | } |
426 | } | 430 | } |
427 | bool res ; | 431 | bool res ; |
428 | if ( res = database->updateCategories(contact, ids) ) | 432 | if ( res = database->updateCategories(contact, ids) ) |
429 | qDebug("cat updated "); | 433 | qDebug("cat updated "); |
430 | else | 434 | else |
431 | qDebug("error cat updating "); | 435 | qDebug("error cat updating "); |
432 | 436 | ||
433 | return res; | 437 | return res; |
434 | } | 438 | } |
435 | 439 | ||
436 | #if 0 | 440 | #if 0 |
437 | m_pCategories = new SlCategories; | 441 | m_pCategories = new SlCategories; |
438 | catDB | 442 | catDB |
439 | 443 | ||
440 | if(categories == QString::null) return true; | 444 | if(categories == QString::null) return true; |
441 | QStringList list = CSVParser::parse(categories); | 445 | QStringList list = CSVParser::parse(categories); |
442 | QArray<int> ids(list.count()); | 446 | QArray<int> ids(list.count()); |
443 | uint index = 0; | 447 | uint index = 0; |
444 | for(uint i=0; i<ids.size(); i++){ | 448 | for(uint i=0; i<ids.size(); i++){ |
445 | #if 0 | 449 | #if 0 |
446 | bool ok; | 450 | bool ok; |
447 | ids[index] = list[i].toInt(&ok); | 451 | ids[index] = list[i].toInt(&ok); |
448 | if(ok){ | 452 | if(ok){ |
449 | index++; | 453 | index++; |
450 | } else { | 454 | } else { |
451 | if(m_pCategories->exists(list[i])){ | 455 | if(m_pCategories->exists(list[i])){ |
452 | ids[index] = m_pCategories->id(list[i]); | 456 | ids[index] = m_pCategories->id(list[i]); |
453 | index++; | 457 | index++; |
454 | } | 458 | } |
455 | } | 459 | } |
456 | #else | 460 | #else |
457 | if(m_pCategories->exists(list[i])){ | 461 | if(m_pCategories->exists(list[i])){ |
458 | ids[index] = m_pCategories->id(list[i]); | 462 | ids[index] = m_pCategories->id(list[i]); |
459 | index++; | 463 | index++; |
460 | } else if(m_addCategory){ | 464 | } else if(m_addCategory){ |
461 | ids[index] = m_pCategories->addCategory(list[i]); | 465 | ids[index] = m_pCategories->addCategory(list[i]); |
462 | index++; | 466 | index++; |
463 | } | 467 | } |
464 | #endif | 468 | #endif |
465 | } | 469 | } |
466 | if(ids.size() > 0 && index == 0){ | 470 | if(ids.size() > 0 && index == 0){ |
467 | return true; | 471 | return true; |
468 | } else if(index != ids.size()){ | 472 | } else if(index != ids.size()){ |
469 | ids.resize(index); | 473 | ids.resize(index); |
470 | } | 474 | } |
471 | if(!m_pZdb->updateCategories(id, ids)){ | 475 | if(!m_pZdb->updateCategories(id, ids)){ |
472 | return false; | 476 | return false; |
473 | } | 477 | } |
474 | return true; | 478 | return true; |
475 | #endif | 479 | #endif |
476 | 480 | ||
477 | QDate SharpDTMConverter::convertDate( QString s) | 481 | QDate SharpDTMConverter::convertDate( QString s) |
478 | { | 482 | { |
479 | QDate dt = KGlobal::locale()->readDate( s ); | 483 | QDate dt = KGlobal::locale()->readDate( s ); |
480 | return dt; | 484 | return dt; |
481 | return QDate (); | 485 | return QDate (); |
482 | } | 486 | } |
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index 42e147f..d970ff1 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -820,2486 +820,2496 @@ void KABCore::updateMainWindow() | |||
820 | { | 820 | { |
821 | 821 | ||
822 | mMainWindow->showMaximized(); | 822 | mMainWindow->showMaximized(); |
823 | mMainWindow->update(); | 823 | mMainWindow->update(); |
824 | } | 824 | } |
825 | void KABCore::resizeEvent(QResizeEvent* e ) | 825 | void KABCore::resizeEvent(QResizeEvent* e ) |
826 | { | 826 | { |
827 | if ( !mMiniSplitter ) | 827 | if ( !mMiniSplitter ) |
828 | return; | 828 | return; |
829 | //qDebug("KABCore::resizeEvent(QResizeEvent* e ) "); | 829 | //qDebug("KABCore::resizeEvent(QResizeEvent* e ) "); |
830 | if ( QApplication::desktop()->width() >= 480 ) { | 830 | if ( QApplication::desktop()->width() >= 480 ) { |
831 | if (QApplication::desktop()->width() == 640 ) { // e.g. 640x480 | 831 | if (QApplication::desktop()->width() == 640 ) { // e.g. 640x480 |
832 | if ( mMiniSplitter->orientation() == Qt::Vertical ) { | 832 | if ( mMiniSplitter->orientation() == Qt::Vertical ) { |
833 | mMiniSplitter->setOrientation( Qt::Horizontal); | 833 | mMiniSplitter->setOrientation( Qt::Horizontal); |
834 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 834 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
835 | if ( QApplication::desktop()->width() <= 640 ) { | 835 | if ( QApplication::desktop()->width() <= 640 ) { |
836 | //mMainWindow->setMaximumSize( QApplication::desktop()->size() ); | 836 | //mMainWindow->setMaximumSize( QApplication::desktop()->size() ); |
837 | mViewManager->getFilterAction()->setComboWidth( 150 ); | 837 | mViewManager->getFilterAction()->setComboWidth( 150 ); |
838 | QTimer::singleShot( 1, this , SLOT ( updateMainWindow())); | 838 | QTimer::singleShot( 1, this , SLOT ( updateMainWindow())); |
839 | } | 839 | } |
840 | } | 840 | } |
841 | } else if (QApplication::desktop()->width() == 480 ){// e.g. 480x640 | 841 | } else if (QApplication::desktop()->width() == 480 ){// e.g. 480x640 |
842 | if ( mMiniSplitter->orientation() == Qt::Horizontal ) { | 842 | if ( mMiniSplitter->orientation() == Qt::Horizontal ) { |
843 | mMiniSplitter->setOrientation( Qt::Vertical ); | 843 | mMiniSplitter->setOrientation( Qt::Vertical ); |
844 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); | 844 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); |
845 | if ( QApplication::desktop()->width() <= 640 ) { | 845 | if ( QApplication::desktop()->width() <= 640 ) { |
846 | //mMainWindow->setMaximumSize( QApplication::desktop()->size() ); | 846 | //mMainWindow->setMaximumSize( QApplication::desktop()->size() ); |
847 | mMainWindow->showMinimized(); | 847 | mMainWindow->showMinimized(); |
848 | mViewManager->getFilterAction()->setComboWidth( 0 ); | 848 | mViewManager->getFilterAction()->setComboWidth( 0 ); |
849 | QTimer::singleShot( 1, this , SLOT ( updateMainWindow())); | 849 | QTimer::singleShot( 1, this , SLOT ( updateMainWindow())); |
850 | } | 850 | } |
851 | } | 851 | } |
852 | } | 852 | } |
853 | } | 853 | } |
854 | 854 | ||
855 | } | 855 | } |
856 | void KABCore::export2phone() | 856 | void KABCore::export2phone() |
857 | { | 857 | { |
858 | 858 | ||
859 | QStringList uids; | 859 | QStringList uids; |
860 | XXPortSelectDialog dlg( this, false, this ); | 860 | XXPortSelectDialog dlg( this, false, this ); |
861 | if ( dlg.exec() ) | 861 | if ( dlg.exec() ) |
862 | uids = dlg.uids(); | 862 | uids = dlg.uids(); |
863 | else | 863 | else |
864 | return; | 864 | return; |
865 | if ( uids.isEmpty() ) | 865 | if ( uids.isEmpty() ) |
866 | return; | 866 | return; |
867 | // qDebug("count %d ", uids.count()); | 867 | // qDebug("count %d ", uids.count()); |
868 | 868 | ||
869 | KAex2phonePrefs ex2phone; | 869 | KAex2phonePrefs ex2phone; |
870 | ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); | 870 | ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); |
871 | ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); | 871 | ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); |
872 | ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); | 872 | ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); |
873 | 873 | ||
874 | if ( !ex2phone.exec() ) { | 874 | if ( !ex2phone.exec() ) { |
875 | return; | 875 | return; |
876 | } | 876 | } |
877 | KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); | 877 | KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); |
878 | KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); | 878 | KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); |
879 | KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); | 879 | KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); |
880 | 880 | ||
881 | 881 | ||
882 | PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, | 882 | PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, |
883 | KPimGlobalPrefs::instance()->mEx2PhoneConnection, | 883 | KPimGlobalPrefs::instance()->mEx2PhoneConnection, |
884 | KPimGlobalPrefs::instance()->mEx2PhoneModel ); | 884 | KPimGlobalPrefs::instance()->mEx2PhoneModel ); |
885 | 885 | ||
886 | QString fileName = getPhoneFile(); | 886 | QString fileName = getPhoneFile(); |
887 | if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) ) | 887 | if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) ) |
888 | return; | 888 | return; |
889 | 889 | ||
890 | message(i18n("Exporting to phone...")); | 890 | message(i18n("Exporting to phone...")); |
891 | QTimer::singleShot( 1, this , SLOT ( writeToPhone())); | 891 | QTimer::singleShot( 1, this , SLOT ( writeToPhone())); |
892 | 892 | ||
893 | } | 893 | } |
894 | QString KABCore::getPhoneFile() | 894 | QString KABCore::getPhoneFile() |
895 | { | 895 | { |
896 | #ifdef DESKTOP_VERSION | 896 | #ifdef DESKTOP_VERSION |
897 | return locateLocal("tmp", "phonefile.vcf"); | 897 | return locateLocal("tmp", "phonefile.vcf"); |
898 | #else | 898 | #else |
899 | return "/tmp/phonefile.vcf"; | 899 | return "/tmp/phonefile.vcf"; |
900 | #endif | 900 | #endif |
901 | 901 | ||
902 | } | 902 | } |
903 | void KABCore::writeToPhone( ) | 903 | void KABCore::writeToPhone( ) |
904 | { | 904 | { |
905 | if ( PhoneAccess::writeToPhone( getPhoneFile() ) ) | 905 | if ( PhoneAccess::writeToPhone( getPhoneFile() ) ) |
906 | message(i18n("Export to phone finished!")); | 906 | message(i18n("Export to phone finished!")); |
907 | else | 907 | else |
908 | qDebug(i18n("Error exporting to phone")); | 908 | qDebug(i18n("Error exporting to phone")); |
909 | } | 909 | } |
910 | void KABCore::beamVCard() | 910 | void KABCore::beamVCard() |
911 | { | 911 | { |
912 | QStringList uids; | 912 | QStringList uids; |
913 | XXPortSelectDialog dlg( this, false, this ); | 913 | XXPortSelectDialog dlg( this, false, this ); |
914 | if ( dlg.exec() ) | 914 | if ( dlg.exec() ) |
915 | uids = dlg.uids(); | 915 | uids = dlg.uids(); |
916 | else | 916 | else |
917 | return; | 917 | return; |
918 | if ( uids.isEmpty() ) | 918 | if ( uids.isEmpty() ) |
919 | return; | 919 | return; |
920 | beamVCard( uids ); | 920 | beamVCard( uids ); |
921 | } | 921 | } |
922 | 922 | ||
923 | 923 | ||
924 | void KABCore::beamVCard(const QStringList& uids) | 924 | void KABCore::beamVCard(const QStringList& uids) |
925 | { | 925 | { |
926 | 926 | ||
927 | // LR: we should use the /tmp dir on the Zaurus, | 927 | // LR: we should use the /tmp dir on the Zaurus, |
928 | // because: /tmp = RAM, (HOME)/kdepim = flash memory | 928 | // because: /tmp = RAM, (HOME)/kdepim = flash memory |
929 | 929 | ||
930 | #ifdef DESKTOP_VERSION | 930 | #ifdef DESKTOP_VERSION |
931 | QString fileName = locateLocal("tmp", "kapibeamfile.vcf"); | 931 | QString fileName = locateLocal("tmp", "kapibeamfile.vcf"); |
932 | #else | 932 | #else |
933 | QString fileName = "/tmp/kapibeamfile.vcf"; | 933 | QString fileName = "/tmp/kapibeamfile.vcf"; |
934 | #endif | 934 | #endif |
935 | 935 | ||
936 | KABC::VCardConverter converter; | 936 | KABC::VCardConverter converter; |
937 | QString description; | 937 | QString description; |
938 | QString datastream; | 938 | QString datastream; |
939 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { | 939 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { |
940 | KABC::Addressee a = mAddressBook->findByUid( *it ); | 940 | KABC::Addressee a = mAddressBook->findByUid( *it ); |
941 | 941 | ||
942 | if ( a.isEmpty() ) | 942 | if ( a.isEmpty() ) |
943 | continue; | 943 | continue; |
944 | 944 | ||
945 | if (description.isEmpty()) | 945 | if (description.isEmpty()) |
946 | description = a.formattedName(); | 946 | description = a.formattedName(); |
947 | 947 | ||
948 | QString vcard; | 948 | QString vcard; |
949 | converter.addresseeToVCard( a, vcard ); | 949 | converter.addresseeToVCard( a, vcard ); |
950 | int start = 0; | 950 | int start = 0; |
951 | int next; | 951 | int next; |
952 | while ( (next = vcard.find("TYPE=", start) )>= 0 ) { | 952 | while ( (next = vcard.find("TYPE=", start) )>= 0 ) { |
953 | int semi = vcard.find(";", next); | 953 | int semi = vcard.find(";", next); |
954 | int dopp = vcard.find(":", next); | 954 | int dopp = vcard.find(":", next); |
955 | int sep; | 955 | int sep; |
956 | if ( semi < dopp && semi >= 0 ) | 956 | if ( semi < dopp && semi >= 0 ) |
957 | sep = semi ; | 957 | sep = semi ; |
958 | else | 958 | else |
959 | sep = dopp; | 959 | sep = dopp; |
960 | datastream +=vcard.mid( start, next - start); | 960 | datastream +=vcard.mid( start, next - start); |
961 | datastream +=vcard.mid( next+5,sep -next -5 ).upper(); | 961 | datastream +=vcard.mid( next+5,sep -next -5 ).upper(); |
962 | start = sep; | 962 | start = sep; |
963 | } | 963 | } |
964 | datastream += vcard.mid( start,vcard.length() ); | 964 | datastream += vcard.mid( start,vcard.length() ); |
965 | } | 965 | } |
966 | #ifndef DESKTOP_VERSION | 966 | #ifndef DESKTOP_VERSION |
967 | QFile outFile(fileName); | 967 | QFile outFile(fileName); |
968 | if ( outFile.open(IO_WriteOnly) ) { | 968 | if ( outFile.open(IO_WriteOnly) ) { |
969 | datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); | 969 | datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); |
970 | QTextStream t( &outFile ); // use a text stream | 970 | QTextStream t( &outFile ); // use a text stream |
971 | //t.setEncoding( QTextStream::UnicodeUTF8 ); | 971 | //t.setEncoding( QTextStream::UnicodeUTF8 ); |
972 | t.setEncoding( QTextStream::Latin1 ); | 972 | t.setEncoding( QTextStream::Latin1 ); |
973 | t <<datastream.latin1(); | 973 | t <<datastream.latin1(); |
974 | outFile.close(); | 974 | outFile.close(); |
975 | Ir *ir = new Ir( this ); | 975 | Ir *ir = new Ir( this ); |
976 | connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); | 976 | connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); |
977 | ir->send( fileName, description, "text/x-vCard" ); | 977 | ir->send( fileName, description, "text/x-vCard" ); |
978 | } else { | 978 | } else { |
979 | qDebug("Error open temp beam file "); | 979 | qDebug("Error open temp beam file "); |
980 | return; | 980 | return; |
981 | } | 981 | } |
982 | #endif | 982 | #endif |
983 | 983 | ||
984 | } | 984 | } |
985 | 985 | ||
986 | void KABCore::beamDone( Ir *ir ) | 986 | void KABCore::beamDone( Ir *ir ) |
987 | { | 987 | { |
988 | #ifndef DESKTOP_VERSION | 988 | #ifndef DESKTOP_VERSION |
989 | delete ir; | 989 | delete ir; |
990 | #endif | 990 | #endif |
991 | topLevelWidget()->raise(); | 991 | topLevelWidget()->raise(); |
992 | message( i18n("Beaming finished!") ); | 992 | message( i18n("Beaming finished!") ); |
993 | } | 993 | } |
994 | 994 | ||
995 | 995 | ||
996 | void KABCore::browse( const QString& url ) | 996 | void KABCore::browse( const QString& url ) |
997 | { | 997 | { |
998 | #ifndef KAB_EMBEDDED | 998 | #ifndef KAB_EMBEDDED |
999 | kapp->invokeBrowser( url ); | 999 | kapp->invokeBrowser( url ); |
1000 | #else //KAB_EMBEDDED | 1000 | #else //KAB_EMBEDDED |
1001 | qDebug("KABCore::browse must be fixed"); | 1001 | qDebug("KABCore::browse must be fixed"); |
1002 | #endif //KAB_EMBEDDED | 1002 | #endif //KAB_EMBEDDED |
1003 | } | 1003 | } |
1004 | 1004 | ||
1005 | void KABCore::selectAllContacts() | 1005 | void KABCore::selectAllContacts() |
1006 | { | 1006 | { |
1007 | mViewManager->setSelected( QString::null, true ); | 1007 | mViewManager->setSelected( QString::null, true ); |
1008 | } | 1008 | } |
1009 | 1009 | ||
1010 | void KABCore::deleteContacts() | 1010 | void KABCore::deleteContacts() |
1011 | { | 1011 | { |
1012 | QStringList uidList = mViewManager->selectedUids(); | 1012 | QStringList uidList = mViewManager->selectedUids(); |
1013 | deleteContacts( uidList ); | 1013 | deleteContacts( uidList ); |
1014 | } | 1014 | } |
1015 | 1015 | ||
1016 | void KABCore::deleteContacts( const QStringList &uids ) | 1016 | void KABCore::deleteContacts( const QStringList &uids ) |
1017 | { | 1017 | { |
1018 | if ( uids.count() > 0 ) { | 1018 | if ( uids.count() > 0 ) { |
1019 | PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); | 1019 | PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); |
1020 | UndoStack::instance()->push( command ); | 1020 | UndoStack::instance()->push( command ); |
1021 | RedoStack::instance()->clear(); | 1021 | RedoStack::instance()->clear(); |
1022 | 1022 | ||
1023 | // now if we deleted anything, refresh | 1023 | // now if we deleted anything, refresh |
1024 | setContactSelected( QString::null ); | 1024 | setContactSelected( QString::null ); |
1025 | setModified( true ); | 1025 | setModified( true ); |
1026 | } | 1026 | } |
1027 | } | 1027 | } |
1028 | 1028 | ||
1029 | void KABCore::copyContacts() | 1029 | void KABCore::copyContacts() |
1030 | { | 1030 | { |
1031 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 1031 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
1032 | 1032 | ||
1033 | QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); | 1033 | QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); |
1034 | 1034 | ||
1035 | kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; | 1035 | kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; |
1036 | 1036 | ||
1037 | QClipboard *cb = QApplication::clipboard(); | 1037 | QClipboard *cb = QApplication::clipboard(); |
1038 | cb->setText( clipText ); | 1038 | cb->setText( clipText ); |
1039 | } | 1039 | } |
1040 | 1040 | ||
1041 | void KABCore::cutContacts() | 1041 | void KABCore::cutContacts() |
1042 | { | 1042 | { |
1043 | QStringList uidList = mViewManager->selectedUids(); | 1043 | QStringList uidList = mViewManager->selectedUids(); |
1044 | 1044 | ||
1045 | //US if ( uidList.size() > 0 ) { | 1045 | //US if ( uidList.size() > 0 ) { |
1046 | if ( uidList.count() > 0 ) { | 1046 | if ( uidList.count() > 0 ) { |
1047 | PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); | 1047 | PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); |
1048 | UndoStack::instance()->push( command ); | 1048 | UndoStack::instance()->push( command ); |
1049 | RedoStack::instance()->clear(); | 1049 | RedoStack::instance()->clear(); |
1050 | 1050 | ||
1051 | setModified( true ); | 1051 | setModified( true ); |
1052 | } | 1052 | } |
1053 | } | 1053 | } |
1054 | 1054 | ||
1055 | void KABCore::pasteContacts() | 1055 | void KABCore::pasteContacts() |
1056 | { | 1056 | { |
1057 | QClipboard *cb = QApplication::clipboard(); | 1057 | QClipboard *cb = QApplication::clipboard(); |
1058 | 1058 | ||
1059 | KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); | 1059 | KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); |
1060 | 1060 | ||
1061 | pasteContacts( list ); | 1061 | pasteContacts( list ); |
1062 | } | 1062 | } |
1063 | 1063 | ||
1064 | void KABCore::pasteContacts( KABC::Addressee::List &list ) | 1064 | void KABCore::pasteContacts( KABC::Addressee::List &list ) |
1065 | { | 1065 | { |
1066 | KABC::Resource *resource = requestResource( this ); | 1066 | KABC::Resource *resource = requestResource( this ); |
1067 | KABC::Addressee::List::Iterator it; | 1067 | KABC::Addressee::List::Iterator it; |
1068 | for ( it = list.begin(); it != list.end(); ++it ) | 1068 | for ( it = list.begin(); it != list.end(); ++it ) |
1069 | (*it).setResource( resource ); | 1069 | (*it).setResource( resource ); |
1070 | 1070 | ||
1071 | PwPasteCommand *command = new PwPasteCommand( this, list ); | 1071 | PwPasteCommand *command = new PwPasteCommand( this, list ); |
1072 | UndoStack::instance()->push( command ); | 1072 | UndoStack::instance()->push( command ); |
1073 | RedoStack::instance()->clear(); | 1073 | RedoStack::instance()->clear(); |
1074 | 1074 | ||
1075 | setModified( true ); | 1075 | setModified( true ); |
1076 | } | 1076 | } |
1077 | 1077 | ||
1078 | void KABCore::setWhoAmI() | 1078 | void KABCore::setWhoAmI() |
1079 | { | 1079 | { |
1080 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 1080 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
1081 | 1081 | ||
1082 | if ( addrList.count() > 1 ) { | 1082 | if ( addrList.count() > 1 ) { |
1083 | KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); | 1083 | KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); |
1084 | return; | 1084 | return; |
1085 | } | 1085 | } |
1086 | 1086 | ||
1087 | QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); | 1087 | QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); |
1088 | if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) | 1088 | if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) |
1089 | static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); | 1089 | static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); |
1090 | } | 1090 | } |
1091 | void KABCore::editCategories() | 1091 | void KABCore::editCategories() |
1092 | { | 1092 | { |
1093 | KPIM::CategoryEditDialog dlg ( KABPrefs::instance(), this, "", true ); | 1093 | KPIM::CategoryEditDialog dlg ( KABPrefs::instance(), this, "", true ); |
1094 | dlg.exec(); | 1094 | dlg.exec(); |
1095 | } | 1095 | } |
1096 | void KABCore::setCategories() | 1096 | void KABCore::setCategories() |
1097 | { | 1097 | { |
1098 | 1098 | ||
1099 | QStringList uids; | 1099 | QStringList uids; |
1100 | XXPortSelectDialog dlgx( this, false, this ); | 1100 | XXPortSelectDialog dlgx( this, false, this ); |
1101 | if ( dlgx.exec() ) | 1101 | if ( dlgx.exec() ) |
1102 | uids = dlgx.uids(); | 1102 | uids = dlgx.uids(); |
1103 | else | 1103 | else |
1104 | return; | 1104 | return; |
1105 | if ( uids.isEmpty() ) | 1105 | if ( uids.isEmpty() ) |
1106 | return; | 1106 | return; |
1107 | // qDebug("count %d ", uids.count()); | 1107 | // qDebug("count %d ", uids.count()); |
1108 | 1108 | ||
1109 | 1109 | ||
1110 | KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); | 1110 | KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); |
1111 | if ( !dlg.exec() ) { | 1111 | if ( !dlg.exec() ) { |
1112 | message( i18n("Setting categories cancelled") ); | 1112 | message( i18n("Setting categories cancelled") ); |
1113 | return; | 1113 | return; |
1114 | } | 1114 | } |
1115 | bool merge = false; | 1115 | bool merge = false; |
1116 | QString msg = i18n( "Merge with existing categories?" ); | 1116 | QString msg = i18n( "Merge with existing categories?" ); |
1117 | if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) | 1117 | if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) |
1118 | merge = true; | 1118 | merge = true; |
1119 | 1119 | ||
1120 | message( i18n("Setting categories ... please wait!") ); | 1120 | message( i18n("Setting categories ... please wait!") ); |
1121 | QStringList categories = dlg.selectedCategories(); | 1121 | QStringList categories = dlg.selectedCategories(); |
1122 | 1122 | ||
1123 | //QStringList uids = mViewManager->selectedUids(); | 1123 | //QStringList uids = mViewManager->selectedUids(); |
1124 | QStringList::Iterator it; | 1124 | QStringList::Iterator it; |
1125 | for ( it = uids.begin(); it != uids.end(); ++it ) { | 1125 | for ( it = uids.begin(); it != uids.end(); ++it ) { |
1126 | KABC::Addressee addr = mAddressBook->findByUid( *it ); | 1126 | KABC::Addressee addr = mAddressBook->findByUid( *it ); |
1127 | if ( !addr.isEmpty() ) { | 1127 | if ( !addr.isEmpty() ) { |
1128 | if ( !merge ) | 1128 | if ( !merge ) |
1129 | addr.setCategories( categories ); | 1129 | addr.setCategories( categories ); |
1130 | else { | 1130 | else { |
1131 | QStringList addrCategories = addr.categories(); | 1131 | QStringList addrCategories = addr.categories(); |
1132 | QStringList::Iterator catIt; | 1132 | QStringList::Iterator catIt; |
1133 | for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { | 1133 | for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { |
1134 | if ( !addrCategories.contains( *catIt ) ) | 1134 | if ( !addrCategories.contains( *catIt ) ) |
1135 | addrCategories.append( *catIt ); | 1135 | addrCategories.append( *catIt ); |
1136 | } | 1136 | } |
1137 | addr.setCategories( addrCategories ); | 1137 | addr.setCategories( addrCategories ); |
1138 | } | 1138 | } |
1139 | mAddressBook->insertAddressee( addr ); | 1139 | mAddressBook->insertAddressee( addr ); |
1140 | } | 1140 | } |
1141 | } | 1141 | } |
1142 | 1142 | ||
1143 | if ( uids.count() > 0 ) | 1143 | if ( uids.count() > 0 ) |
1144 | setModified( true ); | 1144 | setModified( true ); |
1145 | message( i18n("Setting categories completed!") ); | 1145 | message( i18n("Setting categories completed!") ); |
1146 | } | 1146 | } |
1147 | 1147 | ||
1148 | void KABCore::setSearchFields( const KABC::Field::List &fields ) | 1148 | void KABCore::setSearchFields( const KABC::Field::List &fields ) |
1149 | { | 1149 | { |
1150 | mIncSearchWidget->setFields( fields ); | 1150 | mIncSearchWidget->setFields( fields ); |
1151 | } | 1151 | } |
1152 | 1152 | ||
1153 | void KABCore::incrementalSearch( const QString& text ) | 1153 | void KABCore::incrementalSearch( const QString& text ) |
1154 | { | 1154 | { |
1155 | mViewManager->doSearch( text, mIncSearchWidget->currentField() ); | 1155 | mViewManager->doSearch( text, mIncSearchWidget->currentField() ); |
1156 | } | 1156 | } |
1157 | 1157 | ||
1158 | void KABCore::setModified() | 1158 | void KABCore::setModified() |
1159 | { | 1159 | { |
1160 | setModified( true ); | 1160 | setModified( true ); |
1161 | } | 1161 | } |
1162 | 1162 | ||
1163 | void KABCore::setModifiedWOrefresh() | 1163 | void KABCore::setModifiedWOrefresh() |
1164 | { | 1164 | { |
1165 | // qDebug("KABCore::setModifiedWOrefresh() "); | 1165 | // qDebug("KABCore::setModifiedWOrefresh() "); |
1166 | mModified = true; | 1166 | mModified = true; |
1167 | mActionSave->setEnabled( mModified ); | 1167 | mActionSave->setEnabled( mModified ); |
1168 | 1168 | ||
1169 | 1169 | ||
1170 | } | 1170 | } |
1171 | void KABCore::setModified( bool modified ) | 1171 | void KABCore::setModified( bool modified ) |
1172 | { | 1172 | { |
1173 | mModified = modified; | 1173 | mModified = modified; |
1174 | mActionSave->setEnabled( mModified ); | 1174 | mActionSave->setEnabled( mModified ); |
1175 | 1175 | ||
1176 | if ( modified ) | 1176 | if ( modified ) |
1177 | mJumpButtonBar->recreateButtons(); | 1177 | mJumpButtonBar->recreateButtons(); |
1178 | 1178 | ||
1179 | mViewManager->refreshView(); | 1179 | mViewManager->refreshView(); |
1180 | 1180 | ||
1181 | } | 1181 | } |
1182 | 1182 | ||
1183 | bool KABCore::modified() const | 1183 | bool KABCore::modified() const |
1184 | { | 1184 | { |
1185 | return mModified; | 1185 | return mModified; |
1186 | } | 1186 | } |
1187 | 1187 | ||
1188 | void KABCore::contactModified( const KABC::Addressee &addr ) | 1188 | void KABCore::contactModified( const KABC::Addressee &addr ) |
1189 | { | 1189 | { |
1190 | addrModified( addr ); | 1190 | addrModified( addr ); |
1191 | } | 1191 | } |
1192 | 1192 | ||
1193 | void KABCore::addrModified( const KABC::Addressee &addr ,bool updateDetails ) | 1193 | void KABCore::addrModified( const KABC::Addressee &addr ,bool updateDetails ) |
1194 | { | 1194 | { |
1195 | 1195 | ||
1196 | Command *command = 0; | 1196 | Command *command = 0; |
1197 | QString uid; | 1197 | QString uid; |
1198 | 1198 | ||
1199 | // check if it exists already | 1199 | // check if it exists already |
1200 | KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); | 1200 | KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); |
1201 | if ( origAddr.isEmpty() ) | 1201 | if ( origAddr.isEmpty() ) |
1202 | command = new PwNewCommand( mAddressBook, addr ); | 1202 | command = new PwNewCommand( mAddressBook, addr ); |
1203 | else { | 1203 | else { |
1204 | command = new PwEditCommand( mAddressBook, origAddr, addr ); | 1204 | command = new PwEditCommand( mAddressBook, origAddr, addr ); |
1205 | uid = addr.uid(); | 1205 | uid = addr.uid(); |
1206 | } | 1206 | } |
1207 | 1207 | ||
1208 | UndoStack::instance()->push( command ); | 1208 | UndoStack::instance()->push( command ); |
1209 | RedoStack::instance()->clear(); | 1209 | RedoStack::instance()->clear(); |
1210 | if ( updateDetails ) | 1210 | if ( updateDetails ) |
1211 | mDetails->setAddressee( addr ); | 1211 | mDetails->setAddressee( addr ); |
1212 | setModified( true ); | 1212 | setModified( true ); |
1213 | } | 1213 | } |
1214 | 1214 | ||
1215 | void KABCore::newContact() | 1215 | void KABCore::newContact() |
1216 | { | 1216 | { |
1217 | 1217 | ||
1218 | 1218 | ||
1219 | QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); | 1219 | QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); |
1220 | 1220 | ||
1221 | QPtrList<KRES::Resource> kresResources; | 1221 | QPtrList<KRES::Resource> kresResources; |
1222 | QPtrListIterator<KABC::Resource> it( kabcResources ); | 1222 | QPtrListIterator<KABC::Resource> it( kabcResources ); |
1223 | KABC::Resource *resource; | 1223 | KABC::Resource *resource; |
1224 | while ( ( resource = it.current() ) != 0 ) { | 1224 | while ( ( resource = it.current() ) != 0 ) { |
1225 | ++it; | 1225 | ++it; |
1226 | if ( !resource->readOnly() ) { | 1226 | if ( !resource->readOnly() ) { |
1227 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); | 1227 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); |
1228 | if ( res ) | 1228 | if ( res ) |
1229 | kresResources.append( res ); | 1229 | kresResources.append( res ); |
1230 | } | 1230 | } |
1231 | } | 1231 | } |
1232 | 1232 | ||
1233 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); | 1233 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); |
1234 | resource = static_cast<KABC::Resource*>( res ); | 1234 | resource = static_cast<KABC::Resource*>( res ); |
1235 | 1235 | ||
1236 | if ( resource ) { | 1236 | if ( resource ) { |
1237 | KABC::Addressee addr; | 1237 | KABC::Addressee addr; |
1238 | addr.setResource( resource ); | 1238 | addr.setResource( resource ); |
1239 | mEditorDialog->setAddressee( addr ); | 1239 | mEditorDialog->setAddressee( addr ); |
1240 | KApplication::execDialog ( mEditorDialog ); | 1240 | KApplication::execDialog ( mEditorDialog ); |
1241 | 1241 | ||
1242 | } else | 1242 | } else |
1243 | return; | 1243 | return; |
1244 | 1244 | ||
1245 | // mEditorDict.insert( dialog->addressee().uid(), dialog ); | 1245 | // mEditorDict.insert( dialog->addressee().uid(), dialog ); |
1246 | 1246 | ||
1247 | 1247 | ||
1248 | } | 1248 | } |
1249 | 1249 | ||
1250 | void KABCore::addEmail( QString aStr ) | 1250 | void KABCore::addEmail( QString aStr ) |
1251 | { | 1251 | { |
1252 | #ifndef KAB_EMBEDDED | 1252 | #ifndef KAB_EMBEDDED |
1253 | QString fullName, email; | 1253 | QString fullName, email; |
1254 | 1254 | ||
1255 | KABC::Addressee::parseEmailAddress( aStr, fullName, email ); | 1255 | KABC::Addressee::parseEmailAddress( aStr, fullName, email ); |
1256 | 1256 | ||
1257 | // Try to lookup the addressee matching the email address | 1257 | // Try to lookup the addressee matching the email address |
1258 | bool found = false; | 1258 | bool found = false; |
1259 | QStringList emailList; | 1259 | QStringList emailList; |
1260 | KABC::AddressBook::Iterator it; | 1260 | KABC::AddressBook::Iterator it; |
1261 | for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { | 1261 | for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { |
1262 | emailList = (*it).emails(); | 1262 | emailList = (*it).emails(); |
1263 | if ( emailList.contains( email ) > 0 ) { | 1263 | if ( emailList.contains( email ) > 0 ) { |
1264 | found = true; | 1264 | found = true; |
1265 | (*it).setNameFromString( fullName ); | 1265 | (*it).setNameFromString( fullName ); |
1266 | editContact( (*it).uid() ); | 1266 | editContact( (*it).uid() ); |
1267 | } | 1267 | } |
1268 | } | 1268 | } |
1269 | 1269 | ||
1270 | if ( !found ) { | 1270 | if ( !found ) { |
1271 | KABC::Addressee addr; | 1271 | KABC::Addressee addr; |
1272 | addr.setNameFromString( fullName ); | 1272 | addr.setNameFromString( fullName ); |
1273 | addr.insertEmail( email, true ); | 1273 | addr.insertEmail( email, true ); |
1274 | 1274 | ||
1275 | mAddressBook->insertAddressee( addr ); | 1275 | mAddressBook->insertAddressee( addr ); |
1276 | mViewManager->refreshView( addr.uid() ); | 1276 | mViewManager->refreshView( addr.uid() ); |
1277 | editContact( addr.uid() ); | 1277 | editContact( addr.uid() ); |
1278 | } | 1278 | } |
1279 | #else //KAB_EMBEDDED | 1279 | #else //KAB_EMBEDDED |
1280 | qDebug("KABCore::addEmail finsih method"); | 1280 | qDebug("KABCore::addEmail finsih method"); |
1281 | #endif //KAB_EMBEDDED | 1281 | #endif //KAB_EMBEDDED |
1282 | } | 1282 | } |
1283 | 1283 | ||
1284 | void KABCore::importVCard( const KURL &url, bool showPreview ) | 1284 | void KABCore::importVCard( const KURL &url, bool showPreview ) |
1285 | { | 1285 | { |
1286 | mXXPortManager->importVCard( url, showPreview ); | 1286 | mXXPortManager->importVCard( url, showPreview ); |
1287 | } | 1287 | } |
1288 | void KABCore::importFromOL() | 1288 | void KABCore::importFromOL() |
1289 | { | 1289 | { |
1290 | #ifdef _WIN32_ | 1290 | #ifdef _WIN32_ |
1291 | KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); | 1291 | KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); |
1292 | idgl->exec(); | 1292 | idgl->exec(); |
1293 | KABC::Addressee::List list = idgl->getAddressList(); | 1293 | KABC::Addressee::List list = idgl->getAddressList(); |
1294 | if ( list.count() > 0 ) { | 1294 | if ( list.count() > 0 ) { |
1295 | KABC::Addressee::List listNew; | 1295 | KABC::Addressee::List listNew; |
1296 | KABC::Addressee::List listExisting; | 1296 | KABC::Addressee::List listExisting; |
1297 | KABC::Addressee::List::Iterator it; | 1297 | KABC::Addressee::List::Iterator it; |
1298 | KABC::AddressBook::Iterator iter; | 1298 | KABC::AddressBook::Iterator iter; |
1299 | for ( it = list.begin(); it != list.end(); ++it ) { | 1299 | for ( it = list.begin(); it != list.end(); ++it ) { |
1300 | if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) | 1300 | if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) |
1301 | listNew.append( (*it) ); | 1301 | listNew.append( (*it) ); |
1302 | else | 1302 | else |
1303 | listExisting.append( (*it) ); | 1303 | listExisting.append( (*it) ); |
1304 | } | 1304 | } |
1305 | if ( listExisting.count() > 0 ) | 1305 | if ( listExisting.count() > 0 ) |
1306 | KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); | 1306 | KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); |
1307 | if ( listNew.count() > 0 ) { | 1307 | if ( listNew.count() > 0 ) { |
1308 | pasteWithNewUid = false; | 1308 | pasteWithNewUid = false; |
1309 | pasteContacts( listNew ); | 1309 | pasteContacts( listNew ); |
1310 | pasteWithNewUid = true; | 1310 | pasteWithNewUid = true; |
1311 | } | 1311 | } |
1312 | } | 1312 | } |
1313 | delete idgl; | 1313 | delete idgl; |
1314 | #endif | 1314 | #endif |
1315 | } | 1315 | } |
1316 | 1316 | ||
1317 | void KABCore::importVCard( const QString &vCard, bool showPreview ) | 1317 | void KABCore::importVCard( const QString &vCard, bool showPreview ) |
1318 | { | 1318 | { |
1319 | mXXPortManager->importVCard( vCard, showPreview ); | 1319 | mXXPortManager->importVCard( vCard, showPreview ); |
1320 | } | 1320 | } |
1321 | 1321 | ||
1322 | //US added a second method without defaultparameter | 1322 | //US added a second method without defaultparameter |
1323 | void KABCore::editContact2() { | 1323 | void KABCore::editContact2() { |
1324 | editContact( QString::null ); | 1324 | editContact( QString::null ); |
1325 | } | 1325 | } |
1326 | 1326 | ||
1327 | void KABCore::editContact( const QString &uid ) | 1327 | void KABCore::editContact( const QString &uid ) |
1328 | { | 1328 | { |
1329 | 1329 | ||
1330 | if ( mExtensionManager->isQuickEditVisible() ) | 1330 | if ( mExtensionManager->isQuickEditVisible() ) |
1331 | return; | 1331 | return; |
1332 | 1332 | ||
1333 | // First, locate the contact entry | 1333 | // First, locate the contact entry |
1334 | QString localUID = uid; | 1334 | QString localUID = uid; |
1335 | if ( localUID.isNull() ) { | 1335 | if ( localUID.isNull() ) { |
1336 | QStringList uidList = mViewManager->selectedUids(); | 1336 | QStringList uidList = mViewManager->selectedUids(); |
1337 | if ( uidList.count() > 0 ) | 1337 | if ( uidList.count() > 0 ) |
1338 | localUID = *( uidList.at( 0 ) ); | 1338 | localUID = *( uidList.at( 0 ) ); |
1339 | } | 1339 | } |
1340 | 1340 | ||
1341 | KABC::Addressee addr = mAddressBook->findByUid( localUID ); | 1341 | KABC::Addressee addr = mAddressBook->findByUid( localUID ); |
1342 | if ( !addr.isEmpty() ) { | 1342 | if ( !addr.isEmpty() ) { |
1343 | mEditorDialog->setAddressee( addr ); | 1343 | mEditorDialog->setAddressee( addr ); |
1344 | KApplication::execDialog ( mEditorDialog ); | 1344 | KApplication::execDialog ( mEditorDialog ); |
1345 | } | 1345 | } |
1346 | } | 1346 | } |
1347 | 1347 | ||
1348 | /** | 1348 | /** |
1349 | Shows or edits the detail view for the given uid. If the uid is QString::null, | 1349 | Shows or edits the detail view for the given uid. If the uid is QString::null, |
1350 | the method will try to find a selected addressee in the view. | 1350 | the method will try to find a selected addressee in the view. |
1351 | */ | 1351 | */ |
1352 | void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) | 1352 | void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) |
1353 | { | 1353 | { |
1354 | if ( mMultipleViewsAtOnce ) | 1354 | if ( mMultipleViewsAtOnce ) |
1355 | { | 1355 | { |
1356 | editContact( uid ); | 1356 | editContact( uid ); |
1357 | } | 1357 | } |
1358 | else | 1358 | else |
1359 | { | 1359 | { |
1360 | setDetailsVisible( true ); | 1360 | setDetailsVisible( true ); |
1361 | mActionDetails->setChecked(true); | 1361 | mActionDetails->setChecked(true); |
1362 | } | 1362 | } |
1363 | 1363 | ||
1364 | } | 1364 | } |
1365 | 1365 | ||
1366 | void KABCore::save() | 1366 | void KABCore::save() |
1367 | { | 1367 | { |
1368 | if (syncManager->blockSave()) | 1368 | if (syncManager->blockSave()) |
1369 | return; | 1369 | return; |
1370 | if ( !mModified ) | 1370 | if ( !mModified ) |
1371 | return; | 1371 | return; |
1372 | 1372 | ||
1373 | syncManager->setBlockSave(true); | 1373 | syncManager->setBlockSave(true); |
1374 | QString text = i18n( "There was an error while attempting to save\n the " | 1374 | QString text = i18n( "There was an error while attempting to save\n the " |
1375 | "address book. Please check that some \nother application is " | 1375 | "address book. Please check that some \nother application is " |
1376 | "not using it. " ); | 1376 | "not using it. " ); |
1377 | message(i18n("Saving ... please wait! "), false); | 1377 | message(i18n("Saving ... please wait! "), false); |
1378 | //qApp->processEvents(); | 1378 | //qApp->processEvents(); |
1379 | #ifndef KAB_EMBEDDED | 1379 | #ifndef KAB_EMBEDDED |
1380 | KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); | 1380 | KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); |
1381 | if ( !b || !b->save() ) { | 1381 | if ( !b || !b->save() ) { |
1382 | KMessageBox::error( this, text, i18n( "Unable to Save" ) ); | 1382 | KMessageBox::error( this, text, i18n( "Unable to Save" ) ); |
1383 | } | 1383 | } |
1384 | #else //KAB_EMBEDDED | 1384 | #else //KAB_EMBEDDED |
1385 | KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); | 1385 | KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); |
1386 | if ( !b || !b->save() ) { | 1386 | if ( !b || !b->save() ) { |
1387 | QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); | 1387 | QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); |
1388 | } | 1388 | } |
1389 | #endif //KAB_EMBEDDED | 1389 | #endif //KAB_EMBEDDED |
1390 | 1390 | ||
1391 | message(i18n("Addressbook saved!")); | 1391 | message(i18n("Addressbook saved!")); |
1392 | setModified( false ); | 1392 | setModified( false ); |
1393 | syncManager->setBlockSave(false); | 1393 | syncManager->setBlockSave(false); |
1394 | } | 1394 | } |
1395 | 1395 | ||
1396 | 1396 | ||
1397 | void KABCore::undo() | 1397 | void KABCore::undo() |
1398 | { | 1398 | { |
1399 | UndoStack::instance()->undo(); | 1399 | UndoStack::instance()->undo(); |
1400 | 1400 | ||
1401 | // Refresh the view | 1401 | // Refresh the view |
1402 | mViewManager->refreshView(); | 1402 | mViewManager->refreshView(); |
1403 | } | 1403 | } |
1404 | 1404 | ||
1405 | void KABCore::redo() | 1405 | void KABCore::redo() |
1406 | { | 1406 | { |
1407 | RedoStack::instance()->redo(); | 1407 | RedoStack::instance()->redo(); |
1408 | 1408 | ||
1409 | // Refresh the view | 1409 | // Refresh the view |
1410 | mViewManager->refreshView(); | 1410 | mViewManager->refreshView(); |
1411 | } | 1411 | } |
1412 | 1412 | ||
1413 | void KABCore::setJumpButtonBarVisible( bool visible ) | 1413 | void KABCore::setJumpButtonBarVisible( bool visible ) |
1414 | { | 1414 | { |
1415 | if (mMultipleViewsAtOnce) | 1415 | if (mMultipleViewsAtOnce) |
1416 | { | 1416 | { |
1417 | if ( visible ) | 1417 | if ( visible ) |
1418 | mJumpButtonBar->show(); | 1418 | mJumpButtonBar->show(); |
1419 | else | 1419 | else |
1420 | mJumpButtonBar->hide(); | 1420 | mJumpButtonBar->hide(); |
1421 | } | 1421 | } |
1422 | else | 1422 | else |
1423 | { | 1423 | { |
1424 | // show the jumpbar only if "the details are hidden" == "viewmanager are shown" | 1424 | // show the jumpbar only if "the details are hidden" == "viewmanager are shown" |
1425 | if (mViewManager->isVisible()) | 1425 | if (mViewManager->isVisible()) |
1426 | { | 1426 | { |
1427 | if ( visible ) | 1427 | if ( visible ) |
1428 | mJumpButtonBar->show(); | 1428 | mJumpButtonBar->show(); |
1429 | else | 1429 | else |
1430 | mJumpButtonBar->hide(); | 1430 | mJumpButtonBar->hide(); |
1431 | } | 1431 | } |
1432 | else | 1432 | else |
1433 | { | 1433 | { |
1434 | mJumpButtonBar->hide(); | 1434 | mJumpButtonBar->hide(); |
1435 | } | 1435 | } |
1436 | } | 1436 | } |
1437 | } | 1437 | } |
1438 | 1438 | ||
1439 | 1439 | ||
1440 | void KABCore::setDetailsToState() | 1440 | void KABCore::setDetailsToState() |
1441 | { | 1441 | { |
1442 | setDetailsVisible( mActionDetails->isChecked() ); | 1442 | setDetailsVisible( mActionDetails->isChecked() ); |
1443 | } | 1443 | } |
1444 | void KABCore::setDetailsToggle() | 1444 | void KABCore::setDetailsToggle() |
1445 | { | 1445 | { |
1446 | mActionDetails->setChecked( !mActionDetails->isChecked() ); | 1446 | mActionDetails->setChecked( !mActionDetails->isChecked() ); |
1447 | setDetailsToState(); | 1447 | setDetailsToState(); |
1448 | } | 1448 | } |
1449 | 1449 | ||
1450 | 1450 | ||
1451 | 1451 | ||
1452 | void KABCore::setDetailsVisible( bool visible ) | 1452 | void KABCore::setDetailsVisible( bool visible ) |
1453 | { | 1453 | { |
1454 | if (visible && mDetails->isHidden()) | 1454 | if (visible && mDetails->isHidden()) |
1455 | { | 1455 | { |
1456 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 1456 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
1457 | if ( addrList.count() > 0 ) | 1457 | if ( addrList.count() > 0 ) |
1458 | mDetails->setAddressee( addrList[ 0 ] ); | 1458 | mDetails->setAddressee( addrList[ 0 ] ); |
1459 | } | 1459 | } |
1460 | 1460 | ||
1461 | // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between | 1461 | // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between |
1462 | // the listview and the detailview. We do that by changing the splitbar size. | 1462 | // the listview and the detailview. We do that by changing the splitbar size. |
1463 | if (mMultipleViewsAtOnce) | 1463 | if (mMultipleViewsAtOnce) |
1464 | { | 1464 | { |
1465 | if ( visible ) | 1465 | if ( visible ) |
1466 | mDetails->show(); | 1466 | mDetails->show(); |
1467 | else | 1467 | else |
1468 | mDetails->hide(); | 1468 | mDetails->hide(); |
1469 | } | 1469 | } |
1470 | else | 1470 | else |
1471 | { | 1471 | { |
1472 | if ( visible ) { | 1472 | if ( visible ) { |
1473 | mViewManager->hide(); | 1473 | mViewManager->hide(); |
1474 | mDetails->show(); | 1474 | mDetails->show(); |
1475 | mIncSearchWidget->setFocus(); | 1475 | mIncSearchWidget->setFocus(); |
1476 | } | 1476 | } |
1477 | else { | 1477 | else { |
1478 | mViewManager->show(); | 1478 | mViewManager->show(); |
1479 | mDetails->hide(); | 1479 | mDetails->hide(); |
1480 | mViewManager->setFocusAV(); | 1480 | mViewManager->setFocusAV(); |
1481 | } | 1481 | } |
1482 | setJumpButtonBarVisible( !visible ); | 1482 | setJumpButtonBarVisible( !visible ); |
1483 | } | 1483 | } |
1484 | 1484 | ||
1485 | } | 1485 | } |
1486 | 1486 | ||
1487 | void KABCore::extensionChanged( int id ) | 1487 | void KABCore::extensionChanged( int id ) |
1488 | { | 1488 | { |
1489 | //change the details view only for non desktop systems | 1489 | //change the details view only for non desktop systems |
1490 | #ifndef DESKTOP_VERSION | 1490 | #ifndef DESKTOP_VERSION |
1491 | 1491 | ||
1492 | if (id == 0) | 1492 | if (id == 0) |
1493 | { | 1493 | { |
1494 | //the user disabled the extension. | 1494 | //the user disabled the extension. |
1495 | 1495 | ||
1496 | if (mMultipleViewsAtOnce) | 1496 | if (mMultipleViewsAtOnce) |
1497 | { // enable detailsview again | 1497 | { // enable detailsview again |
1498 | setDetailsVisible( true ); | 1498 | setDetailsVisible( true ); |
1499 | mActionDetails->setChecked( true ); | 1499 | mActionDetails->setChecked( true ); |
1500 | } | 1500 | } |
1501 | else | 1501 | else |
1502 | { //go back to the listview | 1502 | { //go back to the listview |
1503 | setDetailsVisible( false ); | 1503 | setDetailsVisible( false ); |
1504 | mActionDetails->setChecked( false ); | 1504 | mActionDetails->setChecked( false ); |
1505 | mActionDetails->setEnabled(true); | 1505 | mActionDetails->setEnabled(true); |
1506 | } | 1506 | } |
1507 | 1507 | ||
1508 | } | 1508 | } |
1509 | else | 1509 | else |
1510 | { | 1510 | { |
1511 | //the user enabled the extension. | 1511 | //the user enabled the extension. |
1512 | setDetailsVisible( false ); | 1512 | setDetailsVisible( false ); |
1513 | mActionDetails->setChecked( false ); | 1513 | mActionDetails->setChecked( false ); |
1514 | 1514 | ||
1515 | if (!mMultipleViewsAtOnce) | 1515 | if (!mMultipleViewsAtOnce) |
1516 | { | 1516 | { |
1517 | mActionDetails->setEnabled(false); | 1517 | mActionDetails->setEnabled(false); |
1518 | } | 1518 | } |
1519 | 1519 | ||
1520 | mExtensionManager->setSelectionChanged(); | 1520 | mExtensionManager->setSelectionChanged(); |
1521 | 1521 | ||
1522 | } | 1522 | } |
1523 | 1523 | ||
1524 | #endif// DESKTOP_VERSION | 1524 | #endif// DESKTOP_VERSION |
1525 | 1525 | ||
1526 | } | 1526 | } |
1527 | 1527 | ||
1528 | 1528 | ||
1529 | void KABCore::extensionModified( const KABC::Addressee::List &list ) | 1529 | void KABCore::extensionModified( const KABC::Addressee::List &list ) |
1530 | { | 1530 | { |
1531 | 1531 | ||
1532 | if ( list.count() != 0 ) { | 1532 | if ( list.count() != 0 ) { |
1533 | KABC::Addressee::List::ConstIterator it; | 1533 | KABC::Addressee::List::ConstIterator it; |
1534 | for ( it = list.begin(); it != list.end(); ++it ) | 1534 | for ( it = list.begin(); it != list.end(); ++it ) |
1535 | mAddressBook->insertAddressee( *it ); | 1535 | mAddressBook->insertAddressee( *it ); |
1536 | if ( list.count() > 1 ) | 1536 | if ( list.count() > 1 ) |
1537 | setModified(); | 1537 | setModified(); |
1538 | else | 1538 | else |
1539 | setModifiedWOrefresh(); | 1539 | setModifiedWOrefresh(); |
1540 | } | 1540 | } |
1541 | if ( list.count() == 0 ) | 1541 | if ( list.count() == 0 ) |
1542 | mViewManager->refreshView(); | 1542 | mViewManager->refreshView(); |
1543 | else | 1543 | else |
1544 | mViewManager->refreshView( list[ 0 ].uid() ); | 1544 | mViewManager->refreshView( list[ 0 ].uid() ); |
1545 | 1545 | ||
1546 | 1546 | ||
1547 | 1547 | ||
1548 | } | 1548 | } |
1549 | 1549 | ||
1550 | QString KABCore::getNameByPhone( const QString &phone ) | 1550 | QString KABCore::getNameByPhone( const QString &phone ) |
1551 | { | 1551 | { |
1552 | #ifndef KAB_EMBEDDED | 1552 | #ifndef KAB_EMBEDDED |
1553 | QRegExp r( "[/*/-/ ]" ); | 1553 | QRegExp r( "[/*/-/ ]" ); |
1554 | QString localPhone( phone ); | 1554 | QString localPhone( phone ); |
1555 | 1555 | ||
1556 | bool found = false; | 1556 | bool found = false; |
1557 | QString ownerName = ""; | 1557 | QString ownerName = ""; |
1558 | KABC::AddressBook::Iterator iter; | 1558 | KABC::AddressBook::Iterator iter; |
1559 | KABC::PhoneNumber::List::Iterator phoneIter; | 1559 | KABC::PhoneNumber::List::Iterator phoneIter; |
1560 | KABC::PhoneNumber::List phoneList; | 1560 | KABC::PhoneNumber::List phoneList; |
1561 | for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { | 1561 | for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { |
1562 | phoneList = (*iter).phoneNumbers(); | 1562 | phoneList = (*iter).phoneNumbers(); |
1563 | for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); | 1563 | for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); |
1564 | ++phoneIter) { | 1564 | ++phoneIter) { |
1565 | // Get rid of separator chars so just the numbers are compared. | 1565 | // Get rid of separator chars so just the numbers are compared. |
1566 | if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { | 1566 | if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { |
1567 | ownerName = (*iter).formattedName(); | 1567 | ownerName = (*iter).formattedName(); |
1568 | found = true; | 1568 | found = true; |
1569 | } | 1569 | } |
1570 | } | 1570 | } |
1571 | } | 1571 | } |
1572 | 1572 | ||
1573 | return ownerName; | 1573 | return ownerName; |
1574 | #else //KAB_EMBEDDED | 1574 | #else //KAB_EMBEDDED |
1575 | qDebug("KABCore::getNameByPhone finsih method"); | 1575 | qDebug("KABCore::getNameByPhone finsih method"); |
1576 | return ""; | 1576 | return ""; |
1577 | #endif //KAB_EMBEDDED | 1577 | #endif //KAB_EMBEDDED |
1578 | 1578 | ||
1579 | } | 1579 | } |
1580 | 1580 | ||
1581 | void KABCore::openConfigDialog() | 1581 | void KABCore::openConfigDialog() |
1582 | { | 1582 | { |
1583 | KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); | 1583 | KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); |
1584 | KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); | 1584 | KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); |
1585 | ConfigureDialog->addModule(kabcfg ); | 1585 | ConfigureDialog->addModule(kabcfg ); |
1586 | KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); | 1586 | KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); |
1587 | ConfigureDialog->addModule(kdelibcfg ); | 1587 | ConfigureDialog->addModule(kdelibcfg ); |
1588 | 1588 | ||
1589 | connect( ConfigureDialog, SIGNAL( applyClicked() ), | 1589 | connect( ConfigureDialog, SIGNAL( applyClicked() ), |
1590 | this, SLOT( configurationChanged() ) ); | 1590 | this, SLOT( configurationChanged() ) ); |
1591 | connect( ConfigureDialog, SIGNAL( okClicked() ), | 1591 | connect( ConfigureDialog, SIGNAL( okClicked() ), |
1592 | this, SLOT( configurationChanged() ) ); | 1592 | this, SLOT( configurationChanged() ) ); |
1593 | saveSettings(); | 1593 | saveSettings(); |
1594 | #ifndef DESKTOP_VERSION | 1594 | #ifndef DESKTOP_VERSION |
1595 | ConfigureDialog->showMaximized(); | 1595 | ConfigureDialog->showMaximized(); |
1596 | #endif | 1596 | #endif |
1597 | if ( ConfigureDialog->exec() ) | 1597 | if ( ConfigureDialog->exec() ) |
1598 | KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); | 1598 | KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); |
1599 | delete ConfigureDialog; | 1599 | delete ConfigureDialog; |
1600 | } | 1600 | } |
1601 | 1601 | ||
1602 | void KABCore::openLDAPDialog() | 1602 | void KABCore::openLDAPDialog() |
1603 | { | 1603 | { |
1604 | #ifndef KAB_EMBEDDED | 1604 | #ifndef KAB_EMBEDDED |
1605 | if ( !mLdapSearchDialog ) { | 1605 | if ( !mLdapSearchDialog ) { |
1606 | mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); | 1606 | mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); |
1607 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, | 1607 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, |
1608 | SLOT( refreshView() ) ); | 1608 | SLOT( refreshView() ) ); |
1609 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, | 1609 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, |
1610 | SLOT( setModified() ) ); | 1610 | SLOT( setModified() ) ); |
1611 | } else | 1611 | } else |
1612 | mLdapSearchDialog->restoreSettings(); | 1612 | mLdapSearchDialog->restoreSettings(); |
1613 | 1613 | ||
1614 | if ( mLdapSearchDialog->isOK() ) | 1614 | if ( mLdapSearchDialog->isOK() ) |
1615 | mLdapSearchDialog->exec(); | 1615 | mLdapSearchDialog->exec(); |
1616 | #else //KAB_EMBEDDED | 1616 | #else //KAB_EMBEDDED |
1617 | qDebug("KABCore::openLDAPDialog() finsih method"); | 1617 | qDebug("KABCore::openLDAPDialog() finsih method"); |
1618 | #endif //KAB_EMBEDDED | 1618 | #endif //KAB_EMBEDDED |
1619 | } | 1619 | } |
1620 | 1620 | ||
1621 | void KABCore::print() | 1621 | void KABCore::print() |
1622 | { | 1622 | { |
1623 | #ifndef KAB_EMBEDDED | 1623 | #ifndef KAB_EMBEDDED |
1624 | KPrinter printer; | 1624 | KPrinter printer; |
1625 | if ( !printer.setup( this ) ) | 1625 | if ( !printer.setup( this ) ) |
1626 | return; | 1626 | return; |
1627 | 1627 | ||
1628 | KABPrinting::PrintingWizard wizard( &printer, mAddressBook, | 1628 | KABPrinting::PrintingWizard wizard( &printer, mAddressBook, |
1629 | mViewManager->selectedUids(), this ); | 1629 | mViewManager->selectedUids(), this ); |
1630 | 1630 | ||
1631 | wizard.exec(); | 1631 | wizard.exec(); |
1632 | #else //KAB_EMBEDDED | 1632 | #else //KAB_EMBEDDED |
1633 | qDebug("KABCore::print() finsih method"); | 1633 | qDebug("KABCore::print() finsih method"); |
1634 | #endif //KAB_EMBEDDED | 1634 | #endif //KAB_EMBEDDED |
1635 | 1635 | ||
1636 | } | 1636 | } |
1637 | 1637 | ||
1638 | 1638 | ||
1639 | void KABCore::addGUIClient( KXMLGUIClient *client ) | 1639 | void KABCore::addGUIClient( KXMLGUIClient *client ) |
1640 | { | 1640 | { |
1641 | if ( mGUIClient ) | 1641 | if ( mGUIClient ) |
1642 | mGUIClient->insertChildClient( client ); | 1642 | mGUIClient->insertChildClient( client ); |
1643 | else | 1643 | else |
1644 | KMessageBox::error( this, "no KXMLGUICLient"); | 1644 | KMessageBox::error( this, "no KXMLGUICLient"); |
1645 | } | 1645 | } |
1646 | 1646 | ||
1647 | 1647 | ||
1648 | void KABCore::configurationChanged() | 1648 | void KABCore::configurationChanged() |
1649 | { | 1649 | { |
1650 | mExtensionManager->reconfigure(); | 1650 | mExtensionManager->reconfigure(); |
1651 | } | 1651 | } |
1652 | 1652 | ||
1653 | void KABCore::addressBookChanged() | 1653 | void KABCore::addressBookChanged() |
1654 | { | 1654 | { |
1655 | /*US | 1655 | /*US |
1656 | QDictIterator<AddresseeEditorDialog> it( mEditorDict ); | 1656 | QDictIterator<AddresseeEditorDialog> it( mEditorDict ); |
1657 | while ( it.current() ) { | 1657 | while ( it.current() ) { |
1658 | if ( it.current()->dirty() ) { | 1658 | if ( it.current()->dirty() ) { |
1659 | QString text = i18n( "Data has been changed externally. Unsaved " | 1659 | QString text = i18n( "Data has been changed externally. Unsaved " |
1660 | "changes will be lost." ); | 1660 | "changes will be lost." ); |
1661 | KMessageBox::information( this, text ); | 1661 | KMessageBox::information( this, text ); |
1662 | } | 1662 | } |
1663 | it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); | 1663 | it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); |
1664 | ++it; | 1664 | ++it; |
1665 | } | 1665 | } |
1666 | */ | 1666 | */ |
1667 | if (mEditorDialog) | 1667 | if (mEditorDialog) |
1668 | { | 1668 | { |
1669 | if (mEditorDialog->dirty()) | 1669 | if (mEditorDialog->dirty()) |
1670 | { | 1670 | { |
1671 | QString text = i18n( "Data has been changed externally. Unsaved " | 1671 | QString text = i18n( "Data has been changed externally. Unsaved " |
1672 | "changes will be lost." ); | 1672 | "changes will be lost." ); |
1673 | KMessageBox::information( this, text ); | 1673 | KMessageBox::information( this, text ); |
1674 | } | 1674 | } |
1675 | QString currentuid = mEditorDialog->addressee().uid(); | 1675 | QString currentuid = mEditorDialog->addressee().uid(); |
1676 | mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); | 1676 | mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); |
1677 | } | 1677 | } |
1678 | mViewManager->refreshView(); | 1678 | mViewManager->refreshView(); |
1679 | 1679 | ||
1680 | 1680 | ||
1681 | } | 1681 | } |
1682 | 1682 | ||
1683 | AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, | 1683 | AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, |
1684 | const char *name ) | 1684 | const char *name ) |
1685 | { | 1685 | { |
1686 | 1686 | ||
1687 | if ( mEditorDialog == 0 ) { | 1687 | if ( mEditorDialog == 0 ) { |
1688 | mEditorDialog = new AddresseeEditorDialog( this, parent, | 1688 | mEditorDialog = new AddresseeEditorDialog( this, parent, |
1689 | name ? name : "editorDialog" ); | 1689 | name ? name : "editorDialog" ); |
1690 | 1690 | ||
1691 | 1691 | ||
1692 | connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), | 1692 | connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), |
1693 | SLOT( contactModified( const KABC::Addressee& ) ) ); | 1693 | SLOT( contactModified( const KABC::Addressee& ) ) ); |
1694 | //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), | 1694 | //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), |
1695 | // SLOT( slotEditorDestroyed( const QString& ) ) ; | 1695 | // SLOT( slotEditorDestroyed( const QString& ) ) ; |
1696 | } | 1696 | } |
1697 | 1697 | ||
1698 | return mEditorDialog; | 1698 | return mEditorDialog; |
1699 | } | 1699 | } |
1700 | 1700 | ||
1701 | void KABCore::slotEditorDestroyed( const QString &uid ) | 1701 | void KABCore::slotEditorDestroyed( const QString &uid ) |
1702 | { | 1702 | { |
1703 | //mEditorDict.remove( uid ); | 1703 | //mEditorDict.remove( uid ); |
1704 | } | 1704 | } |
1705 | 1705 | ||
1706 | void KABCore::initGUI() | 1706 | void KABCore::initGUI() |
1707 | { | 1707 | { |
1708 | #ifndef KAB_EMBEDDED | 1708 | #ifndef KAB_EMBEDDED |
1709 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1709 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1710 | topLayout->setSpacing( KDialogBase::spacingHint() ); | 1710 | topLayout->setSpacing( KDialogBase::spacingHint() ); |
1711 | 1711 | ||
1712 | mExtensionBarSplitter = new QSplitter( this ); | 1712 | mExtensionBarSplitter = new QSplitter( this ); |
1713 | mExtensionBarSplitter->setOrientation( Qt::Vertical ); | 1713 | mExtensionBarSplitter->setOrientation( Qt::Vertical ); |
1714 | 1714 | ||
1715 | mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); | 1715 | mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); |
1716 | 1716 | ||
1717 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); | 1717 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); |
1718 | mIncSearchWidget = new IncSearchWidget( viewSpace ); | 1718 | mIncSearchWidget = new IncSearchWidget( viewSpace ); |
1719 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 1719 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
1720 | SLOT( incrementalSearch( const QString& ) ) ); | 1720 | SLOT( incrementalSearch( const QString& ) ) ); |
1721 | 1721 | ||
1722 | mViewManager = new ViewManager( this, viewSpace ); | 1722 | mViewManager = new ViewManager( this, viewSpace ); |
1723 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1723 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1724 | 1724 | ||
1725 | mDetails = new ViewContainer( mDetailsSplitter ); | 1725 | mDetails = new ViewContainer( mDetailsSplitter ); |
1726 | 1726 | ||
1727 | mJumpButtonBar = new JumpButtonBar( this, this ); | 1727 | mJumpButtonBar = new JumpButtonBar( this, this ); |
1728 | 1728 | ||
1729 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); | 1729 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); |
1730 | 1730 | ||
1731 | topLayout->addWidget( mExtensionBarSplitter ); | 1731 | topLayout->addWidget( mExtensionBarSplitter ); |
1732 | topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); | 1732 | topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); |
1733 | topLayout->addWidget( mJumpButtonBar ); | 1733 | topLayout->addWidget( mJumpButtonBar ); |
1734 | topLayout->setStretchFactor( mJumpButtonBar, 1 ); | 1734 | topLayout->setStretchFactor( mJumpButtonBar, 1 ); |
1735 | 1735 | ||
1736 | mXXPortManager = new XXPortManager( this, this ); | 1736 | mXXPortManager = new XXPortManager( this, this ); |
1737 | 1737 | ||
1738 | #else //KAB_EMBEDDED | 1738 | #else //KAB_EMBEDDED |
1739 | //US initialize viewMenu before settingup viewmanager. | 1739 | //US initialize viewMenu before settingup viewmanager. |
1740 | // Viewmanager needs this menu to plugin submenues. | 1740 | // Viewmanager needs this menu to plugin submenues. |
1741 | viewMenu = new QPopupMenu( this ); | 1741 | viewMenu = new QPopupMenu( this ); |
1742 | settingsMenu = new QPopupMenu( this ); | 1742 | settingsMenu = new QPopupMenu( this ); |
1743 | //filterMenu = new QPopupMenu( this ); | 1743 | //filterMenu = new QPopupMenu( this ); |
1744 | ImportMenu = new QPopupMenu( this ); | 1744 | ImportMenu = new QPopupMenu( this ); |
1745 | ExportMenu = new QPopupMenu( this ); | 1745 | ExportMenu = new QPopupMenu( this ); |
1746 | syncMenu = new QPopupMenu( this ); | 1746 | syncMenu = new QPopupMenu( this ); |
1747 | changeMenu= new QPopupMenu( this ); | 1747 | changeMenu= new QPopupMenu( this ); |
1748 | beamMenu= new QPopupMenu( this ); | 1748 | beamMenu= new QPopupMenu( this ); |
1749 | 1749 | ||
1750 | //US since we have no splitter for the embedded system, setup | 1750 | //US since we have no splitter for the embedded system, setup |
1751 | // a layout with two frames. One left and one right. | 1751 | // a layout with two frames. One left and one right. |
1752 | 1752 | ||
1753 | QBoxLayout *topLayout; | 1753 | QBoxLayout *topLayout; |
1754 | 1754 | ||
1755 | // = new QHBoxLayout( this ); | 1755 | // = new QHBoxLayout( this ); |
1756 | // QBoxLayout *topLayout = (QBoxLayout*)layout(); | 1756 | // QBoxLayout *topLayout = (QBoxLayout*)layout(); |
1757 | 1757 | ||
1758 | // QWidget *mainBox = new QWidget( this ); | 1758 | // QWidget *mainBox = new QWidget( this ); |
1759 | // QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); | 1759 | // QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); |
1760 | 1760 | ||
1761 | #ifdef DESKTOP_VERSION | 1761 | #ifdef DESKTOP_VERSION |
1762 | topLayout = new QHBoxLayout( this ); | 1762 | topLayout = new QHBoxLayout( this ); |
1763 | 1763 | ||
1764 | 1764 | ||
1765 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 1765 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
1766 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 1766 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
1767 | 1767 | ||
1768 | topLayout->addWidget(mMiniSplitter ); | 1768 | topLayout->addWidget(mMiniSplitter ); |
1769 | 1769 | ||
1770 | mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); | 1770 | mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); |
1771 | mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); | 1771 | mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); |
1772 | mViewManager = new ViewManager( this, mExtensionBarSplitter ); | 1772 | mViewManager = new ViewManager( this, mExtensionBarSplitter ); |
1773 | mDetails = new ViewContainer( mMiniSplitter ); | 1773 | mDetails = new ViewContainer( mMiniSplitter ); |
1774 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); | 1774 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); |
1775 | #else | 1775 | #else |
1776 | if ( QApplication::desktop()->width() > 480 ) { | 1776 | if ( QApplication::desktop()->width() > 480 ) { |
1777 | topLayout = new QHBoxLayout( this ); | 1777 | topLayout = new QHBoxLayout( this ); |
1778 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 1778 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
1779 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 1779 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
1780 | } else { | 1780 | } else { |
1781 | 1781 | ||
1782 | topLayout = new QHBoxLayout( this ); | 1782 | topLayout = new QHBoxLayout( this ); |
1783 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); | 1783 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); |
1784 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); | 1784 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); |
1785 | } | 1785 | } |
1786 | 1786 | ||
1787 | topLayout->addWidget(mMiniSplitter ); | 1787 | topLayout->addWidget(mMiniSplitter ); |
1788 | mViewManager = new ViewManager( this, mMiniSplitter ); | 1788 | mViewManager = new ViewManager( this, mMiniSplitter ); |
1789 | mDetails = new ViewContainer( mMiniSplitter ); | 1789 | mDetails = new ViewContainer( mMiniSplitter ); |
1790 | 1790 | ||
1791 | 1791 | ||
1792 | mExtensionManager = new ExtensionManager( this, mMiniSplitter ); | 1792 | mExtensionManager = new ExtensionManager( this, mMiniSplitter ); |
1793 | #endif | 1793 | #endif |
1794 | //eh->hide(); | 1794 | //eh->hide(); |
1795 | // topLayout->addWidget(mExtensionManager ); | 1795 | // topLayout->addWidget(mExtensionManager ); |
1796 | 1796 | ||
1797 | 1797 | ||
1798 | /*US | 1798 | /*US |
1799 | #ifndef KAB_NOSPLITTER | 1799 | #ifndef KAB_NOSPLITTER |
1800 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1800 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1801 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); | 1801 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); |
1802 | topLayout->setSpacing( 10 ); | 1802 | topLayout->setSpacing( 10 ); |
1803 | 1803 | ||
1804 | mDetailsSplitter = new QSplitter( this ); | 1804 | mDetailsSplitter = new QSplitter( this ); |
1805 | 1805 | ||
1806 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); | 1806 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); |
1807 | 1807 | ||
1808 | mViewManager = new ViewManager( this, viewSpace ); | 1808 | mViewManager = new ViewManager( this, viewSpace ); |
1809 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1809 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1810 | 1810 | ||
1811 | mDetails = new ViewContainer( mDetailsSplitter ); | 1811 | mDetails = new ViewContainer( mDetailsSplitter ); |
1812 | 1812 | ||
1813 | topLayout->addWidget( mDetailsSplitter ); | 1813 | topLayout->addWidget( mDetailsSplitter ); |
1814 | topLayout->setStretchFactor( mDetailsSplitter, 100 ); | 1814 | topLayout->setStretchFactor( mDetailsSplitter, 100 ); |
1815 | #else //KAB_NOSPLITTER | 1815 | #else //KAB_NOSPLITTER |
1816 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1816 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1817 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); | 1817 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); |
1818 | topLayout->setSpacing( 10 ); | 1818 | topLayout->setSpacing( 10 ); |
1819 | 1819 | ||
1820 | // mDetailsSplitter = new QSplitter( this ); | 1820 | // mDetailsSplitter = new QSplitter( this ); |
1821 | 1821 | ||
1822 | QVBox *viewSpace = new QVBox( this ); | 1822 | QVBox *viewSpace = new QVBox( this ); |
1823 | 1823 | ||
1824 | mViewManager = new ViewManager( this, viewSpace ); | 1824 | mViewManager = new ViewManager( this, viewSpace ); |
1825 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1825 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1826 | 1826 | ||
1827 | mDetails = new ViewContainer( this ); | 1827 | mDetails = new ViewContainer( this ); |
1828 | 1828 | ||
1829 | topLayout->addWidget( viewSpace ); | 1829 | topLayout->addWidget( viewSpace ); |
1830 | // topLayout->setStretchFactor( mDetailsSplitter, 100 ); | 1830 | // topLayout->setStretchFactor( mDetailsSplitter, 100 ); |
1831 | topLayout->addWidget( mDetails ); | 1831 | topLayout->addWidget( mDetails ); |
1832 | #endif //KAB_NOSPLITTER | 1832 | #endif //KAB_NOSPLITTER |
1833 | */ | 1833 | */ |
1834 | 1834 | ||
1835 | syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); | 1835 | syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); |
1836 | syncManager->setBlockSave(false); | 1836 | syncManager->setBlockSave(false); |
1837 | 1837 | ||
1838 | connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); | 1838 | connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); |
1839 | connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); | 1839 | connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); |
1840 | QString sync_file = sentSyncFile(); | 1840 | QString sync_file = sentSyncFile(); |
1841 | qDebug("KABCore::initGUI()::setting tmp sync file to:%s ",sync_file.latin1()); | 1841 | qDebug("KABCore::initGUI()::setting tmp sync file to:%s ",sync_file.latin1()); |
1842 | syncManager->setDefaultFileName( sync_file ); | 1842 | syncManager->setDefaultFileName( sync_file ); |
1843 | //connect(syncManager , SIGNAL( ), this, SLOT( ) ); | 1843 | //connect(syncManager , SIGNAL( ), this, SLOT( ) ); |
1844 | 1844 | ||
1845 | #endif //KAB_EMBEDDED | 1845 | #endif //KAB_EMBEDDED |
1846 | initActions(); | 1846 | initActions(); |
1847 | 1847 | ||
1848 | #ifdef KAB_EMBEDDED | 1848 | #ifdef KAB_EMBEDDED |
1849 | addActionsManually(); | 1849 | addActionsManually(); |
1850 | //US make sure the export and import menues are initialized before creating the xxPortManager. | 1850 | //US make sure the export and import menues are initialized before creating the xxPortManager. |
1851 | mXXPortManager = new XXPortManager( this, this ); | 1851 | mXXPortManager = new XXPortManager( this, this ); |
1852 | 1852 | ||
1853 | // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); | 1853 | // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); |
1854 | //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); | 1854 | //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); |
1855 | // mActionQuit->plug ( mMainWindow->toolBar()); | 1855 | // mActionQuit->plug ( mMainWindow->toolBar()); |
1856 | //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); | 1856 | //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); |
1857 | //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); | 1857 | //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); |
1858 | // mIncSearchWidget->hide(); | 1858 | // mIncSearchWidget->hide(); |
1859 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 1859 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
1860 | SLOT( incrementalSearch( const QString& ) ) ); | 1860 | SLOT( incrementalSearch( const QString& ) ) ); |
1861 | connect( mIncSearchWidget, SIGNAL( scrollUP() ),mViewManager, SLOT( scrollUP() ) ); | 1861 | connect( mIncSearchWidget, SIGNAL( scrollUP() ),mViewManager, SLOT( scrollUP() ) ); |
1862 | connect( mIncSearchWidget, SIGNAL( scrollDOWN() ),mViewManager, SLOT( scrollDOWN() ) ); | 1862 | connect( mIncSearchWidget, SIGNAL( scrollDOWN() ),mViewManager, SLOT( scrollDOWN() ) ); |
1863 | 1863 | ||
1864 | mJumpButtonBar = new JumpButtonBar( this, this ); | 1864 | mJumpButtonBar = new JumpButtonBar( this, this ); |
1865 | 1865 | ||
1866 | topLayout->addWidget( mJumpButtonBar ); | 1866 | topLayout->addWidget( mJumpButtonBar ); |
1867 | //US topLayout->setStretchFactor( mJumpButtonBar, 10 ); | 1867 | //US topLayout->setStretchFactor( mJumpButtonBar, 10 ); |
1868 | 1868 | ||
1869 | // mMainWindow->getIconToolBar()->raise(); | 1869 | // mMainWindow->getIconToolBar()->raise(); |
1870 | 1870 | ||
1871 | #endif //KAB_EMBEDDED | 1871 | #endif //KAB_EMBEDDED |
1872 | 1872 | ||
1873 | } | 1873 | } |
1874 | void KABCore::initActions() | 1874 | void KABCore::initActions() |
1875 | { | 1875 | { |
1876 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); | 1876 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); |
1877 | 1877 | ||
1878 | #ifndef KAB_EMBEDDED | 1878 | #ifndef KAB_EMBEDDED |
1879 | connect( QApplication::clipboard(), SIGNAL( dataChanged() ), | 1879 | connect( QApplication::clipboard(), SIGNAL( dataChanged() ), |
1880 | SLOT( clipboardDataChanged() ) ); | 1880 | SLOT( clipboardDataChanged() ) ); |
1881 | #endif //KAB_EMBEDDED | 1881 | #endif //KAB_EMBEDDED |
1882 | 1882 | ||
1883 | // file menu | 1883 | // file menu |
1884 | 1884 | ||
1885 | mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); | 1885 | mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); |
1886 | //mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); | 1886 | //mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); |
1887 | mActionPrint = new KAction( i18n( "&Print View" ), "fileprint", CTRL + Key_P, mViewManager, | 1887 | mActionPrint = new KAction( i18n( "&Print View" ), "fileprint", CTRL + Key_P, mViewManager, |
1888 | SLOT( printView() ), actionCollection(), "kaddressbook_print" ); | 1888 | SLOT( printView() ), actionCollection(), "kaddressbook_print" ); |
1889 | 1889 | ||
1890 | 1890 | ||
1891 | mActionPrintDetails = new KAction( i18n( "&Print Details" ), "fileprint", 0, mDetails, | 1891 | mActionPrintDetails = new KAction( i18n( "&Print Details" ), "fileprint", 0, mDetails, |
1892 | SLOT( printView() ), actionCollection(), "kaddressbook_print2" ); | 1892 | SLOT( printView() ), actionCollection(), "kaddressbook_print2" ); |
1893 | 1893 | ||
1894 | mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, | 1894 | mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, |
1895 | SLOT( save() ), actionCollection(), "file_sync" ); | 1895 | SLOT( save() ), actionCollection(), "file_sync" ); |
1896 | 1896 | ||
1897 | mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, | 1897 | mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, |
1898 | SLOT( newContact() ), actionCollection(), "file_new_contact" ); | 1898 | SLOT( newContact() ), actionCollection(), "file_new_contact" ); |
1899 | 1899 | ||
1900 | mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, | 1900 | mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, |
1901 | this, SLOT( mailVCard() ), | 1901 | this, SLOT( mailVCard() ), |
1902 | actionCollection(), "file_mail_vcard"); | 1902 | actionCollection(), "file_mail_vcard"); |
1903 | 1903 | ||
1904 | mActionExport2phone = new KAction( i18n( "Export to phone" ), "ex2phone", 0, this, | 1904 | mActionExport2phone = new KAction( i18n( "Export to phone" ), "ex2phone", 0, this, |
1905 | SLOT( export2phone() ), actionCollection(), | 1905 | SLOT( export2phone() ), actionCollection(), |
1906 | "kaddressbook_ex2phone" ); | 1906 | "kaddressbook_ex2phone" ); |
1907 | 1907 | ||
1908 | mActionBeamVCard = 0; | 1908 | mActionBeamVCard = 0; |
1909 | mActionBeam = 0; | 1909 | mActionBeam = 0; |
1910 | 1910 | ||
1911 | #ifndef DESKTOP_VERSION | 1911 | #ifndef DESKTOP_VERSION |
1912 | if ( Ir::supported() ) { | 1912 | if ( Ir::supported() ) { |
1913 | mActionBeamVCard = new KAction( i18n( "Beam v&Card(s)..." ), "beam", 0, this, | 1913 | mActionBeamVCard = new KAction( i18n( "Beam v&Card(s)..." ), "beam", 0, this, |
1914 | SLOT( beamVCard() ), actionCollection(), | 1914 | SLOT( beamVCard() ), actionCollection(), |
1915 | "kaddressbook_beam_vcard" ); | 1915 | "kaddressbook_beam_vcard" ); |
1916 | 1916 | ||
1917 | mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, | 1917 | mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, |
1918 | SLOT( beamMySelf() ), actionCollection(), | 1918 | SLOT( beamMySelf() ), actionCollection(), |
1919 | "kaddressbook_beam_myself" ); | 1919 | "kaddressbook_beam_myself" ); |
1920 | } | 1920 | } |
1921 | #endif | 1921 | #endif |
1922 | 1922 | ||
1923 | mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, | 1923 | mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, |
1924 | this, SLOT( editContact2() ), | 1924 | this, SLOT( editContact2() ), |
1925 | actionCollection(), "file_properties" ); | 1925 | actionCollection(), "file_properties" ); |
1926 | 1926 | ||
1927 | #ifdef KAB_EMBEDDED | 1927 | #ifdef KAB_EMBEDDED |
1928 | // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); | 1928 | // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); |
1929 | mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, | 1929 | mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, |
1930 | mMainWindow, SLOT( exit() ), | 1930 | mMainWindow, SLOT( exit() ), |
1931 | actionCollection(), "quit" ); | 1931 | actionCollection(), "quit" ); |
1932 | #endif //KAB_EMBEDDED | 1932 | #endif //KAB_EMBEDDED |
1933 | 1933 | ||
1934 | // edit menu | 1934 | // edit menu |
1935 | if ( mIsPart ) { | 1935 | if ( mIsPart ) { |
1936 | mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, | 1936 | mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, |
1937 | SLOT( copyContacts() ), actionCollection(), | 1937 | SLOT( copyContacts() ), actionCollection(), |
1938 | "kaddressbook_copy" ); | 1938 | "kaddressbook_copy" ); |
1939 | mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, | 1939 | mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, |
1940 | SLOT( cutContacts() ), actionCollection(), | 1940 | SLOT( cutContacts() ), actionCollection(), |
1941 | "kaddressbook_cut" ); | 1941 | "kaddressbook_cut" ); |
1942 | mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, | 1942 | mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, |
1943 | SLOT( pasteContacts() ), actionCollection(), | 1943 | SLOT( pasteContacts() ), actionCollection(), |
1944 | "kaddressbook_paste" ); | 1944 | "kaddressbook_paste" ); |
1945 | mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, | 1945 | mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, |
1946 | SLOT( selectAllContacts() ), actionCollection(), | 1946 | SLOT( selectAllContacts() ), actionCollection(), |
1947 | "kaddressbook_select_all" ); | 1947 | "kaddressbook_select_all" ); |
1948 | mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, | 1948 | mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, |
1949 | SLOT( undo() ), actionCollection(), | 1949 | SLOT( undo() ), actionCollection(), |
1950 | "kaddressbook_undo" ); | 1950 | "kaddressbook_undo" ); |
1951 | mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, | 1951 | mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, |
1952 | this, SLOT( redo() ), actionCollection(), | 1952 | this, SLOT( redo() ), actionCollection(), |
1953 | "kaddressbook_redo" ); | 1953 | "kaddressbook_redo" ); |
1954 | } else { | 1954 | } else { |
1955 | mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); | 1955 | mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); |
1956 | mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); | 1956 | mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); |
1957 | mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); | 1957 | mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); |
1958 | mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); | 1958 | mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); |
1959 | mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); | 1959 | mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); |
1960 | mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); | 1960 | mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); |
1961 | } | 1961 | } |
1962 | 1962 | ||
1963 | mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", | 1963 | mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", |
1964 | Key_Delete, this, SLOT( deleteContacts() ), | 1964 | Key_Delete, this, SLOT( deleteContacts() ), |
1965 | actionCollection(), "edit_delete" ); | 1965 | actionCollection(), "edit_delete" ); |
1966 | 1966 | ||
1967 | mActionUndo->setEnabled( false ); | 1967 | mActionUndo->setEnabled( false ); |
1968 | mActionRedo->setEnabled( false ); | 1968 | mActionRedo->setEnabled( false ); |
1969 | 1969 | ||
1970 | // settings menu | 1970 | // settings menu |
1971 | #ifdef KAB_EMBEDDED | 1971 | #ifdef KAB_EMBEDDED |
1972 | //US special menuentry to configure the addressbook resources. On KDE | 1972 | //US special menuentry to configure the addressbook resources. On KDE |
1973 | // you do that through the control center !!! | 1973 | // you do that through the control center !!! |
1974 | mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, | 1974 | mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, |
1975 | SLOT( configureResources() ), actionCollection(), | 1975 | SLOT( configureResources() ), actionCollection(), |
1976 | "kaddressbook_configure_resources" ); | 1976 | "kaddressbook_configure_resources" ); |
1977 | #endif //KAB_EMBEDDED | 1977 | #endif //KAB_EMBEDDED |
1978 | 1978 | ||
1979 | if ( mIsPart ) { | 1979 | if ( mIsPart ) { |
1980 | mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, | 1980 | mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, |
1981 | SLOT( openConfigDialog() ), actionCollection(), | 1981 | SLOT( openConfigDialog() ), actionCollection(), |
1982 | "kaddressbook_configure" ); | 1982 | "kaddressbook_configure" ); |
1983 | 1983 | ||
1984 | //US not implemented yet | 1984 | //US not implemented yet |
1985 | //mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, | 1985 | //mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, |
1986 | // this, SLOT( configureKeyBindings() ), actionCollection(), | 1986 | // this, SLOT( configureKeyBindings() ), actionCollection(), |
1987 | // "kaddressbook_configure_shortcuts" ); | 1987 | // "kaddressbook_configure_shortcuts" ); |
1988 | #ifdef KAB_EMBEDDED | 1988 | #ifdef KAB_EMBEDDED |
1989 | mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); | 1989 | mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); |
1990 | mActionConfigureToolbars->setEnabled( false ); | 1990 | mActionConfigureToolbars->setEnabled( false ); |
1991 | #endif //KAB_EMBEDDED | 1991 | #endif //KAB_EMBEDDED |
1992 | 1992 | ||
1993 | } else { | 1993 | } else { |
1994 | mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); | 1994 | mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); |
1995 | 1995 | ||
1996 | //US not implemented yet | 1996 | //US not implemented yet |
1997 | //mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); | 1997 | //mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); |
1998 | } | 1998 | } |
1999 | 1999 | ||
2000 | mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, | 2000 | mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, |
2001 | actionCollection(), "options_show_jump_bar" ); | 2001 | actionCollection(), "options_show_jump_bar" ); |
2002 | connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); | 2002 | connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); |
2003 | 2003 | ||
2004 | mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, | 2004 | mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, |
2005 | actionCollection(), "options_show_details" ); | 2005 | actionCollection(), "options_show_details" ); |
2006 | connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); | 2006 | connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); |
2007 | 2007 | ||
2008 | 2008 | ||
2009 | mActionBR = new KToggleAction( i18n( "Beam receive enabled" ), "beam", 0, this, | 2009 | mActionBR = new KToggleAction( i18n( "Beam receive enabled" ), "beam", 0, this, |
2010 | SLOT( toggleBeamReceive() ), actionCollection(), | 2010 | SLOT( toggleBeamReceive() ), actionCollection(), |
2011 | "kaddressbook_beam_rec" ); | 2011 | "kaddressbook_beam_rec" ); |
2012 | 2012 | ||
2013 | 2013 | ||
2014 | // misc | 2014 | // misc |
2015 | // only enable LDAP lookup if we can handle the protocol | 2015 | // only enable LDAP lookup if we can handle the protocol |
2016 | #ifndef KAB_EMBEDDED | 2016 | #ifndef KAB_EMBEDDED |
2017 | if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { | 2017 | if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { |
2018 | new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, | 2018 | new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, |
2019 | this, SLOT( openLDAPDialog() ), actionCollection(), | 2019 | this, SLOT( openLDAPDialog() ), actionCollection(), |
2020 | "ldap_lookup" ); | 2020 | "ldap_lookup" ); |
2021 | } | 2021 | } |
2022 | #else //KAB_EMBEDDED | 2022 | #else //KAB_EMBEDDED |
2023 | //qDebug("KABCore::initActions() LDAP has to be implemented"); | 2023 | //qDebug("KABCore::initActions() LDAP has to be implemented"); |
2024 | #endif //KAB_EMBEDDED | 2024 | #endif //KAB_EMBEDDED |
2025 | 2025 | ||
2026 | 2026 | ||
2027 | mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, | 2027 | mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, |
2028 | SLOT( setWhoAmI() ), actionCollection(), | 2028 | SLOT( setWhoAmI() ), actionCollection(), |
2029 | "set_personal" ); | 2029 | "set_personal" ); |
2030 | 2030 | ||
2031 | 2031 | ||
2032 | mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, | 2032 | mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, |
2033 | SLOT( setCategories() ), actionCollection(), | 2033 | SLOT( setCategories() ), actionCollection(), |
2034 | "edit_set_categories" ); | 2034 | "edit_set_categories" ); |
2035 | mActionEditCategories = new KAction( i18n( "Edit Categories" ), 0, this, | 2035 | mActionEditCategories = new KAction( i18n( "Edit Categories" ), 0, this, |
2036 | SLOT( editCategories() ), actionCollection(), | 2036 | SLOT( editCategories() ), actionCollection(), |
2037 | "edit__categories" ); | 2037 | "edit__categories" ); |
2038 | 2038 | ||
2039 | mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, | 2039 | mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, |
2040 | SLOT( removeVoice() ), actionCollection(), | 2040 | SLOT( removeVoice() ), actionCollection(), |
2041 | "remove_voice" ); | 2041 | "remove_voice" ); |
2042 | mActionSetFormattedName = new KAction( i18n( "Set formatted name..." ), 0, this, | 2042 | mActionSetFormattedName = new KAction( i18n( "Set formatted name..." ), 0, this, |
2043 | SLOT( setFormattedName() ), actionCollection(), | 2043 | SLOT( setFormattedName() ), actionCollection(), |
2044 | "set_formatted" ); | 2044 | "set_formatted" ); |
2045 | 2045 | ||
2046 | mActionManageCategories= new KAction( i18n( "Manage new categories..." ), 0, this, | 2046 | mActionManageCategories= new KAction( i18n( "Manage new categories..." ), 0, this, |
2047 | SLOT( manageCategories() ), actionCollection(), | 2047 | SLOT( manageCategories() ), actionCollection(), |
2048 | "remove_voice" ); | 2048 | "remove_voice" ); |
2049 | 2049 | ||
2050 | 2050 | ||
2051 | mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, | 2051 | mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, |
2052 | SLOT( importFromOL() ), actionCollection(), | 2052 | SLOT( importFromOL() ), actionCollection(), |
2053 | "import_OL" ); | 2053 | "import_OL" ); |
2054 | #ifdef KAB_EMBEDDED | 2054 | #ifdef KAB_EMBEDDED |
2055 | mActionLicence = new KAction( i18n( "Licence" ), 0, | 2055 | mActionLicence = new KAction( i18n( "Licence" ), 0, |
2056 | this, SLOT( showLicence() ), actionCollection(), | 2056 | this, SLOT( showLicence() ), actionCollection(), |
2057 | "licence_about_data" ); | 2057 | "licence_about_data" ); |
2058 | mActionFaq = new KAction( i18n( "Faq" ), 0, | 2058 | mActionFaq = new KAction( i18n( "Faq" ), 0, |
2059 | this, SLOT( faq() ), actionCollection(), | 2059 | this, SLOT( faq() ), actionCollection(), |
2060 | "faq_about_data" ); | 2060 | "faq_about_data" ); |
2061 | mActionWN = new KAction( i18n( "What's New?" ), 0, | 2061 | mActionWN = new KAction( i18n( "What's New?" ), 0, |
2062 | this, SLOT( whatsnew() ), actionCollection(), | 2062 | this, SLOT( whatsnew() ), actionCollection(), |
2063 | "wn" ); | 2063 | "wn" ); |
2064 | mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0, | 2064 | mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0, |
2065 | this, SLOT( synchowto() ), actionCollection(), | 2065 | this, SLOT( synchowto() ), actionCollection(), |
2066 | "sync" ); | 2066 | "sync" ); |
2067 | mActionKdeSyncHowto = new KAction( i18n( "Kde Sync HowTo" ), 0, | 2067 | mActionKdeSyncHowto = new KAction( i18n( "Kde Sync HowTo" ), 0, |
2068 | this, SLOT( kdesynchowto() ), actionCollection(), | 2068 | this, SLOT( kdesynchowto() ), actionCollection(), |
2069 | "kdesync" ); | 2069 | "kdesync" ); |
2070 | mActionMultiSyncHowto = new KAction( i18n( "Multi Sync HowTo" ), 0, | 2070 | mActionMultiSyncHowto = new KAction( i18n( "Multi Sync HowTo" ), 0, |
2071 | this, SLOT( multisynchowto() ), actionCollection(), | 2071 | this, SLOT( multisynchowto() ), actionCollection(), |
2072 | "multisync" ); | 2072 | "multisync" ); |
2073 | 2073 | ||
2074 | mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, | 2074 | mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, |
2075 | this, SLOT( createAboutData() ), actionCollection(), | 2075 | this, SLOT( createAboutData() ), actionCollection(), |
2076 | "kaddressbook_about_data" ); | 2076 | "kaddressbook_about_data" ); |
2077 | #endif //KAB_EMBEDDED | 2077 | #endif //KAB_EMBEDDED |
2078 | 2078 | ||
2079 | clipboardDataChanged(); | 2079 | clipboardDataChanged(); |
2080 | connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); | 2080 | connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); |
2081 | connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); | 2081 | connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); |
2082 | } | 2082 | } |
2083 | 2083 | ||
2084 | //US we need this function, to plug all actions into the correct menues. | 2084 | //US we need this function, to plug all actions into the correct menues. |
2085 | // KDE uses a XML format to plug the actions, but we work her without this overhead. | 2085 | // KDE uses a XML format to plug the actions, but we work her without this overhead. |
2086 | void KABCore::addActionsManually() | 2086 | void KABCore::addActionsManually() |
2087 | { | 2087 | { |
2088 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); | 2088 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); |
2089 | 2089 | ||
2090 | #ifdef KAB_EMBEDDED | 2090 | #ifdef KAB_EMBEDDED |
2091 | QPopupMenu *fileMenu = new QPopupMenu( this ); | 2091 | QPopupMenu *fileMenu = new QPopupMenu( this ); |
2092 | QPopupMenu *editMenu = new QPopupMenu( this ); | 2092 | QPopupMenu *editMenu = new QPopupMenu( this ); |
2093 | QPopupMenu *helpMenu = new QPopupMenu( this ); | 2093 | QPopupMenu *helpMenu = new QPopupMenu( this ); |
2094 | 2094 | ||
2095 | KToolBar* tb = mMainWindow->toolBar(); | 2095 | KToolBar* tb = mMainWindow->toolBar(); |
2096 | 2096 | ||
2097 | #ifndef DESKTOP_VERSION | 2097 | #ifndef DESKTOP_VERSION |
2098 | if ( KABPrefs::instance()->mFullMenuBarVisible ) { | 2098 | if ( KABPrefs::instance()->mFullMenuBarVisible ) { |
2099 | #endif | 2099 | #endif |
2100 | QMenuBar* mb = mMainWindow->menuBar(); | 2100 | QMenuBar* mb = mMainWindow->menuBar(); |
2101 | 2101 | ||
2102 | //US setup menubar. | 2102 | //US setup menubar. |
2103 | //Disable the following block if you do not want to have a menubar. | 2103 | //Disable the following block if you do not want to have a menubar. |
2104 | mb->insertItem( i18n("&File"), fileMenu ); | 2104 | mb->insertItem( i18n("&File"), fileMenu ); |
2105 | mb->insertItem( i18n("&Edit"), editMenu ); | 2105 | mb->insertItem( i18n("&Edit"), editMenu ); |
2106 | mb->insertItem( i18n("&View"), viewMenu ); | 2106 | mb->insertItem( i18n("&View"), viewMenu ); |
2107 | mb->insertItem( i18n("&Settings"), settingsMenu ); | 2107 | mb->insertItem( i18n("&Settings"), settingsMenu ); |
2108 | mb->insertItem( i18n("Synchronize"), syncMenu ); | 2108 | mb->insertItem( i18n("Synchronize"), syncMenu ); |
2109 | //mb->insertItem( i18n("&Change"), changeMenu ); | 2109 | //mb->insertItem( i18n("&Change"), changeMenu ); |
2110 | mb->insertItem( i18n("&Help"), helpMenu ); | 2110 | mb->insertItem( i18n("&Help"), helpMenu ); |
2111 | mIncSearchWidget = new IncSearchWidget( tb ); | 2111 | mIncSearchWidget = new IncSearchWidget( tb ); |
2112 | // tb->insertWidget(-1, 0, mIncSearchWidget); | 2112 | // tb->insertWidget(-1, 0, mIncSearchWidget); |
2113 | #ifndef DESKTOP_VERSION | 2113 | #ifndef DESKTOP_VERSION |
2114 | } else { | 2114 | } else { |
2115 | //US setup toolbar | 2115 | //US setup toolbar |
2116 | QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); | 2116 | QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); |
2117 | QPopupMenu *popupBarTB = new QPopupMenu( this ); | 2117 | QPopupMenu *popupBarTB = new QPopupMenu( this ); |
2118 | menuBarTB->insertItem( "ME", popupBarTB); | 2118 | menuBarTB->insertItem( "ME", popupBarTB); |
2119 | tb->insertWidget(-1, 0, menuBarTB); | 2119 | tb->insertWidget(-1, 0, menuBarTB); |
2120 | mIncSearchWidget = new IncSearchWidget( tb ); | 2120 | mIncSearchWidget = new IncSearchWidget( tb ); |
2121 | 2121 | ||
2122 | tb->enableMoving(false); | 2122 | tb->enableMoving(false); |
2123 | popupBarTB->insertItem( i18n("&File"), fileMenu ); | 2123 | popupBarTB->insertItem( i18n("&File"), fileMenu ); |
2124 | popupBarTB->insertItem( i18n("&Edit"), editMenu ); | 2124 | popupBarTB->insertItem( i18n("&Edit"), editMenu ); |
2125 | popupBarTB->insertItem( i18n("&View"), viewMenu ); | 2125 | popupBarTB->insertItem( i18n("&View"), viewMenu ); |
2126 | popupBarTB->insertItem( i18n("&Settings"), settingsMenu ); | 2126 | popupBarTB->insertItem( i18n("&Settings"), settingsMenu ); |
2127 | popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); | 2127 | popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); |
2128 | mViewManager->getFilterAction()->plug ( popupBarTB); | 2128 | mViewManager->getFilterAction()->plug ( popupBarTB); |
2129 | //popupBarTB->insertItem( i18n("&Change selected"), changeMenu ); | 2129 | //popupBarTB->insertItem( i18n("&Change selected"), changeMenu ); |
2130 | popupBarTB->insertItem( i18n("&Help"), helpMenu ); | 2130 | popupBarTB->insertItem( i18n("&Help"), helpMenu ); |
2131 | if (QApplication::desktop()->width() > 320 ) { | 2131 | if (QApplication::desktop()->width() > 320 ) { |
2132 | // mViewManager->getFilterAction()->plug ( tb); | 2132 | // mViewManager->getFilterAction()->plug ( tb); |
2133 | } | 2133 | } |
2134 | } | 2134 | } |
2135 | #endif | 2135 | #endif |
2136 | // mActionQuit->plug ( mMainWindow->toolBar()); | 2136 | // mActionQuit->plug ( mMainWindow->toolBar()); |
2137 | 2137 | ||
2138 | 2138 | ||
2139 | 2139 | ||
2140 | //US Now connect the actions with the menue entries. | 2140 | //US Now connect the actions with the menue entries. |
2141 | #ifdef DESKTOP_VERSION | 2141 | #ifdef DESKTOP_VERSION |
2142 | mActionPrint->plug( fileMenu ); | 2142 | mActionPrint->plug( fileMenu ); |
2143 | mActionPrintDetails->plug( fileMenu ); | 2143 | mActionPrintDetails->plug( fileMenu ); |
2144 | fileMenu->insertSeparator(); | 2144 | fileMenu->insertSeparator(); |
2145 | #endif | 2145 | #endif |
2146 | mActionMail->plug( fileMenu ); | 2146 | mActionMail->plug( fileMenu ); |
2147 | fileMenu->insertSeparator(); | 2147 | fileMenu->insertSeparator(); |
2148 | 2148 | ||
2149 | mActionNewContact->plug( fileMenu ); | 2149 | mActionNewContact->plug( fileMenu ); |
2150 | mActionNewContact->plug( tb ); | 2150 | mActionNewContact->plug( tb ); |
2151 | 2151 | ||
2152 | mActionEditAddressee->plug( fileMenu ); | 2152 | mActionEditAddressee->plug( fileMenu ); |
2153 | // if ((KGlobal::getDesktopSize() > KGlobal::Small ) || | 2153 | // if ((KGlobal::getDesktopSize() > KGlobal::Small ) || |
2154 | // (!KABPrefs::instance()->mMultipleViewsAtOnce )) | 2154 | // (!KABPrefs::instance()->mMultipleViewsAtOnce )) |
2155 | mActionEditAddressee->plug( tb ); | 2155 | mActionEditAddressee->plug( tb ); |
2156 | 2156 | ||
2157 | fileMenu->insertSeparator(); | 2157 | fileMenu->insertSeparator(); |
2158 | mActionSave->plug( fileMenu ); | 2158 | mActionSave->plug( fileMenu ); |
2159 | fileMenu->insertItem( "&Import", ImportMenu ); | 2159 | fileMenu->insertItem( "&Import", ImportMenu ); |
2160 | fileMenu->insertItem( "&Export", ExportMenu ); | 2160 | fileMenu->insertItem( "&Export", ExportMenu ); |
2161 | fileMenu->insertItem( i18n("&Change"), changeMenu ); | 2161 | fileMenu->insertItem( i18n("&Change"), changeMenu ); |
2162 | #ifndef DESKTOP_VERSION | 2162 | #ifndef DESKTOP_VERSION |
2163 | if ( Ir::supported() ) fileMenu->insertItem( i18n("&Beam"), beamMenu ); | 2163 | if ( Ir::supported() ) fileMenu->insertItem( i18n("&Beam"), beamMenu ); |
2164 | #endif | 2164 | #endif |
2165 | #if 0 | 2165 | #if 0 |
2166 | // PENDING fix MailVCard | 2166 | // PENDING fix MailVCard |
2167 | fileMenu->insertSeparator(); | 2167 | fileMenu->insertSeparator(); |
2168 | mActionMailVCard->plug( fileMenu ); | 2168 | mActionMailVCard->plug( fileMenu ); |
2169 | #endif | 2169 | #endif |
2170 | #ifndef DESKTOP_VERSION | 2170 | #ifndef DESKTOP_VERSION |
2171 | if ( Ir::supported() ) mActionBR->plug( beamMenu ); | 2171 | if ( Ir::supported() ) mActionBR->plug( beamMenu ); |
2172 | if ( Ir::supported() ) mActionBeamVCard->plug( beamMenu ); | 2172 | if ( Ir::supported() ) mActionBeamVCard->plug( beamMenu ); |
2173 | if ( Ir::supported() ) mActionBeam->plug( beamMenu ); | 2173 | if ( Ir::supported() ) mActionBeam->plug( beamMenu ); |
2174 | #endif | 2174 | #endif |
2175 | fileMenu->insertSeparator(); | 2175 | fileMenu->insertSeparator(); |
2176 | mActionQuit->plug( fileMenu ); | 2176 | mActionQuit->plug( fileMenu ); |
2177 | #ifdef _WIN32_ | 2177 | #ifdef _WIN32_ |
2178 | mActionImportOL->plug( ImportMenu ); | 2178 | mActionImportOL->plug( ImportMenu ); |
2179 | #endif | 2179 | #endif |
2180 | // edit menu | 2180 | // edit menu |
2181 | mActionUndo->plug( editMenu ); | 2181 | mActionUndo->plug( editMenu ); |
2182 | mActionRedo->plug( editMenu ); | 2182 | mActionRedo->plug( editMenu ); |
2183 | editMenu->insertSeparator(); | 2183 | editMenu->insertSeparator(); |
2184 | mActionCut->plug( editMenu ); | 2184 | mActionCut->plug( editMenu ); |
2185 | mActionCopy->plug( editMenu ); | 2185 | mActionCopy->plug( editMenu ); |
2186 | mActionPaste->plug( editMenu ); | 2186 | mActionPaste->plug( editMenu ); |
2187 | mActionDelete->plug( editMenu ); | 2187 | mActionDelete->plug( editMenu ); |
2188 | editMenu->insertSeparator(); | 2188 | editMenu->insertSeparator(); |
2189 | mActionSelectAll->plug( editMenu ); | 2189 | mActionSelectAll->plug( editMenu ); |
2190 | 2190 | ||
2191 | mActionSetFormattedName->plug( changeMenu ); | 2191 | mActionSetFormattedName->plug( changeMenu ); |
2192 | mActionRemoveVoice->plug( changeMenu ); | 2192 | mActionRemoveVoice->plug( changeMenu ); |
2193 | // settings menu | 2193 | // settings menu |
2194 | //US special menuentry to configure the addressbook resources. On KDE | 2194 | //US special menuentry to configure the addressbook resources. On KDE |
2195 | // you do that through the control center !!! | 2195 | // you do that through the control center !!! |
2196 | mActionConfigResources->plug( settingsMenu ); | 2196 | mActionConfigResources->plug( settingsMenu ); |
2197 | settingsMenu->insertSeparator(); | 2197 | settingsMenu->insertSeparator(); |
2198 | 2198 | ||
2199 | mActionConfigKAddressbook->plug( settingsMenu ); | 2199 | mActionConfigKAddressbook->plug( settingsMenu ); |
2200 | 2200 | ||
2201 | if ( mIsPart ) { | 2201 | if ( mIsPart ) { |
2202 | //US not implemented yet | 2202 | //US not implemented yet |
2203 | //mActionConfigShortcuts->plug( settingsMenu ); | 2203 | //mActionConfigShortcuts->plug( settingsMenu ); |
2204 | //mActionConfigureToolbars->plug( settingsMenu ); | 2204 | //mActionConfigureToolbars->plug( settingsMenu ); |
2205 | 2205 | ||
2206 | } else { | 2206 | } else { |
2207 | //US not implemented yet | 2207 | //US not implemented yet |
2208 | //mActionKeyBindings->plug( settingsMenu ); | 2208 | //mActionKeyBindings->plug( settingsMenu ); |
2209 | } | 2209 | } |
2210 | 2210 | ||
2211 | settingsMenu->insertSeparator(); | 2211 | settingsMenu->insertSeparator(); |
2212 | 2212 | ||
2213 | mActionJumpBar->plug( settingsMenu ); | 2213 | mActionJumpBar->plug( settingsMenu ); |
2214 | mActionDetails->plug( settingsMenu ); | 2214 | mActionDetails->plug( settingsMenu ); |
2215 | //if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) | 2215 | //if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) |
2216 | mActionDetails->plug( tb ); | 2216 | mActionDetails->plug( tb ); |
2217 | settingsMenu->insertSeparator(); | 2217 | settingsMenu->insertSeparator(); |
2218 | #ifndef DESKTOP_VERSION | 2218 | #ifndef DESKTOP_VERSION |
2219 | if ( Ir::supported() ) mActionBR->plug(settingsMenu ); | 2219 | if ( Ir::supported() ) mActionBR->plug(settingsMenu ); |
2220 | #endif | 2220 | #endif |
2221 | settingsMenu->insertSeparator(); | 2221 | settingsMenu->insertSeparator(); |
2222 | 2222 | ||
2223 | mActionWhoAmI->plug( settingsMenu ); | 2223 | mActionWhoAmI->plug( settingsMenu ); |
2224 | mActionEditCategories->plug( settingsMenu ); | 2224 | mActionEditCategories->plug( settingsMenu ); |
2225 | mActionEditCategories->plug( changeMenu ); | 2225 | mActionEditCategories->plug( changeMenu ); |
2226 | mActionCategories->plug( changeMenu ); | 2226 | mActionCategories->plug( changeMenu ); |
2227 | mActionManageCategories->plug( changeMenu ); | 2227 | mActionManageCategories->plug( changeMenu ); |
2228 | 2228 | ||
2229 | mActionCategories->plug( settingsMenu ); | 2229 | mActionCategories->plug( settingsMenu ); |
2230 | mActionManageCategories->plug( settingsMenu ); | 2230 | mActionManageCategories->plug( settingsMenu ); |
2231 | 2231 | ||
2232 | 2232 | ||
2233 | mActionWN->plug( helpMenu ); | 2233 | mActionWN->plug( helpMenu ); |
2234 | mActionSyncHowto->plug( helpMenu ); | 2234 | mActionSyncHowto->plug( helpMenu ); |
2235 | mActionKdeSyncHowto->plug( helpMenu ); | 2235 | mActionKdeSyncHowto->plug( helpMenu ); |
2236 | mActionMultiSyncHowto->plug( helpMenu ); | 2236 | mActionMultiSyncHowto->plug( helpMenu ); |
2237 | mActionFaq->plug( helpMenu ); | 2237 | mActionFaq->plug( helpMenu ); |
2238 | mActionLicence->plug( helpMenu ); | 2238 | mActionLicence->plug( helpMenu ); |
2239 | mActionAboutKAddressbook->plug( helpMenu ); | 2239 | mActionAboutKAddressbook->plug( helpMenu ); |
2240 | 2240 | ||
2241 | if (KGlobal::getDesktopSize() > KGlobal::Small ) { | 2241 | if (KGlobal::getDesktopSize() > KGlobal::Small ) { |
2242 | 2242 | ||
2243 | mActionSave->plug( tb ); | 2243 | mActionSave->plug( tb ); |
2244 | mViewManager->getFilterAction()->plug ( tb); | 2244 | mViewManager->getFilterAction()->plug ( tb); |
2245 | //LR hide filteraction on started in 480x640 | 2245 | //LR hide filteraction on started in 480x640 |
2246 | if (QApplication::desktop()->width() == 480 ) { | 2246 | if (QApplication::desktop()->width() == 480 ) { |
2247 | mViewManager->getFilterAction()->setComboWidth( 0 ); | 2247 | mViewManager->getFilterAction()->setComboWidth( 0 ); |
2248 | } | 2248 | } |
2249 | mActionUndo->plug( tb ); | 2249 | mActionUndo->plug( tb ); |
2250 | mActionDelete->plug( tb ); | 2250 | mActionDelete->plug( tb ); |
2251 | mActionRedo->plug( tb ); | 2251 | mActionRedo->plug( tb ); |
2252 | } else { | 2252 | } else { |
2253 | mActionSave->plug( tb ); | 2253 | mActionSave->plug( tb ); |
2254 | tb->enableMoving(false); | 2254 | tb->enableMoving(false); |
2255 | } | 2255 | } |
2256 | //mActionQuit->plug ( tb ); | 2256 | //mActionQuit->plug ( tb ); |
2257 | // tb->insertWidget(-1, 0, mIncSearchWidget, 6); | 2257 | // tb->insertWidget(-1, 0, mIncSearchWidget, 6); |
2258 | 2258 | ||
2259 | //US link the searchwidget first to this. | 2259 | //US link the searchwidget first to this. |
2260 | // The real linkage to the toolbar happens later. | 2260 | // The real linkage to the toolbar happens later. |
2261 | //US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); | 2261 | //US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); |
2262 | //US tb->insertItem( mIncSearchWidget ); | 2262 | //US tb->insertItem( mIncSearchWidget ); |
2263 | /*US | 2263 | /*US |
2264 | mIncSearchWidget = new IncSearchWidget( tb ); | 2264 | mIncSearchWidget = new IncSearchWidget( tb ); |
2265 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 2265 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
2266 | SLOT( incrementalSearch( const QString& ) ) ); | 2266 | SLOT( incrementalSearch( const QString& ) ) ); |
2267 | 2267 | ||
2268 | mJumpButtonBar = new JumpButtonBar( this, this ); | 2268 | mJumpButtonBar = new JumpButtonBar( this, this ); |
2269 | 2269 | ||
2270 | //US topLayout->addWidget( mJumpButtonBar ); | 2270 | //US topLayout->addWidget( mJumpButtonBar ); |
2271 | this->layout()->add( mJumpButtonBar ); | 2271 | this->layout()->add( mJumpButtonBar ); |
2272 | */ | 2272 | */ |
2273 | 2273 | ||
2274 | #endif //KAB_EMBEDDED | 2274 | #endif //KAB_EMBEDDED |
2275 | 2275 | ||
2276 | mActionExport2phone->plug( ExportMenu ); | 2276 | mActionExport2phone->plug( ExportMenu ); |
2277 | connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); | 2277 | connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); |
2278 | syncManager->fillSyncMenu(); | 2278 | syncManager->fillSyncMenu(); |
2279 | 2279 | ||
2280 | } | 2280 | } |
2281 | void KABCore::showLicence() | 2281 | void KABCore::showLicence() |
2282 | { | 2282 | { |
2283 | KApplication::showLicence(); | 2283 | KApplication::showLicence(); |
2284 | } | 2284 | } |
2285 | 2285 | ||
2286 | void KABCore::manageCategories( ) | 2286 | void KABCore::manageCategories( ) |
2287 | { | 2287 | { |
2288 | KABCatPrefs* cp = new KABCatPrefs(); | 2288 | KABCatPrefs* cp = new KABCatPrefs(); |
2289 | cp->show(); | 2289 | cp->show(); |
2290 | int w =cp->sizeHint().width() ; | 2290 | int w =cp->sizeHint().width() ; |
2291 | int h = cp->sizeHint().height() ; | 2291 | int h = cp->sizeHint().height() ; |
2292 | int dw = QApplication::desktop()->width(); | 2292 | int dw = QApplication::desktop()->width(); |
2293 | int dh = QApplication::desktop()->height(); | 2293 | int dh = QApplication::desktop()->height(); |
2294 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2294 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2295 | if ( !cp->exec() ) { | 2295 | if ( !cp->exec() ) { |
2296 | delete cp; | 2296 | delete cp; |
2297 | return; | 2297 | return; |
2298 | } | 2298 | } |
2299 | int count = 0; | 2299 | int count = 0; |
2300 | int cc = 0; | 2300 | int cc = 0; |
2301 | message( i18n("Please wait, processing categories...")); | 2301 | message( i18n("Please wait, processing categories...")); |
2302 | if ( cp->addCat() ) { | 2302 | if ( cp->addCat() ) { |
2303 | KABC::AddressBook::Iterator it; | 2303 | KABC::AddressBook::Iterator it; |
2304 | QStringList catList = KABPrefs::instance()->mCustomCategories; | 2304 | QStringList catList = KABPrefs::instance()->mCustomCategories; |
2305 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { | 2305 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { |
2306 | ++cc; | 2306 | ++cc; |
2307 | if ( cc %10 == 0) | 2307 | if ( cc %10 == 0) |
2308 | message(i18n("Processing contact #%1").arg(cc)); | 2308 | message(i18n("Processing contact #%1").arg(cc)); |
2309 | QStringList catIncList = (*it).categories(); | 2309 | QStringList catIncList = (*it).categories(); |
2310 | int i; | 2310 | int i; |
2311 | for( i = 0; i< catIncList.count(); ++i ) { | 2311 | for( i = 0; i< catIncList.count(); ++i ) { |
2312 | if ( !catList.contains (catIncList[i])) { | 2312 | if ( !catList.contains (catIncList[i])) { |
2313 | catList.append( catIncList[i] ); | 2313 | catList.append( catIncList[i] ); |
2314 | //qDebug("add cat %s ", catIncList[i].latin1()); | 2314 | //qDebug("add cat %s ", catIncList[i].latin1()); |
2315 | ++count; | 2315 | ++count; |
2316 | } | 2316 | } |
2317 | } | 2317 | } |
2318 | } | 2318 | } |
2319 | catList.sort(); | 2319 | catList.sort(); |
2320 | KABPrefs::instance()->mCustomCategories = catList; | 2320 | KABPrefs::instance()->mCustomCategories = catList; |
2321 | KABPrefs::instance()->writeConfig(); | 2321 | KABPrefs::instance()->writeConfig(); |
2322 | message(QString::number( count )+ i18n(" categories added to list! ")); | 2322 | message(QString::number( count )+ i18n(" categories added to list! ")); |
2323 | } else { | 2323 | } else { |
2324 | QStringList catList = KABPrefs::instance()->mCustomCategories; | 2324 | QStringList catList = KABPrefs::instance()->mCustomCategories; |
2325 | QStringList catIncList; | 2325 | QStringList catIncList; |
2326 | QStringList newCatList; | 2326 | QStringList newCatList; |
2327 | KABC::AddressBook::Iterator it; | 2327 | KABC::AddressBook::Iterator it; |
2328 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { | 2328 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { |
2329 | ++cc; | 2329 | ++cc; |
2330 | if ( cc %10 == 0) | 2330 | if ( cc %10 == 0) |
2331 | message(i18n("Processing contact #%1").arg(cc)); | 2331 | message(i18n("Processing contact #%1").arg(cc)); |
2332 | QStringList catIncList = (*it).categories(); | 2332 | QStringList catIncList = (*it).categories(); |
2333 | int i; | 2333 | int i; |
2334 | if ( catIncList.count() ) { | 2334 | if ( catIncList.count() ) { |
2335 | newCatList.clear(); | 2335 | newCatList.clear(); |
2336 | for( i = 0; i< catIncList.count(); ++i ) { | 2336 | for( i = 0; i< catIncList.count(); ++i ) { |
2337 | if ( catList.contains (catIncList[i])) { | 2337 | if ( catList.contains (catIncList[i])) { |
2338 | newCatList.append( catIncList[i] ); | 2338 | newCatList.append( catIncList[i] ); |
2339 | } | 2339 | } |
2340 | } | 2340 | } |
2341 | newCatList.sort(); | 2341 | newCatList.sort(); |
2342 | (*it).setCategories( newCatList ); | 2342 | (*it).setCategories( newCatList ); |
2343 | mAddressBook->insertAddressee( (*it) ); | 2343 | mAddressBook->insertAddressee( (*it) ); |
2344 | } | 2344 | } |
2345 | } | 2345 | } |
2346 | setModified( true ); | 2346 | setModified( true ); |
2347 | mViewManager->refreshView(); | 2347 | mViewManager->refreshView(); |
2348 | message( i18n("Removing categories done!")); | 2348 | message( i18n("Removing categories done!")); |
2349 | } | 2349 | } |
2350 | delete cp; | 2350 | delete cp; |
2351 | } | 2351 | } |
2352 | void KABCore::removeVoice() | 2352 | void KABCore::removeVoice() |
2353 | { | 2353 | { |
2354 | 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 ) | 2354 | 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 ) |
2355 | return; | 2355 | return; |
2356 | KABC::Addressee::List list; | ||
2357 | XXPortSelectDialog dlg( this, false, this ); | 2356 | XXPortSelectDialog dlg( this, false, this ); |
2358 | if ( dlg.exec() ) | 2357 | if ( !dlg.exec() ) |
2359 | list = dlg.contacts(); | ||
2360 | else | ||
2361 | return; | 2358 | return; |
2362 | KABC::Addressee::List::Iterator it; | 2359 | mAddressBook->setUntagged(); |
2363 | for ( it = list.begin(); it != list.end(); ++it ) { | 2360 | dlg.tagSelected(); |
2364 | if ( (*it).removeVoice() ) | 2361 | message(i18n("Removing voice..."), false ); |
2365 | addrModified((*it), false ); | 2362 | KABC::AddressBook::Iterator it; |
2363 | for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { | ||
2364 | if ( (*it).tagged() ) { | ||
2365 | (*it).removeVoice(); | ||
2366 | } | ||
2366 | } | 2367 | } |
2368 | message(i18n("Refreshing view...") ); | ||
2369 | qApp->processEvents(); | ||
2370 | mViewManager->refreshView( "" ); | ||
2371 | Addressee add; | ||
2372 | mDetails->setAddressee( add ); | ||
2373 | message(i18n("Remove voice completed!") ); | ||
2374 | |||
2375 | |||
2376 | |||
2367 | } | 2377 | } |
2368 | 2378 | ||
2369 | void KABCore::setFormattedName() | 2379 | void KABCore::setFormattedName() |
2370 | { | 2380 | { |
2371 | KABFormatPrefs setpref; | 2381 | KABFormatPrefs setpref; |
2372 | if ( !setpref.exec() ) { | 2382 | if ( !setpref.exec() ) { |
2373 | return; | 2383 | return; |
2374 | } | 2384 | } |
2375 | XXPortSelectDialog dlg( this, false, this ); | 2385 | XXPortSelectDialog dlg( this, false, this ); |
2376 | if ( !dlg.exec() ) | 2386 | if ( !dlg.exec() ) |
2377 | return; | 2387 | return; |
2378 | mAddressBook->setUntagged(); | 2388 | mAddressBook->setUntagged(); |
2379 | dlg.tagSelected(); | 2389 | dlg.tagSelected(); |
2380 | int count = 0; | 2390 | int count = 0; |
2381 | KABC::AddressBook::Iterator it; | 2391 | KABC::AddressBook::Iterator it; |
2382 | for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { | 2392 | for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { |
2383 | if ( (*it).tagged() ) { | 2393 | if ( (*it).tagged() ) { |
2384 | ++count; | 2394 | ++count; |
2385 | if ( count %10 == 0 ) | 2395 | if ( count %10 == 0 ) |
2386 | message(i18n("Changing contact #%1").arg( count ) ); | 2396 | message(i18n("Changing contact #%1").arg( count ) ); |
2387 | qApp->processEvents(); | 2397 | qApp->processEvents(); |
2388 | QString fName; | 2398 | QString fName; |
2389 | if ( setpref.simple->isChecked() ) | 2399 | if ( setpref.simple->isChecked() ) |
2390 | fName = NameEditDialog::formattedName( (*it), NameEditDialog::SimpleName ); | 2400 | fName = NameEditDialog::formattedName( (*it), NameEditDialog::SimpleName ); |
2391 | else if ( setpref.full->isChecked() ) | 2401 | else if ( setpref.full->isChecked() ) |
2392 | fName = NameEditDialog::formattedName( (*it), NameEditDialog::FullName ); | 2402 | fName = NameEditDialog::formattedName( (*it), NameEditDialog::FullName ); |
2393 | else if ( setpref.reverse->isChecked() ) | 2403 | else if ( setpref.reverse->isChecked() ) |
2394 | fName = NameEditDialog::formattedName( (*it), NameEditDialog::ReverseName ); | 2404 | fName = NameEditDialog::formattedName( (*it), NameEditDialog::ReverseName ); |
2395 | else | 2405 | else |
2396 | fName = (*it).organization(); | 2406 | fName = (*it).organization(); |
2397 | if ( setpref.setCompany->isChecked() ) | 2407 | if ( setpref.setCompany->isChecked() ) |
2398 | if ( fName.isEmpty() || fName =="," ) | 2408 | if ( fName.isEmpty() || fName =="," ) |
2399 | fName = (*it).organization(); | 2409 | fName = (*it).organization(); |
2400 | (*it).setFormattedName( fName ); | 2410 | (*it).setFormattedName( fName ); |
2401 | } | 2411 | } |
2402 | } | 2412 | } |
2403 | message(i18n("Refreshing view...") ); | 2413 | message(i18n("Refreshing view...") ); |
2404 | qApp->processEvents(); | 2414 | qApp->processEvents(); |
2405 | mViewManager->refreshView( "" ); | 2415 | mViewManager->refreshView( "" ); |
2406 | Addressee add; | 2416 | Addressee add; |
2407 | mDetails->setAddressee( add ); | 2417 | mDetails->setAddressee( add ); |
2408 | message(i18n("Setting formatted name completed!") ); | 2418 | message(i18n("Setting formatted name completed!") ); |
2409 | } | 2419 | } |
2410 | 2420 | ||
2411 | void KABCore::clipboardDataChanged() | 2421 | void KABCore::clipboardDataChanged() |
2412 | { | 2422 | { |
2413 | 2423 | ||
2414 | if ( mReadWrite ) | 2424 | if ( mReadWrite ) |
2415 | mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); | 2425 | mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); |
2416 | 2426 | ||
2417 | } | 2427 | } |
2418 | 2428 | ||
2419 | void KABCore::updateActionMenu() | 2429 | void KABCore::updateActionMenu() |
2420 | { | 2430 | { |
2421 | UndoStack *undo = UndoStack::instance(); | 2431 | UndoStack *undo = UndoStack::instance(); |
2422 | RedoStack *redo = RedoStack::instance(); | 2432 | RedoStack *redo = RedoStack::instance(); |
2423 | 2433 | ||
2424 | if ( undo->isEmpty() ) | 2434 | if ( undo->isEmpty() ) |
2425 | mActionUndo->setText( i18n( "Undo" ) ); | 2435 | mActionUndo->setText( i18n( "Undo" ) ); |
2426 | else | 2436 | else |
2427 | mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); | 2437 | mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); |
2428 | 2438 | ||
2429 | mActionUndo->setEnabled( !undo->isEmpty() ); | 2439 | mActionUndo->setEnabled( !undo->isEmpty() ); |
2430 | 2440 | ||
2431 | if ( !redo->top() ) | 2441 | if ( !redo->top() ) |
2432 | mActionRedo->setText( i18n( "Redo" ) ); | 2442 | mActionRedo->setText( i18n( "Redo" ) ); |
2433 | else | 2443 | else |
2434 | mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); | 2444 | mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); |
2435 | 2445 | ||
2436 | mActionRedo->setEnabled( !redo->isEmpty() ); | 2446 | mActionRedo->setEnabled( !redo->isEmpty() ); |
2437 | } | 2447 | } |
2438 | 2448 | ||
2439 | void KABCore::configureKeyBindings() | 2449 | void KABCore::configureKeyBindings() |
2440 | { | 2450 | { |
2441 | #ifndef KAB_EMBEDDED | 2451 | #ifndef KAB_EMBEDDED |
2442 | KKeyDialog::configure( actionCollection(), true ); | 2452 | KKeyDialog::configure( actionCollection(), true ); |
2443 | #else //KAB_EMBEDDED | 2453 | #else //KAB_EMBEDDED |
2444 | qDebug("KABCore::configureKeyBindings() not implemented"); | 2454 | qDebug("KABCore::configureKeyBindings() not implemented"); |
2445 | #endif //KAB_EMBEDDED | 2455 | #endif //KAB_EMBEDDED |
2446 | } | 2456 | } |
2447 | 2457 | ||
2448 | #ifdef KAB_EMBEDDED | 2458 | #ifdef KAB_EMBEDDED |
2449 | void KABCore::configureResources() | 2459 | void KABCore::configureResources() |
2450 | { | 2460 | { |
2451 | KRES::KCMKResources dlg( this, "" , 0 ); | 2461 | KRES::KCMKResources dlg( this, "" , 0 ); |
2452 | 2462 | ||
2453 | if ( !dlg.exec() ) | 2463 | if ( !dlg.exec() ) |
2454 | return; | 2464 | return; |
2455 | KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); | 2465 | KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); |
2456 | } | 2466 | } |
2457 | #endif //KAB_EMBEDDED | 2467 | #endif //KAB_EMBEDDED |
2458 | 2468 | ||
2459 | 2469 | ||
2460 | /* this method will be called through the QCop interface from Ko/Pi to select addresses | 2470 | /* this method will be called through the QCop interface from Ko/Pi to select addresses |
2461 | * for the attendees list of an event. | 2471 | * for the attendees list of an event. |
2462 | */ | 2472 | */ |
2463 | void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) | 2473 | void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) |
2464 | { | 2474 | { |
2465 | QStringList nameList; | 2475 | QStringList nameList; |
2466 | QStringList emailList; | 2476 | QStringList emailList; |
2467 | QStringList uidList; | 2477 | QStringList uidList; |
2468 | 2478 | ||
2469 | KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); | 2479 | KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); |
2470 | uint i=0; | 2480 | uint i=0; |
2471 | for (i=0; i < list.count(); i++) | 2481 | for (i=0; i < list.count(); i++) |
2472 | { | 2482 | { |
2473 | nameList.append(list[i].realName()); | 2483 | nameList.append(list[i].realName()); |
2474 | emailList.append(list[i].preferredEmail()); | 2484 | emailList.append(list[i].preferredEmail()); |
2475 | uidList.append(list[i].uid()); | 2485 | uidList.append(list[i].uid()); |
2476 | } | 2486 | } |
2477 | 2487 | ||
2478 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); | 2488 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); |
2479 | 2489 | ||
2480 | } | 2490 | } |
2481 | 2491 | ||
2482 | /* this method will be called through the QCop interface from Ko/Pi to select birthdays | 2492 | /* this method will be called through the QCop interface from Ko/Pi to select birthdays |
2483 | * to put them into the calendar. | 2493 | * to put them into the calendar. |
2484 | */ | 2494 | */ |
2485 | void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid) | 2495 | void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid) |
2486 | { | 2496 | { |
2487 | // qDebug("KABCore::requestForBirthdayList"); | 2497 | // qDebug("KABCore::requestForBirthdayList"); |
2488 | QStringList birthdayList; | 2498 | QStringList birthdayList; |
2489 | QStringList anniversaryList; | 2499 | QStringList anniversaryList; |
2490 | QStringList realNameList; | 2500 | QStringList realNameList; |
2491 | QStringList preferredEmailList; | 2501 | QStringList preferredEmailList; |
2492 | QStringList assembledNameList; | 2502 | QStringList assembledNameList; |
2493 | QStringList uidList; | 2503 | QStringList uidList; |
2494 | 2504 | ||
2495 | KABC::AddressBook::Iterator it; | 2505 | KABC::AddressBook::Iterator it; |
2496 | 2506 | ||
2497 | int count = 0; | 2507 | int count = 0; |
2498 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { | 2508 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { |
2499 | ++count; | 2509 | ++count; |
2500 | } | 2510 | } |
2501 | QProgressBar bar(count,0 ); | 2511 | QProgressBar bar(count,0 ); |
2502 | int w = 300; | 2512 | int w = 300; |
2503 | if ( QApplication::desktop()->width() < 320 ) | 2513 | if ( QApplication::desktop()->width() < 320 ) |
2504 | w = 220; | 2514 | w = 220; |
2505 | int h = bar.sizeHint().height() ; | 2515 | int h = bar.sizeHint().height() ; |
2506 | int dw = QApplication::desktop()->width(); | 2516 | int dw = QApplication::desktop()->width(); |
2507 | int dh = QApplication::desktop()->height(); | 2517 | int dh = QApplication::desktop()->height(); |
2508 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2518 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2509 | bar.show(); | 2519 | bar.show(); |
2510 | bar.setCaption (i18n("Collecting birthdays - close to abort!") ); | 2520 | bar.setCaption (i18n("Collecting birthdays - close to abort!") ); |
2511 | qApp->processEvents(); | 2521 | qApp->processEvents(); |
2512 | 2522 | ||
2513 | QDate bday; | 2523 | QDate bday; |
2514 | QString anni; | 2524 | QString anni; |
2515 | QString formattedbday; | 2525 | QString formattedbday; |
2516 | 2526 | ||
2517 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) | 2527 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) |
2518 | { | 2528 | { |
2519 | if ( ! bar.isVisible() ) | 2529 | if ( ! bar.isVisible() ) |
2520 | return; | 2530 | return; |
2521 | bar.setProgress( count++ ); | 2531 | bar.setProgress( count++ ); |
2522 | qApp->processEvents(); | 2532 | qApp->processEvents(); |
2523 | bday = (*it).birthday().date(); | 2533 | bday = (*it).birthday().date(); |
2524 | anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" ); | 2534 | anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" ); |
2525 | 2535 | ||
2526 | if ( bday.isValid() || !anni.isEmpty()) | 2536 | if ( bday.isValid() || !anni.isEmpty()) |
2527 | { | 2537 | { |
2528 | if (bday.isValid()) | 2538 | if (bday.isValid()) |
2529 | formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate); | 2539 | formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate); |
2530 | else | 2540 | else |
2531 | formattedbday = "NOTVALID"; | 2541 | formattedbday = "NOTVALID"; |
2532 | if (anni.isEmpty()) | 2542 | if (anni.isEmpty()) |
2533 | anni = "INVALID"; | 2543 | anni = "INVALID"; |
2534 | 2544 | ||
2535 | birthdayList.append(formattedbday); | 2545 | birthdayList.append(formattedbday); |
2536 | anniversaryList.append(anni); //should be ISODate | 2546 | anniversaryList.append(anni); //should be ISODate |
2537 | realNameList.append((*it).realName()); | 2547 | realNameList.append((*it).realName()); |
2538 | preferredEmailList.append((*it).preferredEmail()); | 2548 | preferredEmailList.append((*it).preferredEmail()); |
2539 | assembledNameList.append((*it).assembledName()); | 2549 | assembledNameList.append((*it).assembledName()); |
2540 | uidList.append((*it).uid()); | 2550 | uidList.append((*it).uid()); |
2541 | 2551 | ||
2542 | //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() ); | 2552 | //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() ); |
2543 | } | 2553 | } |
2544 | } | 2554 | } |
2545 | 2555 | ||
2546 | bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList); | 2556 | bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList); |
2547 | 2557 | ||
2548 | } | 2558 | } |
2549 | 2559 | ||
2550 | /* this method will be called through the QCop interface from other apps to show details of a contact. | 2560 | /* this method will be called through the QCop interface from other apps to show details of a contact. |
2551 | */ | 2561 | */ |
2552 | void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) | 2562 | void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) |
2553 | { | 2563 | { |
2554 | //qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); | 2564 | //qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); |
2555 | 2565 | ||
2556 | QString foundUid = QString::null; | 2566 | QString foundUid = QString::null; |
2557 | if ( ! uid.isEmpty() ) { | 2567 | if ( ! uid.isEmpty() ) { |
2558 | Addressee adrr = mAddressBook->findByUid( uid ); | 2568 | Addressee adrr = mAddressBook->findByUid( uid ); |
2559 | if ( !adrr.isEmpty() ) { | 2569 | if ( !adrr.isEmpty() ) { |
2560 | foundUid = uid; | 2570 | foundUid = uid; |
2561 | } | 2571 | } |
2562 | if ( email == "sendbacklist" ) { | 2572 | if ( email == "sendbacklist" ) { |
2563 | //qDebug("ssssssssssssssssssssssend "); | 2573 | //qDebug("ssssssssssssssssssssssend "); |
2564 | QStringList nameList; | 2574 | QStringList nameList; |
2565 | QStringList emailList; | 2575 | QStringList emailList; |
2566 | QStringList uidList; | 2576 | QStringList uidList; |
2567 | nameList.append(adrr.realName()); | 2577 | nameList.append(adrr.realName()); |
2568 | emailList = adrr.emails(); | 2578 | emailList = adrr.emails(); |
2569 | uidList.append( adrr.preferredEmail()); | 2579 | uidList.append( adrr.preferredEmail()); |
2570 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); | 2580 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); |
2571 | return; | 2581 | return; |
2572 | } | 2582 | } |
2573 | 2583 | ||
2574 | } | 2584 | } |
2575 | 2585 | ||
2576 | if ( email == "sendbacklist" ) | 2586 | if ( email == "sendbacklist" ) |
2577 | return; | 2587 | return; |
2578 | if (foundUid.isEmpty()) | 2588 | if (foundUid.isEmpty()) |
2579 | { | 2589 | { |
2580 | //find the uid of the person first | 2590 | //find the uid of the person first |
2581 | Addressee::List namelist; | 2591 | Addressee::List namelist; |
2582 | Addressee::List emaillist; | 2592 | Addressee::List emaillist; |
2583 | 2593 | ||
2584 | if (!name.isEmpty()) | 2594 | if (!name.isEmpty()) |
2585 | namelist = mAddressBook->findByName( name ); | 2595 | namelist = mAddressBook->findByName( name ); |
2586 | 2596 | ||
2587 | if (!email.isEmpty()) | 2597 | if (!email.isEmpty()) |
2588 | emaillist = mAddressBook->findByEmail( email ); | 2598 | emaillist = mAddressBook->findByEmail( email ); |
2589 | //qDebug("count %d %d ", namelist.count(),emaillist.count() ); | 2599 | //qDebug("count %d %d ", namelist.count(),emaillist.count() ); |
2590 | //check if we have a match in Namelist and Emaillist | 2600 | //check if we have a match in Namelist and Emaillist |
2591 | if ((namelist.count() == 0) && (emaillist.count() > 0)) { | 2601 | if ((namelist.count() == 0) && (emaillist.count() > 0)) { |
2592 | foundUid = emaillist[0].uid(); | 2602 | foundUid = emaillist[0].uid(); |
2593 | } | 2603 | } |
2594 | else if ((namelist.count() > 0) && (emaillist.count() == 0)) | 2604 | else if ((namelist.count() > 0) && (emaillist.count() == 0)) |
2595 | foundUid = namelist[0].uid(); | 2605 | foundUid = namelist[0].uid(); |
2596 | else | 2606 | else |
2597 | { | 2607 | { |
2598 | for (int i = 0; i < namelist.count(); i++) | 2608 | for (int i = 0; i < namelist.count(); i++) |
2599 | { | 2609 | { |
2600 | for (int j = 0; j < emaillist.count(); j++) | 2610 | for (int j = 0; j < emaillist.count(); j++) |
2601 | { | 2611 | { |
2602 | if (namelist[i] == emaillist[j]) | 2612 | if (namelist[i] == emaillist[j]) |
2603 | { | 2613 | { |
2604 | foundUid = namelist[i].uid(); | 2614 | foundUid = namelist[i].uid(); |
2605 | } | 2615 | } |
2606 | } | 2616 | } |
2607 | } | 2617 | } |
2608 | } | 2618 | } |
2609 | } | 2619 | } |
2610 | else | 2620 | else |
2611 | { | 2621 | { |
2612 | foundUid = uid; | 2622 | foundUid = uid; |
2613 | } | 2623 | } |
2614 | 2624 | ||
2615 | if (!foundUid.isEmpty()) | 2625 | if (!foundUid.isEmpty()) |
2616 | { | 2626 | { |
2617 | 2627 | ||
2618 | // raise Ka/Pi if it is in the background | 2628 | // raise Ka/Pi if it is in the background |
2619 | #ifndef DESKTOP_VERSION | 2629 | #ifndef DESKTOP_VERSION |
2620 | #ifndef KORG_NODCOP | 2630 | #ifndef KORG_NODCOP |
2621 | //QCopEnvelope e("QPE/Application/kapi", "raise()"); | 2631 | //QCopEnvelope e("QPE/Application/kapi", "raise()"); |
2622 | #endif | 2632 | #endif |
2623 | #endif | 2633 | #endif |
2624 | 2634 | ||
2625 | mMainWindow->showMaximized(); | 2635 | mMainWindow->showMaximized(); |
2626 | mMainWindow-> raise(); | 2636 | mMainWindow-> raise(); |
2627 | 2637 | ||
2628 | mViewManager->setSelected( "", false); | 2638 | mViewManager->setSelected( "", false); |
2629 | mViewManager->refreshView( "" ); | 2639 | mViewManager->refreshView( "" ); |
2630 | mViewManager->setSelected( foundUid, true ); | 2640 | mViewManager->setSelected( foundUid, true ); |
2631 | mViewManager->refreshView( foundUid ); | 2641 | mViewManager->refreshView( foundUid ); |
2632 | 2642 | ||
2633 | if ( !mMultipleViewsAtOnce ) | 2643 | if ( !mMultipleViewsAtOnce ) |
2634 | { | 2644 | { |
2635 | setDetailsVisible( true ); | 2645 | setDetailsVisible( true ); |
2636 | mActionDetails->setChecked(true); | 2646 | mActionDetails->setChecked(true); |
2637 | } | 2647 | } |
2638 | } | 2648 | } |
2639 | } | 2649 | } |
2640 | 2650 | ||
2641 | void KABCore::whatsnew() | 2651 | void KABCore::whatsnew() |
2642 | { | 2652 | { |
2643 | KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); | 2653 | KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); |
2644 | } | 2654 | } |
2645 | void KABCore::synchowto() | 2655 | void KABCore::synchowto() |
2646 | { | 2656 | { |
2647 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); | 2657 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); |
2648 | } | 2658 | } |
2649 | void KABCore::kdesynchowto() | 2659 | void KABCore::kdesynchowto() |
2650 | { | 2660 | { |
2651 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" ); | 2661 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" ); |
2652 | } | 2662 | } |
2653 | void KABCore::multisynchowto() | 2663 | void KABCore::multisynchowto() |
2654 | { | 2664 | { |
2655 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" ); | 2665 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" ); |
2656 | } | 2666 | } |
2657 | void KABCore::faq() | 2667 | void KABCore::faq() |
2658 | { | 2668 | { |
2659 | KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); | 2669 | KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); |
2660 | } | 2670 | } |
2661 | 2671 | ||
2662 | #include <libkcal/syncdefines.h> | 2672 | #include <libkcal/syncdefines.h> |
2663 | 2673 | ||
2664 | KABC::Addressee KABCore::getLastSyncAddressee() | 2674 | KABC::Addressee KABCore::getLastSyncAddressee() |
2665 | { | 2675 | { |
2666 | Addressee lse; | 2676 | Addressee lse; |
2667 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2677 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2668 | 2678 | ||
2669 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 2679 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
2670 | lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); | 2680 | lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); |
2671 | if (lse.isEmpty()) { | 2681 | if (lse.isEmpty()) { |
2672 | qDebug("Creating new last-syncAddressee "); | 2682 | qDebug("Creating new last-syncAddressee "); |
2673 | lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); | 2683 | lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); |
2674 | QString sum = ""; | 2684 | QString sum = ""; |
2675 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 2685 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
2676 | sum = "E: "; | 2686 | sum = "E: "; |
2677 | lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); | 2687 | lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); |
2678 | lse.setRevision( mLastAddressbookSync ); | 2688 | lse.setRevision( mLastAddressbookSync ); |
2679 | lse.setCategories( i18n("SyncEvent") ); | 2689 | lse.setCategories( i18n("SyncEvent") ); |
2680 | mAddressBook->insertAddressee( lse ); | 2690 | mAddressBook->insertAddressee( lse ); |
2681 | } | 2691 | } |
2682 | return lse; | 2692 | return lse; |
2683 | } | 2693 | } |
2684 | int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) | 2694 | int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) |
2685 | { | 2695 | { |
2686 | 2696 | ||
2687 | //void setZaurusId(int id); | 2697 | //void setZaurusId(int id); |
2688 | // int zaurusId() const; | 2698 | // int zaurusId() const; |
2689 | // void setZaurusUid(int id); | 2699 | // void setZaurusUid(int id); |
2690 | // int zaurusUid() const; | 2700 | // int zaurusUid() const; |
2691 | // void setZaurusStat(int id); | 2701 | // void setZaurusStat(int id); |
2692 | // int zaurusStat() const; | 2702 | // int zaurusStat() const; |
2693 | // 0 equal | 2703 | // 0 equal |
2694 | // 1 take local | 2704 | // 1 take local |
2695 | // 2 take remote | 2705 | // 2 take remote |
2696 | // 3 cancel | 2706 | // 3 cancel |
2697 | QDateTime lastSync = mLastAddressbookSync; | 2707 | QDateTime lastSync = mLastAddressbookSync; |
2698 | QDateTime localMod = local->revision(); | 2708 | QDateTime localMod = local->revision(); |
2699 | QDateTime remoteMod = remote->revision(); | 2709 | QDateTime remoteMod = remote->revision(); |
2700 | 2710 | ||
2701 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2711 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2702 | 2712 | ||
2703 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2713 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2704 | bool remCh, locCh; | 2714 | bool remCh, locCh; |
2705 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 2715 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
2706 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 2716 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); |
2707 | locCh = ( localMod > mLastAddressbookSync ); | 2717 | locCh = ( localMod > mLastAddressbookSync ); |
2708 | //qDebug("cahnged rem %d loc %d",remCh, locCh ); | 2718 | //qDebug("cahnged rem %d loc %d",remCh, locCh ); |
2709 | if ( !remCh && ! locCh ) { | 2719 | if ( !remCh && ! locCh ) { |
2710 | //qDebug("both not changed "); | 2720 | //qDebug("both not changed "); |
2711 | lastSync = localMod.addDays(1); | 2721 | lastSync = localMod.addDays(1); |
2712 | if ( mode <= SYNC_PREF_ASK ) | 2722 | if ( mode <= SYNC_PREF_ASK ) |
2713 | return 0; | 2723 | return 0; |
2714 | } else { | 2724 | } else { |
2715 | if ( locCh ) { | 2725 | if ( locCh ) { |
2716 | //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); | 2726 | //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); |
2717 | lastSync = localMod.addDays( -1 ); | 2727 | lastSync = localMod.addDays( -1 ); |
2718 | if ( !remCh ) | 2728 | if ( !remCh ) |
2719 | remoteMod =( lastSync.addDays( -1 ) ); | 2729 | remoteMod =( lastSync.addDays( -1 ) ); |
2720 | } else { | 2730 | } else { |
2721 | //qDebug(" not loc changed "); | 2731 | //qDebug(" not loc changed "); |
2722 | lastSync = localMod.addDays( 1 ); | 2732 | lastSync = localMod.addDays( 1 ); |
2723 | if ( remCh ) { | 2733 | if ( remCh ) { |
2724 | //qDebug("rem changed "); | 2734 | //qDebug("rem changed "); |
2725 | remoteMod =( lastSync.addDays( 1 ) ); | 2735 | remoteMod =( lastSync.addDays( 1 ) ); |
2726 | } | 2736 | } |
2727 | 2737 | ||
2728 | } | 2738 | } |
2729 | } | 2739 | } |
2730 | full = true; | 2740 | full = true; |
2731 | if ( mode < SYNC_PREF_ASK ) | 2741 | if ( mode < SYNC_PREF_ASK ) |
2732 | mode = SYNC_PREF_ASK; | 2742 | mode = SYNC_PREF_ASK; |
2733 | } else { | 2743 | } else { |
2734 | if ( localMod == remoteMod ) | 2744 | if ( localMod == remoteMod ) |
2735 | return 0; | 2745 | return 0; |
2736 | 2746 | ||
2737 | } | 2747 | } |
2738 | //qDebug("%s %s --- %d %d", localMod.toString().latin1() , remoteMod.toString().latin1(), localMod.time().msec(), remoteMod.time().msec()); | 2748 | //qDebug("%s %s --- %d %d", localMod.toString().latin1() , remoteMod.toString().latin1(), localMod.time().msec(), remoteMod.time().msec()); |
2739 | //qDebug("lastsync %s ", lastSync.toString().latin1() ); | 2749 | //qDebug("lastsync %s ", lastSync.toString().latin1() ); |
2740 | //full = true; //debug only | 2750 | //full = true; //debug only |
2741 | if ( full ) { | 2751 | if ( full ) { |
2742 | bool equ = ( (*local) == (*remote) ); | 2752 | bool equ = ( (*local) == (*remote) ); |
2743 | if ( equ ) { | 2753 | if ( equ ) { |
2744 | //qDebug("equal "); | 2754 | //qDebug("equal "); |
2745 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2755 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2746 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 2756 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
2747 | } | 2757 | } |
2748 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 2758 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
2749 | return 0; | 2759 | return 0; |
2750 | 2760 | ||
2751 | }//else //debug only | 2761 | }//else //debug only |
2752 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 2762 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
2753 | } | 2763 | } |
2754 | int result; | 2764 | int result; |
2755 | bool localIsNew; | 2765 | bool localIsNew; |
2756 | //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() ); | 2766 | //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() ); |
2757 | 2767 | ||
2758 | if ( full && mode < SYNC_PREF_NEWEST ) | 2768 | if ( full && mode < SYNC_PREF_NEWEST ) |
2759 | mode = SYNC_PREF_ASK; | 2769 | mode = SYNC_PREF_ASK; |
2760 | 2770 | ||
2761 | switch( mode ) { | 2771 | switch( mode ) { |
2762 | case SYNC_PREF_LOCAL: | 2772 | case SYNC_PREF_LOCAL: |
2763 | if ( lastSync > remoteMod ) | 2773 | if ( lastSync > remoteMod ) |
2764 | return 1; | 2774 | return 1; |
2765 | if ( lastSync > localMod ) | 2775 | if ( lastSync > localMod ) |
2766 | return 2; | 2776 | return 2; |
2767 | return 1; | 2777 | return 1; |
2768 | break; | 2778 | break; |
2769 | case SYNC_PREF_REMOTE: | 2779 | case SYNC_PREF_REMOTE: |
2770 | if ( lastSync > remoteMod ) | 2780 | if ( lastSync > remoteMod ) |
2771 | return 1; | 2781 | return 1; |
2772 | if ( lastSync > localMod ) | 2782 | if ( lastSync > localMod ) |
2773 | return 2; | 2783 | return 2; |
2774 | return 2; | 2784 | return 2; |
2775 | break; | 2785 | break; |
2776 | case SYNC_PREF_NEWEST: | 2786 | case SYNC_PREF_NEWEST: |
2777 | if ( localMod > remoteMod ) | 2787 | if ( localMod > remoteMod ) |
2778 | return 1; | 2788 | return 1; |
2779 | else | 2789 | else |
2780 | return 2; | 2790 | return 2; |
2781 | break; | 2791 | break; |
2782 | case SYNC_PREF_ASK: | 2792 | case SYNC_PREF_ASK: |
2783 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 2793 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
2784 | if ( lastSync > remoteMod ) | 2794 | if ( lastSync > remoteMod ) |
2785 | return 1; | 2795 | return 1; |
2786 | if ( lastSync > localMod ) { | 2796 | if ( lastSync > localMod ) { |
2787 | return 2; | 2797 | return 2; |
2788 | } | 2798 | } |
2789 | localIsNew = localMod >= remoteMod; | 2799 | localIsNew = localMod >= remoteMod; |
2790 | //qDebug("conflict! ************************************** "); | 2800 | //qDebug("conflict! ************************************** "); |
2791 | { | 2801 | { |
2792 | KABC::AddresseeChooser acd ( *local,*remote, localIsNew , this ); | 2802 | KABC::AddresseeChooser acd ( *local,*remote, localIsNew , this ); |
2793 | result = acd.executeD(localIsNew); | 2803 | result = acd.executeD(localIsNew); |
2794 | return result; | 2804 | return result; |
2795 | } | 2805 | } |
2796 | break; | 2806 | break; |
2797 | case SYNC_PREF_FORCE_LOCAL: | 2807 | case SYNC_PREF_FORCE_LOCAL: |
2798 | return 1; | 2808 | return 1; |
2799 | break; | 2809 | break; |
2800 | case SYNC_PREF_FORCE_REMOTE: | 2810 | case SYNC_PREF_FORCE_REMOTE: |
2801 | return 2; | 2811 | return 2; |
2802 | break; | 2812 | break; |
2803 | 2813 | ||
2804 | default: | 2814 | default: |
2805 | // SYNC_PREF_TAKE_BOTH not implemented | 2815 | // SYNC_PREF_TAKE_BOTH not implemented |
2806 | break; | 2816 | break; |
2807 | } | 2817 | } |
2808 | return 0; | 2818 | return 0; |
2809 | } | 2819 | } |
2810 | 2820 | ||
2811 | 2821 | ||
2812 | bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) | 2822 | bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) |
2813 | { | 2823 | { |
2814 | bool syncOK = true; | 2824 | bool syncOK = true; |
2815 | int addedAddressee = 0; | 2825 | int addedAddressee = 0; |
2816 | int addedAddresseeR = 0; | 2826 | int addedAddresseeR = 0; |
2817 | int deletedAddresseeR = 0; | 2827 | int deletedAddresseeR = 0; |
2818 | int deletedAddresseeL = 0; | 2828 | int deletedAddresseeL = 0; |
2819 | int changedLocal = 0; | 2829 | int changedLocal = 0; |
2820 | int changedRemote = 0; | 2830 | int changedRemote = 0; |
2821 | int filteredIN = 0; | 2831 | int filteredIN = 0; |
2822 | int filteredOUT = 0; | 2832 | int filteredOUT = 0; |
2823 | 2833 | ||
2824 | QString mCurrentSyncName = syncManager->getCurrentSyncName(); | 2834 | QString mCurrentSyncName = syncManager->getCurrentSyncName(); |
2825 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2835 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2826 | 2836 | ||
2827 | //QPtrList<Addressee> el = local->rawAddressees(); | 2837 | //QPtrList<Addressee> el = local->rawAddressees(); |
2828 | Addressee addresseeR; | 2838 | Addressee addresseeR; |
2829 | QString uid; | 2839 | QString uid; |
2830 | int take; | 2840 | int take; |
2831 | Addressee addresseeL; | 2841 | Addressee addresseeL; |
2832 | Addressee addresseeRSync; | 2842 | Addressee addresseeRSync; |
2833 | Addressee addresseeLSync; | 2843 | Addressee addresseeLSync; |
2834 | // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); | 2844 | // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); |
2835 | //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); | 2845 | //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); |
2836 | bool fullDateRange = false; | 2846 | bool fullDateRange = false; |
2837 | local->resetTempSyncStat(); | 2847 | local->resetTempSyncStat(); |
2838 | mLastAddressbookSync = QDateTime::currentDateTime(); | 2848 | mLastAddressbookSync = QDateTime::currentDateTime(); |
2839 | if ( syncManager->syncWithDesktop() ) { | 2849 | if ( syncManager->syncWithDesktop() ) { |
2840 | // remote->removeSyncInfo( QString());//remove all info | 2850 | // remote->removeSyncInfo( QString());//remove all info |
2841 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { | 2851 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { |
2842 | mLastAddressbookSync = KSyncManager::mRequestedSyncEvent; | 2852 | mLastAddressbookSync = KSyncManager::mRequestedSyncEvent; |
2843 | qDebug("using extern time for calendar sync: %s ", mLastAddressbookSync.toString().latin1() ); | 2853 | qDebug("using extern time for calendar sync: %s ", mLastAddressbookSync.toString().latin1() ); |
2844 | } else { | 2854 | } else { |
2845 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); | 2855 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); |
2846 | } | 2856 | } |
2847 | } | 2857 | } |
2848 | QDateTime modifiedCalendar = mLastAddressbookSync; | 2858 | QDateTime modifiedCalendar = mLastAddressbookSync; |
2849 | addresseeLSync = getLastSyncAddressee(); | 2859 | addresseeLSync = getLastSyncAddressee(); |
2850 | qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); | 2860 | qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); |
2851 | addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); | 2861 | addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); |
2852 | if ( !addresseeR.isEmpty() ) { | 2862 | if ( !addresseeR.isEmpty() ) { |
2853 | addresseeRSync = addresseeR; | 2863 | addresseeRSync = addresseeR; |
2854 | remote->removeAddressee(addresseeR ); | 2864 | remote->removeAddressee(addresseeR ); |
2855 | 2865 | ||
2856 | } else { | 2866 | } else { |
2857 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2867 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2858 | addresseeRSync = addresseeLSync ; | 2868 | addresseeRSync = addresseeLSync ; |
2859 | } else { | 2869 | } else { |
2860 | //qDebug("FULLDATE 1"); | 2870 | //qDebug("FULLDATE 1"); |
2861 | fullDateRange = true; | 2871 | fullDateRange = true; |
2862 | Addressee newAdd; | 2872 | Addressee newAdd; |
2863 | addresseeRSync = newAdd; | 2873 | addresseeRSync = newAdd; |
2864 | addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); | 2874 | addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); |
2865 | addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); | 2875 | addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); |
2866 | addresseeRSync.setRevision( mLastAddressbookSync ); | 2876 | addresseeRSync.setRevision( mLastAddressbookSync ); |
2867 | addresseeRSync.setCategories( i18n("SyncAddressee") ); | 2877 | addresseeRSync.setCategories( i18n("SyncAddressee") ); |
2868 | } | 2878 | } |
2869 | } | 2879 | } |
2870 | if ( addresseeLSync.revision() == mLastAddressbookSync ) { | 2880 | if ( addresseeLSync.revision() == mLastAddressbookSync ) { |
2871 | // qDebug("FULLDATE 2"); | 2881 | // qDebug("FULLDATE 2"); |
2872 | fullDateRange = true; | 2882 | fullDateRange = true; |
2873 | } | 2883 | } |
2874 | if ( ! fullDateRange ) { | 2884 | if ( ! fullDateRange ) { |
2875 | if ( addresseeLSync.revision() != addresseeRSync.revision() ) { | 2885 | if ( addresseeLSync.revision() != addresseeRSync.revision() ) { |
2876 | 2886 | ||
2877 | // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); | 2887 | // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); |
2878 | //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); | 2888 | //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); |
2879 | fullDateRange = true; | 2889 | fullDateRange = true; |
2880 | //qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); | 2890 | //qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); |
2881 | } | 2891 | } |
2882 | } | 2892 | } |
2883 | // fullDateRange = true; // debug only! | 2893 | // fullDateRange = true; // debug only! |
2884 | if ( fullDateRange ) | 2894 | if ( fullDateRange ) |
2885 | mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); | 2895 | mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); |
2886 | else | 2896 | else |
2887 | mLastAddressbookSync = addresseeLSync.revision(); | 2897 | mLastAddressbookSync = addresseeLSync.revision(); |
2888 | // for resyncing if own file has changed | 2898 | // for resyncing if own file has changed |
2889 | // PENDING fixme later when implemented | 2899 | // PENDING fixme later when implemented |
2890 | #if 0 | 2900 | #if 0 |
2891 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 2901 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
2892 | mLastAddressbookSync = loadedFileVersion; | 2902 | mLastAddressbookSync = loadedFileVersion; |
2893 | qDebug("setting mLastAddressbookSync "); | 2903 | qDebug("setting mLastAddressbookSync "); |
2894 | } | 2904 | } |
2895 | #endif | 2905 | #endif |
2896 | 2906 | ||
2897 | 2907 | ||
2898 | // ********** setting filters **************** | 2908 | // ********** setting filters **************** |
2899 | Filter filterIN = mViewManager->getFilterByName( syncManager->mFilterInAB ); | 2909 | Filter filterIN = mViewManager->getFilterByName( syncManager->mFilterInAB ); |
2900 | Filter filterOUT = mViewManager->getFilterByName( syncManager->mFilterOutAB ); | 2910 | Filter filterOUT = mViewManager->getFilterByName( syncManager->mFilterOutAB ); |
2901 | 2911 | ||
2902 | //qDebug("*************************** "); | 2912 | //qDebug("*************************** "); |
2903 | // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); | 2913 | // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); |
2904 | QStringList er = remote->uidList(); | 2914 | QStringList er = remote->uidList(); |
2905 | Addressee inR ;//= er.first(); | 2915 | Addressee inR ;//= er.first(); |
2906 | Addressee inL; | 2916 | Addressee inL; |
2907 | 2917 | ||
2908 | syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); | 2918 | syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); |
2909 | 2919 | ||
2910 | int modulo = (er.count()/10)+1; | 2920 | int modulo = (er.count()/10)+1; |
2911 | int incCounter = 0; | 2921 | int incCounter = 0; |
2912 | while ( incCounter < er.count()) { | 2922 | while ( incCounter < er.count()) { |
2913 | if (syncManager->isProgressBarCanceled()) | 2923 | if (syncManager->isProgressBarCanceled()) |
2914 | return false; | 2924 | return false; |
2915 | if ( incCounter % modulo == 0 ) | 2925 | if ( incCounter % modulo == 0 ) |
2916 | syncManager->showProgressBar(incCounter); | 2926 | syncManager->showProgressBar(incCounter); |
2917 | 2927 | ||
2918 | uid = er[ incCounter ]; | 2928 | uid = er[ incCounter ]; |
2919 | bool skipIncidence = false; | 2929 | bool skipIncidence = false; |
2920 | if ( uid.left(19) == QString("last-syncAddressee-") ) | 2930 | if ( uid.left(19) == QString("last-syncAddressee-") ) |
2921 | skipIncidence = true; | 2931 | skipIncidence = true; |
2922 | QString idS,OidS; | 2932 | QString idS,OidS; |
2923 | qApp->processEvents(); | 2933 | qApp->processEvents(); |
2924 | if ( !skipIncidence ) { | 2934 | if ( !skipIncidence ) { |
2925 | inL = local->findByUid( uid ); | 2935 | inL = local->findByUid( uid ); |
2926 | inR = remote->findByUid( uid ); | 2936 | inR = remote->findByUid( uid ); |
2927 | //inL.setResource( 0 ); | 2937 | //inL.setResource( 0 ); |
2928 | //inR.setResource( 0 ); | 2938 | //inR.setResource( 0 ); |
2929 | if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars | 2939 | if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars |
2930 | if ( !inL.resource() || inL.resource()->includeInSync() ) { | 2940 | if ( !inL.resource() || inL.resource()->includeInSync() ) { |
2931 | if ( (take = takeAddressee( &inL, &inR, mode, fullDateRange )) ) { | 2941 | if ( (take = takeAddressee( &inL, &inR, mode, fullDateRange )) ) { |
2932 | //qDebug("take %d %s ", take, inL.summary().latin1()); | 2942 | //qDebug("take %d %s ", take, inL.summary().latin1()); |
2933 | if ( take == 3 ) | 2943 | if ( take == 3 ) |
2934 | return false; | 2944 | return false; |
2935 | if ( take == 1 ) {// take local ********************** | 2945 | if ( take == 1 ) {// take local ********************** |
2936 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2946 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2937 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); | 2947 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); |
2938 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); | 2948 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); |
2939 | local->insertAddressee( inL, false ); | 2949 | local->insertAddressee( inL, false ); |
2940 | idS = inR.externalUID(); | 2950 | idS = inR.externalUID(); |
2941 | OidS = inR.originalExternalUID(); | 2951 | OidS = inR.originalExternalUID(); |
2942 | } | 2952 | } |
2943 | else | 2953 | else |
2944 | idS = inR.IDStr(); | 2954 | idS = inR.IDStr(); |
2945 | remote->removeAddressee( inR ); | 2955 | remote->removeAddressee( inR ); |
2946 | inR = inL; | 2956 | inR = inL; |
2947 | inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 2957 | inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
2948 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2958 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2949 | inR.setOriginalExternalUID( OidS ); | 2959 | inR.setOriginalExternalUID( OidS ); |
2950 | inR.setExternalUID( idS ); | 2960 | inR.setExternalUID( idS ); |
2951 | if ( syncManager->syncWithDesktop() ) { | 2961 | if ( syncManager->syncWithDesktop() ) { |
2952 | inR.setIDStr("changed" ); | 2962 | inR.setIDStr("changed" ); |
2953 | } | 2963 | } |
2954 | //inR.insertCustom( "KADDRESSBOOK", "X-KDESYNC","changed" ); | 2964 | //inR.insertCustom( "KADDRESSBOOK", "X-KDESYNC","changed" ); |
2955 | } else { | 2965 | } else { |
2956 | inR.setIDStr( idS ); | 2966 | inR.setIDStr( idS ); |
2957 | } | 2967 | } |
2958 | inR.setResource( 0 ); | 2968 | inR.setResource( 0 ); |
2959 | remote->insertAddressee( inR , false); | 2969 | remote->insertAddressee( inR , false); |
2960 | ++changedRemote; | 2970 | ++changedRemote; |
2961 | } else { // take == 2 take remote ********************** | 2971 | } else { // take == 2 take remote ********************** |
2962 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2972 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2963 | if ( inR.revision().date().year() < 2004 ) | 2973 | if ( inR.revision().date().year() < 2004 ) |
2964 | inR.setRevision( modifiedCalendar ); | 2974 | inR.setRevision( modifiedCalendar ); |
2965 | } | 2975 | } |
2966 | idS = inL.IDStr(); | 2976 | idS = inL.IDStr(); |
2967 | local->removeAddressee( inL ); | 2977 | local->removeAddressee( inL ); |
2968 | inL = inR; | 2978 | inL = inR; |
2969 | inL.setIDStr( idS ); | 2979 | inL.setIDStr( idS ); |
2970 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2980 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2971 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); | 2981 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); |
2972 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); | 2982 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); |
2973 | } | 2983 | } |
2974 | inL.setResource( 0 ); | 2984 | inL.setResource( 0 ); |
2975 | local->insertAddressee( inL , false ); | 2985 | local->insertAddressee( inL , false ); |
2976 | ++changedLocal; | 2986 | ++changedLocal; |
2977 | } | 2987 | } |
2978 | } | 2988 | } |
2979 | } | 2989 | } |
2980 | } else { // no conflict ********** add or delete remote | 2990 | } else { // no conflict ********** add or delete remote |
2981 | if ( filterIN.name().isEmpty() || filterIN.filterAddressee( inR ) ) { | 2991 | if ( filterIN.name().isEmpty() || filterIN.filterAddressee( inR ) ) { |
2982 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2992 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2983 | QString des = addresseeLSync.note(); | 2993 | QString des = addresseeLSync.note(); |
2984 | if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 2994 | if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
2985 | inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 2995 | inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
2986 | remote->insertAddressee( inR, false ); | 2996 | remote->insertAddressee( inR, false ); |
2987 | ++deletedAddresseeR; | 2997 | ++deletedAddresseeR; |
2988 | } else { | 2998 | } else { |
2989 | inR.setRevision( modifiedCalendar ); | 2999 | inR.setRevision( modifiedCalendar ); |
2990 | remote->insertAddressee( inR, false ); | 3000 | remote->insertAddressee( inR, false ); |
2991 | inL = inR; | 3001 | inL = inR; |
2992 | inL.setIDStr( ":" ); | 3002 | inL.setIDStr( ":" ); |
2993 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); | 3003 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); |
2994 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); | 3004 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); |
2995 | inL.setResource( 0 ); | 3005 | inL.setResource( 0 ); |
2996 | local->insertAddressee( inL , false); | 3006 | local->insertAddressee( inL , false); |
2997 | ++addedAddressee; | 3007 | ++addedAddressee; |
2998 | } | 3008 | } |
2999 | } else { | 3009 | } else { |
3000 | if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { | 3010 | if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { |
3001 | inR.setRevision( modifiedCalendar ); | 3011 | inR.setRevision( modifiedCalendar ); |
3002 | remote->insertAddressee( inR, false ); | 3012 | remote->insertAddressee( inR, false ); |
3003 | inR.setResource( 0 ); | 3013 | inR.setResource( 0 ); |
3004 | local->insertAddressee( inR, false ); | 3014 | local->insertAddressee( inR, false ); |
3005 | ++addedAddressee; | 3015 | ++addedAddressee; |
3006 | } else { | 3016 | } else { |
3007 | // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); | 3017 | // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); |
3008 | remote->removeAddressee( inR ); | 3018 | remote->removeAddressee( inR ); |
3009 | ++deletedAddresseeR; | 3019 | ++deletedAddresseeR; |
3010 | } | 3020 | } |
3011 | } | 3021 | } |
3012 | } else { | 3022 | } else { |
3013 | ++filteredIN; | 3023 | ++filteredIN; |
3014 | } | 3024 | } |
3015 | } | 3025 | } |
3016 | } | 3026 | } |
3017 | ++incCounter; | 3027 | ++incCounter; |
3018 | } | 3028 | } |
3019 | er.clear(); | 3029 | er.clear(); |
3020 | QStringList el = local->uidList(); | 3030 | QStringList el = local->uidList(); |
3021 | modulo = (el.count()/10)+1; | 3031 | modulo = (el.count()/10)+1; |
3022 | 3032 | ||
3023 | syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); | 3033 | syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); |
3024 | incCounter = 0; | 3034 | incCounter = 0; |
3025 | while ( incCounter < el.count()) { | 3035 | while ( incCounter < el.count()) { |
3026 | qApp->processEvents(); | 3036 | qApp->processEvents(); |
3027 | if (syncManager->isProgressBarCanceled()) | 3037 | if (syncManager->isProgressBarCanceled()) |
3028 | return false; | 3038 | return false; |
3029 | if ( incCounter % modulo == 0 ) | 3039 | if ( incCounter % modulo == 0 ) |
3030 | syncManager->showProgressBar(incCounter); | 3040 | syncManager->showProgressBar(incCounter); |
3031 | uid = el[ incCounter ]; | 3041 | uid = el[ incCounter ]; |
3032 | bool skipIncidence = false; | 3042 | bool skipIncidence = false; |
3033 | if ( uid.left(19) == QString("last-syncAddressee-") ) | 3043 | if ( uid.left(19) == QString("last-syncAddressee-") ) |
3034 | skipIncidence = true; | 3044 | skipIncidence = true; |
3035 | if ( !skipIncidence ) { | 3045 | if ( !skipIncidence ) { |
3036 | inL = local->findByUid( uid ); | 3046 | inL = local->findByUid( uid ); |
3037 | if ( !inL.resource() || inL.resource()->includeInSync() ) { | 3047 | if ( !inL.resource() || inL.resource()->includeInSync() ) { |
3038 | inR = remote->findByUid( uid ); | 3048 | inR = remote->findByUid( uid ); |
3039 | if ( inR.isEmpty() ){ | 3049 | if ( inR.isEmpty() ){ |
3040 | if ( filterOUT.name().isEmpty() || filterOUT.filterAddressee( inL ) ) { | 3050 | if ( filterOUT.name().isEmpty() || filterOUT.filterAddressee( inL ) ) { |
3041 | // no conflict ********** add or delete local | 3051 | // no conflict ********** add or delete local |
3042 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 3052 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
3043 | if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 3053 | if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
3044 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); | 3054 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); |
3045 | local->removeAddressee( inL ); | 3055 | local->removeAddressee( inL ); |
3046 | ++deletedAddresseeL; | 3056 | ++deletedAddresseeL; |
3047 | } else { | 3057 | } else { |
3048 | if ( ! syncManager->mWriteBackExistingOnly ) { | 3058 | if ( ! syncManager->mWriteBackExistingOnly ) { |
3049 | inL.removeID(mCurrentSyncDevice ); | 3059 | inL.removeID(mCurrentSyncDevice ); |
3050 | ++addedAddresseeR; | 3060 | ++addedAddresseeR; |
3051 | inL.setRevision( modifiedCalendar ); | 3061 | inL.setRevision( modifiedCalendar ); |
3052 | local->insertAddressee( inL, false ); | 3062 | local->insertAddressee( inL, false ); |
3053 | inR = inL; | 3063 | inR = inL; |
3054 | inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); | 3064 | inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); |
3055 | inR.setResource( 0 ); | 3065 | inR.setResource( 0 ); |
3056 | remote->insertAddressee( inR, false ); | 3066 | remote->insertAddressee( inR, false ); |
3057 | } | 3067 | } |
3058 | } | 3068 | } |
3059 | } else { | 3069 | } else { |
3060 | if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { | 3070 | if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { |
3061 | //qDebug("data %s ", inL.revision().toString().latin1()); | 3071 | //qDebug("data %s ", inL.revision().toString().latin1()); |
3062 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); | 3072 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); |
3063 | local->removeAddressee( inL ); | 3073 | local->removeAddressee( inL ); |
3064 | ++deletedAddresseeL; | 3074 | ++deletedAddresseeL; |
3065 | } else { | 3075 | } else { |
3066 | if ( ! syncManager->mWriteBackExistingOnly ) { | 3076 | if ( ! syncManager->mWriteBackExistingOnly ) { |
3067 | ++addedAddresseeR; | 3077 | ++addedAddresseeR; |
3068 | inL.setRevision( modifiedCalendar ); | 3078 | inL.setRevision( modifiedCalendar ); |
3069 | local->insertAddressee( inL, false ); | 3079 | local->insertAddressee( inL, false ); |
3070 | inR = inL; | 3080 | inR = inL; |
3071 | inR.setIDStr( ":" ); | 3081 | inR.setIDStr( ":" ); |
3072 | inR.setResource( 0 ); | 3082 | inR.setResource( 0 ); |
3073 | remote->insertAddressee( inR, false ); | 3083 | remote->insertAddressee( inR, false ); |
3074 | } | 3084 | } |
3075 | } | 3085 | } |
3076 | } | 3086 | } |
3077 | } else { | 3087 | } else { |
3078 | ++filteredOUT; | 3088 | ++filteredOUT; |
3079 | } | 3089 | } |
3080 | } | 3090 | } |
3081 | } | 3091 | } |
3082 | } | 3092 | } |
3083 | ++incCounter; | 3093 | ++incCounter; |
3084 | } | 3094 | } |
3085 | el.clear(); | 3095 | el.clear(); |
3086 | syncManager->hideProgressBar(); | 3096 | syncManager->hideProgressBar(); |
3087 | mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); | 3097 | mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); |
3088 | // get rid of micro seconds | 3098 | // get rid of micro seconds |
3089 | QTime t = mLastAddressbookSync.time(); | 3099 | QTime t = mLastAddressbookSync.time(); |
3090 | mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); | 3100 | mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); |
3091 | addresseeLSync.setRevision( mLastAddressbookSync ); | 3101 | addresseeLSync.setRevision( mLastAddressbookSync ); |
3092 | addresseeRSync.setRevision( mLastAddressbookSync ); | 3102 | addresseeRSync.setRevision( mLastAddressbookSync ); |
3093 | addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; | 3103 | addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; |
3094 | addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); | 3104 | addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); |
3095 | addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; | 3105 | addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; |
3096 | addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); | 3106 | addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); |
3097 | addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; | 3107 | addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; |
3098 | addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); | 3108 | addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); |
3099 | addresseeRSync.setNote( "" ) ; | 3109 | addresseeRSync.setNote( "" ) ; |
3100 | addresseeLSync.setNote( "" ); | 3110 | addresseeLSync.setNote( "" ); |
3101 | 3111 | ||
3102 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) | 3112 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) |
3103 | remote->insertAddressee( addresseeRSync, false ); | 3113 | remote->insertAddressee( addresseeRSync, false ); |
3104 | local->insertAddressee( addresseeLSync, false ); | 3114 | local->insertAddressee( addresseeLSync, false ); |
3105 | QString mes; | 3115 | QString mes; |
3106 | 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 %d incoming filtered out\n %d outgoing filtered out"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR, filteredIN, filteredOUT ); | 3116 | 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 %d incoming filtered out\n %d outgoing filtered out"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR, filteredIN, filteredOUT ); |
3107 | qDebug( mes ); | 3117 | qDebug( mes ); |
3108 | mes = i18n("Local addressbook changed!\n") +mes; | 3118 | mes = i18n("Local addressbook changed!\n") +mes; |
3109 | if ( syncManager->mShowSyncSummary ) { | 3119 | if ( syncManager->mShowSyncSummary ) { |
3110 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, | 3120 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, |
3111 | i18n("KA/Pi Synchronization"),i18n("Write back"))) { | 3121 | i18n("KA/Pi Synchronization"),i18n("Write back"))) { |
3112 | qDebug("cancelled "); | 3122 | qDebug("cancelled "); |
3113 | return false; | 3123 | return false; |
3114 | } | 3124 | } |
3115 | } | 3125 | } |
3116 | return syncOK; | 3126 | return syncOK; |
3117 | } | 3127 | } |
3118 | 3128 | ||
3119 | 3129 | ||
3120 | //this is a overwritten callbackmethods from the syncinterface | 3130 | //this is a overwritten callbackmethods from the syncinterface |
3121 | bool KABCore::sync(KSyncManager* manager, QString filename, int mode) | 3131 | bool KABCore::sync(KSyncManager* manager, QString filename, int mode) |
3122 | { | 3132 | { |
3123 | 3133 | ||
3124 | //pending prepare addresseeview for output | 3134 | //pending prepare addresseeview for output |
3125 | //pending detect, if remote file has REV field. if not switch to external sync | 3135 | //pending detect, if remote file has REV field. if not switch to external sync |
3126 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 3136 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
3127 | if ( manager != syncManager ) | 3137 | if ( manager != syncManager ) |
3128 | qDebug("KABCore::sync:: ERROR! :: manager != syncManager "); | 3138 | qDebug("KABCore::sync:: ERROR! :: manager != syncManager "); |
3129 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); | 3139 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); |
3130 | 3140 | ||
3131 | AddressBook abLocal(filename,"syncContact"); | 3141 | AddressBook abLocal(filename,"syncContact"); |
3132 | bool syncOK = false; | 3142 | bool syncOK = false; |
3133 | if ( abLocal.load() ) { | 3143 | if ( abLocal.load() ) { |
3134 | qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); | 3144 | qDebug("Sync:AB loaded %s,sync mode %d",filename.latin1(), mode ); |
3135 | bool external = false; | 3145 | bool external = false; |
3136 | bool isXML = false; | 3146 | bool isXML = false; |
3137 | if ( filename.right(4) == ".xml") { | 3147 | if ( filename.right(4) == ".xml") { |
3138 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 3148 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
3139 | isXML = true; | 3149 | isXML = true; |
3140 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); | 3150 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); |
3141 | } else { | 3151 | } else { |
3142 | external = !manager->mIsKapiFile; | 3152 | external = !manager->mIsKapiFile; |
3143 | if ( external ) { | 3153 | if ( external ) { |
3144 | qDebug("Setting vcf mode to external "); | 3154 | qDebug("Sync:Setting vcf mode to external "); |
3145 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 3155 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
3146 | AddressBook::Iterator it; | 3156 | AddressBook::Iterator it; |
3147 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 3157 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
3148 | (*it).setID( mCurrentSyncDevice, (*it).uid() ); | 3158 | (*it).setID( mCurrentSyncDevice, (*it).uid() ); |
3149 | (*it).computeCsum( mCurrentSyncDevice ); | 3159 | (*it).computeCsum( mCurrentSyncDevice ); |
3150 | } | 3160 | } |
3151 | } | 3161 | } |
3152 | } | 3162 | } |
3153 | //AddressBook::Iterator it; | 3163 | //AddressBook::Iterator it; |
3154 | //QStringList vcards; | 3164 | //QStringList vcards; |
3155 | //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 3165 | //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
3156 | // qDebug("Name %s ", (*it).familyName().latin1()); | 3166 | // qDebug("Name %s ", (*it).familyName().latin1()); |
3157 | //} | 3167 | //} |
3158 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); | 3168 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); |
3159 | if ( syncOK ) { | 3169 | if ( syncOK ) { |
3160 | if ( syncManager->mWriteBackFile ) | 3170 | if ( syncManager->mWriteBackFile ) |
3161 | { | 3171 | { |
3162 | if ( external ) | 3172 | if ( external ) |
3163 | abLocal.removeSyncAddressees( !isXML); | 3173 | abLocal.removeSyncAddressees( !isXML); |
3164 | qDebug("Saving remote AB "); | 3174 | qDebug("Sync:Saving remote AB "); |
3165 | if ( ! abLocal.saveAB()) | 3175 | if ( ! abLocal.saveAB()) |
3166 | qDebug("Error writing back AB to file "); | 3176 | qDebug("Error writing back AB to file "); |
3167 | if ( external ) { | 3177 | if ( external ) { |
3168 | // afterwrite processing | 3178 | // afterwrite processing |
3169 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML); | 3179 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML); |
3170 | } | 3180 | } |
3171 | } | 3181 | } |
3172 | } | 3182 | } |
3173 | setModified(); | 3183 | setModified(); |
3174 | 3184 | ||
3175 | } | 3185 | } |
3176 | abLocal.removeResources(); | 3186 | abLocal.removeResources(); |
3177 | if ( syncOK ) | 3187 | if ( syncOK ) |
3178 | mViewManager->refreshView(); | 3188 | mViewManager->refreshView(); |
3179 | return syncOK; | 3189 | return syncOK; |
3180 | 3190 | ||
3181 | } | 3191 | } |
3182 | void KABCore::removeSyncInfo( QString syncProfile) | 3192 | void KABCore::removeSyncInfo( QString syncProfile) |
3183 | { | 3193 | { |
3184 | qDebug("AB:removeSyncInfo for profile %s ", syncProfile.latin1()); | 3194 | qDebug("AB:removeSyncInfo for profile %s ", syncProfile.latin1()); |
3185 | mAddressBook->removeSyncInfo( syncProfile ); | 3195 | mAddressBook->removeSyncInfo( syncProfile ); |
3186 | setModified(); | 3196 | setModified(); |
3187 | } | 3197 | } |
3188 | 3198 | ||
3189 | 3199 | ||
3190 | //this is a overwritten callbackmethods from the syncinterface | 3200 | //this is a overwritten callbackmethods from the syncinterface |
3191 | bool KABCore::syncExternal(KSyncManager* manager, QString resource) | 3201 | bool KABCore::syncExternal(KSyncManager* manager, QString resource) |
3192 | { | 3202 | { |
3193 | if ( resource == "phone" ) | 3203 | if ( resource == "phone" ) |
3194 | return syncPhone(); | 3204 | return syncPhone(); |
3195 | disableBR( true ); | 3205 | disableBR( true ); |
3196 | if ( manager != syncManager ) | 3206 | if ( manager != syncManager ) |
3197 | qDebug("KABCore::syncExternal:: ERROR! :: manager != syncManager "); | 3207 | qDebug("KABCore::syncExternal:: ERROR! :: manager != syncManager "); |
3198 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); | 3208 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); |
3199 | 3209 | ||
3200 | AddressBook abLocal( resource,"syncContact"); | 3210 | AddressBook abLocal( resource,"syncContact"); |
3201 | bool syncOK = false; | 3211 | bool syncOK = false; |
3202 | message(i18n("Loading DTM address data..."), false); | 3212 | message(i18n("Loading DTM address data..."), false); |
3203 | if ( abLocal.load() ) { | 3213 | if ( abLocal.load() ) { |
3204 | qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); | 3214 | qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); |
3205 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 3215 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
3206 | message(i18n("Sync preprocessing..."),false); | 3216 | message(i18n("Sync preprocessing..."),false); |
3207 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false ); | 3217 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false ); |
3208 | message(i18n("Synchronizing..."),false); | 3218 | message(i18n("Synchronizing..."),false); |
3209 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); | 3219 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); |
3210 | if ( syncOK ) { | 3220 | if ( syncOK ) { |
3211 | if ( syncManager->mWriteBackFile ) { | 3221 | if ( syncManager->mWriteBackFile ) { |
3212 | abLocal.removeSyncAddressees( false ); | 3222 | abLocal.removeSyncAddressees( false ); |
3213 | message(i18n("Saving DTM address data..."),false); | 3223 | message(i18n("Saving DTM address data..."),false); |
3214 | abLocal.saveAB(); | 3224 | abLocal.saveAB(); |
3215 | message(i18n("Sync postprocessing..."),false); | 3225 | message(i18n("Sync postprocessing..."),false); |
3216 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); | 3226 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); |
3217 | } | 3227 | } |
3218 | } else | 3228 | } else |
3219 | message( i18n("Sync cancelled or failed.") ); | 3229 | message( i18n("Sync cancelled or failed.") ); |
3220 | setModified(); | 3230 | setModified(); |
3221 | } | 3231 | } |
3222 | abLocal.removeResources(); | 3232 | abLocal.removeResources(); |
3223 | if ( syncOK ) { | 3233 | if ( syncOK ) { |
3224 | mViewManager->refreshView(); | 3234 | mViewManager->refreshView(); |
3225 | message(i18n("DTM syncing finished.")); | 3235 | message(i18n("DTM syncing finished.")); |
3226 | } | 3236 | } |
3227 | disableBR( false ); | 3237 | disableBR( false ); |
3228 | return syncOK; | 3238 | return syncOK; |
3229 | 3239 | ||
3230 | } | 3240 | } |
3231 | void KABCore::message( QString m, bool startTimer) | 3241 | void KABCore::message( QString m, bool startTimer) |
3232 | { | 3242 | { |
3233 | topLevelWidget()->setCaption( m ); | 3243 | topLevelWidget()->setCaption( m ); |
3234 | qApp->processEvents(); | 3244 | qApp->processEvents(); |
3235 | if ( startTimer ) | 3245 | if ( startTimer ) |
3236 | mMessageTimer->start( 15000, true ); | 3246 | mMessageTimer->start( 15000, true ); |
3237 | else | 3247 | else |
3238 | mMessageTimer->stop(); | 3248 | mMessageTimer->stop(); |
3239 | } | 3249 | } |
3240 | bool KABCore::syncPhone() | 3250 | bool KABCore::syncPhone() |
3241 | { | 3251 | { |
3242 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 3252 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
3243 | QString fileName = getPhoneFile(); | 3253 | QString fileName = getPhoneFile(); |
3244 | if ( !PhoneAccess::readFromPhone( fileName) ) { | 3254 | if ( !PhoneAccess::readFromPhone( fileName) ) { |
3245 | message(i18n("Phone access failed!")); | 3255 | message(i18n("Phone access failed!")); |
3246 | return false; | 3256 | return false; |
3247 | } | 3257 | } |
3248 | AddressBook abLocal( fileName,"syncContact"); | 3258 | AddressBook abLocal( fileName,"syncContact"); |
3249 | bool syncOK = false; | 3259 | bool syncOK = false; |
3250 | { | 3260 | { |
3251 | abLocal.importFromFile( fileName ); | 3261 | abLocal.importFromFile( fileName ); |
3252 | qDebug("AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1()); | 3262 | qDebug("AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1()); |
3253 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 3263 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
3254 | abLocal.preparePhoneSync( mCurrentSyncDevice, true ); | 3264 | abLocal.preparePhoneSync( mCurrentSyncDevice, true ); |
3255 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); | 3265 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); |
3256 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); | 3266 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); |
3257 | if ( syncOK ) { | 3267 | if ( syncOK ) { |
3258 | if ( syncManager->mWriteBackFile ) { | 3268 | if ( syncManager->mWriteBackFile ) { |
3259 | abLocal.removeSyncAddressees( true ); | 3269 | abLocal.removeSyncAddressees( true ); |
3260 | abLocal.saveABphone( fileName ); | 3270 | abLocal.saveABphone( fileName ); |
3261 | abLocal.findNewExtIds( fileName, mCurrentSyncDevice ); | 3271 | abLocal.findNewExtIds( fileName, mCurrentSyncDevice ); |
3262 | //abLocal.preparePhoneSync( mCurrentSyncDevice, false ); | 3272 | //abLocal.preparePhoneSync( mCurrentSyncDevice, false ); |
3263 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); | 3273 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); |
3264 | } | 3274 | } |
3265 | } | 3275 | } |
3266 | setModified(); | 3276 | setModified(); |
3267 | } | 3277 | } |
3268 | abLocal.removeResources(); | 3278 | abLocal.removeResources(); |
3269 | if ( syncOK ) | 3279 | if ( syncOK ) |
3270 | mViewManager->refreshView(); | 3280 | mViewManager->refreshView(); |
3271 | return syncOK; | 3281 | return syncOK; |
3272 | } | 3282 | } |
3273 | void KABCore::getFile( bool success ) | 3283 | void KABCore::getFile( bool success ) |
3274 | { | 3284 | { |
3275 | if ( ! success ) { | 3285 | if ( ! success ) { |
3276 | message( i18n("Error receiving file. Nothing changed!") ); | 3286 | message( i18n("Error receiving file. Nothing changed!") ); |
3277 | return; | 3287 | return; |
3278 | } | 3288 | } |
3279 | int count = mAddressBook->importFromFile( sentSyncFile() , false, true ); | 3289 | int count = mAddressBook->importFromFile( sentSyncFile() , false, true ); |
3280 | if ( count ) | 3290 | if ( count ) |
3281 | setModified( true ); | 3291 | setModified( true ); |
3282 | message( i18n("Pi-Sync successful!") ); | 3292 | message( i18n("Pi-Sync successful!") ); |
3283 | mViewManager->refreshView(); | 3293 | mViewManager->refreshView(); |
3284 | } | 3294 | } |
3285 | void KABCore::syncFileRequest() | 3295 | void KABCore::syncFileRequest() |
3286 | { | 3296 | { |
3287 | if ( KABPrefs::instance()->mPassiveSyncWithDesktop ) { | 3297 | if ( KABPrefs::instance()->mPassiveSyncWithDesktop ) { |
3288 | syncManager->slotSyncMenu( 999 ); | 3298 | syncManager->slotSyncMenu( 999 ); |
3289 | } | 3299 | } |
3290 | mAddressBook->export2File( sentSyncFile() ); | 3300 | mAddressBook->export2File( sentSyncFile() ); |
3291 | } | 3301 | } |
3292 | QString KABCore::sentSyncFile() | 3302 | QString KABCore::sentSyncFile() |
3293 | { | 3303 | { |
3294 | #ifdef DESKTOP_VERSION | 3304 | #ifdef DESKTOP_VERSION |
3295 | return locateLocal( "tmp", "copysyncab.vcf" ); | 3305 | return locateLocal( "tmp", "copysyncab.vcf" ); |
3296 | #else | 3306 | #else |
3297 | return QString( "/tmp/copysyncab.vcf" ); | 3307 | return QString( "/tmp/copysyncab.vcf" ); |
3298 | #endif | 3308 | #endif |
3299 | } | 3309 | } |
3300 | 3310 | ||
3301 | void KABCore::setCaptionBack() | 3311 | void KABCore::setCaptionBack() |
3302 | { | 3312 | { |
3303 | mMessageTimer->stop(); | 3313 | mMessageTimer->stop(); |
3304 | topLevelWidget()->setCaption( i18n("KAddressbook/Pi") ); | 3314 | topLevelWidget()->setCaption( i18n("KAddressbook/Pi") ); |
3305 | } | 3315 | } |