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