summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-03-26 17:26:28 (UTC)
committer zautrix <zautrix>2005-03-26 17:26:28 (UTC)
commit36dd498ad2f5a2cf43fc08c621669fe42198e5eb (patch) (unidiff)
tree78f826bd02a35e0624d245f267ec5b595350574e
parente3f00322eb77bd03250eb66a2574b640de9aebb4 (diff)
downloadkdepimpi-36dd498ad2f5a2cf43fc08c621669fe42198e5eb.zip
kdepimpi-36dd498ad2f5a2cf43fc08c621669fe42198e5eb.tar.gz
kdepimpi-36dd498ad2f5a2cf43fc08c621669fe42198e5eb.tar.bz2
fix
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kmicromail/accountview.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/kmicromail/accountview.cpp b/kmicromail/accountview.cpp
index e9be224..6227f6d 100644
--- a/kmicromail/accountview.cpp
+++ b/kmicromail/accountview.cpp
@@ -1,233 +1,235 @@
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 if ( !view->getFolder() )
107 return;
106 QString bName = view->getFolder()->getDisplayName(); 108 QString bName = view->getFolder()->getDisplayName();
107 if (bName.startsWith("/")&&bName.length()>1) 109 if (bName.startsWith("/")&&bName.length()>1)
108 { 110 {
109 bName.replace(0,1,""); 111 bName.replace(0,1,"");
110 } 112 }
111 int pos = bName.findRev("/"); 113 int pos = bName.findRev("/");
112 if (pos > 0) 114 if (pos > 0)
113 { 115 {
114 bName.replace(0,pos+1,""); 116 bName.replace(0,pos+1,"");
115 } 117 }
116 //qDebug("name *%s* ",bName.lower().latin1() ); 118 //qDebug("name *%s* ",bName.lower().latin1() );
117 if ( bName.lower() == "outgoing" || bName.lower() == "sent" || bName.lower() == "sendfailed" ) { 119 if ( bName.lower() == "outgoing" || bName.lower() == "sent" || bName.lower() == "sendfailed" ) {
118 refreshCurrent(); 120 refreshCurrent();
119 // qDebug("refresh "); 121 // qDebug("refresh ");
120 } 122 }
121} 123}
122 124
123void AccountView::refreshCurrent() 125void AccountView::refreshCurrent()
124{ 126{
125 m_currentItem = currentItem(); 127 m_currentItem = currentItem();
126 if ( !m_currentItem ) return; 128 if ( !m_currentItem ) return;
127 QValueList<RecMailP> headerlist; 129 QValueList<RecMailP> headerlist;
128 AccountViewItem *view = static_cast<AccountViewItem *>(m_currentItem); 130 AccountViewItem *view = static_cast<AccountViewItem *>(m_currentItem);
129 view->refresh(headerlist); 131 view->refresh(headerlist);
130 emit refreshMailview(headerlist); 132 emit refreshMailview(headerlist);
131} 133}
132 134
133void AccountView::refreshAll() 135void AccountView::refreshAll()
134{ 136{
135} 137}
136 138
137RecBodyP AccountView::fetchBody(const RecMailP&aMail) 139RecBodyP AccountView::fetchBody(const RecMailP&aMail)
138{ 140{
139 QListViewItem*item = selectedItem (); 141 QListViewItem*item = selectedItem ();
140 if (!item) return new RecBody(); 142 if (!item) return new RecBody();
141 AccountViewItem *view = static_cast<AccountViewItem *>(item); 143 AccountViewItem *view = static_cast<AccountViewItem *>(item);
142 return view->fetchBody(aMail); 144 return view->fetchBody(aMail);
143} 145}
144 146
145void AccountView::setupFolderselect(Selectstore*sels) 147void AccountView::setupFolderselect(Selectstore*sels)
146{ 148{
147 149
148#ifndef DESKTOP_VERSION 150#ifndef DESKTOP_VERSION
149 sels->showMaximized(); 151 sels->showMaximized();
150#else 152#else
151 sels->show(); 153 sels->show();
152#endif 154#endif
153 QStringList sFolders; 155 QStringList sFolders;
154 unsigned int i = 0; 156 unsigned int i = 0;
155 for (i=0; i < mhAccounts.count();++i) 157 for (i=0; i < mhAccounts.count();++i)
156 { 158 {
157 mhAccounts[i]->refresh(false); 159 mhAccounts[i]->refresh(false);
158 sFolders = mhAccounts[i]->subFolders(); 160 sFolders = mhAccounts[i]->subFolders();
159 sels->addAccounts(mhAccounts[i]->getWrapper(),sFolders); 161 sels->addAccounts(mhAccounts[i]->getWrapper(),sFolders);
160 } 162 }
161 for (i=0; i < imapAccounts.count();++i) 163 for (i=0; i < imapAccounts.count();++i)
162 { 164 {
163 if (imapAccounts[i]->offline()) 165 if (imapAccounts[i]->offline())
164 continue; 166 continue;
165 imapAccounts[i]->refreshFolders(false); 167 imapAccounts[i]->refreshFolders(false);
166 sels->addAccounts(imapAccounts[i]->getWrapper(),imapAccounts[i]->subFolders()); 168 sels->addAccounts(imapAccounts[i]->getWrapper(),imapAccounts[i]->subFolders());
167 } 169 }
168} 170}
169void AccountView::downloadMailsInbox(const FolderP&fromFolder,AbstractMail*fromWrapper) 171void AccountView::downloadMailsInbox(const FolderP&fromFolder,AbstractMail*fromWrapper)
170{ 172{
171#if 0 173#if 0
172 AbstractMail*targetMail = 0; 174 AbstractMail*targetMail = 0;
173 QString targetFolder = ""; 175 QString targetFolder = "";
174 Selectstore sels; 176 Selectstore sels;
175 setupFolderselect(&sels); 177 setupFolderselect(&sels);
176 if (!sels.exec()) return; 178 if (!sels.exec()) return;
177 targetMail = sels.currentMail(); 179 targetMail = sels.currentMail();
178 targetFolder = sels.currentFolder(); 180 targetFolder = sels.currentFolder();
179 if ( (fromWrapper==targetMail && fromFolder->getName()==targetFolder) || 181 if ( (fromWrapper==targetMail && fromFolder->getName()==targetFolder) ||
180 targetFolder.isEmpty()) 182 targetFolder.isEmpty())
181 { 183 {
182 return; 184 return;
183 } 185 }
184 if (sels.newFolder() && !targetMail->createMbox(targetFolder)) 186 if (sels.newFolder() && !targetMail->createMbox(targetFolder))
185 { 187 {
186 QMessageBox::critical(0,i18n("Error creating new Folder"), 188 QMessageBox::critical(0,i18n("Error creating new Folder"),
187 i18n("<center>Error while creating<br>new folder - breaking.</center>")); 189 i18n("<center>Error while creating<br>new folder - breaking.</center>"));
188 return; 190 return;
189 } 191 }
190 int maxsize = 0; 192 int maxsize = 0;
191 if ( sels.useSize->isChecked()) 193 if ( sels.useSize->isChecked())
192 maxsize = sels.sizeSpinBox->value(); 194 maxsize = sels.sizeSpinBox->value();
193 fromWrapper->mvcpAllMails(fromFolder,targetFolder,targetMail,sels.moveMails(), maxsize); 195 fromWrapper->mvcpAllMails(fromFolder,targetFolder,targetMail,sels.moveMails(), maxsize);
194#endif 196#endif
195 fromWrapper->downloadNewMails( fromFolder, mhAccounts[0]->getWrapper()); 197 fromWrapper->downloadNewMails( fromFolder, mhAccounts[0]->getWrapper());
196 refreshCurrent(); 198 refreshCurrent();
197 199
198} 200}
199 201
200void AccountView::downloadMails(const FolderP&fromFolder,AbstractMail*fromWrapper) 202void AccountView::downloadMails(const FolderP&fromFolder,AbstractMail*fromWrapper)
201{ 203{
202 AbstractMail*targetMail = 0; 204 AbstractMail*targetMail = 0;
203 QString targetFolder = ""; 205 QString targetFolder = "";
204 Selectstore sels; 206 Selectstore sels;
205 setupFolderselect(&sels); 207 setupFolderselect(&sels);
206 if (!sels.exec()) return; 208 if (!sels.exec()) return;
207 targetMail = sels.currentMail(); 209 targetMail = sels.currentMail();
208 targetFolder = sels.currentFolder(); 210 targetFolder = sels.currentFolder();
209 if ( (fromWrapper==targetMail && fromFolder->getName()==targetFolder) || 211 if ( (fromWrapper==targetMail && fromFolder->getName()==targetFolder) ||
210 targetFolder.isEmpty()) 212 targetFolder.isEmpty())
211 { 213 {
212 return; 214 return;
213 } 215 }
214 if (sels.newFolder() && !targetMail->createMbox(targetFolder)) 216 if (sels.newFolder() && !targetMail->createMbox(targetFolder))
215 { 217 {
216 QMessageBox::critical(0,i18n("Error creating new Folder"), 218 QMessageBox::critical(0,i18n("Error creating new Folder"),
217 i18n("<center>Error while creating<br>new folder - breaking.</center>")); 219 i18n("<center>Error while creating<br>new folder - breaking.</center>"));
218 return; 220 return;
219 } 221 }
220 int maxsize = 0; 222 int maxsize = 0;
221 if ( sels.useSize->isChecked()) 223 if ( sels.useSize->isChecked())
222 maxsize = sels.sizeSpinBox->value(); 224 maxsize = sels.sizeSpinBox->value();
223 225
224 fromWrapper->mvcpAllMails(fromFolder,targetFolder,targetMail,sels.moveMails(), maxsize); 226 fromWrapper->mvcpAllMails(fromFolder,targetFolder,targetMail,sels.moveMails(), maxsize);
225 refreshCurrent(); 227 refreshCurrent();
226} 228}
227 229
228bool AccountView::currentisDraft() 230bool AccountView::currentisDraft()
229{ 231{
230 AccountViewItem *view = static_cast<AccountViewItem *>(currentItem()); 232 AccountViewItem *view = static_cast<AccountViewItem *>(currentItem());
231 if (!view) return false; 233 if (!view) return false;
232 return view->isDraftfolder(); 234 return view->isDraftfolder();
233} 235}