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) (show whitespace changes)
-rw-r--r--kaddressbook/kabcore.cpp9
-rw-r--r--kaddressbook/viewmanager.cpp9
-rw-r--r--kaddressbook/viewmanager.h2
3 files changed, 20 insertions, 0 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index c6288fa..c5a36e2 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -2822,225 +2822,234 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo
2822 addresseeLSync = getLastSyncAddressee(); 2822 addresseeLSync = getLastSyncAddressee();
2823 qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); 2823 qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1());
2824 addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); 2824 addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName );
2825 if ( !addresseeR.isEmpty() ) { 2825 if ( !addresseeR.isEmpty() ) {
2826 addresseeRSync = addresseeR; 2826 addresseeRSync = addresseeR;
2827 remote->removeAddressee(addresseeR ); 2827 remote->removeAddressee(addresseeR );
2828 2828
2829 } else { 2829 } else {
2830 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2830 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2831 addresseeRSync = addresseeLSync ; 2831 addresseeRSync = addresseeLSync ;
2832 } else { 2832 } else {
2833 //qDebug("FULLDATE 1"); 2833 //qDebug("FULLDATE 1");
2834 fullDateRange = true; 2834 fullDateRange = true;
2835 Addressee newAdd; 2835 Addressee newAdd;
2836 addresseeRSync = newAdd; 2836 addresseeRSync = newAdd;
2837 addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); 2837 addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee"));
2838 addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); 2838 addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName );
2839 addresseeRSync.setRevision( mLastAddressbookSync ); 2839 addresseeRSync.setRevision( mLastAddressbookSync );
2840 addresseeRSync.setCategories( i18n("SyncAddressee") ); 2840 addresseeRSync.setCategories( i18n("SyncAddressee") );
2841 } 2841 }
2842 } 2842 }
2843 if ( addresseeLSync.revision() == mLastAddressbookSync ) { 2843 if ( addresseeLSync.revision() == mLastAddressbookSync ) {
2844 // qDebug("FULLDATE 2"); 2844 // qDebug("FULLDATE 2");
2845 fullDateRange = true; 2845 fullDateRange = true;
2846 } 2846 }
2847 if ( ! fullDateRange ) { 2847 if ( ! fullDateRange ) {
2848 if ( addresseeLSync.revision() != addresseeRSync.revision() ) { 2848 if ( addresseeLSync.revision() != addresseeRSync.revision() ) {
2849 2849
2850 // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); 2850 // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() );
2851 //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); 2851 //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec());
2852 fullDateRange = true; 2852 fullDateRange = true;
2853 //qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); 2853 //qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() );
2854 } 2854 }
2855 } 2855 }
2856 // fullDateRange = true; // debug only! 2856 // fullDateRange = true; // debug only!
2857 if ( fullDateRange ) 2857 if ( fullDateRange )
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())
2882 return false; 2887 return false;
2883 if ( incCounter % modulo == 0 ) 2888 if ( incCounter % modulo == 0 )
2884 syncManager->showProgressBar(incCounter); 2889 syncManager->showProgressBar(incCounter);
2885 2890
2886 uid = er[ incCounter ]; 2891 uid = er[ incCounter ];
2887 bool skipIncidence = false; 2892 bool skipIncidence = false;
2888 if ( uid.left(19) == QString("last-syncAddressee-") ) 2893 if ( uid.left(19) == QString("last-syncAddressee-") )
2889 skipIncidence = true; 2894 skipIncidence = true;
2890 QString idS,OidS; 2895 QString idS,OidS;
2891 qApp->processEvents(); 2896 qApp->processEvents();
2892 if ( !skipIncidence ) { 2897 if ( !skipIncidence ) {
2893 inL = local->findByUid( uid ); 2898 inL = local->findByUid( uid );
2894 inR = remote->findByUid( uid ); 2899 inR = remote->findByUid( uid );
2895 //inL.setResource( 0 ); 2900 //inL.setResource( 0 );
2896 //inR.setResource( 0 ); 2901 //inR.setResource( 0 );
2897 if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars 2902 if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars
2898 if ( !inL.resource() || inL.resource()->includeInSync() ) { 2903 if ( !inL.resource() || inL.resource()->includeInSync() ) {
2899 if ( (take = takeAddressee( &inL, &inR, mode, fullDateRange )) ) { 2904 if ( (take = takeAddressee( &inL, &inR, mode, fullDateRange )) ) {
2900 //qDebug("take %d %s ", take, inL.summary().latin1()); 2905 //qDebug("take %d %s ", take, inL.summary().latin1());
2901 if ( take == 3 ) 2906 if ( take == 3 )
2902 return false; 2907 return false;
2903 if ( take == 1 ) {// take local ********************** 2908 if ( take == 1 ) {// take local **********************
2904 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2909 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2905 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 2910 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
2906 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 2911 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
2907 local->insertAddressee( inL, false ); 2912 local->insertAddressee( inL, false );
2908 idS = inR.externalUID(); 2913 idS = inR.externalUID();
2909 OidS = inR.originalExternalUID(); 2914 OidS = inR.originalExternalUID();
2910 } 2915 }
2911 else 2916 else
2912 idS = inR.IDStr(); 2917 idS = inR.IDStr();
2913 remote->removeAddressee( inR ); 2918 remote->removeAddressee( inR );
2914 inR = inL; 2919 inR = inL;
2915 inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 2920 inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
2916 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2921 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2917 inR.setOriginalExternalUID( OidS ); 2922 inR.setOriginalExternalUID( OidS );
2918 inR.setExternalUID( idS ); 2923 inR.setExternalUID( idS );
2919 if ( syncManager->syncWithDesktop() ) { 2924 if ( syncManager->syncWithDesktop() ) {
2920 inR.setIDStr("changed" ); 2925 inR.setIDStr("changed" );
2921 } 2926 }
2922 //inR.insertCustom( "KADDRESSBOOK", "X-KDESYNC","changed" ); 2927 //inR.insertCustom( "KADDRESSBOOK", "X-KDESYNC","changed" );
2923 } else { 2928 } else {
2924 inR.setIDStr( idS ); 2929 inR.setIDStr( idS );
2925 } 2930 }
2926 inR.setResource( 0 ); 2931 inR.setResource( 0 );
2927 remote->insertAddressee( inR , false); 2932 remote->insertAddressee( inR , false);
2928 ++changedRemote; 2933 ++changedRemote;
2929 } else { // take == 2 take remote ********************** 2934 } else { // take == 2 take remote **********************
2930 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2935 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2931 if ( inR.revision().date().year() < 2004 ) 2936 if ( inR.revision().date().year() < 2004 )
2932 inR.setRevision( modifiedCalendar ); 2937 inR.setRevision( modifiedCalendar );
2933 } 2938 }
2934 idS = inL.IDStr(); 2939 idS = inL.IDStr();
2935 local->removeAddressee( inL ); 2940 local->removeAddressee( inL );
2936 inL = inR; 2941 inL = inR;
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
2954 if ( filterIN.name().isEmpty() || filterIN.filterAddressee( inR ) ) {
2949 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2955 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2950 QString des = addresseeLSync.note(); 2956 QString des = addresseeLSync.note();
2951 if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 2957 if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
2952 inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 2958 inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE );
2953 remote->insertAddressee( inR, false ); 2959 remote->insertAddressee( inR, false );
2954 ++deletedAddresseeR; 2960 ++deletedAddresseeR;
2955 } else { 2961 } else {
2956 inR.setRevision( modifiedCalendar ); 2962 inR.setRevision( modifiedCalendar );
2957 remote->insertAddressee( inR, false ); 2963 remote->insertAddressee( inR, false );
2958 inL = inR; 2964 inL = inR;
2959 inL.setIDStr( ":" ); 2965 inL.setIDStr( ":" );
2960 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 2966 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
2961 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 2967 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
2962 inL.setResource( 0 ); 2968 inL.setResource( 0 );
2963 local->insertAddressee( inL , false); 2969 local->insertAddressee( inL , false);
2964 ++addedAddressee; 2970 ++addedAddressee;
2965 } 2971 }
2966 } else { 2972 } else {
2967 if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { 2973 if ( inR.revision() > mLastAddressbookSync || mode == 5 ) {
2968 inR.setRevision( modifiedCalendar ); 2974 inR.setRevision( modifiedCalendar );
2969 remote->insertAddressee( inR, false ); 2975 remote->insertAddressee( inR, false );
2970 inR.setResource( 0 ); 2976 inR.setResource( 0 );
2971 local->insertAddressee( inR, false ); 2977 local->insertAddressee( inR, false );
2972 ++addedAddressee; 2978 ++addedAddressee;
2973 } else { 2979 } else {
2974 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); 2980 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR);
2975 remote->removeAddressee( inR ); 2981 remote->removeAddressee( inR );
2976 ++deletedAddresseeR; 2982 ++deletedAddresseeR;
2977 } 2983 }
2978 } 2984 }
2979 } 2985 }
2980 } 2986 }
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 ) {
3011 inL.removeID(mCurrentSyncDevice ); 3020 inL.removeID(mCurrentSyncDevice );
3012 ++addedAddresseeR; 3021 ++addedAddresseeR;
3013 inL.setRevision( modifiedCalendar ); 3022 inL.setRevision( modifiedCalendar );
3014 local->insertAddressee( inL, false ); 3023 local->insertAddressee( inL, false );
3015 inR = inL; 3024 inR = inL;
3016 inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); 3025 inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL );
3017 inR.setResource( 0 ); 3026 inR.setResource( 0 );
3018 remote->insertAddressee( inR, false ); 3027 remote->insertAddressee( inR, false );
3019 } 3028 }
3020 } 3029 }
3021 } else { 3030 } else {
3022 if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { 3031 if ( inL.revision() < mLastAddressbookSync && mode != 4 ) {
3023 //qDebug("data %s ", inL.revision().toString().latin1()); 3032 //qDebug("data %s ", inL.revision().toString().latin1());
3024 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); 3033 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
3025 local->removeAddressee( inL ); 3034 local->removeAddressee( inL );
3026 ++deletedAddresseeL; 3035 ++deletedAddresseeL;
3027 } else { 3036 } else {
3028 if ( ! syncManager->mWriteBackExistingOnly ) { 3037 if ( ! syncManager->mWriteBackExistingOnly ) {
3029 ++addedAddresseeR; 3038 ++addedAddresseeR;
3030 inL.setRevision( modifiedCalendar ); 3039 inL.setRevision( modifiedCalendar );
3031 local->insertAddressee( inL, false ); 3040 local->insertAddressee( inL, false );
3032 inR = inL; 3041 inR = inL;
3033 inR.setIDStr( ":" ); 3042 inR.setIDStr( ":" );
3034 inR.setResource( 0 ); 3043 inR.setResource( 0 );
3035 remote->insertAddressee( inR, false ); 3044 remote->insertAddressee( inR, false );
3036 } 3045 }
3037 } 3046 }
3038 } 3047 }
3039 } 3048 }
3040 } 3049 }
3041 } 3050 }
3042 ++incCounter; 3051 ++incCounter;
3043 } 3052 }
3044 el.clear(); 3053 el.clear();
3045 syncManager->hideProgressBar(); 3054 syncManager->hideProgressBar();
3046 mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); 3055 mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 );
diff --git a/kaddressbook/viewmanager.cpp b/kaddressbook/viewmanager.cpp
index 59bddd9..9c3a641 100644
--- a/kaddressbook/viewmanager.cpp
+++ b/kaddressbook/viewmanager.cpp
@@ -573,96 +573,105 @@ void ViewManager::doSearch( const QString& s,KABC::Field *field )
573void ViewManager::setActiveFilter( int index ) 573void ViewManager::setActiveFilter( int index )
574{ 574{
575 Filter currentFilter; 575 Filter currentFilter;
576 576
577 if ( ( index - 1 ) < 0 ) 577 if ( ( index - 1 ) < 0 )
578 currentFilter = Filter(); 578 currentFilter = Filter();
579 else 579 else
580 currentFilter = mFilterList[ index - 1 ]; 580 currentFilter = mFilterList[ index - 1 ];
581 581
582 // Check if we have a view. Since the filter combo is created before 582 // Check if we have a view. Since the filter combo is created before
583 // the view, this slot could be called before there is a valid view. 583 // the view, this slot could be called before there is a valid view.
584 if ( mActiveView ) { 584 if ( mActiveView ) {
585 mActiveView->setFilter( currentFilter ); 585 mActiveView->setFilter( currentFilter );
586 mActiveView->refresh(); 586 mActiveView->refresh();
587 emit selected( QString::null ); 587 emit selected( QString::null );
588 } 588 }
589} 589}
590 590
591void ViewManager::configureFilters() 591void ViewManager::configureFilters()
592{ 592{
593 FilterDialog dlg( this ); 593 FilterDialog dlg( this );
594 594
595 dlg.setFilters( mFilterList ); 595 dlg.setFilters( mFilterList );
596 596
597 if ( dlg.exec() ) 597 if ( dlg.exec() )
598 mFilterList = dlg.filters(); 598 mFilterList = dlg.filters();
599 599
600 uint pos = mActionSelectFilter->currentItem(); 600 uint pos = mActionSelectFilter->currentItem();
601 mActionSelectFilter->setItems( filterNames() ); 601 mActionSelectFilter->setItems( filterNames() );
602 mActionSelectFilter->setCurrentItem( pos ); 602 mActionSelectFilter->setCurrentItem( pos );
603 setActiveFilter( pos ); 603 setActiveFilter( pos );
604 int cw = 150; 604 int cw = 150;
605 if (QApplication::desktop()->width() == 480 ) 605 if (QApplication::desktop()->width() == 480 )
606 cw = 0; 606 cw = 0;
607 mActionSelectFilter->setComboWidth( cw ); 607 mActionSelectFilter->setComboWidth( cw );
608 saveSettings(); 608 saveSettings();
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}
633 642
634void ViewManager::initActions() 643void ViewManager::initActions()
635{ 644{
636//US <ActionList name="view_loadedviews"/> 645//US <ActionList name="view_loadedviews"/>
637//US <Separator/> 646//US <Separator/>
638 647
639#ifdef KAB_EMBEDDED 648#ifdef KAB_EMBEDDED
640 QPopupMenu *viewmenu = (QPopupMenu*)mCore->getViewMenu(); 649 QPopupMenu *viewmenu = (QPopupMenu*)mCore->getViewMenu();
641 QPopupMenu *settingsmenu = (QPopupMenu*)mCore->getSettingsMenu(); 650 QPopupMenu *settingsmenu = (QPopupMenu*)mCore->getSettingsMenu();
642 QPopupMenu *filtermenu = (QPopupMenu*)mCore->getFilterMenu(); 651 QPopupMenu *filtermenu = (QPopupMenu*)mCore->getFilterMenu();
643#endif //KAB_EMBEDDED 652#endif //KAB_EMBEDDED
644 653
645 mActionSelectView = new KSelectAction( i18n( "Select View" ), 0, mCore->actionCollection(), "select_view" ); 654 mActionSelectView = new KSelectAction( i18n( "Select View" ), 0, mCore->actionCollection(), "select_view" );
646#if KDE_VERSION >= 309 655#if KDE_VERSION >= 309
647 mActionSelectView->setMenuAccelsEnabled( false ); 656 mActionSelectView->setMenuAccelsEnabled( false );
648#endif 657#endif
649 connect( mActionSelectView, SIGNAL( activated( const QString& ) ), 658 connect( mActionSelectView, SIGNAL( activated( const QString& ) ),
650 SLOT( setActiveView( const QString& ) ) ); 659 SLOT( setActiveView( const QString& ) ) );
651 660
652 661
653#ifdef KAB_EMBEDDED 662#ifdef KAB_EMBEDDED
654 mActionSelectView->plug(viewmenu); 663 mActionSelectView->plug(viewmenu);
655 viewmenu->insertSeparator(); 664 viewmenu->insertSeparator();
656#endif //KAB_EMBEDDED 665#endif //KAB_EMBEDDED
657 666
658 KAction *action; 667 KAction *action;
659 668
660 action = new KAction( i18n( "Modify View..." ), "configure", 0, this, 669 action = new KAction( i18n( "Modify View..." ), "configure", 0, this,
661 SLOT( editView() ), mCore->actionCollection(), "view_modify" ); 670 SLOT( editView() ), mCore->actionCollection(), "view_modify" );
662#ifndef KAB_EMBEDDED 671#ifndef KAB_EMBEDDED
663 action->setWhatsThis( i18n( "By pressing this button a dialog opens that allows you to modify the view of the addressbook. There you can add or remove fields that you want to be shown or hidden in the addressbook like the name for example." ) ); 672 action->setWhatsThis( i18n( "By pressing this button a dialog opens that allows you to modify the view of the addressbook. There you can add or remove fields that you want to be shown or hidden in the addressbook like the name for example." ) );
664#else //KAB_EMBEDDED 673#else //KAB_EMBEDDED
665 action->plug(viewmenu); 674 action->plug(viewmenu);
666#endif //KAB_EMBEDDED 675#endif //KAB_EMBEDDED
667 676
668 action = new KAction( i18n( "Add View..." ), "window_new", 0, this, 677 action = new KAction( i18n( "Add View..." ), "window_new", 0, this,
diff --git a/kaddressbook/viewmanager.h b/kaddressbook/viewmanager.h
index a03a83f..272e1b0 100644
--- a/kaddressbook/viewmanager.h
+++ b/kaddressbook/viewmanager.h
@@ -1,109 +1,111 @@
1/* 1/*
2 This file is part of KAddressBook. 2 This file is part of KAddressBook.
3 Copyright (c) 2002 Mike Pilone <mpilone@slac.com> 3 Copyright (c) 2002 Mike Pilone <mpilone@slac.com>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
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
43 manager will load the views at startup and display a view when told to 44 manager will load the views at startup and display a view when told to
44 make one active. 45 make one active.
45 46
46 The view manager will also create and manage all dialogs directly related to 47 The view manager will also create and manage all dialogs directly related to
47 views (ie: AddView, ConfigureView, DeleteView, etc). 48 views (ie: AddView, ConfigureView, DeleteView, etc).
48 */ 49 */
49class ViewManager : public QWidget 50class 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 );
74 void setSelected( const QString &uid, bool); 76 void setSelected( const QString &uid, bool);
75//US added another method with no parameter, since my moc compiler does not support default parameters. 77//US added another method with no parameter, since my moc compiler does not support default parameters.
76 void setSelected(); 78 void setSelected();
77 79
78 80
79 81
80//US added another method with no parameter, since my moc compiler does not support default parameters. 82//US added another method with no parameter, since my moc compiler does not support default parameters.
81 void refreshView(); 83 void refreshView();
82 void refreshView( const QString &uid); 84 void refreshView( const QString &uid);
83 85
84 void editView(); 86 void editView();
85 void deleteView(); 87 void deleteView();
86 void addView(); 88 void addView();
87 89
88 protected slots: 90 protected slots:
89 /** 91 /**
90 Called whenever the user drops something in the active view. 92 Called whenever the user drops something in the active view.
91 This method will try to decode what was dropped, and if it was 93 This method will try to decode what was dropped, and if it was
92 a valid addressee, add it to the addressbook. 94 a valid addressee, add it to the addressbook.
93 */ 95 */
94 void dropped( QDropEvent* ); 96 void dropped( QDropEvent* );
95 97
96 /** 98 /**
97 Called whenever the user attempts to start a drag in the view. 99 Called whenever the user attempts to start a drag in the view.
98 This method will convert all the selected addressees into text (vcard) 100 This method will convert all the selected addressees into text (vcard)
99 and create a drag object. 101 and create a drag object.
100 */ 102 */
101 void startDrag(); 103 void startDrag();
102 104
103 signals: 105 signals:
104 /** 106 /**
105 Emitted whenever the user selects an entry in the view. 107 Emitted whenever the user selects an entry in the view.
106 */ 108 */
107 void selected( const QString &uid ); 109 void selected( const QString &uid );
108 void deleteRequest( ); 110 void deleteRequest( );
109 111