summaryrefslogtreecommitdiffabout
path: root/libkdepim/ksyncprefsdialog.cpp
authorzautrix <zautrix>2004-08-01 13:59:52 (UTC)
committer zautrix <zautrix>2004-08-01 13:59:52 (UTC)
commit43d6cf3619675856333d82ae2fcad6ce81d824b8 (patch) (unidiff)
tree40629720fce9e0840fc4ab50ab1ef746a7c07375 /libkdepim/ksyncprefsdialog.cpp
parent47a3a79ddde4ab63d34ddb0ffaa92d65f04de8ad (diff)
downloadkdepimpi-43d6cf3619675856333d82ae2fcad6ce81d824b8.zip
kdepimpi-43d6cf3619675856333d82ae2fcad6ce81d824b8.tar.gz
kdepimpi-43d6cf3619675856333d82ae2fcad6ce81d824b8.tar.bz2
fixed sync config
Diffstat (limited to 'libkdepim/ksyncprefsdialog.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libkdepim/ksyncprefsdialog.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/libkdepim/ksyncprefsdialog.cpp b/libkdepim/ksyncprefsdialog.cpp
index 8d610d8..3df2a3b 100644
--- a/libkdepim/ksyncprefsdialog.cpp
+++ b/libkdepim/ksyncprefsdialog.cpp
@@ -53,416 +53,419 @@
53#include <kcolordialog.h> 53#include <kcolordialog.h>
54#include <kiconloader.h> 54#include <kiconloader.h>
55#include <kemailsettings.h> 55#include <kemailsettings.h>
56#include <kstandarddirs.h> 56#include <kstandarddirs.h>
57#include <kfiledialog.h> 57#include <kfiledialog.h>
58#include <kmessagebox.h> 58#include <kmessagebox.h>
59 59
60//#include <kurlrequester.h> 60//#include <kurlrequester.h>
61#include <klineedit.h> 61#include <klineedit.h>
62#include "ksyncprofile.h" 62#include "ksyncprofile.h"
63 63
64 64
65//#include "koprefs.h" 65//#include "koprefs.h"
66 66
67#include "ksyncprefsdialog.h" 67#include "ksyncprefsdialog.h"
68//#include "koglobals.h" 68//#include "koglobals.h"
69 69
70 70
71KSyncPrefsDialog::KSyncPrefsDialog(QWidget *parent, char *name, bool modal) : 71KSyncPrefsDialog::KSyncPrefsDialog(QWidget *parent, char *name, bool modal) :
72 KDialog(parent,name,true) 72 KDialog(parent,name,true)
73{ 73{
74 74
75 setCaption( i18n("Synchronization Preferences")); 75 setCaption( i18n("Synchronization Preferences"));
76 76
77 mSyncProfiles.setAutoDelete( true ); 77 mSyncProfiles.setAutoDelete( true );
78 setupSyncAlgTab(); 78 setupSyncAlgTab();
79} 79}
80 80
81 81
82KSyncPrefsDialog::~KSyncPrefsDialog() 82KSyncPrefsDialog::~KSyncPrefsDialog()
83{ 83{
84} 84}
85 85
86void KSyncPrefsDialog::setupSyncAlgTab() 86void KSyncPrefsDialog::setupSyncAlgTab()
87{ 87{
88 QLabel * lab; 88 QLabel * lab;
89 //QFrame *page = addPage(i18n("Sync Prefs"),0,0); 89 //QFrame *page = addPage(i18n("Sync Prefs"),0,0);
90 QVBox * mainbox = new QVBox( this ); 90 QVBox * mainbox = new QVBox( this );
91 QScrollView* sv = new QScrollView( mainbox ); 91 QScrollView* sv = new QScrollView( mainbox );
92 QHBoxLayout * lay = new QHBoxLayout( this ); 92 QHBoxLayout * lay = new QHBoxLayout( this );
93 lay->addWidget( mainbox ); 93 lay->addWidget( mainbox );
94 QHBox * b_box = new QHBox( mainbox ); 94 QHBox * b_box = new QHBox( mainbox );
95 95
96 QPushButton* button = new QPushButton( i18n("Ok"), b_box ); 96 QPushButton* button = new QPushButton( i18n("Ok"), b_box );
97 connect ( button, SIGNAL( clicked()), this, SLOT (slotOK() ) ); 97 connect ( button, SIGNAL( clicked()), this, SLOT (slotOK() ) );
98 button = new QPushButton( i18n("Cancel"), b_box ); 98 button = new QPushButton( i18n("Cancel"), b_box );
99 connect ( button, SIGNAL( clicked()), this, SLOT (reject() ) ); 99 connect ( button, SIGNAL( clicked()), this, SLOT (reject() ) );
100 //QBoxLayout * sl = new QVBoxLayout(this ); 100 //QBoxLayout * sl = new QVBoxLayout(this );
101 //sl->addWidget ( sv ); 101 //sl->addWidget ( sv );
102 sv->setResizePolicy ( QScrollView::AutoOneFit ); 102 sv->setResizePolicy ( QScrollView::AutoOneFit );
103 QFrame *topFrame = new QFrame ( sv ); 103 QFrame *topFrame = new QFrame ( sv );
104 sv->addChild( topFrame ); 104 sv->addChild( topFrame );
105 mSetupSyncAlgTab = topFrame; 105 mSetupSyncAlgTab = topFrame;
106 QGridLayout *topLayout = new QGridLayout(topFrame,6,2); 106 QGridLayout *topLayout = new QGridLayout(topFrame,6,2);
107 topLayout->setSpacing(spacingHint()); 107 topLayout->setSpacing(spacingHint());
108 topLayout->setMargin(marginHint()); 108 topLayout->setMargin(marginHint());
109 109
110 //lab = new QLabel(i18n("Sync settings not yet implemented. DO NOT USE!"), topFrame); 110 //lab = new QLabel(i18n("Sync settings not yet implemented. DO NOT USE!"), topFrame);
111 int iii = 0; 111 int iii = 0;
112 //topLayout->addMultiCellWidget(lab , iii,iii,0,1); 112 //topLayout->addMultiCellWidget(lab , iii,iii,0,1);
113 //++iii; 113 //++iii;
114 114
115 mMyMachineName = new QLineEdit(topFrame); 115 mMyMachineName = new QLineEdit(topFrame);
116 lab = new QLabel(mMyMachineName, i18n("Local device name:"), topFrame); 116 lab = new QLabel(mMyMachineName, i18n("Local device name:"), topFrame);
117 topLayout->addWidget(lab ,iii,0); 117 topLayout->addWidget(lab ,iii,0);
118 topLayout->addWidget(mMyMachineName,iii,1); 118 topLayout->addWidget(mMyMachineName,iii,1);
119 ++iii; 119 ++iii;
120 120
121 QHBox* buttonbox = new QHBox( topFrame); 121 QHBox* buttonbox = new QHBox( topFrame);
122 topLayout->addMultiCellWidget(buttonbox, iii,iii,0,1); 122 topLayout->addMultiCellWidget(buttonbox, iii,iii,0,1);
123 ++iii; 123 ++iii;
124 button = new QPushButton( i18n("New profile"), buttonbox ); 124 button = new QPushButton( i18n("New profile"), buttonbox );
125 connect ( button, SIGNAL( clicked()), this, SLOT (newProfile() ) ); 125 connect ( button, SIGNAL( clicked()), this, SLOT (newProfile() ) );
126 126
127 button = new QPushButton( i18n("Clone profile"), buttonbox ); 127 button = new QPushButton( i18n("Clone profile"), buttonbox );
128 connect ( button, SIGNAL( clicked()), this, SLOT ( cloneProfile() ) ); 128 connect ( button, SIGNAL( clicked()), this, SLOT ( cloneProfile() ) );
129 129
130 button = new QPushButton( i18n("Delete profile"), buttonbox ); 130 button = new QPushButton( i18n("Delete profile"), buttonbox );
131 connect ( button, SIGNAL( clicked()), this, SLOT (deleteProfile() ) ); 131 connect ( button, SIGNAL( clicked()), this, SLOT (deleteProfile() ) );
132 132
133 mProfileBox = new QComboBox(topFrame); 133 mProfileBox = new QComboBox(topFrame);
134 mProfileBox->setEditable ( true ); 134 mProfileBox->setEditable ( true );
135 connect ( mProfileBox, SIGNAL(activated ( int ) ), this, SLOT (profileChanged( int ) ) ); 135 connect ( mProfileBox, SIGNAL(activated ( int ) ), this, SLOT (profileChanged( int ) ) );
136 connect ( mProfileBox, SIGNAL( textChanged ( const QString & ) ), this, SLOT (textChanged( const QString & ) ) ); 136 connect ( mProfileBox, SIGNAL( textChanged ( const QString & ) ), this, SLOT (textChanged( const QString & ) ) );
137 137
138 lab = new QLabel(mProfileBox, i18n("Profile:"), topFrame); 138 lab = new QLabel(mProfileBox, i18n("Profile:"), topFrame);
139 topLayout->addWidget(lab ,iii,0); 139 topLayout->addWidget(lab ,iii,0);
140 topLayout->addWidget(mProfileBox, iii,1); 140 topLayout->addWidget(mProfileBox, iii,1);
141 ++iii; 141 ++iii;
142 142
143 mIncludeInRing = new QCheckBox( i18n("Include in multiple sync"), topFrame ); 143 mIncludeInRing = new QCheckBox( i18n("Include in multiple sync"), topFrame );
144 topLayout->addMultiCellWidget(mIncludeInRing, iii,iii,0,1); 144 topLayout->addMultiCellWidget(mIncludeInRing, iii,iii,0,1);
145 ++iii; 145 ++iii;
146 146
147 mAskForPreferences = new QCheckBox( i18n("Ask for preferences before sync"), topFrame ); 147 mAskForPreferences = new QCheckBox( i18n("Ask for preferences before sync"), topFrame );
148 topLayout->addMultiCellWidget(mAskForPreferences, iii,iii,0,1); 148 topLayout->addMultiCellWidget(mAskForPreferences, iii,iii,0,1);
149 ++iii; 149 ++iii;
150 QButtonGroup* gr = new QButtonGroup ( 1, Qt::Horizontal, i18n("Sync preferences"), topFrame); 150 QButtonGroup* gr = new QButtonGroup ( 1, Qt::Horizontal, i18n("Sync preferences"), topFrame);
151 topLayout->addMultiCellWidget(gr, iii,iii,0,1); 151 topLayout->addMultiCellWidget(gr, iii,iii,0,1);
152 ++iii; 152 ++iii;
153 loc = new QRadioButton ( i18n("Take local entry on conflict"), gr ); 153 loc = new QRadioButton ( i18n("Take local entry on conflict"), gr );
154 rem = new QRadioButton ( i18n("Take remote entry on conflict"), gr ); 154 rem = new QRadioButton ( i18n("Take remote entry on conflict"), gr );
155 newest = new QRadioButton ( i18n("Take newest entry on conflict"), gr ); 155 newest = new QRadioButton ( i18n("Take newest entry on conflict"), gr );
156 ask = new QRadioButton ( i18n("Ask for every entry on conflict"), gr ); 156 ask = new QRadioButton ( i18n("Ask for every entry on conflict"), gr );
157 f_loc= new QRadioButton ( i18n("Force: Take local entry always"), gr ); 157 f_loc= new QRadioButton ( i18n("Force: Take local entry always"), gr );
158 f_rem = new QRadioButton ( i18n("Force: Take remote entry always"), gr ); 158 f_rem = new QRadioButton ( i18n("Force: Take remote entry always"), gr );
159 // both = new QRadioButton ( i18n("Take both on conflict"), gr ); 159 // both = new QRadioButton ( i18n("Take both on conflict"), gr );
160 160
161 mShowSummaryAfterSync = new QCheckBox( i18n("Show summary after sync"), topFrame ); 161 mShowSummaryAfterSync = new QCheckBox( i18n("Show summary after sync"), topFrame );
162 topLayout->addMultiCellWidget(mShowSummaryAfterSync, iii,iii,0,1); 162 topLayout->addMultiCellWidget(mShowSummaryAfterSync, iii,iii,0,1);
163 ++iii; 163 ++iii;
164 164
165 mWriteBackExisting= new QCheckBox( i18n("Write back existing entries only"), topFrame ); 165 mWriteBackExisting= new QCheckBox( i18n("Write back existing entries only"), topFrame );
166 topLayout->addMultiCellWidget(mWriteBackExisting, iii,iii,0,1); 166 topLayout->addMultiCellWidget(mWriteBackExisting, iii,iii,0,1);
167 ++iii; 167 ++iii;
168 168
169 mWriteBackFile = new QCheckBox( i18n("Write back file"), topFrame ); 169 mWriteBackFile = new QCheckBox( i18n("Write back file"), topFrame );
170 topLayout->addMultiCellWidget(mWriteBackFile, iii,iii,0,1); 170 topLayout->addMultiCellWidget(mWriteBackFile, iii,iii,0,1);
171 ++iii; 171 ++iii;
172 172
173 proGr = new QButtonGroup ( 1, Qt::Horizontal, i18n("Profile kind"), topFrame); 173 proGr = new QButtonGroup ( 1, Qt::Horizontal, i18n("Profile kind"), topFrame);
174 gr = proGr; 174 gr = proGr;
175 topLayout->addMultiCellWidget(gr, iii,iii,0,1); 175 topLayout->addMultiCellWidget(gr, iii,iii,0,1);
176 ++iii; 176 ++iii;
177 mIsLocal = new QRadioButton ( i18n("Local file"), gr ); 177 mIsLocal = new QRadioButton ( i18n("Local file"), gr );
178 mIsNotLocal = new QRadioButton ( i18n("Remote file (w down/upload command)"), gr ); 178 mIsNotLocal = new QRadioButton ( i18n("Remote file (w down/upload command)"), gr );
179 connect (mIsLocal, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) ); 179 connect (mIsLocal, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) );
180 180
181 localFileWidget = new QVBox( topFrame); 181 localFileWidget = new QVBox( topFrame);
182 topLayout->addMultiCellWidget(localFileWidget, iii,iii,0,1); 182 topLayout->addMultiCellWidget(localFileWidget, iii,iii,0,1);
183 ++iii; 183 ++iii;
184 QHBox* temphb = new QHBox( localFileWidget ); 184 QHBox* temphb = new QHBox( localFileWidget );
185 lab = new QLabel( i18n("Local file:"), temphb); 185 lab = new QLabel( i18n("Local file:"), temphb);
186 mRemoteFile = new QLineEdit(localFileWidget); 186 mRemoteFile = new QLineEdit(localFileWidget);
187 187
188 button = new QPushButton( i18n("Choose..."), temphb ); 188 button = new QPushButton( i18n("Choose..."), temphb );
189 connect ( button, SIGNAL( clicked()), this, SLOT ( chooseFile() ) ); 189 connect ( button, SIGNAL( clicked()), this, SLOT ( chooseFile() ) );
190 190
191 191
192 remoteFileWidget = new QVBox( topFrame); 192 remoteFileWidget = new QVBox( topFrame);
193 topLayout->addMultiCellWidget(remoteFileWidget, iii,iii,0,1); 193 topLayout->addMultiCellWidget(remoteFileWidget, iii,iii,0,1);
194 ++iii; 194 ++iii;
195 lab = new QLabel( i18n("Pre sync (download) command:"), remoteFileWidget); 195 lab = new QLabel( i18n("Pre sync (download) command:"), remoteFileWidget);
196 mRemotePrecommand = new QLineEdit(remoteFileWidget); 196 mRemotePrecommand = new QLineEdit(remoteFileWidget);
197 197
198 lab = new QLabel( i18n("Local temp file:"), remoteFileWidget); 198 lab = new QLabel( i18n("Local temp file:"), remoteFileWidget);
199 mLocalTempFile = new QLineEdit(remoteFileWidget); 199 mLocalTempFile = new QLineEdit(remoteFileWidget);
200 200
201 201
202 lab = new QLabel( i18n("Post sync (upload) command:"), remoteFileWidget); 202 lab = new QLabel( i18n("Post sync (upload) command:"), remoteFileWidget);
203 mRemotePostcommand = new QLineEdit(remoteFileWidget); 203 mRemotePostcommand = new QLineEdit(remoteFileWidget);
204 204
205 lab = new QLabel( i18n("Fill in default values for:"), remoteFileWidget); 205 lab = new QLabel( i18n("Fill in default values for:"), remoteFileWidget);
206 temphb = new QHBox( remoteFileWidget ); 206 temphb = new QHBox( remoteFileWidget );
207 button = new QPushButton( i18n("ssh/scp"), temphb ); 207 button = new QPushButton( i18n("ssh/scp"), temphb );
208 connect ( button, SIGNAL( clicked()), this, SLOT (fillSSH() ) ); 208 connect ( button, SIGNAL( clicked()), this, SLOT (fillSSH() ) );
209 button = new QPushButton( i18n("ftp"), temphb ); 209 button = new QPushButton( i18n("ftp"), temphb );
210 connect ( button, SIGNAL( clicked()), this, SLOT (fillFTP() ) ); 210 connect ( button, SIGNAL( clicked()), this, SLOT (fillFTP() ) );
211 lab = new QLabel( i18n("Hint: Use $PWD$ for placeholder of password!"), remoteFileWidget); 211 lab = new QLabel( i18n("Hint: Use $PWD$ for placeholder of password!"), remoteFileWidget);
212 212
213 213
214} 214}
215void KSyncPrefsDialog::slotOK() 215void KSyncPrefsDialog::slotOK()
216{ 216{
217 if ( mMyMachineName->text() == "undefined" ) { 217 if ( mMyMachineName->text() == "undefined" ) {
218 KMessageBox::error(this,i18n("Local device name undefined!\nPlease define device name!"),i18n("KO/Pi config error")); 218 KMessageBox::error(this,i18n("Local device name undefined!\nPlease define device name!"),i18n("KO/Pi config error"));
219 return; 219 return;
220 } 220 }
221 int i; 221 int i;
222 for (i = 0; i < mSyncProfileNames.count(); ++ i) { 222 for (i = 0; i < mSyncProfileNames.count(); ++ i) {
223 if ( mSyncProfileNames.contains( mSyncProfileNames[i]) > 1 ) { 223 if ( mSyncProfileNames.contains( mSyncProfileNames[i]) > 1 ) {
224 KMessageBox::error(this,i18n("Multiple profiles with same name!\nPlease use unique profile names!"),i18n("KO/Pi config error")); 224 KMessageBox::error(this,i18n("Multiple profiles with same name!\nPlease use unique profile names!"),i18n("KO/Pi config error"));
225 return; 225 return;
226 } 226 }
227 } 227 }
228 usrWriteConfig(); 228 usrWriteConfig();
229 QDialog::accept(); 229 QDialog::accept();
230} 230}
231void KSyncPrefsDialog::accept() 231void KSyncPrefsDialog::accept()
232{ 232{
233 slotOK(); 233 slotOK();
234} 234}
235void KSyncPrefsDialog::chooseFile() 235void KSyncPrefsDialog::chooseFile()
236{ 236{
237 QString fn = QDir::homeDirPath(); 237 QString fn = QDir::homeDirPath();
238 238
239 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this ); 239 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this );
240 if ( fn == "" ) 240 if ( fn == "" )
241 return; 241 return;
242 mRemoteFile->setText( fn ); 242 mRemoteFile->setText( fn );
243} 243}
244 244
245void KSyncPrefsDialog::textChanged( const QString & s ) 245void KSyncPrefsDialog::textChanged( const QString & s )
246{ 246{
247 if ( mProfileBox->count() == 0 ) 247 if ( mProfileBox->count() == 0 )
248 return; 248 return;
249 if ( currentSelection < 3 ) { 249 if ( currentSelection < 3 ) {
250 //KMessageBox::error(this,i18n("This profil name\ncannot be edited!\n"),i18n("KO/Pi config error")); 250 //KMessageBox::error(this,i18n("This profil name\ncannot be edited!\n"),i18n("KO/Pi config error"));
251 mProfileBox->blockSignals( true ); 251 mProfileBox->blockSignals( true );
252 mProfileBox->setCurrentItem(mProfileBox-> currentItem ()); 252 mProfileBox->setCurrentItem(mProfileBox-> currentItem ());
253 mProfileBox->blockSignals( false ); 253 mProfileBox->blockSignals( false );
254 return; 254 return;
255 } 255 }
256 //qDebug("cur i %d ",mProfileBox-> currentItem () ); 256 //qDebug("cur i %d ",mProfileBox-> currentItem () );
257 mProfileBox->changeItem ( s, mProfileBox-> currentItem () ) ; 257 mProfileBox->changeItem ( s, mProfileBox-> currentItem () ) ;
258 KSyncProfile* prof = mSyncProfiles.at(mProfileBox-> currentItem ()) ; 258 KSyncProfile* prof = mSyncProfiles.at(mProfileBox-> currentItem ()) ;
259 prof->setName( s ); 259 prof->setName( s );
260 mSyncProfileNames[mProfileBox-> currentItem ()] = s; 260 mSyncProfileNames[mProfileBox-> currentItem ()] = s;
261} 261}
262void KSyncPrefsDialog::profileChanged( int item ) 262void KSyncPrefsDialog::profileChanged( int item )
263{ 263{
264 //qDebug("KSyncPrefsDialog::profileChanged %d ", item ); 264 //qDebug("KSyncPrefsDialog::profileChanged %d ", item );
265 KSyncProfile* prof; 265 KSyncProfile* prof;
266 saveProfile(); 266 saveProfile();
267 currentSelection = item; 267 currentSelection = item;
268 prof = mSyncProfiles.at(item) ; 268 prof = mSyncProfiles.at(item) ;
269 mRemotePrecommand->setText(prof->getPreSyncCommand()); 269 mRemotePrecommand->setText(prof->getPreSyncCommand());
270 mRemotePostcommand->setText(prof->getPostSyncCommand()); 270 mRemotePostcommand->setText(prof->getPostSyncCommand());
271 mLocalTempFile->setText(prof->getLocalTempFile()); 271 mLocalTempFile->setText(prof->getLocalTempFile());
272 mRemoteFile->setText(prof->getRemoteFileName()) ; 272 mRemoteFile->setText(prof->getRemoteFileName()) ;
273 mShowSummaryAfterSync->setChecked( prof->getShowSummaryAfterSync()); 273 mShowSummaryAfterSync->setChecked( prof->getShowSummaryAfterSync());
274 mAskForPreferences->setChecked( prof->getAskForPreferences()); 274 mAskForPreferences->setChecked( prof->getAskForPreferences());
275 mWriteBackExisting->setChecked( prof->getWriteBackExisting() ); 275 mWriteBackExisting->setChecked( prof->getWriteBackExisting() );
276 mWriteBackFile->setChecked( prof->getWriteBackFile()); 276 mWriteBackFile->setChecked( prof->getWriteBackFile());
277 mIncludeInRing->setChecked( prof->getIncludeInRingSync() ); 277 mIncludeInRing->setChecked( prof->getIncludeInRingSync() );
278 278
279 switch ( prof->getSyncPrefs() ) { 279 switch ( prof->getSyncPrefs() ) {
280 case 0: 280 case 0:
281 loc->setChecked( true); 281 loc->setChecked( true);
282 break; 282 break;
283 case 1: 283 case 1:
284 rem->setChecked( true ); 284 rem->setChecked( true );
285 break; 285 break;
286 case 2: 286 case 2:
287 newest->setChecked( true); 287 newest->setChecked( true);
288 break; 288 break;
289 case 3: 289 case 3:
290 ask->setChecked( true); 290 ask->setChecked( true);
291 break; 291 break;
292 case 4: 292 case 4:
293 f_loc->setChecked( true); 293 f_loc->setChecked( true);
294 break; 294 break;
295 case 5: 295 case 5:
296 f_rem->setChecked( true); 296 f_rem->setChecked( true);
297 break; 297 break;
298 case 6: 298 case 6:
299 //both->setChecked( true); 299 //both->setChecked( true);
300 break; 300 break;
301 default: 301 default:
302 break; 302 break;
303 } 303 }
304 mIsLocal->setChecked(prof->getIsLocalFileSync()) ; 304 mIsLocal->setChecked(prof->getIsLocalFileSync()) ;
305 mIsNotLocal->setChecked(!prof->getIsLocalFileSync()); 305 mIsNotLocal->setChecked(!prof->getIsLocalFileSync());
306 proGr->setEnabled( item > 2 ); 306 proGr->setEnabled( item > 2 );
307 if ( item < 3 ) { 307 if ( item < 3 ) {
308 localFileWidget->setEnabled(false); 308 localFileWidget->setEnabled(false);
309 remoteFileWidget->setEnabled(false); 309 remoteFileWidget->setEnabled(false);
310 310
311 } else 311 } else
312 kindChanged( prof->getIsLocalFileSync() ); 312 kindChanged( prof->getIsLocalFileSync() );
313} 313}
314 314
315void KSyncPrefsDialog::fillSSH() 315void KSyncPrefsDialog::fillSSH()
316{ 316{
317 mRemotePrecommand->setText("scp zaurus@192.168.0.65:/home/zaurus/kdepim/apps/korganizer/mycalendar.ics /tmp/mycalendar.ics" ); 317 mRemotePrecommand->setText("scp zaurus@192.168.0.65:/home/zaurus/kdepim/apps/korganizer/mycalendar.ics /tmp/mycalendar.ics" );
318 mLocalTempFile->setText("/tmp/mycalendar.ics" ); 318 mLocalTempFile->setText("/tmp/mycalendar.ics" );
319 mRemotePostcommand->setText("scp /tmp/mycalendar.ics zaurus@192.168.0.65:/home/zaurus/kdepim/apps/korganizer/mycalendar.ics" ); 319 mRemotePostcommand->setText("scp /tmp/mycalendar.ics zaurus@192.168.0.65:/home/zaurus/kdepim/apps/korganizer/mycalendar.ics" );
320} 320}
321void KSyncPrefsDialog::fillFTP() 321void KSyncPrefsDialog::fillFTP()
322{ 322{
323 mRemotePrecommand->setText("cd /tmp;ftp ftp://zaurus:a@192.168.0.65/kdepim/apps/korganizer/mycalendar.ics" ); 323 mRemotePrecommand->setText("cd /tmp;ftp ftp://zaurus:a@192.168.0.65/kdepim/apps/korganizer/mycalendar.ics" );
324 mLocalTempFile->setText("/tmp/mycalendar.ics" ); 324 mLocalTempFile->setText("/tmp/mycalendar.ics" );
325 mRemotePostcommand->setText("ftp -u ftp://zaurus:a@192.168.0.65/kdepim/apps/korganizer/mycalendar.ics /tmp/mycalendar.ics" ); 325 mRemotePostcommand->setText("ftp -u ftp://zaurus:a@192.168.0.65/kdepim/apps/korganizer/mycalendar.ics /tmp/mycalendar.ics" );
326 326
327} 327}
328void KSyncPrefsDialog::kindChanged( bool b ) 328void KSyncPrefsDialog::kindChanged( bool b )
329{ 329{
330 330
331 localFileWidget->setEnabled(b); 331 localFileWidget->setEnabled(b);
332 remoteFileWidget->setEnabled(!b); 332 remoteFileWidget->setEnabled(!b);
333 333
334} 334}
335void KSyncPrefsDialog::deleteProfile() 335void KSyncPrefsDialog::deleteProfile()
336{ 336{
337 //qDebug("KSyncPrefsDialog::deleteProfile() "); 337 //qDebug("KSyncPrefsDialog::deleteProfile() ");
338 if ( currentSelection >= 0 ) { 338 if ( currentSelection >= 0 ) {
339 if ( currentSelection < 3 ) { 339 if ( currentSelection < 3 ) {
340 KMessageBox::error(this,i18n("This profil cannot be deleted!\n"),i18n("KO/Pi config error")); 340 KMessageBox::error(this,i18n("This profil cannot be deleted!\n"),i18n("KO/Pi config error"));
341 return; 341 return;
342 } 342 }
343 KSyncProfile* temp = mSyncProfiles.at(currentSelection); 343 KSyncProfile* temp = mSyncProfiles.at(currentSelection);
344 mSyncProfiles.remove( temp ); 344 mSyncProfiles.remove( temp );
345 mSyncProfileNames.remove( mSyncProfileNames.at( currentSelection )); 345 mSyncProfileNames.remove( mSyncProfileNames.at( currentSelection ));
346 insertProfiles(); 346 insertProfiles();
347 } 347 }
348} 348}
349 349
350void KSyncPrefsDialog::saveProfile() 350void KSyncPrefsDialog::saveProfile()
351{ 351{
352 KSyncProfile* prof; 352 KSyncProfile* prof;
353 if ( currentSelection >= 0 ) { 353 if ( currentSelection >= 0 ) {
354 prof = mSyncProfiles.at(currentSelection) ; 354 prof = mSyncProfiles.at(currentSelection) ;
355 prof->setPreSyncCommand( mRemotePrecommand->text()); 355 prof->setPreSyncCommand( mRemotePrecommand->text());
356 prof->setPostSyncCommand( mRemotePostcommand->text() ); 356 prof->setPostSyncCommand( mRemotePostcommand->text() );
357 prof->setLocalTempFile( mLocalTempFile->text()); 357 prof->setLocalTempFile( mLocalTempFile->text());
358 prof->setRemoteFileName( mRemoteFile->text() ); 358 prof->setRemoteFileName( mRemoteFile->text() );
359 prof->setShowSummaryAfterSync( mShowSummaryAfterSync->isChecked() ); 359 prof->setShowSummaryAfterSync( mShowSummaryAfterSync->isChecked() );
360 prof->setAskForPreferences( mAskForPreferences->isChecked()); 360 prof->setAskForPreferences( mAskForPreferences->isChecked());
361 prof->setWriteBackExisting(mWriteBackExisting->isChecked() ); 361 prof->setWriteBackExisting(mWriteBackExisting->isChecked() );
362 prof->setWriteBackFile( mWriteBackFile->isChecked()); 362 prof->setWriteBackFile( mWriteBackFile->isChecked());
363 prof->setIncludeInRingSync( mIncludeInRing->isChecked() ); 363 prof->setIncludeInRingSync( mIncludeInRing->isChecked() );
364 int syncprefs = rem->isChecked()*1+newest->isChecked()*2+ ask->isChecked()*3+ f_loc->isChecked()*4+ f_rem->isChecked()*5 ;//+ both->isChecked()*6 ; 364 int syncprefs = rem->isChecked()*1+newest->isChecked()*2+ ask->isChecked()*3+ f_loc->isChecked()*4+ f_rem->isChecked()*5 ;//+ both->isChecked()*6 ;
365 prof->setSyncPrefs( syncprefs); 365 prof->setSyncPrefs( syncprefs);
366 prof->setIsLocalFileSync( mIsLocal->isChecked() ); 366 prof->setIsLocalFileSync( mIsLocal->isChecked() );
367 } 367 }
368 368
369} 369}
370 370
371void KSyncPrefsDialog::insertProfiles() 371void KSyncPrefsDialog::insertProfiles()
372{ 372{
373 int curItem = mProfileBox->currentItem(); 373 int curItem = mProfileBox->currentItem();
374 mProfileBox->blockSignals( true ); 374 mProfileBox->blockSignals( true );
375 mProfileBox->clear(); 375 mProfileBox->clear();
376 mProfileBox->insertStringList (mSyncProfileNames ); 376 mProfileBox->insertStringList (mSyncProfileNames );
377 int item = mSyncProfileNames.count() -1; 377 int item = mSyncProfileNames.count() -1;
378 if ( curItem >= 0 && mSyncProfileNames.count() > 0 && curItem < mSyncProfileNames.count() ) 378 if ( curItem >= 0 && mSyncProfileNames.count() > 0 && curItem < mSyncProfileNames.count() )
379 mProfileBox->setCurrentItem( curItem ); 379 mProfileBox->setCurrentItem( curItem );
380 else if ( item >= 0 ) { 380 else if ( item >= 0 ) {
381 mProfileBox->setCurrentItem( item ); 381 mProfileBox->setCurrentItem( item );
382 } 382 }
383 currentSelection = -1; 383 currentSelection = -1;
384 if ( mSyncProfileNames.count() > 0 ) { 384 if ( mSyncProfileNames.count() > 0 ) {
385 //qDebug(" profileChanged( mProfileBox->currentItem() "); 385 //qDebug(" profileChanged( mProfileBox->currentItem() ");
386 profileChanged( mProfileBox->currentItem() ); 386 profileChanged( mProfileBox->currentItem() );
387 currentSelection = mProfileBox->currentItem(); 387 currentSelection = mProfileBox->currentItem();
388 } 388 }
389 mProfileBox->blockSignals( false ); 389 mProfileBox->blockSignals( false );
390} 390}
391 391
392void KSyncPrefsDialog::addProfile ( KSyncProfile* temp ) 392void KSyncPrefsDialog::addProfile ( KSyncProfile* temp )
393{ 393{
394 saveProfile(); 394 saveProfile();
395 mSyncProfiles.append( temp ); 395 mSyncProfiles.append( temp );
396 mSyncProfileNames << temp->getName(); 396 mSyncProfileNames << temp->getName();
397 insertProfiles(); 397 insertProfiles();
398 int last = mProfileBox->count() -1; 398 int last = mProfileBox->count() -1;
399 mProfileBox->blockSignals( true ); 399 mProfileBox->blockSignals( true );
400 mProfileBox->setCurrentItem( last ); 400 mProfileBox->setCurrentItem( last );
401 mProfileBox->blockSignals( false ); 401 mProfileBox->blockSignals( false );
402 profileChanged(last); 402 profileChanged(last);
403} 403}
404void KSyncPrefsDialog::newProfile() 404void KSyncPrefsDialog::newProfile()
405{ 405{
406 addProfile ( new KSyncProfile () ); 406 addProfile ( new KSyncProfile () );
407} 407}
408 408
409void KSyncPrefsDialog::cloneProfile() 409void KSyncPrefsDialog::cloneProfile()
410{ 410{
411 if ( currentSelection >= 0 ) 411 if ( currentSelection >= 0 )
412 addProfile (mSyncProfiles.at(currentSelection)->clone()) ; 412 addProfile (mSyncProfiles.at(currentSelection)->clone()) ;
413 else 413 else
414 newProfile(); 414 newProfile();
415} 415}
416 416
417void KSyncPrefsDialog::setLocalMachineName ( const QString& name ) 417void KSyncPrefsDialog::setLocalMachineName ( const QString& name )
418{ 418{
419 mMyMachineName->setText( name ); 419 mMyMachineName->setText( name );
420 420
421} 421}
422QString KSyncPrefsDialog::getLocalMachineName ( ) 422QString KSyncPrefsDialog::getLocalMachineName ( )
423{ 423{
424 return mMyMachineName->text(); 424 return mMyMachineName->text();
425} 425}
426 426
427QStringList KSyncPrefsDialog::getSyncProfileNames() 427QStringList KSyncPrefsDialog::getSyncProfileNames()
428{ 428{
429 return mSyncProfileNames; 429 return mSyncProfileNames;
430} 430}
431void KSyncPrefsDialog::usrReadConfig() 431void KSyncPrefsDialog::usrReadConfig()
432{ 432{
433 //KConfig *config = KOGlobals::config(); 433 //KConfig *config = KOGlobals::config();
434 KConfig config ( locateLocal( "config","syncprofilesrc" ) ); 434 KConfig config ( locateLocal( "config","syncprofilesrc" ) );
435 config.setGroup("SyncProfiles"); 435 config.setGroup("SyncProfiles");
436 mSyncProfileNames =config.readListEntry("SyncProfileNames"); 436 mSyncProfileNames =config.readListEntry("SyncProfileNames");
437 mMyMachineName->setText(config.readEntry("LocalMachineName","undefined"));
437 int i; 438 int i;
438 KSyncProfile* temp ; 439 KSyncProfile* temp ;
439 mSyncProfiles.clear(); 440 mSyncProfiles.clear();
440 for ( i = 0; i < mSyncProfileNames.count();++i ) { 441 for ( i = 0; i < mSyncProfileNames.count();++i ) {
441 temp = new KSyncProfile (); 442 temp = new KSyncProfile ();
442 temp->setName( mSyncProfileNames[i] ); 443 temp->setName( mSyncProfileNames[i] );
443 temp->readConfig( &config ); 444 temp->readConfig( &config );
444 mSyncProfiles.append( temp ); 445 mSyncProfiles.append( temp );
445 } 446 }
446 insertProfiles(); 447 insertProfiles();
447 //mMyMachineName->setText(KOPrefs::instance()->mLocalMachineName ); 448 //mMyMachineName->setText(KOPrefs::instance()->mLocalMachineName );
448} 449}
449 450
450 451
451void KSyncPrefsDialog::usrWriteConfig() 452void KSyncPrefsDialog::usrWriteConfig()
452{ 453{
453 saveProfile(); 454 saveProfile();
454 if ( currentSelection >= 0 ) 455 if ( currentSelection >= 0 )
455 profileChanged(currentSelection); 456 profileChanged(currentSelection);
456 //KConfig *config = KOGlobals::config(); 457 //KConfig *config = KOGlobals::config();
457 KConfig config ( locateLocal( "config","syncprofilesrc" ) ); 458 KConfig config ( locateLocal( "config","syncprofilesrc" ) );
458 config.setGroup("SyncProfiles"); 459 config.setGroup("SyncProfiles");
459 KSyncProfile* prof = mSyncProfiles.first(); 460 KSyncProfile* prof = mSyncProfiles.first();
460 while ( prof ) { 461 while ( prof ) {
461 prof->writeConfig(&config); 462 prof->writeConfig(&config);
462 prof = mSyncProfiles.next(); 463 prof = mSyncProfiles.next();
463 } 464 }
464 //KOPrefs::instance()->mSyncProfileNames = mSyncProfileNames; 465 //KOPrefs::instance()->mSyncProfileNames = mSyncProfileNames;
465 //KOPrefs::instance()->mLocalMachineName = mMyMachineName->text(); 466 //KOPrefs::instance()->mLocalMachineName = mMyMachineName->text();
466 config.writeEntry("SyncProfileNames",&mSyncProfileNames); 467 config.writeEntry("SyncProfileNames",mSyncProfileNames);
468 QString name = mMyMachineName->text();
469 config.writeEntry("LocalMachineName",name);
467} 470}
468 471