-rw-r--r-- | kmicromail/editaccounts.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/kmicromail/editaccounts.cpp b/kmicromail/editaccounts.cpp index 0d30097..48c3963 100644 --- a/kmicromail/editaccounts.cpp +++ b/kmicromail/editaccounts.cpp | |||
@@ -1,302 +1,305 @@ | |||
1 | 1 | ||
2 | #include <qdialog.h> | 2 | #include <qdialog.h> |
3 | #include "kapplication.h" | 3 | #include "kapplication.h" |
4 | #include "defines.h" | 4 | #include "defines.h" |
5 | #include "editaccounts.h" | 5 | #include "editaccounts.h" |
6 | /* OPIE */ | 6 | /* OPIE */ |
7 | #include <qpe/qpeapplication.h> | 7 | #include <qpe/qpeapplication.h> |
8 | 8 | ||
9 | /* QT */ | 9 | /* QT */ |
10 | #include <qstringlist.h> | 10 | #include <qstringlist.h> |
11 | 11 | ||
12 | #include <qcombobox.h> | 12 | #include <qcombobox.h> |
13 | #include <qcheckbox.h> | 13 | #include <qcheckbox.h> |
14 | #include <qmessagebox.h> | 14 | #include <qmessagebox.h> |
15 | #include <qpushbutton.h> | 15 | #include <qpushbutton.h> |
16 | #include <qlineedit.h> | 16 | #include <qlineedit.h> |
17 | #include <qlabel.h> | 17 | #include <qlabel.h> |
18 | #include <qtabwidget.h> | 18 | #include <qtabwidget.h> |
19 | #include <qlistview.h> | 19 | #include <qlistview.h> |
20 | #include <qspinbox.h> | 20 | #include <qspinbox.h> |
21 | #include <klocale.h> | 21 | #include <klocale.h> |
22 | 22 | ||
23 | #include <libmailwrapper/nntpwrapper.h> | 23 | #include <libmailwrapper/nntpwrapper.h> |
24 | 24 | ||
25 | using namespace Opie::Core; | 25 | using namespace Opie::Core; |
26 | 26 | ||
27 | AccountListItem::AccountListItem( QListView *parent, Account *a) | 27 | AccountListItem::AccountListItem( QListView *parent, Account *a) |
28 | : QListViewItem( parent ) | 28 | : QListViewItem( parent ) |
29 | { | 29 | { |
30 | account = a; | 30 | account = a; |
31 | setText( 0, account->getAccountName() ); | 31 | setText( 0, account->getAccountName() ); |
32 | QString ttext = ""; | 32 | QString ttext = ""; |
33 | switch (account->getType()) { | 33 | switch (account->getType()) { |
34 | case MAILLIB::A_NNTP: | 34 | case MAILLIB::A_NNTP: |
35 | ttext="NNTP"; | 35 | ttext="NNTP"; |
36 | break; | 36 | break; |
37 | case MAILLIB::A_POP3: | 37 | case MAILLIB::A_POP3: |
38 | ttext = "POP3"; | 38 | ttext = "POP3"; |
39 | break; | 39 | break; |
40 | case MAILLIB::A_IMAP: | 40 | case MAILLIB::A_IMAP: |
41 | ttext = "IMAP"; | 41 | ttext = "IMAP"; |
42 | break; | 42 | break; |
43 | case MAILLIB::A_SMTP: | 43 | case MAILLIB::A_SMTP: |
44 | ttext = "SMTP"; | 44 | ttext = "SMTP"; |
45 | break; | 45 | break; |
46 | default: | 46 | default: |
47 | ttext = "UNKNOWN"; | 47 | ttext = "UNKNOWN"; |
48 | break; | 48 | break; |
49 | } | 49 | } |
50 | setText( 1, ttext); | 50 | setText( 1, ttext); |
51 | } | 51 | } |
52 | 52 | ||
53 | EditAccounts::EditAccounts( Settings *s, QWidget *parent, const char *name, bool modal, WFlags flags ) | 53 | EditAccounts::EditAccounts( Settings *s, QWidget *parent, const char *name, bool modal, WFlags flags ) |
54 | : EditAccountsUI( parent, name, modal, flags ) | 54 | : EditAccountsUI( parent, name, modal, flags ) |
55 | { | 55 | { |
56 | settings = s; | 56 | settings = s; |
57 | 57 | ||
58 | mailList->addColumn( i18n( "Account" ) ); | 58 | mailList->addColumn( i18n( "Account" ) ); |
59 | mailList->addColumn( i18n( "Type" ) ); | 59 | mailList->addColumn( i18n( "Type" ) ); |
60 | 60 | ||
61 | newsList->addColumn( i18n( "Account" ) ); | 61 | newsList->addColumn( i18n( "Account" ) ); |
62 | 62 | ||
63 | connect( newMail, SIGNAL( clicked() ), SLOT( slotNewMail() ) ); | 63 | connect( newMail, SIGNAL( clicked() ), SLOT( slotNewMail() ) ); |
64 | connect( editMail, SIGNAL( clicked() ), SLOT( slotEditMail() ) ); | 64 | connect( editMail, SIGNAL( clicked() ), SLOT( slotEditMail() ) ); |
65 | connect( deleteMail, SIGNAL( clicked() ), SLOT( slotDeleteMail() ) ); | 65 | connect( deleteMail, SIGNAL( clicked() ), SLOT( slotDeleteMail() ) ); |
66 | connect( newNews, SIGNAL( clicked() ), SLOT( slotNewNews() ) ); | 66 | connect( newNews, SIGNAL( clicked() ), SLOT( slotNewNews() ) ); |
67 | connect( editNews, SIGNAL( clicked() ), SLOT( slotEditNews() ) ); | 67 | connect( editNews, SIGNAL( clicked() ), SLOT( slotEditNews() ) ); |
68 | connect( deleteNews, SIGNAL( clicked() ), SLOT( slotDeleteNews() ) ); | 68 | connect( deleteNews, SIGNAL( clicked() ), SLOT( slotDeleteNews() ) ); |
69 | 69 | ||
70 | slotFillLists(); | 70 | slotFillLists(); |
71 | } | 71 | } |
72 | 72 | ||
73 | void EditAccounts::slotFillLists() | 73 | void EditAccounts::slotFillLists() |
74 | { | 74 | { |
75 | mailList->clear(); | 75 | mailList->clear(); |
76 | newsList->clear(); | 76 | newsList->clear(); |
77 | 77 | ||
78 | QList<Account> accounts = settings->getAccounts(); | 78 | QList<Account> accounts = settings->getAccounts(); |
79 | Account *it; | 79 | Account *it; |
80 | for ( it = accounts.first(); it; it = accounts.next() ) | 80 | for ( it = accounts.first(); it; it = accounts.next() ) |
81 | { | 81 | { |
82 | if ( it->getType()==MAILLIB::A_NNTP ) | 82 | if ( it->getType()==MAILLIB::A_NNTP ) |
83 | { | 83 | { |
84 | (void) new AccountListItem( newsList, it ); | 84 | (void) new AccountListItem( newsList, it ); |
85 | } | 85 | } |
86 | else | 86 | else |
87 | { | 87 | { |
88 | (void) new AccountListItem( mailList, it ); | 88 | (void) new AccountListItem( mailList, it ); |
89 | } | 89 | } |
90 | } | 90 | } |
91 | } | 91 | } |
92 | 92 | ||
93 | void EditAccounts::slotNewMail() | 93 | void EditAccounts::slotNewMail() |
94 | { | 94 | { |
95 | QString *selection = new QString(); | 95 | QString *selection = new QString(); |
96 | SelectMailType selType( selection, this, 0, true ); | 96 | SelectMailType selType( selection, this, 0, true ); |
97 | selType.show(); | 97 | selType.show(); |
98 | if ( QDialog::Accepted == selType.exec() ) | 98 | if ( QDialog::Accepted == selType.exec() ) |
99 | { | 99 | { |
100 | slotNewAccount( *selection ); | 100 | slotNewAccount( *selection ); |
101 | } | 101 | } |
102 | } | 102 | } |
103 | 103 | ||
104 | void EditAccounts::slotNewAccount( const QString &type ) | 104 | void EditAccounts::slotNewAccount( const QString &type ) |
105 | { | 105 | { |
106 | if ( type.compare( i18n("IMAP") ) == 0 ) | 106 | if ( type.compare( i18n("IMAP") ) == 0 ) |
107 | { | 107 | { |
108 | IMAPaccount *account = new IMAPaccount(); | 108 | IMAPaccount *account = new IMAPaccount(); |
109 | IMAPconfig imap( account, this, 0, true ); | 109 | IMAPconfig imap( account, this, 0, true ); |
110 | |||
111 | #ifndef DESKTOP_VERSION | ||
110 | imap.showMaximized(); | 112 | imap.showMaximized(); |
113 | #endif | ||
111 | if ( QDialog::Accepted == imap.exec() ) | 114 | if ( QDialog::Accepted == imap.exec() ) |
112 | { | 115 | { |
113 | settings->addAccount( account ); | 116 | settings->addAccount( account ); |
114 | account->save(); | 117 | account->save(); |
115 | slotFillLists(); | 118 | slotFillLists(); |
116 | } | 119 | } |
117 | else | 120 | else |
118 | { | 121 | { |
119 | account->remove(); | 122 | account->remove(); |
120 | } | 123 | } |
121 | } | 124 | } |
122 | else if ( type.compare( i18n("POP3") ) == 0 ) | 125 | else if ( type.compare( i18n("POP3") ) == 0 ) |
123 | { | 126 | { |
124 | POP3account *account = new POP3account(); | 127 | POP3account *account = new POP3account(); |
125 | POP3config pop3( account, this, 0, true, WStyle_ContextHelp ); | 128 | POP3config pop3( account, this, 0, true, WStyle_ContextHelp ); |
126 | if ( QDialog::Accepted == KApplication::execDialog( &pop3 ) ) | 129 | if ( QDialog::Accepted == KApplication::execDialog( &pop3 ) ) |
127 | { | 130 | { |
128 | settings->addAccount( account ); | 131 | settings->addAccount( account ); |
129 | account->save(); | 132 | account->save(); |
130 | slotFillLists(); | 133 | slotFillLists(); |
131 | } | 134 | } |
132 | else | 135 | else |
133 | { | 136 | { |
134 | account->remove(); | 137 | account->remove(); |
135 | } | 138 | } |
136 | } | 139 | } |
137 | else if ( type.compare( i18n("SMTP") ) == 0 ) | 140 | else if ( type.compare( i18n("SMTP") ) == 0 ) |
138 | { | 141 | { |
139 | SMTPaccount *account = new SMTPaccount(); | 142 | SMTPaccount *account = new SMTPaccount(); |
140 | SMTPconfig smtp( account, this, 0, true, WStyle_ContextHelp ); | 143 | SMTPconfig smtp( account, this, 0, true, WStyle_ContextHelp ); |
141 | if ( QDialog::Accepted == KApplication::execDialog( &smtp ) ) | 144 | if ( QDialog::Accepted == KApplication::execDialog( &smtp ) ) |
142 | { | 145 | { |
143 | settings->addAccount( account ); | 146 | settings->addAccount( account ); |
144 | account->save(); | 147 | account->save(); |
145 | slotFillLists(); | 148 | slotFillLists(); |
146 | 149 | ||
147 | } | 150 | } |
148 | else | 151 | else |
149 | { | 152 | { |
150 | account->remove(); | 153 | account->remove(); |
151 | } | 154 | } |
152 | } | 155 | } |
153 | else if ( type.compare( i18n("NNTP") ) == 0 ) | 156 | else if ( type.compare( i18n("NNTP") ) == 0 ) |
154 | { | 157 | { |
155 | NNTPaccount *account = new NNTPaccount(); | 158 | NNTPaccount *account = new NNTPaccount(); |
156 | NNTPconfig nntp( account, this, 0, true, WStyle_ContextHelp ); | 159 | NNTPconfig nntp( account, this, 0, true, WStyle_ContextHelp ); |
157 | if ( QDialog::Accepted == KApplication::execDialog( &nntp ) ) | 160 | if ( QDialog::Accepted == KApplication::execDialog( &nntp ) ) |
158 | { | 161 | { |
159 | settings->addAccount( account ); | 162 | settings->addAccount( account ); |
160 | account->save(); | 163 | account->save(); |
161 | slotFillLists(); | 164 | slotFillLists(); |
162 | } | 165 | } |
163 | else | 166 | else |
164 | { | 167 | { |
165 | account->remove(); | 168 | account->remove(); |
166 | } | 169 | } |
167 | } | 170 | } |
168 | } | 171 | } |
169 | 172 | ||
170 | void EditAccounts::slotEditAccount( Account *account ) | 173 | void EditAccounts::slotEditAccount( Account *account ) |
171 | { | 174 | { |
172 | if ( account->getType() == MAILLIB::A_IMAP ) | 175 | if ( account->getType() == MAILLIB::A_IMAP ) |
173 | { | 176 | { |
174 | IMAPaccount *imapAcc = static_cast<IMAPaccount *>(account); | 177 | IMAPaccount *imapAcc = static_cast<IMAPaccount *>(account); |
175 | IMAPconfig imap( imapAcc, this, 0, true, WStyle_ContextHelp ); | 178 | IMAPconfig imap( imapAcc, this, 0, true, WStyle_ContextHelp ); |
176 | if ( QDialog::Accepted == KApplication::execDialog( &imap ) ) | 179 | if ( QDialog::Accepted == KApplication::execDialog( &imap ) ) |
177 | { | 180 | { |
178 | slotFillLists(); | 181 | slotFillLists(); |
179 | } | 182 | } |
180 | } | 183 | } |
181 | else if ( account->getType()==MAILLIB::A_POP3 ) | 184 | else if ( account->getType()==MAILLIB::A_POP3 ) |
182 | { | 185 | { |
183 | POP3account *pop3Acc = static_cast<POP3account *>(account); | 186 | POP3account *pop3Acc = static_cast<POP3account *>(account); |
184 | POP3config pop3( pop3Acc, this, 0, true, WStyle_ContextHelp ); | 187 | POP3config pop3( pop3Acc, this, 0, true, WStyle_ContextHelp ); |
185 | if ( QDialog::Accepted == KApplication::execDialog( &pop3 ) ) | 188 | if ( QDialog::Accepted == KApplication::execDialog( &pop3 ) ) |
186 | { | 189 | { |
187 | slotFillLists(); | 190 | slotFillLists(); |
188 | } | 191 | } |
189 | } | 192 | } |
190 | else if ( account->getType()==MAILLIB::A_SMTP ) | 193 | else if ( account->getType()==MAILLIB::A_SMTP ) |
191 | { | 194 | { |
192 | SMTPaccount *smtpAcc = static_cast<SMTPaccount *>(account); | 195 | SMTPaccount *smtpAcc = static_cast<SMTPaccount *>(account); |
193 | SMTPconfig smtp( smtpAcc, this, 0, true, WStyle_ContextHelp ); | 196 | SMTPconfig smtp( smtpAcc, this, 0, true, WStyle_ContextHelp ); |
194 | if ( QDialog::Accepted == KApplication::execDialog( &smtp ) ) | 197 | if ( QDialog::Accepted == KApplication::execDialog( &smtp ) ) |
195 | { | 198 | { |
196 | slotFillLists(); | 199 | slotFillLists(); |
197 | } | 200 | } |
198 | } | 201 | } |
199 | else if ( account->getType()==MAILLIB::A_NNTP) | 202 | else if ( account->getType()==MAILLIB::A_NNTP) |
200 | { | 203 | { |
201 | NNTPaccount *nntpAcc = static_cast<NNTPaccount *>(account); | 204 | NNTPaccount *nntpAcc = static_cast<NNTPaccount *>(account); |
202 | NNTPconfig nntp( nntpAcc, this, 0, true, WStyle_ContextHelp ); | 205 | NNTPconfig nntp( nntpAcc, this, 0, true, WStyle_ContextHelp ); |
203 | if ( QDialog::Accepted == KApplication::execDialog( &nntp ) ) | 206 | if ( QDialog::Accepted == KApplication::execDialog( &nntp ) ) |
204 | { | 207 | { |
205 | slotFillLists(); | 208 | slotFillLists(); |
206 | } | 209 | } |
207 | } | 210 | } |
208 | } | 211 | } |
209 | 212 | ||
210 | void EditAccounts::slotDeleteAccount( Account *account ) | 213 | void EditAccounts::slotDeleteAccount( Account *account ) |
211 | { | 214 | { |
212 | if ( QMessageBox::information( this, i18n( "Question" ), | 215 | if ( QMessageBox::information( this, i18n( "Question" ), |
213 | i18n( "<p>Do you really want to delete the selected Account?</p>" ), | 216 | i18n( "<p>Do you really want to delete the selected Account?</p>" ), |
214 | i18n( "Yes" ), i18n( "No" ) ) == 0 ) | 217 | i18n( "Yes" ), i18n( "No" ) ) == 0 ) |
215 | { | 218 | { |
216 | settings->delAccount( account ); | 219 | settings->delAccount( account ); |
217 | slotFillLists(); | 220 | slotFillLists(); |
218 | } | 221 | } |
219 | } | 222 | } |
220 | 223 | ||
221 | void EditAccounts::slotEditMail() | 224 | void EditAccounts::slotEditMail() |
222 | { | 225 | { |
223 | if ( !mailList->currentItem() ) | 226 | if ( !mailList->currentItem() ) |
224 | { | 227 | { |
225 | QMessageBox::information( this, i18n( "Error" ), | 228 | QMessageBox::information( this, i18n( "Error" ), |
226 | i18n( "<p>Please select an account.</p>" ), | 229 | i18n( "<p>Please select an account.</p>" ), |
227 | i18n( "Ok" ) ); | 230 | i18n( "Ok" ) ); |
228 | return; | 231 | return; |
229 | } | 232 | } |
230 | 233 | ||
231 | Account *a = ((AccountListItem *) mailList->currentItem())->getAccount(); | 234 | Account *a = ((AccountListItem *) mailList->currentItem())->getAccount(); |
232 | slotEditAccount( a ); | 235 | slotEditAccount( a ); |
233 | } | 236 | } |
234 | 237 | ||
235 | void EditAccounts::slotDeleteMail() | 238 | void EditAccounts::slotDeleteMail() |
236 | { | 239 | { |
237 | if ( !mailList->currentItem() ) | 240 | if ( !mailList->currentItem() ) |
238 | { | 241 | { |
239 | QMessageBox::information( this, i18n( "Error" ), | 242 | QMessageBox::information( this, i18n( "Error" ), |
240 | i18n( "<p>Please select an account.</p>" ), | 243 | i18n( "<p>Please select an account.</p>" ), |
241 | i18n( "Ok" ) ); | 244 | i18n( "Ok" ) ); |
242 | return; | 245 | return; |
243 | } | 246 | } |
244 | 247 | ||
245 | Account *a = ((AccountListItem *) mailList->currentItem())->getAccount(); | 248 | Account *a = ((AccountListItem *) mailList->currentItem())->getAccount(); |
246 | slotDeleteAccount( a ); | 249 | slotDeleteAccount( a ); |
247 | } | 250 | } |
248 | 251 | ||
249 | void EditAccounts::slotNewNews() | 252 | void EditAccounts::slotNewNews() |
250 | { | 253 | { |
251 | slotNewAccount( "NNTP" ); | 254 | slotNewAccount( "NNTP" ); |
252 | } | 255 | } |
253 | 256 | ||
254 | void EditAccounts::slotEditNews() | 257 | void EditAccounts::slotEditNews() |
255 | { | 258 | { |
256 | if ( !newsList->currentItem() ) | 259 | if ( !newsList->currentItem() ) |
257 | { | 260 | { |
258 | QMessageBox::information( this, i18n( "Error" ), | 261 | QMessageBox::information( this, i18n( "Error" ), |
259 | i18n( "<p>Please select an account.</p>" ), | 262 | i18n( "<p>Please select an account.</p>" ), |
260 | i18n( "Ok" ) ); | 263 | i18n( "Ok" ) ); |
261 | return; | 264 | return; |
262 | } | 265 | } |
263 | 266 | ||
264 | Account *a = ((AccountListItem *) newsList->currentItem())->getAccount(); | 267 | Account *a = ((AccountListItem *) newsList->currentItem())->getAccount(); |
265 | slotEditAccount( a ); | 268 | slotEditAccount( a ); |
266 | } | 269 | } |
267 | 270 | ||
268 | void EditAccounts::slotDeleteNews() | 271 | void EditAccounts::slotDeleteNews() |
269 | { | 272 | { |
270 | if ( !newsList->currentItem() ) | 273 | if ( !newsList->currentItem() ) |
271 | { | 274 | { |
272 | QMessageBox::information( this, i18n( "Error" ), | 275 | QMessageBox::information( this, i18n( "Error" ), |
273 | i18n( "<p>Please select an account.</p>" ), | 276 | i18n( "<p>Please select an account.</p>" ), |
274 | i18n( "Ok" ) ); | 277 | i18n( "Ok" ) ); |
275 | return; | 278 | return; |
276 | } | 279 | } |
277 | 280 | ||
278 | Account *a = ((AccountListItem *) newsList->currentItem())->getAccount(); | 281 | Account *a = ((AccountListItem *) newsList->currentItem())->getAccount(); |
279 | slotDeleteAccount( a ); | 282 | slotDeleteAccount( a ); |
280 | } | 283 | } |
281 | 284 | ||
282 | void EditAccounts::slotAdjustColumns() | 285 | void EditAccounts::slotAdjustColumns() |
283 | { | 286 | { |
284 | int currPage = configTab->currentPageIndex(); | 287 | int currPage = configTab->currentPageIndex(); |
285 | 288 | ||
286 | configTab->showPage( mailTab ); | 289 | configTab->showPage( mailTab ); |
287 | mailList->setColumnWidth( 0, mailList->visibleWidth() - 50 ); | 290 | mailList->setColumnWidth( 0, mailList->visibleWidth() - 50 ); |
288 | mailList->setColumnWidth( 1, 50 ); | 291 | mailList->setColumnWidth( 1, 50 ); |
289 | 292 | ||
290 | configTab->showPage( newsTab ); | 293 | configTab->showPage( newsTab ); |
291 | newsList->setColumnWidth( 0, newsList->visibleWidth() ); | 294 | newsList->setColumnWidth( 0, newsList->visibleWidth() ); |
292 | 295 | ||
293 | configTab->setCurrentPage( currPage ); | 296 | configTab->setCurrentPage( currPage ); |
294 | } | 297 | } |
295 | 298 | ||
296 | void EditAccounts::accept() | 299 | void EditAccounts::accept() |
297 | { | 300 | { |
298 | settings->saveAccounts(); | 301 | settings->saveAccounts(); |
299 | 302 | ||
300 | QDialog::accept(); | 303 | QDialog::accept(); |
301 | } | 304 | } |
302 | 305 | ||