author | zautrix <zautrix> | 2005-01-18 14:09:00 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-01-18 14:09:00 (UTC) |
commit | ced210b0c4643ddac6a2e80eab4c85c1994b20e0 (patch) (unidiff) | |
tree | 5126b599b1213553ae71512a400f46d7b2037d92 | |
parent | 4b82a36d1b2479dd2e6f00aef45af848f6793099 (diff) | |
download | kdepimpi-ced210b0c4643ddac6a2e80eab4c85c1994b20e0.zip kdepimpi-ced210b0c4643ddac6a2e80eab4c85c1994b20e0.tar.gz kdepimpi-ced210b0c4643ddac6a2e80eab4c85c1994b20e0.tar.bz2 |
ab sync fixes
-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 | |||
@@ -187,24 +187,25 @@ ulong Addressee::getCsum4List( const QStringList & attList) | |||
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 | { |
@@ -219,27 +220,50 @@ void Addressee::computeCsum(const QString &dev) | |||
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; |
@@ -269,24 +293,25 @@ void Addressee::computeCsum(const QString &dev) | |||
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; |
diff --git a/kaddressbook/imagewidget.cpp b/kaddressbook/imagewidget.cpp index 1e9743c..d0f52ea 100644 --- a/kaddressbook/imagewidget.cpp +++ b/kaddressbook/imagewidget.cpp | |||
@@ -230,26 +230,27 @@ KABC::Picture ImageWidget::logo() const | |||
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 | } |
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index d970ff1..e88706e 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -1179,24 +1179,28 @@ void KABCore::setModified( bool modified ) | |||
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 ); |
@@ -2704,25 +2708,26 @@ int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, i | |||
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 ) |
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 | |||
@@ -148,25 +148,25 @@ void KAddressBookTableView::doSearch( const QString& s, KABC::Field *field ) | |||
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; |