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