summaryrefslogtreecommitdiffabout
path: root/kmicromail/accountview.cpp
authorzautrix <zautrix>2005-02-28 15:30:47 (UTC)
committer zautrix <zautrix>2005-02-28 15:30:47 (UTC)
commit16575cca67c9047de72530080dfeb5793a66c935 (patch) (unidiff)
treefec5ada5eee13fad9c73ec04cd066ccaf2619d4a /kmicromail/accountview.cpp
parentb1f912cbb6a9daf050e94d337de0e0e73417284a (diff)
downloadkdepimpi-16575cca67c9047de72530080dfeb5793a66c935.zip
kdepimpi-16575cca67c9047de72530080dfeb5793a66c935.tar.gz
kdepimpi-16575cca67c9047de72530080dfeb5793a66c935.tar.bz2
mail fix
Diffstat (limited to 'kmicromail/accountview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kmicromail/accountview.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/kmicromail/accountview.cpp b/kmicromail/accountview.cpp
index 3ad3e9b..e9be224 100644
--- a/kmicromail/accountview.cpp
+++ b/kmicromail/accountview.cpp
@@ -1,230 +1,233 @@
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 <qpe/qpeapplication.h> 12#include <qpe/qpeapplication.h>
13 13
14/* QT */ 14/* QT */
15#include <qmessagebox.h> 15#include <qmessagebox.h>
16#include <qpopupmenu.h> 16#include <qpopupmenu.h>
17#include <qcheckbox.h> 17#include <qcheckbox.h>
18#include <qspinbox.h> 18#include <qspinbox.h>
19#include <klocale.h> 19#include <klocale.h>
20 20
21using namespace Opie::Core; 21using namespace Opie::Core;
22AccountView::AccountView( QWidget *parent, const char *name, WFlags flags ) 22AccountView::AccountView( QWidget *parent, const char *name, WFlags flags )
23 : QListView( parent, name, flags ) 23 : QListView( parent, name, flags )
24{ 24{
25 connect( this, SIGNAL( selectionChanged(QListViewItem*) ), 25 connect( this, SIGNAL( selectionChanged(QListViewItem*) ),
26 SLOT( refresh(QListViewItem*) ) ); 26 SLOT( refresh(QListViewItem*) ) );
27 connect( this, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ),this, 27 connect( this, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ),this,
28 SLOT( slotHold(int,QListViewItem*,const QPoint&,int) ) ); 28 SLOT( slotHold(int,QListViewItem*,const QPoint&,int) ) );
29 setSorting(0); 29 setSorting(0);
30} 30}
31 31
32AccountView::~AccountView() 32AccountView::~AccountView()
33{ 33{
34 imapAccounts.clear(); 34 imapAccounts.clear();
35 mhAccounts.clear(); 35 mhAccounts.clear();
36} 36}
37 37
38void AccountView::slotContextMenu(int id) 38void AccountView::slotContextMenu(int id)
39{ 39{
40 AccountViewItem *view = static_cast<AccountViewItem *>(currentItem()); 40 AccountViewItem *view = static_cast<AccountViewItem *>(currentItem());
41 if (!view) return; 41 if (!view) return;
42 view->contextMenuSelected(id); 42 view->contextMenuSelected(id);
43} 43}
44 44
45void AccountView::slotHold(int button, QListViewItem * item,const QPoint&,int) 45void AccountView::slotHold(int button, QListViewItem * item,const QPoint&,int)
46{ 46{
47 if (button==1) {return;} 47 if (button==1) {return;}
48 if (!item) return; 48 if (!item) return;
49 AccountViewItem *view = static_cast<AccountViewItem *>(item); 49 AccountViewItem *view = static_cast<AccountViewItem *>(item);
50 QPopupMenu*m = view->getContextMenu(); 50 QPopupMenu*m = view->getContextMenu();
51 if (!m) return; 51 if (!m) return;
52 connect(m,SIGNAL(activated(int)),this,SLOT(slotContextMenu(int))); 52 connect(m,SIGNAL(activated(int)),this,SLOT(slotContextMenu(int)));
53 m->setFocus(); 53 m->setFocus();
54 m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); 54 m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) );
55 delete m; 55 delete m;
56} 56}
57 57
58void AccountView::populate( QList<Account> list ) 58void AccountView::populate( QList<Account> list )
59{ 59{
60 clear(); 60 clear();
61 61
62 imapAccounts.clear(); 62 imapAccounts.clear();
63 mhAccounts.clear(); 63 mhAccounts.clear();
64 64
65 mhAccounts.append(new MHviewItem(AbstractMail::defaultLocalfolder(),this)); 65 mhAccounts.append(new MHviewItem(AbstractMail::defaultLocalfolder(),this));
66 66
67 Account *it; 67 Account *it;
68 for ( it = list.first(); it; it = list.next() ) 68 for ( it = list.first(); it; it = list.next() )
69 { 69 {
70 if ( it->getType() == MAILLIB::A_IMAP ) 70 if ( it->getType() == MAILLIB::A_IMAP )
71 { 71 {
72 IMAPaccount *imap = static_cast<IMAPaccount *>(it); 72 IMAPaccount *imap = static_cast<IMAPaccount *>(it);
73 imapAccounts.append(new IMAPviewItem( imap, this )); 73 imapAccounts.append(new IMAPviewItem( imap, this ));
74 } 74 }
75 else if ( it->getType() == MAILLIB::A_POP3 ) 75 else if ( it->getType() == MAILLIB::A_POP3 )
76 { 76 {
77 POP3account *pop3 = static_cast<POP3account *>(it); 77 POP3account *pop3 = static_cast<POP3account *>(it);
78 /* must not be hold 'cause it isn't required */ 78 /* must not be hold 'cause it isn't required */
79 (void) new POP3viewItem( pop3, this ); 79 (void) new POP3viewItem( pop3, this );
80 } 80 }
81 else if ( it->getType() == MAILLIB::A_NNTP ) 81 else if ( it->getType() == MAILLIB::A_NNTP )
82 { 82 {
83 NNTPaccount *nntp = static_cast<NNTPaccount *>(it); 83 NNTPaccount *nntp = static_cast<NNTPaccount *>(it);
84 /* must not be hold 'cause it isn't required */ 84 /* must not be hold 'cause it isn't required */
85 (void) new NNTPviewItem( nntp, this ); 85 (void) new NNTPviewItem( nntp, this );
86 } 86 }
87 } 87 }
88} 88}
89 89
90void AccountView::refresh(QListViewItem *item) 90void AccountView::refresh(QListViewItem *item)
91{ 91{
92 if ( item ) 92 if ( item )
93 { 93 {
94 m_currentItem = item; 94 m_currentItem = item;
95 QValueList<RecMailP> headerlist; 95 QValueList<RecMailP> headerlist;
96 AccountViewItem *view = static_cast<AccountViewItem *>(item); 96 AccountViewItem *view = static_cast<AccountViewItem *>(item);
97 view->refresh(headerlist); 97 view->refresh(headerlist);
98 emit refreshMailview(headerlist); 98 emit refreshMailview(headerlist);
99 } 99 }
100} 100}
101void AccountView::refreshOutgoing() 101void AccountView::refreshOutgoing()
102{ 102{
103 m_currentItem = currentItem(); 103 m_currentItem = currentItem();
104 if ( !m_currentItem ) return; 104 if ( !m_currentItem ) return;
105 AccountViewItem *view = static_cast<AccountViewItem *>(m_currentItem); 105 AccountViewItem *view = static_cast<AccountViewItem *>(m_currentItem);
106 QString bName = view->getFolder()->getDisplayName(); 106 QString bName = view->getFolder()->getDisplayName();
107 if (bName.startsWith("/")&&bName.length()>1) 107 if (bName.startsWith("/")&&bName.length()>1)
108 { 108 {
109 bName.replace(0,1,""); 109 bName.replace(0,1,"");
110 } 110 }
111 int pos = bName.findRev("/"); 111 int pos = bName.findRev("/");
112 if (pos > 0) 112 if (pos > 0)
113 { 113 {
114 bName.replace(0,pos+1,""); 114 bName.replace(0,pos+1,"");
115 } 115 }
116 if ( bName.lower() == "outgoing" ) 116 //qDebug("name *%s* ",bName.lower().latin1() );
117 if ( bName.lower() == "outgoing" || bName.lower() == "sent" || bName.lower() == "sendfailed" ) {
117 refreshCurrent(); 118 refreshCurrent();
119 // qDebug("refresh ");
120 }
118} 121}
119 122
120void AccountView::refreshCurrent() 123void AccountView::refreshCurrent()
121{ 124{
122 m_currentItem = currentItem(); 125 m_currentItem = currentItem();
123 if ( !m_currentItem ) return; 126 if ( !m_currentItem ) return;
124 QValueList<RecMailP> headerlist; 127 QValueList<RecMailP> headerlist;
125 AccountViewItem *view = static_cast<AccountViewItem *>(m_currentItem); 128 AccountViewItem *view = static_cast<AccountViewItem *>(m_currentItem);
126 view->refresh(headerlist); 129 view->refresh(headerlist);
127 emit refreshMailview(headerlist); 130 emit refreshMailview(headerlist);
128} 131}
129 132
130void AccountView::refreshAll() 133void AccountView::refreshAll()
131{ 134{
132} 135}
133 136
134RecBodyP AccountView::fetchBody(const RecMailP&aMail) 137RecBodyP AccountView::fetchBody(const RecMailP&aMail)
135{ 138{
136 QListViewItem*item = selectedItem (); 139 QListViewItem*item = selectedItem ();
137 if (!item) return new RecBody(); 140 if (!item) return new RecBody();
138 AccountViewItem *view = static_cast<AccountViewItem *>(item); 141 AccountViewItem *view = static_cast<AccountViewItem *>(item);
139 return view->fetchBody(aMail); 142 return view->fetchBody(aMail);
140} 143}
141 144
142void AccountView::setupFolderselect(Selectstore*sels) 145void AccountView::setupFolderselect(Selectstore*sels)
143{ 146{
144 147
145#ifndef DESKTOP_VERSION 148#ifndef DESKTOP_VERSION
146 sels->showMaximized(); 149 sels->showMaximized();
147#else 150#else
148 sels->show(); 151 sels->show();
149#endif 152#endif
150 QStringList sFolders; 153 QStringList sFolders;
151 unsigned int i = 0; 154 unsigned int i = 0;
152 for (i=0; i < mhAccounts.count();++i) 155 for (i=0; i < mhAccounts.count();++i)
153 { 156 {
154 mhAccounts[i]->refresh(false); 157 mhAccounts[i]->refresh(false);
155 sFolders = mhAccounts[i]->subFolders(); 158 sFolders = mhAccounts[i]->subFolders();
156 sels->addAccounts(mhAccounts[i]->getWrapper(),sFolders); 159 sels->addAccounts(mhAccounts[i]->getWrapper(),sFolders);
157 } 160 }
158 for (i=0; i < imapAccounts.count();++i) 161 for (i=0; i < imapAccounts.count();++i)
159 { 162 {
160 if (imapAccounts[i]->offline()) 163 if (imapAccounts[i]->offline())
161 continue; 164 continue;
162 imapAccounts[i]->refreshFolders(false); 165 imapAccounts[i]->refreshFolders(false);
163 sels->addAccounts(imapAccounts[i]->getWrapper(),imapAccounts[i]->subFolders()); 166 sels->addAccounts(imapAccounts[i]->getWrapper(),imapAccounts[i]->subFolders());
164 } 167 }
165} 168}
166void AccountView::downloadMailsInbox(const FolderP&fromFolder,AbstractMail*fromWrapper) 169void AccountView::downloadMailsInbox(const FolderP&fromFolder,AbstractMail*fromWrapper)
167{ 170{
168#if 0 171#if 0
169 AbstractMail*targetMail = 0; 172 AbstractMail*targetMail = 0;
170 QString targetFolder = ""; 173 QString targetFolder = "";
171 Selectstore sels; 174 Selectstore sels;
172 setupFolderselect(&sels); 175 setupFolderselect(&sels);
173 if (!sels.exec()) return; 176 if (!sels.exec()) return;
174 targetMail = sels.currentMail(); 177 targetMail = sels.currentMail();
175 targetFolder = sels.currentFolder(); 178 targetFolder = sels.currentFolder();
176 if ( (fromWrapper==targetMail && fromFolder->getName()==targetFolder) || 179 if ( (fromWrapper==targetMail && fromFolder->getName()==targetFolder) ||
177 targetFolder.isEmpty()) 180 targetFolder.isEmpty())
178 { 181 {
179 return; 182 return;
180 } 183 }
181 if (sels.newFolder() && !targetMail->createMbox(targetFolder)) 184 if (sels.newFolder() && !targetMail->createMbox(targetFolder))
182 { 185 {
183 QMessageBox::critical(0,i18n("Error creating new Folder"), 186 QMessageBox::critical(0,i18n("Error creating new Folder"),
184 i18n("<center>Error while creating<br>new folder - breaking.</center>")); 187 i18n("<center>Error while creating<br>new folder - breaking.</center>"));
185 return; 188 return;
186 } 189 }
187 int maxsize = 0; 190 int maxsize = 0;
188 if ( sels.useSize->isChecked()) 191 if ( sels.useSize->isChecked())
189 maxsize = sels.sizeSpinBox->value(); 192 maxsize = sels.sizeSpinBox->value();
190 fromWrapper->mvcpAllMails(fromFolder,targetFolder,targetMail,sels.moveMails(), maxsize); 193 fromWrapper->mvcpAllMails(fromFolder,targetFolder,targetMail,sels.moveMails(), maxsize);
191#endif 194#endif
192 fromWrapper->downloadNewMails( fromFolder, mhAccounts[0]->getWrapper()); 195 fromWrapper->downloadNewMails( fromFolder, mhAccounts[0]->getWrapper());
193 refreshCurrent(); 196 refreshCurrent();
194 197
195} 198}
196 199
197void AccountView::downloadMails(const FolderP&fromFolder,AbstractMail*fromWrapper) 200void AccountView::downloadMails(const FolderP&fromFolder,AbstractMail*fromWrapper)
198{ 201{
199 AbstractMail*targetMail = 0; 202 AbstractMail*targetMail = 0;
200 QString targetFolder = ""; 203 QString targetFolder = "";
201 Selectstore sels; 204 Selectstore sels;
202 setupFolderselect(&sels); 205 setupFolderselect(&sels);
203 if (!sels.exec()) return; 206 if (!sels.exec()) return;
204 targetMail = sels.currentMail(); 207 targetMail = sels.currentMail();
205 targetFolder = sels.currentFolder(); 208 targetFolder = sels.currentFolder();
206 if ( (fromWrapper==targetMail && fromFolder->getName()==targetFolder) || 209 if ( (fromWrapper==targetMail && fromFolder->getName()==targetFolder) ||
207 targetFolder.isEmpty()) 210 targetFolder.isEmpty())
208 { 211 {
209 return; 212 return;
210 } 213 }
211 if (sels.newFolder() && !targetMail->createMbox(targetFolder)) 214 if (sels.newFolder() && !targetMail->createMbox(targetFolder))
212 { 215 {
213 QMessageBox::critical(0,i18n("Error creating new Folder"), 216 QMessageBox::critical(0,i18n("Error creating new Folder"),
214 i18n("<center>Error while creating<br>new folder - breaking.</center>")); 217 i18n("<center>Error while creating<br>new folder - breaking.</center>"));
215 return; 218 return;
216 } 219 }
217 int maxsize = 0; 220 int maxsize = 0;
218 if ( sels.useSize->isChecked()) 221 if ( sels.useSize->isChecked())
219 maxsize = sels.sizeSpinBox->value(); 222 maxsize = sels.sizeSpinBox->value();
220 223
221 fromWrapper->mvcpAllMails(fromFolder,targetFolder,targetMail,sels.moveMails(), maxsize); 224 fromWrapper->mvcpAllMails(fromFolder,targetFolder,targetMail,sels.moveMails(), maxsize);
222 refreshCurrent(); 225 refreshCurrent();
223} 226}
224 227
225bool AccountView::currentisDraft() 228bool AccountView::currentisDraft()
226{ 229{
227 AccountViewItem *view = static_cast<AccountViewItem *>(currentItem()); 230 AccountViewItem *view = static_cast<AccountViewItem *>(currentItem());
228 if (!view) return false; 231 if (!view) return false;
229 return view->isDraftfolder(); 232 return view->isDraftfolder();
230} 233}