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