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