-rw-r--r-- | kmicromail/accountview.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/kmicromail/accountview.cpp b/kmicromail/accountview.cpp index 85523b1..de8c5bb 100644 --- a/kmicromail/accountview.cpp +++ b/kmicromail/accountview.cpp | |||
@@ -1,203 +1,206 @@ | |||
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 | ||
20 | using namespace Opie::Core; | 20 | using namespace Opie::Core; |
21 | AccountView::AccountView( QWidget *parent, const char *name, WFlags flags ) | 21 | AccountView::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 | ||
31 | AccountView::~AccountView() | 31 | AccountView::~AccountView() |
32 | { | 32 | { |
33 | imapAccounts.clear(); | 33 | imapAccounts.clear(); |
34 | mhAccounts.clear(); | 34 | mhAccounts.clear(); |
35 | } | 35 | } |
36 | 36 | ||
37 | void AccountView::slotContextMenu(int id) | 37 | void 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 | ||
44 | void AccountView::slotHold(int button, QListViewItem * item,const QPoint&,int) | 44 | void 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 | ||
57 | void AccountView::populate( QList<Account> list ) | 57 | void 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 | ||
89 | void AccountView::refresh(QListViewItem *item) | 89 | void 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 | ||
101 | void AccountView::refreshCurrent() | 101 | void 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 | ||
111 | void AccountView::refreshAll() | 111 | void AccountView::refreshAll() |
112 | { | 112 | { |
113 | } | 113 | } |
114 | 114 | ||
115 | RecBodyP AccountView::fetchBody(const RecMailP&aMail) | 115 | RecBodyP 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 | ||
123 | void AccountView::setupFolderselect(Selectstore*sels) | 123 | void 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 | } |
142 | void AccountView::downloadMailsInbox(const FolderP&fromFolder,AbstractMail*fromWrapper) | 142 | void AccountView::downloadMailsInbox(const FolderP&fromFolder,AbstractMail*fromWrapper) |
143 | { | 143 | { |
144 | #if 0 | ||
144 | AbstractMail*targetMail = 0; | 145 | AbstractMail*targetMail = 0; |
145 | QString targetFolder = ""; | 146 | QString targetFolder = ""; |
146 | Selectstore sels; | 147 | Selectstore sels; |
147 | setupFolderselect(&sels); | 148 | setupFolderselect(&sels); |
148 | if (!sels.exec()) return; | 149 | if (!sels.exec()) return; |
149 | targetMail = sels.currentMail(); | 150 | targetMail = sels.currentMail(); |
150 | targetFolder = sels.currentFolder(); | 151 | targetFolder = sels.currentFolder(); |
151 | if ( (fromWrapper==targetMail && fromFolder->getName()==targetFolder) || | 152 | if ( (fromWrapper==targetMail && fromFolder->getName()==targetFolder) || |
152 | targetFolder.isEmpty()) | 153 | targetFolder.isEmpty()) |
153 | { | 154 | { |
154 | return; | 155 | return; |
155 | } | 156 | } |
156 | if (sels.newFolder() && !targetMail->createMbox(targetFolder)) | 157 | if (sels.newFolder() && !targetMail->createMbox(targetFolder)) |
157 | { | 158 | { |
158 | QMessageBox::critical(0,tr("Error creating new Folder"), | 159 | QMessageBox::critical(0,tr("Error creating new Folder"), |
159 | tr("<center>Error while creating<br>new folder - breaking.</center>")); | 160 | tr("<center>Error while creating<br>new folder - breaking.</center>")); |
160 | return; | 161 | return; |
161 | } | 162 | } |
162 | int maxsize = 0; | 163 | int maxsize = 0; |
163 | if ( sels.useSize->isChecked()) | 164 | if ( sels.useSize->isChecked()) |
164 | maxsize = sels.sizeSpinBox->value(); | 165 | maxsize = sels.sizeSpinBox->value(); |
165 | |||
166 | fromWrapper->mvcpAllMails(fromFolder,targetFolder,targetMail,sels.moveMails(), maxsize); | 166 | fromWrapper->mvcpAllMails(fromFolder,targetFolder,targetMail,sels.moveMails(), maxsize); |
167 | #endif | ||
168 | fromWrapper->downloadNewMails( fromFolder, mhAccounts[0]->getWrapper()); | ||
167 | refreshCurrent(); | 169 | refreshCurrent(); |
170 | |||
168 | } | 171 | } |
169 | 172 | ||
170 | void AccountView::downloadMails(const FolderP&fromFolder,AbstractMail*fromWrapper) | 173 | void AccountView::downloadMails(const FolderP&fromFolder,AbstractMail*fromWrapper) |
171 | { | 174 | { |
172 | AbstractMail*targetMail = 0; | 175 | AbstractMail*targetMail = 0; |
173 | QString targetFolder = ""; | 176 | QString targetFolder = ""; |
174 | Selectstore sels; | 177 | Selectstore sels; |
175 | setupFolderselect(&sels); | 178 | setupFolderselect(&sels); |
176 | if (!sels.exec()) return; | 179 | if (!sels.exec()) return; |
177 | targetMail = sels.currentMail(); | 180 | targetMail = sels.currentMail(); |
178 | targetFolder = sels.currentFolder(); | 181 | targetFolder = sels.currentFolder(); |
179 | if ( (fromWrapper==targetMail && fromFolder->getName()==targetFolder) || | 182 | if ( (fromWrapper==targetMail && fromFolder->getName()==targetFolder) || |
180 | targetFolder.isEmpty()) | 183 | targetFolder.isEmpty()) |
181 | { | 184 | { |
182 | return; | 185 | return; |
183 | } | 186 | } |
184 | if (sels.newFolder() && !targetMail->createMbox(targetFolder)) | 187 | if (sels.newFolder() && !targetMail->createMbox(targetFolder)) |
185 | { | 188 | { |
186 | QMessageBox::critical(0,tr("Error creating new Folder"), | 189 | QMessageBox::critical(0,tr("Error creating new Folder"), |
187 | tr("<center>Error while creating<br>new folder - breaking.</center>")); | 190 | tr("<center>Error while creating<br>new folder - breaking.</center>")); |
188 | return; | 191 | return; |
189 | } | 192 | } |
190 | int maxsize = 0; | 193 | int maxsize = 0; |
191 | if ( sels.useSize->isChecked()) | 194 | if ( sels.useSize->isChecked()) |
192 | maxsize = sels.sizeSpinBox->value(); | 195 | maxsize = sels.sizeSpinBox->value(); |
193 | 196 | ||
194 | fromWrapper->mvcpAllMails(fromFolder,targetFolder,targetMail,sels.moveMails(), maxsize); | 197 | fromWrapper->mvcpAllMails(fromFolder,targetFolder,targetMail,sels.moveMails(), maxsize); |
195 | refreshCurrent(); | 198 | refreshCurrent(); |
196 | } | 199 | } |
197 | 200 | ||
198 | bool AccountView::currentisDraft() | 201 | bool AccountView::currentisDraft() |
199 | { | 202 | { |
200 | AccountViewItem *view = static_cast<AccountViewItem *>(currentItem()); | 203 | AccountViewItem *view = static_cast<AccountViewItem *>(currentItem()); |
201 | if (!view) return false; | 204 | if (!view) return false; |
202 | return view->isDraftfolder(); | 205 | return view->isDraftfolder(); |
203 | } | 206 | } |