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 /kaddressbook | |
parent | 4b82a36d1b2479dd2e6f00aef45af848f6793099 (diff) | |
download | kdepimpi-ced210b0c4643ddac6a2e80eab4c85c1994b20e0.zip kdepimpi-ced210b0c4643ddac6a2e80eab4c85c1994b20e0.tar.gz kdepimpi-ced210b0c4643ddac6a2e80eab4c85c1994b20e0.tar.bz2 |
ab sync fixes
-rw-r--r-- | kaddressbook/imagewidget.cpp | 5 | ||||
-rw-r--r-- | kaddressbook/kabcore.cpp | 7 | ||||
-rw-r--r-- | kaddressbook/views/kaddressbooktableview.cpp | 2 |
3 files changed, 10 insertions, 4 deletions
diff --git a/kaddressbook/imagewidget.cpp b/kaddressbook/imagewidget.cpp index 1e9743c..d0f52ea 100644 --- a/kaddressbook/imagewidget.cpp +++ b/kaddressbook/imagewidget.cpp | |||
@@ -210,66 +210,67 @@ void ImageWidget::setLogo( const KABC::Picture &logo ) | |||
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 | ||
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index d970ff1..e88706e 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -1159,64 +1159,68 @@ 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 ); |
@@ -2684,65 +2688,66 @@ KABC::Addressee KABCore::getLastSyncAddressee() | |||
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()); |
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 | |||
@@ -128,65 +128,65 @@ void KAddressBookTableView::reconstructListView() | |||
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 | } |