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