summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-01-16 12:48:47 (UTC)
committer zautrix <zautrix>2005-01-16 12:48:47 (UTC)
commit3f61f5a339e9c0c67c17b16214abded0d123f246 (patch) (side-by-side diff)
treee3e858f70d85f5a8c6e1547113eae924be73c5c3
parentf3f63a1a1363cba9f58790812e43d6eda14f733c (diff)
downloadkdepimpi-3f61f5a339e9c0c67c17b16214abded0d123f246.zip
kdepimpi-3f61f5a339e9c0c67c17b16214abded0d123f246.tar.gz
kdepimpi-3f61f5a339e9c0c67c17b16214abded0d123f246.tar.bz2
applied AB filters
Diffstat (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
@@ -2854,32 +2854,37 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo
}
}
// fullDateRange = true; // debug only!
if ( fullDateRange )
mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365);
else
mLastAddressbookSync = addresseeLSync.revision();
// for resyncing if own file has changed
// PENDING fixme later when implemented
#if 0
if ( mCurrentSyncDevice == "deleteaftersync" ) {
mLastAddressbookSync = loadedFileVersion;
qDebug("setting mLastAddressbookSync ");
}
#endif
+
+ // ********** setting filters ****************
+ Filter filterIN = mViewManager->getFilterByName( syncManager->mFilterInAB );
+ Filter filterOUT = mViewManager->getFilterByName( syncManager->mFilterOutAB );
+
//qDebug("*************************** ");
// qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() );
QStringList er = remote->uidList();
Addressee inR ;//= er.first();
Addressee inL;
syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count());
int modulo = (er.count()/10)+1;
int incCounter = 0;
while ( incCounter < er.count()) {
if (syncManager->isProgressBarCanceled())
return false;
if ( incCounter % modulo == 0 )
syncManager->showProgressBar(incCounter);
@@ -2933,82 +2938,86 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo
}
idS = inL.IDStr();
local->removeAddressee( inL );
inL = inR;
inL.setIDStr( idS );
if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
}
inL.setResource( 0 );
local->insertAddressee( inL , false );
++changedLocal;
}
}
}
} else { // no conflict ********** add or delete remote
- if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
- QString des = addresseeLSync.note();
- if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
- inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE );
- remote->insertAddressee( inR, false );
- ++deletedAddresseeR;
- } else {
- inR.setRevision( modifiedCalendar );
- remote->insertAddressee( inR, false );
- inL = inR;
- inL.setIDStr( ":" );
- inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
- inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
- inL.setResource( 0 );
- local->insertAddressee( inL , false);
- ++addedAddressee;
- }
- } else {
- if ( inR.revision() > mLastAddressbookSync || mode == 5 ) {
- inR.setRevision( modifiedCalendar );
- remote->insertAddressee( inR, false );
- inR.setResource( 0 );
- local->insertAddressee( inR, false );
- ++addedAddressee;
+ if ( filterIN.name().isEmpty() || filterIN.filterAddressee( inR ) ) {
+ if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
+ QString des = addresseeLSync.note();
+ if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
+ inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE );
+ remote->insertAddressee( inR, false );
+ ++deletedAddresseeR;
+ } else {
+ inR.setRevision( modifiedCalendar );
+ remote->insertAddressee( inR, false );
+ inL = inR;
+ inL.setIDStr( ":" );
+ inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
+ inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
+ inL.setResource( 0 );
+ local->insertAddressee( inL , false);
+ ++addedAddressee;
+ }
} else {
- // pending checkExternSyncAddressee(addresseeRSyncSharp, inR);
- remote->removeAddressee( inR );
- ++deletedAddresseeR;
+ if ( inR.revision() > mLastAddressbookSync || mode == 5 ) {
+ inR.setRevision( modifiedCalendar );
+ remote->insertAddressee( inR, false );
+ inR.setResource( 0 );
+ local->insertAddressee( inR, false );
+ ++addedAddressee;
+ } else {
+ // pending checkExternSyncAddressee(addresseeRSyncSharp, inR);
+ remote->removeAddressee( inR );
+ ++deletedAddresseeR;
+ }
}
}
}
}
++incCounter;
}
er.clear();
QStringList el = local->uidList();
modulo = (el.count()/10)+1;
syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count());
incCounter = 0;
while ( incCounter < el.count()) {
qApp->processEvents();
if (syncManager->isProgressBarCanceled())
return false;
if ( incCounter % modulo == 0 )
syncManager->showProgressBar(incCounter);
uid = el[ incCounter ];
bool skipIncidence = false;
if ( uid.left(19) == QString("last-syncAddressee-") )
skipIncidence = true;
+ if ( !filterOUT.name().isEmpty() && ! filterOUT.filterAddressee( inL ) )
+ skipIncidence = true;
if ( !skipIncidence ) {
inL = local->findByUid( uid );
if ( !inL.resource() || inL.resource()->includeInSync() ) {
inR = remote->findByUid( uid );
if ( inR.isEmpty() ) { // no conflict ********** add or delete local
if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
// pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
local->removeAddressee( inL );
++deletedAddresseeL;
} else {
if ( ! syncManager->mWriteBackExistingOnly ) {
inL.removeID(mCurrentSyncDevice );
++addedAddresseeR;
inL.setRevision( modifiedCalendar );
local->insertAddressee( inL, false );
diff --git a/kaddressbook/viewmanager.cpp b/kaddressbook/viewmanager.cpp
index 59bddd9..9c3a641 100644
--- a/kaddressbook/viewmanager.cpp
+++ b/kaddressbook/viewmanager.cpp
@@ -605,32 +605,41 @@ void ViewManager::configureFilters()
if (QApplication::desktop()->width() == 480 )
cw = 0;
mActionSelectFilter->setComboWidth( cw );
saveSettings();
}
QStringList ViewManager::filterNames() const
{
QStringList names( i18n( "No Filter" ) );
Filter::List::ConstIterator it;
for ( it = mFilterList.begin(); it != mFilterList.end(); ++it )
names.append( (*it).name() );
return names;
}
+Filter ViewManager::getFilterByName( const QString &name ) const
+{
+ Filter::List::ConstIterator it;
+ for ( it = mFilterList.begin(); it != mFilterList.end(); ++it )
+ if ( name == (*it).name() )
+ return (*it);
+
+ return Filter();
+}
int ViewManager::filterPosition( const QString &name ) const
{
int pos = 0;
Filter::List::ConstIterator it;
for ( it = mFilterList.begin(); it != mFilterList.end(); ++it, ++pos )
if ( name == (*it).name() )
return pos + 1;
return 0;
}
void ViewManager::initActions()
{
//US <ActionList name="view_loadedviews"/>
diff --git a/kaddressbook/viewmanager.h b/kaddressbook/viewmanager.h
index a03a83f..272e1b0 100644
--- a/kaddressbook/viewmanager.h
+++ b/kaddressbook/viewmanager.h
@@ -15,63 +15,65 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
As a special exception, permission is given to link this program
with any edition of Qt, and distribute the resulting executable,
without including the source code for Qt in the source distribution.
*/
#ifndef VIEWMANAGER_H
#define VIEWMANAGER_H
#include <qwidget.h>
#include <qstringlist.h>
#include <kaddressbookview.h>
#include <qdict.h>
+#include "filter.h"
class KAction;
class KSelectAction;
class KABCore;
class QWidgetStack;
class QDropEvent;
namespace KABC { class AddressBook; }
/**
The view manager manages the views and everything related to them. The
manager will load the views at startup and display a view when told to
make one active.
The view manager will also create and manage all dialogs directly related to
views (ie: AddView, ConfigureView, DeleteView, etc).
*/
class ViewManager : public QWidget
{
Q_OBJECT
public:
ViewManager( KABCore *core, QWidget *parent, const char *name = 0 );
~ViewManager();
void restoreSettings();
void saveSettings();
void doSearch( const QString& s ,KABC::Field *field );
void unloadViews();
KSelectAction * getFilterAction() { return mActionSelectFilter; }
+ Filter getFilterByName( const QString &name ) const;
QStringList selectedUids() const;
QStringList selectedEmails() const;
KABC::Addressee::List selectedAddressees() const;
void setListSelected(QStringList);
void setFocusAV();
public slots:
void scrollUP();
void scrollDOWN();
//US void setSelected( const QString &uid = QString::null, bool selected = true );
void setSelected( const QString &uid, bool);
//US added another method with no parameter, since my moc compiler does not support default parameters.
void setSelected();