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