summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/aqpkg/settingsimpl.cpp114
1 files changed, 72 insertions, 42 deletions
diff --git a/noncore/settings/aqpkg/settingsimpl.cpp b/noncore/settings/aqpkg/settingsimpl.cpp
index 9f611da..e2afada 100644
--- a/noncore/settings/aqpkg/settingsimpl.cpp
+++ b/noncore/settings/aqpkg/settingsimpl.cpp
@@ -97,355 +97,385 @@ QWidget *SettingsImpl :: initServerTab()
97 QGridLayout *layout = new QGridLayout( container ); 97 QGridLayout *layout = new QGridLayout( container );
98 layout->setSpacing( 2 ); 98 layout->setSpacing( 2 );
99 layout->setMargin( 4 ); 99 layout->setMargin( 4 );
100 100
101 servers = new QListBox( container ); 101 servers = new QListBox( container );
102 servers->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) ); 102 servers->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) );
103 connect( servers, SIGNAL( highlighted( int ) ), this, SLOT( editServer( int ) ) ); 103 connect( servers, SIGNAL( highlighted( int ) ), this, SLOT( editServer( int ) ) );
104 layout->addMultiCellWidget( servers, 0, 0, 0, 1 ); 104 layout->addMultiCellWidget( servers, 0, 0, 0, 1 );
105 105
106 QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), container ); 106 QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), container );
107 connect( btn, SIGNAL( clicked() ), this, SLOT( newServer() ) ); 107 connect( btn, SIGNAL( clicked() ), this, SLOT( newServer() ) );
108 layout->addWidget( btn, 1, 0 ); 108 layout->addWidget( btn, 1, 0 );
109 109
110 btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), container ); 110 btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), container );
111 connect( btn, SIGNAL( clicked() ), this, SLOT( removeServer() ) ); 111 connect( btn, SIGNAL( clicked() ), this, SLOT( removeServer() ) );
112 layout->addWidget( btn, 1, 1 ); 112 layout->addWidget( btn, 1, 1 );
113 113
114 QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "Server" ), container ); 114 QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "Server" ), container );
115 grpbox->layout()->setSpacing( 2 ); 115 grpbox->layout()->setSpacing( 2 );
116 grpbox->layout()->setMargin( 4 ); 116 grpbox->layout()->setMargin( 4 );
117 layout->addMultiCellWidget( grpbox, 2, 2, 0, 1 ); 117 layout->addMultiCellWidget( grpbox, 2, 2, 0, 1 );
118 118
119 QGridLayout *grplayout = new QGridLayout( grpbox->layout() ); 119 QGridLayout *grplayout = new QGridLayout( grpbox->layout() );
120 120
121 QLabel *label = new QLabel( tr( "Name:" ), grpbox ); 121 QLabel *label = new QLabel( tr( "Name:" ), grpbox );
122 grplayout->addWidget( label, 0, 0 ); 122 grplayout->addWidget( label, 0, 0 );
123 servername = new QLineEdit( grpbox ); 123 servername = new QLineEdit( grpbox );
124 grplayout->addWidget( servername, 0, 1 ); 124 grplayout->addWidget( servername, 0, 1 );
125 125
126 label = new QLabel( tr( "Address:" ), grpbox ); 126 label = new QLabel( tr( "Address:" ), grpbox );
127 grplayout->addWidget( label, 1, 0 ); 127 grplayout->addWidget( label, 1, 0 );
128 serverurl = new QLineEdit( grpbox ); 128 serverurl = new QLineEdit( grpbox );
129 grplayout->addWidget( serverurl, 1, 1 ); 129 grplayout->addWidget( serverurl, 1, 1 );
130 130
131 active = new QCheckBox( tr( "Active Server" ), grpbox ); 131 active = new QCheckBox( tr( "Active Server" ), grpbox );
132 grplayout->addMultiCellWidget( active, 2, 2, 0, 1 ); 132 grplayout->addMultiCellWidget( active, 2, 2, 0, 1 );
133 133
134 btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Update" ), grpbox ); 134 btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Update" ), grpbox );
135 connect( btn, SIGNAL( clicked() ), this, SLOT( changeServerDetails() ) ); 135 connect( btn, SIGNAL( clicked() ), this, SLOT( changeServerDetails() ) );
136 grplayout->addMultiCellWidget( btn, 3, 3, 0, 1 ); 136 grplayout->addMultiCellWidget( btn, 3, 3, 0, 1 );
137 137
138 return control; 138 return control;
139} 139}
140 140
141QWidget *SettingsImpl :: initDestinationTab() 141QWidget *SettingsImpl :: initDestinationTab()
142{ 142{
143 QWidget *control = new QWidget( this ); 143 QWidget *control = new QWidget( this );
144 144
145 QVBoxLayout *vb = new QVBoxLayout( control ); 145 QVBoxLayout *vb = new QVBoxLayout( control );
146 146
147 QScrollView *sv = new QScrollView( control ); 147 QScrollView *sv = new QScrollView( control );
148 vb->addWidget( sv, 0, 0 ); 148 vb->addWidget( sv, 0, 0 );
149 sv->setResizePolicy( QScrollView::AutoOneFit ); 149 sv->setResizePolicy( QScrollView::AutoOneFit );
150 sv->setFrameStyle( QFrame::NoFrame ); 150 sv->setFrameStyle( QFrame::NoFrame );
151 151
152 QWidget *container = new QWidget( sv->viewport() ); 152 QWidget *container = new QWidget( sv->viewport() );
153 sv->addChild( container ); 153 sv->addChild( container );
154 154
155 QGridLayout *layout = new QGridLayout( container ); 155 QGridLayout *layout = new QGridLayout( container );
156 layout->setSpacing( 2 ); 156 layout->setSpacing( 2 );
157 layout->setMargin( 4 ); 157 layout->setMargin( 4 );
158 158
159 destinations = new QListBox( container ); 159 destinations = new QListBox( container );
160 destinations->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) ); 160 destinations->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) );
161 connect( destinations, SIGNAL( highlighted( int ) ), this, SLOT( editDestination( int ) ) ); 161 connect( destinations, SIGNAL( highlighted( int ) ), this, SLOT( editDestination( int ) ) );
162 layout->addMultiCellWidget( destinations, 0, 0, 0, 1 ); 162 layout->addMultiCellWidget( destinations, 0, 0, 0, 1 );
163 163
164 QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), container ); 164 QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), container );
165 connect( btn, SIGNAL( clicked() ), this, SLOT( newDestination() ) ); 165 connect( btn, SIGNAL( clicked() ), this, SLOT( newDestination() ) );
166 layout->addWidget( btn, 1, 0 ); 166 layout->addWidget( btn, 1, 0 );
167 167
168 btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), container ); 168 btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), container );
169 connect( btn, SIGNAL( clicked() ), this, SLOT( removeDestination() ) ); 169 connect( btn, SIGNAL( clicked() ), this, SLOT( removeDestination() ) );
170 layout->addWidget( btn, 1, 1 ); 170 layout->addWidget( btn, 1, 1 );
171 171
172 QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "Destination" ), container ); 172 QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "Destination" ), container );
173 grpbox->layout()->setSpacing( 2 ); 173 grpbox->layout()->setSpacing( 2 );
174 grpbox->layout()->setMargin( 4 ); 174 grpbox->layout()->setMargin( 4 );
175 layout->addMultiCellWidget( grpbox, 2, 2, 0, 1 ); 175 layout->addMultiCellWidget( grpbox, 2, 2, 0, 1 );
176 176
177 QGridLayout *grplayout = new QGridLayout( grpbox->layout() ); 177 QGridLayout *grplayout = new QGridLayout( grpbox->layout() );
178 178
179 QLabel *label = new QLabel( tr( "Name:" ), grpbox ); 179 QLabel *label = new QLabel( tr( "Name:" ), grpbox );
180 grplayout->addWidget( label, 0, 0 ); 180 grplayout->addWidget( label, 0, 0 );
181 destinationname = new QLineEdit( grpbox ); 181 destinationname = new QLineEdit( grpbox );
182 grplayout->addWidget( destinationname, 0, 1 ); 182 grplayout->addWidget( destinationname, 0, 1 );
183 183
184 label = new QLabel( tr( "Location:" ), grpbox ); 184 label = new QLabel( tr( "Location:" ), grpbox );
185 grplayout->addWidget( label, 1, 0 ); 185 grplayout->addWidget( label, 1, 0 );
186 destinationurl = new QLineEdit( grpbox ); 186 destinationurl = new QLineEdit( grpbox );
187 grplayout->addWidget( destinationurl, 1, 1 ); 187 grplayout->addWidget( destinationurl, 1, 1 );
188 188
189 linkToRoot = new QCheckBox( tr( "Link to root" ), grpbox ); 189 linkToRoot = new QCheckBox( tr( "Link to root" ), grpbox );
190 grplayout->addMultiCellWidget( linkToRoot, 2, 2, 0, 1 ); 190 grplayout->addMultiCellWidget( linkToRoot, 2, 2, 0, 1 );
191 191
192 btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Update" ), grpbox ); 192 btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Update" ), grpbox );
193 connect( btn, SIGNAL( clicked() ), this, SLOT( changeDestinationDetails() ) ); 193 connect( btn, SIGNAL( clicked() ), this, SLOT( changeDestinationDetails() ) );
194 grplayout->addMultiCellWidget( btn, 3, 3, 0, 1 ); 194 grplayout->addMultiCellWidget( btn, 3, 3, 0, 1 );
195 195
196 return control; 196 return control;
197} 197}
198 198
199QWidget *SettingsImpl :: initProxyTab() 199QWidget *SettingsImpl :: initProxyTab()
200{ 200{
201 QWidget *control = new QWidget( this ); 201 QWidget *control = new QWidget( this );
202 202
203 QVBoxLayout *vb = new QVBoxLayout( control ); 203 QVBoxLayout *vb = new QVBoxLayout( control );
204 204
205 QScrollView *sv = new QScrollView( control ); 205 QScrollView *sv = new QScrollView( control );
206 vb->addWidget( sv, 0, 0 ); 206 vb->addWidget( sv, 0, 0 );
207 sv->setResizePolicy( QScrollView::AutoOneFit ); 207 sv->setResizePolicy( QScrollView::AutoOneFit );
208 sv->setFrameStyle( QFrame::NoFrame ); 208 sv->setFrameStyle( QFrame::NoFrame );
209 209
210 QWidget *container = new QWidget( sv->viewport() ); 210 QWidget *container = new QWidget( sv->viewport() );
211 sv->addChild( container ); 211 sv->addChild( container );
212 212
213 QGridLayout *layout = new QGridLayout( container ); 213 QGridLayout *layout = new QGridLayout( container );
214 layout->setSpacing( 2 ); 214 layout->setSpacing( 2 );
215 layout->setMargin( 4 ); 215 layout->setMargin( 4 );
216 216
217 QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "HTTP Proxy" ), container ); 217 QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "HTTP Proxy" ), container );
218 grpbox->layout()->setSpacing( 2 ); 218 grpbox->layout()->setSpacing( 2 );
219 grpbox->layout()->setMargin( 4 ); 219 grpbox->layout()->setMargin( 4 );
220 layout->addMultiCellWidget( grpbox, 0, 0, 0, 1 ); 220 layout->addMultiCellWidget( grpbox, 0, 0, 0, 1 );
221 QVBoxLayout *grplayout = new QVBoxLayout( grpbox->layout() ); 221 QVBoxLayout *grplayout = new QVBoxLayout( grpbox->layout() );
222 txtHttpProxy = new QLineEdit( grpbox ); 222 txtHttpProxy = new QLineEdit( grpbox );
223 grplayout->addWidget( txtHttpProxy ); 223 grplayout->addWidget( txtHttpProxy );
224 chkHttpProxyEnabled = new QCheckBox( tr( "Enabled" ), grpbox ); 224 chkHttpProxyEnabled = new QCheckBox( tr( "Enabled" ), grpbox );
225 grplayout->addWidget( chkHttpProxyEnabled ); 225 grplayout->addWidget( chkHttpProxyEnabled );
226 226
227 grpbox = new QGroupBox( 0, Qt::Vertical, tr( "FTP Proxy" ), container ); 227 grpbox = new QGroupBox( 0, Qt::Vertical, tr( "FTP Proxy" ), container );
228 grpbox->layout()->setSpacing( 2 ); 228 grpbox->layout()->setSpacing( 2 );
229 grpbox->layout()->setMargin( 4 ); 229 grpbox->layout()->setMargin( 4 );
230 layout->addMultiCellWidget( grpbox, 1, 1, 0, 1 ); 230 layout->addMultiCellWidget( grpbox, 1, 1, 0, 1 );
231 grplayout = new QVBoxLayout( grpbox->layout() ); 231 grplayout = new QVBoxLayout( grpbox->layout() );
232 txtFtpProxy = new QLineEdit( grpbox ); 232 txtFtpProxy = new QLineEdit( grpbox );
233 grplayout->addWidget( txtFtpProxy ); 233 grplayout->addWidget( txtFtpProxy );
234 chkFtpProxyEnabled = new QCheckBox( tr( "Enabled" ), grpbox ); 234 chkFtpProxyEnabled = new QCheckBox( tr( "Enabled" ), grpbox );
235 grplayout->addWidget( chkFtpProxyEnabled ); 235 grplayout->addWidget( chkFtpProxyEnabled );
236 236
237 QLabel *label = new QLabel( tr( "Username:" ), container ); 237 QLabel *label = new QLabel( tr( "Username:" ), container );
238 layout->addWidget( label, 2, 0 ); 238 layout->addWidget( label, 2, 0 );
239 txtUsername = new QLineEdit( container ); 239 txtUsername = new QLineEdit( container );
240 layout->addWidget( txtUsername, 2, 1 ); 240 layout->addWidget( txtUsername, 2, 1 );
241 241
242 label = new QLabel( tr( "Password:" ), container ); 242 label = new QLabel( tr( "Password:" ), container );
243 layout->addWidget( label, 3, 0 ); 243 layout->addWidget( label, 3, 0 );
244 txtPassword = new QLineEdit( container ); 244 txtPassword = new QLineEdit( container );
245 layout->addWidget( txtPassword, 3, 1 ); 245 layout->addWidget( txtPassword, 3, 1 );
246 246
247 QPushButton *btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Update" ), container ); 247 QPushButton *btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Update" ), container );
248 connect( btn, SIGNAL( clicked() ), this, SLOT( proxyApplyChanges() ) ); 248 connect( btn, SIGNAL( clicked() ), this, SLOT( proxyApplyChanges() ) );
249 layout->addMultiCellWidget( btn, 4, 4, 0, 1 ); 249 layout->addMultiCellWidget( btn, 4, 4, 0, 1 );
250 250
251 return control; 251 return control;
252} 252}
253 253
254void SettingsImpl :: setupData() 254void SettingsImpl :: setupData()
255{ 255{
256 // add servers 256 // add servers
257 QString serverName; 257 QString serverName;
258 QListIterator<Server> it( dataMgr->getServerList() ); 258 QListIterator<Server> it( dataMgr->getServerList() );
259 for ( ; it.current(); ++it ) 259 for ( ; it.current(); ++it )
260 { 260 {
261 serverName = it.current()->getServerName(); 261 serverName = it.current()->getServerName();
262 if ( serverName == LOCAL_SERVER || serverName == LOCAL_IPKGS ) 262 if ( serverName == LOCAL_SERVER || serverName == LOCAL_IPKGS )
263 continue; 263 continue;
264 264
265 servers->insertItem( serverName ); 265 servers->insertItem( serverName );
266 } 266 }
267 267
268 268
269 // add destinations 269 // add destinations
270 QListIterator<Destination> it2( dataMgr->getDestinationList() ); 270 QListIterator<Destination> it2( dataMgr->getDestinationList() );
271 for ( ; it2.current(); ++it2 ) 271 for ( ; it2.current(); ++it2 )
272 destinations->insertItem( it2.current()->getDestinationName() ); 272 destinations->insertItem( it2.current()->getDestinationName() );
273 273
274 // setup proxy tab 274 // setup proxy tab
275 txtHttpProxy->setText( dataMgr->getHttpProxy() ); 275 txtHttpProxy->setText( dataMgr->getHttpProxy() );
276 txtFtpProxy->setText( dataMgr->getFtpProxy() ); 276 txtFtpProxy->setText( dataMgr->getFtpProxy() );
277 txtUsername->setText( dataMgr->getProxyUsername() ); 277 txtUsername->setText( dataMgr->getProxyUsername() );
278 txtPassword->setText( dataMgr->getProxyPassword() ); 278 txtPassword->setText( dataMgr->getProxyPassword() );
279 chkHttpProxyEnabled->setChecked( dataMgr->getHttpProxyEnabled() ); 279 chkHttpProxyEnabled->setChecked( dataMgr->getHttpProxyEnabled() );
280 chkFtpProxyEnabled->setChecked( dataMgr->getFtpProxyEnabled() ); 280 chkFtpProxyEnabled->setChecked( dataMgr->getFtpProxyEnabled() );
281} 281}
282 282
283//------------------ Servers tab ---------------------- 283//------------------ Servers tab ----------------------
284 284
285void SettingsImpl :: editServer( int sel ) 285void SettingsImpl :: editServer( int sel )
286{ 286{
287 currentSelectedServer = sel; 287 currentSelectedServer = sel;
288 Server *s = dataMgr->getServer( servers->currentText() ); 288 Server *s = dataMgr->getServer( servers->currentText() );
289 serverName = s->getServerName(); 289 if ( s )
290 servername->setText( s->getServerName() ); 290 {
291 serverurl->setText( s->getServerUrl() ); 291 serverName = s->getServerName();
292 active->setChecked( s->isServerActive() ); 292 servername->setText( s->getServerName() );
293 serverurl->setText( s->getServerUrl() );
294 active->setChecked( s->isServerActive() );
295 }
296 else
297 {
298 serverName = "";
299 servername->setText( "" );
300 serverurl->setText( "" );
301 active->setChecked( false );
302 }
293} 303}
294 304
295void SettingsImpl :: newServer() 305void SettingsImpl :: newServer()
296{ 306{
297 newserver = true; 307 newserver = true;
298 servername->setText( "" ); 308 servername->setText( "" );
299 serverurl->setText( "" ); 309 serverurl->setText( "" );
300 servername->setFocus(); 310 servername->setFocus();
301 active->setChecked( true ); 311 active->setChecked( true );
302} 312}
303 313
304void SettingsImpl :: removeServer() 314void SettingsImpl :: removeServer()
305{ 315{
306 changed = true; 316 changed = true;
307 Server *s = dataMgr->getServer( servers->currentText() ); 317 Server *s = dataMgr->getServer( servers->currentText() );
308 dataMgr->getServerList().removeRef( s ); 318 if ( s )
309 servers->removeItem( currentSelectedServer ); 319 {
320 dataMgr->getServerList().removeRef( s );
321 servers->removeItem( currentSelectedServer );
322 }
310} 323}
311 324
312void SettingsImpl :: changeServerDetails() 325void SettingsImpl :: changeServerDetails()
313{ 326{
314 changed = true; 327 changed = true;
315 328
316 QString newName = servername->text(); 329 QString newName = servername->text();
317 330
318 // Convert any spaces to underscores 331 // Convert any spaces to underscores
319 char *tmpStr = new char[newName.length() + 1]; 332 char *tmpStr = new char[newName.length() + 1];
320 for ( unsigned int i = 0 ; i < newName.length() ; ++i ) 333 for ( unsigned int i = 0 ; i < newName.length() ; ++i )
321 { 334 {
322 if ( newName[i] == ' ' ) 335 if ( newName[i] == ' ' )
323 tmpStr[i] = '_'; 336 tmpStr[i] = '_';
324 else 337 else
325 tmpStr[i] = newName[i].latin1(); 338 tmpStr[i] = newName[i].latin1();
326 } 339 }
327 tmpStr[newName.length()] = '\0'; 340 tmpStr[newName.length()] = '\0';
328 341
329 newName = tmpStr; 342 newName = tmpStr;
330 delete tmpStr; 343 delete tmpStr;
331 344
332 if ( !newserver ) 345 if ( !newserver )
333 { 346 {
334 Server *s = dataMgr->getServer( servers->currentText() ); 347 Server *s = dataMgr->getServer( servers->currentText() );
335 348 if ( s )
336 // Update url
337 s->setServerUrl( serverurl->text() );
338 s->setActive( active->isChecked() );
339
340
341 // Check if server name has changed, if it has then we need to replace the key in the map
342 if ( serverName != newName )
343 { 349 {
344 // Update server name 350 // Update url
345 s->setServerName( newName ); 351 s->setServerUrl( serverurl->text() );
346 } 352 s->setActive( active->isChecked() );
353
354 // Check if server name has changed, if it has then we need to replace the key in the map
355 if ( serverName != newName )
356 {
357 // Update server name
358 s->setServerName( newName );
359 }
347 360
348 // Update list box 361 // Update list box
349 servers->changeItem( newName, currentSelectedServer ); 362 servers->changeItem( newName, currentSelectedServer );
363 }
350 } 364 }
351 else 365 else
352 { 366 {
353 Server s( newName, serverurl->text() ); 367 Server s( newName, serverurl->text() );
354 dataMgr->getServerList().append( new Server( newName, serverurl->text() ) ); 368 dataMgr->getServerList().append( new Server( newName, serverurl->text() ) );
355 dataMgr->getServerList().last()->setActive( active->isChecked() ); 369 dataMgr->getServerList().last()->setActive( active->isChecked() );
356 servers->insertItem( newName ); 370 servers->insertItem( newName );
357 servers->setCurrentItem( servers->count() ); 371 servers->setCurrentItem( servers->count() );
358 newserver = false; 372 newserver = false;
359 } 373 }
360} 374}
361 375
362//------------------ Destinations tab ---------------------- 376//------------------ Destinations tab ----------------------
363 377
364void SettingsImpl :: editDestination( int sel ) 378void SettingsImpl :: editDestination( int sel )
365{ 379{
366 currentSelectedDestination = sel; 380 currentSelectedDestination = sel;
367 Destination *d = dataMgr->getDestination( destinations->currentText() ); 381 Destination *d = dataMgr->getDestination( destinations->currentText() );
368 destinationName = d->getDestinationName(); 382 if ( d )
369 destinationname->setText( d->getDestinationName() ); 383 {
370 destinationurl->setText( d->getDestinationPath() ); 384 destinationName = d->getDestinationName();
371 linkToRoot->setChecked( d->linkToRoot() ); 385 destinationname->setText( d->getDestinationName() );
386 destinationurl->setText( d->getDestinationPath() );
387 linkToRoot->setChecked( d->linkToRoot() );
388 }
389 else
390 {
391 destinationName = "";
392 destinationname->setText( "" );
393 destinationurl->setText( "" );
394 linkToRoot->setChecked( false );
395 }
372} 396}
373 397
374void SettingsImpl :: newDestination() 398void SettingsImpl :: newDestination()
375{ 399{
376 newdestination = true; 400 newdestination = true;
377 destinationname->setText( "" ); 401 destinationname->setText( "" );
378 destinationurl->setText( "" ); 402 destinationurl->setText( "" );
379 destinationname->setFocus(); 403 destinationname->setFocus();
380 linkToRoot->setChecked( true ); 404 linkToRoot->setChecked( true );
381} 405}
382 406
383void SettingsImpl :: removeDestination() 407void SettingsImpl :: removeDestination()
384{ 408{
385 changed = true; 409 changed = true;
386 Destination *d = dataMgr->getDestination( destinations->currentText() ); 410 Destination *d = dataMgr->getDestination( destinations->currentText() );
387 dataMgr->getDestinationList().removeRef( d ); 411 if ( d )
388 destinations->removeItem( currentSelectedDestination ); 412 {
413 dataMgr->getDestinationList().removeRef( d );
414 destinations->removeItem( currentSelectedDestination );
415 }
389} 416}
390 417
391void SettingsImpl :: changeDestinationDetails() 418void SettingsImpl :: changeDestinationDetails()
392{ 419{
393 changed = true; 420 changed = true;
394 421
395#ifdef QWS 422#ifdef QWS
396 Config cfg( "aqpkg" ); 423 Config cfg( "aqpkg" );
397 cfg.setGroup( "destinations" ); 424 cfg.setGroup( "destinations" );
398#endif 425#endif
399 426
400 QString newName = destinationname->text(); 427 QString newName = destinationname->text();
401 if ( !newdestination ) 428 if ( !newdestination )
402 { 429 {
403 Destination *d = dataMgr->getDestination( destinations->currentText() ); 430 Destination *d = dataMgr->getDestination( destinations->currentText() );
431 if ( d )
432 {
433 // Update url
434 d->setDestinationPath( destinationurl->text() );
435 d->linkToRoot( linkToRoot->isChecked() );
404 436
405 // Update url 437 // Check if server name has changed, if it has then we need to replace the key in the map
406 d->setDestinationPath( destinationurl->text() ); 438 if ( destinationName != newName )
407 d->linkToRoot( linkToRoot->isChecked() ); 439 {
440 // Update server name
441 d->setDestinationName( newName );
408 442
409 // Check if server name has changed, if it has then we need to replace the key in the map 443 // Update list box
410 if ( destinationName != newName ) 444 destinations->changeItem( newName, currentSelectedDestination );
411 { 445 }
412 // Update server name
413 d->setDestinationName( newName );
414 446
415 // Update list box
416 destinations->changeItem( newName, currentSelectedDestination );
417 }
418#ifdef QWS 447#ifdef QWS
419 QString key = newName; 448 QString key = newName;
420 key += "_linkToRoot"; 449 key += "_linkToRoot";
421 int val = d->linkToRoot(); 450 int val = d->linkToRoot();
422 cfg.writeEntry( key, val ); 451 cfg.writeEntry( key, val );
423#endif 452#endif
453 }
424 } 454 }
425 else 455 else
426 { 456 {
427 dataMgr->getDestinationList().append( new Destination( newName, destinationurl->text() ) ); 457 dataMgr->getDestinationList().append( new Destination( newName, destinationurl->text() ) );
428 destinations->insertItem( newName ); 458 destinations->insertItem( newName );
429 destinations->setCurrentItem( destinations->count() ); 459 destinations->setCurrentItem( destinations->count() );
430 newdestination = false; 460 newdestination = false;
431 461
432#ifdef QWS 462#ifdef QWS
433 QString key = newName; 463 QString key = newName;
434 key += "_linkToRoot"; 464 key += "_linkToRoot";
435 cfg.writeEntry( key, true ); 465 cfg.writeEntry( key, true );
436#endif 466#endif
437 } 467 }
438} 468}
439 469
440//------------------ Proxy tab ---------------------- 470//------------------ Proxy tab ----------------------
441void SettingsImpl :: proxyApplyChanges() 471void SettingsImpl :: proxyApplyChanges()
442{ 472{
443 changed = true; 473 changed = true;
444 dataMgr->setHttpProxy( txtHttpProxy->text() ); 474 dataMgr->setHttpProxy( txtHttpProxy->text() );
445 dataMgr->setFtpProxy( txtFtpProxy->text() ); 475 dataMgr->setFtpProxy( txtFtpProxy->text() );
446 dataMgr->setProxyUsername( txtUsername->text() ); 476 dataMgr->setProxyUsername( txtUsername->text() );
447 dataMgr->setProxyPassword( txtPassword->text() ); 477 dataMgr->setProxyPassword( txtPassword->text() );
448 478
449 dataMgr->setHttpProxyEnabled( chkHttpProxyEnabled->isChecked() ); 479 dataMgr->setHttpProxyEnabled( chkHttpProxyEnabled->isChecked() );
450 dataMgr->setFtpProxyEnabled( chkFtpProxyEnabled->isChecked() ); 480 dataMgr->setFtpProxyEnabled( chkFtpProxyEnabled->isChecked() );
451} 481}