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