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