-rw-r--r-- | kmicromail/editaccounts.cpp | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/kmicromail/editaccounts.cpp b/kmicromail/editaccounts.cpp index e7d2750..d43d23b 100644 --- a/kmicromail/editaccounts.cpp +++ b/kmicromail/editaccounts.cpp | |||
@@ -1,606 +1,621 @@ | |||
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 | 20 | ||
21 | #include <libmailwrapper/nntpwrapper.h> | 21 | #include <libmailwrapper/nntpwrapper.h> |
22 | 22 | ||
23 | using namespace Opie::Core; | 23 | using namespace Opie::Core; |
24 | 24 | ||
25 | AccountListItem::AccountListItem( QListView *parent, Account *a) | 25 | AccountListItem::AccountListItem( QListView *parent, Account *a) |
26 | : QListViewItem( parent ) | 26 | : QListViewItem( parent ) |
27 | { | 27 | { |
28 | account = a; | 28 | account = a; |
29 | setText( 0, account->getAccountName() ); | 29 | setText( 0, account->getAccountName() ); |
30 | QString ttext = ""; | 30 | QString ttext = ""; |
31 | switch (account->getType()) { | 31 | switch (account->getType()) { |
32 | case MAILLIB::A_NNTP: | 32 | case MAILLIB::A_NNTP: |
33 | ttext="NNTP"; | 33 | ttext="NNTP"; |
34 | break; | 34 | break; |
35 | case MAILLIB::A_POP3: | 35 | case MAILLIB::A_POP3: |
36 | ttext = "POP3"; | 36 | ttext = "POP3"; |
37 | break; | 37 | break; |
38 | case MAILLIB::A_IMAP: | 38 | case MAILLIB::A_IMAP: |
39 | ttext = "IMAP"; | 39 | ttext = "IMAP"; |
40 | break; | 40 | break; |
41 | case MAILLIB::A_SMTP: | 41 | case MAILLIB::A_SMTP: |
42 | ttext = "SMTP"; | 42 | ttext = "SMTP"; |
43 | break; | 43 | break; |
44 | default: | 44 | default: |
45 | ttext = "UNKNOWN"; | 45 | ttext = "UNKNOWN"; |
46 | break; | 46 | break; |
47 | } | 47 | } |
48 | setText( 1, ttext); | 48 | setText( 1, ttext); |
49 | } | 49 | } |
50 | 50 | ||
51 | EditAccounts::EditAccounts( Settings *s, QWidget *parent, const char *name, bool modal, WFlags flags ) | 51 | EditAccounts::EditAccounts( Settings *s, QWidget *parent, const char *name, bool modal, WFlags flags ) |
52 | : EditAccountsUI( parent, name, modal, flags ) | 52 | : EditAccountsUI( parent, name, modal, flags ) |
53 | { | 53 | { |
54 | settings = s; | 54 | settings = s; |
55 | 55 | ||
56 | mailList->addColumn( tr( "Account" ) ); | 56 | mailList->addColumn( tr( "Account" ) ); |
57 | mailList->addColumn( tr( "Type" ) ); | 57 | mailList->addColumn( tr( "Type" ) ); |
58 | 58 | ||
59 | newsList->addColumn( tr( "Account" ) ); | 59 | newsList->addColumn( tr( "Account" ) ); |
60 | 60 | ||
61 | connect( newMail, SIGNAL( clicked() ), SLOT( slotNewMail() ) ); | 61 | connect( newMail, SIGNAL( clicked() ), SLOT( slotNewMail() ) ); |
62 | connect( editMail, SIGNAL( clicked() ), SLOT( slotEditMail() ) ); | 62 | connect( editMail, SIGNAL( clicked() ), SLOT( slotEditMail() ) ); |
63 | connect( deleteMail, SIGNAL( clicked() ), SLOT( slotDeleteMail() ) ); | 63 | connect( deleteMail, SIGNAL( clicked() ), SLOT( slotDeleteMail() ) ); |
64 | connect( newNews, SIGNAL( clicked() ), SLOT( slotNewNews() ) ); | 64 | connect( newNews, SIGNAL( clicked() ), SLOT( slotNewNews() ) ); |
65 | connect( editNews, SIGNAL( clicked() ), SLOT( slotEditNews() ) ); | 65 | connect( editNews, SIGNAL( clicked() ), SLOT( slotEditNews() ) ); |
66 | connect( deleteNews, SIGNAL( clicked() ), SLOT( slotDeleteNews() ) ); | 66 | connect( deleteNews, SIGNAL( clicked() ), SLOT( slotDeleteNews() ) ); |
67 | 67 | ||
68 | slotFillLists(); | 68 | slotFillLists(); |
69 | } | 69 | } |
70 | 70 | ||
71 | void EditAccounts::slotFillLists() | 71 | void EditAccounts::slotFillLists() |
72 | { | 72 | { |
73 | mailList->clear(); | 73 | mailList->clear(); |
74 | newsList->clear(); | 74 | newsList->clear(); |
75 | 75 | ||
76 | QList<Account> accounts = settings->getAccounts(); | 76 | QList<Account> accounts = settings->getAccounts(); |
77 | Account *it; | 77 | Account *it; |
78 | for ( it = accounts.first(); it; it = accounts.next() ) | 78 | for ( it = accounts.first(); it; it = accounts.next() ) |
79 | { | 79 | { |
80 | if ( it->getType()==MAILLIB::A_NNTP ) | 80 | if ( it->getType()==MAILLIB::A_NNTP ) |
81 | { | 81 | { |
82 | (void) new AccountListItem( newsList, it ); | 82 | (void) new AccountListItem( newsList, it ); |
83 | } | 83 | } |
84 | else | 84 | else |
85 | { | 85 | { |
86 | (void) new AccountListItem( mailList, it ); | 86 | (void) new AccountListItem( mailList, it ); |
87 | } | 87 | } |
88 | } | 88 | } |
89 | } | 89 | } |
90 | 90 | ||
91 | void EditAccounts::slotNewMail() | 91 | void EditAccounts::slotNewMail() |
92 | { | 92 | { |
93 | QString *selection = new QString(); | 93 | QString *selection = new QString(); |
94 | SelectMailType selType( selection, this, 0, true ); | 94 | SelectMailType selType( selection, this, 0, true ); |
95 | selType.show(); | 95 | selType.show(); |
96 | if ( QDialog::Accepted == selType.exec() ) | 96 | if ( QDialog::Accepted == selType.exec() ) |
97 | { | 97 | { |
98 | slotNewAccount( *selection ); | 98 | slotNewAccount( *selection ); |
99 | } | 99 | } |
100 | } | 100 | } |
101 | 101 | ||
102 | void EditAccounts::slotNewAccount( const QString &type ) | 102 | void EditAccounts::slotNewAccount( const QString &type ) |
103 | { | 103 | { |
104 | if ( type.compare( "IMAP" ) == 0 ) | 104 | if ( type.compare( "IMAP" ) == 0 ) |
105 | { | 105 | { |
106 | IMAPaccount *account = new IMAPaccount(); | 106 | IMAPaccount *account = new IMAPaccount(); |
107 | IMAPconfig imap( account, this, 0, true ); | 107 | IMAPconfig imap( account, this, 0, true ); |
108 | imap.showMaximized(); | 108 | imap.showMaximized(); |
109 | if ( QDialog::Accepted == imap.exec() ) | 109 | if ( QDialog::Accepted == imap.exec() ) |
110 | { | 110 | { |
111 | settings->addAccount( account ); | 111 | settings->addAccount( account ); |
112 | account->save(); | 112 | account->save(); |
113 | slotFillLists(); | 113 | slotFillLists(); |
114 | } | 114 | } |
115 | else | 115 | else |
116 | { | 116 | { |
117 | account->remove(); | 117 | account->remove(); |
118 | } | 118 | } |
119 | } | 119 | } |
120 | else if ( type.compare( "POP3" ) == 0 ) | 120 | else if ( type.compare( "POP3" ) == 0 ) |
121 | { | 121 | { |
122 | POP3account *account = new POP3account(); | 122 | POP3account *account = new POP3account(); |
123 | POP3config pop3( account, this, 0, true, WStyle_ContextHelp ); | 123 | POP3config pop3( account, this, 0, true, WStyle_ContextHelp ); |
124 | if ( QDialog::Accepted == KApplication::execDialog( &pop3 ) ) | 124 | if ( QDialog::Accepted == KApplication::execDialog( &pop3 ) ) |
125 | { | 125 | { |
126 | settings->addAccount( account ); | 126 | settings->addAccount( account ); |
127 | account->save(); | 127 | account->save(); |
128 | slotFillLists(); | 128 | slotFillLists(); |
129 | } | 129 | } |
130 | else | 130 | else |
131 | { | 131 | { |
132 | account->remove(); | 132 | account->remove(); |
133 | } | 133 | } |
134 | } | 134 | } |
135 | else if ( type.compare( "SMTP" ) == 0 ) | 135 | else if ( type.compare( "SMTP" ) == 0 ) |
136 | { | 136 | { |
137 | SMTPaccount *account = new SMTPaccount(); | 137 | SMTPaccount *account = new SMTPaccount(); |
138 | SMTPconfig smtp( account, this, 0, true, WStyle_ContextHelp ); | 138 | SMTPconfig smtp( account, this, 0, true, WStyle_ContextHelp ); |
139 | if ( QDialog::Accepted == KApplication::execDialog( &smtp ) ) | 139 | if ( QDialog::Accepted == KApplication::execDialog( &smtp ) ) |
140 | { | 140 | { |
141 | settings->addAccount( account ); | 141 | settings->addAccount( account ); |
142 | account->save(); | 142 | account->save(); |
143 | slotFillLists(); | 143 | slotFillLists(); |
144 | 144 | ||
145 | } | 145 | } |
146 | else | 146 | else |
147 | { | 147 | { |
148 | account->remove(); | 148 | account->remove(); |
149 | } | 149 | } |
150 | } | 150 | } |
151 | else if ( type.compare( "NNTP" ) == 0 ) | 151 | else if ( type.compare( "NNTP" ) == 0 ) |
152 | { | 152 | { |
153 | NNTPaccount *account = new NNTPaccount(); | 153 | NNTPaccount *account = new NNTPaccount(); |
154 | NNTPconfig nntp( account, this, 0, true, WStyle_ContextHelp ); | 154 | NNTPconfig nntp( account, this, 0, true, WStyle_ContextHelp ); |
155 | if ( QDialog::Accepted == KApplication::execDialog( &nntp ) ) | 155 | if ( QDialog::Accepted == KApplication::execDialog( &nntp ) ) |
156 | { | 156 | { |
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() ); | ||
365 | int max = data->getMaxMailSize() ; | ||
366 | if ( max ) { | ||
367 | CheckBoxDown->setChecked( true ); | ||
368 | SpinBoxDown->setValue ( max ); | ||
369 | } else { | ||
370 | CheckBoxDown->setChecked( false ); | ||
371 | SpinBoxDown->setValue ( 5 ); | ||
372 | } | ||
373 | CheckBoxLeaveOn->setChecked( data->getLeaveOnServer() ); | ||
364 | } | 374 | } |
365 | 375 | ||
366 | void IMAPconfig::accept() | 376 | void IMAPconfig::accept() |
367 | { | 377 | { |
368 | data->setAccountName( accountLine->text() ); | 378 | data->setAccountName( accountLine->text() ); |
369 | data->setServer( serverLine->text() ); | 379 | data->setServer( serverLine->text() ); |
370 | data->setPort( portLine->text() ); | 380 | data->setPort( portLine->text() ); |
371 | data->setConnectionType( ComboBox1->currentItem() ); | 381 | data->setConnectionType( ComboBox1->currentItem() ); |
372 | data->setUser( userLine->text() ); | 382 | data->setUser( userLine->text() ); |
373 | data->setPassword( passLine->text() ); | 383 | data->setPassword( passLine->text() ); |
374 | data->setPrefix(prefixLine->text()); | 384 | data->setPrefix(prefixLine->text()); |
385 | data->setLocalFolder( localFolder->text() ); | ||
386 | data->setMaxMailSize( CheckBoxDown->isChecked()?SpinBoxDown->value():0 ) ; | ||
387 | data->setLeaveOnServer( CheckBoxLeaveOn->isChecked() ); | ||
375 | 388 | ||
376 | QDialog::accept(); | 389 | QDialog::accept(); |
377 | } | 390 | } |
378 | 391 | ||
379 | /** | 392 | /** |
380 | * POP3config | 393 | * POP3config |
381 | */ | 394 | */ |
382 | 395 | ||
383 | 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 ) |
384 | : POP3configUI( parent, name, modal, flags ) | 397 | : POP3configUI( parent, name, modal, flags ) |
385 | { | 398 | { |
386 | data = account; | 399 | data = account; |
387 | fillValues(); | 400 | fillValues(); |
388 | 401 | ||
389 | connect( ComboBox1, SIGNAL( activated(int) ), SLOT( slotConnectionToggle(int) ) ); | 402 | connect( ComboBox1, SIGNAL( activated(int) ), SLOT( slotConnectionToggle(int) ) ); |
390 | ComboBox1->insertItem( "Only if available", 0 ); | 403 | ComboBox1->insertItem( "Only if available", 0 ); |
391 | ComboBox1->insertItem( "Always, Negotiated", 1 ); | 404 | ComboBox1->insertItem( "Always, Negotiated", 1 ); |
392 | ComboBox1->insertItem( "Connect on secure port", 2 ); | 405 | ComboBox1->insertItem( "Connect on secure port", 2 ); |
393 | ComboBox1->insertItem( "Run command instead", 3 ); | 406 | ComboBox1->insertItem( "Run command instead", 3 ); |
394 | CommandEdit->hide(); | 407 | CommandEdit->hide(); |
395 | ComboBox1->setCurrentItem( data->ConnectionType() ); | 408 | ComboBox1->setCurrentItem( data->ConnectionType() ); |
396 | } | 409 | } |
397 | 410 | ||
398 | void POP3config::slotConnectionToggle( int index ) | 411 | void POP3config::slotConnectionToggle( int index ) |
399 | { | 412 | { |
400 | // 2 is ssl connection | 413 | // 2 is ssl connection |
401 | if ( index == 2 ) | 414 | if ( index == 2 ) |
402 | { | 415 | { |
403 | portLine->setText( POP3_SSL_PORT ); | 416 | portLine->setText( POP3_SSL_PORT ); |
404 | } | 417 | } |
405 | else if ( index == 3 ) | 418 | else if ( index == 3 ) |
406 | { | 419 | { |
407 | portLine->setText( POP3_PORT ); | 420 | portLine->setText( POP3_PORT ); |
408 | CommandEdit->show(); | 421 | CommandEdit->show(); |
409 | } | 422 | } |
410 | else | 423 | else |
411 | { | 424 | { |
412 | portLine->setText( POP3_PORT ); | 425 | portLine->setText( POP3_PORT ); |
413 | } | 426 | } |
414 | } | 427 | } |
415 | 428 | ||
416 | void POP3config::fillValues() | 429 | void POP3config::fillValues() |
417 | { | 430 | { |
418 | accountLine->setText( data->getAccountName() ); | 431 | accountLine->setText( data->getAccountName() ); |
419 | serverLine->setText( data->getServer() ); | 432 | serverLine->setText( data->getServer() ); |
420 | portLine->setText( data->getPort() ); | 433 | portLine->setText( data->getPort() ); |
421 | ComboBox1->setCurrentItem( data->ConnectionType() ); | 434 | ComboBox1->setCurrentItem( data->ConnectionType() ); |
422 | userLine->setText( data->getUser() ); | 435 | userLine->setText( data->getUser() ); |
423 | passLine->setText( data->getPassword() ); | 436 | passLine->setText( data->getPassword() ); |
424 | localFolder->setText( data->getLocalFolder() ); | 437 | localFolder->setText( data->getLocalFolder() ); |
425 | int max = data->getMaxMailSize() ; | 438 | int max = data->getMaxMailSize() ; |
426 | if ( max ) { | 439 | if ( max ) { |
427 | CheckBoxDown->setChecked( true ); | 440 | CheckBoxDown->setChecked( true ); |
428 | SpinBoxDown->setValue ( max ); | 441 | SpinBoxDown->setValue ( max ); |
429 | } else { | 442 | } else { |
430 | CheckBoxDown->setChecked( false ); | 443 | CheckBoxDown->setChecked( false ); |
431 | SpinBoxDown->setValue ( 5 ); | 444 | SpinBoxDown->setValue ( 5 ); |
432 | } | 445 | } |
446 | CheckBoxLeaveOn->setChecked( data->getLeaveOnServer() ); | ||
433 | } | 447 | } |
434 | 448 | ||
435 | void POP3config::accept() | 449 | void POP3config::accept() |
436 | { | 450 | { |
437 | data->setAccountName( accountLine->text() ); | 451 | data->setAccountName( accountLine->text() ); |
438 | data->setServer( serverLine->text() ); | 452 | data->setServer( serverLine->text() ); |
439 | data->setPort( portLine->text() ); | 453 | data->setPort( portLine->text() ); |
440 | data->setConnectionType( ComboBox1->currentItem() ); | 454 | data->setConnectionType( ComboBox1->currentItem() ); |
441 | data->setUser( userLine->text() ); | 455 | data->setUser( userLine->text() ); |
442 | data->setPassword( passLine->text() ); | 456 | data->setPassword( passLine->text() ); |
443 | data->setLocalFolder( localFolder->text() ); | 457 | data->setLocalFolder( localFolder->text() ); |
444 | data->setMaxMailSize( CheckBoxDown->isChecked()?SpinBoxDown->value():0 ) ; | 458 | data->setMaxMailSize( CheckBoxDown->isChecked()?SpinBoxDown->value():0 ) ; |
459 | data->setLeaveOnServer( CheckBoxLeaveOn->isChecked() ); | ||
445 | 460 | ||
446 | QDialog::accept(); | 461 | QDialog::accept(); |
447 | } | 462 | } |
448 | 463 | ||
449 | /** | 464 | /** |
450 | * SMTPconfig | 465 | * SMTPconfig |
451 | */ | 466 | */ |
452 | 467 | ||
453 | 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 ) |
454 | : SMTPconfigUI( parent, name, modal, flags ) | 469 | : SMTPconfigUI( parent, name, modal, flags ) |
455 | { | 470 | { |
456 | data = account; | 471 | data = account; |
457 | 472 | ||
458 | connect( loginBox, SIGNAL( toggled(bool) ), userLine, SLOT( setEnabled(bool) ) ); | 473 | connect( loginBox, SIGNAL( toggled(bool) ), userLine, SLOT( setEnabled(bool) ) ); |
459 | connect( loginBox, SIGNAL( toggled(bool) ), passLine, SLOT( setEnabled(bool) ) ); | 474 | connect( loginBox, SIGNAL( toggled(bool) ), passLine, SLOT( setEnabled(bool) ) ); |
460 | 475 | ||
461 | fillValues(); | 476 | fillValues(); |
462 | 477 | ||
463 | connect( ComboBox1, SIGNAL( activated(int) ), SLOT( slotConnectionToggle(int) ) ); | 478 | connect( ComboBox1, SIGNAL( activated(int) ), SLOT( slotConnectionToggle(int) ) ); |
464 | ComboBox1->insertItem( "Only if available", 0 ); | 479 | ComboBox1->insertItem( "Only if available", 0 ); |
465 | ComboBox1->insertItem( "Always, Negotiated", 1 ); | 480 | ComboBox1->insertItem( "Always, Negotiated", 1 ); |
466 | ComboBox1->insertItem( "Connect on secure port", 2 ); | 481 | ComboBox1->insertItem( "Connect on secure port", 2 ); |
467 | ComboBox1->insertItem( "Run command instead", 3 ); | 482 | ComboBox1->insertItem( "Run command instead", 3 ); |
468 | CommandEdit->hide(); | 483 | CommandEdit->hide(); |
469 | ComboBox1->setCurrentItem( data->ConnectionType() ); | 484 | ComboBox1->setCurrentItem( data->ConnectionType() ); |
470 | } | 485 | } |
471 | 486 | ||
472 | void SMTPconfig::slotConnectionToggle( int index ) | 487 | void SMTPconfig::slotConnectionToggle( int index ) |
473 | { | 488 | { |
474 | // 2 is ssl connection | 489 | // 2 is ssl connection |
475 | if ( index == 2 ) | 490 | if ( index == 2 ) |
476 | { | 491 | { |
477 | portLine->setText( SMTP_SSL_PORT ); | 492 | portLine->setText( SMTP_SSL_PORT ); |
478 | } | 493 | } |
479 | else if ( index == 3 ) | 494 | else if ( index == 3 ) |
480 | { | 495 | { |
481 | portLine->setText( SMTP_PORT ); | 496 | portLine->setText( SMTP_PORT ); |
482 | CommandEdit->show(); | 497 | CommandEdit->show(); |
483 | } | 498 | } |
484 | else | 499 | else |
485 | { | 500 | { |
486 | portLine->setText( SMTP_PORT ); | 501 | portLine->setText( SMTP_PORT ); |
487 | } | 502 | } |
488 | } | 503 | } |
489 | 504 | ||
490 | void SMTPconfig::fillValues() | 505 | void SMTPconfig::fillValues() |
491 | { | 506 | { |
492 | accountLine->setText( data->getAccountName() ); | 507 | accountLine->setText( data->getAccountName() ); |
493 | serverLine->setText( data->getServer() ); | 508 | serverLine->setText( data->getServer() ); |
494 | portLine->setText( data->getPort() ); | 509 | portLine->setText( data->getPort() ); |
495 | ComboBox1->setCurrentItem( data->ConnectionType() ); | 510 | ComboBox1->setCurrentItem( data->ConnectionType() ); |
496 | loginBox->setChecked( data->getLogin() ); | 511 | loginBox->setChecked( data->getLogin() ); |
497 | userLine->setText( data->getUser() ); | 512 | userLine->setText( data->getUser() ); |
498 | passLine->setText( data->getPassword() ); | 513 | passLine->setText( data->getPassword() ); |
499 | } | 514 | } |
500 | 515 | ||
501 | void SMTPconfig::accept() | 516 | void SMTPconfig::accept() |
502 | { | 517 | { |
503 | data->setAccountName( accountLine->text() ); | 518 | data->setAccountName( accountLine->text() ); |
504 | data->setServer( serverLine->text() ); | 519 | data->setServer( serverLine->text() ); |
505 | data->setPort( portLine->text() ); | 520 | data->setPort( portLine->text() ); |
506 | data->setConnectionType( ComboBox1->currentItem() ); | 521 | data->setConnectionType( ComboBox1->currentItem() ); |
507 | data->setLogin( loginBox->isChecked() ); | 522 | data->setLogin( loginBox->isChecked() ); |
508 | data->setUser( userLine->text() ); | 523 | data->setUser( userLine->text() ); |
509 | data->setPassword( passLine->text() ); | 524 | data->setPassword( passLine->text() ); |
510 | 525 | ||
511 | QDialog::accept(); | 526 | QDialog::accept(); |
512 | } | 527 | } |
513 | 528 | ||
514 | /** | 529 | /** |
515 | * NNTPconfig | 530 | * NNTPconfig |
516 | */ | 531 | */ |
517 | 532 | ||
518 | 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 ) |
519 | : NNTPconfigUI( parent, name, modal, flags ) | 534 | : NNTPconfigUI( parent, name, modal, flags ) |
520 | { | 535 | { |
521 | data = account; | 536 | data = account; |
522 | 537 | ||
523 | connect( loginBox, SIGNAL( toggled(bool) ), userLine, SLOT( setEnabled(bool) ) ); | 538 | connect( loginBox, SIGNAL( toggled(bool) ), userLine, SLOT( setEnabled(bool) ) ); |
524 | connect( loginBox, SIGNAL( toggled(bool) ), passLine, SLOT( setEnabled(bool) ) ); | 539 | connect( loginBox, SIGNAL( toggled(bool) ), passLine, SLOT( setEnabled(bool) ) ); |
525 | connect( GetNGButton, SIGNAL( clicked() ), this, SLOT( slotGetNG() ) ); | 540 | connect( GetNGButton, SIGNAL( clicked() ), this, SLOT( slotGetNG() ) ); |
526 | fillValues(); | 541 | fillValues(); |
527 | 542 | ||
528 | connect( sslBox, SIGNAL( toggled(bool) ), SLOT( slotSSL(bool) ) ); | 543 | connect( sslBox, SIGNAL( toggled(bool) ), SLOT( slotSSL(bool) ) ); |
529 | } | 544 | } |
530 | 545 | ||
531 | void NNTPconfig::slotGetNG() { | 546 | void NNTPconfig::slotGetNG() { |
532 | save(); | 547 | save(); |
533 | data->save(); | 548 | data->save(); |
534 | NNTPwrapper* tmp = new NNTPwrapper( data ); | 549 | NNTPwrapper* tmp = new NNTPwrapper( data ); |
535 | QStringList list = tmp->listAllNewsgroups(); | 550 | QStringList list = tmp->listAllNewsgroups(); |
536 | 551 | ||
537 | ListViewGroups->clear(); | 552 | ListViewGroups->clear(); |
538 | 553 | ||
539 | for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { | 554 | for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { |
540 | QCheckListItem *item; | 555 | QCheckListItem *item; |
541 | item = new QCheckListItem( ListViewGroups, (*it), QCheckListItem::CheckBox ); | 556 | item = new QCheckListItem( ListViewGroups, (*it), QCheckListItem::CheckBox ); |
542 | if ( subscribedGroups.contains( (*it) ) >= 1 ) { | 557 | if ( subscribedGroups.contains( (*it) ) >= 1 ) { |
543 | item->setOn( true ); | 558 | item->setOn( true ); |
544 | } | 559 | } |
545 | } | 560 | } |
546 | } | 561 | } |
547 | 562 | ||
548 | void NNTPconfig::slotSSL( bool enabled ) | 563 | void NNTPconfig::slotSSL( bool enabled ) |
549 | { | 564 | { |
550 | if ( enabled ) | 565 | if ( enabled ) |
551 | { | 566 | { |
552 | portLine->setText( NNTP_SSL_PORT ); | 567 | portLine->setText( NNTP_SSL_PORT ); |
553 | } | 568 | } |
554 | else | 569 | else |
555 | { | 570 | { |
556 | portLine->setText( NNTP_PORT ); | 571 | portLine->setText( NNTP_PORT ); |
557 | } | 572 | } |
558 | } | 573 | } |
559 | 574 | ||
560 | void NNTPconfig::fillValues() | 575 | void NNTPconfig::fillValues() |
561 | { | 576 | { |
562 | accountLine->setText( data->getAccountName() ); | 577 | accountLine->setText( data->getAccountName() ); |
563 | serverLine->setText( data->getServer() ); | 578 | serverLine->setText( data->getServer() ); |
564 | portLine->setText( data->getPort() ); | 579 | portLine->setText( data->getPort() ); |
565 | sslBox->setChecked( data->getSSL() ); | 580 | sslBox->setChecked( data->getSSL() ); |
566 | loginBox->setChecked( data->getLogin() ); | 581 | loginBox->setChecked( data->getLogin() ); |
567 | userLine->setText( data->getUser() ); | 582 | userLine->setText( data->getUser() ); |
568 | passLine->setText( data->getPassword() ); | 583 | passLine->setText( data->getPassword() ); |
569 | subscribedGroups = data->getGroups(); | 584 | subscribedGroups = data->getGroups(); |
570 | /* don't forget that - you will overwrite values if user clicks cancel! */ | 585 | /* don't forget that - you will overwrite values if user clicks cancel! */ |
571 | for ( QStringList::Iterator it = subscribedGroups.begin(); it != subscribedGroups.end(); ++it ) { | 586 | for ( QStringList::Iterator it = subscribedGroups.begin(); it != subscribedGroups.end(); ++it ) { |
572 | QCheckListItem *item; | 587 | QCheckListItem *item; |
573 | item = new QCheckListItem( ListViewGroups, (*it), QCheckListItem::CheckBox ); | 588 | item = new QCheckListItem( ListViewGroups, (*it), QCheckListItem::CheckBox ); |
574 | item->setOn( true ); | 589 | item->setOn( true ); |
575 | } | 590 | } |
576 | } | 591 | } |
577 | 592 | ||
578 | void NNTPconfig::save() | 593 | void NNTPconfig::save() |
579 | { | 594 | { |
580 | data->setAccountName( accountLine->text() ); | 595 | data->setAccountName( accountLine->text() ); |
581 | data->setServer( serverLine->text() ); | 596 | data->setServer( serverLine->text() ); |
582 | data->setPort( portLine->text() ); | 597 | data->setPort( portLine->text() ); |
583 | data->setSSL( sslBox->isChecked() ); | 598 | data->setSSL( sslBox->isChecked() ); |
584 | data->setLogin( loginBox->isChecked() ); | 599 | data->setLogin( loginBox->isChecked() ); |
585 | data->setUser( userLine->text() ); | 600 | data->setUser( userLine->text() ); |
586 | data->setPassword( passLine->text() ); | 601 | data->setPassword( passLine->text() ); |
587 | 602 | ||
588 | QListViewItemIterator list_it( ListViewGroups ); | 603 | QListViewItemIterator list_it( ListViewGroups ); |
589 | 604 | ||
590 | QStringList groupList; | 605 | QStringList groupList; |
591 | for ( ; list_it.current(); ++list_it ) { | 606 | for ( ; list_it.current(); ++list_it ) { |
592 | 607 | ||
593 | if ( ( (QCheckListItem*)list_it.current() )->isOn() ) { | 608 | if ( ( (QCheckListItem*)list_it.current() )->isOn() ) { |
594 | groupList.append( list_it.current()->text(0) ); | 609 | groupList.append( list_it.current()->text(0) ); |
595 | } | 610 | } |
596 | 611 | ||
597 | } | 612 | } |
598 | data->setGroups( groupList ); | 613 | data->setGroups( groupList ); |
599 | } | 614 | } |
600 | 615 | ||
601 | void NNTPconfig::accept() | 616 | void NNTPconfig::accept() |
602 | { | 617 | { |
603 | save(); | 618 | save(); |
604 | QDialog::accept(); | 619 | QDialog::accept(); |
605 | } | 620 | } |
606 | 621 | ||