summaryrefslogtreecommitdiffabout
path: root/kaddressbook
authorzautrix <zautrix>2005-03-25 00:08:08 (UTC)
committer zautrix <zautrix>2005-03-25 00:08:08 (UTC)
commit7c2e130ddd194f1c4b5365af6999a27c08232f4b (patch) (side-by-side diff)
tree75665681327ee49d7650f4d840b5c8c772180fb4 /kaddressbook
parent5cf054b82738d65f9b0a34ccb51c993ee4a0189f (diff)
downloadkdepimpi-7c2e130ddd194f1c4b5365af6999a27c08232f4b.zip
kdepimpi-7c2e130ddd194f1c4b5365af6999a27c08232f4b.tar.gz
kdepimpi-7c2e130ddd194f1c4b5365af6999a27c08232f4b.tar.bz2
fixes
Diffstat (limited to 'kaddressbook') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/filtereditdialog.cpp2
-rw-r--r--kaddressbook/kabcore.cpp3
2 files changed, 4 insertions, 1 deletions
diff --git a/kaddressbook/filtereditdialog.cpp b/kaddressbook/filtereditdialog.cpp
index 1194406..ef9b979 100644
--- a/kaddressbook/filtereditdialog.cpp
+++ b/kaddressbook/filtereditdialog.cpp
@@ -113,99 +113,99 @@ Filter FilterEditDialog::filter()
item = item->nextSibling();
}
filter.setCategories( categories );
if ( mMatchRuleGroup->find( 0 )->isOn() )
filter.setMatchRule( Filter::Matching );
else
filter.setMatchRule( Filter::NotMatching );
int c = 0;
if (mPublic->isChecked()) c |= Filter::ShowPublic;
if (mPrivate->isChecked()) c |= Filter::ShowPrivate;
if (mConfidential->isChecked()) c |= Filter::ShowConfidential;
filter.setCriteria( c ) ;
return filter;
}
void FilterEditDialog::initGUI()
{
#ifndef KAB_EMBEDDED
resize( 490, 300 );
#else //KAB_EMBEDDED
resize( KMIN(KGlobal::getDesktopWidth()-10, 490), KMIN(KGlobal::getDesktopHeight()-50, 300));
#endif //KAB_EMBEDDED
QWidget *page = plainPage();
QLabel *label;
QGridLayout *topLayout = new QGridLayout( page, 3, 2, 0, spacingHint() );
label = new QLabel( i18n( "Name" ), page );
mNameEdit = new KLineEdit( page );
mNameEdit->setFocus();
topLayout->addWidget( label, 0, 0 );
topLayout->addWidget( mNameEdit, 0, 1 );
connect( mNameEdit, SIGNAL( textChanged( const QString& ) ),
SLOT( filterNameTextChanged( const QString&) ) );
mCategoriesView = new KListView( page );
mCategoriesView->addColumn( i18n( "Categories" ) );
topLayout->addMultiCellWidget( mCategoriesView, 1, 1, 0, 1 );
mMatchRuleGroup = new QHButtonGroup( i18n( "Category rule" ), page );
mMatchRuleGroup->setExclusive( true );
QRadioButton *radio = new QRadioButton( i18n( "Include categories" ), mMatchRuleGroup );
- radio->setChecked( true );
//mMatchRuleGroup->insert( radio );
radio = new QRadioButton( i18n( "Exclude categories" ), mMatchRuleGroup );
+ radio->setChecked( true );
//mMatchRuleGroup->insert( radio );
topLayout->addMultiCellWidget( mMatchRuleGroup, 2, 2, 0, 1 );
QHButtonGroup * mMatchPPCGroup = new QHButtonGroup(i18n( "Include contacts, that are:" ), page );
mPublic = new QCheckBox( i18n( "public" ), mMatchPPCGroup );
mPrivate = new QCheckBox( i18n( "private" ), mMatchPPCGroup );
mConfidential = new QCheckBox( i18n( "confidential" ), mMatchPPCGroup );
mPublic->setChecked( true );
mPrivate->setChecked( true );
mConfidential->setChecked( true );
topLayout->addMultiCellWidget( mMatchPPCGroup, 3, 3, 0, 1 );
}
void FilterEditDialog::filterNameTextChanged( const QString &text )
{
enableButtonOK( !text.isEmpty() );
}
void FilterEditDialog::slotHelp()
{
#ifndef KAB_EMBEDDED
kapp->invokeHelp( "using-filters" );
#endif //KAB_EMBEDDED
}
FilterDialog::FilterDialog( QWidget *parent, const char *name )
: KDialogBase( Plain, i18n( "Edit Address Book Filters" ),
Ok | Cancel, Ok, parent, name, /*US false*/true, true )
{
initGUI();
}
FilterDialog::~FilterDialog()
{
}
void FilterDialog::setFilters( const Filter::List &list )
{
mFilterList.clear();
mInternalFilterList.clear();
Filter::List::ConstIterator it;
for ( it = list.begin(); it != list.end(); ++it ) {
if ( (*it).isInternal() )
mInternalFilterList.append( *it );
else
mFilterList.append( *it );
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index e8f6132..59aa5a5 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -3141,194 +3141,197 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo
qDebug("KA: WB cancelled ");
syncManager->mWriteBackFile = false;
return syncOK;
}
}
return syncOK;
}
//this is a overwritten callbackmethods from the syncinterface
bool KABCore::sync(KSyncManager* manager, 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;
if ( manager != syncManager )
qDebug("KABCore::sync:: ERROR! :: manager != syncManager ");
QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
AddressBook abLocal(filename,"syncContact");
bool syncOK = false;
if ( abLocal.load() ) {
qDebug("KA: Sync::AB loaded %s,sync mode %d",filename.latin1(), mode );
bool external = false;
bool isXML = false;
if ( filename.right(4) == ".xml") {
mGlobalSyncMode = SYNC_MODE_EXTERNAL;
isXML = true;
abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true );
} else {
external = !manager->mIsKapiFile;
if ( external ) {
qDebug("KA: Sync::Setting vcf mode to external ");
mGlobalSyncMode = SYNC_MODE_EXTERNAL;
AddressBook::Iterator it;
for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
(*it).setID( mCurrentSyncDevice, (*it).uid() );
(*it).computeCsum( mCurrentSyncDevice );
}
}
}
//AddressBook::Iterator it;
//QStringList vcards;
//for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
// qDebug("Name %s ", (*it).familyName().latin1());
//}
syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode );
+ syncManager->hideProgressBar();
if ( syncOK ) {
if ( syncManager->mWriteBackFile )
{
if ( external )
abLocal.removeSyncAddressees( !isXML);
qDebug("KA: Sync::Saving remote AB ");
if ( ! abLocal.saveAB())
qDebug("KA: sync::Error writing back AB to file ");
if ( external ) {
// afterwrite processing
abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML);
}
}
}
setModified();
}
abLocal.removeResources();
if ( syncOK )
mViewManager->refreshView();
return syncOK;
}
void KABCore::removeSyncInfo( QString syncProfile)
{
qDebug("KA: AB:removeSyncInfo for profile %s ", syncProfile.latin1());
mAddressBook->removeSyncInfo( syncProfile );
setModified();
}
//this is a overwritten callbackmethods from the syncinterface
bool KABCore::syncExternal(KSyncManager* manager, QString resource)
{
if ( resource == "phone" )
return syncPhone();
disableBR( true );
if ( manager != syncManager )
qDebug("KABCore::syncExternal:: ERROR! :: manager != syncManager ");
QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
AddressBook abLocal( resource,"syncContact");
bool syncOK = false;
message(i18n("Loading DTM address data..."), false);
if ( abLocal.load() ) {
qDebug("KA: AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1());
mGlobalSyncMode = SYNC_MODE_EXTERNAL;
message(i18n("Sync preprocessing..."),false);
abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false );
message(i18n("Synchronizing..."),false);
syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs );
+ syncManager->hideProgressBar();
if ( syncOK ) {
if ( syncManager->mWriteBackFile ) {
abLocal.removeSyncAddressees( false );
message(i18n("Saving DTM address data..."),false);
abLocal.saveAB();
message(i18n("Sync postprocessing..."),false);
abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true );
}
} else
message( i18n("Sync cancelled or failed.") );
setModified();
}
abLocal.removeResources();
if ( syncOK ) {
mViewManager->refreshView();
message(i18n("DTM syncing finished."));
}
disableBR( false );
return syncOK;
}
void KABCore::message( QString m, bool startTimer)
{
topLevelWidget()->setCaption( m );
qApp->processEvents();
if ( startTimer )
mMessageTimer->start( 15000, true );
else
mMessageTimer->stop();
}
bool KABCore::syncPhone()
{
QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
QString fileName = getPhoneFile();
if ( !PhoneAccess::readFromPhone( fileName) ) {
message(i18n("Phone access failed!"));
return false;
}
AddressBook abLocal( fileName,"syncContact");
bool syncOK = false;
{
abLocal.importFromFile( fileName );
qDebug("KA: AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1());
mGlobalSyncMode = SYNC_MODE_EXTERNAL;
abLocal.preparePhoneSync( mCurrentSyncDevice, true );
abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true );
syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs );
+ syncManager->hideProgressBar();
if ( syncOK ) {
if ( syncManager->mWriteBackFile ) {
abLocal.removeSyncAddressees( true );
abLocal.saveABphone( fileName );
abLocal.findNewExtIds( fileName, mCurrentSyncDevice );
//abLocal.preparePhoneSync( mCurrentSyncDevice, false );
abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true );
}
}
setModified();
}
abLocal.removeResources();
if ( syncOK )
mViewManager->refreshView();
return syncOK;
}
void KABCore::getFile( bool success )
{
if ( ! success ) {
message( i18n("Error receiving file. Nothing changed!") );
return;
}
int count = mAddressBook->importFromFile( sentSyncFile() , false, true );
if ( count )
setModified( true );
message( i18n("Pi-Sync successful!") );
mViewManager->refreshView();
}
void KABCore::syncFileRequest()
{
if ( KABPrefs::instance()->mPassiveSyncWithDesktop ) {
syncManager->slotSyncMenu( 999 );
}
mAddressBook->export2File( sentSyncFile() );
}
QString KABCore::sentSyncFile()
{
#ifdef DESKTOP_VERSION
return locateLocal( "tmp", "copysyncab.vcf" );
#else
return QString( "/tmp/copysyncab.vcf" );
#endif
}
void KABCore::setCaptionBack()
{
mMessageTimer->stop();
topLevelWidget()->setCaption( i18n("KAddressbook/Pi") );