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