summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/accountview.cpp1
1 files changed, 0 insertions, 1 deletions
diff --git a/noncore/net/mail/accountview.cpp b/noncore/net/mail/accountview.cpp
index d01d6bb..faa42c3 100644
--- a/noncore/net/mail/accountview.cpp
+++ b/noncore/net/mail/accountview.cpp
@@ -1,214 +1,213 @@
1 1
2#include "accountview.h" 2#include "accountview.h"
3#include "accountitem.h" 3#include "accountitem.h"
4#include "selectstore.h" 4#include "selectstore.h"
5 5
6#include <libmailwrapper/settings.h> 6#include <libmailwrapper/settings.h>
7#include <libmailwrapper/mailwrapper.h> 7#include <libmailwrapper/mailwrapper.h>
8#include <libmailwrapper/mailtypes.h> 8#include <libmailwrapper/mailtypes.h>
9#include <libmailwrapper/abstractmail.h> 9#include <libmailwrapper/abstractmail.h>
10 10
11/* OPIE */ 11/* OPIE */
12#include <opie2/odebug.h> 12#include <opie2/odebug.h>
13#include <qpe/qpeapplication.h> 13#include <qpe/qpeapplication.h>
14 14
15/* QT */ 15/* QT */
16#include <qmessagebox.h> 16#include <qmessagebox.h>
17#include <qpopupmenu.h> 17#include <qpopupmenu.h>
18 18
19using namespace Opie::Core; 19using namespace Opie::Core;
20AccountView::AccountView( QWidget *parent, const char *name, WFlags flags ) 20AccountView::AccountView( QWidget *parent, const char *name, WFlags flags )
21 : QListView( parent, name, flags ) 21 : QListView( parent, name, flags )
22{ 22{
23 setSorting(0); 23 setSorting(0);
24 setSelectionMode(Single); 24 setSelectionMode(Single);
25 m_rightPressed = false; 25 m_rightPressed = false;
26 26
27 connect( this, SIGNAL( selectionChanged(QListViewItem*) ), 27 connect( this, SIGNAL( selectionChanged(QListViewItem*) ),
28 SLOT( slotSelectionChanged(QListViewItem*) ) ); 28 SLOT( slotSelectionChanged(QListViewItem*) ) );
29 connect( this, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ),this, 29 connect( this, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ),this,
30 SLOT( slotMouseButton(int,QListViewItem*,const QPoint&,int) ) ); 30 SLOT( slotMouseButton(int,QListViewItem*,const QPoint&,int) ) );
31 connect( this, SIGNAL(clicked(QListViewItem*) ),this, 31 connect( this, SIGNAL(clicked(QListViewItem*) ),this,
32 SLOT( slotMouseClicked(QListViewItem*) ) ); 32 SLOT( slotMouseClicked(QListViewItem*) ) );
33 m_currentItem = 0; 33 m_currentItem = 0;
34} 34}
35 35
36AccountView::~AccountView() 36AccountView::~AccountView()
37{ 37{
38 imapAccounts.clear(); 38 imapAccounts.clear();
39 mhAccounts.clear(); 39 mhAccounts.clear();
40} 40}
41 41
42void AccountView::slotSelectionChanged(QListViewItem*item) 42void AccountView::slotSelectionChanged(QListViewItem*item)
43{ 43{
44 odebug << "AccountView: Selection changed" << oendl; 44 odebug << "AccountView: Selection changed" << oendl;
45 if (!item) { 45 if (!item) {
46 emit serverSelected(0); 46 emit serverSelected(0);
47 return; 47 return;
48 } 48 }
49 AccountViewItem *view = static_cast<AccountViewItem *>(item); 49 AccountViewItem *view = static_cast<AccountViewItem *>(item);
50 50
51 emit serverSelected(view->isServer()); 51 emit serverSelected(view->isServer());
52} 52}
53 53
54void AccountView::slotContextMenu(int id) 54void AccountView::slotContextMenu(int id)
55{ 55{
56 AccountViewItem *view = static_cast<AccountViewItem *>(currentItem()); 56 AccountViewItem *view = static_cast<AccountViewItem *>(currentItem());
57 if (!view) return; 57 if (!view) return;
58 view->contextMenuSelected(id); 58 view->contextMenuSelected(id);
59} 59}
60 60
61void AccountView::slotRightButton(int button, QListViewItem * item,const QPoint&,int) 61void AccountView::slotRightButton(int button, QListViewItem * item,const QPoint&,int)
62{ 62{
63 m_rightPressed = true; 63 m_rightPressed = true;
64 if (!item) return; 64 if (!item) return;
65 AccountViewItem *view = static_cast<AccountViewItem *>(item); 65 AccountViewItem *view = static_cast<AccountViewItem *>(item);
66 QPopupMenu*m = view->getContextMenu(); 66 QPopupMenu*m = view->getContextMenu();
67 if (!m) return; 67 if (!m) return;
68 connect(m,SIGNAL(activated(int)),this,SLOT(slotContextMenu(int))); 68 connect(m,SIGNAL(activated(int)),this,SLOT(slotContextMenu(int)));
69 m->setFocus(); 69 m->setFocus();
70 m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); 70 m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) );
71 delete m; 71 delete m;
72 setSelected(item,true);
73} 72}
74 73
75void AccountView::slotLeftButton(int button, QListViewItem * item,const QPoint&,int) 74void AccountView::slotLeftButton(int button, QListViewItem * item,const QPoint&,int)
76{ 75{
77 m_rightPressed = false; 76 m_rightPressed = false;
78} 77}
79 78
80void AccountView::slotMouseClicked(QListViewItem*item) 79void AccountView::slotMouseClicked(QListViewItem*item)
81{ 80{
82 if (m_rightPressed) return; 81 if (m_rightPressed) return;
83 if (!item || m_currentItem == item) return; 82 if (!item || m_currentItem == item) return;
84 /* ### ToDo check settings if on single tab it should open */ 83 /* ### ToDo check settings if on single tab it should open */
85 m_currentItem = item; 84 m_currentItem = item;
86 refresh(m_currentItem); 85 refresh(m_currentItem);
87} 86}
88 87
89void AccountView::slotMouseButton(int button, QListViewItem * item,const QPoint&pos,int column) 88void AccountView::slotMouseButton(int button, QListViewItem * item,const QPoint&pos,int column)
90{ 89{
91 if (button==1) { 90 if (button==1) {
92 slotLeftButton(button,item,pos,column); 91 slotLeftButton(button,item,pos,column);
93 } else if (button==2) { 92 } else if (button==2) {
94 slotRightButton(button,item,pos,column); 93 slotRightButton(button,item,pos,column);
95 } 94 }
96} 95}
97 96
98void AccountView::populate( QList<Account> list ) 97void AccountView::populate( QList<Account> list )
99{ 98{
100 clear(); 99 clear();
101 100
102 imapAccounts.clear(); 101 imapAccounts.clear();
103 mhAccounts.clear(); 102 mhAccounts.clear();
104 mhAccounts.append(new MHviewItem(AbstractMail::defaultLocalfolder(),this)); 103 mhAccounts.append(new MHviewItem(AbstractMail::defaultLocalfolder(),this));
105 104
106 Account *it; 105 Account *it;
107 for ( it = list.first(); it; it = list.next() ) { 106 for ( it = list.first(); it; it = list.next() ) {
108 if ( it->getType() == MAILLIB::A_IMAP ) { 107 if ( it->getType() == MAILLIB::A_IMAP ) {
109 IMAPaccount *imap = static_cast<IMAPaccount *>(it); 108 IMAPaccount *imap = static_cast<IMAPaccount *>(it);
110 odebug << "added IMAP " + imap->getAccountName() << oendl; 109 odebug << "added IMAP " + imap->getAccountName() << oendl;
111 imapAccounts.append(new IMAPviewItem( imap, this )); 110 imapAccounts.append(new IMAPviewItem( imap, this ));
112 } else if ( it->getType() == MAILLIB::A_POP3 ) { 111 } else if ( it->getType() == MAILLIB::A_POP3 ) {
113 POP3account *pop3 = static_cast<POP3account *>(it); 112 POP3account *pop3 = static_cast<POP3account *>(it);
114 odebug << "added POP3 " + pop3->getAccountName() << oendl; 113 odebug << "added POP3 " + pop3->getAccountName() << oendl;
115 /* must not be hold 'cause it isn't required */ 114 /* must not be hold 'cause it isn't required */
116 (void) new POP3viewItem( pop3, this ); 115 (void) new POP3viewItem( pop3, this );
117 } else if ( it->getType() == MAILLIB::A_NNTP ) { 116 } else if ( it->getType() == MAILLIB::A_NNTP ) {
118 NNTPaccount *nntp = static_cast<NNTPaccount *>(it); 117 NNTPaccount *nntp = static_cast<NNTPaccount *>(it);
119 odebug << "added NNTP " + nntp->getAccountName() << oendl; 118 odebug << "added NNTP " + nntp->getAccountName() << oendl;
120 /* must not be hold 'cause it isn't required */ 119 /* must not be hold 'cause it isn't required */
121 (void) new NNTPviewItem( nntp, this ); 120 (void) new NNTPviewItem( nntp, this );
122 } else if ( it->getType() == MAILLIB::A_MH ) { 121 } else if ( it->getType() == MAILLIB::A_MH ) {
123 } 122 }
124 } 123 }
125} 124}
126 125
127void AccountView::refresh(QListViewItem *item) 126void AccountView::refresh(QListViewItem *item)
128{ 127{
129 128
130 odebug << "AccountView refresh..." << oendl; 129 odebug << "AccountView refresh..." << oendl;
131 if ( item ) 130 if ( item )
132 { 131 {
133 m_currentItem = item; 132 m_currentItem = item;
134 QValueList<RecMailP> headerlist; 133 QValueList<RecMailP> headerlist;
135 AccountViewItem *view = static_cast<AccountViewItem *>(item); 134 AccountViewItem *view = static_cast<AccountViewItem *>(item);
136 view->refresh(headerlist); 135 view->refresh(headerlist);
137 emit refreshMailview(headerlist); 136 emit refreshMailview(headerlist);
138 } 137 }
139} 138}
140 139
141void AccountView::refreshCurrent() 140void AccountView::refreshCurrent()
142{ 141{
143 m_currentItem = currentItem(); 142 m_currentItem = currentItem();
144 if ( !m_currentItem ) return; 143 if ( !m_currentItem ) return;
145 QValueList<RecMailP> headerlist; 144 QValueList<RecMailP> headerlist;
146 AccountViewItem *view = static_cast<AccountViewItem *>(m_currentItem); 145 AccountViewItem *view = static_cast<AccountViewItem *>(m_currentItem);
147 view->refresh(headerlist); 146 view->refresh(headerlist);
148 emit refreshMailview(headerlist); 147 emit refreshMailview(headerlist);
149} 148}
150 149
151void AccountView::refreshAll() 150void AccountView::refreshAll()
152{ 151{
153} 152}
154 153
155RecBodyP AccountView::fetchBody(const RecMailP&aMail) 154RecBodyP AccountView::fetchBody(const RecMailP&aMail)
156{ 155{
157 QListViewItem*item = selectedItem (); 156 QListViewItem*item = selectedItem ();
158 if (!item) return new RecBody(); 157 if (!item) return new RecBody();
159 AccountViewItem *view = static_cast<AccountViewItem *>(item); 158 AccountViewItem *view = static_cast<AccountViewItem *>(item);
160 return view->fetchBody(aMail); 159 return view->fetchBody(aMail);
161} 160}
162 161
163void AccountView::setupFolderselect(Selectstore*sels) 162void AccountView::setupFolderselect(Selectstore*sels)
164{ 163{
165 QPEApplication::showDialog( sels ); 164 QPEApplication::showDialog( sels );
166 QStringList sFolders; 165 QStringList sFolders;
167 unsigned int i = 0; 166 unsigned int i = 0;
168 for (i=0; i < mhAccounts.count();++i) 167 for (i=0; i < mhAccounts.count();++i)
169 { 168 {
170 mhAccounts[i]->refresh(false); 169 mhAccounts[i]->refresh(false);
171 sFolders = mhAccounts[i]->subFolders(); 170 sFolders = mhAccounts[i]->subFolders();
172 sels->addAccounts(mhAccounts[i]->getWrapper(),sFolders); 171 sels->addAccounts(mhAccounts[i]->getWrapper(),sFolders);
173 } 172 }
174 for (i=0; i < imapAccounts.count();++i) 173 for (i=0; i < imapAccounts.count();++i)
175 { 174 {
176 if (imapAccounts[i]->offline()) 175 if (imapAccounts[i]->offline())
177 continue; 176 continue;
178 imapAccounts[i]->refreshFolders(false); 177 imapAccounts[i]->refreshFolders(false);
179 sels->addAccounts(imapAccounts[i]->getWrapper(),imapAccounts[i]->subFolders()); 178 sels->addAccounts(imapAccounts[i]->getWrapper(),imapAccounts[i]->subFolders());
180 } 179 }
181} 180}
182 181
183void AccountView::downloadMails(const FolderP&fromFolder,AbstractMail*fromWrapper) 182void AccountView::downloadMails(const FolderP&fromFolder,AbstractMail*fromWrapper)
184{ 183{
185 AbstractMail*targetMail = 0; 184 AbstractMail*targetMail = 0;
186 QString targetFolder = ""; 185 QString targetFolder = "";
187 Selectstore sels; 186 Selectstore sels;
188 setupFolderselect(&sels); 187 setupFolderselect(&sels);
189 if (!sels.exec()) return; 188 if (!sels.exec()) return;
190 targetMail = sels.currentMail(); 189 targetMail = sels.currentMail();
191 targetFolder = sels.currentFolder(); 190 targetFolder = sels.currentFolder();
192 if ( (fromWrapper==targetMail && fromFolder->getName()==targetFolder) || 191 if ( (fromWrapper==targetMail && fromFolder->getName()==targetFolder) ||
193 targetFolder.isEmpty()) 192 targetFolder.isEmpty())
194 { 193 {
195 return; 194 return;
196 } 195 }
197 if (sels.newFolder() && !targetMail->createMbox(targetFolder)) 196 if (sels.newFolder() && !targetMail->createMbox(targetFolder))
198 { 197 {
199 QMessageBox::critical(0,tr("Error creating new Folder"), 198 QMessageBox::critical(0,tr("Error creating new Folder"),
200 tr("<center>Error while creating<br>new folder - breaking.</center>")); 199 tr("<center>Error while creating<br>new folder - breaking.</center>"));
201 return; 200 return;
202 } 201 }
203 odebug << "Targetfolder: " << targetFolder.latin1() << "" << oendl; 202 odebug << "Targetfolder: " << targetFolder.latin1() << "" << oendl;
204 odebug << "Fromfolder: " << fromFolder->getName().latin1() << "" << oendl; 203 odebug << "Fromfolder: " << fromFolder->getName().latin1() << "" << oendl;
205 fromWrapper->mvcpAllMails(fromFolder,targetFolder,targetMail,sels.moveMails()); 204 fromWrapper->mvcpAllMails(fromFolder,targetFolder,targetMail,sels.moveMails());
206 refreshCurrent(); 205 refreshCurrent();
207} 206}
208 207
209bool AccountView::currentisDraft() 208bool AccountView::currentisDraft()
210{ 209{
211 AccountViewItem *view = static_cast<AccountViewItem *>(currentItem()); 210 AccountViewItem *view = static_cast<AccountViewItem *>(currentItem());
212 if (!view) return false; 211 if (!view) return false;
213 return view->isDraftfolder(); 212 return view->isDraftfolder();
214} 213}