summaryrefslogtreecommitdiffabout
path: root/kaddressbook
authorzautrix <zautrix>2005-01-16 12:48:47 (UTC)
committer zautrix <zautrix>2005-01-16 12:48:47 (UTC)
commit3f61f5a339e9c0c67c17b16214abded0d123f246 (patch) (unidiff)
treee3e858f70d85f5a8c6e1547113eae924be73c5c3 /kaddressbook
parentf3f63a1a1363cba9f58790812e43d6eda14f733c (diff)
downloadkdepimpi-3f61f5a339e9c0c67c17b16214abded0d123f246.zip
kdepimpi-3f61f5a339e9c0c67c17b16214abded0d123f246.tar.gz
kdepimpi-3f61f5a339e9c0c67c17b16214abded0d123f246.tar.bz2
applied AB filters
Diffstat (limited to 'kaddressbook') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/kabcore.cpp63
-rw-r--r--kaddressbook/viewmanager.cpp9
-rw-r--r--kaddressbook/viewmanager.h2
3 files changed, 47 insertions, 27 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index c6288fa..c5a36e2 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -2858,24 +2858,29 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo
2858 mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); 2858 mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365);
2859 else 2859 else
2860 mLastAddressbookSync = addresseeLSync.revision(); 2860 mLastAddressbookSync = addresseeLSync.revision();
2861 // for resyncing if own file has changed 2861 // for resyncing if own file has changed
2862 // PENDING fixme later when implemented 2862 // PENDING fixme later when implemented
2863#if 0 2863#if 0
2864 if ( mCurrentSyncDevice == "deleteaftersync" ) { 2864 if ( mCurrentSyncDevice == "deleteaftersync" ) {
2865 mLastAddressbookSync = loadedFileVersion; 2865 mLastAddressbookSync = loadedFileVersion;
2866 qDebug("setting mLastAddressbookSync "); 2866 qDebug("setting mLastAddressbookSync ");
2867 } 2867 }
2868#endif 2868#endif
2869 2869
2870
2871 // ********** setting filters ****************
2872 Filter filterIN = mViewManager->getFilterByName( syncManager->mFilterInAB );
2873 Filter filterOUT = mViewManager->getFilterByName( syncManager->mFilterOutAB );
2874
2870 //qDebug("*************************** "); 2875 //qDebug("*************************** ");
2871 // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); 2876 // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() );
2872 QStringList er = remote->uidList(); 2877 QStringList er = remote->uidList();
2873 Addressee inR ;//= er.first(); 2878 Addressee inR ;//= er.first();
2874 Addressee inL; 2879 Addressee inL;
2875 2880
2876 syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); 2881 syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count());
2877 2882
2878 int modulo = (er.count()/10)+1; 2883 int modulo = (er.count()/10)+1;
2879 int incCounter = 0; 2884 int incCounter = 0;
2880 while ( incCounter < er.count()) { 2885 while ( incCounter < er.count()) {
2881 if (syncManager->isProgressBarCanceled()) 2886 if (syncManager->isProgressBarCanceled())
@@ -2937,74 +2942,78 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo
2937 inL.setIDStr( idS ); 2942 inL.setIDStr( idS );
2938 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2943 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2939 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 2944 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
2940 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 2945 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
2941 } 2946 }
2942 inL.setResource( 0 ); 2947 inL.setResource( 0 );
2943 local->insertAddressee( inL , false ); 2948 local->insertAddressee( inL , false );
2944 ++changedLocal; 2949 ++changedLocal;
2945 } 2950 }
2946 } 2951 }
2947 } 2952 }
2948 } else { // no conflict ********** add or delete remote 2953 } else { // no conflict ********** add or delete remote
2949 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2954 if ( filterIN.name().isEmpty() || filterIN.filterAddressee( inR ) ) {
2950 QString des = addresseeLSync.note(); 2955 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2951 if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 2956 QString des = addresseeLSync.note();
2952 inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 2957 if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
2953 remote->insertAddressee( inR, false ); 2958 inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE );
2954 ++deletedAddresseeR; 2959 remote->insertAddressee( inR, false );
2955 } else { 2960 ++deletedAddresseeR;
2956 inR.setRevision( modifiedCalendar ); 2961 } else {
2957 remote->insertAddressee( inR, false ); 2962 inR.setRevision( modifiedCalendar );
2958 inL = inR; 2963 remote->insertAddressee( inR, false );
2959 inL.setIDStr( ":" ); 2964 inL = inR;
2960 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 2965 inL.setIDStr( ":" );
2961 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 2966 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
2962 inL.setResource( 0 ); 2967 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
2963 local->insertAddressee( inL , false); 2968 inL.setResource( 0 );
2964 ++addedAddressee; 2969 local->insertAddressee( inL , false);
2965 } 2970 ++addedAddressee;
2966 } else { 2971 }
2967 if ( inR.revision() > mLastAddressbookSync || mode == 5 ) {
2968 inR.setRevision( modifiedCalendar );
2969 remote->insertAddressee( inR, false );
2970 inR.setResource( 0 );
2971 local->insertAddressee( inR, false );
2972 ++addedAddressee;
2973 } else { 2972 } else {
2974 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); 2973 if ( inR.revision() > mLastAddressbookSync || mode == 5 ) {
2975 remote->removeAddressee( inR ); 2974 inR.setRevision( modifiedCalendar );
2976 ++deletedAddresseeR; 2975 remote->insertAddressee( inR, false );
2976 inR.setResource( 0 );
2977 local->insertAddressee( inR, false );
2978 ++addedAddressee;
2979 } else {
2980 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR);
2981 remote->removeAddressee( inR );
2982 ++deletedAddresseeR;
2983 }
2977 } 2984 }
2978 } 2985 }
2979 } 2986 }
2980 } 2987 }
2981 ++incCounter; 2988 ++incCounter;
2982 } 2989 }
2983 er.clear(); 2990 er.clear();
2984 QStringList el = local->uidList(); 2991 QStringList el = local->uidList();
2985 modulo = (el.count()/10)+1; 2992 modulo = (el.count()/10)+1;
2986 2993
2987 syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); 2994 syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count());
2988 incCounter = 0; 2995 incCounter = 0;
2989 while ( incCounter < el.count()) { 2996 while ( incCounter < el.count()) {
2990 qApp->processEvents(); 2997 qApp->processEvents();
2991 if (syncManager->isProgressBarCanceled()) 2998 if (syncManager->isProgressBarCanceled())
2992 return false; 2999 return false;
2993 if ( incCounter % modulo == 0 ) 3000 if ( incCounter % modulo == 0 )
2994 syncManager->showProgressBar(incCounter); 3001 syncManager->showProgressBar(incCounter);
2995 uid = el[ incCounter ]; 3002 uid = el[ incCounter ];
2996 bool skipIncidence = false; 3003 bool skipIncidence = false;
2997 if ( uid.left(19) == QString("last-syncAddressee-") ) 3004 if ( uid.left(19) == QString("last-syncAddressee-") )
2998 skipIncidence = true; 3005 skipIncidence = true;
3006 if ( !filterOUT.name().isEmpty() && ! filterOUT.filterAddressee( inL ) )
3007 skipIncidence = true;
2999 if ( !skipIncidence ) { 3008 if ( !skipIncidence ) {
3000 inL = local->findByUid( uid ); 3009 inL = local->findByUid( uid );
3001 if ( !inL.resource() || inL.resource()->includeInSync() ) { 3010 if ( !inL.resource() || inL.resource()->includeInSync() ) {
3002 inR = remote->findByUid( uid ); 3011 inR = remote->findByUid( uid );
3003 if ( inR.isEmpty() ) { // no conflict ********** add or delete local 3012 if ( inR.isEmpty() ) { // no conflict ********** add or delete local
3004 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 3013 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
3005 if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 3014 if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
3006 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); 3015 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
3007 local->removeAddressee( inL ); 3016 local->removeAddressee( inL );
3008 ++deletedAddresseeL; 3017 ++deletedAddresseeL;
3009 } else { 3018 } else {
3010 if ( ! syncManager->mWriteBackExistingOnly ) { 3019 if ( ! syncManager->mWriteBackExistingOnly ) {
diff --git a/kaddressbook/viewmanager.cpp b/kaddressbook/viewmanager.cpp
index 59bddd9..9c3a641 100644
--- a/kaddressbook/viewmanager.cpp
+++ b/kaddressbook/viewmanager.cpp
@@ -609,24 +609,33 @@ void ViewManager::configureFilters()
609} 609}
610 610
611QStringList ViewManager::filterNames() const 611QStringList ViewManager::filterNames() const
612{ 612{
613 QStringList names( i18n( "No Filter" ) ); 613 QStringList names( i18n( "No Filter" ) );
614 614
615 Filter::List::ConstIterator it; 615 Filter::List::ConstIterator it;
616 for ( it = mFilterList.begin(); it != mFilterList.end(); ++it ) 616 for ( it = mFilterList.begin(); it != mFilterList.end(); ++it )
617 names.append( (*it).name() ); 617 names.append( (*it).name() );
618 618
619 return names; 619 return names;
620} 620}
621Filter ViewManager::getFilterByName( const QString &name ) const
622{
623 Filter::List::ConstIterator it;
624 for ( it = mFilterList.begin(); it != mFilterList.end(); ++it )
625 if ( name == (*it).name() )
626 return (*it);
627
628 return Filter();
629}
621 630
622int ViewManager::filterPosition( const QString &name ) const 631int ViewManager::filterPosition( const QString &name ) const
623{ 632{
624 int pos = 0; 633 int pos = 0;
625 634
626 Filter::List::ConstIterator it; 635 Filter::List::ConstIterator it;
627 for ( it = mFilterList.begin(); it != mFilterList.end(); ++it, ++pos ) 636 for ( it = mFilterList.begin(); it != mFilterList.end(); ++it, ++pos )
628 if ( name == (*it).name() ) 637 if ( name == (*it).name() )
629 return pos + 1; 638 return pos + 1;
630 639
631 return 0; 640 return 0;
632} 641}
diff --git a/kaddressbook/viewmanager.h b/kaddressbook/viewmanager.h
index a03a83f..272e1b0 100644
--- a/kaddressbook/viewmanager.h
+++ b/kaddressbook/viewmanager.h
@@ -19,24 +19,25 @@
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#ifndef VIEWMANAGER_H 24#ifndef VIEWMANAGER_H
25#define VIEWMANAGER_H 25#define VIEWMANAGER_H
26 26
27#include <qwidget.h> 27#include <qwidget.h>
28#include <qstringlist.h> 28#include <qstringlist.h>
29#include <kaddressbookview.h> 29#include <kaddressbookview.h>
30#include <qdict.h> 30#include <qdict.h>
31#include "filter.h"
31 32
32class KAction; 33class KAction;
33class KSelectAction; 34class KSelectAction;
34 35
35class KABCore; 36class KABCore;
36class QWidgetStack; 37class QWidgetStack;
37class QDropEvent; 38class QDropEvent;
38 39
39namespace KABC { class AddressBook; } 40namespace KABC { class AddressBook; }
40 41
41/** 42/**
42 The view manager manages the views and everything related to them. The 43 The view manager manages the views and everything related to them. The
@@ -50,24 +51,25 @@ class ViewManager : public QWidget
50{ 51{
51 Q_OBJECT 52 Q_OBJECT
52 public: 53 public:
53 ViewManager( KABCore *core, QWidget *parent, const char *name = 0 ); 54 ViewManager( KABCore *core, QWidget *parent, const char *name = 0 );
54 ~ViewManager(); 55 ~ViewManager();
55 56
56 void restoreSettings(); 57 void restoreSettings();
57 void saveSettings(); 58 void saveSettings();
58 void doSearch( const QString& s ,KABC::Field *field ); 59 void doSearch( const QString& s ,KABC::Field *field );
59 60
60 void unloadViews(); 61 void unloadViews();
61 KSelectAction * getFilterAction() { return mActionSelectFilter; } 62 KSelectAction * getFilterAction() { return mActionSelectFilter; }
63 Filter getFilterByName( const QString &name ) const;
62 64
63 QStringList selectedUids() const; 65 QStringList selectedUids() const;
64 QStringList selectedEmails() const; 66 QStringList selectedEmails() const;
65 KABC::Addressee::List selectedAddressees() const; 67 KABC::Addressee::List selectedAddressees() const;
66 void setListSelected(QStringList); 68 void setListSelected(QStringList);
67 void setFocusAV(); 69 void setFocusAV();
68 70
69 public slots: 71 public slots:
70 void scrollUP(); 72 void scrollUP();
71 void scrollDOWN(); 73 void scrollDOWN();
72 74
73//US void setSelected( const QString &uid = QString::null, bool selected = true ); 75//US void setSelected( const QString &uid = QString::null, bool selected = true );