-rw-r--r-- | kabc/addressee.cpp | 31 | ||||
-rw-r--r-- | kaddressbook/imagewidget.cpp | 5 | ||||
-rw-r--r-- | kaddressbook/kabcore.cpp | 7 | ||||
-rw-r--r-- | kaddressbook/views/kaddressbooktableview.cpp | 2 |
4 files changed, 38 insertions, 7 deletions
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp index bfcfab5..18b4d58 100644 --- a/kabc/addressee.cpp +++ b/kabc/addressee.cpp | |||
@@ -7,466 +7,491 @@ | |||
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 | //qDebug("csum: %d %d %d", i,k,cSum); | ||
199 | } | 200 | } |
200 | } | 201 | } |
201 | 202 | ||
202 | } | 203 | } |
203 | //QString dump = attList.join(","); | 204 | //QString dump = attList.join(","); |
204 | //qDebug("csum: %d %s", cSum,dump.latin1()); | 205 | //qDebug("csum: %d %s", cSum,dump.latin1()); |
205 | 206 | ||
206 | return cSum; | 207 | return cSum; |
207 | 208 | ||
208 | } | 209 | } |
209 | void Addressee::computeCsum(const QString &dev) | 210 | void Addressee::computeCsum(const QString &dev) |
210 | { | 211 | { |
211 | QStringList l; | 212 | QStringList l; |
212 | //if ( !mData->name.isEmpty() ) l.append(mData->name); | 213 | //if ( !mData->name.isEmpty() ) l.append(mData->name); |
213 | //if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName ); | 214 | //if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName ); |
214 | if ( !mData->familyName.isEmpty() ) l.append( mData->familyName ); | 215 | if ( !mData->familyName.isEmpty() ) l.append( mData->familyName ); |
215 | if ( !mData->givenName.isEmpty() ) l.append(mData->givenName ); | 216 | if ( !mData->givenName.isEmpty() ) l.append(mData->givenName ); |
216 | if ( !mData->additionalName.isEmpty() ) l.append( mData->additionalName ); | 217 | if ( !mData->additionalName.isEmpty() ) l.append( mData->additionalName ); |
217 | if ( !mData->prefix.isEmpty() ) l.append( mData->prefix ); | 218 | if ( !mData->prefix.isEmpty() ) l.append( mData->prefix ); |
218 | if ( !mData->suffix.isEmpty() ) l.append( mData->suffix ); | 219 | if ( !mData->suffix.isEmpty() ) l.append( mData->suffix ); |
219 | if ( !mData->nickName.isEmpty() ) l.append( mData->nickName ); | 220 | if ( !mData->nickName.isEmpty() ) l.append( mData->nickName ); |
220 | if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() ); | 221 | if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() ); |
221 | if ( !mData->mailer.isEmpty() ) l.append( mData->mailer ); | 222 | if ( !mData->mailer.isEmpty() ) l.append( mData->mailer ); |
222 | if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() ); | 223 | if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() ); |
223 | if ( mData->geo.isValid() ) l.append( mData->geo.asString() ); | 224 | if ( mData->geo.isValid() ) l.append( mData->geo.asString() ); |
224 | if ( !mData->title .isEmpty() ) l.append( mData->title ); | 225 | if ( !mData->title .isEmpty() ) l.append( mData->title ); |
225 | if ( !mData->role.isEmpty() ) l.append( mData->role ); | 226 | if ( !mData->role.isEmpty() ) l.append( mData->role ); |
226 | if ( !mData->organization.isEmpty() ) l.append( mData->organization ); | 227 | if ( !mData->organization.isEmpty() ) l.append( mData->organization ); |
227 | if ( !mData->note.isEmpty() ) l.append( mData->note ); | 228 | if ( !mData->note.isEmpty() ) l.append( mData->note ); |
228 | if ( !mData->productId.isEmpty() ) l.append(mData->productId ); | 229 | if ( !mData->productId.isEmpty() ) l.append(mData->productId ); |
229 | if ( !mData->sortString.isEmpty() ) l.append( mData->sortString ); | 230 | if ( !mData->sortString.isEmpty() ) l.append( mData->sortString ); |
230 | if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString()); | 231 | if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString()); |
231 | // if ( !mData->logo.isEmpty() ) l.append( ); | 232 | if ( !mData->logo.undefined() ) { |
232 | //if ( !mData->photo.isEmpty() ) l.append( ); | 233 | if ( !mData->logo.isIntern() ) |
233 | //if ( !mData->sound.isEmpty() ) l.append( ); | 234 | l.append( mData->logo.url() ); |
235 | else | ||
236 | l.append( QString::number(mData->logo.data().width()* mData->logo.data().height())); | ||
237 | } else { | ||
238 | l.append( "nologo"); | ||
239 | } | ||
240 | if ( !mData->photo.undefined() ) { | ||
241 | if ( !mData->photo.isIntern() ) | ||
242 | l.append( mData->photo.url() ); | ||
243 | else | ||
244 | l.append( QString::number(mData->photo.data().width()* mData->photo.data().height())); | ||
245 | } else { | ||
246 | l.append( "nophoto"); | ||
247 | } | ||
248 | #if 0 | ||
249 | if ( !mData->sound.undefined() ) { | ||
250 | if ( !mData->sound.isIntern() ) | ||
251 | l.append( mData->sound.url() ); | ||
252 | else | ||
253 | l.append( QString(mData->sound.data().with()* mData->sound.data().height())); | ||
254 | } else { | ||
255 | l.append( "nosound"); | ||
256 | } | ||
257 | #endif | ||
234 | //if ( !mData->agent.isEmpty() ) l.append( ); | 258 | //if ( !mData->agent.isEmpty() ) l.append( ); |
235 | if ( mData->url.isValid() ) | 259 | if ( mData->url.isValid() ) |
236 | if ( ! mData->url.path().isEmpty()) l.append( mData->url.path() ); | 260 | if ( ! mData->url.path().isEmpty()) l.append( mData->url.path() ); |
237 | KABC::PhoneNumber::List phoneNumbers; | 261 | KABC::PhoneNumber::List phoneNumbers; |
238 | KABC::PhoneNumber::List::Iterator phoneIter; | 262 | KABC::PhoneNumber::List::Iterator phoneIter; |
239 | 263 | ||
240 | QStringList t; | 264 | QStringList t; |
241 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | 265 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); |
242 | ++phoneIter ) | 266 | ++phoneIter ) |
243 | t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) ); | 267 | t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) ); |
244 | t.sort(); | 268 | t.sort(); |
245 | uint iii; | 269 | uint iii; |
246 | for ( iii = 0; iii < t.count(); ++iii) | 270 | for ( iii = 0; iii < t.count(); ++iii) |
247 | l.append( t[iii] ); | 271 | l.append( t[iii] ); |
248 | t = mData->emails; | 272 | t = mData->emails; |
249 | t.sort(); | 273 | t.sort(); |
250 | for ( iii = 0; iii < t.count(); ++iii) | 274 | for ( iii = 0; iii < t.count(); ++iii) |
251 | l.append( t[iii] ); | 275 | l.append( t[iii] ); |
252 | t = mData->categories; | 276 | t = mData->categories; |
253 | t.sort(); | 277 | t.sort(); |
254 | for ( iii = 0; iii < t.count(); ++iii) | 278 | for ( iii = 0; iii < t.count(); ++iii) |
255 | l.append( t[iii] ); | 279 | l.append( t[iii] ); |
256 | t = mData->custom; | 280 | t = mData->custom; |
257 | t.sort(); | 281 | t.sort(); |
258 | for ( iii = 0; iii < t.count(); ++iii) | 282 | for ( iii = 0; iii < t.count(); ++iii) |
259 | if ( t[iii].left( 25 ) != "KADDRESSBOOK-X-ExternalID" ) { | 283 | if ( t[iii].left( 25 ) != "KADDRESSBOOK-X-ExternalID" ) { |
260 | int find = t[iii].find (':')+1; | 284 | int find = t[iii].find (':')+1; |
261 | //qDebug("lennnn %d %d ", find, t[iii].length()); | 285 | //qDebug("lennnn %d %d ", find, t[iii].length()); |
262 | if ( find < t[iii].length()) | 286 | if ( find < t[iii].length()) |
263 | l.append( t[iii] ); | 287 | l.append( t[iii] ); |
264 | 288 | ||
265 | } | 289 | } |
266 | KABC::Address::List::Iterator addressIter; | 290 | KABC::Address::List::Iterator addressIter; |
267 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); | 291 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); |
268 | ++addressIter ) { | 292 | ++addressIter ) { |
269 | t = (*addressIter).asList(); | 293 | t = (*addressIter).asList(); |
270 | t.sort(); | 294 | t.sort(); |
271 | for ( iii = 0; iii < t.count(); ++iii) | 295 | for ( iii = 0; iii < t.count(); ++iii) |
272 | l.append( t[iii] ); | 296 | l.append( t[iii] ); |
273 | } | 297 | } |
274 | uint cs = getCsum4List(l); | 298 | uint cs = getCsum4List(l); |
275 | 299 | ||
276 | #if 0 | 300 | #if 0 |
277 | for ( iii = 0; iii < l.count(); ++iii) | 301 | for ( iii = 0; iii < l.count(); ++iii) |
278 | qDebug("%d***%s***",iii,l[iii].latin1()); | 302 | qDebug("%d***%s***",iii,l[iii].latin1()); |
279 | qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); | 303 | qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); |
280 | #endif | 304 | #endif |
305 | |||
281 | 306 | ||
282 | setCsum( dev, QString::number (cs )); | 307 | setCsum( dev, QString::number (cs )); |
283 | } | 308 | } |
284 | 309 | ||
285 | void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false) | 310 | void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false) |
286 | { | 311 | { |
287 | // merge all standard non-outlook fields. | 312 | // merge all standard non-outlook fields. |
288 | //if isSubSet (e.g. mobile phone sync) merge all fields | 313 | //if isSubSet (e.g. mobile phone sync) merge all fields |
289 | 314 | ||
290 | detach(); | 315 | detach(); |
291 | if ( isSubSet ) { | 316 | if ( isSubSet ) { |
292 | if ( mData->name.isEmpty() ) mData->name = ad.mData->name; | 317 | if ( mData->name.isEmpty() ) mData->name = ad.mData->name; |
293 | if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName; | 318 | if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName; |
294 | if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName; | 319 | if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName; |
295 | if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ; | 320 | if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ; |
296 | if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName; | 321 | if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName; |
297 | if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix; | 322 | if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix; |
298 | if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix; | 323 | if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix; |
299 | if ( mData->title .isEmpty() ) mData->title = ad.mData->title ; | 324 | if ( mData->title .isEmpty() ) mData->title = ad.mData->title ; |
300 | if ( mData->role.isEmpty() ) mData->role = ad.mData->role ; | 325 | if ( mData->role.isEmpty() ) mData->role = ad.mData->role ; |
301 | if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName; | 326 | if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName; |
302 | if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ; | 327 | if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ; |
303 | if ( mData->note.isEmpty() ) mData->note = ad.mData->note ; | 328 | if ( mData->note.isEmpty() ) mData->note = ad.mData->note ; |
304 | if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy; | 329 | if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy; |
305 | if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ; | 330 | if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ; |
306 | if ( !mData->birthday.isValid() ) | 331 | if ( !mData->birthday.isValid() ) |
307 | if ( ad.mData->birthday.isValid()) | 332 | if ( ad.mData->birthday.isValid()) |
308 | mData->birthday = ad.mData->birthday; | 333 | mData->birthday = ad.mData->birthday; |
309 | 334 | ||
310 | } | 335 | } |
311 | if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer; | 336 | if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer; |
312 | if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone; | 337 | if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone; |
313 | if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo; | 338 | if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo; |
314 | if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId; | 339 | if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId; |
315 | if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString; | 340 | if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString; |
316 | QStringList t; | 341 | QStringList t; |
317 | QStringList tAD; | 342 | QStringList tAD; |
318 | uint iii; | 343 | uint iii; |
319 | 344 | ||
320 | // ********** phone numbers | 345 | // ********** phone numbers |
321 | if ( isSubSet ) { | 346 | if ( isSubSet ) { |
322 | PhoneNumber::List phoneAD = ad.phoneNumbers(); | 347 | PhoneNumber::List phoneAD = ad.phoneNumbers(); |
323 | PhoneNumber::List::Iterator phoneItAD; | 348 | PhoneNumber::List::Iterator phoneItAD; |
324 | for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) { | 349 | for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) { |
325 | bool found = false; | 350 | bool found = false; |
326 | PhoneNumber::List::Iterator it; | 351 | PhoneNumber::List::Iterator it; |
327 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 352 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
328 | if ( ( *phoneItAD ).contains( (*it) ) ) { | 353 | if ( ( *phoneItAD ).contains( (*it) ) ) { |
329 | found = true; | 354 | found = true; |
330 | (*it).setType( ( *phoneItAD ).type() ); | 355 | (*it).setType( ( *phoneItAD ).type() ); |
331 | (*it).setNumber( ( *phoneItAD ).number() ); | 356 | (*it).setNumber( ( *phoneItAD ).number() ); |
332 | break; | 357 | break; |
333 | } | 358 | } |
334 | } | 359 | } |
335 | // if ( isSubSet && ! found ) | 360 | // if ( isSubSet && ! found ) |
336 | if ( ! found ) // LR try this one... | 361 | if ( ! found ) // LR try this one... |
337 | mData->phoneNumbers.append( *phoneItAD ); | 362 | mData->phoneNumbers.append( *phoneItAD ); |
338 | } | 363 | } |
339 | } else { | 364 | } else { |
340 | PhoneNumber::List phoneAD = ad.phoneNumbers(); | 365 | PhoneNumber::List phoneAD = ad.phoneNumbers(); |
341 | PhoneNumber::List::Iterator phoneItAD; | 366 | PhoneNumber::List::Iterator phoneItAD; |
342 | for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) { | 367 | for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) { |
343 | bool found = false; | 368 | bool found = false; |
344 | PhoneNumber::List::Iterator it; | 369 | PhoneNumber::List::Iterator it; |
345 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 370 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
346 | if ( ( *phoneItAD ).contains( (*it) ) ) { | 371 | if ( ( *phoneItAD ).contains( (*it) ) ) { |
347 | found = true; | 372 | found = true; |
348 | (*it).setType( ( *phoneItAD ).type() ); | 373 | (*it).setType( ( *phoneItAD ).type() ); |
349 | (*it).setNumber( ( *phoneItAD ).number() ); | 374 | (*it).setNumber( ( *phoneItAD ).number() ); |
350 | break; | 375 | break; |
351 | } | 376 | } |
352 | } | 377 | } |
353 | if ( ! found ) { // append numbers which do not have work or home type | 378 | if ( ! found ) { // append numbers which do not have work or home type |
354 | if ( ! ( ( *phoneItAD ).type() & (PhoneNumber::Work | PhoneNumber::Home) ) ) | 379 | if ( ! ( ( *phoneItAD ).type() & (PhoneNumber::Work | PhoneNumber::Home) ) ) |
355 | mData->phoneNumbers.append( *phoneItAD ); | 380 | mData->phoneNumbers.append( *phoneItAD ); |
356 | } | 381 | } |
357 | } | 382 | } |
358 | } | 383 | } |
359 | if ( isSubSet ) { | 384 | if ( isSubSet ) { |
360 | // ************* emails; | 385 | // ************* emails; |
361 | t = mData->emails; | 386 | t = mData->emails; |
362 | tAD = ad.mData->emails; | 387 | tAD = ad.mData->emails; |
363 | for ( iii = 0; iii < tAD.count(); ++iii) | 388 | for ( iii = 0; iii < tAD.count(); ++iii) |
364 | if ( !t.contains(tAD[iii] ) ) | 389 | if ( !t.contains(tAD[iii] ) ) |
365 | mData->emails.append( tAD[iii] ); | 390 | mData->emails.append( tAD[iii] ); |
366 | } | 391 | } |
367 | 392 | ||
368 | // ************* categories; | 393 | // ************* categories; |
369 | if ( isSubSet ) { | 394 | if ( isSubSet ) { |
370 | t = mData->categories; | 395 | t = mData->categories; |
371 | tAD = ad.mData->categories; | 396 | tAD = ad.mData->categories; |
372 | for ( iii = 0; iii < tAD.count(); ++iii) | 397 | for ( iii = 0; iii < tAD.count(); ++iii) |
373 | if ( !t.contains(tAD[iii] ) ) | 398 | if ( !t.contains(tAD[iii] ) ) |
374 | mData->categories.append( tAD[iii] ); | 399 | mData->categories.append( tAD[iii] ); |
375 | } | 400 | } |
376 | QStringList::ConstIterator it; | 401 | QStringList::ConstIterator it; |
377 | for( it = ad.mData->custom.begin(); it != ad.mData->custom.end(); ++it ) { | 402 | for( it = ad.mData->custom.begin(); it != ad.mData->custom.end(); ++it ) { |
378 | QString qualifiedName = (*it).left( (*it).find( ":" )); | 403 | QString qualifiedName = (*it).left( (*it).find( ":" )); |
379 | bool found = false; | 404 | bool found = false; |
380 | QStringList::ConstIterator itL; | 405 | QStringList::ConstIterator itL; |
381 | for( itL = mData->custom.begin(); itL != mData->custom.end(); ++itL ) { | 406 | for( itL = mData->custom.begin(); itL != mData->custom.end(); ++itL ) { |
382 | if ( (*itL).startsWith( qualifiedName ) ) { | 407 | if ( (*itL).startsWith( qualifiedName ) ) { |
383 | found = true; | 408 | found = true; |
384 | break; | 409 | break; |
385 | } | 410 | } |
386 | } | 411 | } |
387 | if ( ! found ) { | 412 | if ( ! found ) { |
388 | mData->custom.append( *it ); | 413 | mData->custom.append( *it ); |
389 | } | 414 | } |
390 | } | 415 | } |
391 | if ( mData->logo.undefined() && !ad.mData->logo.undefined() ) mData->logo = ad.mData->logo; | 416 | if ( mData->logo.undefined() && !ad.mData->logo.undefined() ) mData->logo = ad.mData->logo; |
392 | if ( mData->photo.undefined() && !ad.mData->photo.undefined() ) mData->photo = ad.mData->photo; | 417 | if ( mData->photo.undefined() && !ad.mData->photo.undefined() ) mData->photo = ad.mData->photo; |
393 | if ( !mData->sound.isIntern() ) { | 418 | if ( !mData->sound.isIntern() ) { |
394 | if ( mData->sound.url().isEmpty() ) { | 419 | if ( mData->sound.url().isEmpty() ) { |
395 | mData->sound = ad.mData->sound; | 420 | mData->sound = ad.mData->sound; |
396 | } | 421 | } |
397 | } | 422 | } |
398 | if ( !mData->agent.isIntern() ) { | 423 | if ( !mData->agent.isIntern() ) { |
399 | if ( mData->agent.url().isEmpty() ) { | 424 | if ( mData->agent.url().isEmpty() ) { |
400 | mData->agent = ad.mData->agent; | 425 | mData->agent = ad.mData->agent; |
401 | } | 426 | } |
402 | } | 427 | } |
403 | { | 428 | { |
404 | Key::List::Iterator itA; | 429 | Key::List::Iterator itA; |
405 | for( itA = ad.mData->keys.begin(); itA != ad.mData->keys.end(); ++itA ) { | 430 | for( itA = ad.mData->keys.begin(); itA != ad.mData->keys.end(); ++itA ) { |
406 | bool found = false; | 431 | bool found = false; |
407 | Key::List::Iterator it; | 432 | Key::List::Iterator it; |
408 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 433 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
409 | if ( (*it) == (*itA)) { | 434 | if ( (*it) == (*itA)) { |
410 | found = true; | 435 | found = true; |
411 | break; | 436 | break; |
412 | 437 | ||
413 | } | 438 | } |
414 | } | 439 | } |
415 | if ( ! found ) { | 440 | if ( ! found ) { |
416 | mData->keys.append( *itA ); | 441 | mData->keys.append( *itA ); |
417 | } | 442 | } |
418 | } | 443 | } |
419 | } | 444 | } |
420 | if ( isSubSet ) { | 445 | if ( isSubSet ) { |
421 | KABC::Address::List::Iterator addressIterA; | 446 | KABC::Address::List::Iterator addressIterA; |
422 | for ( addressIterA = ad.mData->addresses.begin(); addressIterA != ad.mData->addresses.end(); ++addressIterA ) { | 447 | for ( addressIterA = ad.mData->addresses.begin(); addressIterA != ad.mData->addresses.end(); ++addressIterA ) { |
423 | bool found = false; | 448 | bool found = false; |
424 | KABC::Address::List::Iterator addressIter; | 449 | KABC::Address::List::Iterator addressIter; |
425 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); | 450 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); |
426 | ++addressIter ) { | 451 | ++addressIter ) { |
427 | if ( (*addressIter) == (*addressIterA)) { | 452 | if ( (*addressIter) == (*addressIterA)) { |
428 | found = true; | 453 | found = true; |
429 | (*addressIter).setType( (*addressIterA).type() ); | 454 | (*addressIter).setType( (*addressIterA).type() ); |
430 | break; | 455 | break; |
431 | } | 456 | } |
432 | 457 | ||
433 | } | 458 | } |
434 | if ( isSubSet && ! found ) { | 459 | if ( isSubSet && ! found ) { |
435 | mData->addresses.append( *addressIterA ); | 460 | mData->addresses.append( *addressIterA ); |
436 | } | 461 | } |
437 | } | 462 | } |
438 | } | 463 | } |
439 | //qDebug("merge contact %s ", ad.uid().latin1()); | 464 | //qDebug("merge contact %s ", ad.uid().latin1()); |
440 | setUid( ad.uid() ); | 465 | setUid( ad.uid() ); |
441 | setRevision( ad.revision() ); | 466 | setRevision( ad.revision() ); |
442 | } | 467 | } |
443 | 468 | ||
444 | bool Addressee::removeVoice() | 469 | bool Addressee::removeVoice() |
445 | { | 470 | { |
446 | PhoneNumber::List phoneN = phoneNumbers(); | 471 | PhoneNumber::List phoneN = phoneNumbers(); |
447 | PhoneNumber::List::Iterator phoneIt; | 472 | PhoneNumber::List::Iterator phoneIt; |
448 | bool found = false; | 473 | bool found = false; |
449 | for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { | 474 | for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { |
450 | if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found | 475 | if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found |
451 | if ((*phoneIt).type() - PhoneNumber::Voice ) { | 476 | if ((*phoneIt).type() - PhoneNumber::Voice ) { |
452 | (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice ); | 477 | (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice ); |
453 | insertPhoneNumber( (*phoneIt) ); | 478 | insertPhoneNumber( (*phoneIt) ); |
454 | found = true; | 479 | found = true; |
455 | } | 480 | } |
456 | } | 481 | } |
457 | 482 | ||
458 | } | 483 | } |
459 | return found; | 484 | return found; |
460 | } | 485 | } |
461 | 486 | ||
462 | bool Addressee::containsAdr(const Addressee& ad ) | 487 | bool Addressee::containsAdr(const Addressee& ad ) |
463 | { | 488 | { |
464 | if ( ! ad.mData->familyName.isEmpty() ) if ( mData->familyName != ad.mData->familyName) return false; | 489 | if ( ! ad.mData->familyName.isEmpty() ) if ( mData->familyName != ad.mData->familyName) return false; |
465 | if ( ! ad.mData->givenName.isEmpty() )if ( mData->givenName != ad.mData->givenName ) return false; | 490 | if ( ! ad.mData->givenName.isEmpty() )if ( mData->givenName != ad.mData->givenName ) return false; |
466 | if ( ad.mData->url.isValid() ) if (mData->url != ad.mData->url) return false ; | 491 | if ( ad.mData->url.isValid() ) if (mData->url != ad.mData->url) return false ; |
467 | if ( ! ad.mData->role.isEmpty() ) if (mData->role != ad.mData->role) return false ; | 492 | if ( ! ad.mData->role.isEmpty() ) if (mData->role != ad.mData->role) return false ; |
468 | if ( ! ad.mData->organization.isEmpty() ) if (mData->organization != ad.mData->organization) return false ; | 493 | if ( ! ad.mData->organization.isEmpty() ) if (mData->organization != ad.mData->organization) return false ; |
469 | if ( ! ad.mData->note.isEmpty() ) if (mData->note != ad.mData->note) return false ; | 494 | if ( ! ad.mData->note.isEmpty() ) if (mData->note != ad.mData->note) return false ; |
470 | if ( ! ad.mData->title .isEmpty() ) if (mData->title != ad.mData->title ) return false ; | 495 | if ( ! ad.mData->title .isEmpty() ) if (mData->title != ad.mData->title ) return false ; |
471 | 496 | ||
472 | // compare phone numbers | 497 | // compare phone numbers |
diff --git a/kaddressbook/imagewidget.cpp b/kaddressbook/imagewidget.cpp index 1e9743c..d0f52ea 100644 --- a/kaddressbook/imagewidget.cpp +++ b/kaddressbook/imagewidget.cpp | |||
@@ -50,262 +50,263 @@ ImageWidget::ImageWidget( QWidget *parent, const char *name ) | |||
50 | : QWidget( parent, name ) | 50 | : QWidget( parent, name ) |
51 | { | 51 | { |
52 | QGridLayout *topLayout = new QGridLayout( this, 2, 1, KDialog::marginHint(), | 52 | QGridLayout *topLayout = new QGridLayout( this, 2, 1, KDialog::marginHint(), |
53 | KDialog::spacingHint() ); | 53 | KDialog::spacingHint() ); |
54 | 54 | ||
55 | QGroupBox *photoBox = new QGroupBox( 0, Qt::Vertical, i18n( "Photo" ), this ); | 55 | QGroupBox *photoBox = new QGroupBox( 0, Qt::Vertical, i18n( "Photo" ), this ); |
56 | QGridLayout *boxLayout = new QGridLayout( photoBox->layout(), 3, 2, | 56 | QGridLayout *boxLayout = new QGridLayout( photoBox->layout(), 3, 2, |
57 | KDialog::spacingHint() ); | 57 | KDialog::spacingHint() ); |
58 | boxLayout->setRowStretch( 2, 1 ); | 58 | boxLayout->setRowStretch( 2, 1 ); |
59 | 59 | ||
60 | mPhotoLabel = new QLabel( photoBox ); | 60 | mPhotoLabel = new QLabel( photoBox ); |
61 | int fac = 9; | 61 | int fac = 9; |
62 | if ( QApplication::desktop()->width() > 320 ) | 62 | if ( QApplication::desktop()->width() > 320 ) |
63 | fac = 6; | 63 | fac = 6; |
64 | mPhotoLabel->setFixedSize( 50*9/fac, 70*9/fac ); | 64 | mPhotoLabel->setFixedSize( 50*9/fac, 70*9/fac ); |
65 | mPhotoLabel->setScaledContents( true ); | 65 | mPhotoLabel->setScaledContents( true ); |
66 | mPhotoLabel->setFrameStyle( QFrame::Panel | QFrame::Sunken ); | 66 | mPhotoLabel->setFrameStyle( QFrame::Panel | QFrame::Sunken ); |
67 | boxLayout->addMultiCellWidget( mPhotoLabel, 0, 3, 0, 0 ); | 67 | boxLayout->addMultiCellWidget( mPhotoLabel, 0, 3, 0, 0 ); |
68 | 68 | ||
69 | mPhotoUrl = new KURLRequester( photoBox ); | 69 | mPhotoUrl = new KURLRequester( photoBox ); |
70 | #ifndef KAB_EMBEDDED | 70 | #ifndef KAB_EMBEDDED |
71 | mPhotoUrl->setFilter( KImageIO::pattern() ); | 71 | mPhotoUrl->setFilter( KImageIO::pattern() ); |
72 | #else //KAB_EMBEDDED | 72 | #else //KAB_EMBEDDED |
73 | //US qDebug("ImageWidget::ImageWidget KImageIO not defined. Does this harm ???"); | 73 | //US qDebug("ImageWidget::ImageWidget KImageIO not defined. Does this harm ???"); |
74 | #endif //KAB_EMBEDDED | 74 | #endif //KAB_EMBEDDED |
75 | 75 | ||
76 | 76 | ||
77 | boxLayout->addWidget( mPhotoUrl, 0, 1 ); | 77 | boxLayout->addWidget( mPhotoUrl, 0, 1 ); |
78 | QHBox *hb1 = new QHBox ( photoBox ); | 78 | QHBox *hb1 = new QHBox ( photoBox ); |
79 | mUsePhotoUrl = new QCheckBox( i18n( "Store as URL" ), hb1 ); | 79 | mUsePhotoUrl = new QCheckBox( i18n( "Store as URL" ), hb1 ); |
80 | mUsePhotoUrl->setEnabled( false ); | 80 | mUsePhotoUrl->setEnabled( false ); |
81 | boxLayout->addWidget( hb1, 1, 1 ); | 81 | boxLayout->addWidget( hb1, 1, 1 ); |
82 | 82 | ||
83 | QPushButton * pb = new QPushButton( i18n( "Remove" ), hb1 ); | 83 | QPushButton * pb = new QPushButton( i18n( "Remove" ), hb1 ); |
84 | connect( pb, SIGNAL( clicked() ),this, SLOT( removePhoto() ) ); | 84 | connect( pb, SIGNAL( clicked() ),this, SLOT( removePhoto() ) ); |
85 | boxLayout->addWidget( new QLabel( photoBox ), 2, 1 ); | 85 | boxLayout->addWidget( new QLabel( photoBox ), 2, 1 ); |
86 | 86 | ||
87 | topLayout->addWidget( photoBox, 0, 0 ); | 87 | topLayout->addWidget( photoBox, 0, 0 ); |
88 | 88 | ||
89 | QGroupBox *logoBox = new QGroupBox( 0, Qt::Vertical, i18n( "Logo" ), this ); | 89 | QGroupBox *logoBox = new QGroupBox( 0, Qt::Vertical, i18n( "Logo" ), this ); |
90 | boxLayout = new QGridLayout( logoBox->layout(), 3, 2, KDialog::spacingHint() ); | 90 | boxLayout = new QGridLayout( logoBox->layout(), 3, 2, KDialog::spacingHint() ); |
91 | boxLayout->setRowStretch( 2, 1 ); | 91 | boxLayout->setRowStretch( 2, 1 ); |
92 | 92 | ||
93 | mLogoLabel = new QLabel( logoBox ); | 93 | mLogoLabel = new QLabel( logoBox ); |
94 | mLogoLabel->setFixedSize( 50*9/fac, 70*9/fac ); | 94 | mLogoLabel->setFixedSize( 50*9/fac, 70*9/fac ); |
95 | mLogoLabel->setScaledContents( true ); | 95 | mLogoLabel->setScaledContents( true ); |
96 | mLogoLabel->setFrameStyle( QFrame::Panel | QFrame::Sunken ); | 96 | mLogoLabel->setFrameStyle( QFrame::Panel | QFrame::Sunken ); |
97 | boxLayout->addMultiCellWidget( mLogoLabel, 0, 3, 0, 0 ); | 97 | boxLayout->addMultiCellWidget( mLogoLabel, 0, 3, 0, 0 ); |
98 | 98 | ||
99 | mLogoUrl = new KURLRequester( logoBox ); | 99 | mLogoUrl = new KURLRequester( logoBox ); |
100 | #ifndef KAB_EMBEDDED | 100 | #ifndef KAB_EMBEDDED |
101 | mLogoUrl->setFilter( KImageIO::pattern() ); | 101 | mLogoUrl->setFilter( KImageIO::pattern() ); |
102 | #else //KAB_EMBEDDED | 102 | #else //KAB_EMBEDDED |
103 | //US qDebug("ImageWidget::ImageWidget KImageIO not defined 2"); | 103 | //US qDebug("ImageWidget::ImageWidget KImageIO not defined 2"); |
104 | #endif //KAB_EMBEDDED | 104 | #endif //KAB_EMBEDDED |
105 | boxLayout->addWidget( mLogoUrl, 0, 1 ); | 105 | boxLayout->addWidget( mLogoUrl, 0, 1 ); |
106 | 106 | ||
107 | QHBox *hb2 = new QHBox ( logoBox ); | 107 | QHBox *hb2 = new QHBox ( logoBox ); |
108 | mUseLogoUrl = new QCheckBox( i18n( "Store as URL" ), hb2 ); | 108 | mUseLogoUrl = new QCheckBox( i18n( "Store as URL" ), hb2 ); |
109 | mUseLogoUrl->setEnabled( false ); | 109 | mUseLogoUrl->setEnabled( false ); |
110 | boxLayout->addWidget( hb2, 1, 1 ); | 110 | boxLayout->addWidget( hb2, 1, 1 ); |
111 | 111 | ||
112 | pb = new QPushButton( i18n( "Remove" ), hb2 ); | 112 | pb = new QPushButton( i18n( "Remove" ), hb2 ); |
113 | connect( pb, SIGNAL( clicked() ),this, SLOT( removeLogo() ) ); | 113 | connect( pb, SIGNAL( clicked() ),this, SLOT( removeLogo() ) ); |
114 | boxLayout->addWidget( new QLabel( logoBox ), 2, 1 ); | 114 | boxLayout->addWidget( new QLabel( logoBox ), 2, 1 ); |
115 | topLayout->addWidget( logoBox, 1, 0 ); | 115 | topLayout->addWidget( logoBox, 1, 0 ); |
116 | 116 | ||
117 | connect( mPhotoUrl, SIGNAL( textChanged( const QString& ) ), | 117 | connect( mPhotoUrl, SIGNAL( textChanged( const QString& ) ), |
118 | SIGNAL( changed() ) ); | 118 | SIGNAL( changed() ) ); |
119 | connect( mPhotoUrl, SIGNAL( urlSelected( const QString& ) ), | 119 | connect( mPhotoUrl, SIGNAL( urlSelected( const QString& ) ), |
120 | SLOT( loadPhoto() ) ); | 120 | SLOT( loadPhoto() ) ); |
121 | connect( mPhotoUrl, SIGNAL( urlSelected( const QString& ) ), | 121 | connect( mPhotoUrl, SIGNAL( urlSelected( const QString& ) ), |
122 | SIGNAL( changed() ) ); | 122 | SIGNAL( changed() ) ); |
123 | connect( mPhotoUrl, SIGNAL( urlSelected( const QString& ) ), | 123 | connect( mPhotoUrl, SIGNAL( urlSelected( const QString& ) ), |
124 | SLOT( updateGUI() ) ); | 124 | SLOT( updateGUI() ) ); |
125 | connect( mUsePhotoUrl, SIGNAL( toggled( bool ) ), | 125 | connect( mUsePhotoUrl, SIGNAL( toggled( bool ) ), |
126 | SIGNAL( changed() ) ); | 126 | SIGNAL( changed() ) ); |
127 | 127 | ||
128 | connect( mLogoUrl, SIGNAL( textChanged( const QString& ) ), | 128 | connect( mLogoUrl, SIGNAL( textChanged( const QString& ) ), |
129 | SIGNAL( changed() ) ); | 129 | SIGNAL( changed() ) ); |
130 | connect( mLogoUrl, SIGNAL( urlSelected( const QString& ) ), | 130 | connect( mLogoUrl, SIGNAL( urlSelected( const QString& ) ), |
131 | SLOT( loadLogo() ) ); | 131 | SLOT( loadLogo() ) ); |
132 | connect( mLogoUrl, SIGNAL( urlSelected( const QString& ) ), | 132 | connect( mLogoUrl, SIGNAL( urlSelected( const QString& ) ), |
133 | SIGNAL( changed() ) ); | 133 | SIGNAL( changed() ) ); |
134 | connect( mLogoUrl, SIGNAL( urlSelected( const QString& ) ), | 134 | connect( mLogoUrl, SIGNAL( urlSelected( const QString& ) ), |
135 | SLOT( updateGUI() ) ); | 135 | SLOT( updateGUI() ) ); |
136 | connect( mUseLogoUrl, SIGNAL( toggled( bool ) ), | 136 | connect( mUseLogoUrl, SIGNAL( toggled( bool ) ), |
137 | SIGNAL( changed() ) ); | 137 | SIGNAL( changed() ) ); |
138 | 138 | ||
139 | #ifndef KAB_EMBEDDED | 139 | #ifndef KAB_EMBEDDED |
140 | KAcceleratorManager::manage( this ); | 140 | KAcceleratorManager::manage( this ); |
141 | #endif //KAB_EMBEDDED | 141 | #endif //KAB_EMBEDDED |
142 | 142 | ||
143 | } | 143 | } |
144 | 144 | ||
145 | ImageWidget::~ImageWidget() | 145 | ImageWidget::~ImageWidget() |
146 | { | 146 | { |
147 | } | 147 | } |
148 | 148 | ||
149 | void ImageWidget::setPhoto( const KABC::Picture &photo ) | 149 | void ImageWidget::setPhoto( const KABC::Picture &photo ) |
150 | { | 150 | { |
151 | bool blocked = signalsBlocked(); | 151 | bool blocked = signalsBlocked(); |
152 | blockSignals( true ); | 152 | blockSignals( true ); |
153 | 153 | ||
154 | if ( photo.isIntern() ) { | 154 | if ( photo.isIntern() ) { |
155 | //US | 155 | //US |
156 | //US mPhotoLabel->setPixmap( photo.data() ); | 156 | //US mPhotoLabel->setPixmap( photo.data() ); |
157 | if (photo.data().isNull() != true) | 157 | if (photo.data().isNull() != true) |
158 | { | 158 | { |
159 | QPixmap pm; | 159 | QPixmap pm; |
160 | pm.convertFromImage(photo.data()); | 160 | pm.convertFromImage(photo.data()); |
161 | 161 | ||
162 | mPhotoLabel->setPixmap( pm ); | 162 | mPhotoLabel->setPixmap( pm ); |
163 | } | 163 | } |
164 | 164 | ||
165 | mUsePhotoUrl->setChecked( false ); | 165 | mUsePhotoUrl->setChecked( false ); |
166 | } else { | 166 | } else { |
167 | mPhotoUrl->setURL( photo.url() ); | 167 | mPhotoUrl->setURL( photo.url() ); |
168 | if ( !photo.url().isEmpty() ) | 168 | if ( !photo.url().isEmpty() ) |
169 | mUsePhotoUrl->setChecked( true ); | 169 | mUsePhotoUrl->setChecked( true ); |
170 | loadPhoto(); | 170 | loadPhoto(); |
171 | } | 171 | } |
172 | 172 | ||
173 | blockSignals( blocked ); | 173 | blockSignals( blocked ); |
174 | } | 174 | } |
175 | 175 | ||
176 | KABC::Picture ImageWidget::photo() const | 176 | KABC::Picture ImageWidget::photo() const |
177 | { | 177 | { |
178 | KABC::Picture photo; | 178 | KABC::Picture photo; |
179 | 179 | ||
180 | if ( mUsePhotoUrl->isChecked() ) | 180 | if ( mUsePhotoUrl->isChecked() ) |
181 | photo.setUrl( mPhotoUrl->url() ); | 181 | photo.setUrl( mPhotoUrl->url() ); |
182 | else { | 182 | else { |
183 | QPixmap *px = mPhotoLabel->pixmap(); | 183 | QPixmap *px = mPhotoLabel->pixmap(); |
184 | if ( px ) { | 184 | if ( px ) { |
185 | #ifndef KAB_EMBEDDED | 185 | #ifndef KAB_EMBEDDED |
186 | if ( px->height() > px->width() ) | 186 | if ( px->height() > px->width() ) |
187 | photo.setData( px->convertToImage().scaleHeight( 140 ) ); | 187 | photo.setData( px->convertToImage().scaleHeight( 140 ) ); |
188 | else | 188 | else |
189 | photo.setData( px->convertToImage().scaleWidth( 100 ) ); | 189 | photo.setData( px->convertToImage().scaleWidth( 100 ) ); |
190 | #else //KAB_EMBEDDED | 190 | #else //KAB_EMBEDDED |
191 | //US add teh nullcheck | 191 | //US add teh nullcheck |
192 | if (px->isNull() != true ) | 192 | if (px->isNull() != true ) |
193 | photo.setData( px->convertToImage() ); | 193 | photo.setData( px->convertToImage() ); |
194 | #endif //KAB_EMBEDDED | 194 | #endif //KAB_EMBEDDED |
195 | 195 | ||
196 | photo.setType( "PNG" ); | 196 | photo.setType( "PNG" ); |
197 | } | 197 | } |
198 | } | 198 | } |
199 | 199 | ||
200 | return photo; | 200 | return photo; |
201 | } | 201 | } |
202 | 202 | ||
203 | void ImageWidget::setLogo( const KABC::Picture &logo ) | 203 | void ImageWidget::setLogo( const KABC::Picture &logo ) |
204 | { | 204 | { |
205 | bool blocked = signalsBlocked(); | 205 | bool blocked = signalsBlocked(); |
206 | blockSignals( true ); | 206 | blockSignals( true ); |
207 | 207 | ||
208 | if ( logo.isIntern() ) { | 208 | if ( logo.isIntern() ) { |
209 | //US | 209 | //US |
210 | //US mLogoLabel->setPixmap( logo.data() ); | 210 | //US mLogoLabel->setPixmap( logo.data() ); |
211 | if (logo.data().isNull() != true) | 211 | if (logo.data().isNull() != true) |
212 | { | 212 | { |
213 | QPixmap pm; | 213 | QPixmap pm; |
214 | pm.convertFromImage(logo.data()); | 214 | pm.convertFromImage(logo.data()); |
215 | mLogoLabel->setPixmap( pm ); | 215 | mLogoLabel->setPixmap( pm ); |
216 | } | 216 | } |
217 | mUseLogoUrl->setChecked( false ); | 217 | mUseLogoUrl->setChecked( false ); |
218 | } else { | 218 | } else { |
219 | mLogoUrl->setURL( logo.url() ); | 219 | mLogoUrl->setURL( logo.url() ); |
220 | if ( !logo.url().isEmpty() ) | 220 | if ( !logo.url().isEmpty() ) |
221 | mUseLogoUrl->setChecked( true ); | 221 | mUseLogoUrl->setChecked( true ); |
222 | loadLogo(); | 222 | loadLogo(); |
223 | } | 223 | } |
224 | 224 | ||
225 | blockSignals( blocked ); | 225 | blockSignals( blocked ); |
226 | } | 226 | } |
227 | 227 | ||
228 | KABC::Picture ImageWidget::logo() const | 228 | KABC::Picture ImageWidget::logo() const |
229 | { | 229 | { |
230 | KABC::Picture logo; | 230 | KABC::Picture logo; |
231 | 231 | ||
232 | if ( mUseLogoUrl->isChecked() ) | 232 | if ( mUseLogoUrl->isChecked() ) |
233 | logo.setUrl( mLogoUrl->url() ); | 233 | logo.setUrl( mLogoUrl->url() ); |
234 | else { | 234 | else { |
235 | QPixmap *px = mLogoLabel->pixmap(); | 235 | QPixmap *px = mLogoLabel->pixmap(); |
236 | if ( px ) { | 236 | if ( px ) { |
237 | #ifndef KAB_EMBEDDED | 237 | #ifndef KAB_EMBEDDED |
238 | if ( px->height() > px->width() ) | 238 | if ( px->height() > px->width() ) |
239 | logo.setData( px->convertToImage().scaleHeight( 140 ) ); | 239 | logo.setData( px->convertToImage().scaleHeight( 140 ) ); |
240 | else | 240 | else |
241 | logo.setData( px->convertToImage().scaleWidth( 100 ) ); | 241 | logo.setData( px->convertToImage().scaleWidth( 100 ) ); |
242 | #else //KAB_EMBEDDED | 242 | #else //KAB_EMBEDDED |
243 | logo.setData( px->convertToImage() ); | 243 | if (px->isNull() != true ) |
244 | logo.setData( px->convertToImage() ); | ||
244 | #endif //KAB_EMBEDDED | 245 | #endif //KAB_EMBEDDED |
245 | 246 | ||
246 | logo.setType( "PNG" ); | 247 | logo.setType( "PNG" ); |
247 | 248 | ||
248 | } | 249 | } |
249 | } | 250 | } |
250 | return logo; | 251 | return logo; |
251 | } | 252 | } |
252 | void ImageWidget::removePhoto() | 253 | void ImageWidget::removePhoto() |
253 | { | 254 | { |
254 | setPhoto(KABC::Picture() ); | 255 | setPhoto(KABC::Picture() ); |
255 | } | 256 | } |
256 | 257 | ||
257 | void ImageWidget::removeLogo() | 258 | void ImageWidget::removeLogo() |
258 | { | 259 | { |
259 | setLogo(KABC::Picture() ); | 260 | setLogo(KABC::Picture() ); |
260 | } | 261 | } |
261 | 262 | ||
262 | void ImageWidget::loadPhoto() | 263 | void ImageWidget::loadPhoto() |
263 | { | 264 | { |
264 | mPhotoLabel->setPixmap( loadPixmap( mPhotoUrl->url() ) ); | 265 | mPhotoLabel->setPixmap( loadPixmap( mPhotoUrl->url() ) ); |
265 | } | 266 | } |
266 | 267 | ||
267 | void ImageWidget::loadLogo() | 268 | void ImageWidget::loadLogo() |
268 | { | 269 | { |
269 | mLogoLabel->setPixmap( loadPixmap( mLogoUrl->url() ) ); | 270 | mLogoLabel->setPixmap( loadPixmap( mLogoUrl->url() ) ); |
270 | } | 271 | } |
271 | 272 | ||
272 | void ImageWidget::updateGUI() | 273 | void ImageWidget::updateGUI() |
273 | { | 274 | { |
274 | KURLRequester *ptr = (KURLRequester*)sender(); | 275 | KURLRequester *ptr = (KURLRequester*)sender(); |
275 | 276 | ||
276 | 277 | ||
277 | if ( ptr == mPhotoUrl ) | 278 | if ( ptr == mPhotoUrl ) |
278 | mUsePhotoUrl->setEnabled( true ); | 279 | mUsePhotoUrl->setEnabled( true ); |
279 | else if ( ptr == mLogoUrl ) | 280 | else if ( ptr == mLogoUrl ) |
280 | mUseLogoUrl->setEnabled( true ); | 281 | mUseLogoUrl->setEnabled( true ); |
281 | } | 282 | } |
282 | 283 | ||
283 | QPixmap ImageWidget::loadPixmap( const KURL &url ) | 284 | QPixmap ImageWidget::loadPixmap( const KURL &url ) |
284 | { | 285 | { |
285 | QString tempFile; | 286 | QString tempFile; |
286 | QPixmap pixmap; | 287 | QPixmap pixmap; |
287 | 288 | ||
288 | if ( url.isEmpty() ) | 289 | if ( url.isEmpty() ) |
289 | return pixmap; | 290 | return pixmap; |
290 | 291 | ||
291 | if ( url.isLocalFile() ) | 292 | if ( url.isLocalFile() ) |
292 | pixmap = QPixmap( url.path() ); | 293 | pixmap = QPixmap( url.path() ); |
293 | else | 294 | else |
294 | { | 295 | { |
295 | #ifndef KAB_EMBEDDED | 296 | #ifndef KAB_EMBEDDED |
296 | if ( KIO::NetAccess::download( url, tempFile ) ) { | 297 | if ( KIO::NetAccess::download( url, tempFile ) ) { |
297 | pixmap = QPixmap( tempFile ); | 298 | pixmap = QPixmap( tempFile ); |
298 | KIO::NetAccess::removeTempFile( tempFile ); | 299 | KIO::NetAccess::removeTempFile( tempFile ); |
299 | } | 300 | } |
300 | #else //KAB_EMBEDDED | 301 | #else //KAB_EMBEDDED |
301 | qDebug("ImageWidget::loadPixmap : only local pixmaps are allowed"); | 302 | qDebug("ImageWidget::loadPixmap : only local pixmaps are allowed"); |
302 | #endif //KAB_EMBEDDED | 303 | #endif //KAB_EMBEDDED |
303 | 304 | ||
304 | } | 305 | } |
305 | 306 | ||
306 | return pixmap; | 307 | return pixmap; |
307 | } | 308 | } |
308 | 309 | ||
309 | #ifndef KAB_EMBEDDED | 310 | #ifndef KAB_EMBEDDED |
310 | #include "imagewidget.moc" | 311 | #include "imagewidget.moc" |
311 | #endif //KAB_EMBEDDED | 312 | #endif //KAB_EMBEDDED |
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index d970ff1..e88706e 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -999,384 +999,388 @@ void KABCore::browse( const QString& url ) | |||
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 | #if 0 // debug only | ||
1192 | KABC::Addressee ad = addr; | ||
1193 | ad.computeCsum( "123"); | ||
1194 | #endif | ||
1191 | } | 1195 | } |
1192 | 1196 | ||
1193 | void KABCore::addrModified( const KABC::Addressee &addr ,bool updateDetails ) | 1197 | void KABCore::addrModified( const KABC::Addressee &addr ,bool updateDetails ) |
1194 | { | 1198 | { |
1195 | 1199 | ||
1196 | Command *command = 0; | 1200 | Command *command = 0; |
1197 | QString uid; | 1201 | QString uid; |
1198 | 1202 | ||
1199 | // check if it exists already | 1203 | // check if it exists already |
1200 | KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); | 1204 | KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); |
1201 | if ( origAddr.isEmpty() ) | 1205 | if ( origAddr.isEmpty() ) |
1202 | command = new PwNewCommand( mAddressBook, addr ); | 1206 | command = new PwNewCommand( mAddressBook, addr ); |
1203 | else { | 1207 | else { |
1204 | command = new PwEditCommand( mAddressBook, origAddr, addr ); | 1208 | command = new PwEditCommand( mAddressBook, origAddr, addr ); |
1205 | uid = addr.uid(); | 1209 | uid = addr.uid(); |
1206 | } | 1210 | } |
1207 | 1211 | ||
1208 | UndoStack::instance()->push( command ); | 1212 | UndoStack::instance()->push( command ); |
1209 | RedoStack::instance()->clear(); | 1213 | RedoStack::instance()->clear(); |
1210 | if ( updateDetails ) | 1214 | if ( updateDetails ) |
1211 | mDetails->setAddressee( addr ); | 1215 | mDetails->setAddressee( addr ); |
1212 | setModified( true ); | 1216 | setModified( true ); |
1213 | } | 1217 | } |
1214 | 1218 | ||
1215 | void KABCore::newContact() | 1219 | void KABCore::newContact() |
1216 | { | 1220 | { |
1217 | 1221 | ||
1218 | 1222 | ||
1219 | QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); | 1223 | QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); |
1220 | 1224 | ||
1221 | QPtrList<KRES::Resource> kresResources; | 1225 | QPtrList<KRES::Resource> kresResources; |
1222 | QPtrListIterator<KABC::Resource> it( kabcResources ); | 1226 | QPtrListIterator<KABC::Resource> it( kabcResources ); |
1223 | KABC::Resource *resource; | 1227 | KABC::Resource *resource; |
1224 | while ( ( resource = it.current() ) != 0 ) { | 1228 | while ( ( resource = it.current() ) != 0 ) { |
1225 | ++it; | 1229 | ++it; |
1226 | if ( !resource->readOnly() ) { | 1230 | if ( !resource->readOnly() ) { |
1227 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); | 1231 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); |
1228 | if ( res ) | 1232 | if ( res ) |
1229 | kresResources.append( res ); | 1233 | kresResources.append( res ); |
1230 | } | 1234 | } |
1231 | } | 1235 | } |
1232 | 1236 | ||
1233 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); | 1237 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); |
1234 | resource = static_cast<KABC::Resource*>( res ); | 1238 | resource = static_cast<KABC::Resource*>( res ); |
1235 | 1239 | ||
1236 | if ( resource ) { | 1240 | if ( resource ) { |
1237 | KABC::Addressee addr; | 1241 | KABC::Addressee addr; |
1238 | addr.setResource( resource ); | 1242 | addr.setResource( resource ); |
1239 | mEditorDialog->setAddressee( addr ); | 1243 | mEditorDialog->setAddressee( addr ); |
1240 | KApplication::execDialog ( mEditorDialog ); | 1244 | KApplication::execDialog ( mEditorDialog ); |
1241 | 1245 | ||
1242 | } else | 1246 | } else |
1243 | return; | 1247 | return; |
1244 | 1248 | ||
1245 | // mEditorDict.insert( dialog->addressee().uid(), dialog ); | 1249 | // mEditorDict.insert( dialog->addressee().uid(), dialog ); |
1246 | 1250 | ||
1247 | 1251 | ||
1248 | } | 1252 | } |
1249 | 1253 | ||
1250 | void KABCore::addEmail( QString aStr ) | 1254 | void KABCore::addEmail( QString aStr ) |
1251 | { | 1255 | { |
1252 | #ifndef KAB_EMBEDDED | 1256 | #ifndef KAB_EMBEDDED |
1253 | QString fullName, email; | 1257 | QString fullName, email; |
1254 | 1258 | ||
1255 | KABC::Addressee::parseEmailAddress( aStr, fullName, email ); | 1259 | KABC::Addressee::parseEmailAddress( aStr, fullName, email ); |
1256 | 1260 | ||
1257 | // Try to lookup the addressee matching the email address | 1261 | // Try to lookup the addressee matching the email address |
1258 | bool found = false; | 1262 | bool found = false; |
1259 | QStringList emailList; | 1263 | QStringList emailList; |
1260 | KABC::AddressBook::Iterator it; | 1264 | KABC::AddressBook::Iterator it; |
1261 | for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { | 1265 | for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { |
1262 | emailList = (*it).emails(); | 1266 | emailList = (*it).emails(); |
1263 | if ( emailList.contains( email ) > 0 ) { | 1267 | if ( emailList.contains( email ) > 0 ) { |
1264 | found = true; | 1268 | found = true; |
1265 | (*it).setNameFromString( fullName ); | 1269 | (*it).setNameFromString( fullName ); |
1266 | editContact( (*it).uid() ); | 1270 | editContact( (*it).uid() ); |
1267 | } | 1271 | } |
1268 | } | 1272 | } |
1269 | 1273 | ||
1270 | if ( !found ) { | 1274 | if ( !found ) { |
1271 | KABC::Addressee addr; | 1275 | KABC::Addressee addr; |
1272 | addr.setNameFromString( fullName ); | 1276 | addr.setNameFromString( fullName ); |
1273 | addr.insertEmail( email, true ); | 1277 | addr.insertEmail( email, true ); |
1274 | 1278 | ||
1275 | mAddressBook->insertAddressee( addr ); | 1279 | mAddressBook->insertAddressee( addr ); |
1276 | mViewManager->refreshView( addr.uid() ); | 1280 | mViewManager->refreshView( addr.uid() ); |
1277 | editContact( addr.uid() ); | 1281 | editContact( addr.uid() ); |
1278 | } | 1282 | } |
1279 | #else //KAB_EMBEDDED | 1283 | #else //KAB_EMBEDDED |
1280 | qDebug("KABCore::addEmail finsih method"); | 1284 | qDebug("KABCore::addEmail finsih method"); |
1281 | #endif //KAB_EMBEDDED | 1285 | #endif //KAB_EMBEDDED |
1282 | } | 1286 | } |
1283 | 1287 | ||
1284 | void KABCore::importVCard( const KURL &url, bool showPreview ) | 1288 | void KABCore::importVCard( const KURL &url, bool showPreview ) |
1285 | { | 1289 | { |
1286 | mXXPortManager->importVCard( url, showPreview ); | 1290 | mXXPortManager->importVCard( url, showPreview ); |
1287 | } | 1291 | } |
1288 | void KABCore::importFromOL() | 1292 | void KABCore::importFromOL() |
1289 | { | 1293 | { |
1290 | #ifdef _WIN32_ | 1294 | #ifdef _WIN32_ |
1291 | KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); | 1295 | KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); |
1292 | idgl->exec(); | 1296 | idgl->exec(); |
1293 | KABC::Addressee::List list = idgl->getAddressList(); | 1297 | KABC::Addressee::List list = idgl->getAddressList(); |
1294 | if ( list.count() > 0 ) { | 1298 | if ( list.count() > 0 ) { |
1295 | KABC::Addressee::List listNew; | 1299 | KABC::Addressee::List listNew; |
1296 | KABC::Addressee::List listExisting; | 1300 | KABC::Addressee::List listExisting; |
1297 | KABC::Addressee::List::Iterator it; | 1301 | KABC::Addressee::List::Iterator it; |
1298 | KABC::AddressBook::Iterator iter; | 1302 | KABC::AddressBook::Iterator iter; |
1299 | for ( it = list.begin(); it != list.end(); ++it ) { | 1303 | for ( it = list.begin(); it != list.end(); ++it ) { |
1300 | if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) | 1304 | if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) |
1301 | listNew.append( (*it) ); | 1305 | listNew.append( (*it) ); |
1302 | else | 1306 | else |
1303 | listExisting.append( (*it) ); | 1307 | listExisting.append( (*it) ); |
1304 | } | 1308 | } |
1305 | if ( listExisting.count() > 0 ) | 1309 | 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() )); | 1310 | 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 ) { | 1311 | if ( listNew.count() > 0 ) { |
1308 | pasteWithNewUid = false; | 1312 | pasteWithNewUid = false; |
1309 | pasteContacts( listNew ); | 1313 | pasteContacts( listNew ); |
1310 | pasteWithNewUid = true; | 1314 | pasteWithNewUid = true; |
1311 | } | 1315 | } |
1312 | } | 1316 | } |
1313 | delete idgl; | 1317 | delete idgl; |
1314 | #endif | 1318 | #endif |
1315 | } | 1319 | } |
1316 | 1320 | ||
1317 | void KABCore::importVCard( const QString &vCard, bool showPreview ) | 1321 | void KABCore::importVCard( const QString &vCard, bool showPreview ) |
1318 | { | 1322 | { |
1319 | mXXPortManager->importVCard( vCard, showPreview ); | 1323 | mXXPortManager->importVCard( vCard, showPreview ); |
1320 | } | 1324 | } |
1321 | 1325 | ||
1322 | //US added a second method without defaultparameter | 1326 | //US added a second method without defaultparameter |
1323 | void KABCore::editContact2() { | 1327 | void KABCore::editContact2() { |
1324 | editContact( QString::null ); | 1328 | editContact( QString::null ); |
1325 | } | 1329 | } |
1326 | 1330 | ||
1327 | void KABCore::editContact( const QString &uid ) | 1331 | void KABCore::editContact( const QString &uid ) |
1328 | { | 1332 | { |
1329 | 1333 | ||
1330 | if ( mExtensionManager->isQuickEditVisible() ) | 1334 | if ( mExtensionManager->isQuickEditVisible() ) |
1331 | return; | 1335 | return; |
1332 | 1336 | ||
1333 | // First, locate the contact entry | 1337 | // First, locate the contact entry |
1334 | QString localUID = uid; | 1338 | QString localUID = uid; |
1335 | if ( localUID.isNull() ) { | 1339 | if ( localUID.isNull() ) { |
1336 | QStringList uidList = mViewManager->selectedUids(); | 1340 | QStringList uidList = mViewManager->selectedUids(); |
1337 | if ( uidList.count() > 0 ) | 1341 | if ( uidList.count() > 0 ) |
1338 | localUID = *( uidList.at( 0 ) ); | 1342 | localUID = *( uidList.at( 0 ) ); |
1339 | } | 1343 | } |
1340 | 1344 | ||
1341 | KABC::Addressee addr = mAddressBook->findByUid( localUID ); | 1345 | KABC::Addressee addr = mAddressBook->findByUid( localUID ); |
1342 | if ( !addr.isEmpty() ) { | 1346 | if ( !addr.isEmpty() ) { |
1343 | mEditorDialog->setAddressee( addr ); | 1347 | mEditorDialog->setAddressee( addr ); |
1344 | KApplication::execDialog ( mEditorDialog ); | 1348 | KApplication::execDialog ( mEditorDialog ); |
1345 | } | 1349 | } |
1346 | } | 1350 | } |
1347 | 1351 | ||
1348 | /** | 1352 | /** |
1349 | Shows or edits the detail view for the given uid. If the uid is QString::null, | 1353 | 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. | 1354 | the method will try to find a selected addressee in the view. |
1351 | */ | 1355 | */ |
1352 | void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) | 1356 | void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) |
1353 | { | 1357 | { |
1354 | if ( mMultipleViewsAtOnce ) | 1358 | if ( mMultipleViewsAtOnce ) |
1355 | { | 1359 | { |
1356 | editContact( uid ); | 1360 | editContact( uid ); |
1357 | } | 1361 | } |
1358 | else | 1362 | else |
1359 | { | 1363 | { |
1360 | setDetailsVisible( true ); | 1364 | setDetailsVisible( true ); |
1361 | mActionDetails->setChecked(true); | 1365 | mActionDetails->setChecked(true); |
1362 | } | 1366 | } |
1363 | 1367 | ||
1364 | } | 1368 | } |
1365 | 1369 | ||
1366 | void KABCore::save() | 1370 | void KABCore::save() |
1367 | { | 1371 | { |
1368 | if (syncManager->blockSave()) | 1372 | if (syncManager->blockSave()) |
1369 | return; | 1373 | return; |
1370 | if ( !mModified ) | 1374 | if ( !mModified ) |
1371 | return; | 1375 | return; |
1372 | 1376 | ||
1373 | syncManager->setBlockSave(true); | 1377 | syncManager->setBlockSave(true); |
1374 | QString text = i18n( "There was an error while attempting to save\n the " | 1378 | QString text = i18n( "There was an error while attempting to save\n the " |
1375 | "address book. Please check that some \nother application is " | 1379 | "address book. Please check that some \nother application is " |
1376 | "not using it. " ); | 1380 | "not using it. " ); |
1377 | message(i18n("Saving ... please wait! "), false); | 1381 | message(i18n("Saving ... please wait! "), false); |
1378 | //qApp->processEvents(); | 1382 | //qApp->processEvents(); |
1379 | #ifndef KAB_EMBEDDED | 1383 | #ifndef KAB_EMBEDDED |
1380 | KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); | 1384 | KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); |
1381 | if ( !b || !b->save() ) { | 1385 | if ( !b || !b->save() ) { |
1382 | KMessageBox::error( this, text, i18n( "Unable to Save" ) ); | 1386 | KMessageBox::error( this, text, i18n( "Unable to Save" ) ); |
@@ -2524,385 +2528,386 @@ void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString | |||
2524 | QString anni; | 2528 | QString anni; |
2525 | QString formattedbday; | 2529 | QString formattedbday; |
2526 | 2530 | ||
2527 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) | 2531 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) |
2528 | { | 2532 | { |
2529 | if ( ! bar.isVisible() ) | 2533 | if ( ! bar.isVisible() ) |
2530 | return; | 2534 | return; |
2531 | bar.setProgress( count++ ); | 2535 | bar.setProgress( count++ ); |
2532 | qApp->processEvents(); | 2536 | qApp->processEvents(); |
2533 | bday = (*it).birthday().date(); | 2537 | bday = (*it).birthday().date(); |
2534 | anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" ); | 2538 | anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" ); |
2535 | 2539 | ||
2536 | if ( bday.isValid() || !anni.isEmpty()) | 2540 | if ( bday.isValid() || !anni.isEmpty()) |
2537 | { | 2541 | { |
2538 | if (bday.isValid()) | 2542 | if (bday.isValid()) |
2539 | formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate); | 2543 | formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate); |
2540 | else | 2544 | else |
2541 | formattedbday = "NOTVALID"; | 2545 | formattedbday = "NOTVALID"; |
2542 | if (anni.isEmpty()) | 2546 | if (anni.isEmpty()) |
2543 | anni = "INVALID"; | 2547 | anni = "INVALID"; |
2544 | 2548 | ||
2545 | birthdayList.append(formattedbday); | 2549 | birthdayList.append(formattedbday); |
2546 | anniversaryList.append(anni); //should be ISODate | 2550 | anniversaryList.append(anni); //should be ISODate |
2547 | realNameList.append((*it).realName()); | 2551 | realNameList.append((*it).realName()); |
2548 | preferredEmailList.append((*it).preferredEmail()); | 2552 | preferredEmailList.append((*it).preferredEmail()); |
2549 | assembledNameList.append((*it).assembledName()); | 2553 | assembledNameList.append((*it).assembledName()); |
2550 | uidList.append((*it).uid()); | 2554 | uidList.append((*it).uid()); |
2551 | 2555 | ||
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() ); | 2556 | //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() ); |
2553 | } | 2557 | } |
2554 | } | 2558 | } |
2555 | 2559 | ||
2556 | bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList); | 2560 | bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList); |
2557 | 2561 | ||
2558 | } | 2562 | } |
2559 | 2563 | ||
2560 | /* this method will be called through the QCop interface from other apps to show details of a contact. | 2564 | /* this method will be called through the QCop interface from other apps to show details of a contact. |
2561 | */ | 2565 | */ |
2562 | void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) | 2566 | void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) |
2563 | { | 2567 | { |
2564 | //qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); | 2568 | //qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); |
2565 | 2569 | ||
2566 | QString foundUid = QString::null; | 2570 | QString foundUid = QString::null; |
2567 | if ( ! uid.isEmpty() ) { | 2571 | if ( ! uid.isEmpty() ) { |
2568 | Addressee adrr = mAddressBook->findByUid( uid ); | 2572 | Addressee adrr = mAddressBook->findByUid( uid ); |
2569 | if ( !adrr.isEmpty() ) { | 2573 | if ( !adrr.isEmpty() ) { |
2570 | foundUid = uid; | 2574 | foundUid = uid; |
2571 | } | 2575 | } |
2572 | if ( email == "sendbacklist" ) { | 2576 | if ( email == "sendbacklist" ) { |
2573 | //qDebug("ssssssssssssssssssssssend "); | 2577 | //qDebug("ssssssssssssssssssssssend "); |
2574 | QStringList nameList; | 2578 | QStringList nameList; |
2575 | QStringList emailList; | 2579 | QStringList emailList; |
2576 | QStringList uidList; | 2580 | QStringList uidList; |
2577 | nameList.append(adrr.realName()); | 2581 | nameList.append(adrr.realName()); |
2578 | emailList = adrr.emails(); | 2582 | emailList = adrr.emails(); |
2579 | uidList.append( adrr.preferredEmail()); | 2583 | uidList.append( adrr.preferredEmail()); |
2580 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); | 2584 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); |
2581 | return; | 2585 | return; |
2582 | } | 2586 | } |
2583 | 2587 | ||
2584 | } | 2588 | } |
2585 | 2589 | ||
2586 | if ( email == "sendbacklist" ) | 2590 | if ( email == "sendbacklist" ) |
2587 | return; | 2591 | return; |
2588 | if (foundUid.isEmpty()) | 2592 | if (foundUid.isEmpty()) |
2589 | { | 2593 | { |
2590 | //find the uid of the person first | 2594 | //find the uid of the person first |
2591 | Addressee::List namelist; | 2595 | Addressee::List namelist; |
2592 | Addressee::List emaillist; | 2596 | Addressee::List emaillist; |
2593 | 2597 | ||
2594 | if (!name.isEmpty()) | 2598 | if (!name.isEmpty()) |
2595 | namelist = mAddressBook->findByName( name ); | 2599 | namelist = mAddressBook->findByName( name ); |
2596 | 2600 | ||
2597 | if (!email.isEmpty()) | 2601 | if (!email.isEmpty()) |
2598 | emaillist = mAddressBook->findByEmail( email ); | 2602 | emaillist = mAddressBook->findByEmail( email ); |
2599 | //qDebug("count %d %d ", namelist.count(),emaillist.count() ); | 2603 | //qDebug("count %d %d ", namelist.count(),emaillist.count() ); |
2600 | //check if we have a match in Namelist and Emaillist | 2604 | //check if we have a match in Namelist and Emaillist |
2601 | if ((namelist.count() == 0) && (emaillist.count() > 0)) { | 2605 | if ((namelist.count() == 0) && (emaillist.count() > 0)) { |
2602 | foundUid = emaillist[0].uid(); | 2606 | foundUid = emaillist[0].uid(); |
2603 | } | 2607 | } |
2604 | else if ((namelist.count() > 0) && (emaillist.count() == 0)) | 2608 | else if ((namelist.count() > 0) && (emaillist.count() == 0)) |
2605 | foundUid = namelist[0].uid(); | 2609 | foundUid = namelist[0].uid(); |
2606 | else | 2610 | else |
2607 | { | 2611 | { |
2608 | for (int i = 0; i < namelist.count(); i++) | 2612 | for (int i = 0; i < namelist.count(); i++) |
2609 | { | 2613 | { |
2610 | for (int j = 0; j < emaillist.count(); j++) | 2614 | for (int j = 0; j < emaillist.count(); j++) |
2611 | { | 2615 | { |
2612 | if (namelist[i] == emaillist[j]) | 2616 | if (namelist[i] == emaillist[j]) |
2613 | { | 2617 | { |
2614 | foundUid = namelist[i].uid(); | 2618 | foundUid = namelist[i].uid(); |
2615 | } | 2619 | } |
2616 | } | 2620 | } |
2617 | } | 2621 | } |
2618 | } | 2622 | } |
2619 | } | 2623 | } |
2620 | else | 2624 | else |
2621 | { | 2625 | { |
2622 | foundUid = uid; | 2626 | foundUid = uid; |
2623 | } | 2627 | } |
2624 | 2628 | ||
2625 | if (!foundUid.isEmpty()) | 2629 | if (!foundUid.isEmpty()) |
2626 | { | 2630 | { |
2627 | 2631 | ||
2628 | // raise Ka/Pi if it is in the background | 2632 | // raise Ka/Pi if it is in the background |
2629 | #ifndef DESKTOP_VERSION | 2633 | #ifndef DESKTOP_VERSION |
2630 | #ifndef KORG_NODCOP | 2634 | #ifndef KORG_NODCOP |
2631 | //QCopEnvelope e("QPE/Application/kapi", "raise()"); | 2635 | //QCopEnvelope e("QPE/Application/kapi", "raise()"); |
2632 | #endif | 2636 | #endif |
2633 | #endif | 2637 | #endif |
2634 | 2638 | ||
2635 | mMainWindow->showMaximized(); | 2639 | mMainWindow->showMaximized(); |
2636 | mMainWindow-> raise(); | 2640 | mMainWindow-> raise(); |
2637 | 2641 | ||
2638 | mViewManager->setSelected( "", false); | 2642 | mViewManager->setSelected( "", false); |
2639 | mViewManager->refreshView( "" ); | 2643 | mViewManager->refreshView( "" ); |
2640 | mViewManager->setSelected( foundUid, true ); | 2644 | mViewManager->setSelected( foundUid, true ); |
2641 | mViewManager->refreshView( foundUid ); | 2645 | mViewManager->refreshView( foundUid ); |
2642 | 2646 | ||
2643 | if ( !mMultipleViewsAtOnce ) | 2647 | if ( !mMultipleViewsAtOnce ) |
2644 | { | 2648 | { |
2645 | setDetailsVisible( true ); | 2649 | setDetailsVisible( true ); |
2646 | mActionDetails->setChecked(true); | 2650 | mActionDetails->setChecked(true); |
2647 | } | 2651 | } |
2648 | } | 2652 | } |
2649 | } | 2653 | } |
2650 | 2654 | ||
2651 | void KABCore::whatsnew() | 2655 | void KABCore::whatsnew() |
2652 | { | 2656 | { |
2653 | KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); | 2657 | KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); |
2654 | } | 2658 | } |
2655 | void KABCore::synchowto() | 2659 | void KABCore::synchowto() |
2656 | { | 2660 | { |
2657 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); | 2661 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); |
2658 | } | 2662 | } |
2659 | void KABCore::kdesynchowto() | 2663 | void KABCore::kdesynchowto() |
2660 | { | 2664 | { |
2661 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" ); | 2665 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" ); |
2662 | } | 2666 | } |
2663 | void KABCore::multisynchowto() | 2667 | void KABCore::multisynchowto() |
2664 | { | 2668 | { |
2665 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" ); | 2669 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" ); |
2666 | } | 2670 | } |
2667 | void KABCore::faq() | 2671 | void KABCore::faq() |
2668 | { | 2672 | { |
2669 | KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); | 2673 | KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); |
2670 | } | 2674 | } |
2671 | 2675 | ||
2672 | #include <libkcal/syncdefines.h> | 2676 | #include <libkcal/syncdefines.h> |
2673 | 2677 | ||
2674 | KABC::Addressee KABCore::getLastSyncAddressee() | 2678 | KABC::Addressee KABCore::getLastSyncAddressee() |
2675 | { | 2679 | { |
2676 | Addressee lse; | 2680 | Addressee lse; |
2677 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2681 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2678 | 2682 | ||
2679 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 2683 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
2680 | lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); | 2684 | lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); |
2681 | if (lse.isEmpty()) { | 2685 | if (lse.isEmpty()) { |
2682 | qDebug("Creating new last-syncAddressee "); | 2686 | qDebug("Creating new last-syncAddressee "); |
2683 | lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); | 2687 | lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); |
2684 | QString sum = ""; | 2688 | QString sum = ""; |
2685 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 2689 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
2686 | sum = "E: "; | 2690 | sum = "E: "; |
2687 | lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); | 2691 | lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); |
2688 | lse.setRevision( mLastAddressbookSync ); | 2692 | lse.setRevision( mLastAddressbookSync ); |
2689 | lse.setCategories( i18n("SyncEvent") ); | 2693 | lse.setCategories( i18n("SyncEvent") ); |
2690 | mAddressBook->insertAddressee( lse ); | 2694 | mAddressBook->insertAddressee( lse ); |
2691 | } | 2695 | } |
2692 | return lse; | 2696 | return lse; |
2693 | } | 2697 | } |
2694 | int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) | 2698 | int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) |
2695 | { | 2699 | { |
2696 | 2700 | ||
2697 | //void setZaurusId(int id); | 2701 | //void setZaurusId(int id); |
2698 | // int zaurusId() const; | 2702 | // int zaurusId() const; |
2699 | // void setZaurusUid(int id); | 2703 | // void setZaurusUid(int id); |
2700 | // int zaurusUid() const; | 2704 | // int zaurusUid() const; |
2701 | // void setZaurusStat(int id); | 2705 | // void setZaurusStat(int id); |
2702 | // int zaurusStat() const; | 2706 | // int zaurusStat() const; |
2703 | // 0 equal | 2707 | // 0 equal |
2704 | // 1 take local | 2708 | // 1 take local |
2705 | // 2 take remote | 2709 | // 2 take remote |
2706 | // 3 cancel | 2710 | // 3 cancel |
2707 | QDateTime lastSync = mLastAddressbookSync; | 2711 | QDateTime lastSync = mLastAddressbookSync; |
2708 | QDateTime localMod = local->revision(); | 2712 | QDateTime localMod = local->revision(); |
2709 | QDateTime remoteMod = remote->revision(); | 2713 | QDateTime remoteMod = remote->revision(); |
2710 | 2714 | ||
2711 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2715 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2712 | 2716 | ||
2713 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2717 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2714 | bool remCh, locCh; | 2718 | bool remCh, locCh; |
2715 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 2719 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
2716 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 2720 | if ( remCh ) |
2721 | qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | ||
2717 | locCh = ( localMod > mLastAddressbookSync ); | 2722 | locCh = ( localMod > mLastAddressbookSync ); |
2718 | //qDebug("cahnged rem %d loc %d",remCh, locCh ); | 2723 | //qDebug("cahnged rem %d loc %d",remCh, locCh ); |
2719 | if ( !remCh && ! locCh ) { | 2724 | if ( !remCh && ! locCh ) { |
2720 | //qDebug("both not changed "); | 2725 | //qDebug("both not changed "); |
2721 | lastSync = localMod.addDays(1); | 2726 | lastSync = localMod.addDays(1); |
2722 | if ( mode <= SYNC_PREF_ASK ) | 2727 | if ( mode <= SYNC_PREF_ASK ) |
2723 | return 0; | 2728 | return 0; |
2724 | } else { | 2729 | } else { |
2725 | if ( locCh ) { | 2730 | if ( locCh ) { |
2726 | //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); | 2731 | //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); |
2727 | lastSync = localMod.addDays( -1 ); | 2732 | lastSync = localMod.addDays( -1 ); |
2728 | if ( !remCh ) | 2733 | if ( !remCh ) |
2729 | remoteMod =( lastSync.addDays( -1 ) ); | 2734 | remoteMod =( lastSync.addDays( -1 ) ); |
2730 | } else { | 2735 | } else { |
2731 | //qDebug(" not loc changed "); | 2736 | //qDebug(" not loc changed "); |
2732 | lastSync = localMod.addDays( 1 ); | 2737 | lastSync = localMod.addDays( 1 ); |
2733 | if ( remCh ) { | 2738 | if ( remCh ) { |
2734 | //qDebug("rem changed "); | 2739 | //qDebug("rem changed "); |
2735 | remoteMod =( lastSync.addDays( 1 ) ); | 2740 | remoteMod =( lastSync.addDays( 1 ) ); |
2736 | } | 2741 | } |
2737 | 2742 | ||
2738 | } | 2743 | } |
2739 | } | 2744 | } |
2740 | full = true; | 2745 | full = true; |
2741 | if ( mode < SYNC_PREF_ASK ) | 2746 | if ( mode < SYNC_PREF_ASK ) |
2742 | mode = SYNC_PREF_ASK; | 2747 | mode = SYNC_PREF_ASK; |
2743 | } else { | 2748 | } else { |
2744 | if ( localMod == remoteMod ) | 2749 | if ( localMod == remoteMod ) |
2745 | return 0; | 2750 | return 0; |
2746 | 2751 | ||
2747 | } | 2752 | } |
2748 | //qDebug("%s %s --- %d %d", localMod.toString().latin1() , remoteMod.toString().latin1(), localMod.time().msec(), remoteMod.time().msec()); | 2753 | //qDebug("%s %s --- %d %d", localMod.toString().latin1() , remoteMod.toString().latin1(), localMod.time().msec(), remoteMod.time().msec()); |
2749 | //qDebug("lastsync %s ", lastSync.toString().latin1() ); | 2754 | //qDebug("lastsync %s ", lastSync.toString().latin1() ); |
2750 | //full = true; //debug only | 2755 | //full = true; //debug only |
2751 | if ( full ) { | 2756 | if ( full ) { |
2752 | bool equ = ( (*local) == (*remote) ); | 2757 | bool equ = ( (*local) == (*remote) ); |
2753 | if ( equ ) { | 2758 | if ( equ ) { |
2754 | //qDebug("equal "); | 2759 | //qDebug("equal "); |
2755 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2760 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2756 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 2761 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
2757 | } | 2762 | } |
2758 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 2763 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
2759 | return 0; | 2764 | return 0; |
2760 | 2765 | ||
2761 | }//else //debug only | 2766 | }//else //debug only |
2762 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 2767 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
2763 | } | 2768 | } |
2764 | int result; | 2769 | int result; |
2765 | bool localIsNew; | 2770 | bool localIsNew; |
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() ); | 2771 | //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() ); |
2767 | 2772 | ||
2768 | if ( full && mode < SYNC_PREF_NEWEST ) | 2773 | if ( full && mode < SYNC_PREF_NEWEST ) |
2769 | mode = SYNC_PREF_ASK; | 2774 | mode = SYNC_PREF_ASK; |
2770 | 2775 | ||
2771 | switch( mode ) { | 2776 | switch( mode ) { |
2772 | case SYNC_PREF_LOCAL: | 2777 | case SYNC_PREF_LOCAL: |
2773 | if ( lastSync > remoteMod ) | 2778 | if ( lastSync > remoteMod ) |
2774 | return 1; | 2779 | return 1; |
2775 | if ( lastSync > localMod ) | 2780 | if ( lastSync > localMod ) |
2776 | return 2; | 2781 | return 2; |
2777 | return 1; | 2782 | return 1; |
2778 | break; | 2783 | break; |
2779 | case SYNC_PREF_REMOTE: | 2784 | case SYNC_PREF_REMOTE: |
2780 | if ( lastSync > remoteMod ) | 2785 | if ( lastSync > remoteMod ) |
2781 | return 1; | 2786 | return 1; |
2782 | if ( lastSync > localMod ) | 2787 | if ( lastSync > localMod ) |
2783 | return 2; | 2788 | return 2; |
2784 | return 2; | 2789 | return 2; |
2785 | break; | 2790 | break; |
2786 | case SYNC_PREF_NEWEST: | 2791 | case SYNC_PREF_NEWEST: |
2787 | if ( localMod > remoteMod ) | 2792 | if ( localMod > remoteMod ) |
2788 | return 1; | 2793 | return 1; |
2789 | else | 2794 | else |
2790 | return 2; | 2795 | return 2; |
2791 | break; | 2796 | break; |
2792 | case SYNC_PREF_ASK: | 2797 | case SYNC_PREF_ASK: |
2793 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 2798 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
2794 | if ( lastSync > remoteMod ) | 2799 | if ( lastSync > remoteMod ) |
2795 | return 1; | 2800 | return 1; |
2796 | if ( lastSync > localMod ) { | 2801 | if ( lastSync > localMod ) { |
2797 | return 2; | 2802 | return 2; |
2798 | } | 2803 | } |
2799 | localIsNew = localMod >= remoteMod; | 2804 | localIsNew = localMod >= remoteMod; |
2800 | //qDebug("conflict! ************************************** "); | 2805 | //qDebug("conflict! ************************************** "); |
2801 | { | 2806 | { |
2802 | KABC::AddresseeChooser acd ( *local,*remote, localIsNew , this ); | 2807 | KABC::AddresseeChooser acd ( *local,*remote, localIsNew , this ); |
2803 | result = acd.executeD(localIsNew); | 2808 | result = acd.executeD(localIsNew); |
2804 | return result; | 2809 | return result; |
2805 | } | 2810 | } |
2806 | break; | 2811 | break; |
2807 | case SYNC_PREF_FORCE_LOCAL: | 2812 | case SYNC_PREF_FORCE_LOCAL: |
2808 | return 1; | 2813 | return 1; |
2809 | break; | 2814 | break; |
2810 | case SYNC_PREF_FORCE_REMOTE: | 2815 | case SYNC_PREF_FORCE_REMOTE: |
2811 | return 2; | 2816 | return 2; |
2812 | break; | 2817 | break; |
2813 | 2818 | ||
2814 | default: | 2819 | default: |
2815 | // SYNC_PREF_TAKE_BOTH not implemented | 2820 | // SYNC_PREF_TAKE_BOTH not implemented |
2816 | break; | 2821 | break; |
2817 | } | 2822 | } |
2818 | return 0; | 2823 | return 0; |
2819 | } | 2824 | } |
2820 | 2825 | ||
2821 | 2826 | ||
2822 | bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) | 2827 | bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) |
2823 | { | 2828 | { |
2824 | bool syncOK = true; | 2829 | bool syncOK = true; |
2825 | int addedAddressee = 0; | 2830 | int addedAddressee = 0; |
2826 | int addedAddresseeR = 0; | 2831 | int addedAddresseeR = 0; |
2827 | int deletedAddresseeR = 0; | 2832 | int deletedAddresseeR = 0; |
2828 | int deletedAddresseeL = 0; | 2833 | int deletedAddresseeL = 0; |
2829 | int changedLocal = 0; | 2834 | int changedLocal = 0; |
2830 | int changedRemote = 0; | 2835 | int changedRemote = 0; |
2831 | int filteredIN = 0; | 2836 | int filteredIN = 0; |
2832 | int filteredOUT = 0; | 2837 | int filteredOUT = 0; |
2833 | 2838 | ||
2834 | QString mCurrentSyncName = syncManager->getCurrentSyncName(); | 2839 | QString mCurrentSyncName = syncManager->getCurrentSyncName(); |
2835 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2840 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2836 | 2841 | ||
2837 | //QPtrList<Addressee> el = local->rawAddressees(); | 2842 | //QPtrList<Addressee> el = local->rawAddressees(); |
2838 | Addressee addresseeR; | 2843 | Addressee addresseeR; |
2839 | QString uid; | 2844 | QString uid; |
2840 | int take; | 2845 | int take; |
2841 | Addressee addresseeL; | 2846 | Addressee addresseeL; |
2842 | Addressee addresseeRSync; | 2847 | Addressee addresseeRSync; |
2843 | Addressee addresseeLSync; | 2848 | Addressee addresseeLSync; |
2844 | // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); | 2849 | // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); |
2845 | //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); | 2850 | //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); |
2846 | bool fullDateRange = false; | 2851 | bool fullDateRange = false; |
2847 | local->resetTempSyncStat(); | 2852 | local->resetTempSyncStat(); |
2848 | mLastAddressbookSync = QDateTime::currentDateTime(); | 2853 | mLastAddressbookSync = QDateTime::currentDateTime(); |
2849 | if ( syncManager->syncWithDesktop() ) { | 2854 | if ( syncManager->syncWithDesktop() ) { |
2850 | // remote->removeSyncInfo( QString());//remove all info | 2855 | // remote->removeSyncInfo( QString());//remove all info |
2851 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { | 2856 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { |
2852 | mLastAddressbookSync = KSyncManager::mRequestedSyncEvent; | 2857 | mLastAddressbookSync = KSyncManager::mRequestedSyncEvent; |
2853 | qDebug("using extern time for calendar sync: %s ", mLastAddressbookSync.toString().latin1() ); | 2858 | qDebug("using extern time for calendar sync: %s ", mLastAddressbookSync.toString().latin1() ); |
2854 | } else { | 2859 | } else { |
2855 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); | 2860 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); |
2856 | } | 2861 | } |
2857 | } | 2862 | } |
2858 | QDateTime modifiedCalendar = mLastAddressbookSync; | 2863 | QDateTime modifiedCalendar = mLastAddressbookSync; |
2859 | addresseeLSync = getLastSyncAddressee(); | 2864 | addresseeLSync = getLastSyncAddressee(); |
2860 | qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); | 2865 | qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); |
2861 | addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); | 2866 | addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); |
2862 | if ( !addresseeR.isEmpty() ) { | 2867 | if ( !addresseeR.isEmpty() ) { |
2863 | addresseeRSync = addresseeR; | 2868 | addresseeRSync = addresseeR; |
2864 | remote->removeAddressee(addresseeR ); | 2869 | remote->removeAddressee(addresseeR ); |
2865 | 2870 | ||
2866 | } else { | 2871 | } else { |
2867 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2872 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2868 | addresseeRSync = addresseeLSync ; | 2873 | addresseeRSync = addresseeLSync ; |
2869 | } else { | 2874 | } else { |
2870 | //qDebug("FULLDATE 1"); | 2875 | //qDebug("FULLDATE 1"); |
2871 | fullDateRange = true; | 2876 | fullDateRange = true; |
2872 | Addressee newAdd; | 2877 | Addressee newAdd; |
2873 | addresseeRSync = newAdd; | 2878 | addresseeRSync = newAdd; |
2874 | addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); | 2879 | addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); |
2875 | addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); | 2880 | addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); |
2876 | addresseeRSync.setRevision( mLastAddressbookSync ); | 2881 | addresseeRSync.setRevision( mLastAddressbookSync ); |
2877 | addresseeRSync.setCategories( i18n("SyncAddressee") ); | 2882 | addresseeRSync.setCategories( i18n("SyncAddressee") ); |
2878 | } | 2883 | } |
2879 | } | 2884 | } |
2880 | if ( addresseeLSync.revision() == mLastAddressbookSync ) { | 2885 | if ( addresseeLSync.revision() == mLastAddressbookSync ) { |
2881 | // qDebug("FULLDATE 2"); | 2886 | // qDebug("FULLDATE 2"); |
2882 | fullDateRange = true; | 2887 | fullDateRange = true; |
2883 | } | 2888 | } |
2884 | if ( ! fullDateRange ) { | 2889 | if ( ! fullDateRange ) { |
2885 | if ( addresseeLSync.revision() != addresseeRSync.revision() ) { | 2890 | if ( addresseeLSync.revision() != addresseeRSync.revision() ) { |
2886 | 2891 | ||
2887 | // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); | 2892 | // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); |
2888 | //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); | 2893 | //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); |
2889 | fullDateRange = true; | 2894 | fullDateRange = true; |
2890 | //qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); | 2895 | //qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); |
2891 | } | 2896 | } |
2892 | } | 2897 | } |
2893 | // fullDateRange = true; // debug only! | 2898 | // fullDateRange = true; // debug only! |
2894 | if ( fullDateRange ) | 2899 | if ( fullDateRange ) |
2895 | mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); | 2900 | mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); |
2896 | else | 2901 | else |
2897 | mLastAddressbookSync = addresseeLSync.revision(); | 2902 | mLastAddressbookSync = addresseeLSync.revision(); |
2898 | // for resyncing if own file has changed | 2903 | // for resyncing if own file has changed |
2899 | // PENDING fixme later when implemented | 2904 | // PENDING fixme later when implemented |
2900 | #if 0 | 2905 | #if 0 |
2901 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 2906 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
2902 | mLastAddressbookSync = loadedFileVersion; | 2907 | mLastAddressbookSync = loadedFileVersion; |
2903 | qDebug("setting mLastAddressbookSync "); | 2908 | qDebug("setting mLastAddressbookSync "); |
2904 | } | 2909 | } |
2905 | #endif | 2910 | #endif |
2906 | 2911 | ||
2907 | 2912 | ||
2908 | // ********** setting filters **************** | 2913 | // ********** setting filters **************** |
diff --git a/kaddressbook/views/kaddressbooktableview.cpp b/kaddressbook/views/kaddressbooktableview.cpp index ecd6f05..7022dcb 100644 --- a/kaddressbook/views/kaddressbooktableview.cpp +++ b/kaddressbook/views/kaddressbooktableview.cpp | |||
@@ -1,352 +1,352 @@ | |||
1 | // $Id$ | 1 | // $Id$ |
2 | 2 | ||
3 | #include <qvbox.h> | 3 | #include <qvbox.h> |
4 | #include <qlistbox.h> | 4 | #include <qlistbox.h> |
5 | #include <qwidget.h> | 5 | #include <qwidget.h> |
6 | #include <qfile.h> | 6 | #include <qfile.h> |
7 | #include <qimage.h> | 7 | #include <qimage.h> |
8 | #include <qcombobox.h> | 8 | #include <qcombobox.h> |
9 | #include <qapplication.h> | 9 | #include <qapplication.h> |
10 | #include <qdragobject.h> | 10 | #include <qdragobject.h> |
11 | #include <qevent.h> | 11 | #include <qevent.h> |
12 | #include <qurl.h> | 12 | #include <qurl.h> |
13 | #include <qpixmap.h> | 13 | #include <qpixmap.h> |
14 | 14 | ||
15 | #include <kabc/addressbook.h> | 15 | #include <kabc/addressbook.h> |
16 | #include <kapplication.h> | 16 | #include <kapplication.h> |
17 | #include <kconfig.h> | 17 | #include <kconfig.h> |
18 | #include <kcolorbutton.h> | 18 | #include <kcolorbutton.h> |
19 | #include <kdebug.h> | 19 | #include <kdebug.h> |
20 | #include <kglobal.h> | 20 | #include <kglobal.h> |
21 | #include <kiconloader.h> | 21 | #include <kiconloader.h> |
22 | #include <klineedit.h> | 22 | #include <klineedit.h> |
23 | #include <klocale.h> | 23 | #include <klocale.h> |
24 | #include <kmessagebox.h> | 24 | #include <kmessagebox.h> |
25 | #include <kurl.h> | 25 | #include <kurl.h> |
26 | #include <kurlrequester.h> | 26 | #include <kurlrequester.h> |
27 | 27 | ||
28 | //US#include "configuretableviewdialog.h" | 28 | //US#include "configuretableviewdialog.h" |
29 | #include "contactlistview.h" | 29 | #include "contactlistview.h" |
30 | #include "kabprefs.h" | 30 | #include "kabprefs.h" |
31 | #include "undocmds.h" | 31 | #include "undocmds.h" |
32 | #include "viewmanager.h" | 32 | #include "viewmanager.h" |
33 | 33 | ||
34 | #include <qlayout.h> | 34 | #include <qlayout.h> |
35 | #include <qheader.h> | 35 | #include <qheader.h> |
36 | #include <qregexp.h> | 36 | #include <qregexp.h> |
37 | 37 | ||
38 | #include "kaddressbooktableview.h" | 38 | #include "kaddressbooktableview.h" |
39 | 39 | ||
40 | 40 | ||
41 | KAddressBookTableView::KAddressBookTableView( KABC::AddressBook *ab, | 41 | KAddressBookTableView::KAddressBookTableView( KABC::AddressBook *ab, |
42 | QWidget *parent, const char *name ) | 42 | QWidget *parent, const char *name ) |
43 | : KAddressBookView( ab, parent, name ) | 43 | : KAddressBookView( ab, parent, name ) |
44 | { | 44 | { |
45 | mainLayout = new QVBoxLayout( viewWidget(), 2 ); | 45 | mainLayout = new QVBoxLayout( viewWidget(), 2 ); |
46 | 46 | ||
47 | // The list view will be created when the config is read. | 47 | // The list view will be created when the config is read. |
48 | mListView = 0; | 48 | mListView = 0; |
49 | } | 49 | } |
50 | 50 | ||
51 | KAddressBookTableView::~KAddressBookTableView() | 51 | KAddressBookTableView::~KAddressBookTableView() |
52 | { | 52 | { |
53 | } | 53 | } |
54 | void KAddressBookTableView::setFocusAV() | 54 | void KAddressBookTableView::setFocusAV() |
55 | { | 55 | { |
56 | if ( mListView ) | 56 | if ( mListView ) |
57 | mListView->setFocus(); | 57 | mListView->setFocus(); |
58 | 58 | ||
59 | } | 59 | } |
60 | void KAddressBookTableView::scrollUP() | 60 | void KAddressBookTableView::scrollUP() |
61 | { | 61 | { |
62 | QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Up, 0,0 ); | 62 | QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Up, 0,0 ); |
63 | QApplication::postEvent( mListView, ev ); | 63 | QApplication::postEvent( mListView, ev ); |
64 | } | 64 | } |
65 | void KAddressBookTableView::scrollDOWN() | 65 | void KAddressBookTableView::scrollDOWN() |
66 | { | 66 | { |
67 | QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Down, 0,0 ); | 67 | QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Down, 0,0 ); |
68 | QApplication::postEvent( mListView, ev ); | 68 | QApplication::postEvent( mListView, ev ); |
69 | } | 69 | } |
70 | void KAddressBookTableView::reconstructListView() | 70 | void KAddressBookTableView::reconstructListView() |
71 | { | 71 | { |
72 | if (mListView) | 72 | if (mListView) |
73 | { | 73 | { |
74 | disconnect(mListView, SIGNAL(selectionChanged()), | 74 | disconnect(mListView, SIGNAL(selectionChanged()), |
75 | this, SLOT(addresseeSelected())); | 75 | this, SLOT(addresseeSelected())); |
76 | disconnect(mListView, SIGNAL(executed(QListViewItem*)), | 76 | disconnect(mListView, SIGNAL(executed(QListViewItem*)), |
77 | this, SLOT(addresseeExecuted(QListViewItem*))); | 77 | this, SLOT(addresseeExecuted(QListViewItem*))); |
78 | disconnect(mListView, SIGNAL(doubleClicked(QListViewItem*)), | 78 | disconnect(mListView, SIGNAL(doubleClicked(QListViewItem*)), |
79 | this, SLOT(addresseeExecuted(QListViewItem*))); | 79 | this, SLOT(addresseeExecuted(QListViewItem*))); |
80 | disconnect(mListView, SIGNAL(startAddresseeDrag()), this, | 80 | disconnect(mListView, SIGNAL(startAddresseeDrag()), this, |
81 | SIGNAL(startDrag())); | 81 | SIGNAL(startDrag())); |
82 | disconnect(mListView, SIGNAL(returnPressed(QListViewItem*)), | 82 | disconnect(mListView, SIGNAL(returnPressed(QListViewItem*)), |
83 | this, SLOT(addresseeExecuted(QListViewItem*))); | 83 | this, SLOT(addresseeExecuted(QListViewItem*))); |
84 | 84 | ||
85 | disconnect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this, | 85 | disconnect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this, |
86 | SIGNAL(dropped(QDropEvent*))); | 86 | SIGNAL(dropped(QDropEvent*))); |
87 | delete mListView; | 87 | delete mListView; |
88 | } | 88 | } |
89 | 89 | ||
90 | mListView = new ContactListView( this, addressBook(), viewWidget() ); | 90 | mListView = new ContactListView( this, addressBook(), viewWidget() ); |
91 | 91 | ||
92 | connect(this, SIGNAL(printView()), | 92 | connect(this, SIGNAL(printView()), |
93 | mListView , SLOT(printMe())); | 93 | mListView , SLOT(printMe())); |
94 | //US set singleClick manually, because it is no global configparameter in embedded space | 94 | //US set singleClick manually, because it is no global configparameter in embedded space |
95 | mListView->setSingleClick(KABPrefs::instance()->mHonorSingleClick); | 95 | mListView->setSingleClick(KABPrefs::instance()->mHonorSingleClick); |
96 | 96 | ||
97 | // Add the columns | 97 | // Add the columns |
98 | KABC::Field::List fieldList = fields(); | 98 | KABC::Field::List fieldList = fields(); |
99 | KABC::Field::List::ConstIterator it; | 99 | KABC::Field::List::ConstIterator it; |
100 | 100 | ||
101 | int c = 0; | 101 | int c = 0; |
102 | for( it = fieldList.begin(); it != fieldList.end(); ++it ) { | 102 | for( it = fieldList.begin(); it != fieldList.end(); ++it ) { |
103 | mListView->addColumn( (*it)->label() ); | 103 | mListView->addColumn( (*it)->label() ); |
104 | mListView->setColumnWidthMode(c++, QListView::Manual); | 104 | mListView->setColumnWidthMode(c++, QListView::Manual); |
105 | //US | 105 | //US |
106 | // qDebug("KAddressBookTableView::reconstructListView: field %s", (*it)->label().latin1()); | 106 | // qDebug("KAddressBookTableView::reconstructListView: field %s", (*it)->label().latin1()); |
107 | } | 107 | } |
108 | 108 | ||
109 | connect(mListView, SIGNAL(selectionChanged()), | 109 | connect(mListView, SIGNAL(selectionChanged()), |
110 | this, SLOT(addresseeSelected())); | 110 | this, SLOT(addresseeSelected())); |
111 | connect(mListView, SIGNAL(startAddresseeDrag()), this, | 111 | connect(mListView, SIGNAL(startAddresseeDrag()), this, |
112 | SIGNAL(startDrag())); | 112 | SIGNAL(startDrag())); |
113 | connect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this, | 113 | connect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this, |
114 | SIGNAL(dropped(QDropEvent*))); | 114 | SIGNAL(dropped(QDropEvent*))); |
115 | 115 | ||
116 | if (KABPrefs::instance()->mHonorSingleClick) { | 116 | if (KABPrefs::instance()->mHonorSingleClick) { |
117 | // qDebug("KAddressBookTableView::reconstructListView single"); | 117 | // qDebug("KAddressBookTableView::reconstructListView single"); |
118 | connect(mListView, SIGNAL(executed(QListViewItem*)), | 118 | connect(mListView, SIGNAL(executed(QListViewItem*)), |
119 | this, SLOT(addresseeExecuted(QListViewItem*))); | 119 | this, SLOT(addresseeExecuted(QListViewItem*))); |
120 | } else { | 120 | } else { |
121 | // qDebug("KAddressBookTableView::reconstructListView double"); | 121 | // qDebug("KAddressBookTableView::reconstructListView double"); |
122 | connect(mListView, SIGNAL(doubleClicked(QListViewItem*)), | 122 | connect(mListView, SIGNAL(doubleClicked(QListViewItem*)), |
123 | this, SLOT(addresseeExecuted(QListViewItem*))); | 123 | this, SLOT(addresseeExecuted(QListViewItem*))); |
124 | } | 124 | } |
125 | connect(mListView, SIGNAL(returnPressed(QListViewItem*)), | 125 | connect(mListView, SIGNAL(returnPressed(QListViewItem*)), |
126 | this, SLOT(addresseeExecuted(QListViewItem*))); | 126 | this, SLOT(addresseeExecuted(QListViewItem*))); |
127 | connect(mListView, SIGNAL(signalDelete()), | 127 | connect(mListView, SIGNAL(signalDelete()), |
128 | this, SLOT(addresseeDeleted())); | 128 | this, SLOT(addresseeDeleted())); |
129 | 129 | ||
130 | //US performceimprovement. Refresh is done from the outside | 130 | //US performceimprovement. Refresh is done from the outside |
131 | //US refresh(); | 131 | //US refresh(); |
132 | 132 | ||
133 | mListView->setSorting( 0, true ); | 133 | mListView->setSorting( 0, true ); |
134 | mainLayout->addWidget( mListView ); | 134 | mainLayout->addWidget( mListView ); |
135 | mainLayout->activate(); | 135 | mainLayout->activate(); |
136 | mListView->show(); | 136 | mListView->show(); |
137 | } | 137 | } |
138 | 138 | ||
139 | void KAddressBookTableView::doSearch( const QString& s, KABC::Field *field ) | 139 | void KAddressBookTableView::doSearch( const QString& s, KABC::Field *field ) |
140 | { | 140 | { |
141 | mListView->clear(); | 141 | mListView->clear(); |
142 | if ( s.isEmpty() || s == "*" ) { | 142 | if ( s.isEmpty() || s == "*" ) { |
143 | refresh(); | 143 | refresh(); |
144 | return; | 144 | return; |
145 | } | 145 | } |
146 | QString pattern = s.lower()+"*"; | 146 | QString pattern = s.lower()+"*"; |
147 | QRegExp re; | 147 | QRegExp re; |
148 | re.setWildcard(true); // most people understand these better. | 148 | re.setWildcard(true); // most people understand these better. |
149 | re.setCaseSensitive(false); | 149 | re.setCaseSensitive(false); |
150 | re.setPattern( pattern ); | 150 | re.setPattern( pattern ); |
151 | if (!re.isValid()) | 151 | if (!re.isValid()) |
152 | return; | 152 | return; |
153 | KABC::Addressee::List addresseeList = addressees(); | 153 | KABC::Addressee::List addresseeList = addressees(); |
154 | KABC::Addressee::List::Iterator it; | 154 | KABC::Addressee::List::Iterator it; |
155 | if ( field ) { | 155 | if ( field ) { |
156 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { | 156 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { |
157 | if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) | 157 | if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) |
158 | continue; | 158 | continue; |
159 | #if QT_VERSION >= 300 | 159 | #if QT_VERSION >= 300 |
160 | if (re.search(field->value( *it ).lower()) != -1) | 160 | if (re.search(field->value( *it ).lower()) == 0) |
161 | #else | 161 | #else |
162 | if (re.match(field->value( *it ).lower()) != -1) | 162 | if (re.match(field->value( *it ).lower()) != -1) |
163 | #endif | 163 | #endif |
164 | ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); | 164 | ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); |
165 | 165 | ||
166 | } | 166 | } |
167 | } else { | 167 | } else { |
168 | KABC::Field::List fieldList = allFields(); | 168 | KABC::Field::List fieldList = allFields(); |
169 | KABC::Field::List::ConstIterator fieldIt; | 169 | KABC::Field::List::ConstIterator fieldIt; |
170 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { | 170 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { |
171 | if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) | 171 | if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) |
172 | continue; | 172 | continue; |
173 | for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { | 173 | for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { |
174 | #if QT_VERSION >= 300 | 174 | #if QT_VERSION >= 300 |
175 | if (re.search((*fieldIt)->value( *it ).lower()) != -1) | 175 | if (re.search((*fieldIt)->value( *it ).lower()) != -1) |
176 | #else | 176 | #else |
177 | if (re.match((*fieldIt)->value( *it ).lower()) != -1) | 177 | if (re.match((*fieldIt)->value( *it ).lower()) != -1) |
178 | #endif | 178 | #endif |
179 | { | 179 | { |
180 | ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); | 180 | ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); |
181 | break; | 181 | break; |
182 | } | 182 | } |
183 | } | 183 | } |
184 | } | 184 | } |
185 | } | 185 | } |
186 | // Sometimes the background pixmap gets messed up when we add lots | 186 | // Sometimes the background pixmap gets messed up when we add lots |
187 | // of items. | 187 | // of items. |
188 | mListView->repaint(); | 188 | mListView->repaint(); |
189 | if ( mListView->firstChild() ) { | 189 | if ( mListView->firstChild() ) { |
190 | mListView->setCurrentItem ( mListView->firstChild() ); | 190 | mListView->setCurrentItem ( mListView->firstChild() ); |
191 | mListView->setSelected ( mListView->firstChild(), true ); | 191 | mListView->setSelected ( mListView->firstChild(), true ); |
192 | } | 192 | } |
193 | else | 193 | else |
194 | emit selected(QString::null); | 194 | emit selected(QString::null); |
195 | 195 | ||
196 | } | 196 | } |
197 | void KAddressBookTableView::writeConfig(KConfig *config) | 197 | void KAddressBookTableView::writeConfig(KConfig *config) |
198 | { | 198 | { |
199 | KAddressBookView::writeConfig(config); | 199 | KAddressBookView::writeConfig(config); |
200 | 200 | ||
201 | mListView->saveLayout(config, config->group()); | 201 | mListView->saveLayout(config, config->group()); |
202 | } | 202 | } |
203 | 203 | ||
204 | void KAddressBookTableView::readConfig(KConfig *config) | 204 | void KAddressBookTableView::readConfig(KConfig *config) |
205 | { | 205 | { |
206 | KAddressBookView::readConfig( config ); | 206 | KAddressBookView::readConfig( config ); |
207 | // The config could have changed the fields, so we need to reconstruct | 207 | // The config could have changed the fields, so we need to reconstruct |
208 | // the listview. | 208 | // the listview. |
209 | reconstructListView(); | 209 | reconstructListView(); |
210 | 210 | ||
211 | // costum colors? | 211 | // costum colors? |
212 | if ( config->readBoolEntry( "EnableCustomColors", false ) ) | 212 | if ( config->readBoolEntry( "EnableCustomColors", false ) ) |
213 | { | 213 | { |
214 | QPalette p( mListView->palette() ); | 214 | QPalette p( mListView->palette() ); |
215 | QColor c = p.color(QPalette::Normal, QColorGroup::Base ); | 215 | QColor c = p.color(QPalette::Normal, QColorGroup::Base ); |
216 | p.setColor( QPalette::Normal, QColorGroup::Base, config->readColorEntry( "BackgroundColor", &c ) ); | 216 | p.setColor( QPalette::Normal, QColorGroup::Base, config->readColorEntry( "BackgroundColor", &c ) ); |
217 | c = p.color(QPalette::Normal, QColorGroup::Text ); | 217 | c = p.color(QPalette::Normal, QColorGroup::Text ); |
218 | p.setColor( QPalette::Normal, QColorGroup::Text, config->readColorEntry( "TextColor", &c ) ); | 218 | p.setColor( QPalette::Normal, QColorGroup::Text, config->readColorEntry( "TextColor", &c ) ); |
219 | c = p.color(QPalette::Normal, QColorGroup::Button ); | 219 | c = p.color(QPalette::Normal, QColorGroup::Button ); |
220 | p.setColor( QPalette::Normal, QColorGroup::Button, config->readColorEntry( "HeaderColor", &c ) ); | 220 | p.setColor( QPalette::Normal, QColorGroup::Button, config->readColorEntry( "HeaderColor", &c ) ); |
221 | c = p.color(QPalette::Normal, QColorGroup::ButtonText ); | 221 | c = p.color(QPalette::Normal, QColorGroup::ButtonText ); |
222 | p.setColor( QPalette::Normal, QColorGroup::ButtonText, config->readColorEntry( "HeaderTextColor", &c ) ); | 222 | p.setColor( QPalette::Normal, QColorGroup::ButtonText, config->readColorEntry( "HeaderTextColor", &c ) ); |
223 | c = p.color(QPalette::Normal, QColorGroup::Highlight ); | 223 | c = p.color(QPalette::Normal, QColorGroup::Highlight ); |
224 | p.setColor( QPalette::Normal, QColorGroup::Highlight, config->readColorEntry( "HighlightColor", &c ) ); | 224 | p.setColor( QPalette::Normal, QColorGroup::Highlight, config->readColorEntry( "HighlightColor", &c ) ); |
225 | c = p.color(QPalette::Normal, QColorGroup::HighlightedText ); | 225 | c = p.color(QPalette::Normal, QColorGroup::HighlightedText ); |
226 | p.setColor( QPalette::Normal, QColorGroup::HighlightedText, config->readColorEntry( "HighlightedTextColor", &c ) ); | 226 | p.setColor( QPalette::Normal, QColorGroup::HighlightedText, config->readColorEntry( "HighlightedTextColor", &c ) ); |
227 | #ifndef KAB_EMBEDDED | 227 | #ifndef KAB_EMBEDDED |
228 | c = KGlobalSettings::alternateBackgroundColor(); | 228 | c = KGlobalSettings::alternateBackgroundColor(); |
229 | #else //KAB_EMBEDDED | 229 | #else //KAB_EMBEDDED |
230 | c = QColor(240, 240, 240); | 230 | c = QColor(240, 240, 240); |
231 | #endif //KAB_EMBEDDED | 231 | #endif //KAB_EMBEDDED |
232 | c = config->readColorEntry ("AlternatingBackgroundColor", &c); | 232 | c = config->readColorEntry ("AlternatingBackgroundColor", &c); |
233 | mListView->setAlternateColor(c); | 233 | mListView->setAlternateColor(c); |
234 | 234 | ||
235 | 235 | ||
236 | //US mListView->viewport()->setPalette( p ); | 236 | //US mListView->viewport()->setPalette( p ); |
237 | mListView->setPalette( p ); | 237 | mListView->setPalette( p ); |
238 | } | 238 | } |
239 | else | 239 | else |
240 | { | 240 | { |
241 | // needed if turned off during a session. | 241 | // needed if turned off during a session. |
242 | //US mListView->viewport()->setPalette( mListView->palette() ); | 242 | //US mListView->viewport()->setPalette( mListView->palette() ); |
243 | mListView->setPalette( mListView->palette() ); | 243 | mListView->setPalette( mListView->palette() ); |
244 | } | 244 | } |
245 | 245 | ||
246 | //custom fonts? | 246 | //custom fonts? |
247 | QFont f( font() ); | 247 | QFont f( font() ); |
248 | if ( config->readBoolEntry( "EnableCustomFonts", false ) ) | 248 | if ( config->readBoolEntry( "EnableCustomFonts", false ) ) |
249 | { | 249 | { |
250 | mListView->setFont( config->readFontEntry( "TextFont", &f) ); | 250 | mListView->setFont( config->readFontEntry( "TextFont", &f) ); |
251 | f.setBold( true ); | 251 | f.setBold( true ); |
252 | //US mListView->setHeaderFont( config->readFontEntry( "HeaderFont", &f ) ); | 252 | //US mListView->setHeaderFont( config->readFontEntry( "HeaderFont", &f ) ); |
253 | mListView->header()->setFont( config->readFontEntry( "HeaderFont", &f ) ); | 253 | mListView->header()->setFont( config->readFontEntry( "HeaderFont", &f ) ); |
254 | } | 254 | } |
255 | else | 255 | else |
256 | { | 256 | { |
257 | mListView->setFont( f ); | 257 | mListView->setFont( f ); |
258 | f.setBold( true ); | 258 | f.setBold( true ); |
259 | //US mListView->setHeaderFont( f ); | 259 | //US mListView->setHeaderFont( f ); |
260 | mListView->header()->setFont( f ); | 260 | mListView->header()->setFont( f ); |
261 | } | 261 | } |
262 | 262 | ||
263 | // Set the list view options | 263 | // Set the list view options |
264 | mListView->setAlternateBackgroundEnabled(config->readBoolEntry("ABackground", | 264 | mListView->setAlternateBackgroundEnabled(config->readBoolEntry("ABackground", |
265 | true)); | 265 | true)); |
266 | mListView->setSingleLineEnabled(config->readBoolEntry("SingleLine", false)); | 266 | mListView->setSingleLineEnabled(config->readBoolEntry("SingleLine", false)); |
267 | mListView->setToolTipsEnabled(config->readBoolEntry("ToolTips", true)); | 267 | mListView->setToolTipsEnabled(config->readBoolEntry("ToolTips", true)); |
268 | 268 | ||
269 | if (config->readBoolEntry("Background", false)) | 269 | if (config->readBoolEntry("Background", false)) |
270 | mListView->setBackgroundPixmap(config->readEntry("BackgroundName")); | 270 | mListView->setBackgroundPixmap(config->readEntry("BackgroundName")); |
271 | 271 | ||
272 | // Restore the layout of the listview | 272 | // Restore the layout of the listview |
273 | mListView->restoreLayout(config, config->group()); | 273 | mListView->restoreLayout(config, config->group()); |
274 | } | 274 | } |
275 | 275 | ||
276 | void KAddressBookTableView::refresh(QString uid) | 276 | void KAddressBookTableView::refresh(QString uid) |
277 | { | 277 | { |
278 | // For now just repopulate. In reality this method should | 278 | // For now just repopulate. In reality this method should |
279 | // check the value of uid, and if valid iterate through | 279 | // check the value of uid, and if valid iterate through |
280 | // the listview to find the entry, then tell it to refresh. | 280 | // the listview to find the entry, then tell it to refresh. |
281 | 281 | ||
282 | if (uid.isNull()) { | 282 | if (uid.isNull()) { |
283 | // Clear the list view | 283 | // Clear the list view |
284 | QString currentUID, nextUID; | 284 | QString currentUID, nextUID; |
285 | #ifndef KAB_EMBEDDED | 285 | #ifndef KAB_EMBEDDED |
286 | ContactListViewItem *currentItem = dynamic_cast<ContactListViewItem*>( mListView->currentItem() ); | 286 | ContactListViewItem *currentItem = dynamic_cast<ContactListViewItem*>( mListView->currentItem() ); |
287 | #else //KAB_EMBEDDED | 287 | #else //KAB_EMBEDDED |
288 | ContactListViewItem *currentItem = (ContactListViewItem*)( mListView->currentItem() ); | 288 | ContactListViewItem *currentItem = (ContactListViewItem*)( mListView->currentItem() ); |
289 | #endif //KAB_EMBEDDED | 289 | #endif //KAB_EMBEDDED |
290 | 290 | ||
291 | if ( currentItem ) { | 291 | if ( currentItem ) { |
292 | #ifndef KAB_EMBEDDED | 292 | #ifndef KAB_EMBEDDED |
293 | ContactListViewItem *nextItem = dynamic_cast<ContactListViewItem*>( currentItem->itemBelow() ); | 293 | ContactListViewItem *nextItem = dynamic_cast<ContactListViewItem*>( currentItem->itemBelow() ); |
294 | #else //KAB_EMBEDDED | 294 | #else //KAB_EMBEDDED |
295 | ContactListViewItem *nextItem = (ContactListViewItem*)( currentItem->itemBelow() ); | 295 | ContactListViewItem *nextItem = (ContactListViewItem*)( currentItem->itemBelow() ); |
296 | #endif //KAB_EMBEDDED | 296 | #endif //KAB_EMBEDDED |
297 | if ( nextItem ) | 297 | if ( nextItem ) |
298 | nextUID = nextItem->addressee().uid(); | 298 | nextUID = nextItem->addressee().uid(); |
299 | currentUID = currentItem->addressee().uid(); | 299 | currentUID = currentItem->addressee().uid(); |
300 | } | 300 | } |
301 | 301 | ||
302 | mListView->clear(); | 302 | mListView->clear(); |
303 | 303 | ||
304 | currentItem = 0; | 304 | currentItem = 0; |
305 | KABC::Addressee::List addresseeList = addressees(); | 305 | KABC::Addressee::List addresseeList = addressees(); |
306 | KABC::Addressee::List::Iterator it; | 306 | KABC::Addressee::List::Iterator it; |
307 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { | 307 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { |
308 | if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) | 308 | if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) |
309 | continue; | 309 | continue; |
310 | ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); | 310 | ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); |
311 | if ( (*it).uid() == currentUID ) | 311 | if ( (*it).uid() == currentUID ) |
312 | currentItem = item; | 312 | currentItem = item; |
313 | else if ( (*it).uid() == nextUID && !currentItem ) | 313 | else if ( (*it).uid() == nextUID && !currentItem ) |
314 | currentItem = item; | 314 | currentItem = item; |
315 | } | 315 | } |
316 | 316 | ||
317 | // Sometimes the background pixmap gets messed up when we add lots | 317 | // Sometimes the background pixmap gets messed up when we add lots |
318 | // of items. | 318 | // of items. |
319 | mListView->repaint(); | 319 | mListView->repaint(); |
320 | 320 | ||
321 | if ( currentItem ) { | 321 | if ( currentItem ) { |
322 | mListView->setCurrentItem( currentItem ); | 322 | mListView->setCurrentItem( currentItem ); |
323 | mListView->ensureItemVisible( currentItem ); | 323 | mListView->ensureItemVisible( currentItem ); |
324 | } | 324 | } |
325 | } else { | 325 | } else { |
326 | // Only need to update on entry. Iterate through and try to find it | 326 | // Only need to update on entry. Iterate through and try to find it |
327 | ContactListViewItem *ceItem; | 327 | ContactListViewItem *ceItem; |
328 | QListViewItemIterator it( mListView ); | 328 | QListViewItemIterator it( mListView ); |
329 | while ( it.current() ) { | 329 | while ( it.current() ) { |
330 | #ifndef KAB_EMBEDDED | 330 | #ifndef KAB_EMBEDDED |
331 | ceItem = dynamic_cast<ContactListViewItem*>( it.current() ); | 331 | ceItem = dynamic_cast<ContactListViewItem*>( it.current() ); |
332 | #else //KAB_EMBEDDED | 332 | #else //KAB_EMBEDDED |
333 | ceItem = (ContactListViewItem*)( it.current() ); | 333 | ceItem = (ContactListViewItem*)( it.current() ); |
334 | #endif //KAB_EMBEDDED | 334 | #endif //KAB_EMBEDDED |
335 | 335 | ||
336 | if ( ceItem && ceItem->addressee().uid() == uid ) { | 336 | if ( ceItem && ceItem->addressee().uid() == uid ) { |
337 | ceItem->refresh(); | 337 | ceItem->refresh(); |
338 | return; | 338 | return; |
339 | } | 339 | } |
340 | ++it; | 340 | ++it; |
341 | } | 341 | } |
342 | 342 | ||
343 | refresh( QString::null ); | 343 | refresh( QString::null ); |
344 | } | 344 | } |
345 | } | 345 | } |
346 | 346 | ||
347 | QStringList KAddressBookTableView::selectedUids() | 347 | QStringList KAddressBookTableView::selectedUids() |
348 | { | 348 | { |
349 | QStringList uidList; | 349 | QStringList uidList; |
350 | QListViewItem *item; | 350 | QListViewItem *item; |
351 | ContactListViewItem *ceItem; | 351 | ContactListViewItem *ceItem; |
352 | 352 | ||