author | zautrix <zautrix> | 2004-09-18 19:07:00 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-09-18 19:07:00 (UTC) |
commit | 28f894fd2a0dfbd5f09f9e530f359981efe0198c (patch) (side-by-side diff) | |
tree | 426565d2716916f48b0c3e68b41e963fd10a3463 | |
parent | ec8099bf369e5b8327ca6cfd78b34366353e3abf (diff) | |
download | kdepimpi-28f894fd2a0dfbd5f09f9e530f359981efe0198c.zip kdepimpi-28f894fd2a0dfbd5f09f9e530f359981efe0198c.tar.gz kdepimpi-28f894fd2a0dfbd5f09f9e530f359981efe0198c.tar.bz2 |
more AB sync
-rw-r--r-- | kabc/addresseeview.cpp | 15 | ||||
-rw-r--r-- | kaddressbook/kabcore.cpp | 23 |
2 files changed, 8 insertions, 30 deletions
diff --git a/kabc/addresseeview.cpp b/kabc/addresseeview.cpp index 487e8a5..2dda968 100644 --- a/kabc/addresseeview.cpp +++ b/kabc/addresseeview.cpp @@ -367,101 +367,98 @@ mText = "<table width=\"100%\">\n"; // at last display it... setText( mText ); } KABC::Addressee AddresseeView::addressee() const { return mAddressee; } void AddresseeView::addTag(const QString & tag,const QString & text) { if ( text.isEmpty() ) return; int number=text.contains("\n"); QString str = "<" + tag + ">"; QString tmpText=text; QString tmpStr=str; if(number !=-1) { if (number > 0) { int pos=0; QString tmp; for(int i=0;i<=number;i++) { pos=tmpText.find("\n"); tmp=tmpText.left(pos); tmpText=tmpText.right(tmpText.length()-pos-1); tmpStr+=tmp+"<br>"; } } else tmpStr += tmpText; tmpStr+="</" + tag + ">"; mText.append(tmpStr); } else { str += text + "</" + tag + ">"; mText.append(str); } } AddresseeChooser::AddresseeChooser( KABC::Addressee loc, KABC::Addressee rem, bool takeloc, QWidget *parent, const char *name ) : KDialogBase(parent,name, true ,i18n("Conflict! Please choose Adressee!"),Ok|User1|Close,Close, false) { findButton( Close )->setText( i18n("Cancel Sync")); findButton( Ok )->setText( i18n("Remote")); findButton( User1 )->setText( i18n("Local")); QWidget* topframe = new QWidget( this ); - //QVBox* topframe = new QVBox( this ); setMainWidget( topframe ); QBoxLayout* bl; if ( QApplication::desktop()->width() < 640 ) { bl = new QVBoxLayout( topframe ); - } else { bl = new QHBoxLayout( topframe ); - } QVBox* subframe = new QVBox( topframe ); bl->addWidget(subframe ); QLabel* lab = new QLabel( i18n("Local Addressee"), subframe ); + if ( takeloc ) + lab->setBackgroundColor(Qt::green.light() ); AddresseeView * av = new AddresseeView( subframe ); av->setAddressee( loc ); subframe = new QVBox( topframe ); bl->addWidget(subframe ); lab = new QLabel( i18n("Remote Addressee"), subframe ); + if ( !takeloc ) + lab->setBackgroundColor(Qt::green.light() ); av = new AddresseeView( subframe ); av->setAddressee( rem ); - - QObject::connect(findButton( Ok ),SIGNAL(clicked()), - SLOT(slot_remote())); - QObject::connect(this,SIGNAL(user1Clicked()), - SLOT(slot_local())); + QObject::connect(findButton( Ok ),SIGNAL(clicked()),this, SLOT(slot_remote())); + QObject::connect(this,SIGNAL(user1Clicked()),this, SLOT(slot_local())); #ifndef DESKTOP_VERSION showMaximized(); #else resize ( 640, 400 ); #endif } int AddresseeChooser::executeD( bool local ) { mSyncResult = 3; if ( local ) findButton( User1 )->setFocus(); else findButton( Ok )->setFocus(); exec(); - qDebug("returning %d ",mSyncResult ); return mSyncResult; } void AddresseeChooser::slot_remote() { mSyncResult = 2; accept(); } void AddresseeChooser::slot_local() { mSyncResult = 1; accept(); } diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index b1a951c..cc8eb52 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp @@ -2582,121 +2582,103 @@ int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, i } // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , local->revision(), remote->lastModified().toString().latin1(), remote->revision()); //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); //full = true; //debug only if ( full ) { bool equ = ( (*local) == (*remote) ); if ( equ ) { //qDebug("equal "); if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); } if ( mode < SYNC_PREF_FORCE_LOCAL ) return 0; }//else //debug only //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); } int result; bool localIsNew; //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() ); if ( full && mode < SYNC_PREF_NEWEST ) mode = SYNC_PREF_ASK; switch( mode ) { case SYNC_PREF_LOCAL: if ( lastSync > remote->revision() ) return 1; if ( lastSync > local->revision() ) return 2; return 1; break; case SYNC_PREF_REMOTE: if ( lastSync > remote->revision() ) return 1; if ( lastSync > local->revision() ) return 2; return 2; break; case SYNC_PREF_NEWEST: if ( local->revision() > remote->revision() ) return 1; else return 2; break; case SYNC_PREF_ASK: - qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->revision().toString().latin1(), remote->revision().toString().latin1() ); + //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->revision().toString().latin1(), remote->revision().toString().latin1() ); if ( lastSync > remote->revision() ) return 1; if ( lastSync > local->revision() ) return 2; - //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->revision().toString().latin1(), remote->revision().toString().latin1() ); localIsNew = local->revision() >= remote->revision(); -#if 0 - if ( localIsNew ) - getEventViewerDialog()->setColorMode( 1 ); - else - getEventViewerDialog()->setColorMode( 2 ); - getEventViewerDialog()->setIncidence(local); - if ( localIsNew ) - getEventViewerDialog()->setColorMode( 2 ); - else - getEventViewerDialog()->setColorMode( 1 ); - getEventViewerDialog()->addIncidence(remote); - getEventViewerDialog()->setColorMode( 0 ); - //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); - getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); - getEventViewerDialog()->showMe(); - result = getEventViewerDialog()->executeS( localIsNew ); -#endif - qDebug("conflict! ************************************** "); + //qDebug("conflict! ************************************** "); { KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this ); result = acd.executeD(localIsNew); return result; } break; case SYNC_PREF_FORCE_LOCAL: return 1; break; case SYNC_PREF_FORCE_REMOTE: return 2; break; default: // SYNC_PREF_TAKE_BOTH not implemented break; } return 0; } bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) { bool syncOK = true; int addedAddressee = 0; int addedAddresseeR = 0; int deletedAddresseeR = 0; int deletedAddresseeL = 0; int changedLocal = 0; int changedRemote = 0; //QPtrList<Addressee> el = local->rawAddressees(); Addressee addresseeR; QString uid; int take; Addressee addresseeL; Addressee addresseeRSync; Addressee addresseeLSync; KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); bool fullDateRange = false; local->resetTempSyncStat(); mLastAddressbookSync = QDateTime::currentDateTime(); QDateTime modifiedCalendar = mLastAddressbookSync;; addresseeLSync = getLastSyncAddressee(); qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); if ( !addresseeR.isEmpty() ) { addresseeRSync = addresseeR; remote->removeAddressee(addresseeR ); @@ -2929,84 +2911,83 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo bool KABCore::syncAB(QString filename, int mode) { //pending prepare addresseeview for output //pending detect, if remote file has REV field. if not switch to external sync mGlobalSyncMode = SYNC_MODE_NORMAL; AddressBook abLocal(filename,"syncContact"); bool syncOK = false; if ( abLocal.load() ) { qDebug("AB loaded %s mode %d",filename.latin1(), mode ); AddressBook::Iterator it; //QStringList vcards; //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { // qDebug("Name %s ", (*it).familyName().latin1()); //} syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); if ( syncOK ) { if ( KABPrefs::instance()->mWriteBackFile ) { qDebug("saving remote AB "); abLocal.saveAB(); } } setModified(); } if ( syncOK ) mViewManager->refreshView(); return syncOK; #if 0 if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { getEventViewerDialog()->setSyncMode( true ); syncOK = synchronizeCalendar( mCalendar, calendar, mode ); getEventViewerDialog()->setSyncMode( false ); if ( syncOK ) { if ( KOPrefs::instance()->mWriteBackFile ) { storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); storage->save(); } } setModified(); } #endif } - void KABCore::confSync() { static KSyncPrefsDialog* sp = 0; if ( ! sp ) { sp = new KSyncPrefsDialog( this, "syncprefs", true ); } sp->usrReadConfig(); #ifndef DESKTOP_VERSION sp->showMaximized(); #else sp->show(); #endif sp->exec(); KABPrefs::instance()->mSyncProfileNames = sp->getSyncProfileNames(); KABPrefs::instance()->mLocalMachineName = sp->getLocalMachineName (); fillSyncMenu(); } void KABCore::syncSharp() { if ( mModified ) save(); qDebug("pending syncSharp() "); //mView->syncSharp(); setModified(); } void KABCore::syncPhone() { if ( mModified ) save(); qDebug("pending syncPhone(); "); //mView->syncPhone(); setModified(); } |