-rw-r--r-- | kmicromail/opiemail.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/kmicromail/opiemail.cpp b/kmicromail/opiemail.cpp index b2119e6..19ffdb3 100644 --- a/kmicromail/opiemail.cpp +++ b/kmicromail/opiemail.cpp | |||
@@ -1,375 +1,383 @@ | |||
1 | // CHANGED 2004-09-31 Lutz Rogowski | 1 | // CHANGED 2004-09-31 Lutz Rogowski |
2 | // CHANGED 2004-08-06 Lutz Rogowski | 2 | // CHANGED 2004-08-06 Lutz Rogowski |
3 | 3 | ||
4 | #include "settingsdialog.h" | 4 | #include "settingsdialog.h" |
5 | #include "opiemail.h" | 5 | #include "opiemail.h" |
6 | #include "editaccounts.h" | 6 | #include "editaccounts.h" |
7 | #include "composemail.h" | 7 | #include "composemail.h" |
8 | #include "mailistviewitem.h" | 8 | #include "mailistviewitem.h" |
9 | #include "viewmail.h" | 9 | #include "viewmail.h" |
10 | #include "selectstore.h" | 10 | #include "selectstore.h" |
11 | #include "selectsmtp.h" | 11 | #include "selectsmtp.h" |
12 | #include "accountitem.h" | ||
12 | 13 | ||
13 | #include <qmessagebox.h> | 14 | #include <qmessagebox.h> |
14 | #include <qtimer.h> | 15 | #include <qtimer.h> |
15 | #include <libkdepim/externalapphandler.h> | 16 | #include <libkdepim/externalapphandler.h> |
16 | 17 | ||
17 | #include <qpe/qpeapplication.h> | 18 | #include <qpe/qpeapplication.h> |
18 | #include <libmailwrapper/smtpwrapper.h> | 19 | #include <libmailwrapper/smtpwrapper.h> |
19 | #include <libmailwrapper/mailtypes.h> | 20 | #include <libmailwrapper/mailtypes.h> |
20 | #include <libmailwrapper/abstractmail.h> | 21 | #include <libmailwrapper/abstractmail.h> |
21 | /* OPIE */ | 22 | /* OPIE */ |
22 | //#include <qpe/resource.h> | 23 | //#include <qpe/resource.h> |
23 | //#include <qpe/qpeapplication.h> | 24 | //#include <qpe/qpeapplication.h> |
24 | 25 | ||
25 | /* QT */ | 26 | /* QT */ |
26 | 27 | ||
27 | //using namespace Opie::Core; | 28 | //using namespace Opie::Core; |
28 | 29 | ||
29 | OpieMail::OpieMail( QWidget *parent, const char *name ) | 30 | OpieMail::OpieMail( QWidget *parent, const char *name ) |
30 | : MainWindow( parent, name) //, WStyle_ContextHelp ) | 31 | : MainWindow( parent, name) //, WStyle_ContextHelp ) |
31 | { | 32 | { |
32 | settings = new Settings(); | 33 | settings = new Settings(); |
33 | 34 | ||
34 | folderView->populate( settings->getAccounts() ); | 35 | folderView->populate( settings->getAccounts() ); |
35 | 36 | ||
36 | } | 37 | } |
37 | 38 | ||
38 | OpieMail::~OpieMail() | 39 | OpieMail::~OpieMail() |
39 | { | 40 | { |
40 | if (settings) delete settings; | 41 | if (settings) delete settings; |
41 | } | 42 | } |
42 | 43 | ||
43 | void OpieMail::appMessage(const QCString &msg, const QByteArray &data) | 44 | void OpieMail::appMessage(const QCString &msg, const QByteArray &data) |
44 | { | 45 | { |
45 | 46 | ||
46 | } | 47 | } |
47 | #include <stdlib.h> | 48 | #include <stdlib.h> |
48 | void OpieMail::message(const QCString &msg, const QByteArray &data) | 49 | void OpieMail::message(const QCString &msg, const QByteArray &data) |
49 | { | 50 | { |
50 | // copied from old mail2 | 51 | // copied from old mail2 |
51 | static int ii = 0; | 52 | static int ii = 0; |
52 | //qDebug("QCOP CALL ############################# %d ", ii); | 53 | //qDebug("QCOP CALL ############################# %d ", ii); |
53 | //QString mess ( msg ); | 54 | //QString mess ( msg ); |
54 | //qDebug("Message = %s ",mess.latin1()); | 55 | //qDebug("Message = %s ",mess.latin1()); |
55 | ++ii; | 56 | ++ii; |
56 | //qDebug("KM:appMessage %d *%s* %x", ii, msg.data(), this); | 57 | //qDebug("KM:appMessage %d *%s* %x", ii, msg.data(), this); |
57 | 58 | ||
58 | mPendingEmail = QString::null; | 59 | mPendingEmail = QString::null; |
59 | mPendingName = QString::null; | 60 | mPendingName = QString::null; |
60 | if (msg == "writeMail(QString,QString)") | 61 | if (msg == "writeMail(QString,QString)") |
61 | { | 62 | { |
62 | //qDebug("writeMail(QString,QString) "); | 63 | //qDebug("writeMail(QString,QString) "); |
63 | QDataStream stream(data,IO_ReadOnly); | 64 | QDataStream stream(data,IO_ReadOnly); |
64 | stream >> mPendingName >> mPendingEmail; | 65 | stream >> mPendingName >> mPendingEmail; |
65 | // removing the whitespaces at beginning and end is needed! | 66 | // removing the whitespaces at beginning and end is needed! |
66 | QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); | 67 | QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); |
67 | } | 68 | } |
68 | else if (msg == "newMail()") | 69 | else if (msg == "newMail()") |
69 | { | 70 | { |
70 | //qDebug("slotComposeMail() "); | 71 | //qDebug("slotComposeMail() "); |
71 | // we cannot call slotComposeMail(); directly, because may be executing a QCOP call | 72 | // we cannot call slotComposeMail(); directly, because may be executing a QCOP call |
72 | // and a QCOP call does not like a processevents in his execution | 73 | // and a QCOP call does not like a processevents in his execution |
73 | // with the Qtimer we call slotComposeMail() after we reached the main event loop | 74 | // with the Qtimer we call slotComposeMail() after we reached the main event loop |
74 | QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); | 75 | QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); |
75 | // slotComposeMail(); | 76 | // slotComposeMail(); |
76 | } | 77 | } |
77 | else if (msg == "newMail(QString)") | 78 | else if (msg == "newMail(QString)") |
78 | { | 79 | { |
79 | //qDebug(" newMail(QString)"); | 80 | //qDebug(" newMail(QString)"); |
80 | QDataStream stream(data,IO_ReadOnly); | 81 | QDataStream stream(data,IO_ReadOnly); |
81 | stream >> mPendingName; | 82 | stream >> mPendingName; |
82 | // the format is | 83 | // the format is |
83 | // NAME <EMAIL>:SUBJECT | 84 | // NAME <EMAIL>:SUBJECT |
84 | QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); | 85 | QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); |
85 | } else { | 86 | } else { |
86 | if ( ii == 1 ) { | 87 | if ( ii == 1 ) { |
87 | qDebug("Kopiemail::Error:: Initial QCOP call for ExternalAppHandler not supported "); | 88 | qDebug("Kopiemail::Error:: Initial QCOP call for ExternalAppHandler not supported "); |
88 | return; | 89 | return; |
89 | } | 90 | } |
90 | ExternalAppHandler::instance()->appMessage ( msg, data); | 91 | ExternalAppHandler::instance()->appMessage ( msg, data); |
91 | } | 92 | } |
92 | 93 | ||
93 | //qDebug("END OpieMail::message "); | 94 | //qDebug("END OpieMail::message "); |
94 | } | 95 | } |
95 | void OpieMail::slotwriteMail2(const QString& namemail ) | 96 | void OpieMail::slotwriteMail2(const QString& namemail ) |
96 | { | 97 | { |
97 | //qDebug("OpieMail::slotwriteMail2 "); | 98 | //qDebug("OpieMail::slotwriteMail2 "); |
98 | //qApp->processEvents(); | 99 | //qApp->processEvents(); |
99 | ComposeMail compose( settings, this, 0, true ); | 100 | ComposeMail compose( settings, this, 0, true ); |
100 | if ( !namemail.isEmpty() ) { | 101 | if ( !namemail.isEmpty() ) { |
101 | QString to = namemail; | 102 | QString to = namemail; |
102 | if ( namemail.find( " <") > 1 ) { | 103 | if ( namemail.find( " <") > 1 ) { |
103 | to = "\"" +to.replace( QRegExp( " <"), "\" <") ; | 104 | to = "\"" +to.replace( QRegExp( " <"), "\" <") ; |
104 | } else | 105 | } else |
105 | if ( namemail.find( "<") > 1 ) { | 106 | if ( namemail.find( "<") > 1 ) { |
106 | to = "\"" +to.replace( QRegExp( "<"), "\" <") ; | 107 | to = "\"" +to.replace( QRegExp( "<"), "\" <") ; |
107 | } | 108 | } |
108 | int sub = to.find( ">:"); | 109 | int sub = to.find( ">:"); |
109 | if ( sub > 0 ) { | 110 | if ( sub > 0 ) { |
110 | compose.setTo( to.left(sub+1) ); | 111 | compose.setTo( to.left(sub+1) ); |
111 | compose.setSubject( to.mid(sub+2) ); | 112 | compose.setSubject( to.mid(sub+2) ); |
112 | } else | 113 | } else |
113 | compose.setTo( to ); | 114 | compose.setTo( to ); |
114 | } | 115 | } |
115 | compose.slotAdjustColumns(); | 116 | compose.slotAdjustColumns(); |
116 | compose.showMaximized(); | 117 | compose.showMaximized(); |
117 | compose.exec(); | 118 | compose.exec(); |
118 | raise(); | 119 | raise(); |
119 | //qDebug("retttich "); | 120 | //qDebug("retttich "); |
120 | } | 121 | } |
121 | void OpieMail::slotwriteMail(const QString&name,const QString&email) | 122 | void OpieMail::slotwriteMail(const QString&name,const QString&email) |
122 | { | 123 | { |
123 | // qDebug("OpieMail::slotwriteMail "); | 124 | // qDebug("OpieMail::slotwriteMail "); |
124 | ComposeMail compose( settings, this, 0, true ); | 125 | ComposeMail compose( settings, this, 0, true ); |
125 | if (!email.isEmpty()) | 126 | if (!email.isEmpty()) |
126 | { | 127 | { |
127 | if (!name.isEmpty()) | 128 | if (!name.isEmpty()) |
128 | { | 129 | { |
129 | compose.setTo("\"" + name + "\"" + " " + "<"+ email + ">"); | 130 | compose.setTo("\"" + name + "\"" + " " + "<"+ email + ">"); |
130 | } | 131 | } |
131 | else | 132 | else |
132 | { | 133 | { |
133 | compose.setTo(email); | 134 | compose.setTo(email); |
134 | } | 135 | } |
135 | } | 136 | } |
136 | compose.slotAdjustColumns(); | 137 | compose.slotAdjustColumns(); |
137 | compose.showMaximized(); | 138 | compose.showMaximized(); |
138 | compose.exec(); | 139 | compose.exec(); |
139 | raise(); | 140 | raise(); |
140 | } | 141 | } |
141 | 142 | ||
142 | void OpieMail::slotComposeMail() | 143 | void OpieMail::slotComposeMail() |
143 | { | 144 | { |
144 | if ( mPendingEmail == QString::null && mPendingName == QString::null) | 145 | if ( mPendingEmail == QString::null && mPendingName == QString::null) |
145 | slotwriteMail2( QString () ); | 146 | slotwriteMail2( QString () ); |
146 | else { | 147 | else { |
147 | if ( mPendingEmail == QString::null ) | 148 | if ( mPendingEmail == QString::null ) |
148 | slotwriteMail2( mPendingName ); | 149 | slotwriteMail2( mPendingName ); |
149 | else | 150 | else |
150 | slotwriteMail( mPendingName, mPendingEmail ); | 151 | slotwriteMail( mPendingName, mPendingEmail ); |
151 | } | 152 | } |
152 | //slotwriteMail(0l,0l); | 153 | //slotwriteMail(0l,0l); |
153 | } | 154 | } |
154 | 155 | ||
155 | void OpieMail::slotSendQueued() | 156 | void OpieMail::slotSendQueued() |
156 | { | 157 | { |
157 | SMTPaccount *smtp = 0; | 158 | SMTPaccount *smtp = 0; |
158 | 159 | ||
159 | QList<Account> list = settings->getAccounts(); | 160 | QList<Account> list = settings->getAccounts(); |
160 | QList<SMTPaccount> smtpList; | 161 | QList<SMTPaccount> smtpList; |
161 | smtpList.setAutoDelete(false); | 162 | smtpList.setAutoDelete(false); |
162 | Account *it; | 163 | Account *it; |
163 | for ( it = list.first(); it; it = list.next() ) | 164 | for ( it = list.first(); it; it = list.next() ) |
164 | { | 165 | { |
165 | if ( it->getType() == MAILLIB::A_SMTP ) | 166 | if ( it->getType() == MAILLIB::A_SMTP ) |
166 | { | 167 | { |
167 | smtp = static_cast<SMTPaccount *>(it); | 168 | smtp = static_cast<SMTPaccount *>(it); |
168 | smtpList.append(smtp); | 169 | smtpList.append(smtp); |
169 | } | 170 | } |
170 | } | 171 | } |
171 | if (smtpList.count()==0) | 172 | if (smtpList.count()==0) |
172 | { | 173 | { |
173 | QMessageBox::information(0,tr("Info"),tr("Define a smtp account first!\n")); | 174 | QMessageBox::information(0,tr("Info"),tr("Define a smtp account first!\n")); |
174 | return; | 175 | return; |
175 | } | 176 | } |
176 | if (smtpList.count()==1) | 177 | if (smtpList.count()==1) |
177 | { | 178 | { |
178 | smtp = smtpList.at(0); | 179 | smtp = smtpList.at(0); |
179 | } | 180 | } |
180 | else | 181 | else |
181 | { | 182 | { |
182 | smtp = 0; | 183 | smtp = 0; |
183 | selectsmtp selsmtp; | 184 | selectsmtp selsmtp; |
184 | selsmtp.setSelectionlist(&smtpList); | 185 | selsmtp.setSelectionlist(&smtpList); |
185 | selsmtp.showMaximized(); | 186 | selsmtp.showMaximized(); |
186 | if ( selsmtp.exec() == QDialog::Accepted ) | 187 | if ( selsmtp.exec() == QDialog::Accepted ) |
187 | { | 188 | { |
188 | smtp = selsmtp.selected_smtp(); | 189 | smtp = selsmtp.selected_smtp(); |
189 | } | 190 | } |
190 | } | 191 | } |
191 | if (smtp) | 192 | if (smtp) |
192 | { | 193 | { |
193 | SMTPwrapper * wrap = new SMTPwrapper(smtp); | 194 | SMTPwrapper * wrap = new SMTPwrapper(smtp); |
194 | if ( wrap->flushOutbox() ) | 195 | if ( wrap->flushOutbox() ) |
195 | { | 196 | { |
196 | QMessageBox::information(0,tr("Info"),tr("Mail queue flushed")); | 197 | QMessageBox::information(0,tr("Info"),tr("Mail queue flushed")); |
197 | } | 198 | } |
198 | delete wrap; | 199 | delete wrap; |
199 | } | 200 | } |
200 | } | 201 | } |
201 | 202 | ||
202 | void OpieMail::slotSearchMails() | 203 | void OpieMail::slotSearchMails() |
203 | { | 204 | { |
204 | qDebug("OpieMail::slotSearchMails():not implemented "); | 205 | qDebug("OpieMail::slotSearchMails():not implemented "); |
205 | } | 206 | } |
206 | 207 | ||
207 | void OpieMail::slotEditSettings() | 208 | void OpieMail::slotEditSettings() |
208 | { | 209 | { |
209 | SettingsDialog settingsDialog( this, 0, true, WStyle_ContextHelp ); | 210 | SettingsDialog settingsDialog( this, 0, true, WStyle_ContextHelp ); |
210 | settingsDialog.showMaximized(); | 211 | settingsDialog.showMaximized(); |
211 | settingsDialog.exec(); | 212 | settingsDialog.exec(); |
212 | } | 213 | } |
213 | 214 | ||
214 | void OpieMail::slotEditAccounts() | 215 | void OpieMail::slotEditAccounts() |
215 | { | 216 | { |
216 | EditAccounts eaDialog( settings, this, 0, true, WStyle_ContextHelp ); | 217 | EditAccounts eaDialog( settings, this, 0, true, WStyle_ContextHelp ); |
217 | eaDialog.slotAdjustColumns(); | 218 | eaDialog.slotAdjustColumns(); |
218 | eaDialog.showMaximized(); | 219 | eaDialog.showMaximized(); |
219 | eaDialog.exec(); | 220 | eaDialog.exec(); |
220 | if ( settings ) delete settings; | 221 | if ( settings ) delete settings; |
221 | settings = new Settings(); | 222 | settings = new Settings(); |
222 | 223 | ||
223 | folderView->populate( settings->getAccounts() ); | 224 | folderView->populate( settings->getAccounts() ); |
224 | } | 225 | } |
225 | 226 | ||
226 | void OpieMail::displayMail() | 227 | void OpieMail::displayMail() |
227 | { | 228 | { |
228 | QListViewItem*item = mailView->currentItem(); | 229 | QListViewItem*item = mailView->currentItem(); |
229 | if (!item) return; | 230 | if (!item) return; |
230 | RecMailP mail = ((MailListViewItem*)item)->data(); | 231 | RecMailP mail = ((MailListViewItem*)item)->data(); |
231 | RecBodyP body = folderView->fetchBody(mail); | 232 | RecBodyP body = folderView->fetchBody(mail); |
232 | ViewMail readMail( this,"", Qt::WType_Modal | WStyle_ContextHelp ); | 233 | ViewMail readMail( this,"", Qt::WType_Modal | WStyle_ContextHelp ); |
233 | readMail.setBody( body ); | 234 | readMail.setBody( body ); |
234 | readMail.setMail( mail ); | 235 | readMail.setMail( mail ); |
235 | readMail.showMaximized(); | 236 | readMail.showMaximized(); |
236 | readMail.exec(); | 237 | readMail.exec(); |
237 | 238 | ||
238 | if ( readMail.deleted ) | 239 | if ( readMail.deleted ) |
239 | { | 240 | { |
240 | folderView->refreshCurrent(); | 241 | folderView->refreshCurrent(); |
241 | } | 242 | } |
242 | else | 243 | else |
243 | { | 244 | { |
244 | ( (MailListViewItem*)item )->setPixmap( 0, QPixmap() ); | 245 | ( (MailListViewItem*)item )->setPixmap( 0, QPixmap() ); |
245 | } | 246 | } |
246 | } | 247 | } |
247 | 248 | void OpieMail::slotGetMail() | |
249 | { | ||
250 | QListViewItem * item = folderView->currentItem(); | ||
251 | if ( ! item ) return; | ||
252 | while ( item->parent () ) | ||
253 | item = item->parent (); | ||
254 | ((AccountViewItem *)item)->contextMenuSelected( 101 ); | ||
255 | } | ||
248 | void OpieMail::slotDeleteMail() | 256 | void OpieMail::slotDeleteMail() |
249 | { | 257 | { |
250 | if (!mailView->currentItem()) return; | 258 | if (!mailView->currentItem()) return; |
251 | RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data(); | 259 | RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data(); |
252 | if ( QMessageBox::warning(this, tr("Delete Mail"), QString( tr("<p>Do you really want to delete this mail? <br><br>" ) + mail->getFrom() + " - " + mail->getSubject() ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) | 260 | if ( QMessageBox::warning(this, tr("Delete Mail"), QString( tr("<p>Do you really want to delete this mail? <br><br>" ) + mail->getFrom() + " - " + mail->getSubject() ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) |
253 | { | 261 | { |
254 | mail->Wrapper()->deleteMail( mail ); | 262 | mail->Wrapper()->deleteMail( mail ); |
255 | folderView->refreshCurrent(); | 263 | folderView->refreshCurrent(); |
256 | } | 264 | } |
257 | } | 265 | } |
258 | void OpieMail::slotDeleteAllMail() | 266 | void OpieMail::slotDeleteAllMail() |
259 | { | 267 | { |
260 | 268 | ||
261 | QValueList<RecMailP> t; | 269 | QValueList<RecMailP> t; |
262 | if ( QMessageBox::warning(this, tr("Delete All Mails"), tr("Do you really want to delete\nall selected mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) | 270 | if ( QMessageBox::warning(this, tr("Delete All Mails"), tr("Do you really want to delete\nall selected mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) |
263 | { | 271 | { |
264 | MailListViewItem* item = (MailListViewItem*)mailView->firstChild (); | 272 | MailListViewItem* item = (MailListViewItem*)mailView->firstChild (); |
265 | while ( item ) { | 273 | while ( item ) { |
266 | if ( item->isSelected() ) { | 274 | if ( item->isSelected() ) { |
267 | t.append( item->data() ); | 275 | t.append( item->data() ); |
268 | } | 276 | } |
269 | item = (MailListViewItem*)item->nextSibling(); | 277 | item = (MailListViewItem*)item->nextSibling(); |
270 | } | 278 | } |
271 | } | 279 | } |
272 | else | 280 | else |
273 | return; | 281 | return; |
274 | if ( t.count() == 0 ) | 282 | if ( t.count() == 0 ) |
275 | return; | 283 | return; |
276 | RecMailP mail = t.first(); | 284 | RecMailP mail = t.first(); |
277 | mail->Wrapper()->deleteMailList(t); | 285 | mail->Wrapper()->deleteMailList(t); |
278 | folderView->refreshCurrent(); | 286 | folderView->refreshCurrent(); |
279 | 287 | ||
280 | 288 | ||
281 | } | 289 | } |
282 | void OpieMail::clearSelection() | 290 | void OpieMail::clearSelection() |
283 | { | 291 | { |
284 | mailView->clearSelection(); | 292 | mailView->clearSelection(); |
285 | 293 | ||
286 | } | 294 | } |
287 | 295 | ||
288 | void OpieMail::mailHold(int button, QListViewItem *item,const QPoint&,int ) | 296 | void OpieMail::mailHold(int button, QListViewItem *item,const QPoint&,int ) |
289 | { | 297 | { |
290 | if (!mailView->currentItem()) return; | 298 | if (!mailView->currentItem()) return; |
291 | MAILLIB::ATYPE mailtype = ((MailListViewItem*)mailView->currentItem() )->wrapperType(); | 299 | MAILLIB::ATYPE mailtype = ((MailListViewItem*)mailView->currentItem() )->wrapperType(); |
292 | /* just the RIGHT button - or hold on pda */ | 300 | /* just the RIGHT button - or hold on pda */ |
293 | if (button!=2) {return;} | 301 | if (button!=2) {return;} |
294 | if (!item) return; | 302 | if (!item) return; |
295 | QPopupMenu *m = new QPopupMenu(0); | 303 | QPopupMenu *m = new QPopupMenu(0); |
296 | if (m) | 304 | if (m) |
297 | { | 305 | { |
298 | if (mailtype==MAILLIB::A_NNTP) { | 306 | if (mailtype==MAILLIB::A_NNTP) { |
299 | m->insertItem(tr("Read this posting"),this,SLOT(displayMail())); | 307 | m->insertItem(tr("Read this posting"),this,SLOT(displayMail())); |
300 | // m->insertItem(tr("Copy this posting"),this,SLOT(slotMoveCopyMail())); | 308 | // m->insertItem(tr("Copy this posting"),this,SLOT(slotMoveCopyMail())); |
301 | } else { | 309 | } else { |
302 | if (folderView->currentisDraft()) { | 310 | if (folderView->currentisDraft()) { |
303 | m->insertItem(tr("Edit this mail"),this,SLOT(reEditMail())); | 311 | m->insertItem(tr("Edit this mail"),this,SLOT(reEditMail())); |
304 | } | 312 | } |
305 | m->insertItem(tr("Read this mail"),this,SLOT(displayMail())); | 313 | m->insertItem(tr("Read this mail"),this,SLOT(displayMail())); |
306 | m->insertItem(tr("Move/Copy this mail"),this,SLOT(slotMoveCopyMail())); | 314 | m->insertItem(tr("Move/Copy this mail"),this,SLOT(slotMoveCopyMail())); |
307 | m->insertItem(tr("Delete this mail"),this,SLOT(slotDeleteMail())); | 315 | m->insertItem(tr("Delete this mail"),this,SLOT(slotDeleteMail())); |
308 | m->insertSeparator(); | 316 | m->insertSeparator(); |
309 | m->insertItem(tr("Move/Copy all selected mail"),this,SLOT(slotMoveCopyAllMail())); | 317 | m->insertItem(tr("Move/Copy all selected mail"),this,SLOT(slotMoveCopyAllMail())); |
310 | m->insertItem(tr("Delete all selected mails"),this,SLOT(slotDeleteAllMail())); | 318 | m->insertItem(tr("Delete all selected mails"),this,SLOT(slotDeleteAllMail())); |
311 | m->insertItem(tr("Clear selection"),this,SLOT(clearSelection())); | 319 | m->insertItem(tr("Clear selection"),this,SLOT(clearSelection())); |
312 | } | 320 | } |
313 | m->setFocus(); | 321 | m->setFocus(); |
314 | m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); | 322 | m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); |
315 | delete m; | 323 | delete m; |
316 | } | 324 | } |
317 | } | 325 | } |
318 | 326 | ||
319 | void OpieMail::slotShowFolders( bool show ) | 327 | void OpieMail::slotShowFolders( bool show ) |
320 | { | 328 | { |
321 | if ( show && folderView->isHidden() ) | 329 | if ( show && folderView->isHidden() ) |
322 | { | 330 | { |
323 | folderView->show(); | 331 | folderView->show(); |
324 | } | 332 | } |
325 | else if ( !show && !folderView->isHidden() ) | 333 | else if ( !show && !folderView->isHidden() ) |
326 | { | 334 | { |
327 | folderView->hide(); | 335 | folderView->hide(); |
328 | } | 336 | } |
329 | } | 337 | } |
330 | 338 | ||
331 | void OpieMail::refreshMailView(const QValueList<RecMailP>&list) | 339 | void OpieMail::refreshMailView(const QValueList<RecMailP>&list) |
332 | { | 340 | { |
333 | MailListViewItem*item = 0; | 341 | MailListViewItem*item = 0; |
334 | mailView->clear(); | 342 | mailView->clear(); |
335 | 343 | ||
336 | QValueList<RecMailP>::ConstIterator it; | 344 | QValueList<RecMailP>::ConstIterator it; |
337 | for (it = list.begin(); it != list.end();++it) | 345 | for (it = list.begin(); it != list.end();++it) |
338 | { | 346 | { |
339 | item = new MailListViewItem(mailView,item); | 347 | item = new MailListViewItem(mailView,item); |
340 | item->storeData((*it)); | 348 | item->storeData((*it)); |
341 | item->showEntry(); | 349 | item->showEntry(); |
342 | } | 350 | } |
343 | } | 351 | } |
344 | 352 | ||
345 | void OpieMail::mailLeftClicked( QListViewItem *item ) | 353 | void OpieMail::mailLeftClicked( QListViewItem *item ) |
346 | { | 354 | { |
347 | mailView->clearSelection(); | 355 | mailView->clearSelection(); |
348 | /* just LEFT button - or tap with stylus on pda */ | 356 | /* just LEFT button - or tap with stylus on pda */ |
349 | //if (button!=1) return; | 357 | //if (button!=1) return; |
350 | if (!item) return; | 358 | if (!item) return; |
351 | if (folderView->currentisDraft()) { | 359 | if (folderView->currentisDraft()) { |
352 | reEditMail(); | 360 | reEditMail(); |
353 | } else { | 361 | } else { |
354 | displayMail(); | 362 | displayMail(); |
355 | } | 363 | } |
356 | } | 364 | } |
357 | 365 | ||
358 | void OpieMail::slotMoveCopyMail() | 366 | void OpieMail::slotMoveCopyMail() |
359 | { | 367 | { |
360 | if (!mailView->currentItem()) return; | 368 | if (!mailView->currentItem()) return; |
361 | RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data(); | 369 | RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data(); |
362 | AbstractMail*targetMail = 0; | 370 | AbstractMail*targetMail = 0; |
363 | QString targetFolder = ""; | 371 | QString targetFolder = ""; |
364 | Selectstore sels; | 372 | Selectstore sels; |
365 | folderView->setupFolderselect(&sels); | 373 | folderView->setupFolderselect(&sels); |
366 | if (!sels.exec()) return; | 374 | if (!sels.exec()) return; |
367 | targetMail = sels.currentMail(); | 375 | targetMail = sels.currentMail(); |
368 | targetFolder = sels.currentFolder(); | 376 | targetFolder = sels.currentFolder(); |
369 | if ( (mail->Wrapper()==targetMail && mail->getMbox()==targetFolder) || | 377 | if ( (mail->Wrapper()==targetMail && mail->getMbox()==targetFolder) || |
370 | targetFolder.isEmpty()) | 378 | targetFolder.isEmpty()) |
371 | { | 379 | { |
372 | return; | 380 | return; |
373 | } | 381 | } |
374 | if (sels.newFolder() && !targetMail->createMbox(targetFolder)) | 382 | if (sels.newFolder() && !targetMail->createMbox(targetFolder)) |
375 | { | 383 | { |