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