summaryrefslogtreecommitdiffabout
path: root/libkdepim/ksyncprefsdialog.cpp
authorzautrix <zautrix>2005-11-25 15:49:13 (UTC)
committer zautrix <zautrix>2005-11-25 15:49:13 (UTC)
commit794a5204686ad9bfc16172b01db35f1f3b7683e5 (patch) (side-by-side diff)
tree29da2cb35a4d6a0cd6885436087fe0659b58a9f4 /libkdepim/ksyncprefsdialog.cpp
parent90b62d1158d00f162a258541e24aaed4c967480b (diff)
downloadkdepimpi-794a5204686ad9bfc16172b01db35f1f3b7683e5.zip
kdepimpi-794a5204686ad9bfc16172b01db35f1f3b7683e5.tar.gz
kdepimpi-794a5204686ad9bfc16172b01db35f1f3b7683e5.tar.bz2
sync
Diffstat (limited to 'libkdepim/ksyncprefsdialog.cpp') (more/less context) (show whitespace changes)
-rw-r--r--libkdepim/ksyncprefsdialog.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/libkdepim/ksyncprefsdialog.cpp b/libkdepim/ksyncprefsdialog.cpp
index 292cde1..27f7932 100644
--- a/libkdepim/ksyncprefsdialog.cpp
+++ b/libkdepim/ksyncprefsdialog.cpp
@@ -403,501 +403,501 @@ void KSyncPrefsDialog::readResources()
for ( i = 0;i < mResourcesKopi.count(); ++i ) {
mResTableKopi->verticalHeader ()->setLabel( i, mResourcesKopi[i] );
}
}
void KSyncPrefsDialog::readFilter()
{
mFilterKapi.clear();
mFilterKopi.clear();
KConfig cfgko(locateLocal("config","korganizerrc"));
KConfig cfgka(locateLocal("config","kaddressbookrc"));
cfgko.setGroup("General");
mFilterKopi = cfgko.readListEntry("CalendarFilters");
cfgka.setGroup("Filter");
int count = cfgka.readNumEntry( "Count", 0 );
for ( int i = 0; i < count; i++ ) {
cfgka.setGroup("Filter_"+QString::number( i ) );
mFilterKapi.append( cfgka.readEntry("Name", "internal error") );
}
mFilterOutCal->clear();
mFilterInCal->clear();
mFilterOutAB->clear();
mFilterInAB->clear();
QStringList temp = mFilterKopi;
temp.prepend(i18n("No Filter") );
mFilterOutCal->insertStringList( temp );
mFilterInCal->insertStringList( temp );
temp = mFilterKapi;
temp.prepend(i18n("No Filter") );
mFilterOutAB->insertStringList( temp );
mFilterInAB->insertStringList( temp );
}
void KSyncPrefsDialog::slotOK()
{
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();
}
void KSyncPrefsDialog::accept()
{
slotOK();
}
void KSyncPrefsDialog::chooseFile()
{
QString fn = QDir::homeDirPath();
fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this );
if ( fn == "" )
return;
mRemoteFile->setText( fn );
}
void KSyncPrefsDialog::chooseFileAB()
{
QString fn = QDir::homeDirPath();
fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.vcf)"), this );
if ( fn == "" )
return;
mRemoteFileAB->setText( fn );
}
void KSyncPrefsDialog::chooseFilePWM()
{
QString fn = QDir::homeDirPath();
fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.pwm)"), this );
if ( fn == "" )
return;
mRemoteFilePWM->setText( fn );
}
void KSyncPrefsDialog::textChanged( const QString & s )
{
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 );
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 KSyncPrefsDialog::profileChanged( int item )
{
//qDebug("KSyncPrefsDialog::profileChanged before %d, count %d ", item, mProfileBox->count() );
KSyncProfile* prof;
saveProfile();
readFilter();
readResources();
currentSelection = item;
prof = mSyncProfiles.at(item) ;
mRemotePw->setText(prof->getRemotePw());
mRemoteIP->setText(prof->getRemoteIP());
mRemotePort->setText(prof->getRemotePort());
mRemotePwAB->setText(prof->getRemotePwAB());
mRemoteIPAB->setText(prof->getRemoteIPAB());
mRemotePortAB->setText(prof->getRemotePortAB());
mRemotePwPWM->setText(prof->getRemotePwPWM());
mRemoteIPPWM->setText(prof->getRemoteIPPWM());
mRemotePortPWM->setText(prof->getRemotePortPWM());
mRemotePrecommand->setText(prof->getPreSyncCommand());
mRemotePostcommand->setText(prof->getPostSyncCommand());
mLocalTempFile->setText(prof->getLocalTempFile());
mRemoteFile->setText(prof->getRemoteFileName()) ;
mRemotePrecommandAB->setText(prof->getPreSyncCommandAB());
mRemotePostcommandAB->setText(prof->getPostSyncCommandAB());
mLocalTempFileAB->setText(prof->getLocalTempFileAB());
mRemoteFileAB->setText(prof->getRemoteFileNameAB()) ;
mRemotePrecommandPWM->setText(prof->getPreSyncCommandPWM());
mRemotePostcommandPWM->setText(prof->getPostSyncCommandPWM());
mLocalTempFilePWM->setText(prof->getLocalTempFilePWM());
mRemoteFilePWM->setText(prof->getRemoteFileNamePWM()) ;
if ( mWriteContactToSIM )
mWriteContactToSIM->setChecked( prof->getWriteContactToSIM());
mPhoneDevice->setText(prof->getPhoneDevice());
mPhoneConnection->setText(prof->getPhoneConnection());
mPhoneModel->setText(prof->getPhoneModel());
mShowSummaryAfterSync->setChecked( prof->getShowSummaryAfterSync());
mAskForPreferences->setChecked( prof->getAskForPreferences());
mWriteBackExisting->setChecked( prof->getWriteBackExisting() );
mWriteBackFile->setChecked( prof->getWriteBackFile());
mIncludeInRing->setChecked( prof->getIncludeInRingSync() );
mIncludeInRingAB->setChecked( prof->getIncludeInRingSyncAB() );
mIncludeInRingPWM->setChecked( prof->getIncludeInRingSyncPWM() );
mWriteBackFuture->setChecked( prof->getWriteBackFuture());
mWriteBackFutureWeeks->setValue( prof->getWriteBackFutureWeeks() );
mWriteBackPastWeeks->setValue( prof->getWriteBackPastWeeks() );
mFilterInCal->setCurrentItem( mFilterKopi.findIndex(prof->getFilterInCal () ) + 1 );
mFilterOutCal->setCurrentItem( mFilterKopi.findIndex(prof->getFilterOutCal () ) + 1 );
mFilterInAB->setCurrentItem( mFilterKapi.findIndex(prof->getFilterInAB () ) + 1 );
mFilterOutAB->setCurrentItem( mFilterKapi.findIndex(prof->getFilterOutAB () ) + 1 );
switch ( prof->getSyncPrefs() ) {
case 0:
loc->setChecked( true);
break;
case 1:
rem->setChecked( true );
break;
case 2:
newest->setChecked( true);
break;
case 3:
ask->setChecked( true);
break;
case 4:
f_loc->setChecked( true);
break;
case 5:
f_rem->setChecked( true);
break;
case 6:
//both->setChecked( true);
break;
default:
break;
}
mIsLocal->setChecked(prof->getIsLocalFileSync()) ;
mIsPhone->setChecked(prof->getIsPhoneSync()) ;
mIsPi->setChecked(prof->getIsPiSync()) ;
mIsPiSpecific->setChecked(prof->getIsPiSyncSpec()) ;
mIsKapiFileL->setChecked(prof->getIsKapiFile()) ;
mIsKapiFileR->setChecked(prof->getIsKapiFile()) ;
QStringList res = QStringList::split( ":",prof->getResSpecKopi());
- int i;
- for ( i = 0;i < res.count(); ++i ) {
+ int i= res.count()/2;
+ for ( ;i < res.count(); ++i ) {
mResTableKopi->setText( i, 0, res[i] );
}
res = QStringList::split( ":",prof->getResSpecKapi());
for ( i = 0;i < res.count(); ++i ) {
mResTableKapi->setText( i, 0, res[i] );
}
mIsNotLocal->setChecked(!prof->getIsLocalFileSync() && !prof->getIsPhoneSync() &&!prof->getIsPiSync() &&!prof->getIsPiSyncSpec());
proGr->setEnabled( item > 2 );
if ( item < 3 ) {
localFileWidget->hide();
remoteFileWidget->hide();
phoneWidget->hide();
piWidget->hide();
} else
kindChanged( prof->getIsLocalFileSync() );
}
void KSyncPrefsDialog::fillSSH()
{
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" );
mRemotePrecommandAB->setText("scp zaurus@192.168.0.65:/home/zaurus/kdepim/apps/kabc/std.vcf /tmp/std.vcf" );
mLocalTempFileAB->setText("/tmp/std.vcf" );
mRemotePostcommandAB->setText("scp /tmp/std.vcf zaurus@192.168.0.65:/home/zaurus/kdepim/apps/kabc/std.vcf" );
mRemotePrecommandPWM->setText("scp zaurus@192.168.0.65:/home/zaurus/kdepim/apps/pwmanager/passwords.pwm /tmp/passwords.pwm" );
mLocalTempFilePWM->setText("/tmp/passwords.pwm" );
mRemotePostcommandPWM->setText("scp /tmp/passwords.pwm zaurus@192.168.0.65:/home/zaurus/kdepim/apps/pwmanager/pwmanager.pwm" );
}
void KSyncPrefsDialog::fillFTP()
{
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" );
mRemotePrecommandAB->setText("cd /tmp;ftp ftp://zaurus:a@192.168.0.65/kdepim/apps/kabc/std.vcf" );
mLocalTempFileAB->setText("/tmp/std.vcf" );
mRemotePostcommandAB->setText("ftp -u ftp://zaurus:a@192.168.0.65/kdepim/apps/kabc/std.vcf /tmp/std.vcf" );
mRemotePrecommandPWM->setText("cd /tmp;ftp ftp://zaurus:a@192.168.0.65/kdepim/apps/pwmanager/passwords.pwm" );
mLocalTempFilePWM->setText("/tmp/passwords.pwm" );
mRemotePostcommandPWM->setText("ftp -u ftp://zaurus:a@192.168.0.65/kdepim/apps/pwmanager/passwords.pwm /tmp/passwords.pwm" );
}
void KSyncPrefsDialog::kindChanged( bool b )
{
if ( mIsLocal->isChecked () ) {
mIsKapiFileL->setChecked( mIsKapiFileR->isChecked() );
} else {
mIsKapiFileR->setChecked( mIsKapiFileL->isChecked() );
}
if ( mIsLocal->isChecked () )
localFileWidget->show();
else
localFileWidget->hide();
if ( mIsNotLocal->isChecked () )
remoteFileWidget->show();
else
remoteFileWidget->hide();
if ( mIsPhone->isChecked () ) {
phoneWidget->show();
}
else {
phoneWidget->hide();
}
if ( mIsPi->isChecked () || mIsPiSpecific->isChecked () ) {
piWidget->show();
if (mIsPiSpecific->isChecked () ) {
mTableBox->show();
}
else {
mTableBox->hide();
}
}
else {
piWidget->hide();
}
}
void KSyncPrefsDialog::deleteProfile()
{
//qDebug("KSyncPrefsDialog::deleteProfile() ");
if ( currentSelection >= 0 ) {
if ( currentSelection < 3 ) {
KMessageBox::error(this,i18n("This profil cannot be deleted!\n"),i18n("KO/Pi config error"));
return;
}
KSyncProfile* temp = mSyncProfiles.at(currentSelection);
mSyncProfiles.remove( temp );
mSyncProfileNames.remove( mSyncProfileNames.at( currentSelection ));
insertProfiles();
}
}
void KSyncPrefsDialog::saveProfile()
{
KSyncProfile* prof;
if ( currentSelection >= 0 ) {
prof = mSyncProfiles.at(currentSelection) ;
prof->setRemotePw( mRemotePw->text());
prof->setRemoteIP( mRemoteIP->text());
prof->setRemotePort( mRemotePort->text());
prof->setRemotePwAB( mRemotePwAB->text());
prof->setRemoteIPAB( mRemoteIPAB->text());
prof->setRemotePortAB( mRemotePortAB->text());
prof->setRemotePwPWM( mRemotePwPWM->text());
prof->setRemoteIPPWM( mRemoteIPPWM->text());
prof->setRemotePortPWM( mRemotePortPWM->text());
prof->setPreSyncCommand( mRemotePrecommand->text());
prof->setPostSyncCommand( mRemotePostcommand->text() );
prof->setLocalTempFile( mLocalTempFile->text());
prof->setRemoteFileName( mRemoteFile->text() );
prof->setPreSyncCommandAB( mRemotePrecommandAB->text());
prof->setPostSyncCommandAB( mRemotePostcommandAB->text() );
prof->setLocalTempFileAB( mLocalTempFileAB->text());
prof->setRemoteFileNameAB( mRemoteFileAB->text() );
prof->setPreSyncCommandPWM( mRemotePrecommandPWM->text());
prof->setPostSyncCommandPWM( mRemotePostcommandPWM->text() );
prof->setLocalTempFilePWM( mLocalTempFilePWM->text());
prof->setRemoteFileNamePWM( mRemoteFilePWM->text() );
prof->setShowSummaryAfterSync( mShowSummaryAfterSync->isChecked() );
prof->setAskForPreferences( mAskForPreferences->isChecked());
prof->setWriteBackExisting(mWriteBackExisting->isChecked() );
prof->setWriteBackFile( mWriteBackFile->isChecked());
prof->setIncludeInRingSync( mIncludeInRing->isChecked() );
prof->setIncludeInRingSyncAB( mIncludeInRingAB->isChecked() );
prof->setIncludeInRingSyncPWM( mIncludeInRingPWM->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() );
prof->setIsPhoneSync( mIsPhone->isChecked() );
prof->setIsPiSync( mIsPi->isChecked() );
prof->setIsPiSyncSpec( mIsPiSpecific->isChecked() );
prof->setIsKapiFile( mIsKapiFileL->isChecked() );
prof->setWriteBackFuture(mWriteBackFuture->isChecked());
prof->setWriteBackFutureWeeks(mWriteBackFutureWeeks->value());
prof->setWriteBackPastWeeks(mWriteBackPastWeeks->value());
if ( mWriteContactToSIM )
prof->setWriteContactToSIM(mWriteContactToSIM->isChecked());
prof->setPhoneDevice( mPhoneDevice->text() );
prof->setPhoneConnection( mPhoneConnection->text() );
prof->setPhoneModel( mPhoneModel->text() );
prof->setFilterInCal ( mFilterInCal->currentText ());
prof->setFilterOutCal ( mFilterOutCal ->currentText ());
prof->setFilterInAB ( mFilterInAB ->currentText ());
prof->setFilterOutAB ( mFilterOutAB ->currentText ());
if ( mIsPiSpecific->isChecked() ) {
- QStringList res;
+ QStringList res = mResourcesKopi;
int i;
for ( i = 0;i < mResourcesKopi.count(); ++i ) {
res.append( mResTableKopi->text( i, 0 ));
}
prof->setResSpecKopi( res.join(":"));
}
}
}
void KSyncPrefsDialog::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 KSyncPrefsDialog::addProfile ( KSyncProfile* temp )
{
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 KSyncPrefsDialog::newProfile()
{
addProfile ( new KSyncProfile () );
}
void KSyncPrefsDialog::cloneProfile()
{
if ( currentSelection >= 0 )
addProfile (mSyncProfiles.at(currentSelection)->clone()) ;
else
newProfile();
}
void KSyncPrefsDialog::setLocalMachineName ( const QString& name )
{
mMyMachineName->setText( name );
}
QString KSyncPrefsDialog::getLocalMachineName ( )
{
return mMyMachineName->text();
}
QStringList KSyncPrefsDialog::getSyncProfileNames()
{
return mSyncProfileNames;
}
void KSyncPrefsDialog::usrReadConfig()
{
//KConfig *config = KOGlobals::config();
KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
config.setGroup("General");
mSyncProfileNames =config.readListEntry("SyncProfileNames");
mMyMachineName->setText(config.readEntry("LocalMachineName","undefined"));
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 );
}
void KSyncPrefsDialog::usrWriteConfig()
{
saveProfile();
if ( currentSelection >= 0 )
profileChanged(currentSelection);
//KConfig *config = KOGlobals::config();
KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
KSyncProfile* prof = mSyncProfiles.first();
QStringList externalSyncProfileNames;
externalSyncProfileNames.append("Sharp_DTM");;
while ( prof ) {
prof->writeConfig(&config);
if ( prof->getIsPhoneSync( ) )
externalSyncProfileNames.append(prof->getName( ) );
prof = mSyncProfiles.next();
}
//KOPrefs::instance()->mSyncProfileNames = mSyncProfileNames;
//KOPrefs::instance()->mLocalMachineName = mMyMachineName->text();
config.setGroup("General");
config.writeEntry("SyncProfileNames",mSyncProfileNames);
config.writeEntry("ExternSyncProfiles",externalSyncProfileNames);
config.writeEntry("LocalMachineName",mMyMachineName->text());
config.sync();
}
void KSyncPrefsDialog::helpDevice()
{
QString hint = i18n("Insert device where\nphone is connected. E.g.:\n");
#ifdef _WIN32_
hint += "Leave empty for Irda.\n"
"com1:\n(first serial port)\n"
"usb not supported\n"
"???\n(bluetooth device address)\n";
#else
hint += "/dev/ircomm\n(Irda)\n"
"/dev/ttyS0\n(first serial port)\n"
"/dev/ttyUSB0\n(first device usb port)\n"
"???\n(bluetooth device address)\n";
#endif
KMessageBox::information(this,hint,i18n("KDE-Pim sync config"));
}
void KSyncPrefsDialog::helpModel()
{
QString hint = i18n("Recommended: Leave empty!\n(Such that model can\nbe auto detected)\nOr insert name of model:\n");
hint += "E.g. for Nokia 6310i:\n6310i\nAlso possible:\nobex\nfor Obex connection";
KMessageBox::information(this,hint,i18n("KDE-Pim sync config"));
}
void KSyncPrefsDialog::helpConnection()
{
QString hint = i18n("Insert kind of connection,e.g.:\n");
hint += "irda | Nokia FBUS over infrared\n"
"irdaat | AT commands infrared\n(for Siemens/Sony-Erricsson)\n"
"irdaobex | set also model as obex\n"
"fbus | Nokia FBUS2 serial\n";
KMessageBox::information(this,hint,i18n("KDE-Pim sync config"));
}