-rw-r--r-- | kmicromail/accountitem.cpp | 128 |
1 files changed, 65 insertions, 63 deletions
diff --git a/kmicromail/accountitem.cpp b/kmicromail/accountitem.cpp index 985a762..9b1ea2f 100644 --- a/kmicromail/accountitem.cpp +++ b/kmicromail/accountitem.cpp | |||
@@ -1,1187 +1,1189 @@ | |||
1 | 1 | ||
2 | #include "accountitem.h" | 2 | #include "accountitem.h" |
3 | #include "accountview.h" | 3 | #include "accountview.h" |
4 | #include "newmaildir.h" | 4 | #include "newmaildir.h" |
5 | #include "nntpgroupsdlg.h" | 5 | #include "nntpgroupsdlg.h" |
6 | #include "defines.h" | 6 | #include "defines.h" |
7 | 7 | ||
8 | #include <libmailwrapper/mailtypes.h> | 8 | #include <libmailwrapper/mailtypes.h> |
9 | #include <libmailwrapper/abstractmail.h> | 9 | #include <libmailwrapper/abstractmail.h> |
10 | #include <libmailwrapper/mailwrapper.h> | 10 | #include <libmailwrapper/mailwrapper.h> |
11 | /* OPIE */ | 11 | /* OPIE */ |
12 | //#include <qpe/qpeapplication.h> | 12 | //#include <qpe/qpeapplication.h> |
13 | 13 | ||
14 | /* QT */ | 14 | /* QT */ |
15 | #include <qpopupmenu.h> | 15 | #include <q3popupmenu.h> |
16 | #include <qmessagebox.h> | 16 | #include <qmessagebox.h> |
17 | //Added by qt3to4: | ||
18 | #include <Q3ValueList> | ||
17 | #include <kiconloader.h> | 19 | #include <kiconloader.h> |
18 | #include <klocale.h> | 20 | #include <klocale.h> |
19 | 21 | ||
20 | #define GET_NEW_MAILS 101 | 22 | #define GET_NEW_MAILS 101 |
21 | 23 | ||
22 | using namespace Opie::Core; | 24 | using namespace Opie::Core; |
23 | #define SETPIX(x) if (!account->getOffline()) {setPixmap( 0,x);} else {setPixmap( 0, PIXMAP_OFFLINE );} | 25 | #define SETPIX(x) if (!account->getOffline()) {setPixmap( 0,x);} else {setPixmap( 0, PIXMAP_OFFLINE );} |
24 | /** | 26 | /** |
25 | * POP3 Account stuff | 27 | * POP3 Account stuff |
26 | */ | 28 | */ |
27 | POP3viewItem::POP3viewItem( POP3account *a, AccountView *parent ) | 29 | POP3viewItem::POP3viewItem( POP3account *a, AccountView *parent ) |
28 | : AccountViewItem( parent ) | 30 | : AccountViewItem( parent ) |
29 | { | 31 | { |
30 | account = a; | 32 | account = a; |
31 | wrapper = AbstractMail::getWrapper( account ); | 33 | wrapper = AbstractMail::getWrapper( account ); |
32 | SETPIX(PIXMAP_POP3FOLDER); | 34 | SETPIX(PIXMAP_POP3FOLDER); |
33 | #if 0 | 35 | #if 0 |
34 | if (!account->getOffline()) | 36 | if (!account->getOffline()) |
35 | { | 37 | { |
36 | setPixmap( 0, ); | 38 | setPixmap( 0, ); |
37 | } | 39 | } |
38 | else | 40 | else |
39 | { | 41 | { |
40 | setPixmap( 0, PIXMAP_OFFLINE ); | 42 | setPixmap( 0, PIXMAP_OFFLINE ); |
41 | } | 43 | } |
42 | #endif | 44 | #endif |
43 | setText( 0, account->getAccountName() ); | 45 | setText( 0, account->getAccountName() ); |
44 | setOpen( true ); | 46 | setOpen( true ); |
45 | } | 47 | } |
46 | 48 | ||
47 | POP3viewItem::~POP3viewItem() | 49 | POP3viewItem::~POP3viewItem() |
48 | { | 50 | { |
49 | delete wrapper; | 51 | delete wrapper; |
50 | } | 52 | } |
51 | 53 | ||
52 | AbstractMail *POP3viewItem::getWrapper() | 54 | AbstractMail *POP3viewItem::getWrapper() |
53 | { | 55 | { |
54 | return wrapper; | 56 | return wrapper; |
55 | } | 57 | } |
56 | 58 | ||
57 | void POP3viewItem::refresh(QValueList<Opie::Core::OSmartPointer<RecMail> > & ) | 59 | void POP3viewItem::refresh(Q3ValueList<Opie::Core::OSmartPointer<RecMail> > & ) |
58 | { | 60 | { |
59 | refresh(); | 61 | refresh(); |
60 | } | 62 | } |
61 | 63 | ||
62 | void POP3viewItem::refresh() | 64 | void POP3viewItem::refresh() |
63 | { | 65 | { |
64 | if (account->getOffline()) return; | 66 | if (account->getOffline()) return; |
65 | QValueList<FolderP> *folders = wrapper->listFolders(); | 67 | Q3ValueList<FolderP> *folders = wrapper->listFolders(); |
66 | QListViewItem *child = firstChild(); | 68 | Q3ListViewItem *child = firstChild(); |
67 | while ( child ) | 69 | while ( child ) |
68 | { | 70 | { |
69 | QListViewItem *tmp = child; | 71 | Q3ListViewItem *tmp = child; |
70 | child = child->nextSibling(); | 72 | child = child->nextSibling(); |
71 | delete tmp; | 73 | delete tmp; |
72 | } | 74 | } |
73 | QValueList<FolderP>::ConstIterator it; | 75 | Q3ValueList<FolderP>::ConstIterator it; |
74 | QListViewItem*item = 0; | 76 | Q3ListViewItem*item = 0; |
75 | for ( it = folders->begin(); it!=folders->end(); ++it) | 77 | for ( it = folders->begin(); it!=folders->end(); ++it) |
76 | { | 78 | { |
77 | item = new POP3folderItem( (*it), this , item ); | 79 | item = new POP3folderItem( (*it), this , item ); |
78 | item->setSelectable( (*it)->may_select()); | 80 | item->setSelectable( (*it)->may_select()); |
79 | } | 81 | } |
80 | delete folders; | 82 | delete folders; |
81 | } | 83 | } |
82 | 84 | ||
83 | RECBODYP POP3viewItem::fetchBody( const RecMailP &mail ) | 85 | RECBODYP POP3viewItem::fetchBody( const RecMailP &mail ) |
84 | { | 86 | { |
85 | 87 | ||
86 | return wrapper->fetchBody( mail ); | 88 | return wrapper->fetchBody( mail ); |
87 | } | 89 | } |
88 | 90 | ||
89 | QPopupMenu * POP3viewItem::getContextMenu() | 91 | Q3PopupMenu * POP3viewItem::getContextMenu() |
90 | { | 92 | { |
91 | QPopupMenu *m = new QPopupMenu(0); | 93 | Q3PopupMenu *m = new Q3PopupMenu(0); |
92 | if (m) | 94 | if (m) |
93 | { | 95 | { |
94 | if (!account->getOffline()) | 96 | if (!account->getOffline()) |
95 | { | 97 | { |
96 | m->insertItem(i18n("Get new messages"),GET_NEW_MAILS); | 98 | m->insertItem(i18n("Get new messages"),GET_NEW_MAILS); |
97 | m->insertItem(i18n("Disconnect"),0); | 99 | m->insertItem(i18n("Disconnect"),0); |
98 | m->insertItem(i18n("Set offline"),1); | 100 | m->insertItem(i18n("Set offline"),1); |
99 | } | 101 | } |
100 | else | 102 | else |
101 | { | 103 | { |
102 | m->insertItem(i18n("Get new messages"),GET_NEW_MAILS); | 104 | m->insertItem(i18n("Get new messages"),GET_NEW_MAILS); |
103 | m->insertItem(i18n("Set online"),1); | 105 | m->insertItem(i18n("Set online"),1); |
104 | } | 106 | } |
105 | } | 107 | } |
106 | return m; | 108 | return m; |
107 | } | 109 | } |
108 | 110 | ||
109 | void POP3viewItem::disconnect() | 111 | void POP3viewItem::disconnect() |
110 | { | 112 | { |
111 | QListViewItem *child = firstChild(); | 113 | Q3ListViewItem *child = firstChild(); |
112 | while ( child ) | 114 | while ( child ) |
113 | { | 115 | { |
114 | QListViewItem *tmp = child; | 116 | Q3ListViewItem *tmp = child; |
115 | child = child->nextSibling(); | 117 | child = child->nextSibling(); |
116 | delete tmp; | 118 | delete tmp; |
117 | } | 119 | } |
118 | wrapper->logout(); | 120 | wrapper->logout(); |
119 | } | 121 | } |
120 | 122 | ||
121 | void POP3viewItem::setOnOffline() | 123 | void POP3viewItem::setOnOffline() |
122 | { | 124 | { |
123 | if (!account->getOffline()) | 125 | if (!account->getOffline()) |
124 | { | 126 | { |
125 | disconnect(); | 127 | disconnect(); |
126 | } | 128 | } |
127 | account->setOffline(!account->getOffline()); | 129 | account->setOffline(!account->getOffline()); |
128 | account->save(); | 130 | account->save(); |
129 | SETPIX(PIXMAP_POP3FOLDER); | 131 | SETPIX(PIXMAP_POP3FOLDER); |
130 | refresh(); | 132 | refresh(); |
131 | } | 133 | } |
132 | 134 | ||
133 | void POP3viewItem::contextMenuSelected(int which) | 135 | void POP3viewItem::contextMenuSelected(int which) |
134 | { | 136 | { |
135 | switch (which) | 137 | switch (which) |
136 | { | 138 | { |
137 | case 0: | 139 | case 0: |
138 | disconnect(); | 140 | disconnect(); |
139 | break; | 141 | break; |
140 | case 1: | 142 | case 1: |
141 | setOnOffline(); | 143 | setOnOffline(); |
142 | break; | 144 | break; |
143 | case GET_NEW_MAILS: // daunlood | 145 | case GET_NEW_MAILS: // daunlood |
144 | if (account->getOffline()) | 146 | if (account->getOffline()) |
145 | setOnOffline(); | 147 | setOnOffline(); |
146 | AccountView*bl = accountView(); | 148 | AccountView*bl = accountView(); |
147 | if (!bl) return; | 149 | if (!bl) return; |
148 | AccountViewItem* in = findSubItem( "inbox" , 0); | 150 | AccountViewItem* in = findSubItem( "inbox" , 0); |
149 | if ( ! in ) | 151 | if ( ! in ) |
150 | return; | 152 | return; |
151 | bl->downloadMailsInbox(in->getFolder() ,getWrapper()); | 153 | bl->downloadMailsInbox(in->getFolder() ,getWrapper()); |
152 | setOnOffline(); | 154 | setOnOffline(); |
153 | break; | 155 | break; |
154 | } | 156 | } |
155 | } | 157 | } |
156 | 158 | ||
157 | POP3folderItem::~POP3folderItem() | 159 | POP3folderItem::~POP3folderItem() |
158 | {} | 160 | {} |
159 | 161 | ||
160 | POP3folderItem::POP3folderItem( const FolderP&folderInit, POP3viewItem *parent , QListViewItem*after ) | 162 | POP3folderItem::POP3folderItem( const FolderP&folderInit, POP3viewItem *parent , Q3ListViewItem*after ) |
161 | : AccountViewItem(folderInit,parent,after ) | 163 | : AccountViewItem(folderInit,parent,after ) |
162 | { | 164 | { |
163 | pop3 = parent; | 165 | pop3 = parent; |
164 | if (folder->getDisplayName().lower()!="inbox") | 166 | if (folder->getDisplayName().lower()!="inbox") |
165 | { | 167 | { |
166 | setPixmap( 0, PIXMAP_POP3FOLDER ); | 168 | setPixmap( 0, PIXMAP_POP3FOLDER ); |
167 | } | 169 | } |
168 | else | 170 | else |
169 | { | 171 | { |
170 | setPixmap( 0, PIXMAP_INBOXFOLDER); | 172 | setPixmap( 0, PIXMAP_INBOXFOLDER); |
171 | } | 173 | } |
172 | setText( 0, folder->getDisplayName() ); | 174 | setText( 0, folder->getDisplayName() ); |
173 | } | 175 | } |
174 | 176 | ||
175 | void POP3folderItem::refresh(QValueList<RecMailP>&target) | 177 | void POP3folderItem::refresh(Q3ValueList<RecMailP>&target) |
176 | { | 178 | { |
177 | if (folder->may_select()) | 179 | if (folder->may_select()) |
178 | pop3->getWrapper()->listMessages( folder->getName(),target ); | 180 | pop3->getWrapper()->listMessages( folder->getName(),target ); |
179 | } | 181 | } |
180 | 182 | ||
181 | RECBODYP POP3folderItem::fetchBody(const RecMailP&aMail) | 183 | RECBODYP POP3folderItem::fetchBody(const RecMailP&aMail) |
182 | { | 184 | { |
183 | return pop3->getWrapper()->fetchBody(aMail); | 185 | return pop3->getWrapper()->fetchBody(aMail); |
184 | } | 186 | } |
185 | 187 | ||
186 | QPopupMenu * POP3folderItem::getContextMenu() | 188 | Q3PopupMenu * POP3folderItem::getContextMenu() |
187 | { | 189 | { |
188 | QPopupMenu *m = new QPopupMenu(0); | 190 | Q3PopupMenu *m = new Q3PopupMenu(0); |
189 | if (m) | 191 | if (m) |
190 | { | 192 | { |
191 | m->insertItem(i18n("Get new messages"),GET_NEW_MAILS); | 193 | m->insertItem(i18n("Get new messages"),GET_NEW_MAILS); |
192 | m->insertItem(i18n("Refresh header list"),0); | 194 | m->insertItem(i18n("Refresh header list"),0); |
193 | m->insertItem(i18n("Delete all mails"),1); | 195 | m->insertItem(i18n("Delete all mails"),1); |
194 | m->insertItem(i18n("Move/Copie all mails"),2); | 196 | m->insertItem(i18n("Move/Copie all mails"),2); |
195 | } | 197 | } |
196 | return m; | 198 | return m; |
197 | } | 199 | } |
198 | 200 | ||
199 | void POP3folderItem::downloadMails() | 201 | void POP3folderItem::downloadMails() |
200 | { | 202 | { |
201 | AccountView*bl = pop3->accountView(); | 203 | AccountView*bl = pop3->accountView(); |
202 | if (!bl) return; | 204 | if (!bl) return; |
203 | bl->downloadMails(folder,pop3->getWrapper()); | 205 | bl->downloadMails(folder,pop3->getWrapper()); |
204 | } | 206 | } |
205 | 207 | ||
206 | void POP3folderItem::contextMenuSelected(int which) | 208 | void POP3folderItem::contextMenuSelected(int which) |
207 | { | 209 | { |
208 | AccountView * view = (AccountView*)listView(); | 210 | AccountView * view = (AccountView*)listView(); |
209 | switch (which) | 211 | switch (which) |
210 | { | 212 | { |
211 | case 0: | 213 | case 0: |
212 | /* must be 'cause pop3 lists are cached */ | 214 | /* must be 'cause pop3 lists are cached */ |
213 | pop3->getWrapper()->logout(); | 215 | pop3->getWrapper()->logout(); |
214 | view->refreshCurrent(); | 216 | view->refreshCurrent(); |
215 | break; | 217 | break; |
216 | case 1: | 218 | case 1: |
217 | deleteAllMail(pop3->getWrapper(),folder); | 219 | deleteAllMail(pop3->getWrapper(),folder); |
218 | break; | 220 | break; |
219 | case 2: | 221 | case 2: |
220 | downloadMails(); | 222 | downloadMails(); |
221 | break; | 223 | break; |
222 | case GET_NEW_MAILS: // daunlood | 224 | case GET_NEW_MAILS: // daunlood |
223 | view->downloadMailsInbox(getFolder() ,pop3->getWrapper()); | 225 | view->downloadMailsInbox(getFolder() ,pop3->getWrapper()); |
224 | break; | 226 | break; |
225 | default: | 227 | default: |
226 | break; | 228 | break; |
227 | } | 229 | } |
228 | } | 230 | } |
229 | 231 | ||
230 | /** | 232 | /** |
231 | * NNTP Account stuff | 233 | * NNTP Account stuff |
232 | */ | 234 | */ |
233 | NNTPviewItem::NNTPviewItem( NNTPaccount *a, AccountView *parent ) | 235 | NNTPviewItem::NNTPviewItem( NNTPaccount *a, AccountView *parent ) |
234 | : AccountViewItem( parent ) | 236 | : AccountViewItem( parent ) |
235 | { | 237 | { |
236 | account = a; | 238 | account = a; |
237 | wrapper = AbstractMail::getWrapper( account ); | 239 | wrapper = AbstractMail::getWrapper( account ); |
238 | //FIXME | 240 | //FIXME |
239 | SETPIX(PIXMAP_POP3FOLDER); | 241 | SETPIX(PIXMAP_POP3FOLDER); |
240 | #if 0 | 242 | #if 0 |
241 | if (!account->getOffline()) | 243 | if (!account->getOffline()) |
242 | { | 244 | { |
243 | setPixmap( 0, ); | 245 | setPixmap( 0, ); |
244 | } | 246 | } |
245 | else | 247 | else |
246 | { | 248 | { |
247 | setPixmap( 0, PIXMAP_OFFLINE ); | 249 | setPixmap( 0, PIXMAP_OFFLINE ); |
248 | } | 250 | } |
249 | #endif | 251 | #endif |
250 | setText( 0, account->getAccountName() ); | 252 | setText( 0, account->getAccountName() ); |
251 | setOpen( true ); | 253 | setOpen( true ); |
252 | } | 254 | } |
253 | 255 | ||
254 | NNTPviewItem::~NNTPviewItem() | 256 | NNTPviewItem::~NNTPviewItem() |
255 | { | 257 | { |
256 | delete wrapper; | 258 | delete wrapper; |
257 | } | 259 | } |
258 | 260 | ||
259 | AbstractMail *NNTPviewItem::getWrapper() | 261 | AbstractMail *NNTPviewItem::getWrapper() |
260 | { | 262 | { |
261 | return wrapper; | 263 | return wrapper; |
262 | } | 264 | } |
263 | 265 | ||
264 | void NNTPviewItem::refresh( QValueList<RecMailP> & ) | 266 | void NNTPviewItem::refresh( Q3ValueList<RecMailP> & ) |
265 | { | 267 | { |
266 | refresh(); | 268 | refresh(); |
267 | } | 269 | } |
268 | 270 | ||
269 | void NNTPviewItem::refresh() | 271 | void NNTPviewItem::refresh() |
270 | { | 272 | { |
271 | if (account->getOffline()) return; | 273 | if (account->getOffline()) return; |
272 | QValueList<FolderP> *folders = wrapper->listFolders(); | 274 | Q3ValueList<FolderP> *folders = wrapper->listFolders(); |
273 | 275 | ||
274 | QListViewItem *child = firstChild(); | 276 | Q3ListViewItem *child = firstChild(); |
275 | while ( child ) | 277 | while ( child ) |
276 | { | 278 | { |
277 | QListViewItem *tmp = child; | 279 | Q3ListViewItem *tmp = child; |
278 | child = child->nextSibling(); | 280 | child = child->nextSibling(); |
279 | delete tmp; | 281 | delete tmp; |
280 | } | 282 | } |
281 | QValueList<FolderP>::ConstIterator it; | 283 | Q3ValueList<FolderP>::ConstIterator it; |
282 | QListViewItem*item = 0; | 284 | Q3ListViewItem*item = 0; |
283 | for ( it = folders->begin(); it!=folders->end(); ++it) | 285 | for ( it = folders->begin(); it!=folders->end(); ++it) |
284 | { | 286 | { |
285 | item = new NNTPfolderItem( (*it), this , item ); | 287 | item = new NNTPfolderItem( (*it), this , item ); |
286 | item->setSelectable( (*it)->may_select()); | 288 | item->setSelectable( (*it)->may_select()); |
287 | } | 289 | } |
288 | delete folders; | 290 | delete folders; |
289 | } | 291 | } |
290 | 292 | ||
291 | RECBODYP NNTPviewItem::fetchBody( const RecMailP &mail ) | 293 | RECBODYP NNTPviewItem::fetchBody( const RecMailP &mail ) |
292 | { | 294 | { |
293 | 295 | ||
294 | return wrapper->fetchBody( mail ); | 296 | return wrapper->fetchBody( mail ); |
295 | } | 297 | } |
296 | 298 | ||
297 | QPopupMenu * NNTPviewItem::getContextMenu() | 299 | Q3PopupMenu * NNTPviewItem::getContextMenu() |
298 | { | 300 | { |
299 | QPopupMenu *m = new QPopupMenu(0); | 301 | Q3PopupMenu *m = new Q3PopupMenu(0); |
300 | if (m) | 302 | if (m) |
301 | { | 303 | { |
302 | if (!account->getOffline()) | 304 | if (!account->getOffline()) |
303 | { | 305 | { |
304 | m->insertItem(i18n("Disconnect"),0); | 306 | m->insertItem(i18n("Disconnect"),0); |
305 | m->insertItem(i18n("Set offline"),1); | 307 | m->insertItem(i18n("Set offline"),1); |
306 | //m->insertItem(i18n("(Un-)Subscribe groups"),2); | 308 | //m->insertItem(i18n("(Un-)Subscribe groups"),2); |
307 | } | 309 | } |
308 | else | 310 | else |
309 | { | 311 | { |
310 | m->insertItem(i18n("Set online"),1); | 312 | m->insertItem(i18n("Set online"),1); |
311 | } | 313 | } |
312 | } | 314 | } |
313 | return m; | 315 | return m; |
314 | } | 316 | } |
315 | 317 | ||
316 | void NNTPviewItem::subscribeGroups() | 318 | void NNTPviewItem::subscribeGroups() |
317 | { | 319 | { |
318 | NNTPGroupsDlg dlg(account); | 320 | NNTPGroupsDlg dlg(account); |
319 | #ifndef DESKTOP_VERSION | 321 | #ifndef DESKTOP_VERSION |
320 | dlg.showMaximized(); | 322 | dlg.showMaximized(); |
321 | #endif | 323 | #endif |
322 | if ( dlg.exec()== QDialog::Accepted ){ | 324 | if ( dlg.exec()== QDialog::Accepted ){ |
323 | refresh(); | 325 | refresh(); |
324 | } | 326 | } |
325 | } | 327 | } |
326 | 328 | ||
327 | void NNTPviewItem::disconnect() | 329 | void NNTPviewItem::disconnect() |
328 | { | 330 | { |
329 | QListViewItem *child = firstChild(); | 331 | Q3ListViewItem *child = firstChild(); |
330 | while ( child ) | 332 | while ( child ) |
331 | { | 333 | { |
332 | QListViewItem *tmp = child; | 334 | Q3ListViewItem *tmp = child; |
333 | child = child->nextSibling(); | 335 | child = child->nextSibling(); |
334 | delete tmp; | 336 | delete tmp; |
335 | } | 337 | } |
336 | wrapper->logout(); | 338 | wrapper->logout(); |
337 | } | 339 | } |
338 | 340 | ||
339 | void NNTPviewItem::setOnOffline() | 341 | void NNTPviewItem::setOnOffline() |
340 | { | 342 | { |
341 | if (!account->getOffline()) | 343 | if (!account->getOffline()) |
342 | { | 344 | { |
343 | disconnect(); | 345 | disconnect(); |
344 | } | 346 | } |
345 | account->setOffline(!account->getOffline()); | 347 | account->setOffline(!account->getOffline()); |
346 | account->save(); | 348 | account->save(); |
347 | //FIXME | 349 | //FIXME |
348 | SETPIX(PIXMAP_POP3FOLDER); | 350 | SETPIX(PIXMAP_POP3FOLDER); |
349 | refresh(); | 351 | refresh(); |
350 | } | 352 | } |
351 | 353 | ||
352 | void NNTPviewItem::contextMenuSelected(int which) | 354 | void NNTPviewItem::contextMenuSelected(int which) |
353 | { | 355 | { |
354 | switch (which) | 356 | switch (which) |
355 | { | 357 | { |
356 | case 0: | 358 | case 0: |
357 | disconnect(); | 359 | disconnect(); |
358 | break; | 360 | break; |
359 | case 1: | 361 | case 1: |
360 | setOnOffline(); | 362 | setOnOffline(); |
361 | break; | 363 | break; |
362 | case 2: | 364 | case 2: |
363 | subscribeGroups(); | 365 | subscribeGroups(); |
364 | break; | 366 | break; |
365 | } | 367 | } |
366 | } | 368 | } |
367 | 369 | ||
368 | NNTPfolderItem::~NNTPfolderItem() | 370 | NNTPfolderItem::~NNTPfolderItem() |
369 | {} | 371 | {} |
370 | 372 | ||
371 | NNTPfolderItem::NNTPfolderItem( const FolderP &folderInit, NNTPviewItem *parent , QListViewItem*after ) | 373 | NNTPfolderItem::NNTPfolderItem( const FolderP &folderInit, NNTPviewItem *parent , Q3ListViewItem*after ) |
372 | : AccountViewItem( folderInit, parent,after ) | 374 | : AccountViewItem( folderInit, parent,after ) |
373 | { | 375 | { |
374 | nntp = parent; | 376 | nntp = parent; |
375 | if (folder->getDisplayName().lower()!="inbox") | 377 | if (folder->getDisplayName().lower()!="inbox") |
376 | { | 378 | { |
377 | setPixmap( 0, PIXMAP_POP3FOLDER ); | 379 | setPixmap( 0, PIXMAP_POP3FOLDER ); |
378 | } | 380 | } |
379 | else | 381 | else |
380 | { | 382 | { |
381 | setPixmap( 0, PIXMAP_INBOXFOLDER); | 383 | setPixmap( 0, PIXMAP_INBOXFOLDER); |
382 | } | 384 | } |
383 | setText( 0, folder->getDisplayName() ); | 385 | setText( 0, folder->getDisplayName() ); |
384 | } | 386 | } |
385 | 387 | ||
386 | void NNTPfolderItem::refresh(QValueList<RecMailP>&target) | 388 | void NNTPfolderItem::refresh(Q3ValueList<RecMailP>&target) |
387 | { | 389 | { |
388 | if (folder->may_select()) | 390 | if (folder->may_select()) |
389 | nntp->getWrapper()->listMessages( folder->getName(),target ); | 391 | nntp->getWrapper()->listMessages( folder->getName(),target ); |
390 | } | 392 | } |
391 | 393 | ||
392 | RECBODYP NNTPfolderItem::fetchBody(const RecMailP&aMail) | 394 | RECBODYP NNTPfolderItem::fetchBody(const RecMailP&aMail) |
393 | { | 395 | { |
394 | return nntp->getWrapper()->fetchBody(aMail); | 396 | return nntp->getWrapper()->fetchBody(aMail); |
395 | } | 397 | } |
396 | 398 | ||
397 | QPopupMenu * NNTPfolderItem::getContextMenu() | 399 | Q3PopupMenu * NNTPfolderItem::getContextMenu() |
398 | { | 400 | { |
399 | QPopupMenu *m = new QPopupMenu(0); | 401 | Q3PopupMenu *m = new Q3PopupMenu(0); |
400 | if (m) | 402 | if (m) |
401 | { | 403 | { |
402 | m->insertItem(i18n("Refresh header list"),0); | 404 | m->insertItem(i18n("Refresh header list"),0); |
403 | m->insertItem(i18n("Copy all postings"),1); | 405 | m->insertItem(i18n("Copy all postings"),1); |
404 | } | 406 | } |
405 | return m; | 407 | return m; |
406 | } | 408 | } |
407 | 409 | ||
408 | void NNTPfolderItem::downloadMails() | 410 | void NNTPfolderItem::downloadMails() |
409 | { | 411 | { |
410 | AccountView*bl = nntp->accountView(); | 412 | AccountView*bl = nntp->accountView(); |
411 | if (!bl) return; | 413 | if (!bl) return; |
412 | bl->downloadMails(folder,nntp->getWrapper()); | 414 | bl->downloadMails(folder,nntp->getWrapper()); |
413 | } | 415 | } |
414 | 416 | ||
415 | void NNTPfolderItem::contextMenuSelected(int which) | 417 | void NNTPfolderItem::contextMenuSelected(int which) |
416 | { | 418 | { |
417 | AccountView * view = (AccountView*)listView(); | 419 | AccountView * view = (AccountView*)listView(); |
418 | switch (which) | 420 | switch (which) |
419 | { | 421 | { |
420 | case 0: | 422 | case 0: |
421 | /* must be 'cause pop3 lists are cached */ | 423 | /* must be 'cause pop3 lists are cached */ |
422 | nntp->getWrapper()->logout(); | 424 | nntp->getWrapper()->logout(); |
423 | view->refreshCurrent(); | 425 | view->refreshCurrent(); |
424 | break; | 426 | break; |
425 | case 1: | 427 | case 1: |
426 | downloadMails(); | 428 | downloadMails(); |
427 | break; | 429 | break; |
428 | default: | 430 | default: |
429 | break; | 431 | break; |
430 | } | 432 | } |
431 | } | 433 | } |
432 | 434 | ||
433 | /** | 435 | /** |
434 | * IMAP Account stuff | 436 | * IMAP Account stuff |
435 | */ | 437 | */ |
436 | IMAPviewItem::IMAPviewItem( IMAPaccount *a, AccountView *parent ) | 438 | IMAPviewItem::IMAPviewItem( IMAPaccount *a, AccountView *parent ) |
437 | : AccountViewItem( parent ) | 439 | : AccountViewItem( parent ) |
438 | { | 440 | { |
439 | account = a; | 441 | account = a; |
440 | wrapper = AbstractMail::getWrapper( account ); | 442 | wrapper = AbstractMail::getWrapper( account ); |
441 | SETPIX(PIXMAP_IMAPFOLDER); | 443 | SETPIX(PIXMAP_IMAPFOLDER); |
442 | setText( 0, account->getAccountName() ); | 444 | setText( 0, account->getAccountName() ); |
443 | setOpen( true ); | 445 | setOpen( true ); |
444 | } | 446 | } |
445 | 447 | ||
446 | IMAPviewItem::~IMAPviewItem() | 448 | IMAPviewItem::~IMAPviewItem() |
447 | { | 449 | { |
448 | delete wrapper; | 450 | delete wrapper; |
449 | } | 451 | } |
450 | 452 | ||
451 | AbstractMail *IMAPviewItem::getWrapper() | 453 | AbstractMail *IMAPviewItem::getWrapper() |
452 | { | 454 | { |
453 | return wrapper; | 455 | return wrapper; |
454 | } | 456 | } |
455 | 457 | ||
456 | void IMAPviewItem::refresh(QValueList<RecMailP>&) | 458 | void IMAPviewItem::refresh(Q3ValueList<RecMailP>&) |
457 | { | 459 | { |
458 | refreshFolders(false); | 460 | refreshFolders(false); |
459 | } | 461 | } |
460 | 462 | ||
461 | const QStringList&IMAPviewItem::subFolders() | 463 | const QStringList&IMAPviewItem::subFolders() |
462 | { | 464 | { |
463 | return currentFolders; | 465 | return currentFolders; |
464 | } | 466 | } |
465 | 467 | ||
466 | void IMAPviewItem::refreshFolders(bool force) | 468 | void IMAPviewItem::refreshFolders(bool force) |
467 | { | 469 | { |
468 | if (childCount()>0 && force==false) return; | 470 | if (childCount()>0 && force==false) return; |
469 | if (account->getOffline()) return; | 471 | if (account->getOffline()) return; |
470 | 472 | ||
471 | removeChilds(); | 473 | removeChilds(); |
472 | currentFolders.clear(); | 474 | currentFolders.clear(); |
473 | QValueList<FolderP> * folders = wrapper->listFolders(); | 475 | Q3ValueList<FolderP> * folders = wrapper->listFolders(); |
474 | 476 | ||
475 | QValueList<FolderP>::Iterator it; | 477 | Q3ValueList<FolderP>::Iterator it; |
476 | QListViewItem*item = 0; | 478 | Q3ListViewItem*item = 0; |
477 | QListViewItem*titem = 0; | 479 | Q3ListViewItem*titem = 0; |
478 | QString fname,del,search; | 480 | QString fname,del,search; |
479 | int pos; | 481 | int pos; |
480 | 482 | ||
481 | for ( it = folders->begin(); it!=folders->end(); ++it) | 483 | for ( it = folders->begin(); it!=folders->end(); ++it) |
482 | { | 484 | { |
483 | if ((*it)->getDisplayName().lower()=="inbox") | 485 | if ((*it)->getDisplayName().lower()=="inbox") |
484 | { | 486 | { |
485 | item = new IMAPfolderItem( (*it), this , item ); | 487 | item = new IMAPfolderItem( (*it), this , item ); |
486 | folders->remove(it); | 488 | folders->remove(it); |
487 | break; | 489 | break; |
488 | } | 490 | } |
489 | } | 491 | } |
490 | for ( it = folders->begin(); it!=folders->end(); ++it) | 492 | for ( it = folders->begin(); it!=folders->end(); ++it) |
491 | { | 493 | { |
492 | fname = (*it)->getDisplayName(); | 494 | fname = (*it)->getDisplayName(); |
493 | currentFolders.append((*it)->getName()); | 495 | currentFolders.append((*it)->getName()); |
494 | pos = fname.findRev((*it)->Separator()); | 496 | pos = fname.findRev((*it)->Separator()); |
495 | if (pos != -1) | 497 | if (pos != -1) |
496 | { | 498 | { |
497 | fname = fname.left(pos); | 499 | fname = fname.left(pos); |
498 | } | 500 | } |
499 | IMAPfolderItem*pitem = (IMAPfolderItem*)findSubItem(fname); | 501 | IMAPfolderItem*pitem = (IMAPfolderItem*)findSubItem(fname); |
500 | if (pitem) | 502 | if (pitem) |
501 | { | 503 | { |
502 | titem = item; | 504 | titem = item; |
503 | item = new IMAPfolderItem( (*it),pitem,pitem->firstChild(),this); | 505 | item = new IMAPfolderItem( (*it),pitem,pitem->firstChild(),this); |
504 | /* setup the short name */ | 506 | /* setup the short name */ |
505 | item->setText(0,(*it)->getDisplayName().mid(pos+1)); | 507 | item->setText(0,(*it)->getDisplayName().mid(pos+1)); |
506 | item = titem; | 508 | item = titem; |
507 | } | 509 | } |
508 | else | 510 | else |
509 | { | 511 | { |
510 | item = new IMAPfolderItem( (*it), this , item ); | 512 | item = new IMAPfolderItem( (*it), this , item ); |
511 | } | 513 | } |
512 | } | 514 | } |
513 | delete folders; | 515 | delete folders; |
514 | } | 516 | } |
515 | 517 | ||
516 | QPopupMenu * IMAPviewItem::getContextMenu() | 518 | Q3PopupMenu * IMAPviewItem::getContextMenu() |
517 | { | 519 | { |
518 | QPopupMenu *m = new QPopupMenu(0); | 520 | Q3PopupMenu *m = new Q3PopupMenu(0); |
519 | if (m) | 521 | if (m) |
520 | { | 522 | { |
521 | if (!account->getOffline()) | 523 | if (!account->getOffline()) |
522 | { | 524 | { |
523 | m->insertItem(i18n("Get new messages"),GET_NEW_MAILS); | 525 | m->insertItem(i18n("Get new messages"),GET_NEW_MAILS); |
524 | m->insertItem(i18n("Refresh folder list"),0); | 526 | m->insertItem(i18n("Refresh folder list"),0); |
525 | m->insertItem(i18n("Create new folder"),1); | 527 | m->insertItem(i18n("Create new folder"),1); |
526 | m->insertSeparator(); | 528 | m->insertSeparator(); |
527 | m->insertItem(i18n("Disconnect"),2); | 529 | m->insertItem(i18n("Disconnect"),2); |
528 | m->insertItem(i18n("Set offline"),3); | 530 | m->insertItem(i18n("Set offline"),3); |
529 | m->insertSeparator(); | 531 | m->insertSeparator(); |
530 | } | 532 | } |
531 | else | 533 | else |
532 | { | 534 | { |
533 | m->insertItem(i18n("Get new messages"),GET_NEW_MAILS); | 535 | m->insertItem(i18n("Get new messages"),GET_NEW_MAILS); |
534 | m->insertItem(i18n("Set online"),3); | 536 | m->insertItem(i18n("Set online"),3); |
535 | } | 537 | } |
536 | } | 538 | } |
537 | return m; | 539 | return m; |
538 | } | 540 | } |
539 | 541 | ||
540 | void IMAPviewItem::createNewFolder() | 542 | void IMAPviewItem::createNewFolder() |
541 | { | 543 | { |
542 | Newmdirdlg ndirdlg; | 544 | Newmdirdlg ndirdlg; |
543 | 545 | ||
544 | #ifndef DESKTOP_VERSION | 546 | #ifndef DESKTOP_VERSION |
545 | //ndirdlg.showMaximized(); | 547 | //ndirdlg.showMaximized(); |
546 | #endif | 548 | #endif |
547 | if ( ndirdlg.exec() ) | 549 | if ( ndirdlg.exec() ) |
548 | { | 550 | { |
549 | QString ndir = ndirdlg.Newdir(); | 551 | QString ndir = ndirdlg.Newdir(); |
550 | bool makesubs = ndirdlg.subpossible(); | 552 | bool makesubs = ndirdlg.subpossible(); |
551 | QString delemiter = "/"; | 553 | QString delemiter = "/"; |
552 | IMAPfolderItem*item = (IMAPfolderItem*)firstChild(); | 554 | IMAPfolderItem*item = (IMAPfolderItem*)firstChild(); |
553 | if (item) | 555 | if (item) |
554 | { | 556 | { |
555 | delemiter = item->Delemiter(); | 557 | delemiter = item->Delemiter(); |
556 | } | 558 | } |
557 | if (wrapper->createMbox(ndir,0,delemiter,makesubs)) | 559 | if (wrapper->createMbox(ndir,0,delemiter,makesubs)) |
558 | { | 560 | { |
559 | refreshFolders(true); | 561 | refreshFolders(true); |
560 | } | 562 | } |
561 | } | 563 | } |
562 | } | 564 | } |
563 | 565 | ||
564 | void IMAPviewItem::contextMenuSelected(int id) | 566 | void IMAPviewItem::contextMenuSelected(int id) |
565 | { | 567 | { |
566 | 568 | ||
567 | switch (id) | 569 | switch (id) |
568 | { | 570 | { |
569 | case 0: | 571 | case 0: |
570 | refreshFolders(true); | 572 | refreshFolders(true); |
571 | break; | 573 | break; |
572 | case 1: | 574 | case 1: |
573 | createNewFolder(); | 575 | createNewFolder(); |
574 | break; | 576 | break; |
575 | case 2: | 577 | case 2: |
576 | removeChilds(); | 578 | removeChilds(); |
577 | wrapper->logout(); | 579 | wrapper->logout(); |
578 | break; | 580 | break; |
579 | case 3: | 581 | case 3: |
580 | if (account->getOffline()==false) | 582 | if (account->getOffline()==false) |
581 | { | 583 | { |
582 | removeChilds(); | 584 | removeChilds(); |
583 | wrapper->logout(); | 585 | wrapper->logout(); |
584 | } | 586 | } |
585 | account->setOffline(!account->getOffline()); | 587 | account->setOffline(!account->getOffline()); |
586 | account->save(); | 588 | account->save(); |
587 | SETPIX(PIXMAP_IMAPFOLDER); | 589 | SETPIX(PIXMAP_IMAPFOLDER); |
588 | refreshFolders(false); | 590 | refreshFolders(false); |
589 | break; | 591 | break; |
590 | case GET_NEW_MAILS: // daunlood | 592 | case GET_NEW_MAILS: // daunlood |
591 | { | 593 | { |
592 | if (account->getOffline()) { | 594 | if (account->getOffline()) { |
593 | contextMenuSelected( 3 ); | 595 | contextMenuSelected( 3 ); |
594 | } | 596 | } |
595 | AccountView*bl = accountView(); | 597 | AccountView*bl = accountView(); |
596 | if (!bl) return; | 598 | if (!bl) return; |
597 | AccountViewItem* in = findSubItem( "inbox" , 0); | 599 | AccountViewItem* in = findSubItem( "inbox" , 0); |
598 | if ( ! in ) | 600 | if ( ! in ) |
599 | return; | 601 | return; |
600 | bl->downloadMailsInbox(in->getFolder(),getWrapper()); | 602 | bl->downloadMailsInbox(in->getFolder(),getWrapper()); |
601 | } | 603 | } |
602 | break; | 604 | break; |
603 | default: | 605 | default: |
604 | break; | 606 | break; |
605 | } | 607 | } |
606 | } | 608 | } |
607 | 609 | ||
608 | RECBODYP IMAPviewItem::fetchBody(const RecMailP&) | 610 | RECBODYP IMAPviewItem::fetchBody(const RecMailP&) |
609 | { | 611 | { |
610 | return new RecBody(); | 612 | return new RecBody(); |
611 | } | 613 | } |
612 | 614 | ||
613 | bool IMAPviewItem::offline() | 615 | bool IMAPviewItem::offline() |
614 | { | 616 | { |
615 | return account->getOffline(); | 617 | return account->getOffline(); |
616 | } | 618 | } |
617 | 619 | ||
618 | IMAPfolderItem::IMAPfolderItem( const FolderP& folderInit, IMAPviewItem *parent , QListViewItem*after ) | 620 | IMAPfolderItem::IMAPfolderItem( const FolderP& folderInit, IMAPviewItem *parent , Q3ListViewItem*after ) |
619 | : AccountViewItem( folderInit, parent , after ) | 621 | : AccountViewItem( folderInit, parent , after ) |
620 | { | 622 | { |
621 | imap = parent; | 623 | imap = parent; |
622 | if (folder->getDisplayName().lower()!="inbox") | 624 | if (folder->getDisplayName().lower()!="inbox") |
623 | { | 625 | { |
624 | setPixmap( 0, PIXMAP_IMAPFOLDER ); | 626 | setPixmap( 0, PIXMAP_IMAPFOLDER ); |
625 | } | 627 | } |
626 | else | 628 | else |
627 | { | 629 | { |
628 | setPixmap( 0, PIXMAP_INBOXFOLDER); | 630 | setPixmap( 0, PIXMAP_INBOXFOLDER); |
629 | } | 631 | } |
630 | setText( 0, folder->getDisplayName() ); | 632 | setText( 0, folder->getDisplayName() ); |
631 | } | 633 | } |
632 | 634 | ||
633 | IMAPfolderItem::IMAPfolderItem(const FolderP &folderInit, IMAPfolderItem *parent , QListViewItem*after, IMAPviewItem *master ) | 635 | IMAPfolderItem::IMAPfolderItem(const FolderP &folderInit, IMAPfolderItem *parent , Q3ListViewItem*after, IMAPviewItem *master ) |
634 | : AccountViewItem(folderInit, parent,after ) | 636 | : AccountViewItem(folderInit, parent,after ) |
635 | { | 637 | { |
636 | imap = master; | 638 | imap = master; |
637 | if (folder->getDisplayName().lower()!="inbox") | 639 | if (folder->getDisplayName().lower()!="inbox") |
638 | { | 640 | { |
639 | setPixmap( 0, PIXMAP_IMAPFOLDER ); | 641 | setPixmap( 0, PIXMAP_IMAPFOLDER ); |
640 | } | 642 | } |
641 | else | 643 | else |
642 | { | 644 | { |
643 | setPixmap( 0, PIXMAP_INBOXFOLDER); | 645 | setPixmap( 0, PIXMAP_INBOXFOLDER); |
644 | } | 646 | } |
645 | setText( 0, folder->getDisplayName() ); | 647 | setText( 0, folder->getDisplayName() ); |
646 | } | 648 | } |
647 | 649 | ||
648 | IMAPfolderItem::~IMAPfolderItem() | 650 | IMAPfolderItem::~IMAPfolderItem() |
649 | {} | 651 | {} |
650 | 652 | ||
651 | const QString& IMAPfolderItem::Delemiter()const | 653 | const QString& IMAPfolderItem::Delemiter()const |
652 | { | 654 | { |
653 | return folder->Separator(); | 655 | return folder->Separator(); |
654 | } | 656 | } |
655 | 657 | ||
656 | void IMAPfolderItem::refresh(QValueList<RecMailP>&target) | 658 | void IMAPfolderItem::refresh(Q3ValueList<RecMailP>&target) |
657 | { | 659 | { |
658 | if (folder->may_select()) | 660 | if (folder->may_select()) |
659 | { | 661 | { |
660 | imap->getWrapper()->listMessages( folder->getName(),target ); | 662 | imap->getWrapper()->listMessages( folder->getName(),target ); |
661 | } | 663 | } |
662 | else | 664 | else |
663 | { | 665 | { |
664 | target.clear(); | 666 | target.clear(); |
665 | } | 667 | } |
666 | } | 668 | } |
667 | 669 | ||
668 | RECBODYP IMAPfolderItem::fetchBody(const RecMailP&aMail) | 670 | RECBODYP IMAPfolderItem::fetchBody(const RecMailP&aMail) |
669 | { | 671 | { |
670 | return imap->getWrapper()->fetchBody(aMail); | 672 | return imap->getWrapper()->fetchBody(aMail); |
671 | } | 673 | } |
672 | 674 | ||
673 | QPopupMenu * IMAPfolderItem::getContextMenu() | 675 | Q3PopupMenu * IMAPfolderItem::getContextMenu() |
674 | { | 676 | { |
675 | QPopupMenu *m = new QPopupMenu(0); | 677 | Q3PopupMenu *m = new Q3PopupMenu(0); |
676 | if (m) | 678 | if (m) |
677 | { | 679 | { |
678 | if (folder->may_select()) | 680 | if (folder->may_select()) |
679 | { | 681 | { |
680 | m->insertItem(i18n("Get new messages"),GET_NEW_MAILS); | 682 | m->insertItem(i18n("Get new messages"),GET_NEW_MAILS); |
681 | m->insertItem(i18n("Refresh header list"),0); | 683 | m->insertItem(i18n("Refresh header list"),0); |
682 | m->insertItem(i18n("Move/Copie all mails"),4); | 684 | m->insertItem(i18n("Move/Copie all mails"),4); |
683 | m->insertItem(i18n("Delete all mails"),1); | 685 | m->insertItem(i18n("Delete all mails"),1); |
684 | } | 686 | } |
685 | if (folder->no_inferior()==false) | 687 | if (folder->no_inferior()==false) |
686 | { | 688 | { |
687 | m->insertItem(i18n("Create new subfolder"),2); | 689 | m->insertItem(i18n("Create new subfolder"),2); |
688 | } | 690 | } |
689 | if (folder->getDisplayName().lower()!="inbox") | 691 | if (folder->getDisplayName().lower()!="inbox") |
690 | { | 692 | { |
691 | m->insertItem(i18n("Delete folder"),3); | 693 | m->insertItem(i18n("Delete folder"),3); |
692 | } | 694 | } |
693 | } | 695 | } |
694 | return m; | 696 | return m; |
695 | } | 697 | } |
696 | 698 | ||
697 | void IMAPfolderItem::createNewFolder() | 699 | void IMAPfolderItem::createNewFolder() |
698 | { | 700 | { |
699 | Newmdirdlg ndirdlg; | 701 | Newmdirdlg ndirdlg; |
700 | //ndirdlg.showMaximized(); | 702 | //ndirdlg.showMaximized(); |
701 | if ( ndirdlg.exec() ) | 703 | if ( ndirdlg.exec() ) |
702 | { | 704 | { |
703 | QString ndir = ndirdlg.Newdir(); | 705 | QString ndir = ndirdlg.Newdir(); |
704 | bool makesubs = ndirdlg.subpossible(); | 706 | bool makesubs = ndirdlg.subpossible(); |
705 | QString delemiter = Delemiter(); | 707 | QString delemiter = Delemiter(); |
706 | if (imap->wrapper->createMbox(ndir,folder,delemiter,makesubs)) | 708 | if (imap->wrapper->createMbox(ndir,folder,delemiter,makesubs)) |
707 | { | 709 | { |
708 | imap->refreshFolders(true); | 710 | imap->refreshFolders(true); |
709 | } | 711 | } |
710 | } | 712 | } |
711 | } | 713 | } |
712 | 714 | ||
713 | void IMAPfolderItem::deleteFolder() | 715 | void IMAPfolderItem::deleteFolder() |
714 | { | 716 | { |
715 | int yesno = QMessageBox::warning(0,i18n("Delete folder"), | 717 | int yesno = QMessageBox::warning(0,i18n("Delete folder"), |
716 | i18n("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>").arg(folder->getDisplayName()), | 718 | i18n("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>").arg(folder->getDisplayName()), |
717 | i18n("Yes"), | 719 | i18n("Yes"), |
718 | i18n("No"),QString::null,1,1); | 720 | i18n("No"),QString::null,1,1); |
719 | 721 | ||
720 | if (yesno == 0) | 722 | if (yesno == 0) |
721 | { | 723 | { |
722 | if (imap->getWrapper()->deleteMbox(folder)) | 724 | if (imap->getWrapper()->deleteMbox(folder)) |
723 | { | 725 | { |
724 | QListView*v=listView(); | 726 | Q3ListView*v=listView(); |
725 | IMAPviewItem * box = imap; | 727 | IMAPviewItem * box = imap; |
726 | /* be carefull - after that this object is destroyd so don't use | 728 | /* be carefull - after that this object is destroyd so don't use |
727 | * any member of it after that call!!*/ | 729 | * any member of it after that call!!*/ |
728 | imap->refreshFolders(true); | 730 | imap->refreshFolders(true); |
729 | if (v) | 731 | if (v) |
730 | { | 732 | { |
731 | v->setSelected(box,true); | 733 | v->setSelected(box,true); |
732 | } | 734 | } |
733 | } | 735 | } |
734 | } | 736 | } |
735 | } | 737 | } |
736 | 738 | ||
737 | void IMAPfolderItem::downloadMails() | 739 | void IMAPfolderItem::downloadMails() |
738 | { | 740 | { |
739 | AccountView*bl = imap->accountView(); | 741 | AccountView*bl = imap->accountView(); |
740 | if (!bl) return; | 742 | if (!bl) return; |
741 | bl->downloadMails(folder,imap->getWrapper()); | 743 | bl->downloadMails(folder,imap->getWrapper()); |
742 | } | 744 | } |
743 | 745 | ||
744 | void IMAPfolderItem::contextMenuSelected(int id) | 746 | void IMAPfolderItem::contextMenuSelected(int id) |
745 | { | 747 | { |
746 | 748 | ||
747 | AccountView * view = (AccountView*)listView(); | 749 | AccountView * view = (AccountView*)listView(); |
748 | switch(id) | 750 | switch(id) |
749 | { | 751 | { |
750 | case 0: | 752 | case 0: |
751 | view->refreshCurrent(); | 753 | view->refreshCurrent(); |
752 | break; | 754 | break; |
753 | case 1: | 755 | case 1: |
754 | deleteAllMail(imap->getWrapper(),folder); | 756 | deleteAllMail(imap->getWrapper(),folder); |
755 | break; | 757 | break; |
756 | case 2: | 758 | case 2: |
757 | createNewFolder(); | 759 | createNewFolder(); |
758 | break; | 760 | break; |
759 | case 3: | 761 | case 3: |
760 | deleteFolder(); | 762 | deleteFolder(); |
761 | break; | 763 | break; |
762 | case 4: | 764 | case 4: |
763 | downloadMails(); | 765 | downloadMails(); |
764 | break; | 766 | break; |
765 | case GET_NEW_MAILS: // daunlood | 767 | case GET_NEW_MAILS: // daunlood |
766 | { | 768 | { |
767 | if (!view) return; | 769 | if (!view) return; |
768 | view->downloadMailsInbox(getFolder(),imap->getWrapper()); | 770 | view->downloadMailsInbox(getFolder(),imap->getWrapper()); |
769 | } | 771 | } |
770 | break; | 772 | break; |
771 | default: | 773 | default: |
772 | break; | 774 | break; |
773 | } | 775 | } |
774 | } | 776 | } |
775 | 777 | ||
776 | /** | 778 | /** |
777 | * MH Account stuff | 779 | * MH Account stuff |
778 | */ | 780 | */ |
779 | /* MH is a little bit different - the top folder can contains messages other than in IMAP and | 781 | /* MH is a little bit different - the top folder can contains messages other than in IMAP and |
780 | POP3 and MBOX */ | 782 | POP3 and MBOX */ |
781 | MHviewItem::MHviewItem( const QString&aPath, AccountView *parent ) | 783 | MHviewItem::MHviewItem( const QString&aPath, AccountView *parent ) |
782 | : AccountViewItem( parent ) | 784 | : AccountViewItem( parent ) |
783 | { | 785 | { |
784 | m_Path = aPath; | 786 | m_Path = aPath; |
785 | /* be carefull - the space within settext is wanted - thats why the string twice */ | 787 | /* be carefull - the space within settext is wanted - thats why the string twice */ |
786 | wrapper = AbstractMail::getWrapper( m_Path,"Local Mailfolders"); | 788 | wrapper = AbstractMail::getWrapper( m_Path,"Local Mailfolders"); |
787 | setPixmap( 0, PIXMAP_LOCALFOLDER ); | 789 | setPixmap( 0, PIXMAP_LOCALFOLDER ); |
788 | setText( 0, i18n(" Local Mailfolders") ); | 790 | setText( 0, i18n(" Local Mailfolders") ); |
789 | setOpen( true ); | 791 | setOpen( true ); |
790 | folder = 0; | 792 | folder = 0; |
791 | } | 793 | } |
792 | 794 | ||
793 | MHviewItem::~MHviewItem() | 795 | MHviewItem::~MHviewItem() |
794 | { | 796 | { |
795 | delete wrapper; | 797 | delete wrapper; |
796 | } | 798 | } |
797 | 799 | ||
798 | AbstractMail *MHviewItem::getWrapper() | 800 | AbstractMail *MHviewItem::getWrapper() |
799 | { | 801 | { |
800 | return wrapper; | 802 | return wrapper; |
801 | } | 803 | } |
802 | 804 | ||
803 | void MHviewItem::refresh( QValueList<RecMailP> & target) | 805 | void MHviewItem::refresh( Q3ValueList<RecMailP> & target) |
804 | { | 806 | { |
805 | refresh(false); | 807 | refresh(false); |
806 | getWrapper()->listMessages( "",target ); | 808 | getWrapper()->listMessages( "",target ); |
807 | } | 809 | } |
808 | 810 | ||
809 | void MHviewItem::refresh(bool force) | 811 | void MHviewItem::refresh(bool force) |
810 | { | 812 | { |
811 | if (childCount()>0 && force==false) return; | 813 | if (childCount()>0 && force==false) return; |
812 | removeChilds(); | 814 | removeChilds(); |
813 | currentFolders.clear(); | 815 | currentFolders.clear(); |
814 | QValueList<FolderP> *folders = wrapper->listFolders(); | 816 | Q3ValueList<FolderP> *folders = wrapper->listFolders(); |
815 | QValueList<FolderP>::ConstIterator it; | 817 | Q3ValueList<FolderP>::ConstIterator it; |
816 | MHfolderItem*item = 0; | 818 | MHfolderItem*item = 0; |
817 | MHfolderItem*pmaster = 0; | 819 | MHfolderItem*pmaster = 0; |
818 | QString fname = ""; | 820 | QString fname = ""; |
819 | int pos; | 821 | int pos; |
820 | for ( it = folders->begin(); it!=folders->end(); ++it) | 822 | for ( it = folders->begin(); it!=folders->end(); ++it) |
821 | { | 823 | { |
822 | fname = (*it)->getDisplayName(); | 824 | fname = (*it)->getDisplayName(); |
823 | /* this folder itself */ | 825 | /* this folder itself */ |
824 | if (fname=="/") | 826 | if (fname=="/") |
825 | { | 827 | { |
826 | currentFolders.append(fname); | 828 | currentFolders.append(fname); |
827 | folder = (*it); | 829 | folder = (*it); |
828 | continue; | 830 | continue; |
829 | } | 831 | } |
830 | currentFolders.append(fname); | 832 | currentFolders.append(fname); |
831 | pos = fname.findRev("/"); | 833 | pos = fname.findRev("/"); |
832 | if (pos > 0) | 834 | if (pos > 0) |
833 | { | 835 | { |
834 | fname = fname.left(pos); | 836 | fname = fname.left(pos); |
835 | pmaster = (MHfolderItem*)findSubItem(fname); | 837 | pmaster = (MHfolderItem*)findSubItem(fname); |
836 | } | 838 | } |
837 | else | 839 | else |
838 | { | 840 | { |
839 | pmaster = 0; | 841 | pmaster = 0; |
840 | } | 842 | } |
841 | if (pmaster) | 843 | if (pmaster) |
842 | { | 844 | { |
843 | item = new MHfolderItem( (*it), pmaster, item, this ); | 845 | item = new MHfolderItem( (*it), pmaster, item, this ); |
844 | } | 846 | } |
845 | else | 847 | else |
846 | { | 848 | { |
847 | item = new MHfolderItem( (*it), this , item ); | 849 | item = new MHfolderItem( (*it), this , item ); |
848 | } | 850 | } |
849 | item->setSelectable((*it)->may_select()); | 851 | item->setSelectable((*it)->may_select()); |
850 | } | 852 | } |
851 | delete folders; | 853 | delete folders; |
852 | } | 854 | } |
853 | 855 | ||
854 | RECBODYP MHviewItem::fetchBody( const RecMailP &mail ) | 856 | RECBODYP MHviewItem::fetchBody( const RecMailP &mail ) |
855 | { | 857 | { |
856 | 858 | ||
857 | return wrapper->fetchBody( mail ); | 859 | return wrapper->fetchBody( mail ); |
858 | } | 860 | } |
859 | 861 | ||
860 | QPopupMenu * MHviewItem::getContextMenu() | 862 | Q3PopupMenu * MHviewItem::getContextMenu() |
861 | { | 863 | { |
862 | QPopupMenu *m = new QPopupMenu(0); | 864 | Q3PopupMenu *m = new Q3PopupMenu(0); |
863 | if (m) | 865 | if (m) |
864 | { | 866 | { |
865 | m->insertItem(i18n("Refresh folder list"),0); | 867 | m->insertItem(i18n("Refresh folder list"),0); |
866 | m->insertItem(i18n("Create new folder"),1); | 868 | m->insertItem(i18n("Create new folder"),1); |
867 | m->insertItem(i18n("Delete all mails"),2); | 869 | m->insertItem(i18n("Delete all mails"),2); |
868 | m->insertItem(i18n("Move/Copie all mails"),3); | 870 | m->insertItem(i18n("Move/Copie all mails"),3); |
869 | } | 871 | } |
870 | return m; | 872 | return m; |
871 | } | 873 | } |
872 | 874 | ||
873 | void MHviewItem::createFolder() | 875 | void MHviewItem::createFolder() |
874 | { | 876 | { |
875 | Newmdirdlg ndirdlg(0,0,true); | 877 | Newmdirdlg ndirdlg(0,0,true); |
876 | //ndirdlg.showMaximized(); | 878 | //ndirdlg.showMaximized(); |
877 | if ( ndirdlg.exec() ) | 879 | if ( ndirdlg.exec() ) |
878 | { | 880 | { |
879 | QString ndir = ndirdlg.Newdir(); | 881 | QString ndir = ndirdlg.Newdir(); |
880 | if (wrapper->createMbox(ndir)) | 882 | if (wrapper->createMbox(ndir)) |
881 | { | 883 | { |
882 | refresh(true); | 884 | refresh(true); |
883 | } | 885 | } |
884 | } | 886 | } |
885 | } | 887 | } |
886 | 888 | ||
887 | void MHviewItem::downloadMails() | 889 | void MHviewItem::downloadMails() |
888 | { | 890 | { |
889 | AccountView*bl = accountView(); | 891 | AccountView*bl = accountView(); |
890 | if (!bl) return; | 892 | if (!bl) return; |
891 | bl->downloadMails(folder,getWrapper()); | 893 | bl->downloadMails(folder,getWrapper()); |
892 | } | 894 | } |
893 | 895 | ||
894 | QStringList MHviewItem::subFolders() | 896 | QStringList MHviewItem::subFolders() |
895 | { | 897 | { |
896 | return currentFolders; | 898 | return currentFolders; |
897 | } | 899 | } |
898 | 900 | ||
899 | void MHviewItem::contextMenuSelected(int which) | 901 | void MHviewItem::contextMenuSelected(int which) |
900 | { | 902 | { |
901 | switch (which) | 903 | switch (which) |
902 | { | 904 | { |
903 | case 0: | 905 | case 0: |
904 | refresh(true); | 906 | refresh(true); |
905 | break; | 907 | break; |
906 | case 1: | 908 | case 1: |
907 | createFolder(); | 909 | createFolder(); |
908 | break; | 910 | break; |
909 | case 2: | 911 | case 2: |
910 | deleteAllMail(getWrapper(),folder); | 912 | deleteAllMail(getWrapper(),folder); |
911 | break; | 913 | break; |
912 | case 3: | 914 | case 3: |
913 | downloadMails(); | 915 | downloadMails(); |
914 | break; | 916 | break; |
915 | default: | 917 | default: |
916 | break; | 918 | break; |
917 | } | 919 | } |
918 | } | 920 | } |
919 | 921 | ||
920 | MHfolderItem::~MHfolderItem() | 922 | MHfolderItem::~MHfolderItem() |
921 | {} | 923 | {} |
922 | 924 | ||
923 | MHfolderItem::MHfolderItem( const FolderP &folderInit, MHviewItem *parent , QListViewItem*after ) | 925 | MHfolderItem::MHfolderItem( const FolderP &folderInit, MHviewItem *parent , Q3ListViewItem*after ) |
924 | : AccountViewItem(folderInit, parent,after ) | 926 | : AccountViewItem(folderInit, parent,after ) |
925 | { | 927 | { |
926 | mbox = parent; | 928 | mbox = parent; |
927 | initName(); | 929 | initName(); |
928 | } | 930 | } |
929 | 931 | ||
930 | MHfolderItem::MHfolderItem(const FolderP& folderInit, MHfolderItem *parent, QListViewItem*after, MHviewItem*master) | 932 | MHfolderItem::MHfolderItem(const FolderP& folderInit, MHfolderItem *parent, Q3ListViewItem*after, MHviewItem*master) |
931 | : AccountViewItem(folderInit, parent,after ) | 933 | : AccountViewItem(folderInit, parent,after ) |
932 | { | 934 | { |
933 | folder = folderInit; | 935 | folder = folderInit; |
934 | mbox = master; | 936 | mbox = master; |
935 | initName(); | 937 | initName(); |
936 | } | 938 | } |
937 | 939 | ||
938 | void MHfolderItem::initName() | 940 | void MHfolderItem::initName() |
939 | { | 941 | { |
940 | QString bName = folder->getDisplayName(); | 942 | QString bName = folder->getDisplayName(); |
941 | if (bName.startsWith("/")&&bName.length()>1) | 943 | if (bName.startsWith("/")&&bName.length()>1) |
942 | { | 944 | { |
943 | bName.replace(0,1,""); | 945 | bName.replace(0,1,""); |
944 | } | 946 | } |
945 | int pos = bName.findRev("/"); | 947 | int pos = bName.findRev("/"); |
946 | if (pos > 0) | 948 | if (pos > 0) |
947 | { | 949 | { |
948 | bName.replace(0,pos+1,""); | 950 | bName.replace(0,pos+1,""); |
949 | } | 951 | } |
950 | if (bName.lower() == "outgoing") | 952 | if (bName.lower() == "outgoing") |
951 | { | 953 | { |
952 | setPixmap( 0, PIXMAP_OUTBOXFOLDER ); | 954 | setPixmap( 0, PIXMAP_OUTBOXFOLDER ); |
953 | } | 955 | } |
954 | else if (bName.lower() == "inbox") | 956 | else if (bName.lower() == "inbox") |
955 | { | 957 | { |
956 | setPixmap( 0, PIXMAP_INBOXFOLDER); | 958 | setPixmap( 0, PIXMAP_INBOXFOLDER); |
957 | } else if (bName.lower() == "drafts") { | 959 | } else if (bName.lower() == "drafts") { |
958 | setPixmap(0, SmallIcon ("edit")); | 960 | setPixmap(0, SmallIcon ("edit")); |
959 | } else { | 961 | } else { |
960 | setPixmap( 0, PIXMAP_MBOXFOLDER ); | 962 | setPixmap( 0, PIXMAP_MBOXFOLDER ); |
961 | } | 963 | } |
962 | setText( 0, bName ); | 964 | setText( 0, bName ); |
963 | } | 965 | } |
964 | 966 | ||
965 | const FolderP&MHfolderItem::getFolder()const | 967 | const FolderP&MHfolderItem::getFolder()const |
966 | { | 968 | { |
967 | return folder; | 969 | return folder; |
968 | } | 970 | } |
969 | 971 | ||
970 | void MHfolderItem::refresh(QValueList<RecMailP>&target) | 972 | void MHfolderItem::refresh(Q3ValueList<RecMailP>&target) |
971 | { | 973 | { |
972 | if (folder->may_select()) | 974 | if (folder->may_select()) |
973 | mbox->getWrapper()->listMessages( folder->getName(),target ); | 975 | mbox->getWrapper()->listMessages( folder->getName(),target ); |
974 | } | 976 | } |
975 | 977 | ||
976 | RECBODYP MHfolderItem::fetchBody(const RecMailP&aMail) | 978 | RECBODYP MHfolderItem::fetchBody(const RecMailP&aMail) |
977 | { | 979 | { |
978 | return mbox->getWrapper()->fetchBody(aMail); | 980 | return mbox->getWrapper()->fetchBody(aMail); |
979 | } | 981 | } |
980 | 982 | ||
981 | void MHfolderItem::deleteFolder() | 983 | void MHfolderItem::deleteFolder() |
982 | { | 984 | { |
983 | int yesno = QMessageBox::warning(0,i18n("Delete folder"), | 985 | int yesno = QMessageBox::warning(0,i18n("Delete folder"), |
984 | i18n("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>").arg(folder->getDisplayName()), | 986 | i18n("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>").arg(folder->getDisplayName()), |
985 | i18n("Yes"), | 987 | i18n("Yes"), |
986 | i18n("No"),QString::null,1,1); | 988 | i18n("No"),QString::null,1,1); |
987 | 989 | ||
988 | if (yesno == 0) | 990 | if (yesno == 0) |
989 | { | 991 | { |
990 | if (mbox->getWrapper()->deleteMbox(folder)) | 992 | if (mbox->getWrapper()->deleteMbox(folder)) |
991 | { | 993 | { |
992 | QListView*v=listView(); | 994 | Q3ListView*v=listView(); |
993 | MHviewItem * box = mbox; | 995 | MHviewItem * box = mbox; |
994 | /* be carefull - after that this object is destroyd so don't use | 996 | /* be carefull - after that this object is destroyd so don't use |
995 | * any member of it after that call!!*/ | 997 | * any member of it after that call!!*/ |
996 | mbox->refresh(true); | 998 | mbox->refresh(true); |
997 | if (v) | 999 | if (v) |
998 | { | 1000 | { |
999 | v->setSelected(box,true); | 1001 | v->setSelected(box,true); |
1000 | } | 1002 | } |
1001 | } | 1003 | } |
1002 | } | 1004 | } |
1003 | } | 1005 | } |
1004 | 1006 | ||
1005 | QPopupMenu * MHfolderItem::getContextMenu() | 1007 | Q3PopupMenu * MHfolderItem::getContextMenu() |
1006 | { | 1008 | { |
1007 | QPopupMenu *m = new QPopupMenu(0); | 1009 | Q3PopupMenu *m = new Q3PopupMenu(0); |
1008 | if (m) | 1010 | if (m) |
1009 | { | 1011 | { |
1010 | m->insertItem(i18n("Move/Copie all mails"),2); | 1012 | m->insertItem(i18n("Move/Copie all mails"),2); |
1011 | m->insertItem(i18n("Delete all mails"),0); | 1013 | m->insertItem(i18n("Delete all mails"),0); |
1012 | m->insertItem(i18n("Create new subfolder"),3); | 1014 | m->insertItem(i18n("Create new subfolder"),3); |
1013 | m->insertItem(i18n("Delete folder"),1); | 1015 | m->insertItem(i18n("Delete folder"),1); |
1014 | } | 1016 | } |
1015 | return m; | 1017 | return m; |
1016 | } | 1018 | } |
1017 | 1019 | ||
1018 | void MHfolderItem::downloadMails() | 1020 | void MHfolderItem::downloadMails() |
1019 | { | 1021 | { |
1020 | AccountView*bl = mbox->accountView(); | 1022 | AccountView*bl = mbox->accountView(); |
1021 | if (!bl) return; | 1023 | if (!bl) return; |
1022 | bl->downloadMails(folder,mbox->getWrapper()); | 1024 | bl->downloadMails(folder,mbox->getWrapper()); |
1023 | } | 1025 | } |
1024 | 1026 | ||
1025 | void MHfolderItem::createFolder() | 1027 | void MHfolderItem::createFolder() |
1026 | { | 1028 | { |
1027 | Newmdirdlg ndirdlg(0,0,true); | 1029 | Newmdirdlg ndirdlg(0,0,true); |
1028 | //ndirdlg.showMaximized(); | 1030 | //ndirdlg.showMaximized(); |
1029 | if (ndirdlg.exec() ) | 1031 | if (ndirdlg.exec() ) |
1030 | { | 1032 | { |
1031 | QString ndir = ndirdlg.Newdir(); | 1033 | QString ndir = ndirdlg.Newdir(); |
1032 | if (mbox->getWrapper()->createMbox(ndir,folder)) | 1034 | if (mbox->getWrapper()->createMbox(ndir,folder)) |
1033 | { | 1035 | { |
1034 | QListView*v=listView(); | 1036 | Q3ListView*v=listView(); |
1035 | MHviewItem * box = mbox; | 1037 | MHviewItem * box = mbox; |
1036 | /* be carefull - after that this object is destroyd so don't use | 1038 | /* be carefull - after that this object is destroyd so don't use |
1037 | * any member of it after that call!!*/ | 1039 | * any member of it after that call!!*/ |
1038 | mbox->refresh(true); | 1040 | mbox->refresh(true); |
1039 | if (v) | 1041 | if (v) |
1040 | { | 1042 | { |
1041 | v->setSelected(box,true); | 1043 | v->setSelected(box,true); |
1042 | } | 1044 | } |
1043 | } | 1045 | } |
1044 | } | 1046 | } |
1045 | } | 1047 | } |
1046 | 1048 | ||
1047 | void MHfolderItem::contextMenuSelected(int which) | 1049 | void MHfolderItem::contextMenuSelected(int which) |
1048 | { | 1050 | { |
1049 | switch(which) | 1051 | switch(which) |
1050 | { | 1052 | { |
1051 | case 0: | 1053 | case 0: |
1052 | deleteAllMail(mbox->getWrapper(),folder); | 1054 | deleteAllMail(mbox->getWrapper(),folder); |
1053 | break; | 1055 | break; |
1054 | case 1: | 1056 | case 1: |
1055 | deleteFolder(); | 1057 | deleteFolder(); |
1056 | break; | 1058 | break; |
1057 | case 2: | 1059 | case 2: |
1058 | downloadMails(); | 1060 | downloadMails(); |
1059 | break; | 1061 | break; |
1060 | case 3: | 1062 | case 3: |
1061 | createFolder(); | 1063 | createFolder(); |
1062 | break; | 1064 | break; |
1063 | default: | 1065 | default: |
1064 | break; | 1066 | break; |
1065 | } | 1067 | } |
1066 | } | 1068 | } |
1067 | 1069 | ||
1068 | bool MHfolderItem::isDraftfolder() | 1070 | bool MHfolderItem::isDraftfolder() |
1069 | { | 1071 | { |
1070 | if (folder && folder->getName()==AbstractMail::defaultLocalfolder()+"/"+AbstractMail::draftFolder()) return true; | 1072 | if (folder && folder->getName()==AbstractMail::defaultLocalfolder()+"/"+AbstractMail::draftFolder()) return true; |
1071 | return false; | 1073 | return false; |
1072 | } | 1074 | } |
1073 | 1075 | ||
1074 | /** | 1076 | /** |
1075 | * Generic stuff | 1077 | * Generic stuff |
1076 | */ | 1078 | */ |
1077 | 1079 | ||
1078 | const QString AccountViewItem::contextName="AccountViewItem"; | 1080 | const QString AccountViewItem::contextName="AccountViewItem"; |
1079 | 1081 | ||
1080 | AccountViewItem::AccountViewItem( AccountView *parent ) | 1082 | AccountViewItem::AccountViewItem( AccountView *parent ) |
1081 | : QListViewItem( parent ) | 1083 | : Q3ListViewItem( parent ) |
1082 | { | 1084 | { |
1083 | init(); | 1085 | init(); |
1084 | m_Backlink = parent; | 1086 | m_Backlink = parent; |
1085 | } | 1087 | } |
1086 | 1088 | ||
1087 | AccountViewItem::AccountViewItem( QListViewItem *parent) | 1089 | AccountViewItem::AccountViewItem( Q3ListViewItem *parent) |
1088 | : QListViewItem( parent),folder(0) | 1090 | : Q3ListViewItem( parent),folder(0) |
1089 | { | 1091 | { |
1090 | init(); | 1092 | init(); |
1091 | } | 1093 | } |
1092 | 1094 | ||
1093 | AccountViewItem::AccountViewItem( QListViewItem *parent , QListViewItem*after ) | 1095 | AccountViewItem::AccountViewItem( Q3ListViewItem *parent , Q3ListViewItem*after ) |
1094 | :QListViewItem( parent,after ),folder(0) | 1096 | :Q3ListViewItem( parent,after ),folder(0) |
1095 | { | 1097 | { |
1096 | init(); | 1098 | init(); |
1097 | } | 1099 | } |
1098 | 1100 | ||
1099 | AccountViewItem::AccountViewItem( const Opie::Core::OSmartPointer<Folder>&folderInit,QListViewItem *parent , QListViewItem*after ) | 1101 | AccountViewItem::AccountViewItem( const Opie::Core::OSmartPointer<Folder>&folderInit,Q3ListViewItem *parent , Q3ListViewItem*after ) |
1100 | :QListViewItem( parent,after ),folder(folderInit) | 1102 | :Q3ListViewItem( parent,after ),folder(folderInit) |
1101 | { | 1103 | { |
1102 | init(); | 1104 | init(); |
1103 | } | 1105 | } |
1104 | 1106 | ||
1105 | void AccountViewItem::init() | 1107 | void AccountViewItem::init() |
1106 | { | 1108 | { |
1107 | m_Backlink = 0; | 1109 | m_Backlink = 0; |
1108 | } | 1110 | } |
1109 | 1111 | ||
1110 | AccountViewItem::~AccountViewItem() | 1112 | AccountViewItem::~AccountViewItem() |
1111 | { | 1113 | { |
1112 | folder = 0; | 1114 | folder = 0; |
1113 | } | 1115 | } |
1114 | 1116 | ||
1115 | AccountView*AccountViewItem::accountView() | 1117 | AccountView*AccountViewItem::accountView() |
1116 | { | 1118 | { |
1117 | return m_Backlink; | 1119 | return m_Backlink; |
1118 | } | 1120 | } |
1119 | 1121 | ||
1120 | void AccountViewItem::deleteAllMail(AbstractMail*wrapper,const FolderP&folder) | 1122 | void AccountViewItem::deleteAllMail(AbstractMail*wrapper,const FolderP&folder) |
1121 | { | 1123 | { |
1122 | if (!wrapper) return; | 1124 | if (!wrapper) return; |
1123 | QString fname=""; | 1125 | QString fname=""; |
1124 | if (folder) fname = folder->getDisplayName(); | 1126 | if (folder) fname = folder->getDisplayName(); |
1125 | int yesno = QMessageBox::warning(0,i18n("Delete all mails"), | 1127 | int yesno = QMessageBox::warning(0,i18n("Delete all mails"), |
1126 | i18n("<center>Realy delete all mails in box <br>%1</center>"). | 1128 | i18n("<center>Realy delete all mails in box <br>%1</center>"). |
1127 | arg(fname), | 1129 | arg(fname), |
1128 | i18n("Yes"), | 1130 | i18n("Yes"), |
1129 | i18n("No"),QString::null,1,1); | 1131 | i18n("No"),QString::null,1,1); |
1130 | 1132 | ||
1131 | if (yesno == 0) | 1133 | if (yesno == 0) |
1132 | { | 1134 | { |
1133 | if (wrapper->deleteAllMail(folder)) | 1135 | if (wrapper->deleteAllMail(folder)) |
1134 | { | 1136 | { |
1135 | AccountView * view = (AccountView*)listView(); | 1137 | AccountView * view = (AccountView*)listView(); |
1136 | if (view) view->refreshCurrent(); | 1138 | if (view) view->refreshCurrent(); |
1137 | } | 1139 | } |
1138 | } | 1140 | } |
1139 | } | 1141 | } |
1140 | 1142 | ||
1141 | void AccountViewItem::removeChilds() | 1143 | void AccountViewItem::removeChilds() |
1142 | { | 1144 | { |
1143 | QListViewItem *child = firstChild(); | 1145 | Q3ListViewItem *child = firstChild(); |
1144 | while ( child ) | 1146 | while ( child ) |
1145 | { | 1147 | { |
1146 | QListViewItem *tmp = child; | 1148 | Q3ListViewItem *tmp = child; |
1147 | child = child->nextSibling(); | 1149 | child = child->nextSibling(); |
1148 | delete tmp; | 1150 | delete tmp; |
1149 | } | 1151 | } |
1150 | } | 1152 | } |
1151 | 1153 | ||
1152 | bool AccountViewItem::matchName(const QString&name)const | 1154 | bool AccountViewItem::matchName(const QString&name)const |
1153 | { | 1155 | { |
1154 | if (!folder) return false; | 1156 | if (!folder) return false; |
1155 | return folder->getDisplayName().lower()==name.lower(); | 1157 | return folder->getDisplayName().lower()==name.lower(); |
1156 | } | 1158 | } |
1157 | 1159 | ||
1158 | 1160 | ||
1159 | AccountViewItem*AccountViewItem::findSubItem(const QString&path,AccountViewItem*start) | 1161 | AccountViewItem*AccountViewItem::findSubItem(const QString&path,AccountViewItem*start) |
1160 | { | 1162 | { |
1161 | AccountViewItem*pitem,*sitem; | 1163 | AccountViewItem*pitem,*sitem; |
1162 | if (!start) pitem = (AccountViewItem*)firstChild(); | 1164 | if (!start) pitem = (AccountViewItem*)firstChild(); |
1163 | else pitem = (AccountViewItem*)start->firstChild(); | 1165 | else pitem = (AccountViewItem*)start->firstChild(); |
1164 | while (pitem) | 1166 | while (pitem) |
1165 | { | 1167 | { |
1166 | if (pitem->matchName(path)) | 1168 | if (pitem->matchName(path)) |
1167 | { | 1169 | { |
1168 | break; | 1170 | break; |
1169 | } | 1171 | } |
1170 | if (pitem->childCount()>0) | 1172 | if (pitem->childCount()>0) |
1171 | { | 1173 | { |
1172 | sitem = findSubItem(path,pitem); | 1174 | sitem = findSubItem(path,pitem); |
1173 | if (sitem) | 1175 | if (sitem) |
1174 | { | 1176 | { |
1175 | pitem = sitem; | 1177 | pitem = sitem; |
1176 | break; | 1178 | break; |
1177 | } | 1179 | } |
1178 | } | 1180 | } |
1179 | pitem=(AccountViewItem*)pitem->nextSibling(); | 1181 | pitem=(AccountViewItem*)pitem->nextSibling(); |
1180 | } | 1182 | } |
1181 | return pitem; | 1183 | return pitem; |
1182 | } | 1184 | } |
1183 | 1185 | ||
1184 | bool AccountViewItem::isDraftfolder() | 1186 | bool AccountViewItem::isDraftfolder() |
1185 | { | 1187 | { |
1186 | return false; | 1188 | return false; |
1187 | } | 1189 | } |