summaryrefslogtreecommitdiffabout
path: root/kmicromail/accountview.cpp
Unidiff
Diffstat (limited to 'kmicromail/accountview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kmicromail/accountview.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/kmicromail/accountview.cpp b/kmicromail/accountview.cpp
index c10d384..c9c4a0f 100644
--- a/kmicromail/accountview.cpp
+++ b/kmicromail/accountview.cpp
@@ -1,207 +1,212 @@
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}
101 101
102void AccountView::refreshCurrent() 102void AccountView::refreshCurrent()
103{ 103{
104 m_currentItem = currentItem(); 104 m_currentItem = currentItem();
105 if ( !m_currentItem ) return; 105 if ( !m_currentItem ) return;
106 QValueList<RecMailP> headerlist; 106 QValueList<RecMailP> headerlist;
107 AccountViewItem *view = static_cast<AccountViewItem *>(m_currentItem); 107 AccountViewItem *view = static_cast<AccountViewItem *>(m_currentItem);
108 view->refresh(headerlist); 108 view->refresh(headerlist);
109 emit refreshMailview(headerlist); 109 emit refreshMailview(headerlist);
110} 110}
111 111
112void AccountView::refreshAll() 112void AccountView::refreshAll()
113{ 113{
114} 114}
115 115
116RecBodyP AccountView::fetchBody(const RecMailP&aMail) 116RecBodyP AccountView::fetchBody(const RecMailP&aMail)
117{ 117{
118 QListViewItem*item = selectedItem (); 118 QListViewItem*item = selectedItem ();
119 if (!item) return new RecBody(); 119 if (!item) return new RecBody();
120 AccountViewItem *view = static_cast<AccountViewItem *>(item); 120 AccountViewItem *view = static_cast<AccountViewItem *>(item);
121 return view->fetchBody(aMail); 121 return view->fetchBody(aMail);
122} 122}
123 123
124void AccountView::setupFolderselect(Selectstore*sels) 124void AccountView::setupFolderselect(Selectstore*sels)
125{ 125{
126
127#ifndef DESKTOP_VERSION
126 sels->showMaximized(); 128 sels->showMaximized();
129#else
130 sels->show();
131#endif
127 QStringList sFolders; 132 QStringList sFolders;
128 unsigned int i = 0; 133 unsigned int i = 0;
129 for (i=0; i < mhAccounts.count();++i) 134 for (i=0; i < mhAccounts.count();++i)
130 { 135 {
131 mhAccounts[i]->refresh(false); 136 mhAccounts[i]->refresh(false);
132 sFolders = mhAccounts[i]->subFolders(); 137 sFolders = mhAccounts[i]->subFolders();
133 sels->addAccounts(mhAccounts[i]->getWrapper(),sFolders); 138 sels->addAccounts(mhAccounts[i]->getWrapper(),sFolders);
134 } 139 }
135 for (i=0; i < imapAccounts.count();++i) 140 for (i=0; i < imapAccounts.count();++i)
136 { 141 {
137 if (imapAccounts[i]->offline()) 142 if (imapAccounts[i]->offline())
138 continue; 143 continue;
139 imapAccounts[i]->refreshFolders(false); 144 imapAccounts[i]->refreshFolders(false);
140 sels->addAccounts(imapAccounts[i]->getWrapper(),imapAccounts[i]->subFolders()); 145 sels->addAccounts(imapAccounts[i]->getWrapper(),imapAccounts[i]->subFolders());
141 } 146 }
142} 147}
143void AccountView::downloadMailsInbox(const FolderP&fromFolder,AbstractMail*fromWrapper) 148void AccountView::downloadMailsInbox(const FolderP&fromFolder,AbstractMail*fromWrapper)
144{ 149{
145#if 0 150#if 0
146 AbstractMail*targetMail = 0; 151 AbstractMail*targetMail = 0;
147 QString targetFolder = ""; 152 QString targetFolder = "";
148 Selectstore sels; 153 Selectstore sels;
149 setupFolderselect(&sels); 154 setupFolderselect(&sels);
150 if (!sels.exec()) return; 155 if (!sels.exec()) return;
151 targetMail = sels.currentMail(); 156 targetMail = sels.currentMail();
152 targetFolder = sels.currentFolder(); 157 targetFolder = sels.currentFolder();
153 if ( (fromWrapper==targetMail && fromFolder->getName()==targetFolder) || 158 if ( (fromWrapper==targetMail && fromFolder->getName()==targetFolder) ||
154 targetFolder.isEmpty()) 159 targetFolder.isEmpty())
155 { 160 {
156 return; 161 return;
157 } 162 }
158 if (sels.newFolder() && !targetMail->createMbox(targetFolder)) 163 if (sels.newFolder() && !targetMail->createMbox(targetFolder))
159 { 164 {
160 QMessageBox::critical(0,i18n("Error creating new Folder"), 165 QMessageBox::critical(0,i18n("Error creating new Folder"),
161 i18n("<center>Error while creating<br>new folder - breaking.</center>")); 166 i18n("<center>Error while creating<br>new folder - breaking.</center>"));
162 return; 167 return;
163 } 168 }
164 int maxsize = 0; 169 int maxsize = 0;
165 if ( sels.useSize->isChecked()) 170 if ( sels.useSize->isChecked())
166 maxsize = sels.sizeSpinBox->value(); 171 maxsize = sels.sizeSpinBox->value();
167 fromWrapper->mvcpAllMails(fromFolder,targetFolder,targetMail,sels.moveMails(), maxsize); 172 fromWrapper->mvcpAllMails(fromFolder,targetFolder,targetMail,sels.moveMails(), maxsize);
168#endif 173#endif
169 fromWrapper->downloadNewMails( fromFolder, mhAccounts[0]->getWrapper()); 174 fromWrapper->downloadNewMails( fromFolder, mhAccounts[0]->getWrapper());
170 refreshCurrent(); 175 refreshCurrent();
171 176
172} 177}
173 178
174void AccountView::downloadMails(const FolderP&fromFolder,AbstractMail*fromWrapper) 179void AccountView::downloadMails(const FolderP&fromFolder,AbstractMail*fromWrapper)
175{ 180{
176 AbstractMail*targetMail = 0; 181 AbstractMail*targetMail = 0;
177 QString targetFolder = ""; 182 QString targetFolder = "";
178 Selectstore sels; 183 Selectstore sels;
179 setupFolderselect(&sels); 184 setupFolderselect(&sels);
180 if (!sels.exec()) return; 185 if (!sels.exec()) return;
181 targetMail = sels.currentMail(); 186 targetMail = sels.currentMail();
182 targetFolder = sels.currentFolder(); 187 targetFolder = sels.currentFolder();
183 if ( (fromWrapper==targetMail && fromFolder->getName()==targetFolder) || 188 if ( (fromWrapper==targetMail && fromFolder->getName()==targetFolder) ||
184 targetFolder.isEmpty()) 189 targetFolder.isEmpty())
185 { 190 {
186 return; 191 return;
187 } 192 }
188 if (sels.newFolder() && !targetMail->createMbox(targetFolder)) 193 if (sels.newFolder() && !targetMail->createMbox(targetFolder))
189 { 194 {
190 QMessageBox::critical(0,i18n("Error creating new Folder"), 195 QMessageBox::critical(0,i18n("Error creating new Folder"),
191 i18n("<center>Error while creating<br>new folder - breaking.</center>")); 196 i18n("<center>Error while creating<br>new folder - breaking.</center>"));
192 return; 197 return;
193 } 198 }
194 int maxsize = 0; 199 int maxsize = 0;
195 if ( sels.useSize->isChecked()) 200 if ( sels.useSize->isChecked())
196 maxsize = sels.sizeSpinBox->value(); 201 maxsize = sels.sizeSpinBox->value();
197 202
198 fromWrapper->mvcpAllMails(fromFolder,targetFolder,targetMail,sels.moveMails(), maxsize); 203 fromWrapper->mvcpAllMails(fromFolder,targetFolder,targetMail,sels.moveMails(), maxsize);
199 refreshCurrent(); 204 refreshCurrent();
200} 205}
201 206
202bool AccountView::currentisDraft() 207bool AccountView::currentisDraft()
203{ 208{
204 AccountViewItem *view = static_cast<AccountViewItem *>(currentItem()); 209 AccountViewItem *view = static_cast<AccountViewItem *>(currentItem());
205 if (!view) return false; 210 if (!view) return false;
206 return view->isDraftfolder(); 211 return view->isDraftfolder();
207} 212}