summaryrefslogtreecommitdiffabout
path: root/kabc
Side-by-side diff
Diffstat (limited to 'kabc') (more/less context) (show whitespace changes)
-rw-r--r--kabc/addressbook.cpp2
-rw-r--r--kabc/plugins/dir/resourcedir.cpp2
-rw-r--r--kabc/plugins/file/resourcefile.cpp28
-rw-r--r--kabc/plugins/ldap/resourceldap.cpp2
-rw-r--r--kabc/plugins/opie/resourceopie.cpp2
-rw-r--r--kabc/plugins/qtopia/resourceqtopia.cpp2
-rw-r--r--kabc/plugins/sharpdtm/resourcesharpdtm.cpp2
-rw-r--r--kabc/resource.cpp5
-rw-r--r--kabc/resource.h2
-rw-r--r--kabc/stdaddressbook.cpp6
-rw-r--r--kabc/syncprefwidget.cpp581
-rw-r--r--kabc/syncprefwidget.h138
12 files changed, 350 insertions, 422 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp
index 20310a0..c61b387 100644
--- a/kabc/addressbook.cpp
+++ b/kabc/addressbook.cpp
@@ -235,7 +235,7 @@ void AddressBook::init(const QString &config, const QString &family )
{
d = new AddressBookData;
if (config != 0) {
- d->mConfig = new KConfig( config );
+ d->mConfig = new KConfig( locateLocal("config", config) );
// qDebug("AddressBook::init 1 config=%s",config.latin1() );
}
else {
diff --git a/kabc/plugins/dir/resourcedir.cpp b/kabc/plugins/dir/resourcedir.cpp
index 29f1e3a..eccd482 100644
--- a/kabc/plugins/dir/resourcedir.cpp
+++ b/kabc/plugins/dir/resourcedir.cpp
@@ -71,7 +71,7 @@ __declspec(dllexport)
//US void *init_kabc_dir()
void *init_microkabc_dir()
{
- return new KRES::PluginFactory<ResourceDir,ResourceDirConfig, SyncPrefWidget>();
+ return new KRES::PluginFactory<ResourceDir,ResourceDirConfig, SyncPrefWidgetContainer>();
}
#ifndef _WIN32_
}
diff --git a/kabc/plugins/file/resourcefile.cpp b/kabc/plugins/file/resourcefile.cpp
index d98efc8..da2e4d7 100644
--- a/kabc/plugins/file/resourcefile.cpp
+++ b/kabc/plugins/file/resourcefile.cpp
@@ -66,7 +66,7 @@ __declspec(dllexport)
//US void *init_kabc_file()
void *init_microkabc_file()
{
- return new KRES::PluginFactory<ResourceFile,ResourceFileConfig, SyncPrefWidget>();
+ return new KRES::PluginFactory<ResourceFile,ResourceFileConfig, SyncPrefWidgetContainer>();
}
#ifndef _WIN32_
}
@@ -75,17 +75,20 @@ __declspec(dllexport)
ResourceFile::ResourceFile( const KConfig *config, bool syncable )
: Resource( config, syncable ) , mFormat( 0 )
{
- QString fileName, formatName;
+ QString fileName, formatName, default_fileName;
+
+ if (syncable == true)
+ default_fileName = "/home/polo/kdepim/apps/kabc/localfile.vcf";
+ else
+ default_fileName = StdAddressBook::fileName();
KConfig *cfg = (KConfig *)config;
if ( cfg ) {
- fileName = cfg->readEntry( "FileName", StdAddressBook::fileName() );
+ fileName = cfg->readEntry( "FileName", default_fileName );
formatName = cfg->readEntry( "FileFormat", "vcard" );
-// qDebug("ResourceFile::ResourceFile : 1 %s, %s", fileName.latin1(), formatName.latin1() );
} else {
- fileName = StdAddressBook::fileName();
+ fileName = default_fileName;
formatName = "vcard";
-// qDebug("ResourceFile::ResourceFile : 2 %s, %s", fileName.latin1(), formatName.latin1() );
}
init( fileName, formatName );
@@ -111,19 +114,6 @@ void ResourceFile::init( const QString &fileName, const QString &formatName )
mFormat = factory->format( mFormatName );
}
-/*US
-//US qDebug("ResourceFile::init initialized with format %s ", formatName.latin1());
- if (mFormatName == "vcard") {
- mFormat = new VCardFormatPlugin2();
-// qDebug("ResourceFile::init format VCardFormatPlugin2");
- }
- else if (mFormatName == "binary") {
- mFormat = new BinaryFormat();
-// qDebug("ResourceFile::init format BinaryFormat");
- }
- else
- qDebug("ResourceFile::init format unknown !!! %s ", formatName.latin1());
-*/
connect( &mDirWatch, SIGNAL( dirty(const QString&) ), SLOT( fileChanged() ) );
connect( &mDirWatch, SIGNAL( created(const QString&) ), SLOT( fileChanged() ) );
diff --git a/kabc/plugins/ldap/resourceldap.cpp b/kabc/plugins/ldap/resourceldap.cpp
index 198e80a..17f115d 100644
--- a/kabc/plugins/ldap/resourceldap.cpp
+++ b/kabc/plugins/ldap/resourceldap.cpp
@@ -45,7 +45,7 @@ extern "C"
//US void *init_kabc_ldap()
void *init_microkabc_ldap()
{
- return new KRES::PluginFactory<ResourceLDAP,ResourceLDAPConfig, SyncPrefWidget>();
+ return new KRES::PluginFactory<ResourceLDAP,ResourceLDAPConfig, SyncPrefWidgetContainer>();
}
}
diff --git a/kabc/plugins/opie/resourceopie.cpp b/kabc/plugins/opie/resourceopie.cpp
index 9dfd473..4b811e9 100644
--- a/kabc/plugins/opie/resourceopie.cpp
+++ b/kabc/plugins/opie/resourceopie.cpp
@@ -61,7 +61,7 @@ extern "C"
{
void *init_microkabc_opie()
{
- return new KRES::PluginFactory<ResourceOpie,ResourceOpieConfig, SyncPrefWidget>();
+ return new KRES::PluginFactory<ResourceOpie,ResourceOpieConfig, SyncPrefWidgetContainer>();
}
}
diff --git a/kabc/plugins/qtopia/resourceqtopia.cpp b/kabc/plugins/qtopia/resourceqtopia.cpp
index 5565580..93a4d33 100644
--- a/kabc/plugins/qtopia/resourceqtopia.cpp
+++ b/kabc/plugins/qtopia/resourceqtopia.cpp
@@ -58,7 +58,7 @@ extern "C"
{
void *init_microkabc_qtopia()
{
- return new KRES::PluginFactory<ResourceQtopia,ResourceQtopiaConfig, SyncPrefWidget>();
+ return new KRES::PluginFactory<ResourceQtopia,ResourceQtopiaConfig, SyncPrefWidgetContainer>();
}
}
diff --git a/kabc/plugins/sharpdtm/resourcesharpdtm.cpp b/kabc/plugins/sharpdtm/resourcesharpdtm.cpp
index 70c3718..b63df0c 100644
--- a/kabc/plugins/sharpdtm/resourcesharpdtm.cpp
+++ b/kabc/plugins/sharpdtm/resourcesharpdtm.cpp
@@ -60,7 +60,7 @@ extern "C"
{
void *init_microkabc_sharpdtm()
{
- return new KRES::PluginFactory<ResourceSharpDTM,ResourceSharpDTMConfig,SyncPrefWidget>();
+ return new KRES::PluginFactory<ResourceSharpDTM,ResourceSharpDTMConfig,SyncPrefWidgetContainer>();
}
}
diff --git a/kabc/resource.cpp b/kabc/resource.cpp
index 2f03927..d39fd6a 100644
--- a/kabc/resource.cpp
+++ b/kabc/resource.cpp
@@ -113,6 +113,11 @@ bool Resource::isSyncable() const
return (mSyncProfile != 0);
}
+KSyncProfile* Resource::getSyncProfile()
+{
+ return mSyncProfile;
+}
+
QString Resource::fileName() const
{
diff --git a/kabc/resource.h b/kabc/resource.h
index 7d42f81..2024d2d 100644
--- a/kabc/resource.h
+++ b/kabc/resource.h
@@ -142,6 +142,8 @@ public:
virtual bool isSyncable() const;
+ virtual KSyncProfile* getSyncProfile();
+
/**
* Set the name of resource.You can override this method,
* but also remember to call Resource::setResourceName().
diff --git a/kabc/stdaddressbook.cpp b/kabc/stdaddressbook.cpp
index 1e00cc6..760820e 100644
--- a/kabc/stdaddressbook.cpp
+++ b/kabc/stdaddressbook.cpp
@@ -112,16 +112,14 @@ StdAddressBook *StdAddressBook::self( bool onlyFastResources )
}
StdAddressBook::StdAddressBook()
-//US : AddressBook( "kabcrc" )
- : AddressBook( locateLocal( "config", "kabcrc") )
+ : AddressBook( "kabcrc" )
{
init( false );
}
StdAddressBook::StdAddressBook( bool onlyFastResources )
-//US : AddressBook( "kabcrc" )
- : AddressBook( locateLocal( "config", "kabcrc") )
+ : AddressBook( "kabcrc" )
{
init( onlyFastResources );
diff --git a/kabc/syncprefwidget.cpp b/kabc/syncprefwidget.cpp
index 51a8040..a2bde72 100644
--- a/kabc/syncprefwidget.cpp
+++ b/kabc/syncprefwidget.cpp
@@ -25,50 +25,6 @@
$Id$
*/
-/*US
-#include <qlayout.h>
-#include <qlabel.h>
-#include <qgroupbox.h>
-#include <qbuttongroup.h>
-#include <qlineedit.h>
-#include <qfont.h>
-#include <qslider.h>
-#include <qfile.h>
-#include <qtextstream.h>
-#include <qcombobox.h>
-#include <qvbox.h>
-#include <qhbox.h>
-#include <qspinbox.h>
-#include <qdatetime.h>
-#include <qcheckbox.h>
-#include <qradiobutton.h>
-#include <qpushbutton.h>
-#include <qstrlist.h>
-#include <qapplication.h>
-
-#include <kcolorbutton.h>
-#include <kdebug.h>
-#include <klocale.h>
-#include <kglobal.h>
-#include <kfontdialog.h>
-#include <kmessagebox.h>
-#include <kcolordialog.h>
-#include <kiconloader.h>
-#include <kemailsettings.h>
-#include <kstandarddirs.h>
-#include <kfiledialog.h>
-#include <kmessagebox.h>
-
-#include <kurlrequester.h>
-#include <klineedit.h>
-#include <libkdepim/ksyncprofile.h>
-
-
-#include "koprefs.h"
-
-#include "kosyncprefsdialog.h"
-#include "koglobals.h"
-*/
#include <qlayout.h>
#include <qbuttongroup.h>
@@ -79,101 +35,36 @@ $Id$
#include <qlabel.h>
#include <qlineedit.h>
#include <qpushbutton.h>
+#include <qscrollview.h>
+#include <qcombobox.h>
#include <klocale.h>
#include <kdialog.h>
-
+#include "ksyncprofile.h"
+#include "resource.h"
#include "syncprefwidget.h"
-SyncPrefWidget::SyncPrefWidget(QWidget *parent) :
- KRES::SyncWidget(parent)
+SyncPrefWidget_Settings::SyncPrefWidget_Settings(QWidget *parent, const char *name) :
+ KRES::SyncWidget(parent, name)
{
-
-//US setCaption( i18n("Synchronization Preferences"));
-
-//US mSyncProfiles.setAutoDelete( true );
init();
}
-SyncPrefWidget::~SyncPrefWidget()
+SyncPrefWidget_Settings::~SyncPrefWidget_Settings()
{
}
-//US #include <qlayout.h>
-//US #include <qscrollview.h>
-void SyncPrefWidget::init()
+void SyncPrefWidget_Settings::init()
{
- QLabel * lab;
- QPushButton* button;
-
-/*US
- //QFrame *page = addPage(i18n("Sync Prefs"),0,0);
- QVBox * mainbox = new QVBox( this );
- QScrollView* sv = new QScrollView( mainbox );
- QHBoxLayout * lay = new QHBoxLayout( this );
- lay->addWidget( mainbox );
- QHBox * b_box = new QHBox( mainbox );
-*/
-/*US
- QPushButton* button = new QPushButton( i18n("Ok"), b_box );
- connect ( button, SIGNAL( clicked()), this, SLOT (slotOK() ) );
- button = new QPushButton( i18n("Cancel"), b_box );
- connect ( button, SIGNAL( clicked()), this, SLOT (reject() ) );
-*/
- //QBoxLayout * sl = new QVBoxLayout(this );
- //sl->addWidget ( sv );
-/*US
- sv->setResizePolicy ( QScrollView::AutoOneFit );
- QFrame *topFrame = new QFrame ( sv );
- sv->addChild( topFrame );
- mSetupSyncAlgTab = topFrame;
- QGridLayout *topLayout = new QGridLayout(topFrame,6,2);
- topLayout->setSpacing(spacingHint());
- topLayout->setMargin(marginHint());
-*/
-//US new code for the layout
QGridLayout *topLayout = new QGridLayout( this, 6,2 );
topLayout->setMargin( KDialog::marginHint() );
topLayout->setSpacing( KDialog::spacingHint() );
- //lab = new QLabel(i18n("Sync settings not yet implemented. DO NOT USE!"), topFrame);
int iii = 0;
- //topLayout->addMultiCellWidget(lab , iii,iii,0,1);
- //++iii;
-
-/*US
- mMyMachineName = new QLineEdit(topFrame);
- lab = new QLabel(mMyMachineName, i18n("Local device name:"), topFrame);
- topLayout->addWidget(lab ,iii,0);
- topLayout->addWidget(mMyMachineName,iii,1);
- ++iii;
-
- QHBox* buttonbox = new QHBox( topFrame);
- topLayout->addMultiCellWidget(buttonbox, iii,iii,0,1);
- ++iii;
- button = new QPushButton( i18n("New profile"), buttonbox );
- connect ( button, SIGNAL( clicked()), this, SLOT (newProfile() ) );
-
- button = new QPushButton( i18n("Clone profile"), buttonbox );
- connect ( button, SIGNAL( clicked()), this, SLOT ( cloneProfile() ) );
-
- button = new QPushButton( i18n("Delete profile"), buttonbox );
- connect ( button, SIGNAL( clicked()), this, SLOT (deleteProfile() ) );
-
- mProfileBox = new QComboBox(topFrame);
- mProfileBox->setEditable ( true );
- connect ( mProfileBox, SIGNAL(activated ( int ) ), this, SLOT (profileChanged( int ) ) );
- connect ( mProfileBox, SIGNAL( textChanged ( const QString & ) ), this, SLOT (textChanged( const QString & ) ) );
-
- lab = new QLabel(mProfileBox, i18n("Profile:"), topFrame);
- topLayout->addWidget(lab ,iii,0);
- topLayout->addWidget(mProfileBox, iii,1);
- ++iii;
-*/
mIncludeInRing = new QCheckBox( i18n("Include in multiple sync"), this );
topLayout->addMultiCellWidget(mIncludeInRing, iii,iii,0,1);
++iii;
@@ -181,16 +72,6 @@ void SyncPrefWidget::init()
mAskForPreferences = new QCheckBox( i18n("Ask for preferences before sync"), this );
topLayout->addMultiCellWidget(mAskForPreferences, iii,iii,0,1);
++iii;
- QButtonGroup* gr = new QButtonGroup ( 1, Qt::Horizontal, i18n("Sync preferences"), this);
- topLayout->addMultiCellWidget(gr, iii,iii,0,1);
- ++iii;
- loc = new QRadioButton ( i18n("Take local entry on conflict"), gr );
- rem = new QRadioButton ( i18n("Take remote entry on conflict"), gr );
- newest = new QRadioButton ( i18n("Take newest entry on conflict"), gr );
- ask = new QRadioButton ( i18n("Ask for every entry on conflict"), gr );
- f_loc= new QRadioButton ( i18n("Force: Take local entry always"), gr );
- f_rem = new QRadioButton ( i18n("Force: Take remote entry always"), gr );
- // both = new QRadioButton ( i18n("Take both on conflict"), gr );
mShowSummaryAfterSync = new QCheckBox( i18n("Show summary after sync"), this );
topLayout->addMultiCellWidget(mShowSummaryAfterSync, iii,iii,0,1);
@@ -200,123 +81,95 @@ void SyncPrefWidget::init()
topLayout->addMultiCellWidget(mWriteBackExisting, iii,iii,0,1);
++iii;
- mWriteBackFile = new QCheckBox( i18n("Write back file"), this );
+ mWriteBackFile = new QCheckBox( i18n("Write back synced data"), this );
topLayout->addMultiCellWidget(mWriteBackFile, iii,iii,0,1);
++iii;
- mIsNotLocal = new QCheckBox( i18n("Remote file (w down/upload command)"), this );
- topLayout->addMultiCellWidget(mIsNotLocal, iii,iii,0,1);
- connect (mIsNotLocal, SIGNAL( checked(bool)), this, SLOT (kindChanged(bool) ) );
-/*US
- proGr = new QButtonGroup ( 1, Qt::Horizontal, i18n("Profile kind"), this);
- gr = proGr;
- topLayout->addMultiCellWidget(gr, iii,iii,0,1);
- ++iii;
- mIsLocal = new QRadioButton ( i18n("Local file"), gr );
- mIsNotLocal = new QRadioButton ( i18n("Remote file (w down/upload command)"), gr );
- connect (mIsLocal, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) );
-*/
+}
-/*US
- localFileWidget = new QVBox( topFrame);
- topLayout->addMultiCellWidget(localFileWidget, iii,iii,0,1);
- ++iii;
- QHBox* temphb = new QHBox( localFileWidget );
- lab = new QLabel( i18n("Local file:"), temphb);
- mRemoteFile = new QLineEdit(localFileWidget);
+void SyncPrefWidget_Settings::loadSettings( KRES::Resource *res )
+{
+ KABC::Resource* resource = (KABC::Resource*)( res );
+ KSyncProfile* prof = resource->getSyncProfile();
- button = new QPushButton( i18n("Choose..."), temphb );
- connect ( button, SIGNAL( clicked()), this, SLOT ( chooseFile() ) );
-*/
- QHBox* temphb;
+ if (prof == 0)
+ {
+ qDebug("SyncPrefWidget_Settings::loadSettings: something is wrong, because resource does have no syncprofile" );
+ return;
+ }
- remoteFileWidget = new QVBox( this);
- topLayout->addMultiCellWidget(remoteFileWidget, iii,iii,0,1);
- ++iii;
- lab = new QLabel( i18n("Pre sync (download) command:"), remoteFileWidget);
- mRemotePrecommand = new QLineEdit(remoteFileWidget);
+ mIncludeInRing->setChecked( prof->getIncludeInRingSync() );
+ mAskForPreferences->setChecked( prof->getAskForPreferences());
+ mShowSummaryAfterSync->setChecked( prof->getShowSummaryAfterSync());
+ mWriteBackExisting->setChecked( prof->getWriteBackExisting() );
+ mWriteBackFile->setChecked( prof->getWriteBackFile());
+}
- lab = new QLabel( i18n("Local temp file:"), remoteFileWidget);
- mLocalTempFile = new QLineEdit(remoteFileWidget);
+void SyncPrefWidget_Settings::saveSettings( KRES::Resource *res )
+{
+ KABC::Resource* resource = (KABC::Resource*)( res );
+ KSyncProfile* prof = resource->getSyncProfile();
+ if (prof == 0)
+ {
+ qDebug("SyncPrefWidget_Settings::saveSettings: something is wrong, because resource does have no syncprofile" );
+ return;
+ }
- lab = new QLabel( i18n("Post sync (upload) command:"), remoteFileWidget);
- mRemotePostcommand = new QLineEdit(remoteFileWidget);
+ prof->setIncludeInRingSync( mIncludeInRing->isChecked() );
+ prof->setAskForPreferences( mAskForPreferences->isChecked());
+ prof->setShowSummaryAfterSync( mShowSummaryAfterSync->isChecked() );
+ prof->setWriteBackExisting(mWriteBackExisting->isChecked() );
+ prof->setWriteBackFile( mWriteBackFile->isChecked());
+}
- lab = new QLabel( i18n("Fill in default values for:"), remoteFileWidget);
- temphb = new QHBox( remoteFileWidget );
- button = new QPushButton( i18n("ssh/scp"), temphb );
- connect ( button, SIGNAL( clicked()), this, SLOT (fillSSH() ) );
- button = new QPushButton( i18n("ftp"), temphb );
- connect ( button, SIGNAL( clicked()), this, SLOT (fillFTP() ) );
- lab = new QLabel( i18n("Hint: Use $PWD$ for placeholder of password!"), remoteFileWidget);
+/***********************************************************************
+ *
+ *
+ **********************************************************************/
-}
-/*US
-void SyncPrefWidget::slotOK()
+SyncPrefWidget_Conflict::SyncPrefWidget_Conflict(QWidget *parent, const char *name) :
+ KRES::SyncWidget(parent, name)
{
- if ( mMyMachineName->text() == "undefined" ) {
- KMessageBox::error(this,i18n("Local device name undefined!\nPlease define device name!"),i18n("KO/Pi config error"));
- return;
- }
- int i;
- for (i = 0; i < mSyncProfileNames.count(); ++ i) {
- if ( mSyncProfileNames.contains( mSyncProfileNames[i]) > 1 ) {
- KMessageBox::error(this,i18n("Multiple profiles with same name!\nPlease use unique profile names!"),i18n("KO/Pi config error"));
- return;
- }
- }
- usrWriteConfig();
- QDialog::accept();
+ init();
}
-void SyncPrefWidget::accept()
+
+
+SyncPrefWidget_Conflict::~SyncPrefWidget_Conflict()
{
- slotOK();
}
-void KOSyncPrefsDialog::chooseFile()
+
+void SyncPrefWidget_Conflict::init()
{
- QString fn =KOPrefs::instance()->mLastSyncedLocalFile;
+ QGridLayout *topLayout = new QGridLayout( this, 6,2 );
+ topLayout->setMargin( KDialog::marginHint() );
+ topLayout->setSpacing( KDialog::spacingHint() );
- fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this );
- if ( fn == "" )
- return;
- mRemoteFile->setText( fn );
+ int iii = 0;
+
+ QButtonGroup* gr = new QButtonGroup ( 1, Qt::Horizontal, i18n("In case of conflicts"), this);
+ topLayout->addMultiCellWidget(gr, iii,iii,0,1);
+ ++iii;
+ loc = new QRadioButton ( i18n("Take local entry on conflict"), gr );
+ rem = new QRadioButton ( i18n("Take remote entry on conflict"), gr );
+ newest = new QRadioButton ( i18n("Take newest entry on conflict"), gr );
+ ask = new QRadioButton ( i18n("Ask for every entry on conflict"), gr );
+ f_loc= new QRadioButton ( i18n("Force: Take local entry always"), gr );
+ f_rem = new QRadioButton ( i18n("Force: Take remote entry always"), gr );
+ // both = new QRadioButton ( i18n("Take both on conflict"), gr );
}
-void KOSyncPrefsDialog::textChanged( const QString & s )
+void SyncPrefWidget_Conflict::loadSettings( KRES::Resource *res )
{
- if ( mProfileBox->count() == 0 )
- return;
- if ( currentSelection < 3 ) {
- //KMessageBox::error(this,i18n("This profil name\ncannot be edited!\n"),i18n("KO/Pi config error"));
- mProfileBox->blockSignals( true );
- mProfileBox->setCurrentItem(mProfileBox-> currentItem ());
- mProfileBox->blockSignals( false );
+ KABC::Resource* resource = (KABC::Resource*)( res );
+ KSyncProfile* prof = resource->getSyncProfile();
+
+ if (prof == 0)
+ {
+ qDebug("SyncPrefWidget_Conflict::loadSettings: something is wrong, because resource does have no syncprofile" );
return;
}
- //qDebug("cur i %d ",mProfileBox-> currentItem () );
- mProfileBox->changeItem ( s, mProfileBox-> currentItem () ) ;
- KSyncProfile* prof = mSyncProfiles.at(mProfileBox-> currentItem ()) ;
- prof->setName( s );
- mSyncProfileNames[mProfileBox-> currentItem ()] = s;
-}
-void KOSyncPrefsDialog::profileChanged( int item )
-{
- //qDebug("KOSyncPrefsDialog::profileChanged %d ", item );
- KSyncProfile* prof;
- saveProfile();
- currentSelection = item;
- prof = mSyncProfiles.at(item) ;
- mRemotePrecommand->setText(prof->getPreSyncCommand());
- mRemotePostcommand->setText(prof->getPostSyncCommand());
- mLocalTempFile->setText(prof->getLocalTempFile());
- mRemoteFile->setText(prof->getRemoteFileName()) ;
- mShowSummaryAfterSync->setChecked( prof->getShowSummaryAfterSync());
- mAskForPreferences->setChecked( prof->getAskForPreferences());
- mWriteBackExisting->setChecked( prof->getWriteBackExisting() );
- mWriteBackFile->setChecked( prof->getWriteBackFile());
- mIncludeInRing->setChecked( prof->getIncludeInRingSync() );
switch ( prof->getSyncPrefs() ) {
case 0:
@@ -343,153 +196,215 @@ void KOSyncPrefsDialog::profileChanged( int item )
default:
break;
}
- mIsLocal->setChecked(prof->getIsLocalFileSync()) ;
- mIsNotLocal->setChecked(!prof->getIsLocalFileSync());
- proGr->setEnabled( item > 2 );
- if ( item < 3 ) {
- localFileWidget->setEnabled(false);
- remoteFileWidget->setEnabled(false);
-
- } else
- kindChanged( prof->getIsLocalFileSync() );
}
-void KOSyncPrefsDialog::fillSSH()
+void SyncPrefWidget_Conflict::saveSettings( KRES::Resource *res )
{
- mRemotePrecommand->setText("scp zaurus@192.168.0.65:/home/zaurus/kdepim/apps/korganizer/mycalendar.ics /tmp/mycalendar.ics" );
- mLocalTempFile->setText("/tmp/mycalendar.ics" );
- mRemotePostcommand->setText("scp /tmp/mycalendar.ics zaurus@192.168.0.65:/home/zaurus/kdepim/apps/korganizer/mycalendar.ics" );
+ KABC::Resource* resource = (KABC::Resource*)( res );
+ KSyncProfile* prof = resource->getSyncProfile();
+
+ if (prof == 0)
+ {
+ qDebug("SyncPrefWidget_Conftlict::saveSettings: something is wrong, because resource does have no syncprofile" );
+ return;
}
-void KOSyncPrefsDialog::fillFTP()
+
+ int syncprefs = rem->isChecked()*1+newest->isChecked()*2+ ask->isChecked()*3+ f_loc->isChecked()*4+ f_rem->isChecked()*5 ;//+ both->isChecked()*6 ;
+ prof->setSyncPrefs( syncprefs );
+
+}
+
+
+/***********************************************************************
+ *
+ *
+ **********************************************************************/
+
+SyncPrefWidget_Remote::SyncPrefWidget_Remote(QWidget *parent, const char *name) :
+ KRES::SyncWidget(parent, name)
{
- mRemotePrecommand->setText("cd /tmp;ftp ftp://zaurus:a@192.168.0.65/kdepim/apps/korganizer/mycalendar.ics" );
- mLocalTempFile->setText("/tmp/mycalendar.ics" );
- mRemotePostcommand->setText("ftp -u ftp://zaurus:a@192.168.0.65/kdepim/apps/korganizer/mycalendar.ics /tmp/mycalendar.ics" );
+ init();
+}
+
+SyncPrefWidget_Remote::~SyncPrefWidget_Remote()
+{
}
-void KOSyncPrefsDialog::kindChanged( bool b )
+
+void SyncPrefWidget_Remote::init()
{
+ QLabel * lab;
+ QPushButton* button;
+
+
+ QGridLayout *topLayout = new QGridLayout( this, 6,2 );
+ topLayout->setMargin( KDialog::marginHint() );
+ topLayout->setSpacing( KDialog::spacingHint() );
+
+ int iii = 0;
+
+ QButtonGroup* gr;
+
+ QButtonGroup *proGr = new QButtonGroup ( 1, Qt::Horizontal, i18n("Profile kind"), this);
+ gr = proGr;
+ topLayout->addMultiCellWidget(gr, iii,iii,0,1);
+ ++iii;
+ mProfileKind = new QComboBox( gr );
+
+ mProfileKind->insertItem( i18n("Local file"), Local );
+ mProfileKind->insertItem( i18n("Remote file (w down/upload cmd)"),Remote );
+ mProfileKind->insertItem( i18n("Mobile device (cell phone)"), Mobile );
+
+ connect( mProfileKind, SIGNAL( activated( int ) ),
+ this, SLOT (kindChanged( int ) ) );
- localFileWidget->setEnabled(b);
- remoteFileWidget->setEnabled(!b);
+
+ QHBox* temphb;
+
+ remoteFileWidget = new QVBox( this);
+ topLayout->addMultiCellWidget(remoteFileWidget, iii,iii,0,1);
+ ++iii;
+ lab = new QLabel( i18n("Pre sync (download) command:"), remoteFileWidget);
+ mRemotePrecommand = new QLineEdit(remoteFileWidget);
+
+ lab = new QLabel( i18n("Local temp file (=Location):"), remoteFileWidget);
+ mLocalTempFile = new QLineEdit(remoteFileWidget);
+ mLocalTempFile->setEnabled(false);
+
+
+ lab = new QLabel( i18n("Post sync (upload) command:"), remoteFileWidget);
+ mRemotePostcommand = new QLineEdit(remoteFileWidget);
+
+ lab = new QLabel( i18n("Fill in default values for:"), remoteFileWidget);
+ temphb = new QHBox( remoteFileWidget );
+ button = new QPushButton( i18n("ssh/scp"), temphb );
+ connect ( button, SIGNAL( clicked()), this, SLOT (fillSSH() ) );
+ button = new QPushButton( i18n("ftp"), temphb );
+ connect ( button, SIGNAL( clicked()), this, SLOT (fillFTP() ) );
+ lab = new QLabel( i18n("Hint: Use $PWD$ for placeholder of password!"), remoteFileWidget);
}
-void KOSyncPrefsDialog::deleteProfile()
+
+void SyncPrefWidget_Remote::loadSettings( KRES::Resource *res )
+{
+ KABC::Resource* resource = (KABC::Resource*)( res );
+ KSyncProfile* prof = resource->getSyncProfile();
+
+ if (prof == 0)
{
- //qDebug("KOSyncPrefsDialog::deleteProfile() ");
- if ( currentSelection >= 0 ) {
- if ( currentSelection < 3 ) {
- KMessageBox::error(this,i18n("This profil cannot be deleted!\n"),i18n("KO/Pi config error"));
+ qDebug("SyncPrefWidget_Remote::loadSettings: something is wrong, because resource does have no syncprofile" );
return;
}
- KSyncProfile* temp = mSyncProfiles.at(currentSelection);
- mSyncProfiles.remove( temp );
- mSyncProfileNames.remove( mSyncProfileNames.at( currentSelection ));
- insertProfiles();
+
+ int val;
+
+ if (prof->getIsPhoneSync())
+ val = Mobile;
+ else if (!prof->getIsLocalFileSync())
+ val = Remote;
+ else // default value
+ val = Local;
+
+ mProfileKind->setCurrentItem( val );
+ kindChanged( val );
+
+
+ mRemotePrecommand->setText(prof->getPreSyncCommand());
+ mLocalTempFile->setText(resource->fileName());
+ mRemotePostcommand->setText(prof->getPostSyncCommand());
}
+
+void SyncPrefWidget_Remote::saveSettings( KRES::Resource *res )
+{
+ KABC::Resource* resource = (KABC::Resource*)( res );
+ KSyncProfile* prof = resource->getSyncProfile();
+
+ if (prof == 0)
+ {
+ qDebug("SyncPrefWidget_Remote::saveSettings: something is wrong, because resource does have no syncprofile" );
+ return;
}
-void KOSyncPrefsDialog::saveProfile()
+ int val = mProfileKind->currentItem();
+
+ if (val == Mobile)
+ {
+ prof->setIsLocalFileSync(true);
+ prof->setIsPhoneSync(true);
+ }
+ else if (val == Remote)
{
- KSyncProfile* prof;
- if ( currentSelection >= 0 ) {
- prof = mSyncProfiles.at(currentSelection) ;
+ prof->setIsLocalFileSync(false);
+ prof->setIsPhoneSync(false);
+ }
+ else // default value is Local
+ {
+ prof->setIsLocalFileSync(true);
+ prof->setIsPhoneSync(false);
+ }
+
+
prof->setPreSyncCommand( mRemotePrecommand->text());
+//US prof->setLocalTempFile( mLocalTempFile->text());
prof->setPostSyncCommand( mRemotePostcommand->text() );
- prof->setLocalTempFile( mLocalTempFile->text());
- prof->setRemoteFileName( mRemoteFile->text() );
- prof->setShowSummaryAfterSync( mShowSummaryAfterSync->isChecked() );
- prof->setAskForPreferences( mAskForPreferences->isChecked());
- prof->setWriteBackExisting(mWriteBackExisting->isChecked() );
- prof->setWriteBackFile( mWriteBackFile->isChecked());
- prof->setIncludeInRingSync( mIncludeInRing->isChecked() );
- int syncprefs = rem->isChecked()*1+newest->isChecked()*2+ ask->isChecked()*3+ f_loc->isChecked()*4+ f_rem->isChecked()*5 ;//+ both->isChecked()*6 ;
- prof->setSyncPrefs( syncprefs);
- prof->setIsLocalFileSync( mIsLocal->isChecked() );
}
-}
-void KOSyncPrefsDialog::insertProfiles()
-{
- int curItem = mProfileBox->currentItem();
- mProfileBox->blockSignals( true );
- mProfileBox->clear();
- mProfileBox->insertStringList (mSyncProfileNames );
- int item = mSyncProfileNames.count() -1;
- if ( curItem >= 0 && mSyncProfileNames.count() > 0 && curItem < mSyncProfileNames.count() )
- mProfileBox->setCurrentItem( curItem );
- else if ( item >= 0 ) {
- mProfileBox->setCurrentItem( item );
- }
- currentSelection = -1;
- if ( mSyncProfileNames.count() > 0 ) {
- //qDebug(" profileChanged( mProfileBox->currentItem() ");
- profileChanged( mProfileBox->currentItem() );
- currentSelection = mProfileBox->currentItem();
- }
- mProfileBox->blockSignals( false );
-}
-
-void KOSyncPrefsDialog::addProfile ( KSyncProfile* temp )
+void SyncPrefWidget_Remote::fillSSH()
{
- saveProfile();
- mSyncProfiles.append( temp );
- mSyncProfileNames << temp->getName();
- insertProfiles();
- int last = mProfileBox->count() -1;
- mProfileBox->blockSignals( true );
- mProfileBox->setCurrentItem( last );
- mProfileBox->blockSignals( false );
- profileChanged(last);
-}
-void KOSyncPrefsDialog::newProfile()
+ QString location = mLocalTempFile->text();
+
+ mRemotePrecommand->setText("scp zaurus@192.168.0.65:/home/zaurus/kdepim/"+location + " " + location );
+//US mLocalTempFile->setText("/tmp/mycalendar.ics" );
+ mRemotePostcommand->setText("scp " + location + " zaurus@192.168.0.65:/home/zaurus/kdepim/"+location );
+}
+
+void SyncPrefWidget_Remote::fillFTP()
{
- addProfile ( new KSyncProfile () );
+ QString location = mLocalTempFile->text();
+
+ mRemotePrecommand->setText("cd /tmp;ftp ftp://zaurus:a@192.168.0.65/kdepim/" + location );
+//US mLocalTempFile->setText("/tmp/mycalendar.ics" );
+ mRemotePostcommand->setText("ftp -u ftp://zaurus:a@192.168.0.65/kdepim/"+location+ " " + location);
+
}
-void KOSyncPrefsDialog::cloneProfile()
+
+void SyncPrefWidget_Remote::kindChanged( int newKind )
{
- if ( currentSelection >= 0 )
- addProfile (mSyncProfiles.at(currentSelection)->clone()) ;
- else
- newProfile();
+
+ if (newKind == Mobile)
+ remoteFileWidget->setEnabled(false);
+ else if (newKind == Remote)
+ remoteFileWidget->setEnabled(true);
+ else // default value is local
+ remoteFileWidget->setEnabled(false);
+
}
+/***********************************************************************
+ *
+ *
+ **********************************************************************/
-void KOSyncPrefsDialog::usrReadConfig()
+
+SyncPrefWidgetContainer::SyncPrefWidgetContainer()
+ : SyncWidgetContainer()
{
- KConfig *config = KOGlobals::config();
- config->setGroup("SyncProfiles");
- mSyncProfileNames = KOPrefs::instance()->mSyncProfileNames;
- int i;
- KSyncProfile* temp ;
- mSyncProfiles.clear();
- for ( i = 0; i < mSyncProfileNames.count();++i ) {
- temp = new KSyncProfile ();
- temp->setName( mSyncProfileNames[i] );
- temp->readConfig( config );
- mSyncProfiles.append( temp );
}
- insertProfiles();
- mMyMachineName->setText(KOPrefs::instance()->mLocalMachineName );
+
+KRES::SyncWidget* SyncPrefWidgetContainer::generateSettingsTab(QWidget *parent = 0, const char *name = 0)
+{
+ return new SyncPrefWidget_Settings(parent, name);
}
+KRES::SyncWidget* SyncPrefWidgetContainer::generateConflictsTab(QWidget *parent = 0, const char *name = 0)
+{
+ return new SyncPrefWidget_Conflict(parent, name);
+}
-void KOSyncPrefsDialog::usrWriteConfig()
+KRES::SyncWidget* SyncPrefWidgetContainer::generateRemoteTab(QWidget *parent = 0, const char *name = 0)
{
- saveProfile();
- if ( currentSelection >= 0 )
- profileChanged(currentSelection);
- KConfig *config = KOGlobals::config();
- config->setGroup("SyncProfiles");
- KSyncProfile* prof = mSyncProfiles.first();
- while ( prof ) {
- prof->writeConfig(config);
- prof = mSyncProfiles.next();
- }
- KOPrefs::instance()->mSyncProfileNames = mSyncProfileNames;
- KOPrefs::instance()->mLocalMachineName = mMyMachineName->text();
- config->writeEntry("SyncProfileNames",&mSyncProfileNames);
+ return new SyncPrefWidget_Remote(parent, name);
}
-*/
+
diff --git a/kabc/syncprefwidget.h b/kabc/syncprefwidget.h
index 3709d78..b20a68e 100644
--- a/kabc/syncprefwidget.h
+++ b/kabc/syncprefwidget.h
@@ -30,92 +30,110 @@ $Id$
#include <kresources/syncwidget.h>
-/*US
-//#include <qframe.h>
-//#include <qdict.h>
-#include <qvbox.h>
-#include <qhbox.h>
-//#include <qcolor.h>
-//#include <qlistview.h>
-
-#include <kdialogbase.h>
-
-#include <libkdepim/kprefsdialog.h>
-*/
-
-//US class KColorButton;
-//US class QSpinBox;;
class QRadioButton;
class QCheckBox;
class QVBox;
-//US class QSlider;
-//US class KURLRequester;
-//US class QComboBox;
+class QComboBox;
class QLineEdit;
-//US class QStringList;
-//US class KSyncProfile;
+class KRES::Resource;
-
-/** Dialog to change the korganizer configuration.
- */
-class SyncPrefWidget : public KRES::SyncWidget
+class SyncPrefWidget_Settings : public KRES::SyncWidget
{
Q_OBJECT
public:
- SyncPrefWidget(QWidget *parent=0);
- ~SyncPrefWidget();
-//US void usrReadConfig();
+ SyncPrefWidget_Settings(QWidget *parent=0, const char *name = 0 );
+ ~SyncPrefWidget_Settings();
public slots:
- protected slots:
-//US void accept();
-//US void deleteProfile();
-//US void newProfile();
-//US void cloneProfile();
-//US void kindChanged(bool);
-//US void fillSSH();
-//US void fillFTP();
-//US void textChanged( const QString & );
-//US void profileChanged( int );
-//US void chooseFile();
-//US void slotOK();
+ virtual void loadSettings( KRES::Resource *resource );
+ virtual void saveSettings( KRES::Resource *resource );
- protected:
-//US void usrWriteConfig();
+ protected:
void init();
private:
+ QCheckBox* mIncludeInRing;
+ QCheckBox* mWriteBackFile;
+ QCheckBox* mWriteBackExisting;
+ QCheckBox* mAskForPreferences;
+ QCheckBox* mShowSummaryAfterSync;
+};
-//US int currentSelection;
-//US QPtrList<KSyncProfile> mSyncProfiles;
-//US QStringList mSyncProfileNames;
-//US QLineEdit * mMyMachineName;
-//US QComboBox * mProfileBox;
-//US QRadioButton* mIsLocal;
- QCheckBox* mIsNotLocal;
- QCheckBox* mIncludeInRing;
-//US void addProfile ( KSyncProfile* );
-//US void insertProfiles();
-//US void saveProfile();
-//US QButtonGroup* proGr;
+class SyncPrefWidget_Conflict : public KRES::SyncWidget
+{
+ Q_OBJECT
+ public:
+ SyncPrefWidget_Conflict(QWidget *parent=0, const char *name = 0 );
+ ~SyncPrefWidget_Conflict();
+
+ public slots:
+ virtual void loadSettings( KRES::Resource *resource );
+ virtual void saveSettings( KRES::Resource *resource );
+
+ protected:
+ void init();
+
+ private:
QRadioButton* loc, *rem, *newest, *ask, *f_loc,* f_rem, *both;
+};
+
+
+
+
+class SyncPrefWidget_Remote : public KRES::SyncWidget
+{
+ Q_OBJECT
+ public:
+ SyncPrefWidget_Remote(QWidget *parent=0, const char *name = 0 );
+ ~SyncPrefWidget_Remote();
+
+ enum Types {
+ Local = 0,
+ Remote = 1,
+ Mobile =2
+ };
+
+
+ public slots:
+ virtual void loadSettings( KRES::Resource *resource );
+ virtual void saveSettings( KRES::Resource *resource );
+ protected slots:
+ void fillSSH();
+ void fillFTP();
+ void kindChanged( int newKind );
+
+ protected:
+ void init();
+ private:
+ QComboBox* mProfileKind;
QLineEdit * mRemotePostcommand;
QLineEdit * mRemotePrecommand;
QLineEdit * mRemoteFile;
QLineEdit * mLocalTempFile;
-//US QWidget* mSetupSyncAlgTab;
-
-//US QVBox* localFileWidget;
QVBox* remoteFileWidget;
- QCheckBox* mWriteBackFile;
- QCheckBox* mWriteBackExisting;
- QCheckBox* mAskForPreferences;
- QCheckBox* mShowSummaryAfterSync;
};
+
+
+
+
+class SyncPrefWidgetContainer : public KRES::SyncWidgetContainer
+{
+ Q_OBJECT
+
+public:
+ SyncPrefWidgetContainer();
+
+ virtual KRES::SyncWidget* generateSettingsTab(QWidget *parent, const char *name);
+ virtual KRES::SyncWidget* generateConflictsTab(QWidget *parent, const char *name);
+ virtual KRES::SyncWidget* generateRemoteTab(QWidget *parent, const char *name);
+};
+
+
+
#endif