author | alwin <alwin> | 2003-12-27 18:23:23 (UTC) |
---|---|---|
committer | alwin <alwin> | 2003-12-27 18:23:23 (UTC) |
commit | 7812187f6732eef351e501d993aa664b7e351cbb (patch) (unidiff) | |
tree | fe2ed5fc0d8c67983956ecf543a54d2e6355a627 /noncore/net/mail/accountview.cpp | |
parent | 583f9d5f33fa055fe8ee612f344d06faae1ef330 (diff) | |
download | opie-7812187f6732eef351e501d993aa664b7e351cbb.zip opie-7812187f6732eef351e501d993aa664b7e351cbb.tar.gz opie-7812187f6732eef351e501d993aa664b7e351cbb.tar.bz2 |
folder handling for imap mostly impelemented, context menus for
imap-mail-folders implemented.
Diffstat (limited to 'noncore/net/mail/accountview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/mail/accountview.cpp | 179 |
1 files changed, 172 insertions, 7 deletions
diff --git a/noncore/net/mail/accountview.cpp b/noncore/net/mail/accountview.cpp index 59e8bc0..8aac14b 100644 --- a/noncore/net/mail/accountview.cpp +++ b/noncore/net/mail/accountview.cpp | |||
@@ -4,2 +4,5 @@ | |||
4 | #include "defines.h" | 4 | #include "defines.h" |
5 | #include "newmaildir.h" | ||
6 | #include <qmessagebox.h> | ||
7 | #include <qpopupmenu.h> | ||
5 | 8 | ||
@@ -8,3 +11,2 @@ | |||
8 | */ | 11 | */ |
9 | |||
10 | POP3viewItem::POP3viewItem( POP3account *a, QListView *parent ) | 12 | POP3viewItem::POP3viewItem( POP3account *a, QListView *parent ) |
@@ -130,3 +132,8 @@ void IMAPviewItem::refresh(QList<RecMail>&) | |||
130 | { | 132 | { |
131 | if (childCount()>0) return; | 133 | refreshFolders(false); |
134 | } | ||
135 | |||
136 | void IMAPviewItem::refreshFolders(bool force) | ||
137 | { | ||
138 | if (childCount()>0 && force==false) return; | ||
132 | QList<Folder> *folders = wrapper->listFolders(); | 139 | QList<Folder> *folders = wrapper->listFolders(); |
@@ -166,3 +173,2 @@ void IMAPviewItem::refresh(QList<RecMail>&) | |||
166 | item = new IMAPfolderItem(it,pitem,pitem->firstChild(),this); | 173 | item = new IMAPfolderItem(it,pitem,pitem->firstChild(),this); |
167 | item->setSelectable(it->may_select()); | ||
168 | /* setup the short name */ | 174 | /* setup the short name */ |
@@ -172,3 +178,2 @@ void IMAPviewItem::refresh(QList<RecMail>&) | |||
172 | item = new IMAPfolderItem( it, this , item ); | 178 | item = new IMAPfolderItem( it, this , item ); |
173 | item->setSelectable(it->may_select()); | ||
174 | } | 179 | } |
@@ -178,2 +183,47 @@ void IMAPviewItem::refresh(QList<RecMail>&) | |||
178 | 183 | ||
184 | QPopupMenu * IMAPviewItem::getContextMenu() | ||
185 | { | ||
186 | QPopupMenu *m = new QPopupMenu(0); | ||
187 | if (m) { | ||
188 | m->insertItem(QObject::tr("Refresh folder list","IMAPviewItem"),0); | ||
189 | m->insertItem(QObject::tr("Create new folder","IMAPviewItem"),1); | ||
190 | m->insertSeparator(); | ||
191 | m->insertItem(QObject::tr("Disconnect","IMAPviewItem"),2); | ||
192 | } | ||
193 | return m; | ||
194 | } | ||
195 | |||
196 | void IMAPviewItem::createNewFolder() | ||
197 | { | ||
198 | Newmdirdlg ndirdlg; | ||
199 | ndirdlg.showMaximized(); | ||
200 | if (ndirdlg.exec()) { | ||
201 | QString ndir = ndirdlg.Newdir(); | ||
202 | bool makesubs = ndirdlg.subpossible(); | ||
203 | QString delemiter = "/"; | ||
204 | IMAPfolderItem*item = (IMAPfolderItem*)firstChild(); | ||
205 | if (item) { | ||
206 | delemiter = item->Delemiter(); | ||
207 | } | ||
208 | if (wrapper->createMbox(ndir,0,delemiter,makesubs)) { | ||
209 | refreshFolders(true); | ||
210 | } | ||
211 | } | ||
212 | } | ||
213 | |||
214 | void IMAPviewItem::contextMenuSelected(int id) | ||
215 | { | ||
216 | qDebug("Id selected: %i",id); | ||
217 | switch (id) { | ||
218 | case 0: | ||
219 | refreshFolders(true); | ||
220 | break; | ||
221 | case 1: | ||
222 | createNewFolder(); | ||
223 | break; | ||
224 | default: | ||
225 | break; | ||
226 | } | ||
227 | } | ||
228 | |||
179 | RecBody IMAPviewItem::fetchBody(const RecMail&) | 229 | RecBody IMAPviewItem::fetchBody(const RecMail&) |
@@ -214,2 +264,7 @@ IMAPfolderItem::IMAPfolderItem( Folder *folderInit, IMAPfolderItem *parent , QLi | |||
214 | 264 | ||
265 | const QString& IMAPfolderItem::Delemiter()const | ||
266 | { | ||
267 | return folder->Separator(); | ||
268 | } | ||
269 | |||
215 | bool IMAPfolderItem::matchName(const QString&name)const | 270 | bool IMAPfolderItem::matchName(const QString&name)const |
@@ -221,4 +276,7 @@ void IMAPfolderItem::refresh(QList<RecMail>&target) | |||
221 | { | 276 | { |
222 | if (folder->may_select()) | 277 | if (folder->may_select()) { |
223 | imap->getWrapper()->listMessages( folder->getName(),target ); | 278 | imap->getWrapper()->listMessages( folder->getName(),target ); |
279 | } else { | ||
280 | target.clear(); | ||
281 | } | ||
224 | } | 282 | } |
@@ -230,2 +288,86 @@ RecBody IMAPfolderItem::fetchBody(const RecMail&aMail) | |||
230 | 288 | ||
289 | QPopupMenu * IMAPfolderItem::getContextMenu() | ||
290 | { | ||
291 | QPopupMenu *m = new QPopupMenu(0); | ||
292 | if (m) { | ||
293 | if (folder->may_select()) { | ||
294 | m->insertItem(QObject::tr("Refresh header list","IMAPfolderItem"),0); | ||
295 | m->insertItem(QObject::tr("Delete all mails","IMAPfolderItem"),1); | ||
296 | } | ||
297 | if (folder->no_inferior()==false) { | ||
298 | m->insertItem(QObject::tr("Create new subfolder","IMAPfolderItem"),2); | ||
299 | } | ||
300 | if (folder->getDisplayName().lower()!="inbox") { | ||
301 | m->insertItem(QObject::tr("Delete folder","IMAPfolderItem"),3); | ||
302 | } | ||
303 | } | ||
304 | return m; | ||
305 | } | ||
306 | |||
307 | void IMAPfolderItem::deleteAllMails() | ||
308 | { | ||
309 | int yesno = QMessageBox::warning(0,QObject::tr("Delete all mails","IMAPfolderItem"), | ||
310 | QObject::tr("<center>Realy delete all mails in box <br>%1</center>","IMAPfolderItem").arg(folder->getDisplayName()), | ||
311 | QObject::tr("Yes","IMAPfolderItem"), | ||
312 | QObject::tr("No","IMAPfolderItem"),QString::null,1,1); | ||
313 | qDebug("Auswahl: %i",yesno); | ||
314 | if (yesno == 0) { | ||
315 | if (imap->getWrapper()->deleteAllMail(folder)) { | ||
316 | AccountView * view = (AccountView*)listView(); | ||
317 | if (view) view->refreshCurrent(); | ||
318 | } | ||
319 | } | ||
320 | } | ||
321 | |||
322 | void IMAPfolderItem::createNewFolder() | ||
323 | { | ||
324 | Newmdirdlg ndirdlg; | ||
325 | ndirdlg.showMaximized(); | ||
326 | if (ndirdlg.exec()) { | ||
327 | QString ndir = ndirdlg.Newdir(); | ||
328 | bool makesubs = ndirdlg.subpossible(); | ||
329 | QString delemiter = Delemiter(); | ||
330 | if (imap->wrapper->createMbox(ndir,folder,delemiter,makesubs)) { | ||
331 | imap->refreshFolders(true); | ||
332 | } | ||
333 | } | ||
334 | } | ||
335 | |||
336 | void IMAPfolderItem::deleteFolder() | ||
337 | { | ||
338 | int yesno = QMessageBox::warning(0,QObject::tr("Delete folder","IMAPfolderItem"), | ||
339 | QObject::tr("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>","IMAPfolderItem").arg(folder->getDisplayName()), | ||
340 | QObject::tr("Yes","IMAPfolderItem"), | ||
341 | QObject::tr("No","IMAPfolderItem"),QString::null,1,1); | ||
342 | qDebug("Auswahl: %i",yesno); | ||
343 | if (yesno == 0) { | ||
344 | if (imap->getWrapper()->deleteMbox(folder)) { | ||
345 | /* be carefull - after that this object is destroyd so don't call | ||
346 | * any member of it after that call!!*/ | ||
347 | imap->refreshFolders(true); | ||
348 | } | ||
349 | } | ||
350 | } | ||
351 | |||
352 | void IMAPfolderItem::contextMenuSelected(int id) | ||
353 | { | ||
354 | qDebug("Selected id: %i",id); | ||
355 | AccountView * view = (AccountView*)listView(); | ||
356 | switch(id) { | ||
357 | case 0: | ||
358 | view->refreshCurrent(); | ||
359 | break; | ||
360 | case 1: | ||
361 | deleteAllMails(); | ||
362 | break; | ||
363 | case 2: | ||
364 | createNewFolder(); | ||
365 | break; | ||
366 | case 3: | ||
367 | deleteFolder(); | ||
368 | break; | ||
369 | default: | ||
370 | break; | ||
371 | } | ||
372 | } | ||
231 | 373 | ||
@@ -239,3 +381,6 @@ AccountView::AccountView( QWidget *parent, const char *name, WFlags flags ) | |||
239 | connect( this, SIGNAL( selectionChanged( QListViewItem * ) ), | 381 | connect( this, SIGNAL( selectionChanged( QListViewItem * ) ), |
240 | SLOT( refresh( QListViewItem * ) ) ); | 382 | SLOT( refresh( QListViewItem * ) ) ); |
383 | connect( this, SIGNAL( mouseButtonPressed(int, QListViewItem *,const QPoint&,int ) ),this, | ||
384 | SLOT( slotHold( int, QListViewItem *,const QPoint&,int ) ) ); | ||
385 | |||
241 | setSorting(0); | 386 | setSorting(0); |
@@ -243,2 +388,22 @@ AccountView::AccountView( QWidget *parent, const char *name, WFlags flags ) | |||
243 | 388 | ||
389 | void AccountView::slotContextMenu(int id) | ||
390 | { | ||
391 | AccountViewItem *view = static_cast<AccountViewItem *>(currentItem()); | ||
392 | if (!view) return; | ||
393 | view->contextMenuSelected(id); | ||
394 | } | ||
395 | |||
396 | void AccountView::slotHold(int button, QListViewItem * item,const QPoint&,int) | ||
397 | { | ||
398 | if (button==1) {return;} | ||
399 | if (!item) return; | ||
400 | AccountViewItem *view = static_cast<AccountViewItem *>(item); | ||
401 | QPopupMenu*m = view->getContextMenu(); | ||
402 | if (!m) return; | ||
403 | connect(m,SIGNAL(activated(int)),this,SLOT(slotContextMenu(int))); | ||
404 | m->setFocus(); | ||
405 | m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); | ||
406 | delete m; | ||
407 | } | ||
408 | |||
244 | void AccountView::populate( QList<Account> list ) | 409 | void AccountView::populate( QList<Account> list ) |
@@ -279,2 +444,3 @@ void AccountView::refreshCurrent() | |||
279 | { | 444 | { |
445 | m_currentItem = currentItem(); | ||
280 | if ( !m_currentItem ) return; | 446 | if ( !m_currentItem ) return; |
@@ -380,2 +546 @@ RecBody MBOXfolderItem::fetchBody(const RecMail&aMail) | |||
380 | } | } | |
381 | |||