author | zautrix <zautrix> | 2004-09-16 20:39:34 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-09-16 20:39:34 (UTC) |
commit | b44edfb21be0eee91c4f47401e3fe6ff37e4c16c (patch) (unidiff) | |
tree | a17655e0e679f67498d9fee6f6a532e9c0f0e9e5 /kmicromail/editaccounts.cpp | |
parent | b6bfa63deb15a2600d46a8c68c231f068da1444a (diff) | |
download | kdepimpi-b44edfb21be0eee91c4f47401e3fe6ff37e4c16c.zip kdepimpi-b44edfb21be0eee91c4f47401e3fe6ff37e4c16c.tar.gz kdepimpi-b44edfb21be0eee91c4f47401e3fe6ff37e4c16c.tar.bz2 |
better newsgroup handling
-rw-r--r-- | kmicromail/editaccounts.cpp | 70 |
1 files changed, 55 insertions, 15 deletions
diff --git a/kmicromail/editaccounts.cpp b/kmicromail/editaccounts.cpp index d43d23b..733e38a 100644 --- a/kmicromail/editaccounts.cpp +++ b/kmicromail/editaccounts.cpp | |||
@@ -157,465 +157,505 @@ void EditAccounts::slotNewAccount( const QString &type ) | |||
157 | settings->addAccount( account ); | 157 | settings->addAccount( account ); |
158 | account->save(); | 158 | account->save(); |
159 | slotFillLists(); | 159 | slotFillLists(); |
160 | } | 160 | } |
161 | else | 161 | else |
162 | { | 162 | { |
163 | account->remove(); | 163 | account->remove(); |
164 | } | 164 | } |
165 | } | 165 | } |
166 | } | 166 | } |
167 | 167 | ||
168 | void EditAccounts::slotEditAccount( Account *account ) | 168 | void EditAccounts::slotEditAccount( Account *account ) |
169 | { | 169 | { |
170 | if ( account->getType() == MAILLIB::A_IMAP ) | 170 | if ( account->getType() == MAILLIB::A_IMAP ) |
171 | { | 171 | { |
172 | IMAPaccount *imapAcc = static_cast<IMAPaccount *>(account); | 172 | IMAPaccount *imapAcc = static_cast<IMAPaccount *>(account); |
173 | IMAPconfig imap( imapAcc, this, 0, true, WStyle_ContextHelp ); | 173 | IMAPconfig imap( imapAcc, this, 0, true, WStyle_ContextHelp ); |
174 | if ( QDialog::Accepted == KApplication::execDialog( &imap ) ) | 174 | if ( QDialog::Accepted == KApplication::execDialog( &imap ) ) |
175 | { | 175 | { |
176 | slotFillLists(); | 176 | slotFillLists(); |
177 | } | 177 | } |
178 | } | 178 | } |
179 | else if ( account->getType()==MAILLIB::A_POP3 ) | 179 | else if ( account->getType()==MAILLIB::A_POP3 ) |
180 | { | 180 | { |
181 | POP3account *pop3Acc = static_cast<POP3account *>(account); | 181 | POP3account *pop3Acc = static_cast<POP3account *>(account); |
182 | POP3config pop3( pop3Acc, this, 0, true, WStyle_ContextHelp ); | 182 | POP3config pop3( pop3Acc, this, 0, true, WStyle_ContextHelp ); |
183 | if ( QDialog::Accepted == KApplication::execDialog( &pop3 ) ) | 183 | if ( QDialog::Accepted == KApplication::execDialog( &pop3 ) ) |
184 | { | 184 | { |
185 | slotFillLists(); | 185 | slotFillLists(); |
186 | } | 186 | } |
187 | } | 187 | } |
188 | else if ( account->getType()==MAILLIB::A_SMTP ) | 188 | else if ( account->getType()==MAILLIB::A_SMTP ) |
189 | { | 189 | { |
190 | SMTPaccount *smtpAcc = static_cast<SMTPaccount *>(account); | 190 | SMTPaccount *smtpAcc = static_cast<SMTPaccount *>(account); |
191 | SMTPconfig smtp( smtpAcc, this, 0, true, WStyle_ContextHelp ); | 191 | SMTPconfig smtp( smtpAcc, this, 0, true, WStyle_ContextHelp ); |
192 | if ( QDialog::Accepted == KApplication::execDialog( &smtp ) ) | 192 | if ( QDialog::Accepted == KApplication::execDialog( &smtp ) ) |
193 | { | 193 | { |
194 | slotFillLists(); | 194 | slotFillLists(); |
195 | } | 195 | } |
196 | } | 196 | } |
197 | else if ( account->getType()==MAILLIB::A_NNTP) | 197 | else if ( account->getType()==MAILLIB::A_NNTP) |
198 | { | 198 | { |
199 | NNTPaccount *nntpAcc = static_cast<NNTPaccount *>(account); | 199 | NNTPaccount *nntpAcc = static_cast<NNTPaccount *>(account); |
200 | NNTPconfig nntp( nntpAcc, this, 0, true, WStyle_ContextHelp ); | 200 | NNTPconfig nntp( nntpAcc, this, 0, true, WStyle_ContextHelp ); |
201 | if ( QDialog::Accepted == KApplication::execDialog( &nntp ) ) | 201 | if ( QDialog::Accepted == KApplication::execDialog( &nntp ) ) |
202 | { | 202 | { |
203 | slotFillLists(); | 203 | slotFillLists(); |
204 | } | 204 | } |
205 | } | 205 | } |
206 | } | 206 | } |
207 | 207 | ||
208 | void EditAccounts::slotDeleteAccount( Account *account ) | 208 | void EditAccounts::slotDeleteAccount( Account *account ) |
209 | { | 209 | { |
210 | if ( QMessageBox::information( this, tr( "Question" ), | 210 | if ( QMessageBox::information( this, tr( "Question" ), |
211 | tr( "<p>Do you really want to delete the selected Account?</p>" ), | 211 | tr( "<p>Do you really want to delete the selected Account?</p>" ), |
212 | tr( "Yes" ), tr( "No" ) ) == 0 ) | 212 | tr( "Yes" ), tr( "No" ) ) == 0 ) |
213 | { | 213 | { |
214 | settings->delAccount( account ); | 214 | settings->delAccount( account ); |
215 | slotFillLists(); | 215 | slotFillLists(); |
216 | } | 216 | } |
217 | } | 217 | } |
218 | 218 | ||
219 | void EditAccounts::slotEditMail() | 219 | void EditAccounts::slotEditMail() |
220 | { | 220 | { |
221 | if ( !mailList->currentItem() ) | 221 | if ( !mailList->currentItem() ) |
222 | { | 222 | { |
223 | QMessageBox::information( this, tr( "Error" ), | 223 | QMessageBox::information( this, tr( "Error" ), |
224 | tr( "<p>Please select an account.</p>" ), | 224 | tr( "<p>Please select an account.</p>" ), |
225 | tr( "Ok" ) ); | 225 | tr( "Ok" ) ); |
226 | return; | 226 | return; |
227 | } | 227 | } |
228 | 228 | ||
229 | Account *a = ((AccountListItem *) mailList->currentItem())->getAccount(); | 229 | Account *a = ((AccountListItem *) mailList->currentItem())->getAccount(); |
230 | slotEditAccount( a ); | 230 | slotEditAccount( a ); |
231 | } | 231 | } |
232 | 232 | ||
233 | void EditAccounts::slotDeleteMail() | 233 | void EditAccounts::slotDeleteMail() |
234 | { | 234 | { |
235 | if ( !mailList->currentItem() ) | 235 | if ( !mailList->currentItem() ) |
236 | { | 236 | { |
237 | QMessageBox::information( this, tr( "Error" ), | 237 | QMessageBox::information( this, tr( "Error" ), |
238 | tr( "<p>Please select an account.</p>" ), | 238 | tr( "<p>Please select an account.</p>" ), |
239 | tr( "Ok" ) ); | 239 | tr( "Ok" ) ); |
240 | return; | 240 | return; |
241 | } | 241 | } |
242 | 242 | ||
243 | Account *a = ((AccountListItem *) mailList->currentItem())->getAccount(); | 243 | Account *a = ((AccountListItem *) mailList->currentItem())->getAccount(); |
244 | slotDeleteAccount( a ); | 244 | slotDeleteAccount( a ); |
245 | } | 245 | } |
246 | 246 | ||
247 | void EditAccounts::slotNewNews() | 247 | void EditAccounts::slotNewNews() |
248 | { | 248 | { |
249 | slotNewAccount( "NNTP" ); | 249 | slotNewAccount( "NNTP" ); |
250 | } | 250 | } |
251 | 251 | ||
252 | void EditAccounts::slotEditNews() | 252 | void EditAccounts::slotEditNews() |
253 | { | 253 | { |
254 | if ( !newsList->currentItem() ) | 254 | if ( !newsList->currentItem() ) |
255 | { | 255 | { |
256 | QMessageBox::information( this, tr( "Error" ), | 256 | QMessageBox::information( this, tr( "Error" ), |
257 | tr( "<p>Please select an account.</p>" ), | 257 | tr( "<p>Please select an account.</p>" ), |
258 | tr( "Ok" ) ); | 258 | tr( "Ok" ) ); |
259 | return; | 259 | return; |
260 | } | 260 | } |
261 | 261 | ||
262 | Account *a = ((AccountListItem *) newsList->currentItem())->getAccount(); | 262 | Account *a = ((AccountListItem *) newsList->currentItem())->getAccount(); |
263 | slotEditAccount( a ); | 263 | slotEditAccount( a ); |
264 | } | 264 | } |
265 | 265 | ||
266 | void EditAccounts::slotDeleteNews() | 266 | void EditAccounts::slotDeleteNews() |
267 | { | 267 | { |
268 | if ( !newsList->currentItem() ) | 268 | if ( !newsList->currentItem() ) |
269 | { | 269 | { |
270 | QMessageBox::information( this, tr( "Error" ), | 270 | QMessageBox::information( this, tr( "Error" ), |
271 | tr( "<p>Please select an account.</p>" ), | 271 | tr( "<p>Please select an account.</p>" ), |
272 | tr( "Ok" ) ); | 272 | tr( "Ok" ) ); |
273 | return; | 273 | return; |
274 | } | 274 | } |
275 | 275 | ||
276 | Account *a = ((AccountListItem *) newsList->currentItem())->getAccount(); | 276 | Account *a = ((AccountListItem *) newsList->currentItem())->getAccount(); |
277 | slotDeleteAccount( a ); | 277 | slotDeleteAccount( a ); |
278 | } | 278 | } |
279 | 279 | ||
280 | void EditAccounts::slotAdjustColumns() | 280 | void EditAccounts::slotAdjustColumns() |
281 | { | 281 | { |
282 | int currPage = configTab->currentPageIndex(); | 282 | int currPage = configTab->currentPageIndex(); |
283 | 283 | ||
284 | configTab->showPage( mailTab ); | 284 | configTab->showPage( mailTab ); |
285 | mailList->setColumnWidth( 0, mailList->visibleWidth() - 50 ); | 285 | mailList->setColumnWidth( 0, mailList->visibleWidth() - 50 ); |
286 | mailList->setColumnWidth( 1, 50 ); | 286 | mailList->setColumnWidth( 1, 50 ); |
287 | 287 | ||
288 | configTab->showPage( newsTab ); | 288 | configTab->showPage( newsTab ); |
289 | newsList->setColumnWidth( 0, newsList->visibleWidth() ); | 289 | newsList->setColumnWidth( 0, newsList->visibleWidth() ); |
290 | 290 | ||
291 | configTab->setCurrentPage( currPage ); | 291 | configTab->setCurrentPage( currPage ); |
292 | } | 292 | } |
293 | 293 | ||
294 | void EditAccounts::accept() | 294 | void EditAccounts::accept() |
295 | { | 295 | { |
296 | settings->saveAccounts(); | 296 | settings->saveAccounts(); |
297 | 297 | ||
298 | QDialog::accept(); | 298 | QDialog::accept(); |
299 | } | 299 | } |
300 | 300 | ||
301 | /** | 301 | /** |
302 | * SelectMailType | 302 | * SelectMailType |
303 | */ | 303 | */ |
304 | 304 | ||
305 | SelectMailType::SelectMailType( QString *selection, QWidget *parent, const char *name, bool modal, WFlags flags ) | 305 | SelectMailType::SelectMailType( QString *selection, QWidget *parent, const char *name, bool modal, WFlags flags ) |
306 | : SelectMailTypeUI( parent, name, modal, flags ) | 306 | : SelectMailTypeUI( parent, name, modal, flags ) |
307 | { | 307 | { |
308 | selected = selection; | 308 | selected = selection; |
309 | selected->replace( 0, selected->length(), typeBox->currentText() ); | 309 | selected->replace( 0, selected->length(), typeBox->currentText() ); |
310 | connect( typeBox, SIGNAL( activated(const QString&) ), SLOT( slotSelection(const QString&) ) ); | 310 | connect( typeBox, SIGNAL( activated(const QString&) ), SLOT( slotSelection(const QString&) ) ); |
311 | } | 311 | } |
312 | 312 | ||
313 | void SelectMailType::slotSelection( const QString &sel ) | 313 | void SelectMailType::slotSelection( const QString &sel ) |
314 | { | 314 | { |
315 | selected->replace( 0, selected->length(), sel ); | 315 | selected->replace( 0, selected->length(), sel ); |
316 | } | 316 | } |
317 | 317 | ||
318 | /** | 318 | /** |
319 | * IMAPconfig | 319 | * IMAPconfig |
320 | */ | 320 | */ |
321 | 321 | ||
322 | IMAPconfig::IMAPconfig( IMAPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags ) | 322 | IMAPconfig::IMAPconfig( IMAPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags ) |
323 | : IMAPconfigUI( parent, name, modal, flags ) | 323 | : IMAPconfigUI( parent, name, modal, flags ) |
324 | { | 324 | { |
325 | data = account; | 325 | data = account; |
326 | 326 | ||
327 | fillValues(); | 327 | fillValues(); |
328 | 328 | ||
329 | connect( ComboBox1, SIGNAL( activated(int) ), SLOT( slotConnectionToggle(int) ) ); | 329 | connect( ComboBox1, SIGNAL( activated(int) ), SLOT( slotConnectionToggle(int) ) ); |
330 | ComboBox1->insertItem( "Only if available", 0 ); | 330 | ComboBox1->insertItem( "Only if available", 0 ); |
331 | ComboBox1->insertItem( "Always, Negotiated", 1 ); | 331 | ComboBox1->insertItem( "Always, Negotiated", 1 ); |
332 | ComboBox1->insertItem( "Connect on secure port", 2 ); | 332 | ComboBox1->insertItem( "Connect on secure port", 2 ); |
333 | ComboBox1->insertItem( "Run command instead", 3 ); | 333 | ComboBox1->insertItem( "Run command instead", 3 ); |
334 | CommandEdit->hide(); | 334 | CommandEdit->hide(); |
335 | ComboBox1->setCurrentItem( data->ConnectionType() ); | 335 | ComboBox1->setCurrentItem( data->ConnectionType() ); |
336 | } | 336 | } |
337 | 337 | ||
338 | void IMAPconfig::slotConnectionToggle( int index ) | 338 | void IMAPconfig::slotConnectionToggle( int index ) |
339 | { | 339 | { |
340 | if ( index == 2 ) | 340 | if ( index == 2 ) |
341 | { | 341 | { |
342 | portLine->setText( IMAP_SSL_PORT ); | 342 | portLine->setText( IMAP_SSL_PORT ); |
343 | } | 343 | } |
344 | else if ( index == 3 ) | 344 | else if ( index == 3 ) |
345 | { | 345 | { |
346 | portLine->setText( IMAP_PORT ); | 346 | portLine->setText( IMAP_PORT ); |
347 | CommandEdit->show(); | 347 | CommandEdit->show(); |
348 | } | 348 | } |
349 | else | 349 | else |
350 | { | 350 | { |
351 | portLine->setText( IMAP_PORT ); | 351 | portLine->setText( IMAP_PORT ); |
352 | } | 352 | } |
353 | } | 353 | } |
354 | 354 | ||
355 | void IMAPconfig::fillValues() | 355 | void IMAPconfig::fillValues() |
356 | { | 356 | { |
357 | accountLine->setText( data->getAccountName() ); | 357 | accountLine->setText( data->getAccountName() ); |
358 | serverLine->setText( data->getServer() ); | 358 | serverLine->setText( data->getServer() ); |
359 | portLine->setText( data->getPort() ); | 359 | portLine->setText( data->getPort() ); |
360 | ComboBox1->setCurrentItem( data->ConnectionType() ); | 360 | ComboBox1->setCurrentItem( data->ConnectionType() ); |
361 | userLine->setText( data->getUser() ); | 361 | userLine->setText( data->getUser() ); |
362 | passLine->setText( data->getPassword() ); | 362 | passLine->setText( data->getPassword() ); |
363 | prefixLine->setText(data->getPrefix()); | 363 | prefixLine->setText(data->getPrefix()); |
364 | localFolder->setText( data->getLocalFolder() ); | 364 | localFolder->setText( data->getLocalFolder() ); |
365 | int max = data->getMaxMailSize() ; | 365 | int max = data->getMaxMailSize() ; |
366 | if ( max ) { | 366 | if ( max ) { |
367 | CheckBoxDown->setChecked( true ); | 367 | CheckBoxDown->setChecked( true ); |
368 | SpinBoxDown->setValue ( max ); | 368 | SpinBoxDown->setValue ( max ); |
369 | } else { | 369 | } else { |
370 | CheckBoxDown->setChecked( false ); | 370 | CheckBoxDown->setChecked( false ); |
371 | SpinBoxDown->setValue ( 5 ); | 371 | SpinBoxDown->setValue ( 5 ); |
372 | } | 372 | } |
373 | CheckBoxLeaveOn->setChecked( data->getLeaveOnServer() ); | 373 | CheckBoxLeaveOn->setChecked( data->getLeaveOnServer() ); |
374 | } | 374 | } |
375 | 375 | ||
376 | void IMAPconfig::accept() | 376 | void IMAPconfig::accept() |
377 | { | 377 | { |
378 | data->setAccountName( accountLine->text() ); | 378 | data->setAccountName( accountLine->text() ); |
379 | data->setServer( serverLine->text() ); | 379 | data->setServer( serverLine->text() ); |
380 | data->setPort( portLine->text() ); | 380 | data->setPort( portLine->text() ); |
381 | data->setConnectionType( ComboBox1->currentItem() ); | 381 | data->setConnectionType( ComboBox1->currentItem() ); |
382 | data->setUser( userLine->text() ); | 382 | data->setUser( userLine->text() ); |
383 | data->setPassword( passLine->text() ); | 383 | data->setPassword( passLine->text() ); |
384 | data->setPrefix(prefixLine->text()); | 384 | data->setPrefix(prefixLine->text()); |
385 | data->setLocalFolder( localFolder->text() ); | 385 | data->setLocalFolder( localFolder->text() ); |
386 | data->setMaxMailSize( CheckBoxDown->isChecked()?SpinBoxDown->value():0 ) ; | 386 | data->setMaxMailSize( CheckBoxDown->isChecked()?SpinBoxDown->value():0 ) ; |
387 | data->setLeaveOnServer( CheckBoxLeaveOn->isChecked() ); | 387 | data->setLeaveOnServer( CheckBoxLeaveOn->isChecked() ); |
388 | 388 | ||
389 | QDialog::accept(); | 389 | QDialog::accept(); |
390 | } | 390 | } |
391 | 391 | ||
392 | /** | 392 | /** |
393 | * POP3config | 393 | * POP3config |
394 | */ | 394 | */ |
395 | 395 | ||
396 | POP3config::POP3config( POP3account *account, QWidget *parent, const char *name, bool modal, WFlags flags ) | 396 | POP3config::POP3config( POP3account *account, QWidget *parent, const char *name, bool modal, WFlags flags ) |
397 | : POP3configUI( parent, name, modal, flags ) | 397 | : POP3configUI( parent, name, modal, flags ) |
398 | { | 398 | { |
399 | data = account; | 399 | data = account; |
400 | fillValues(); | 400 | fillValues(); |
401 | 401 | ||
402 | connect( ComboBox1, SIGNAL( activated(int) ), SLOT( slotConnectionToggle(int) ) ); | 402 | connect( ComboBox1, SIGNAL( activated(int) ), SLOT( slotConnectionToggle(int) ) ); |
403 | ComboBox1->insertItem( "Only if available", 0 ); | 403 | ComboBox1->insertItem( "Only if available", 0 ); |
404 | ComboBox1->insertItem( "Always, Negotiated", 1 ); | 404 | ComboBox1->insertItem( "Always, Negotiated", 1 ); |
405 | ComboBox1->insertItem( "Connect on secure port", 2 ); | 405 | ComboBox1->insertItem( "Connect on secure port", 2 ); |
406 | ComboBox1->insertItem( "Run command instead", 3 ); | 406 | ComboBox1->insertItem( "Run command instead", 3 ); |
407 | CommandEdit->hide(); | 407 | CommandEdit->hide(); |
408 | ComboBox1->setCurrentItem( data->ConnectionType() ); | 408 | ComboBox1->setCurrentItem( data->ConnectionType() ); |
409 | } | 409 | } |
410 | 410 | ||
411 | void POP3config::slotConnectionToggle( int index ) | 411 | void POP3config::slotConnectionToggle( int index ) |
412 | { | 412 | { |
413 | // 2 is ssl connection | 413 | // 2 is ssl connection |
414 | if ( index == 2 ) | 414 | if ( index == 2 ) |
415 | { | 415 | { |
416 | portLine->setText( POP3_SSL_PORT ); | 416 | portLine->setText( POP3_SSL_PORT ); |
417 | } | 417 | } |
418 | else if ( index == 3 ) | 418 | else if ( index == 3 ) |
419 | { | 419 | { |
420 | portLine->setText( POP3_PORT ); | 420 | portLine->setText( POP3_PORT ); |
421 | CommandEdit->show(); | 421 | CommandEdit->show(); |
422 | } | 422 | } |
423 | else | 423 | else |
424 | { | 424 | { |
425 | portLine->setText( POP3_PORT ); | 425 | portLine->setText( POP3_PORT ); |
426 | } | 426 | } |
427 | } | 427 | } |
428 | 428 | ||
429 | void POP3config::fillValues() | 429 | void POP3config::fillValues() |
430 | { | 430 | { |
431 | accountLine->setText( data->getAccountName() ); | 431 | accountLine->setText( data->getAccountName() ); |
432 | serverLine->setText( data->getServer() ); | 432 | serverLine->setText( data->getServer() ); |
433 | portLine->setText( data->getPort() ); | 433 | portLine->setText( data->getPort() ); |
434 | ComboBox1->setCurrentItem( data->ConnectionType() ); | 434 | ComboBox1->setCurrentItem( data->ConnectionType() ); |
435 | userLine->setText( data->getUser() ); | 435 | userLine->setText( data->getUser() ); |
436 | passLine->setText( data->getPassword() ); | 436 | passLine->setText( data->getPassword() ); |
437 | localFolder->setText( data->getLocalFolder() ); | 437 | localFolder->setText( data->getLocalFolder() ); |
438 | int max = data->getMaxMailSize() ; | 438 | int max = data->getMaxMailSize() ; |
439 | if ( max ) { | 439 | if ( max ) { |
440 | CheckBoxDown->setChecked( true ); | 440 | CheckBoxDown->setChecked( true ); |
441 | SpinBoxDown->setValue ( max ); | 441 | SpinBoxDown->setValue ( max ); |
442 | } else { | 442 | } else { |
443 | CheckBoxDown->setChecked( false ); | 443 | CheckBoxDown->setChecked( false ); |
444 | SpinBoxDown->setValue ( 5 ); | 444 | SpinBoxDown->setValue ( 5 ); |
445 | } | 445 | } |
446 | CheckBoxLeaveOn->setChecked( data->getLeaveOnServer() ); | 446 | CheckBoxLeaveOn->setChecked( data->getLeaveOnServer() ); |
447 | } | 447 | } |
448 | 448 | ||
449 | void POP3config::accept() | 449 | void POP3config::accept() |
450 | { | 450 | { |
451 | data->setAccountName( accountLine->text() ); | 451 | data->setAccountName( accountLine->text() ); |
452 | data->setServer( serverLine->text() ); | 452 | data->setServer( serverLine->text() ); |
453 | data->setPort( portLine->text() ); | 453 | data->setPort( portLine->text() ); |
454 | data->setConnectionType( ComboBox1->currentItem() ); | 454 | data->setConnectionType( ComboBox1->currentItem() ); |
455 | data->setUser( userLine->text() ); | 455 | data->setUser( userLine->text() ); |
456 | data->setPassword( passLine->text() ); | 456 | data->setPassword( passLine->text() ); |
457 | data->setLocalFolder( localFolder->text() ); | 457 | data->setLocalFolder( localFolder->text() ); |
458 | data->setMaxMailSize( CheckBoxDown->isChecked()?SpinBoxDown->value():0 ) ; | 458 | data->setMaxMailSize( CheckBoxDown->isChecked()?SpinBoxDown->value():0 ) ; |
459 | data->setLeaveOnServer( CheckBoxLeaveOn->isChecked() ); | 459 | data->setLeaveOnServer( CheckBoxLeaveOn->isChecked() ); |
460 | 460 | ||
461 | QDialog::accept(); | 461 | QDialog::accept(); |
462 | } | 462 | } |
463 | 463 | ||
464 | /** | 464 | /** |
465 | * SMTPconfig | 465 | * SMTPconfig |
466 | */ | 466 | */ |
467 | 467 | ||
468 | SMTPconfig::SMTPconfig( SMTPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags ) | 468 | SMTPconfig::SMTPconfig( SMTPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags ) |
469 | : SMTPconfigUI( parent, name, modal, flags ) | 469 | : SMTPconfigUI( parent, name, modal, flags ) |
470 | { | 470 | { |
471 | data = account; | 471 | data = account; |
472 | 472 | ||
473 | connect( loginBox, SIGNAL( toggled(bool) ), userLine, SLOT( setEnabled(bool) ) ); | 473 | connect( loginBox, SIGNAL( toggled(bool) ), userLine, SLOT( setEnabled(bool) ) ); |
474 | connect( loginBox, SIGNAL( toggled(bool) ), passLine, SLOT( setEnabled(bool) ) ); | 474 | connect( loginBox, SIGNAL( toggled(bool) ), passLine, SLOT( setEnabled(bool) ) ); |
475 | 475 | ||
476 | fillValues(); | 476 | fillValues(); |
477 | 477 | ||
478 | connect( ComboBox1, SIGNAL( activated(int) ), SLOT( slotConnectionToggle(int) ) ); | 478 | connect( ComboBox1, SIGNAL( activated(int) ), SLOT( slotConnectionToggle(int) ) ); |
479 | ComboBox1->insertItem( "Only if available", 0 ); | 479 | ComboBox1->insertItem( "Only if available", 0 ); |
480 | ComboBox1->insertItem( "Always, Negotiated", 1 ); | 480 | ComboBox1->insertItem( "Always, Negotiated", 1 ); |
481 | ComboBox1->insertItem( "Connect on secure port", 2 ); | 481 | ComboBox1->insertItem( "Connect on secure port", 2 ); |
482 | ComboBox1->insertItem( "Run command instead", 3 ); | 482 | ComboBox1->insertItem( "Run command instead", 3 ); |
483 | CommandEdit->hide(); | 483 | CommandEdit->hide(); |
484 | ComboBox1->setCurrentItem( data->ConnectionType() ); | 484 | ComboBox1->setCurrentItem( data->ConnectionType() ); |
485 | } | 485 | } |
486 | 486 | ||
487 | void SMTPconfig::slotConnectionToggle( int index ) | 487 | void SMTPconfig::slotConnectionToggle( int index ) |
488 | { | 488 | { |
489 | // 2 is ssl connection | 489 | // 2 is ssl connection |
490 | if ( index == 2 ) | 490 | if ( index == 2 ) |
491 | { | 491 | { |
492 | portLine->setText( SMTP_SSL_PORT ); | 492 | portLine->setText( SMTP_SSL_PORT ); |
493 | } | 493 | } |
494 | else if ( index == 3 ) | 494 | else if ( index == 3 ) |
495 | { | 495 | { |
496 | portLine->setText( SMTP_PORT ); | 496 | portLine->setText( SMTP_PORT ); |
497 | CommandEdit->show(); | 497 | CommandEdit->show(); |
498 | } | 498 | } |
499 | else | 499 | else |
500 | { | 500 | { |
501 | portLine->setText( SMTP_PORT ); | 501 | portLine->setText( SMTP_PORT ); |
502 | } | 502 | } |
503 | } | 503 | } |
504 | 504 | ||
505 | void SMTPconfig::fillValues() | 505 | void SMTPconfig::fillValues() |
506 | { | 506 | { |
507 | accountLine->setText( data->getAccountName() ); | 507 | accountLine->setText( data->getAccountName() ); |
508 | serverLine->setText( data->getServer() ); | 508 | serverLine->setText( data->getServer() ); |
509 | portLine->setText( data->getPort() ); | 509 | portLine->setText( data->getPort() ); |
510 | ComboBox1->setCurrentItem( data->ConnectionType() ); | 510 | ComboBox1->setCurrentItem( data->ConnectionType() ); |
511 | loginBox->setChecked( data->getLogin() ); | 511 | loginBox->setChecked( data->getLogin() ); |
512 | userLine->setText( data->getUser() ); | 512 | userLine->setText( data->getUser() ); |
513 | passLine->setText( data->getPassword() ); | 513 | passLine->setText( data->getPassword() ); |
514 | } | 514 | } |
515 | 515 | ||
516 | void SMTPconfig::accept() | 516 | void SMTPconfig::accept() |
517 | { | 517 | { |
518 | data->setAccountName( accountLine->text() ); | 518 | data->setAccountName( accountLine->text() ); |
519 | data->setServer( serverLine->text() ); | 519 | data->setServer( serverLine->text() ); |
520 | data->setPort( portLine->text() ); | 520 | data->setPort( portLine->text() ); |
521 | data->setConnectionType( ComboBox1->currentItem() ); | 521 | data->setConnectionType( ComboBox1->currentItem() ); |
522 | data->setLogin( loginBox->isChecked() ); | 522 | data->setLogin( loginBox->isChecked() ); |
523 | data->setUser( userLine->text() ); | 523 | data->setUser( userLine->text() ); |
524 | data->setPassword( passLine->text() ); | 524 | data->setPassword( passLine->text() ); |
525 | 525 | ||
526 | QDialog::accept(); | 526 | QDialog::accept(); |
527 | } | 527 | } |
528 | 528 | ||
529 | /** | 529 | /** |
530 | * NNTPconfig | 530 | * NNTPconfig |
531 | */ | 531 | */ |
532 | 532 | ||
533 | NNTPconfig::NNTPconfig( NNTPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags ) | 533 | NNTPconfig::NNTPconfig( NNTPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags ) |
534 | : NNTPconfigUI( parent, name, modal, flags ) | 534 | : NNTPconfigUI( parent, name, modal, flags ) |
535 | { | 535 | { |
536 | data = account; | 536 | data = account; |
537 | 537 | ||
538 | connect( loginBox, SIGNAL( toggled(bool) ), userLine, SLOT( setEnabled(bool) ) ); | 538 | connect( loginBox, SIGNAL( toggled(bool) ), userLine, SLOT( setEnabled(bool) ) ); |
539 | connect( loginBox, SIGNAL( toggled(bool) ), passLine, SLOT( setEnabled(bool) ) ); | 539 | connect( loginBox, SIGNAL( toggled(bool) ), passLine, SLOT( setEnabled(bool) ) ); |
540 | connect( GetNGButton, SIGNAL( clicked() ), this, SLOT( slotGetNG() ) ); | 540 | connect( GetNGButton, SIGNAL( clicked() ), this, SLOT( slotGetNG() ) ); |
541 | connect( ShowSubcribed, SIGNAL( clicked() ), this, SLOT( slotShowSub() ) ); | ||
542 | connect( FilterButton, SIGNAL( clicked() ), this, SLOT( slotShowFilter() ) ); | ||
541 | fillValues(); | 543 | fillValues(); |
542 | 544 | ||
543 | connect( sslBox, SIGNAL( toggled(bool) ), SLOT( slotSSL(bool) ) ); | 545 | connect( sslBox, SIGNAL( toggled(bool) ), SLOT( slotSSL(bool) ) ); |
544 | } | 546 | } |
545 | 547 | ||
548 | void NNTPconfig::slotShowSub() | ||
549 | { | ||
550 | save(); | ||
551 | data->save(); | ||
552 | ListViewGroups->clear(); | ||
553 | for ( QStringList::Iterator it = subscribedGroups.begin(); it != subscribedGroups.end(); ++it ) { | ||
554 | QCheckListItem *item; | ||
555 | item = new QCheckListItem( ListViewGroups, (*it), QCheckListItem::CheckBox ); | ||
556 | item->setOn( true ); | ||
557 | } | ||
558 | topLevelWidget()->setCaption( tr("%1 groups subscribed").arg( subscribedGroups.count())); | ||
559 | } | ||
560 | void NNTPconfig::slotShowFilter() | ||
561 | { | ||
562 | save(); | ||
563 | data->save(); | ||
564 | ListViewGroups->clear(); | ||
565 | int count = 0; | ||
566 | for ( QStringList::Iterator it = allGroups.begin(); it != allGroups.end(); ++it ) { | ||
567 | QCheckListItem *item; | ||
568 | if ( GroupFilter->text().isEmpty() || (*it).find( GroupFilter->text() ) >= 0 ) { | ||
569 | item = new QCheckListItem( ListViewGroups, (*it), QCheckListItem::CheckBox ); | ||
570 | ++count; | ||
571 | if ( subscribedGroups.contains( (*it) ) >= 1 ) { | ||
572 | item->setOn( true ); | ||
573 | } | ||
574 | } | ||
575 | } | ||
576 | topLevelWidget()->setCaption( tr("Filter found %1 groups").arg( count)); | ||
577 | } | ||
546 | void NNTPconfig::slotGetNG() { | 578 | void NNTPconfig::slotGetNG() { |
547 | save(); | 579 | save(); |
548 | data->save(); | 580 | data->save(); |
581 | topLevelWidget()->setCaption( tr("Fetching group list...")); | ||
582 | qApp->processEvents(); | ||
549 | NNTPwrapper* tmp = new NNTPwrapper( data ); | 583 | NNTPwrapper* tmp = new NNTPwrapper( data ); |
550 | QStringList list = tmp->listAllNewsgroups(); | 584 | allGroups = tmp->listAllNewsgroups(); |
585 | topLevelWidget()->setCaption( tr("Downloaded %1 group names").arg( allGroups.count())); | ||
551 | 586 | ||
552 | ListViewGroups->clear(); | 587 | ListViewGroups->clear(); |
553 | 588 | ||
554 | for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { | 589 | for ( QStringList::Iterator it = allGroups.begin(); it != allGroups.end(); ++it ) { |
555 | QCheckListItem *item; | 590 | QCheckListItem *item; |
556 | item = new QCheckListItem( ListViewGroups, (*it), QCheckListItem::CheckBox ); | 591 | item = new QCheckListItem( ListViewGroups, (*it), QCheckListItem::CheckBox ); |
557 | if ( subscribedGroups.contains( (*it) ) >= 1 ) { | 592 | if ( subscribedGroups.contains( (*it) ) >= 1 ) { |
558 | item->setOn( true ); | 593 | item->setOn( true ); |
559 | } | 594 | |
595 | } | ||
560 | } | 596 | } |
597 | delete tmp; | ||
561 | } | 598 | } |
562 | 599 | ||
563 | void NNTPconfig::slotSSL( bool enabled ) | 600 | void NNTPconfig::slotSSL( bool enabled ) |
564 | { | 601 | { |
565 | if ( enabled ) | 602 | if ( enabled ) |
566 | { | 603 | { |
567 | portLine->setText( NNTP_SSL_PORT ); | 604 | portLine->setText( NNTP_SSL_PORT ); |
568 | } | 605 | } |
569 | else | 606 | else |
570 | { | 607 | { |
571 | portLine->setText( NNTP_PORT ); | 608 | portLine->setText( NNTP_PORT ); |
572 | } | 609 | } |
573 | } | 610 | } |
574 | 611 | ||
575 | void NNTPconfig::fillValues() | 612 | void NNTPconfig::fillValues() |
576 | { | 613 | { |
577 | accountLine->setText( data->getAccountName() ); | 614 | accountLine->setText( data->getAccountName() ); |
578 | serverLine->setText( data->getServer() ); | 615 | serverLine->setText( data->getServer() ); |
579 | portLine->setText( data->getPort() ); | 616 | portLine->setText( data->getPort() ); |
580 | sslBox->setChecked( data->getSSL() ); | 617 | sslBox->setChecked( data->getSSL() ); |
581 | loginBox->setChecked( data->getLogin() ); | 618 | loginBox->setChecked( data->getLogin() ); |
582 | userLine->setText( data->getUser() ); | 619 | userLine->setText( data->getUser() ); |
583 | passLine->setText( data->getPassword() ); | 620 | passLine->setText( data->getPassword() ); |
584 | subscribedGroups = data->getGroups(); | 621 | subscribedGroups = data->getGroups(); |
585 | /* don't forget that - you will overwrite values if user clicks cancel! */ | 622 | /* don't forget that - you will overwrite values if user clicks cancel! */ |
586 | for ( QStringList::Iterator it = subscribedGroups.begin(); it != subscribedGroups.end(); ++it ) { | 623 | for ( QStringList::Iterator it = subscribedGroups.begin(); it != subscribedGroups.end(); ++it ) { |
587 | QCheckListItem *item; | 624 | QCheckListItem *item; |
588 | item = new QCheckListItem( ListViewGroups, (*it), QCheckListItem::CheckBox ); | 625 | item = new QCheckListItem( ListViewGroups, (*it), QCheckListItem::CheckBox ); |
589 | item->setOn( true ); | 626 | item->setOn( true ); |
590 | } | 627 | } |
591 | } | 628 | } |
592 | 629 | ||
593 | void NNTPconfig::save() | 630 | void NNTPconfig::save() |
594 | { | 631 | { |
595 | data->setAccountName( accountLine->text() ); | 632 | data->setAccountName( accountLine->text() ); |
596 | data->setServer( serverLine->text() ); | 633 | data->setServer( serverLine->text() ); |
597 | data->setPort( portLine->text() ); | 634 | data->setPort( portLine->text() ); |
598 | data->setSSL( sslBox->isChecked() ); | 635 | data->setSSL( sslBox->isChecked() ); |
599 | data->setLogin( loginBox->isChecked() ); | 636 | data->setLogin( loginBox->isChecked() ); |
600 | data->setUser( userLine->text() ); | 637 | data->setUser( userLine->text() ); |
601 | data->setPassword( passLine->text() ); | 638 | data->setPassword( passLine->text() ); |
602 | 639 | ||
603 | QListViewItemIterator list_it( ListViewGroups ); | 640 | QListViewItemIterator list_it( ListViewGroups ); |
604 | 641 | ||
605 | QStringList groupList; | 642 | for ( ; list_it.current(); ++list_it ) { |
606 | for ( ; list_it.current(); ++list_it ) { | ||
607 | 643 | ||
608 | if ( ( (QCheckListItem*)list_it.current() )->isOn() ) { | 644 | if ( ( (QCheckListItem*)list_it.current() )->isOn() ) { |
609 | groupList.append( list_it.current()->text(0) ); | 645 | if ( subscribedGroups.contains( list_it.current()->text(0) ) < 1 ) |
610 | } | 646 | subscribedGroups.append( list_it.current()->text(0) ); |
647 | } else { | ||
648 | if ( subscribedGroups.contains( list_it.current()->text(0) ) >= 1 ) | ||
649 | subscribedGroups.remove( list_it.current()->text(0) ); | ||
650 | } | ||
611 | 651 | ||
612 | } | 652 | } |
613 | data->setGroups( groupList ); | 653 | data->setGroups( subscribedGroups ); |
614 | } | 654 | } |
615 | 655 | ||
616 | void NNTPconfig::accept() | 656 | void NNTPconfig::accept() |
617 | { | 657 | { |
618 | save(); | 658 | save(); |
619 | QDialog::accept(); | 659 | QDialog::accept(); |
620 | } | 660 | } |
621 | 661 | ||