-rw-r--r-- | kmicromail/editaccounts.cpp | 45 |
1 files changed, 23 insertions, 22 deletions
diff --git a/kmicromail/editaccounts.cpp b/kmicromail/editaccounts.cpp index 733e38a..7ad4ec8 100644 --- a/kmicromail/editaccounts.cpp +++ b/kmicromail/editaccounts.cpp | |||
@@ -1,83 +1,84 @@ | |||
1 | 1 | ||
2 | #include "defines.h" | 2 | #include "defines.h" |
3 | #include "editaccounts.h" | 3 | #include "editaccounts.h" |
4 | #include "kapplication.h" | 4 | #include "kapplication.h" |
5 | /* OPIE */ | 5 | /* OPIE */ |
6 | #include <qpe/qpeapplication.h> | 6 | #include <qpe/qpeapplication.h> |
7 | 7 | ||
8 | /* QT */ | 8 | /* QT */ |
9 | #include <qstringlist.h> | 9 | #include <qstringlist.h> |
10 | 10 | ||
11 | #include <qcombobox.h> | 11 | #include <qcombobox.h> |
12 | #include <qcheckbox.h> | 12 | #include <qcheckbox.h> |
13 | #include <qmessagebox.h> | 13 | #include <qmessagebox.h> |
14 | #include <qpushbutton.h> | 14 | #include <qpushbutton.h> |
15 | #include <qlineedit.h> | 15 | #include <qlineedit.h> |
16 | #include <qlabel.h> | 16 | #include <qlabel.h> |
17 | #include <qtabwidget.h> | 17 | #include <qtabwidget.h> |
18 | #include <qlistview.h> | 18 | #include <qlistview.h> |
19 | #include <qspinbox.h> | 19 | #include <qspinbox.h> |
20 | #include <klocale.h> | ||
20 | 21 | ||
21 | #include <libmailwrapper/nntpwrapper.h> | 22 | #include <libmailwrapper/nntpwrapper.h> |
22 | 23 | ||
23 | using namespace Opie::Core; | 24 | using namespace Opie::Core; |
24 | 25 | ||
25 | AccountListItem::AccountListItem( QListView *parent, Account *a) | 26 | AccountListItem::AccountListItem( QListView *parent, Account *a) |
26 | : QListViewItem( parent ) | 27 | : QListViewItem( parent ) |
27 | { | 28 | { |
28 | account = a; | 29 | account = a; |
29 | setText( 0, account->getAccountName() ); | 30 | setText( 0, account->getAccountName() ); |
30 | QString ttext = ""; | 31 | QString ttext = ""; |
31 | switch (account->getType()) { | 32 | switch (account->getType()) { |
32 | case MAILLIB::A_NNTP: | 33 | case MAILLIB::A_NNTP: |
33 | ttext="NNTP"; | 34 | ttext="NNTP"; |
34 | break; | 35 | break; |
35 | case MAILLIB::A_POP3: | 36 | case MAILLIB::A_POP3: |
36 | ttext = "POP3"; | 37 | ttext = "POP3"; |
37 | break; | 38 | break; |
38 | case MAILLIB::A_IMAP: | 39 | case MAILLIB::A_IMAP: |
39 | ttext = "IMAP"; | 40 | ttext = "IMAP"; |
40 | break; | 41 | break; |
41 | case MAILLIB::A_SMTP: | 42 | case MAILLIB::A_SMTP: |
42 | ttext = "SMTP"; | 43 | ttext = "SMTP"; |
43 | break; | 44 | break; |
44 | default: | 45 | default: |
45 | ttext = "UNKNOWN"; | 46 | ttext = "UNKNOWN"; |
46 | break; | 47 | break; |
47 | } | 48 | } |
48 | setText( 1, ttext); | 49 | setText( 1, ttext); |
49 | } | 50 | } |
50 | 51 | ||
51 | EditAccounts::EditAccounts( Settings *s, QWidget *parent, const char *name, bool modal, WFlags flags ) | 52 | EditAccounts::EditAccounts( Settings *s, QWidget *parent, const char *name, bool modal, WFlags flags ) |
52 | : EditAccountsUI( parent, name, modal, flags ) | 53 | : EditAccountsUI( parent, name, modal, flags ) |
53 | { | 54 | { |
54 | settings = s; | 55 | settings = s; |
55 | 56 | ||
56 | mailList->addColumn( tr( "Account" ) ); | 57 | mailList->addColumn( i18n( "Account" ) ); |
57 | mailList->addColumn( tr( "Type" ) ); | 58 | mailList->addColumn( i18n( "Type" ) ); |
58 | 59 | ||
59 | newsList->addColumn( tr( "Account" ) ); | 60 | newsList->addColumn( i18n( "Account" ) ); |
60 | 61 | ||
61 | connect( newMail, SIGNAL( clicked() ), SLOT( slotNewMail() ) ); | 62 | connect( newMail, SIGNAL( clicked() ), SLOT( slotNewMail() ) ); |
62 | connect( editMail, SIGNAL( clicked() ), SLOT( slotEditMail() ) ); | 63 | connect( editMail, SIGNAL( clicked() ), SLOT( slotEditMail() ) ); |
63 | connect( deleteMail, SIGNAL( clicked() ), SLOT( slotDeleteMail() ) ); | 64 | connect( deleteMail, SIGNAL( clicked() ), SLOT( slotDeleteMail() ) ); |
64 | connect( newNews, SIGNAL( clicked() ), SLOT( slotNewNews() ) ); | 65 | connect( newNews, SIGNAL( clicked() ), SLOT( slotNewNews() ) ); |
65 | connect( editNews, SIGNAL( clicked() ), SLOT( slotEditNews() ) ); | 66 | connect( editNews, SIGNAL( clicked() ), SLOT( slotEditNews() ) ); |
66 | connect( deleteNews, SIGNAL( clicked() ), SLOT( slotDeleteNews() ) ); | 67 | connect( deleteNews, SIGNAL( clicked() ), SLOT( slotDeleteNews() ) ); |
67 | 68 | ||
68 | slotFillLists(); | 69 | slotFillLists(); |
69 | } | 70 | } |
70 | 71 | ||
71 | void EditAccounts::slotFillLists() | 72 | void EditAccounts::slotFillLists() |
72 | { | 73 | { |
73 | mailList->clear(); | 74 | mailList->clear(); |
74 | newsList->clear(); | 75 | newsList->clear(); |
75 | 76 | ||
76 | QList<Account> accounts = settings->getAccounts(); | 77 | QList<Account> accounts = settings->getAccounts(); |
77 | Account *it; | 78 | Account *it; |
78 | for ( it = accounts.first(); it; it = accounts.next() ) | 79 | for ( it = accounts.first(); it; it = accounts.next() ) |
79 | { | 80 | { |
80 | if ( it->getType()==MAILLIB::A_NNTP ) | 81 | if ( it->getType()==MAILLIB::A_NNTP ) |
81 | { | 82 | { |
82 | (void) new AccountListItem( newsList, it ); | 83 | (void) new AccountListItem( newsList, it ); |
83 | } | 84 | } |
@@ -186,111 +187,111 @@ void EditAccounts::slotEditAccount( Account *account ) | |||
186 | } | 187 | } |
187 | } | 188 | } |
188 | else if ( account->getType()==MAILLIB::A_SMTP ) | 189 | else if ( account->getType()==MAILLIB::A_SMTP ) |
189 | { | 190 | { |
190 | SMTPaccount *smtpAcc = static_cast<SMTPaccount *>(account); | 191 | SMTPaccount *smtpAcc = static_cast<SMTPaccount *>(account); |
191 | SMTPconfig smtp( smtpAcc, this, 0, true, WStyle_ContextHelp ); | 192 | SMTPconfig smtp( smtpAcc, this, 0, true, WStyle_ContextHelp ); |
192 | if ( QDialog::Accepted == KApplication::execDialog( &smtp ) ) | 193 | if ( QDialog::Accepted == KApplication::execDialog( &smtp ) ) |
193 | { | 194 | { |
194 | slotFillLists(); | 195 | slotFillLists(); |
195 | } | 196 | } |
196 | } | 197 | } |
197 | else if ( account->getType()==MAILLIB::A_NNTP) | 198 | else if ( account->getType()==MAILLIB::A_NNTP) |
198 | { | 199 | { |
199 | NNTPaccount *nntpAcc = static_cast<NNTPaccount *>(account); | 200 | NNTPaccount *nntpAcc = static_cast<NNTPaccount *>(account); |
200 | NNTPconfig nntp( nntpAcc, this, 0, true, WStyle_ContextHelp ); | 201 | NNTPconfig nntp( nntpAcc, this, 0, true, WStyle_ContextHelp ); |
201 | if ( QDialog::Accepted == KApplication::execDialog( &nntp ) ) | 202 | if ( QDialog::Accepted == KApplication::execDialog( &nntp ) ) |
202 | { | 203 | { |
203 | slotFillLists(); | 204 | slotFillLists(); |
204 | } | 205 | } |
205 | } | 206 | } |
206 | } | 207 | } |
207 | 208 | ||
208 | void EditAccounts::slotDeleteAccount( Account *account ) | 209 | void EditAccounts::slotDeleteAccount( Account *account ) |
209 | { | 210 | { |
210 | if ( QMessageBox::information( this, tr( "Question" ), | 211 | if ( QMessageBox::information( this, i18n( "Question" ), |
211 | tr( "<p>Do you really want to delete the selected Account?</p>" ), | 212 | i18n( "<p>Do you really want to delete the selected Account?</p>" ), |
212 | tr( "Yes" ), tr( "No" ) ) == 0 ) | 213 | i18n( "Yes" ), i18n( "No" ) ) == 0 ) |
213 | { | 214 | { |
214 | settings->delAccount( account ); | 215 | settings->delAccount( account ); |
215 | slotFillLists(); | 216 | slotFillLists(); |
216 | } | 217 | } |
217 | } | 218 | } |
218 | 219 | ||
219 | void EditAccounts::slotEditMail() | 220 | void EditAccounts::slotEditMail() |
220 | { | 221 | { |
221 | if ( !mailList->currentItem() ) | 222 | if ( !mailList->currentItem() ) |
222 | { | 223 | { |
223 | QMessageBox::information( this, tr( "Error" ), | 224 | QMessageBox::information( this, i18n( "Error" ), |
224 | tr( "<p>Please select an account.</p>" ), | 225 | i18n( "<p>Please select an account.</p>" ), |
225 | tr( "Ok" ) ); | 226 | i18n( "Ok" ) ); |
226 | return; | 227 | return; |
227 | } | 228 | } |
228 | 229 | ||
229 | Account *a = ((AccountListItem *) mailList->currentItem())->getAccount(); | 230 | Account *a = ((AccountListItem *) mailList->currentItem())->getAccount(); |
230 | slotEditAccount( a ); | 231 | slotEditAccount( a ); |
231 | } | 232 | } |
232 | 233 | ||
233 | void EditAccounts::slotDeleteMail() | 234 | void EditAccounts::slotDeleteMail() |
234 | { | 235 | { |
235 | if ( !mailList->currentItem() ) | 236 | if ( !mailList->currentItem() ) |
236 | { | 237 | { |
237 | QMessageBox::information( this, tr( "Error" ), | 238 | QMessageBox::information( this, i18n( "Error" ), |
238 | tr( "<p>Please select an account.</p>" ), | 239 | i18n( "<p>Please select an account.</p>" ), |
239 | tr( "Ok" ) ); | 240 | i18n( "Ok" ) ); |
240 | return; | 241 | return; |
241 | } | 242 | } |
242 | 243 | ||
243 | Account *a = ((AccountListItem *) mailList->currentItem())->getAccount(); | 244 | Account *a = ((AccountListItem *) mailList->currentItem())->getAccount(); |
244 | slotDeleteAccount( a ); | 245 | slotDeleteAccount( a ); |
245 | } | 246 | } |
246 | 247 | ||
247 | void EditAccounts::slotNewNews() | 248 | void EditAccounts::slotNewNews() |
248 | { | 249 | { |
249 | slotNewAccount( "NNTP" ); | 250 | slotNewAccount( "NNTP" ); |
250 | } | 251 | } |
251 | 252 | ||
252 | void EditAccounts::slotEditNews() | 253 | void EditAccounts::slotEditNews() |
253 | { | 254 | { |
254 | if ( !newsList->currentItem() ) | 255 | if ( !newsList->currentItem() ) |
255 | { | 256 | { |
256 | QMessageBox::information( this, tr( "Error" ), | 257 | QMessageBox::information( this, i18n( "Error" ), |
257 | tr( "<p>Please select an account.</p>" ), | 258 | i18n( "<p>Please select an account.</p>" ), |
258 | tr( "Ok" ) ); | 259 | i18n( "Ok" ) ); |
259 | return; | 260 | return; |
260 | } | 261 | } |
261 | 262 | ||
262 | Account *a = ((AccountListItem *) newsList->currentItem())->getAccount(); | 263 | Account *a = ((AccountListItem *) newsList->currentItem())->getAccount(); |
263 | slotEditAccount( a ); | 264 | slotEditAccount( a ); |
264 | } | 265 | } |
265 | 266 | ||
266 | void EditAccounts::slotDeleteNews() | 267 | void EditAccounts::slotDeleteNews() |
267 | { | 268 | { |
268 | if ( !newsList->currentItem() ) | 269 | if ( !newsList->currentItem() ) |
269 | { | 270 | { |
270 | QMessageBox::information( this, tr( "Error" ), | 271 | QMessageBox::information( this, i18n( "Error" ), |
271 | tr( "<p>Please select an account.</p>" ), | 272 | i18n( "<p>Please select an account.</p>" ), |
272 | tr( "Ok" ) ); | 273 | i18n( "Ok" ) ); |
273 | return; | 274 | return; |
274 | } | 275 | } |
275 | 276 | ||
276 | Account *a = ((AccountListItem *) newsList->currentItem())->getAccount(); | 277 | Account *a = ((AccountListItem *) newsList->currentItem())->getAccount(); |
277 | slotDeleteAccount( a ); | 278 | slotDeleteAccount( a ); |
278 | } | 279 | } |
279 | 280 | ||
280 | void EditAccounts::slotAdjustColumns() | 281 | void EditAccounts::slotAdjustColumns() |
281 | { | 282 | { |
282 | int currPage = configTab->currentPageIndex(); | 283 | int currPage = configTab->currentPageIndex(); |
283 | 284 | ||
284 | configTab->showPage( mailTab ); | 285 | configTab->showPage( mailTab ); |
285 | mailList->setColumnWidth( 0, mailList->visibleWidth() - 50 ); | 286 | mailList->setColumnWidth( 0, mailList->visibleWidth() - 50 ); |
286 | mailList->setColumnWidth( 1, 50 ); | 287 | mailList->setColumnWidth( 1, 50 ); |
287 | 288 | ||
288 | configTab->showPage( newsTab ); | 289 | configTab->showPage( newsTab ); |
289 | newsList->setColumnWidth( 0, newsList->visibleWidth() ); | 290 | newsList->setColumnWidth( 0, newsList->visibleWidth() ); |
290 | 291 | ||
291 | configTab->setCurrentPage( currPage ); | 292 | configTab->setCurrentPage( currPage ); |
292 | } | 293 | } |
293 | 294 | ||
294 | void EditAccounts::accept() | 295 | void EditAccounts::accept() |
295 | { | 296 | { |
296 | settings->saveAccounts(); | 297 | settings->saveAccounts(); |
@@ -534,76 +535,76 @@ NNTPconfig::NNTPconfig( NNTPaccount *account, QWidget *parent, const char *name, | |||
534 | : NNTPconfigUI( parent, name, modal, flags ) | 535 | : NNTPconfigUI( parent, name, modal, flags ) |
535 | { | 536 | { |
536 | data = account; | 537 | data = account; |
537 | 538 | ||
538 | connect( loginBox, SIGNAL( toggled(bool) ), userLine, SLOT( setEnabled(bool) ) ); | 539 | connect( loginBox, SIGNAL( toggled(bool) ), userLine, SLOT( setEnabled(bool) ) ); |
539 | connect( loginBox, SIGNAL( toggled(bool) ), passLine, SLOT( setEnabled(bool) ) ); | 540 | connect( loginBox, SIGNAL( toggled(bool) ), passLine, SLOT( setEnabled(bool) ) ); |
540 | connect( GetNGButton, SIGNAL( clicked() ), this, SLOT( slotGetNG() ) ); | 541 | connect( GetNGButton, SIGNAL( clicked() ), this, SLOT( slotGetNG() ) ); |
541 | connect( ShowSubcribed, SIGNAL( clicked() ), this, SLOT( slotShowSub() ) ); | 542 | connect( ShowSubcribed, SIGNAL( clicked() ), this, SLOT( slotShowSub() ) ); |
542 | connect( FilterButton, SIGNAL( clicked() ), this, SLOT( slotShowFilter() ) ); | 543 | connect( FilterButton, SIGNAL( clicked() ), this, SLOT( slotShowFilter() ) ); |
543 | fillValues(); | 544 | fillValues(); |
544 | 545 | ||
545 | connect( sslBox, SIGNAL( toggled(bool) ), SLOT( slotSSL(bool) ) ); | 546 | connect( sslBox, SIGNAL( toggled(bool) ), SLOT( slotSSL(bool) ) ); |
546 | } | 547 | } |
547 | 548 | ||
548 | void NNTPconfig::slotShowSub() | 549 | void NNTPconfig::slotShowSub() |
549 | { | 550 | { |
550 | save(); | 551 | save(); |
551 | data->save(); | 552 | data->save(); |
552 | ListViewGroups->clear(); | 553 | ListViewGroups->clear(); |
553 | for ( QStringList::Iterator it = subscribedGroups.begin(); it != subscribedGroups.end(); ++it ) { | 554 | for ( QStringList::Iterator it = subscribedGroups.begin(); it != subscribedGroups.end(); ++it ) { |
554 | QCheckListItem *item; | 555 | QCheckListItem *item; |
555 | item = new QCheckListItem( ListViewGroups, (*it), QCheckListItem::CheckBox ); | 556 | item = new QCheckListItem( ListViewGroups, (*it), QCheckListItem::CheckBox ); |
556 | item->setOn( true ); | 557 | item->setOn( true ); |
557 | } | 558 | } |
558 | topLevelWidget()->setCaption( tr("%1 groups subscribed").arg( subscribedGroups.count())); | 559 | topLevelWidget()->setCaption( i18n("%1 groups subscribed").arg( subscribedGroups.count())); |
559 | } | 560 | } |
560 | void NNTPconfig::slotShowFilter() | 561 | void NNTPconfig::slotShowFilter() |
561 | { | 562 | { |
562 | save(); | 563 | save(); |
563 | data->save(); | 564 | data->save(); |
564 | ListViewGroups->clear(); | 565 | ListViewGroups->clear(); |
565 | int count = 0; | 566 | int count = 0; |
566 | for ( QStringList::Iterator it = allGroups.begin(); it != allGroups.end(); ++it ) { | 567 | for ( QStringList::Iterator it = allGroups.begin(); it != allGroups.end(); ++it ) { |
567 | QCheckListItem *item; | 568 | QCheckListItem *item; |
568 | if ( GroupFilter->text().isEmpty() || (*it).find( GroupFilter->text() ) >= 0 ) { | 569 | if ( GroupFilter->text().isEmpty() || (*it).find( GroupFilter->text() ) >= 0 ) { |
569 | item = new QCheckListItem( ListViewGroups, (*it), QCheckListItem::CheckBox ); | 570 | item = new QCheckListItem( ListViewGroups, (*it), QCheckListItem::CheckBox ); |
570 | ++count; | 571 | ++count; |
571 | if ( subscribedGroups.contains( (*it) ) >= 1 ) { | 572 | if ( subscribedGroups.contains( (*it) ) >= 1 ) { |
572 | item->setOn( true ); | 573 | item->setOn( true ); |
573 | } | 574 | } |
574 | } | 575 | } |
575 | } | 576 | } |
576 | topLevelWidget()->setCaption( tr("Filter found %1 groups").arg( count)); | 577 | topLevelWidget()->setCaption( i18n("Filter found %1 groups").arg( count)); |
577 | } | 578 | } |
578 | void NNTPconfig::slotGetNG() { | 579 | void NNTPconfig::slotGetNG() { |
579 | save(); | 580 | save(); |
580 | data->save(); | 581 | data->save(); |
581 | topLevelWidget()->setCaption( tr("Fetching group list...")); | 582 | topLevelWidget()->setCaption( i18n("Fetching group list...")); |
582 | qApp->processEvents(); | 583 | qApp->processEvents(); |
583 | NNTPwrapper* tmp = new NNTPwrapper( data ); | 584 | NNTPwrapper* tmp = new NNTPwrapper( data ); |
584 | allGroups = tmp->listAllNewsgroups(); | 585 | allGroups = tmp->listAllNewsgroups(); |
585 | topLevelWidget()->setCaption( tr("Downloaded %1 group names").arg( allGroups.count())); | 586 | topLevelWidget()->setCaption( i18n("Downloaded %1 group names").arg( allGroups.count())); |
586 | 587 | ||
587 | ListViewGroups->clear(); | 588 | ListViewGroups->clear(); |
588 | 589 | ||
589 | for ( QStringList::Iterator it = allGroups.begin(); it != allGroups.end(); ++it ) { | 590 | for ( QStringList::Iterator it = allGroups.begin(); it != allGroups.end(); ++it ) { |
590 | QCheckListItem *item; | 591 | QCheckListItem *item; |
591 | item = new QCheckListItem( ListViewGroups, (*it), QCheckListItem::CheckBox ); | 592 | item = new QCheckListItem( ListViewGroups, (*it), QCheckListItem::CheckBox ); |
592 | if ( subscribedGroups.contains( (*it) ) >= 1 ) { | 593 | if ( subscribedGroups.contains( (*it) ) >= 1 ) { |
593 | item->setOn( true ); | 594 | item->setOn( true ); |
594 | 595 | ||
595 | } | 596 | } |
596 | } | 597 | } |
597 | delete tmp; | 598 | delete tmp; |
598 | } | 599 | } |
599 | 600 | ||
600 | void NNTPconfig::slotSSL( bool enabled ) | 601 | void NNTPconfig::slotSSL( bool enabled ) |
601 | { | 602 | { |
602 | if ( enabled ) | 603 | if ( enabled ) |
603 | { | 604 | { |
604 | portLine->setText( NNTP_SSL_PORT ); | 605 | portLine->setText( NNTP_SSL_PORT ); |
605 | } | 606 | } |
606 | else | 607 | else |
607 | { | 608 | { |
608 | portLine->setText( NNTP_PORT ); | 609 | portLine->setText( NNTP_PORT ); |
609 | } | 610 | } |