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