summaryrefslogtreecommitdiff
path: root/noncore/net/mail/accountview.cpp
Unidiff
Diffstat (limited to 'noncore/net/mail/accountview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/accountview.cpp48
1 files changed, 31 insertions, 17 deletions
diff --git a/noncore/net/mail/accountview.cpp b/noncore/net/mail/accountview.cpp
index d9792d4..2ddf834 100644
--- a/noncore/net/mail/accountview.cpp
+++ b/noncore/net/mail/accountview.cpp
@@ -1,24 +1,29 @@
1
1#include "accountview.h" 2#include "accountview.h"
2#include "accountitem.h" 3#include "accountitem.h"
3#include "selectstore.h" 4#include "selectstore.h"
4#include <qmessagebox.h> 5
5#include <qpopupmenu.h> 6/* OPIE */
6#include <libmailwrapper/settings.h> 7#include <libmailwrapper/settings.h>
7#include <libmailwrapper/mailwrapper.h> 8#include <libmailwrapper/mailwrapper.h>
8#include <libmailwrapper/mailtypes.h> 9#include <libmailwrapper/mailtypes.h>
9#include <libmailwrapper/abstractmail.h> 10#include <libmailwrapper/abstractmail.h>
11#include <qpe/qpeapplication.h>
10 12
13/* QT */
14#include <qmessagebox.h>
15#include <qpopupmenu.h>
11 16
12AccountView::AccountView( QWidget *parent, const char *name, WFlags flags ) 17AccountView::AccountView( QWidget *parent, const char *name, WFlags flags )
13 : QListView( parent, name, flags ) 18 : QListView( parent, name, flags )
14{ 19{
15 connect( this, SIGNAL( selectionChanged( QListViewItem * ) ), 20 connect( this, SIGNAL( selectionChanged( QListViewItem * ) ),
16 SLOT( refresh( QListViewItem * ) ) ); 21 SLOT( refresh( QListViewItem * ) ) );
17 connect( this, SIGNAL( mouseButtonPressed(int, QListViewItem *,const QPoint&,int ) ),this, 22 connect( this, SIGNAL( mouseButtonPressed(int, QListViewItem *,const QPoint&,int ) ),this,
18 SLOT( slotHold( int, QListViewItem *,const QPoint&,int ) ) ); 23 SLOT( slotHold( int, QListViewItem *,const QPoint&,int ) ) );
19 setSorting(0); 24 setSorting(0);
20} 25}
21 26
22AccountView::~AccountView() 27AccountView::~AccountView()
23{ 28{
24 imapAccounts.clear(); 29 imapAccounts.clear();
@@ -52,30 +57,36 @@ void AccountView::populate( QList<Account> list )
52 imapAccounts.clear(); 57 imapAccounts.clear();
53 mhAccounts.clear(); 58 mhAccounts.clear();
54 59
55 mhAccounts.append(new MHviewItem(AbstractMail::defaultLocalfolder(),this)); 60 mhAccounts.append(new MHviewItem(AbstractMail::defaultLocalfolder(),this));
56 61
57 Account *it; 62 Account *it;
58 for ( it = list.first(); it; it = list.next() ) { 63 for ( it = list.first(); it; it = list.next() )
59 if ( it->getType().compare( "IMAP" ) == 0 ) { 64 {
65 if ( it->getType().compare( "IMAP" ) == 0 )
66 {
60 IMAPaccount *imap = static_cast<IMAPaccount *>(it); 67 IMAPaccount *imap = static_cast<IMAPaccount *>(it);
61 qDebug( "added IMAP " + imap->getAccountName() ); 68 qDebug( "added IMAP " + imap->getAccountName() );
62 imapAccounts.append(new IMAPviewItem( imap, this )); 69 imapAccounts.append(new IMAPviewItem( imap, this ));
63 } else if ( it->getType().compare( "POP3" ) == 0 ) { 70 }
71 else if ( it->getType().compare( "POP3" ) == 0 )
72 {
64 POP3account *pop3 = static_cast<POP3account *>(it); 73 POP3account *pop3 = static_cast<POP3account *>(it);
65 qDebug( "added POP3 " + pop3->getAccountName() ); 74 qDebug( "added POP3 " + pop3->getAccountName() );
66 /* must not be hold 'cause it isn't required */ 75 /* must not be hold 'cause it isn't required */
67 (void) new POP3viewItem( pop3, this ); 76 (void) new POP3viewItem( pop3, this );
68 } 77 }
69 } 78 }
70} 79}
71 80
72void AccountView::refresh(QListViewItem *item) { 81void AccountView::refresh(QListViewItem *item)
82{
73 83
74 qDebug("AccountView refresh..."); 84 qDebug("AccountView refresh...");
75 if ( item ) { 85 if ( item )
86 {
76 m_currentItem = item; 87 m_currentItem = item;
77 QList<RecMail> headerlist; 88 QList<RecMail> headerlist;
78 headerlist.setAutoDelete(true); 89 headerlist.setAutoDelete(true);
79 AccountViewItem *view = static_cast<AccountViewItem *>(item); 90 AccountViewItem *view = static_cast<AccountViewItem *>(item);
80 view->refresh(headerlist); 91 view->refresh(headerlist);
81 emit refreshMailview(&headerlist); 92 emit refreshMailview(&headerlist);
@@ -92,34 +103,35 @@ void AccountView::refreshCurrent()
92 view->refresh(headerlist); 103 view->refresh(headerlist);
93 emit refreshMailview(&headerlist); 104 emit refreshMailview(&headerlist);
94} 105}
95 106
96void AccountView::refreshAll() 107void AccountView::refreshAll()
97{ 108{
98
99} 109}
100 110
101RecBody AccountView::fetchBody(const RecMail&aMail) 111RecBody AccountView::fetchBody(const RecMail&aMail)
102{ 112{
103 QListViewItem*item = selectedItem (); 113 QListViewItem*item = selectedItem ();
104 if (!item) return RecBody(); 114 if (!item) return RecBody();
105 AccountViewItem *view = static_cast<AccountViewItem *>(item); 115 AccountViewItem *view = static_cast<AccountViewItem *>(item);
106 return view->fetchBody(aMail); 116 return view->fetchBody(aMail);
107} 117}
108 118
109void AccountView::setupFolderselect(Selectstore*sels) 119void AccountView::setupFolderselect(Selectstore*sels)
110{ 120{
111 sels->showMaximized(); 121 QPEApplication::showDialog( sels );
112 QStringList sFolders; 122 QStringList sFolders;
113 unsigned int i = 0; 123 unsigned int i = 0;
114 for (i=0; i < mhAccounts.count();++i) { 124 for (i=0; i < mhAccounts.count();++i)
125 {
115 mhAccounts[i]->refresh(false); 126 mhAccounts[i]->refresh(false);
116 sFolders = mhAccounts[i]->subFolders(); 127 sFolders = mhAccounts[i]->subFolders();
117 sels->addAccounts(mhAccounts[i]->getWrapper(),sFolders); 128 sels->addAccounts(mhAccounts[i]->getWrapper(),sFolders);
118 } 129 }
119 for (i=0; i < imapAccounts.count();++i) { 130 for (i=0; i < imapAccounts.count();++i)
131 {
120 if (imapAccounts[i]->offline()) 132 if (imapAccounts[i]->offline())
121 continue; 133 continue;
122 imapAccounts[i]->refreshFolders(false); 134 imapAccounts[i]->refreshFolders(false);
123 sels->addAccounts(imapAccounts[i]->getWrapper(),imapAccounts[i]->subFolders()); 135 sels->addAccounts(imapAccounts[i]->getWrapper(),imapAccounts[i]->subFolders());
124 } 136 }
125} 137}
@@ -131,18 +143,20 @@ void AccountView::downloadMails(Folder*fromFolder,AbstractMail*fromWrapper)
131 Selectstore sels; 143 Selectstore sels;
132 setupFolderselect(&sels); 144 setupFolderselect(&sels);
133 if (!sels.exec()) return; 145 if (!sels.exec()) return;
134 targetMail = sels.currentMail(); 146 targetMail = sels.currentMail();
135 targetFolder = sels.currentFolder(); 147 targetFolder = sels.currentFolder();
136 if ( (fromWrapper==targetMail && fromFolder->getName()==targetFolder) || 148 if ( (fromWrapper==targetMail && fromFolder->getName()==targetFolder) ||
137 targetFolder.isEmpty()) { 149 targetFolder.isEmpty())
150 {
138 return; 151 return;
139 } 152 }
140 if (sels.newFolder() && !targetMail->createMbox(targetFolder)) { 153 if (sels.newFolder() && !targetMail->createMbox(targetFolder))
154 {
141 QMessageBox::critical(0,tr("Error creating new Folder"), 155 QMessageBox::critical(0,tr("Error creating new Folder"),
142 tr("<center>Error while creating<br>new folder - breaking.</center>")); 156 tr("<center>Error while creating<br>new folder - breaking.</center>"));
143 return; 157 return;
144 } 158 }
145 qDebug("Targetfolder: %s",targetFolder.latin1()); 159 qDebug("Targetfolder: %s",targetFolder.latin1());
146 qDebug("Fromfolder: %s",fromFolder->getName().latin1()); 160 qDebug("Fromfolder: %s",fromFolder->getName().latin1());
147 fromWrapper->mvcpAllMails(fromFolder,targetFolder,targetMail,sels.moveMails()); 161 fromWrapper->mvcpAllMails(fromFolder,targetFolder,targetMail,sels.moveMails());
148 refreshCurrent(); 162 refreshCurrent();