summaryrefslogtreecommitdiffabout
path: root/libkdepim/ksyncprefsdialog.cpp
Unidiff
Diffstat (limited to 'libkdepim/ksyncprefsdialog.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libkdepim/ksyncprefsdialog.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/libkdepim/ksyncprefsdialog.cpp b/libkdepim/ksyncprefsdialog.cpp
index 3df2a3b..7c04f48 100644
--- a/libkdepim/ksyncprefsdialog.cpp
+++ b/libkdepim/ksyncprefsdialog.cpp
@@ -1,471 +1,476 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2004 Lutz Rogowski <rogowski@kde.org> 3 Copyright (c) 2004 Lutz Rogowski <rogowski@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include <qlayout.h> 24#include <qlayout.h>
25#include <qlabel.h> 25#include <qlabel.h>
26#include <qgroupbox.h> 26#include <qgroupbox.h>
27#include <qbuttongroup.h> 27#include <qbuttongroup.h>
28#include <qlineedit.h> 28#include <qlineedit.h>
29#include <qfont.h> 29#include <qfont.h>
30#include <qslider.h> 30#include <qslider.h>
31#include <qfile.h> 31#include <qfile.h>
32#include <qdir.h> 32#include <qdir.h>
33#include <qtextstream.h> 33#include <qtextstream.h>
34#include <qcombobox.h> 34#include <qcombobox.h>
35#include <qvbox.h> 35#include <qvbox.h>
36#include <qhbox.h> 36#include <qhbox.h>
37#include <qspinbox.h> 37#include <qspinbox.h>
38#include <qdatetime.h> 38#include <qdatetime.h>
39#include <qcheckbox.h> 39#include <qcheckbox.h>
40#include <qradiobutton.h> 40#include <qradiobutton.h>
41#include <qpushbutton.h> 41#include <qpushbutton.h>
42#include <qstrlist.h> 42#include <qstrlist.h>
43#include <qapplication.h> 43#include <qapplication.h>
44#include <qlayout.h> 44#include <qlayout.h>
45#include <qscrollview.h> 45#include <qscrollview.h>
46 46
47#include <kcolorbutton.h> 47#include <kcolorbutton.h>
48#include <kdebug.h> 48#include <kdebug.h>
49#include <klocale.h> 49#include <klocale.h>
50#include <kglobal.h> 50#include <kglobal.h>
51#include <kfontdialog.h> 51#include <kfontdialog.h>
52#include <kmessagebox.h> 52#include <kmessagebox.h>
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 calendar sync"), topFrame );
144 topLayout->addMultiCellWidget(mIncludeInRing, iii,iii,0,1); 144 topLayout->addMultiCellWidget(mIncludeInRing, iii,iii,0,1);
145 ++iii; 145 ++iii;
146 mIncludeInRingAB = new QCheckBox( i18n("Include in multiple addressbook sync"), topFrame );
147 topLayout->addMultiCellWidget(mIncludeInRingAB, iii,iii,0,1);
148 ++iii;
146 149
147 mAskForPreferences = new QCheckBox( i18n("Ask for preferences before sync"), topFrame ); 150 mAskForPreferences = new QCheckBox( i18n("Ask for preferences before sync"), topFrame );
148 topLayout->addMultiCellWidget(mAskForPreferences, iii,iii,0,1); 151 topLayout->addMultiCellWidget(mAskForPreferences, iii,iii,0,1);
149 ++iii; 152 ++iii;
150 QButtonGroup* gr = new QButtonGroup ( 1, Qt::Horizontal, i18n("Sync preferences"), topFrame); 153 QButtonGroup* gr = new QButtonGroup ( 1, Qt::Horizontal, i18n("Sync preferences"), topFrame);
151 topLayout->addMultiCellWidget(gr, iii,iii,0,1); 154 topLayout->addMultiCellWidget(gr, iii,iii,0,1);
152 ++iii; 155 ++iii;
153 loc = new QRadioButton ( i18n("Take local entry on conflict"), gr ); 156 loc = new QRadioButton ( i18n("Take local entry on conflict"), gr );
154 rem = new QRadioButton ( i18n("Take remote entry on conflict"), gr ); 157 rem = new QRadioButton ( i18n("Take remote entry on conflict"), gr );
155 newest = new QRadioButton ( i18n("Take newest entry on conflict"), gr ); 158 newest = new QRadioButton ( i18n("Take newest entry on conflict"), gr );
156 ask = new QRadioButton ( i18n("Ask for every entry on conflict"), gr ); 159 ask = new QRadioButton ( i18n("Ask for every entry on conflict"), gr );
157 f_loc= new QRadioButton ( i18n("Force: Take local entry always"), gr ); 160 f_loc= new QRadioButton ( i18n("Force: Take local entry always"), gr );
158 f_rem = new QRadioButton ( i18n("Force: Take remote entry always"), gr ); 161 f_rem = new QRadioButton ( i18n("Force: Take remote entry always"), gr );
159 // both = new QRadioButton ( i18n("Take both on conflict"), gr ); 162 // both = new QRadioButton ( i18n("Take both on conflict"), gr );
160 163
161 mShowSummaryAfterSync = new QCheckBox( i18n("Show summary after sync"), topFrame ); 164 mShowSummaryAfterSync = new QCheckBox( i18n("Show summary after sync"), topFrame );
162 topLayout->addMultiCellWidget(mShowSummaryAfterSync, iii,iii,0,1); 165 topLayout->addMultiCellWidget(mShowSummaryAfterSync, iii,iii,0,1);
163 ++iii; 166 ++iii;
164 167
165 mWriteBackExisting= new QCheckBox( i18n("Write back existing entries only"), topFrame ); 168 mWriteBackExisting= new QCheckBox( i18n("Write back existing entries only"), topFrame );
166 topLayout->addMultiCellWidget(mWriteBackExisting, iii,iii,0,1); 169 topLayout->addMultiCellWidget(mWriteBackExisting, iii,iii,0,1);
167 ++iii; 170 ++iii;
168 171
169 mWriteBackFile = new QCheckBox( i18n("Write back file"), topFrame ); 172 mWriteBackFile = new QCheckBox( i18n("Write back file"), topFrame );
170 topLayout->addMultiCellWidget(mWriteBackFile, iii,iii,0,1); 173 topLayout->addMultiCellWidget(mWriteBackFile, iii,iii,0,1);
171 ++iii; 174 ++iii;
172 175
173 proGr = new QButtonGroup ( 1, Qt::Horizontal, i18n("Profile kind"), topFrame); 176 proGr = new QButtonGroup ( 1, Qt::Horizontal, i18n("Profile kind"), topFrame);
174 gr = proGr; 177 gr = proGr;
175 topLayout->addMultiCellWidget(gr, iii,iii,0,1); 178 topLayout->addMultiCellWidget(gr, iii,iii,0,1);
176 ++iii; 179 ++iii;
177 mIsLocal = new QRadioButton ( i18n("Local file"), gr ); 180 mIsLocal = new QRadioButton ( i18n("Local file"), gr );
178 mIsNotLocal = new QRadioButton ( i18n("Remote file (w down/upload command)"), gr ); 181 mIsNotLocal = new QRadioButton ( i18n("Remote file (w down/upload command)"), gr );
179 connect (mIsLocal, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) ); 182 connect (mIsLocal, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) );
180 183
181 localFileWidget = new QVBox( topFrame); 184 localFileWidget = new QVBox( topFrame);
182 topLayout->addMultiCellWidget(localFileWidget, iii,iii,0,1); 185 topLayout->addMultiCellWidget(localFileWidget, iii,iii,0,1);
183 ++iii; 186 ++iii;
184 QHBox* temphb = new QHBox( localFileWidget ); 187 QHBox* temphb = new QHBox( localFileWidget );
185 lab = new QLabel( i18n("Local file:"), temphb); 188 lab = new QLabel( i18n("Local file:"), temphb);
186 mRemoteFile = new QLineEdit(localFileWidget); 189 mRemoteFile = new QLineEdit(localFileWidget);
187 190
188 button = new QPushButton( i18n("Choose..."), temphb ); 191 button = new QPushButton( i18n("Choose..."), temphb );
189 connect ( button, SIGNAL( clicked()), this, SLOT ( chooseFile() ) ); 192 connect ( button, SIGNAL( clicked()), this, SLOT ( chooseFile() ) );
190 193
191 194
192 remoteFileWidget = new QVBox( topFrame); 195 remoteFileWidget = new QVBox( topFrame);
193 topLayout->addMultiCellWidget(remoteFileWidget, iii,iii,0,1); 196 topLayout->addMultiCellWidget(remoteFileWidget, iii,iii,0,1);
194 ++iii; 197 ++iii;
195 lab = new QLabel( i18n("Pre sync (download) command:"), remoteFileWidget); 198 lab = new QLabel( i18n("Pre sync (download) command:"), remoteFileWidget);
196 mRemotePrecommand = new QLineEdit(remoteFileWidget); 199 mRemotePrecommand = new QLineEdit(remoteFileWidget);
197 200
198 lab = new QLabel( i18n("Local temp file:"), remoteFileWidget); 201 lab = new QLabel( i18n("Local temp file:"), remoteFileWidget);
199 mLocalTempFile = new QLineEdit(remoteFileWidget); 202 mLocalTempFile = new QLineEdit(remoteFileWidget);
200 203
201 204
202 lab = new QLabel( i18n("Post sync (upload) command:"), remoteFileWidget); 205 lab = new QLabel( i18n("Post sync (upload) command:"), remoteFileWidget);
203 mRemotePostcommand = new QLineEdit(remoteFileWidget); 206 mRemotePostcommand = new QLineEdit(remoteFileWidget);
204 207
205 lab = new QLabel( i18n("Fill in default values for:"), remoteFileWidget); 208 lab = new QLabel( i18n("Fill in default values for:"), remoteFileWidget);
206 temphb = new QHBox( remoteFileWidget ); 209 temphb = new QHBox( remoteFileWidget );
207 button = new QPushButton( i18n("ssh/scp"), temphb ); 210 button = new QPushButton( i18n("ssh/scp"), temphb );
208 connect ( button, SIGNAL( clicked()), this, SLOT (fillSSH() ) ); 211 connect ( button, SIGNAL( clicked()), this, SLOT (fillSSH() ) );
209 button = new QPushButton( i18n("ftp"), temphb ); 212 button = new QPushButton( i18n("ftp"), temphb );
210 connect ( button, SIGNAL( clicked()), this, SLOT (fillFTP() ) ); 213 connect ( button, SIGNAL( clicked()), this, SLOT (fillFTP() ) );
211 lab = new QLabel( i18n("Hint: Use $PWD$ for placeholder of password!"), remoteFileWidget); 214 lab = new QLabel( i18n("Hint: Use $PWD$ for placeholder of password!"), remoteFileWidget);
212 215
213 216
214} 217}
215void KSyncPrefsDialog::slotOK() 218void KSyncPrefsDialog::slotOK()
216{ 219{
217 if ( mMyMachineName->text() == "undefined" ) { 220 if ( mMyMachineName->text() == "undefined" ) {
218 KMessageBox::error(this,i18n("Local device name undefined!\nPlease define device name!"),i18n("KO/Pi config error")); 221 KMessageBox::error(this,i18n("Local device name undefined!\nPlease define device name!"),i18n("KO/Pi config error"));
219 return; 222 return;
220 } 223 }
221 int i; 224 int i;
222 for (i = 0; i < mSyncProfileNames.count(); ++ i) { 225 for (i = 0; i < mSyncProfileNames.count(); ++ i) {
223 if ( mSyncProfileNames.contains( mSyncProfileNames[i]) > 1 ) { 226 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")); 227 KMessageBox::error(this,i18n("Multiple profiles with same name!\nPlease use unique profile names!"),i18n("KO/Pi config error"));
225 return; 228 return;
226 } 229 }
227 } 230 }
228 usrWriteConfig(); 231 usrWriteConfig();
229 QDialog::accept(); 232 QDialog::accept();
230} 233}
231void KSyncPrefsDialog::accept() 234void KSyncPrefsDialog::accept()
232{ 235{
233 slotOK(); 236 slotOK();
234} 237}
235void KSyncPrefsDialog::chooseFile() 238void KSyncPrefsDialog::chooseFile()
236{ 239{
237 QString fn = QDir::homeDirPath(); 240 QString fn = QDir::homeDirPath();
238 241
239 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this ); 242 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this );
240 if ( fn == "" ) 243 if ( fn == "" )
241 return; 244 return;
242 mRemoteFile->setText( fn ); 245 mRemoteFile->setText( fn );
243} 246}
244 247
245void KSyncPrefsDialog::textChanged( const QString & s ) 248void KSyncPrefsDialog::textChanged( const QString & s )
246{ 249{
247 if ( mProfileBox->count() == 0 ) 250 if ( mProfileBox->count() == 0 )
248 return; 251 return;
249 if ( currentSelection < 3 ) { 252 if ( currentSelection < 3 ) {
250 //KMessageBox::error(this,i18n("This profil name\ncannot be edited!\n"),i18n("KO/Pi config error")); 253 //KMessageBox::error(this,i18n("This profil name\ncannot be edited!\n"),i18n("KO/Pi config error"));
251 mProfileBox->blockSignals( true ); 254 mProfileBox->blockSignals( true );
252 mProfileBox->setCurrentItem(mProfileBox-> currentItem ()); 255 mProfileBox->setCurrentItem(mProfileBox-> currentItem ());
253 mProfileBox->blockSignals( false ); 256 mProfileBox->blockSignals( false );
254 return; 257 return;
255 } 258 }
256 //qDebug("cur i %d ",mProfileBox-> currentItem () ); 259 //qDebug("cur i %d ",mProfileBox-> currentItem () );
257 mProfileBox->changeItem ( s, mProfileBox-> currentItem () ) ; 260 mProfileBox->changeItem ( s, mProfileBox-> currentItem () ) ;
258 KSyncProfile* prof = mSyncProfiles.at(mProfileBox-> currentItem ()) ; 261 KSyncProfile* prof = mSyncProfiles.at(mProfileBox-> currentItem ()) ;
259 prof->setName( s ); 262 prof->setName( s );
260 mSyncProfileNames[mProfileBox-> currentItem ()] = s; 263 mSyncProfileNames[mProfileBox-> currentItem ()] = s;
261} 264}
262void KSyncPrefsDialog::profileChanged( int item ) 265void KSyncPrefsDialog::profileChanged( int item )
263{ 266{
264 //qDebug("KSyncPrefsDialog::profileChanged %d ", item ); 267 //qDebug("KSyncPrefsDialog::profileChanged %d ", item );
265 KSyncProfile* prof; 268 KSyncProfile* prof;
266 saveProfile(); 269 saveProfile();
267 currentSelection = item; 270 currentSelection = item;
268 prof = mSyncProfiles.at(item) ; 271 prof = mSyncProfiles.at(item) ;
269 mRemotePrecommand->setText(prof->getPreSyncCommand()); 272 mRemotePrecommand->setText(prof->getPreSyncCommand());
270 mRemotePostcommand->setText(prof->getPostSyncCommand()); 273 mRemotePostcommand->setText(prof->getPostSyncCommand());
271 mLocalTempFile->setText(prof->getLocalTempFile()); 274 mLocalTempFile->setText(prof->getLocalTempFile());
272 mRemoteFile->setText(prof->getRemoteFileName()) ; 275 mRemoteFile->setText(prof->getRemoteFileName()) ;
273 mShowSummaryAfterSync->setChecked( prof->getShowSummaryAfterSync()); 276 mShowSummaryAfterSync->setChecked( prof->getShowSummaryAfterSync());
274 mAskForPreferences->setChecked( prof->getAskForPreferences()); 277 mAskForPreferences->setChecked( prof->getAskForPreferences());
275 mWriteBackExisting->setChecked( prof->getWriteBackExisting() ); 278 mWriteBackExisting->setChecked( prof->getWriteBackExisting() );
276 mWriteBackFile->setChecked( prof->getWriteBackFile()); 279 mWriteBackFile->setChecked( prof->getWriteBackFile());
277 mIncludeInRing->setChecked( prof->getIncludeInRingSync() ); 280 mIncludeInRing->setChecked( prof->getIncludeInRingSync() );
281 mIncludeInRingAB->setChecked( prof->getIncludeInRingSyncAB() );
278 282
279 switch ( prof->getSyncPrefs() ) { 283 switch ( prof->getSyncPrefs() ) {
280 case 0: 284 case 0:
281 loc->setChecked( true); 285 loc->setChecked( true);
282 break; 286 break;
283 case 1: 287 case 1:
284 rem->setChecked( true ); 288 rem->setChecked( true );
285 break; 289 break;
286 case 2: 290 case 2:
287 newest->setChecked( true); 291 newest->setChecked( true);
288 break; 292 break;
289 case 3: 293 case 3:
290 ask->setChecked( true); 294 ask->setChecked( true);
291 break; 295 break;
292 case 4: 296 case 4:
293 f_loc->setChecked( true); 297 f_loc->setChecked( true);
294 break; 298 break;
295 case 5: 299 case 5:
296 f_rem->setChecked( true); 300 f_rem->setChecked( true);
297 break; 301 break;
298 case 6: 302 case 6:
299 //both->setChecked( true); 303 //both->setChecked( true);
300 break; 304 break;
301 default: 305 default:
302 break; 306 break;
303 } 307 }
304 mIsLocal->setChecked(prof->getIsLocalFileSync()) ; 308 mIsLocal->setChecked(prof->getIsLocalFileSync()) ;
305 mIsNotLocal->setChecked(!prof->getIsLocalFileSync()); 309 mIsNotLocal->setChecked(!prof->getIsLocalFileSync());
306 proGr->setEnabled( item > 2 ); 310 proGr->setEnabled( item > 2 );
307 if ( item < 3 ) { 311 if ( item < 3 ) {
308 localFileWidget->setEnabled(false); 312 localFileWidget->setEnabled(false);
309 remoteFileWidget->setEnabled(false); 313 remoteFileWidget->setEnabled(false);
310 314
311 } else 315 } else
312 kindChanged( prof->getIsLocalFileSync() ); 316 kindChanged( prof->getIsLocalFileSync() );
313} 317}
314 318
315void KSyncPrefsDialog::fillSSH() 319void KSyncPrefsDialog::fillSSH()
316{ 320{
317 mRemotePrecommand->setText("scp zaurus@192.168.0.65:/home/zaurus/kdepim/apps/korganizer/mycalendar.ics /tmp/mycalendar.ics" ); 321 mRemotePrecommand->setText("scp zaurus@192.168.0.65:/home/zaurus/kdepim/apps/korganizer/mycalendar.ics /tmp/mycalendar.ics" );
318 mLocalTempFile->setText("/tmp/mycalendar.ics" ); 322 mLocalTempFile->setText("/tmp/mycalendar.ics" );
319 mRemotePostcommand->setText("scp /tmp/mycalendar.ics zaurus@192.168.0.65:/home/zaurus/kdepim/apps/korganizer/mycalendar.ics" ); 323 mRemotePostcommand->setText("scp /tmp/mycalendar.ics zaurus@192.168.0.65:/home/zaurus/kdepim/apps/korganizer/mycalendar.ics" );
320} 324}
321void KSyncPrefsDialog::fillFTP() 325void KSyncPrefsDialog::fillFTP()
322{ 326{
323 mRemotePrecommand->setText("cd /tmp;ftp ftp://zaurus:a@192.168.0.65/kdepim/apps/korganizer/mycalendar.ics" ); 327 mRemotePrecommand->setText("cd /tmp;ftp ftp://zaurus:a@192.168.0.65/kdepim/apps/korganizer/mycalendar.ics" );
324 mLocalTempFile->setText("/tmp/mycalendar.ics" ); 328 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" ); 329 mRemotePostcommand->setText("ftp -u ftp://zaurus:a@192.168.0.65/kdepim/apps/korganizer/mycalendar.ics /tmp/mycalendar.ics" );
326 330
327} 331}
328void KSyncPrefsDialog::kindChanged( bool b ) 332void KSyncPrefsDialog::kindChanged( bool b )
329{ 333{
330 334
331 localFileWidget->setEnabled(b); 335 localFileWidget->setEnabled(b);
332 remoteFileWidget->setEnabled(!b); 336 remoteFileWidget->setEnabled(!b);
333 337
334} 338}
335void KSyncPrefsDialog::deleteProfile() 339void KSyncPrefsDialog::deleteProfile()
336{ 340{
337 //qDebug("KSyncPrefsDialog::deleteProfile() "); 341 //qDebug("KSyncPrefsDialog::deleteProfile() ");
338 if ( currentSelection >= 0 ) { 342 if ( currentSelection >= 0 ) {
339 if ( currentSelection < 3 ) { 343 if ( currentSelection < 3 ) {
340 KMessageBox::error(this,i18n("This profil cannot be deleted!\n"),i18n("KO/Pi config error")); 344 KMessageBox::error(this,i18n("This profil cannot be deleted!\n"),i18n("KO/Pi config error"));
341 return; 345 return;
342 } 346 }
343 KSyncProfile* temp = mSyncProfiles.at(currentSelection); 347 KSyncProfile* temp = mSyncProfiles.at(currentSelection);
344 mSyncProfiles.remove( temp ); 348 mSyncProfiles.remove( temp );
345 mSyncProfileNames.remove( mSyncProfileNames.at( currentSelection )); 349 mSyncProfileNames.remove( mSyncProfileNames.at( currentSelection ));
346 insertProfiles(); 350 insertProfiles();
347 } 351 }
348} 352}
349 353
350void KSyncPrefsDialog::saveProfile() 354void KSyncPrefsDialog::saveProfile()
351{ 355{
352 KSyncProfile* prof; 356 KSyncProfile* prof;
353 if ( currentSelection >= 0 ) { 357 if ( currentSelection >= 0 ) {
354 prof = mSyncProfiles.at(currentSelection) ; 358 prof = mSyncProfiles.at(currentSelection) ;
355 prof->setPreSyncCommand( mRemotePrecommand->text()); 359 prof->setPreSyncCommand( mRemotePrecommand->text());
356 prof->setPostSyncCommand( mRemotePostcommand->text() ); 360 prof->setPostSyncCommand( mRemotePostcommand->text() );
357 prof->setLocalTempFile( mLocalTempFile->text()); 361 prof->setLocalTempFile( mLocalTempFile->text());
358 prof->setRemoteFileName( mRemoteFile->text() ); 362 prof->setRemoteFileName( mRemoteFile->text() );
359 prof->setShowSummaryAfterSync( mShowSummaryAfterSync->isChecked() ); 363 prof->setShowSummaryAfterSync( mShowSummaryAfterSync->isChecked() );
360 prof->setAskForPreferences( mAskForPreferences->isChecked()); 364 prof->setAskForPreferences( mAskForPreferences->isChecked());
361 prof->setWriteBackExisting(mWriteBackExisting->isChecked() ); 365 prof->setWriteBackExisting(mWriteBackExisting->isChecked() );
362 prof->setWriteBackFile( mWriteBackFile->isChecked()); 366 prof->setWriteBackFile( mWriteBackFile->isChecked());
363 prof->setIncludeInRingSync( mIncludeInRing->isChecked() ); 367 prof->setIncludeInRingSync( mIncludeInRing->isChecked() );
368 prof->setIncludeInRingSyncAB( mIncludeInRingAB->isChecked() );
364 int syncprefs = rem->isChecked()*1+newest->isChecked()*2+ ask->isChecked()*3+ f_loc->isChecked()*4+ f_rem->isChecked()*5 ;//+ both->isChecked()*6 ; 369 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); 370 prof->setSyncPrefs( syncprefs);
366 prof->setIsLocalFileSync( mIsLocal->isChecked() ); 371 prof->setIsLocalFileSync( mIsLocal->isChecked() );
367 } 372 }
368 373
369} 374}
370 375
371void KSyncPrefsDialog::insertProfiles() 376void KSyncPrefsDialog::insertProfiles()
372{ 377{
373 int curItem = mProfileBox->currentItem(); 378 int curItem = mProfileBox->currentItem();
374 mProfileBox->blockSignals( true ); 379 mProfileBox->blockSignals( true );
375 mProfileBox->clear(); 380 mProfileBox->clear();
376 mProfileBox->insertStringList (mSyncProfileNames ); 381 mProfileBox->insertStringList (mSyncProfileNames );
377 int item = mSyncProfileNames.count() -1; 382 int item = mSyncProfileNames.count() -1;
378 if ( curItem >= 0 && mSyncProfileNames.count() > 0 && curItem < mSyncProfileNames.count() ) 383 if ( curItem >= 0 && mSyncProfileNames.count() > 0 && curItem < mSyncProfileNames.count() )
379 mProfileBox->setCurrentItem( curItem ); 384 mProfileBox->setCurrentItem( curItem );
380 else if ( item >= 0 ) { 385 else if ( item >= 0 ) {
381 mProfileBox->setCurrentItem( item ); 386 mProfileBox->setCurrentItem( item );
382 } 387 }
383 currentSelection = -1; 388 currentSelection = -1;
384 if ( mSyncProfileNames.count() > 0 ) { 389 if ( mSyncProfileNames.count() > 0 ) {
385 //qDebug(" profileChanged( mProfileBox->currentItem() "); 390 //qDebug(" profileChanged( mProfileBox->currentItem() ");
386 profileChanged( mProfileBox->currentItem() ); 391 profileChanged( mProfileBox->currentItem() );
387 currentSelection = mProfileBox->currentItem(); 392 currentSelection = mProfileBox->currentItem();
388 } 393 }
389 mProfileBox->blockSignals( false ); 394 mProfileBox->blockSignals( false );
390} 395}
391 396
392void KSyncPrefsDialog::addProfile ( KSyncProfile* temp ) 397void KSyncPrefsDialog::addProfile ( KSyncProfile* temp )
393{ 398{
394 saveProfile(); 399 saveProfile();
395 mSyncProfiles.append( temp ); 400 mSyncProfiles.append( temp );
396 mSyncProfileNames << temp->getName(); 401 mSyncProfileNames << temp->getName();
397 insertProfiles(); 402 insertProfiles();
398 int last = mProfileBox->count() -1; 403 int last = mProfileBox->count() -1;
399 mProfileBox->blockSignals( true ); 404 mProfileBox->blockSignals( true );
400 mProfileBox->setCurrentItem( last ); 405 mProfileBox->setCurrentItem( last );
401 mProfileBox->blockSignals( false ); 406 mProfileBox->blockSignals( false );
402 profileChanged(last); 407 profileChanged(last);
403} 408}
404void KSyncPrefsDialog::newProfile() 409void KSyncPrefsDialog::newProfile()
405{ 410{
406 addProfile ( new KSyncProfile () ); 411 addProfile ( new KSyncProfile () );
407} 412}
408 413
409void KSyncPrefsDialog::cloneProfile() 414void KSyncPrefsDialog::cloneProfile()
410{ 415{
411 if ( currentSelection >= 0 ) 416 if ( currentSelection >= 0 )
412 addProfile (mSyncProfiles.at(currentSelection)->clone()) ; 417 addProfile (mSyncProfiles.at(currentSelection)->clone()) ;
413 else 418 else
414 newProfile(); 419 newProfile();
415} 420}
416 421
417void KSyncPrefsDialog::setLocalMachineName ( const QString& name ) 422void KSyncPrefsDialog::setLocalMachineName ( const QString& name )
418{ 423{
419 mMyMachineName->setText( name ); 424 mMyMachineName->setText( name );
420 425
421} 426}
422QString KSyncPrefsDialog::getLocalMachineName ( ) 427QString KSyncPrefsDialog::getLocalMachineName ( )
423{ 428{
424 return mMyMachineName->text(); 429 return mMyMachineName->text();
425} 430}
426 431
427QStringList KSyncPrefsDialog::getSyncProfileNames() 432QStringList KSyncPrefsDialog::getSyncProfileNames()
428{ 433{
429 return mSyncProfileNames; 434 return mSyncProfileNames;
430} 435}
431void KSyncPrefsDialog::usrReadConfig() 436void KSyncPrefsDialog::usrReadConfig()
432{ 437{
433 //KConfig *config = KOGlobals::config(); 438 //KConfig *config = KOGlobals::config();
434 KConfig config ( locateLocal( "config","syncprofilesrc" ) ); 439 KConfig config ( locateLocal( "config","syncprofilesrc" ) );
435 config.setGroup("SyncProfiles"); 440 config.setGroup("SyncProfiles");
436 mSyncProfileNames =config.readListEntry("SyncProfileNames"); 441 mSyncProfileNames =config.readListEntry("SyncProfileNames");
437 mMyMachineName->setText(config.readEntry("LocalMachineName","undefined")); 442 mMyMachineName->setText(config.readEntry("LocalMachineName","undefined"));
438 int i; 443 int i;
439 KSyncProfile* temp ; 444 KSyncProfile* temp ;
440 mSyncProfiles.clear(); 445 mSyncProfiles.clear();
441 for ( i = 0; i < mSyncProfileNames.count();++i ) { 446 for ( i = 0; i < mSyncProfileNames.count();++i ) {
442 temp = new KSyncProfile (); 447 temp = new KSyncProfile ();
443 temp->setName( mSyncProfileNames[i] ); 448 temp->setName( mSyncProfileNames[i] );
444 temp->readConfig( &config ); 449 temp->readConfig( &config );
445 mSyncProfiles.append( temp ); 450 mSyncProfiles.append( temp );
446 } 451 }
447 insertProfiles(); 452 insertProfiles();
448 //mMyMachineName->setText(KOPrefs::instance()->mLocalMachineName ); 453 //mMyMachineName->setText(KOPrefs::instance()->mLocalMachineName );
449} 454}
450 455
451 456
452void KSyncPrefsDialog::usrWriteConfig() 457void KSyncPrefsDialog::usrWriteConfig()
453{ 458{
454 saveProfile(); 459 saveProfile();
455 if ( currentSelection >= 0 ) 460 if ( currentSelection >= 0 )
456 profileChanged(currentSelection); 461 profileChanged(currentSelection);
457 //KConfig *config = KOGlobals::config(); 462 //KConfig *config = KOGlobals::config();
458 KConfig config ( locateLocal( "config","syncprofilesrc" ) ); 463 KConfig config ( locateLocal( "config","syncprofilesrc" ) );
459 config.setGroup("SyncProfiles"); 464 config.setGroup("SyncProfiles");
460 KSyncProfile* prof = mSyncProfiles.first(); 465 KSyncProfile* prof = mSyncProfiles.first();
461 while ( prof ) { 466 while ( prof ) {
462 prof->writeConfig(&config); 467 prof->writeConfig(&config);
463 prof = mSyncProfiles.next(); 468 prof = mSyncProfiles.next();
464 } 469 }
465 //KOPrefs::instance()->mSyncProfileNames = mSyncProfileNames; 470 //KOPrefs::instance()->mSyncProfileNames = mSyncProfileNames;
466 //KOPrefs::instance()->mLocalMachineName = mMyMachineName->text(); 471 //KOPrefs::instance()->mLocalMachineName = mMyMachineName->text();
467 config.writeEntry("SyncProfileNames",mSyncProfileNames); 472 config.writeEntry("SyncProfileNames",mSyncProfileNames);
468 QString name = mMyMachineName->text(); 473 QString name = mMyMachineName->text();
469 config.writeEntry("LocalMachineName",name); 474 config.writeEntry("LocalMachineName",name);
470} 475}
471 476