summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-09-18 18:46:29 (UTC)
committer zautrix <zautrix>2004-09-18 18:46:29 (UTC)
commitec8099bf369e5b8327ca6cfd78b34366353e3abf (patch) (unidiff)
tree551c515124f7b1c47b2860803efa3922f494f938
parent3f16c7aa0ab6badf304c537a6981ece743138821 (diff)
downloadkdepimpi-ec8099bf369e5b8327ca6cfd78b34366353e3abf.zip
kdepimpi-ec8099bf369e5b8327ca6cfd78b34366353e3abf.tar.gz
kdepimpi-ec8099bf369e5b8327ca6cfd78b34366353e3abf.tar.bz2
More AB sync
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addresseeview.cpp66
-rw-r--r--kabc/addresseeview.h18
-rw-r--r--kaddressbook/kabcore.cpp7
3 files changed, 89 insertions, 2 deletions
diff --git a/kabc/addresseeview.cpp b/kabc/addresseeview.cpp
index b4717d7..487e8a5 100644
--- a/kabc/addresseeview.cpp
+++ b/kabc/addresseeview.cpp
@@ -9,49 +9,54 @@
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#include <kabc/address.h> 22#include <kabc/address.h>
23#include <kabc/addressee.h> 23#include <kabc/addressee.h>
24#include <kabc/phonenumber.h> 24#include <kabc/phonenumber.h>
25#include <kglobal.h> 25#include <kglobal.h>
26//US#include <kglobalsettings.h> 26//US#include <kglobalsettings.h>
27#include <kiconloader.h> 27#include <kiconloader.h>
28#include <klocale.h> 28#include <klocale.h>
29//US #include <kstringhandler.h> 29//US #include <kstringhandler.h>
30#include <qscrollview.h> 30#include <qscrollview.h>
31#include <qregexp.h> 31#include <qregexp.h>
32#include <qfile.h> 32#include <qfile.h>
33#include <qvbox.h>
34#include <qlabel.h>
35#include <qwidget.h>
36#include <qlayout.h>
33#include <qapplication.h> 37#include <qapplication.h>
38#include <qpushbutton.h>
34 39
35 40
36#include "externalapphandler.h" 41#include "externalapphandler.h"
37#include "addresseeview.h" 42#include "addresseeview.h"
38 43
39 44
40//US #ifndef DESKTOP_VERSION 45//US #ifndef DESKTOP_VERSION
41//US #include <qtopia/qcopenvelope_qws.h> 46//US #include <qtopia/qcopenvelope_qws.h>
42//US #include <qpe/qpeapplication.h> 47//US #include <qpe/qpeapplication.h>
43//US #endif 48//US #endif
44 49
45//US static int kphoneInstalled = 0; 50//US static int kphoneInstalled = 0;
46 51
47using namespace KPIM; 52using namespace KPIM;
48 53
49AddresseeView::AddresseeView( QWidget *parent, const char *name ) 54AddresseeView::AddresseeView( QWidget *parent, const char *name )
50//US : KTextBrowser( parent, name ) 55//US : KTextBrowser( parent, name )
51 : QTextBrowser( parent, name ) 56 : QTextBrowser( parent, name )
52 57
53 58
54{ 59{
55//US setWrapPolicy( QTextEdit::AtWordBoundary ); 60//US setWrapPolicy( QTextEdit::AtWordBoundary );
56 setLinkUnderline( false ); 61 setLinkUnderline( false );
57 // setVScrollBarMode( QScrollView::AlwaysOff ); 62 // setVScrollBarMode( QScrollView::AlwaysOff );
@@ -378,24 +383,85 @@ void AddresseeView::addTag(const QString & tag,const QString & text)
378 QString tmpText=text; 383 QString tmpText=text;
379 QString tmpStr=str; 384 QString tmpStr=str;
380 if(number !=-1) 385 if(number !=-1)
381 { 386 {
382 if (number > 0) { 387 if (number > 0) {
383 int pos=0; 388 int pos=0;
384 QString tmp; 389 QString tmp;
385 for(int i=0;i<=number;i++) { 390 for(int i=0;i<=number;i++) {
386 pos=tmpText.find("\n"); 391 pos=tmpText.find("\n");
387 tmp=tmpText.left(pos); 392 tmp=tmpText.left(pos);
388 tmpText=tmpText.right(tmpText.length()-pos-1); 393 tmpText=tmpText.right(tmpText.length()-pos-1);
389 tmpStr+=tmp+"<br>"; 394 tmpStr+=tmp+"<br>";
390 } 395 }
391 } 396 }
392 else tmpStr += tmpText; 397 else tmpStr += tmpText;
393 tmpStr+="</" + tag + ">"; 398 tmpStr+="</" + tag + ">";
394 mText.append(tmpStr); 399 mText.append(tmpStr);
395 } 400 }
396 else 401 else
397 { 402 {
398 str += text + "</" + tag + ">"; 403 str += text + "</" + tag + ">";
399 mText.append(str); 404 mText.append(str);
400 } 405 }
401} 406}
407
408AddresseeChooser::AddresseeChooser( KABC::Addressee loc, KABC::Addressee rem, bool takeloc, QWidget *parent, const char *name ) : KDialogBase(parent,name,
409 true ,i18n("Conflict! Please choose Adressee!"),Ok|User1|Close,Close, false)
410{
411 findButton( Close )->setText( i18n("Cancel Sync"));
412 findButton( Ok )->setText( i18n("Remote"));
413 findButton( User1 )->setText( i18n("Local"));
414 QWidget* topframe = new QWidget( this );
415 //QVBox* topframe = new QVBox( this );
416 setMainWidget( topframe );
417 QBoxLayout* bl;
418 if ( QApplication::desktop()->width() < 640 ) {
419 bl = new QVBoxLayout( topframe );
420
421 } else {
422 bl = new QHBoxLayout( topframe );
423
424 }
425 QVBox* subframe = new QVBox( topframe );
426 bl->addWidget(subframe );
427 QLabel* lab = new QLabel( i18n("Local Addressee"), subframe );
428 AddresseeView * av = new AddresseeView( subframe );
429 av->setAddressee( loc );
430 subframe = new QVBox( topframe );
431 bl->addWidget(subframe );
432 lab = new QLabel( i18n("Remote Addressee"), subframe );
433 av = new AddresseeView( subframe );
434 av->setAddressee( rem );
435
436 QObject::connect(findButton( Ok ),SIGNAL(clicked()),
437 SLOT(slot_remote()));
438 QObject::connect(this,SIGNAL(user1Clicked()),
439 SLOT(slot_local()));
440#ifndef DESKTOP_VERSION
441 showMaximized();
442#else
443 resize ( 640, 400 );
444#endif
445}
446
447int AddresseeChooser::executeD( bool local )
448{
449 mSyncResult = 3;
450 if ( local )
451 findButton( User1 )->setFocus();
452 else
453 findButton( Ok )->setFocus();
454 exec();
455 qDebug("returning %d ",mSyncResult );
456 return mSyncResult;
457}
458void AddresseeChooser::slot_remote()
459{
460 mSyncResult = 2;
461 accept();
462}
463void AddresseeChooser::slot_local()
464{
465 mSyncResult = 1;
466 accept();
467}
diff --git a/kabc/addresseeview.h b/kabc/addresseeview.h
index 1865fc4..689d997 100644
--- a/kabc/addresseeview.h
+++ b/kabc/addresseeview.h
@@ -2,59 +2,77 @@
2 This file is part of libkdepim. 2 This file is part of libkdepim.
3 3
4 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> 4 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org>
5 5
6 This library is free software; you can redistribute it and/or 6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public 7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either 8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version. 9 version 2 of the License, or (at your option) any later version.
10 10
11 This library is distributed in the hope that it will be useful, 11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details. 14 Library General Public License for more details.
15 15
16 You should have received a copy of the GNU Library General Public License 16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to 17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. 19 Boston, MA 02111-1307, USA.
20*/ 20*/
21 21
22#ifndef KPIM_ADDRESSEEVIEW_H 22#ifndef KPIM_ADDRESSEEVIEW_H
23#define KPIM_ADDRESSEEVIEW_H 23#define KPIM_ADDRESSEEVIEW_H
24 24
25#include <kabc/addressee.h> 25#include <kabc/addressee.h>
26#include <kdialogbase.h>
26 27
27//US #include <ktextbrowser.h> 28//US #include <ktextbrowser.h>
28#include <qtextbrowser.h> 29#include <qtextbrowser.h>
29 30
30namespace KPIM { 31namespace KPIM {
31 32
32//US class AddresseeView : public KTextBrowser 33//US class AddresseeView : public KTextBrowser
33class AddresseeView : public QTextBrowser 34class AddresseeView : public QTextBrowser
34{ 35{
35 public: 36 public:
36 AddresseeView( QWidget *parent = 0, const char *name = 0 ); 37 AddresseeView( QWidget *parent = 0, const char *name = 0 );
37 38
38 /** 39 /**
39 Sets the addressee object. The addressee is displayed immediately. 40 Sets the addressee object. The addressee is displayed immediately.
40 41
41 @param addr The addressee object. 42 @param addr The addressee object.
42 */ 43 */
43 void setAddressee( const KABC::Addressee& addr ); 44 void setAddressee( const KABC::Addressee& addr );
44 void setSource(const QString& n); 45 void setSource(const QString& n);
45 /** 46 /**
46 Returns the current addressee object. 47 Returns the current addressee object.
47 */ 48 */
48 KABC::Addressee addressee() const; 49 KABC::Addressee addressee() const;
49 50
50 private: 51 private:
51 KABC::Addressee mAddressee; 52 KABC::Addressee mAddressee;
52 QString mText; 53 QString mText;
53 void addTag(const QString & tag,const QString & text); 54 void addTag(const QString & tag,const QString & text);
54 class AddresseeViewPrivate; 55 class AddresseeViewPrivate;
55 AddresseeViewPrivate *d; 56 AddresseeViewPrivate *d;
56}; 57};
58class AddresseeChooser : public KDialogBase
59{
60 Q_OBJECT
61
62 public:
63 AddresseeChooser( KABC::Addressee loc, KABC::Addressee rem, bool takeloc, QWidget *parent = 0, const char *name = 0 );
64
65 int executeD( bool local );
66
67 private:
68 int mSyncResult;
69
70 private slots:
71 void slot_remote();
72 void slot_local();
73
74};
57 75
58} 76}
59 77
60#endif 78#endif
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index 74c10d2..b1a951c 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -2631,51 +2631,53 @@ int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, i
2631 if ( lastSync > remote->revision() ) 2631 if ( lastSync > remote->revision() )
2632 return 1; 2632 return 1;
2633 if ( lastSync > local->revision() ) 2633 if ( lastSync > local->revision() )
2634 return 2; 2634 return 2;
2635 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->revision().toString().latin1(), remote->revision().toString().latin1() ); 2635 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->revision().toString().latin1(), remote->revision().toString().latin1() );
2636 localIsNew = local->revision() >= remote->revision(); 2636 localIsNew = local->revision() >= remote->revision();
2637#if 0 2637#if 0
2638 if ( localIsNew ) 2638 if ( localIsNew )
2639 getEventViewerDialog()->setColorMode( 1 ); 2639 getEventViewerDialog()->setColorMode( 1 );
2640 else 2640 else
2641 getEventViewerDialog()->setColorMode( 2 ); 2641 getEventViewerDialog()->setColorMode( 2 );
2642 getEventViewerDialog()->setIncidence(local); 2642 getEventViewerDialog()->setIncidence(local);
2643 if ( localIsNew ) 2643 if ( localIsNew )
2644 getEventViewerDialog()->setColorMode( 2 ); 2644 getEventViewerDialog()->setColorMode( 2 );
2645 else 2645 else
2646 getEventViewerDialog()->setColorMode( 1 ); 2646 getEventViewerDialog()->setColorMode( 1 );
2647 getEventViewerDialog()->addIncidence(remote); 2647 getEventViewerDialog()->addIncidence(remote);
2648 getEventViewerDialog()->setColorMode( 0 ); 2648 getEventViewerDialog()->setColorMode( 0 );
2649 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); 2649 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() );
2650 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); 2650 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!"));
2651 getEventViewerDialog()->showMe(); 2651 getEventViewerDialog()->showMe();
2652 result = getEventViewerDialog()->executeS( localIsNew ); 2652 result = getEventViewerDialog()->executeS( localIsNew );
2653#endif 2653#endif
2654 qDebug("conflict! ************************************** "); 2654 qDebug("conflict! ************************************** ");
2655 result = 1; 2655 {
2656 KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this );
2657 result = acd.executeD(localIsNew);
2656 return result; 2658 return result;
2657 2659 }
2658 break; 2660 break;
2659 case SYNC_PREF_FORCE_LOCAL: 2661 case SYNC_PREF_FORCE_LOCAL:
2660 return 1; 2662 return 1;
2661 break; 2663 break;
2662 case SYNC_PREF_FORCE_REMOTE: 2664 case SYNC_PREF_FORCE_REMOTE:
2663 return 2; 2665 return 2;
2664 break; 2666 break;
2665 2667
2666 default: 2668 default:
2667 // SYNC_PREF_TAKE_BOTH not implemented 2669 // SYNC_PREF_TAKE_BOTH not implemented
2668 break; 2670 break;
2669 } 2671 }
2670 return 0; 2672 return 0;
2671} 2673}
2672bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) 2674bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode)
2673{ 2675{
2674 bool syncOK = true; 2676 bool syncOK = true;
2675 int addedAddressee = 0; 2677 int addedAddressee = 0;
2676 int addedAddresseeR = 0; 2678 int addedAddresseeR = 0;
2677 int deletedAddresseeR = 0; 2679 int deletedAddresseeR = 0;
2678 int deletedAddresseeL = 0; 2680 int deletedAddresseeL = 0;
2679 int changedLocal = 0; 2681 int changedLocal = 0;
2680 int changedRemote = 0; 2682 int changedRemote = 0;
2681 //QPtrList<Addressee> el = local->rawAddressees(); 2683 //QPtrList<Addressee> el = local->rawAddressees();
@@ -2704,48 +2706,49 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo
2704 } else { 2706 } else {
2705 qDebug("FULLDATE 1"); 2707 qDebug("FULLDATE 1");
2706 fullDateRange = true; 2708 fullDateRange = true;
2707 Addressee newAdd; 2709 Addressee newAdd;
2708 addresseeRSync = newAdd; 2710 addresseeRSync = newAdd;
2709 addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); 2711 addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee"));
2710 addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); 2712 addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName );
2711 addresseeRSync.setRevision( mLastAddressbookSync ); 2713 addresseeRSync.setRevision( mLastAddressbookSync );
2712 addresseeRSync.setCategories( i18n("SyncAddressee") ); 2714 addresseeRSync.setCategories( i18n("SyncAddressee") );
2713 } 2715 }
2714 } 2716 }
2715 if ( addresseeLSync.revision() == mLastAddressbookSync ) { 2717 if ( addresseeLSync.revision() == mLastAddressbookSync ) {
2716 qDebug("FULLDATE 2"); 2718 qDebug("FULLDATE 2");
2717 fullDateRange = true; 2719 fullDateRange = true;
2718 } 2720 }
2719 if ( ! fullDateRange ) { 2721 if ( ! fullDateRange ) {
2720 if ( addresseeLSync.revision() != addresseeRSync.revision() ) { 2722 if ( addresseeLSync.revision() != addresseeRSync.revision() ) {
2721 2723
2722 // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); 2724 // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() );
2723 //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); 2725 //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec());
2724 fullDateRange = true; 2726 fullDateRange = true;
2725 qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); 2727 qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() );
2726 } 2728 }
2727 } 2729 }
2730 fullDateRange = true; // debug only!
2728 if ( fullDateRange ) 2731 if ( fullDateRange )
2729 mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); 2732 mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365);
2730 else 2733 else
2731 mLastAddressbookSync = addresseeLSync.revision(); 2734 mLastAddressbookSync = addresseeLSync.revision();
2732 // for resyncing if own file has changed 2735 // for resyncing if own file has changed
2733 // PENDING fixme later when implemented 2736 // PENDING fixme later when implemented
2734#if 0 2737#if 0
2735 if ( mCurrentSyncDevice == "deleteaftersync" ) { 2738 if ( mCurrentSyncDevice == "deleteaftersync" ) {
2736 mLastAddressbookSync = loadedFileVersion; 2739 mLastAddressbookSync = loadedFileVersion;
2737 qDebug("setting mLastAddressbookSync "); 2740 qDebug("setting mLastAddressbookSync ");
2738 } 2741 }
2739#endif 2742#endif
2740 2743
2741 //qDebug("*************************** "); 2744 //qDebug("*************************** ");
2742 qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); 2745 qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() );
2743 QStringList er = remote->uidList(); 2746 QStringList er = remote->uidList();
2744 Addressee inR ;//= er.first(); 2747 Addressee inR ;//= er.first();
2745 Addressee inL; 2748 Addressee inL;
2746 QProgressBar bar( er.count(),0 ); 2749 QProgressBar bar( er.count(),0 );
2747 bar.setCaption (i18n("Syncing - close to abort!") ); 2750 bar.setCaption (i18n("Syncing - close to abort!") );
2748 2751
2749 int w = 300; 2752 int w = 300;
2750 if ( QApplication::desktop()->width() < 320 ) 2753 if ( QApplication::desktop()->width() < 320 )
2751 w = 220; 2754 w = 220;