-rw-r--r-- | kmicromail/opiemail.cpp | 1 | ||||
-rw-r--r-- | kmicromail/viewmailbase.cpp | 9 | ||||
-rw-r--r-- | kmicromail/viewmailbase.h | 5 |
3 files changed, 12 insertions, 3 deletions
diff --git a/kmicromail/opiemail.cpp b/kmicromail/opiemail.cpp index b701446..4436ad6 100644 --- a/kmicromail/opiemail.cpp +++ b/kmicromail/opiemail.cpp | |||
@@ -1,567 +1,568 @@ | |||
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 | 4 | ||
5 | #define protected public | 5 | #define protected public |
6 | #include <qwidget.h> | 6 | #include <qwidget.h> |
7 | #undef protected | 7 | #undef protected |
8 | #include "koprefsdialog.h" | 8 | #include "koprefsdialog.h" |
9 | #include <kapplication.h> | 9 | #include <kapplication.h> |
10 | #include <libkdepim/externalapphandler.h> | 10 | #include <libkdepim/externalapphandler.h> |
11 | #include <libkdepim/kpimglobalprefs.h> | 11 | #include <libkdepim/kpimglobalprefs.h> |
12 | #ifdef MINIKDE_KDIALOG_H | 12 | #ifdef MINIKDE_KDIALOG_H |
13 | #undef MINIKDE_KDIALOG_H | 13 | #undef MINIKDE_KDIALOG_H |
14 | #endif | 14 | #endif |
15 | #include "settingsdialog.h" | 15 | #include "settingsdialog.h" |
16 | #include "opiemail.h" | 16 | #include "opiemail.h" |
17 | #include "editaccounts.h" | 17 | #include "editaccounts.h" |
18 | #include "composemail.h" | 18 | #include "composemail.h" |
19 | #include "mailistviewitem.h" | 19 | #include "mailistviewitem.h" |
20 | #include "viewmail.h" | 20 | #include "viewmail.h" |
21 | #include "selectstore.h" | 21 | #include "selectstore.h" |
22 | #include "selectsmtp.h" | 22 | #include "selectsmtp.h" |
23 | #include "accountitem.h" | 23 | #include "accountitem.h" |
24 | #include "accountview.h" | 24 | #include "accountview.h" |
25 | #include "klocale.h" | 25 | #include "klocale.h" |
26 | 26 | ||
27 | #include <qmessagebox.h> | 27 | #include <qmessagebox.h> |
28 | #include <qtimer.h> | 28 | #include <qtimer.h> |
29 | #include <qcursor.h> | 29 | #include <qcursor.h> |
30 | #include <qtextbrowser.h> | 30 | #include <qtextbrowser.h> |
31 | #include <qregexp.h> | 31 | #include <qregexp.h> |
32 | #include <qpe/global.h> | 32 | #include <qpe/global.h> |
33 | 33 | ||
34 | #ifdef DESKTOP_VERSION | 34 | #ifdef DESKTOP_VERSION |
35 | #include <qapplication.h> | 35 | #include <qapplication.h> |
36 | #else | 36 | #else |
37 | #include <qpe/qpeapplication.h> | 37 | #include <qpe/qpeapplication.h> |
38 | #endif | 38 | #endif |
39 | #include <libmailwrapper/smtpwrapper.h> | 39 | #include <libmailwrapper/smtpwrapper.h> |
40 | #include <libmailwrapper/mailtypes.h> | 40 | #include <libmailwrapper/mailtypes.h> |
41 | #include <libmailwrapper/abstractmail.h> | 41 | #include <libmailwrapper/abstractmail.h> |
42 | #include "koprefs.h" | 42 | #include "koprefs.h" |
43 | 43 | ||
44 | //using namespace Opie::Core; | 44 | //using namespace Opie::Core; |
45 | 45 | ||
46 | OpieMail::OpieMail( QWidget *parent, const char *name ) | 46 | OpieMail::OpieMail( QWidget *parent, const char *name ) |
47 | : MainWindow( parent, name) //, WStyle_ContextHelp ) | 47 | : MainWindow( parent, name) //, WStyle_ContextHelp ) |
48 | { | 48 | { |
49 | mCurrentComposer = 0; | 49 | mCurrentComposer = 0; |
50 | settings = new Settings(); | 50 | settings = new Settings(); |
51 | tb = 0; | 51 | tb = 0; |
52 | setIcon(SmallIcon( "kmicromail" ) ); | 52 | setIcon(SmallIcon( "kmicromail" ) ); |
53 | folderView->populate( settings->getAccounts() ); | 53 | folderView->populate( settings->getAccounts() ); |
54 | connect(ExternalAppHandler::instance(), SIGNAL(receivedNameEmailUidListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&)), | 54 | connect(ExternalAppHandler::instance(), SIGNAL(receivedNameEmailUidListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&)), |
55 | this, SLOT(insertAttendees(const QString&, const QStringList&, const QStringList&, const QStringList&))); | 55 | this, SLOT(insertAttendees(const QString&, const QStringList&, const QStringList&, const QStringList&))); |
56 | folderView->setFocus(); | ||
56 | } | 57 | } |
57 | 58 | ||
58 | OpieMail::~OpieMail() | 59 | OpieMail::~OpieMail() |
59 | { | 60 | { |
60 | if (settings) delete settings; | 61 | if (settings) delete settings; |
61 | if ( tb ) | 62 | if ( tb ) |
62 | delete tb; | 63 | delete tb; |
63 | } | 64 | } |
64 | 65 | ||
65 | void OpieMail::appMessage(const QCString &msg, const QByteArray &data) | 66 | void OpieMail::appMessage(const QCString &msg, const QByteArray &data) |
66 | { | 67 | { |
67 | 68 | ||
68 | } | 69 | } |
69 | #include <stdlib.h> | 70 | #include <stdlib.h> |
70 | void OpieMail::message(const QCString &msg, const QByteArray &data) | 71 | void OpieMail::message(const QCString &msg, const QByteArray &data) |
71 | { | 72 | { |
72 | // copied from old mail2 | 73 | // copied from old mail2 |
73 | static int ii = 0; | 74 | static int ii = 0; |
74 | //qDebug("QCOP CALL ############################# %d ", ii); | 75 | //qDebug("QCOP CALL ############################# %d ", ii); |
75 | //QString mess ( msg ); | 76 | //QString mess ( msg ); |
76 | //qDebug("Message = %s ",mess.latin1()); | 77 | //qDebug("Message = %s ",mess.latin1()); |
77 | ++ii; | 78 | ++ii; |
78 | //qDebug("KM:appMessage %d *%s* %x", ii, msg.data(), this); | 79 | //qDebug("KM:appMessage %d *%s* %x", ii, msg.data(), this); |
79 | 80 | ||
80 | mPendingEmail = QString::null; | 81 | mPendingEmail = QString::null; |
81 | mPendingName = QString::null; | 82 | mPendingName = QString::null; |
82 | if (msg == "writeMail(QString,QString)") | 83 | if (msg == "writeMail(QString,QString)") |
83 | { | 84 | { |
84 | //qDebug("writeMail(QString,QString) "); | 85 | //qDebug("writeMail(QString,QString) "); |
85 | QDataStream stream(data,IO_ReadOnly); | 86 | QDataStream stream(data,IO_ReadOnly); |
86 | stream >> mPendingName >> mPendingEmail; | 87 | stream >> mPendingName >> mPendingEmail; |
87 | // removing the whitespaces at beginning and end is needed! | 88 | // removing the whitespaces at beginning and end is needed! |
88 | QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); | 89 | QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); |
89 | } | 90 | } |
90 | else if (msg == "newMail()") | 91 | else if (msg == "newMail()") |
91 | { | 92 | { |
92 | //qDebug("slotComposeMail() "); | 93 | //qDebug("slotComposeMail() "); |
93 | // we cannot call slotComposeMail(); directly, because may be executing a QCOP call | 94 | // we cannot call slotComposeMail(); directly, because may be executing a QCOP call |
94 | // and a QCOP call does not like a processevents in his execution | 95 | // and a QCOP call does not like a processevents in his execution |
95 | // with the Qtimer we call slotComposeMail() after we reached the main event loop | 96 | // with the Qtimer we call slotComposeMail() after we reached the main event loop |
96 | QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); | 97 | QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); |
97 | // slotComposeMail(); | 98 | // slotComposeMail(); |
98 | } | 99 | } |
99 | else if (msg == "newMail(QString)") | 100 | else if (msg == "newMail(QString)") |
100 | { | 101 | { |
101 | //qDebug(" newMail(QString)"); | 102 | //qDebug(" newMail(QString)"); |
102 | QDataStream stream(data,IO_ReadOnly); | 103 | QDataStream stream(data,IO_ReadOnly); |
103 | stream >> mPendingName; | 104 | stream >> mPendingName; |
104 | // the format is | 105 | // the format is |
105 | // NAME <EMAIL>:SUBJECT | 106 | // NAME <EMAIL>:SUBJECT |
106 | QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); | 107 | QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); |
107 | } else { | 108 | } else { |
108 | mPendingData = data; | 109 | mPendingData = data; |
109 | mPendingMessage = msg; | 110 | mPendingMessage = msg; |
110 | QTimer::singleShot ( 50, this, SLOT(slotExtAppHandler() ) ); | 111 | QTimer::singleShot ( 50, this, SLOT(slotExtAppHandler() ) ); |
111 | } | 112 | } |
112 | 113 | ||
113 | //qDebug("END OpieMail::message "); | 114 | //qDebug("END OpieMail::message "); |
114 | } | 115 | } |
115 | void OpieMail::slotExtAppHandler() | 116 | void OpieMail::slotExtAppHandler() |
116 | { | 117 | { |
117 | ExternalAppHandler::instance()->appMessage ( mPendingMessage, mPendingData ); | 118 | ExternalAppHandler::instance()->appMessage ( mPendingMessage, mPendingData ); |
118 | } | 119 | } |
119 | void OpieMail::slotwriteMail2(const QString& namemail ) | 120 | void OpieMail::slotwriteMail2(const QString& namemail ) |
120 | { | 121 | { |
121 | //qDebug("OpieMail::slotwriteMail2 "); | 122 | //qDebug("OpieMail::slotwriteMail2 "); |
122 | //qApp->processEvents(); | 123 | //qApp->processEvents(); |
123 | ComposeMail compose( settings, this, 0, true ); | 124 | ComposeMail compose( settings, this, 0, true ); |
124 | if ( !namemail.isEmpty() ) { | 125 | if ( !namemail.isEmpty() ) { |
125 | QString to = namemail; | 126 | QString to = namemail; |
126 | if ( namemail.find( " <") > 1 ) { | 127 | if ( namemail.find( " <") > 1 ) { |
127 | to = "\"" +to.replace( QRegExp( " <"), "\" <") ; | 128 | to = "\"" +to.replace( QRegExp( " <"), "\" <") ; |
128 | } else | 129 | } else |
129 | if ( namemail.find( "<") > 1 ) { | 130 | if ( namemail.find( "<") > 1 ) { |
130 | to = "\"" +to.replace( QRegExp( "<"), "\" <") ; | 131 | to = "\"" +to.replace( QRegExp( "<"), "\" <") ; |
131 | } | 132 | } |
132 | int sub = to.find( ">:"); | 133 | int sub = to.find( ">:"); |
133 | if ( sub > 0 ) { | 134 | if ( sub > 0 ) { |
134 | compose.setTo( to.left(sub+1) ); | 135 | compose.setTo( to.left(sub+1) ); |
135 | compose.setSubject( to.mid(sub+2) ); | 136 | compose.setSubject( to.mid(sub+2) ); |
136 | } else | 137 | } else |
137 | compose.setTo( to ); | 138 | compose.setTo( to ); |
138 | } | 139 | } |
139 | compose.slotAdjustColumns(); | 140 | compose.slotAdjustColumns(); |
140 | #ifndef DESKTOP_VERSION | 141 | #ifndef DESKTOP_VERSION |
141 | compose.showMaximized(); | 142 | compose.showMaximized(); |
142 | #endif | 143 | #endif |
143 | mCurrentComposer = &compose; | 144 | mCurrentComposer = &compose; |
144 | compose.exec(); | 145 | compose.exec(); |
145 | mCurrentComposer = 0; | 146 | mCurrentComposer = 0; |
146 | folderView->refreshOutgoing(); | 147 | folderView->refreshOutgoing(); |
147 | raise(); | 148 | raise(); |
148 | //qDebug("retttich "); | 149 | //qDebug("retttich "); |
149 | } | 150 | } |
150 | void OpieMail::slotwriteMail(const QString&name,const QString&email) | 151 | void OpieMail::slotwriteMail(const QString&name,const QString&email) |
151 | { | 152 | { |
152 | // qDebug("OpieMail::slotwriteMail "); | 153 | // qDebug("OpieMail::slotwriteMail "); |
153 | ComposeMail compose( settings, this, 0, true ); | 154 | ComposeMail compose( settings, this, 0, true ); |
154 | if (!email.isEmpty()) | 155 | if (!email.isEmpty()) |
155 | { | 156 | { |
156 | if (!name.isEmpty()) | 157 | if (!name.isEmpty()) |
157 | { | 158 | { |
158 | compose.setTo("\"" + name + "\"" + " " + "<"+ email + ">"); | 159 | compose.setTo("\"" + name + "\"" + " " + "<"+ email + ">"); |
159 | } | 160 | } |
160 | else | 161 | else |
161 | { | 162 | { |
162 | compose.setTo(email); | 163 | compose.setTo(email); |
163 | } | 164 | } |
164 | } | 165 | } |
165 | compose.slotAdjustColumns(); | 166 | compose.slotAdjustColumns(); |
166 | #ifndef DESKTOP_VERSION | 167 | #ifndef DESKTOP_VERSION |
167 | compose.showMaximized(); | 168 | compose.showMaximized(); |
168 | #endif | 169 | #endif |
169 | 170 | ||
170 | mCurrentComposer = &compose; | 171 | mCurrentComposer = &compose; |
171 | compose.exec(); | 172 | compose.exec(); |
172 | mCurrentComposer = 0; | 173 | mCurrentComposer = 0; |
173 | folderView->refreshOutgoing(); | 174 | folderView->refreshOutgoing(); |
174 | raise(); | 175 | raise(); |
175 | } | 176 | } |
176 | 177 | ||
177 | void OpieMail::slotComposeMail() | 178 | void OpieMail::slotComposeMail() |
178 | { | 179 | { |
179 | if ( mPendingEmail == QString::null && mPendingName == QString::null) | 180 | if ( mPendingEmail == QString::null && mPendingName == QString::null) |
180 | slotwriteMail2( QString () ); | 181 | slotwriteMail2( QString () ); |
181 | else { | 182 | else { |
182 | if ( mPendingEmail == QString::null ) | 183 | if ( mPendingEmail == QString::null ) |
183 | slotwriteMail2( mPendingName ); | 184 | slotwriteMail2( mPendingName ); |
184 | else | 185 | else |
185 | slotwriteMail( mPendingName, mPendingEmail ); | 186 | slotwriteMail( mPendingName, mPendingEmail ); |
186 | } | 187 | } |
187 | //slotwriteMail(0l,0l); | 188 | //slotwriteMail(0l,0l); |
188 | } | 189 | } |
189 | 190 | ||
190 | void OpieMail::slotSendQueued() | 191 | void OpieMail::slotSendQueued() |
191 | { | 192 | { |
192 | SMTPaccount *smtp = 0; | 193 | SMTPaccount *smtp = 0; |
193 | 194 | ||
194 | QList<Account> list = settings->getAccounts(); | 195 | QList<Account> list = settings->getAccounts(); |
195 | QList<SMTPaccount> smtpList; | 196 | QList<SMTPaccount> smtpList; |
196 | smtpList.setAutoDelete(false); | 197 | smtpList.setAutoDelete(false); |
197 | Account *it; | 198 | Account *it; |
198 | for ( it = list.first(); it; it = list.next() ) | 199 | for ( it = list.first(); it; it = list.next() ) |
199 | { | 200 | { |
200 | if ( it->getType() == MAILLIB::A_SMTP ) | 201 | if ( it->getType() == MAILLIB::A_SMTP ) |
201 | { | 202 | { |
202 | smtp = static_cast<SMTPaccount *>(it); | 203 | smtp = static_cast<SMTPaccount *>(it); |
203 | smtpList.append(smtp); | 204 | smtpList.append(smtp); |
204 | } | 205 | } |
205 | } | 206 | } |
206 | if (smtpList.count()==0) | 207 | if (smtpList.count()==0) |
207 | { | 208 | { |
208 | QMessageBox::information(0,i18n("Info"),i18n("Define a smtp\n account first!\n")); | 209 | QMessageBox::information(0,i18n("Info"),i18n("Define a smtp\n account first!\n")); |
209 | return; | 210 | return; |
210 | } | 211 | } |
211 | if ( QMessageBox::warning(this, i18n("Sending all mails"), i18n("Do you really want to\nsend all queued mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::No ) | 212 | if ( QMessageBox::warning(this, i18n("Sending all mails"), i18n("Do you really want to\nsend all queued mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::No ) |
212 | return; | 213 | return; |
213 | if (smtpList.count()==1) | 214 | if (smtpList.count()==1) |
214 | { | 215 | { |
215 | smtp = smtpList.at(0); | 216 | smtp = smtpList.at(0); |
216 | } | 217 | } |
217 | else | 218 | else |
218 | { | 219 | { |
219 | smtp = 0; | 220 | smtp = 0; |
220 | selectsmtp selsmtp; | 221 | selectsmtp selsmtp; |
221 | selsmtp.setSelectionlist(&smtpList); | 222 | selsmtp.setSelectionlist(&smtpList); |
222 | selsmtp.resize( selsmtp.sizeHint() ); | 223 | selsmtp.resize( selsmtp.sizeHint() ); |
223 | if ( selsmtp.exec() == QDialog::Accepted ) | 224 | if ( selsmtp.exec() == QDialog::Accepted ) |
224 | { | 225 | { |
225 | smtp = selsmtp.selected_smtp(); | 226 | smtp = selsmtp.selected_smtp(); |
226 | } | 227 | } |
227 | } | 228 | } |
228 | if (smtp) | 229 | if (smtp) |
229 | { | 230 | { |
230 | 231 | ||
231 | Global::statusMessage("Sending mails...!"); | 232 | Global::statusMessage("Sending mails...!"); |
232 | SMTPwrapper * wrap = new SMTPwrapper(smtp); | 233 | SMTPwrapper * wrap = new SMTPwrapper(smtp); |
233 | if ( wrap->flushOutbox() ) | 234 | if ( wrap->flushOutbox() ) |
234 | { | 235 | { |
235 | Global::statusMessage("Mails sent!"); | 236 | Global::statusMessage("Mails sent!"); |
236 | } | 237 | } |
237 | delete wrap; | 238 | delete wrap; |
238 | } | 239 | } |
239 | folderView->refreshOutgoing(); | 240 | folderView->refreshOutgoing(); |
240 | } | 241 | } |
241 | 242 | ||
242 | void OpieMail::slotSearchMails() | 243 | void OpieMail::slotSearchMails() |
243 | { | 244 | { |
244 | qDebug("OpieMail::slotSearchMails():not implemented "); | 245 | qDebug("OpieMail::slotSearchMails():not implemented "); |
245 | } | 246 | } |
246 | 247 | ||
247 | void OpieMail::slotEditSettings() | 248 | void OpieMail::slotEditSettings() |
248 | { | 249 | { |
249 | 250 | ||
250 | KOPrefsDialog settingsDialog( this, "koprefs", true ); | 251 | KOPrefsDialog settingsDialog( this, "koprefs", true ); |
251 | #ifndef DESKTOP_VERSION | 252 | #ifndef DESKTOP_VERSION |
252 | settingsDialog.showMaximized(); | 253 | settingsDialog.showMaximized(); |
253 | #endif | 254 | #endif |
254 | settingsDialog.exec(); | 255 | settingsDialog.exec(); |
255 | 256 | ||
256 | slotSetCodec( KOPrefs::instance()->mCurrentCodec ); | 257 | slotSetCodec( KOPrefs::instance()->mCurrentCodec ); |
257 | // KApplication::execDialog(settingsDialog); | 258 | // KApplication::execDialog(settingsDialog); |
258 | } | 259 | } |
259 | 260 | ||
260 | void OpieMail::slotEditAccounts() | 261 | void OpieMail::slotEditAccounts() |
261 | { | 262 | { |
262 | EditAccounts eaDialog( settings, this, 0, true ); | 263 | EditAccounts eaDialog( settings, this, 0, true ); |
263 | eaDialog.slotAdjustColumns(); | 264 | eaDialog.slotAdjustColumns(); |
264 | #ifndef DESKTOP_VERSION | 265 | #ifndef DESKTOP_VERSION |
265 | eaDialog.showMaximized(); | 266 | eaDialog.showMaximized(); |
266 | #endif | 267 | #endif |
267 | eaDialog.exec(); | 268 | eaDialog.exec(); |
268 | if ( settings ) delete settings; | 269 | if ( settings ) delete settings; |
269 | settings = new Settings(); | 270 | settings = new Settings(); |
270 | 271 | ||
271 | folderView->populate( settings->getAccounts() ); | 272 | folderView->populate( settings->getAccounts() ); |
272 | } | 273 | } |
273 | void OpieMail::replyMail() | 274 | void OpieMail::replyMail() |
274 | { | 275 | { |
275 | 276 | ||
276 | QListViewItem*item = mailView->currentItem(); | 277 | QListViewItem*item = mailView->currentItem(); |
277 | if (!item) return; | 278 | if (!item) return; |
278 | RecMailP mail = ((MailListViewItem*)item)->data(); | 279 | RecMailP mail = ((MailListViewItem*)item)->data(); |
279 | RecBodyP body = folderView->fetchBody(mail); | 280 | RecBodyP body = folderView->fetchBody(mail); |
280 | 281 | ||
281 | QString rtext; | 282 | QString rtext; |
282 | rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose | 283 | rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose |
283 | .arg( mail->getFrom()) | 284 | .arg( mail->getFrom()) |
284 | .arg( mail->getDate()); | 285 | .arg( mail->getDate()); |
285 | 286 | ||
286 | QString text = body->Bodytext(); | 287 | QString text = body->Bodytext(); |
287 | QStringList lines = QStringList::split(QRegExp("\\n"), text); | 288 | QStringList lines = QStringList::split(QRegExp("\\n"), text); |
288 | QStringList::Iterator it; | 289 | QStringList::Iterator it; |
289 | for (it = lines.begin(); it != lines.end(); it++) | 290 | for (it = lines.begin(); it != lines.end(); it++) |
290 | { | 291 | { |
291 | rtext += "> " + *it + "\n"; | 292 | rtext += "> " + *it + "\n"; |
292 | } | 293 | } |
293 | rtext += "\n"; | 294 | rtext += "\n"; |
294 | 295 | ||
295 | QString prefix; | 296 | QString prefix; |
296 | if ( mail->getSubject().find(QRegExp("^Re: .*$")) != -1) prefix = ""; | 297 | if ( mail->getSubject().find(QRegExp("^Re: .*$")) != -1) prefix = ""; |
297 | else prefix = "Re: "; // no i18n on purpose | 298 | else prefix = "Re: "; // no i18n on purpose |
298 | 299 | ||
299 | Settings *settings = new Settings(); | 300 | Settings *settings = new Settings(); |
300 | ComposeMail composer( settings ,this, 0, true); | 301 | ComposeMail composer( settings ,this, 0, true); |
301 | if (mail->Replyto().isEmpty()) { | 302 | if (mail->Replyto().isEmpty()) { |
302 | composer.setTo( mail->getFrom()); | 303 | composer.setTo( mail->getFrom()); |
303 | } else { | 304 | } else { |
304 | composer.setTo( mail->Replyto()); | 305 | composer.setTo( mail->Replyto()); |
305 | } | 306 | } |
306 | composer.setSubject( prefix + mail->getSubject()); | 307 | composer.setSubject( prefix + mail->getSubject()); |
307 | composer.setMessage( rtext ); | 308 | composer.setMessage( rtext ); |
308 | composer.setInReplyTo( mail->Msgid()); | 309 | composer.setInReplyTo( mail->Msgid()); |
309 | composer.setCharset( body->getCharset() ); | 310 | composer.setCharset( body->getCharset() ); |
310 | 311 | ||
311 | mCurrentComposer = &composer; | 312 | mCurrentComposer = &composer; |
312 | if ( QDialog::Accepted == KApplication::execDialog( &composer ) ) | 313 | if ( QDialog::Accepted == KApplication::execDialog( &composer ) ) |
313 | { | 314 | { |
314 | mail->Wrapper()->answeredMail(mail); | 315 | mail->Wrapper()->answeredMail(mail); |
315 | } | 316 | } |
316 | mCurrentComposer = 0; | 317 | mCurrentComposer = 0; |
317 | folderView->refreshOutgoing(); | 318 | folderView->refreshOutgoing(); |
318 | delete settings; | 319 | delete settings; |
319 | 320 | ||
320 | } | 321 | } |
321 | void OpieMail::closeViewMail(ViewMail * vm) | 322 | void OpieMail::closeViewMail(ViewMail * vm) |
322 | { | 323 | { |
323 | vm->hide(); | 324 | vm->hide(); |
324 | } | 325 | } |
325 | 326 | ||
326 | void OpieMail::slotDownloadMail( ) | 327 | void OpieMail::slotDownloadMail( ) |
327 | { | 328 | { |
328 | QListViewItem*item = mailView->currentItem(); | 329 | QListViewItem*item = mailView->currentItem(); |
329 | if (!item ) { | 330 | if (!item ) { |
330 | Global::statusMessage("Error: No item slected!"); | 331 | Global::statusMessage("Error: No item slected!"); |
331 | return; | 332 | return; |
332 | } | 333 | } |
333 | RecMailP mail = ((MailListViewItem*)item)->data(); | 334 | RecMailP mail = ((MailListViewItem*)item)->data(); |
334 | Account * acc = mail->Wrapper()->getAccount(); | 335 | Account * acc = mail->Wrapper()->getAccount(); |
335 | if ( !acc ) { | 336 | if ( !acc ) { |
336 | Global::statusMessage("Mail is already stored locally!"); | 337 | Global::statusMessage("Mail is already stored locally!"); |
337 | return; | 338 | return; |
338 | } | 339 | } |
339 | QString lfName = acc->getLocalFolder(); | 340 | QString lfName = acc->getLocalFolder(); |
340 | //qDebug("local folder " + lfName ); | 341 | //qDebug("local folder " + lfName ); |
341 | if ( lfName.isEmpty() ) | 342 | if ( lfName.isEmpty() ) |
342 | lfName = acc->getAccountName(); | 343 | lfName = acc->getAccountName(); |
343 | AbstractMail* targetMail = folderView->allAccounts()[0]->getWrapper(); | 344 | AbstractMail* targetMail = folderView->allAccounts()[0]->getWrapper(); |
344 | //qDebug("target %d %d ",targetMail,mail->Wrapper() ); | 345 | //qDebug("target %d %d ",targetMail,mail->Wrapper() ); |
345 | if ( targetMail == mail->Wrapper() ) { | 346 | if ( targetMail == mail->Wrapper() ) { |
346 | Global::statusMessage("Mail is already locally stored!"); | 347 | Global::statusMessage("Mail is already locally stored!"); |
347 | return; | 348 | return; |
348 | } | 349 | } |
349 | if ( !targetMail->createMbox(lfName)) { | 350 | if ( !targetMail->createMbox(lfName)) { |
350 | Global::statusMessage("Error creating folder!"); | 351 | Global::statusMessage("Error creating folder!"); |
351 | return; | 352 | return; |
352 | } | 353 | } |
353 | Global::statusMessage("Fetching mail...please wait!"); | 354 | Global::statusMessage("Fetching mail...please wait!"); |
354 | qApp->processEvents(); | 355 | qApp->processEvents(); |
355 | encodedString*st = 0; | 356 | encodedString*st = 0; |
356 | st = mail->Wrapper()->fetchRawBody(mail); | 357 | st = mail->Wrapper()->fetchRawBody(mail); |
357 | if ( st ) { | 358 | if ( st ) { |
358 | targetMail->storeMessage(st->Content(),st->Length(),lfName); | 359 | targetMail->storeMessage(st->Content(),st->Length(),lfName); |
359 | Global::statusMessage("Mail stored in "+ lfName); | 360 | Global::statusMessage("Mail stored in "+ lfName); |
360 | delete st; | 361 | delete st; |
361 | } else { | 362 | } else { |
362 | Global::statusMessage("Error: Cannot fetch mail!"); | 363 | Global::statusMessage("Error: Cannot fetch mail!"); |
363 | } | 364 | } |
364 | } | 365 | } |
365 | 366 | ||
366 | 367 | ||
367 | void OpieMail::deleteAndDisplayNextMail(ViewMail * vm) | 368 | void OpieMail::deleteAndDisplayNextMail(ViewMail * vm) |
368 | { | 369 | { |
369 | QListViewItem*item = mailView->currentItem(); | 370 | QListViewItem*item = mailView->currentItem(); |
370 | if (!item ) { | 371 | if (!item ) { |
371 | closeViewMail(vm); | 372 | closeViewMail(vm); |
372 | return; | 373 | return; |
373 | } | 374 | } |
374 | RecMailP mail = ((MailListViewItem*)item)->data(); | 375 | RecMailP mail = ((MailListViewItem*)item)->data(); |
375 | mail->Wrapper()->deleteMail( mail ); | 376 | mail->Wrapper()->deleteMail( mail ); |
376 | item = item->itemBelow(); | 377 | item = item->itemBelow(); |
377 | if (!item ) { | 378 | if (!item ) { |
378 | closeViewMail(vm); | 379 | closeViewMail(vm); |
379 | return; | 380 | return; |
380 | } | 381 | } |
381 | mailView->setCurrentItem(item); | 382 | mailView->setCurrentItem(item); |
382 | mail = ((MailListViewItem*)item)->data(); | 383 | mail = ((MailListViewItem*)item)->data(); |
383 | RecBodyP body = folderView->fetchBody(mail); | 384 | RecBodyP body = folderView->fetchBody(mail); |
384 | vm->setBody( body ); | 385 | vm->setBody( body ); |
385 | vm->setMail( mail ); | 386 | vm->setMail( mail ); |
386 | } | 387 | } |
387 | void OpieMail::displayNextMail(ViewMail * vm) | 388 | void OpieMail::displayNextMail(ViewMail * vm) |
388 | { | 389 | { |
389 | QListViewItem*item = mailView->currentItem(); | 390 | QListViewItem*item = mailView->currentItem(); |
390 | if (!item) return; | 391 | if (!item) return; |
391 | ( (MailListViewItem*)item )->setPixmap( 0, QPixmap() ); | 392 | ( (MailListViewItem*)item )->setPixmap( 0, QPixmap() ); |
392 | item = item->itemBelow(); | 393 | item = item->itemBelow(); |
393 | if (!item) { | 394 | if (!item) { |
394 | vm->setCaption(i18n("End of List" )); | 395 | vm->setCaption(i18n("End of List" )); |
395 | return; | 396 | return; |
396 | } | 397 | } |
397 | mailView->setCurrentItem(item); | 398 | mailView->setCurrentItem(item); |
398 | RecMailP mail = ((MailListViewItem*)item)->data(); | 399 | RecMailP mail = ((MailListViewItem*)item)->data(); |
399 | RecBodyP body = folderView->fetchBody(mail); | 400 | RecBodyP body = folderView->fetchBody(mail); |
400 | vm->setBody( body ); | 401 | vm->setBody( body ); |
401 | vm->setMail( mail ); | 402 | vm->setMail( mail ); |
402 | } | 403 | } |
403 | void OpieMail::displayMail() | 404 | void OpieMail::displayMail() |
404 | { | 405 | { |
405 | QListViewItem*item = mailView->currentItem(); | 406 | QListViewItem*item = mailView->currentItem(); |
406 | if (!item) return; | 407 | if (!item) return; |
407 | RecMailP mail = ((MailListViewItem*)item)->data(); | 408 | RecMailP mail = ((MailListViewItem*)item)->data(); |
408 | RecBodyP body = folderView->fetchBody(mail); | 409 | RecBodyP body = folderView->fetchBody(mail); |
409 | ViewMail readMail( this,"", Qt::WType_Modal ); | 410 | ViewMail readMail( this,"", Qt::WType_Modal ); |
410 | readMail.setBody( body ); | 411 | readMail.setBody( body ); |
411 | readMail.setMail( mail ); | 412 | readMail.setMail( mail ); |
412 | #ifndef DESKTOP_VERSION | 413 | #ifndef DESKTOP_VERSION |
413 | readMail.showMaximized(); | 414 | readMail.showMaximized(); |
414 | #else | 415 | #else |
415 | readMail.resize( 640, 480); | 416 | readMail.resize( 640, 480); |
416 | #endif | 417 | #endif |
417 | connect( &readMail,SIGNAL( showNextMail(ViewMail *) ), this, SLOT( displayNextMail(ViewMail *) ) ); | 418 | connect( &readMail,SIGNAL( showNextMail(ViewMail *) ), this, SLOT( displayNextMail(ViewMail *) ) ); |
418 | connect( &readMail,SIGNAL( deleteAndDisplayNextMail(ViewMail *) ), this, SLOT(deleteAndDisplayNextMail(ViewMail *) ) ); | 419 | connect( &readMail,SIGNAL( deleteAndDisplayNextMail(ViewMail *) ), this, SLOT(deleteAndDisplayNextMail(ViewMail *) ) ); |
419 | connect( &readMail,SIGNAL( signalDownloadMail() ), this, SLOT( slotDownloadMail() ) ); | 420 | connect( &readMail,SIGNAL( signalDownloadMail() ), this, SLOT( slotDownloadMail() ) ); |
420 | 421 | ||
421 | readMail.exec(); | 422 | readMail.exec(); |
422 | 423 | ||
423 | if ( readMail.deleted ) | 424 | if ( readMail.deleted ) |
424 | { | 425 | { |
425 | folderView->refreshCurrent(); | 426 | folderView->refreshCurrent(); |
426 | } | 427 | } |
427 | else | 428 | else |
428 | { | 429 | { |
429 | QListViewItem*item = mailView->currentItem(); | 430 | QListViewItem*item = mailView->currentItem(); |
430 | if (item) | 431 | if (item) |
431 | ( (MailListViewItem*)item )->setPixmap( 0, QPixmap() ); | 432 | ( (MailListViewItem*)item )->setPixmap( 0, QPixmap() ); |
432 | } | 433 | } |
433 | } | 434 | } |
434 | void OpieMail::slotGetAllMail() | 435 | void OpieMail::slotGetAllMail() |
435 | { | 436 | { |
436 | QListViewItem * item = folderView->firstChild(); | 437 | QListViewItem * item = folderView->firstChild(); |
437 | while ( item ){ | 438 | while ( item ){ |
438 | ((AccountViewItem *)item)->contextMenuSelected( 101 ); | 439 | ((AccountViewItem *)item)->contextMenuSelected( 101 ); |
439 | item = item->nextSibling (); | 440 | item = item->nextSibling (); |
440 | } | 441 | } |
441 | } | 442 | } |
442 | void OpieMail::slotGetMail() | 443 | void OpieMail::slotGetMail() |
443 | { | 444 | { |
444 | QListViewItem * item = folderView->currentItem(); | 445 | QListViewItem * item = folderView->currentItem(); |
445 | if ( ! item ) return; | 446 | if ( ! item ) return; |
446 | ((AccountViewItem *)item)->contextMenuSelected( 101 ); | 447 | ((AccountViewItem *)item)->contextMenuSelected( 101 ); |
447 | } | 448 | } |
448 | void OpieMail::slotDeleteMail() | 449 | void OpieMail::slotDeleteMail() |
449 | { | 450 | { |
450 | if (!mailView->currentItem()) return; | 451 | if (!mailView->currentItem()) return; |
451 | RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data(); | 452 | RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data(); |
452 | 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 ) | 453 | 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 ) |
453 | { | 454 | { |
454 | mail->Wrapper()->deleteMail( mail ); | 455 | mail->Wrapper()->deleteMail( mail ); |
455 | folderView->refreshCurrent(); | 456 | folderView->refreshCurrent(); |
456 | } | 457 | } |
457 | } | 458 | } |
458 | void OpieMail::slotDeleteAllMail() | 459 | void OpieMail::slotDeleteAllMail() |
459 | { | 460 | { |
460 | 461 | ||
461 | QValueList<RecMailP> t; | 462 | QValueList<RecMailP> t; |
462 | if ( QMessageBox::warning(this, i18n("Delete All Mails"), i18n("Do you really want to delete\nall selected mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) | 463 | if ( QMessageBox::warning(this, i18n("Delete All Mails"), i18n("Do you really want to delete\nall selected mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) |
463 | { | 464 | { |
464 | MailListViewItem* item = (MailListViewItem*)mailView->firstChild (); | 465 | MailListViewItem* item = (MailListViewItem*)mailView->firstChild (); |
465 | while ( item ) { | 466 | while ( item ) { |
466 | if ( item->isSelected() ) { | 467 | if ( item->isSelected() ) { |
467 | t.append( item->data() ); | 468 | t.append( item->data() ); |
468 | } | 469 | } |
469 | item = (MailListViewItem*)item->nextSibling(); | 470 | item = (MailListViewItem*)item->nextSibling(); |
470 | } | 471 | } |
471 | } | 472 | } |
472 | else | 473 | else |
473 | return; | 474 | return; |
474 | if ( t.count() == 0 ) | 475 | if ( t.count() == 0 ) |
475 | return; | 476 | return; |
476 | RecMailP mail = t.first(); | 477 | RecMailP mail = t.first(); |
477 | mail->Wrapper()->deleteMailList(t); | 478 | mail->Wrapper()->deleteMailList(t); |
478 | folderView->refreshCurrent(); | 479 | folderView->refreshCurrent(); |
479 | 480 | ||
480 | 481 | ||
481 | } | 482 | } |
482 | void OpieMail::clearSelection() | 483 | void OpieMail::clearSelection() |
483 | { | 484 | { |
484 | mailView->clearSelection(); | 485 | mailView->clearSelection(); |
485 | 486 | ||
486 | } | 487 | } |
487 | 488 | ||
488 | void OpieMail::mailHold(int button, QListViewItem *item,const QPoint&,int ) | 489 | void OpieMail::mailHold(int button, QListViewItem *item,const QPoint&,int ) |
489 | { | 490 | { |
490 | if (!mailView->currentItem()) return; | 491 | if (!mailView->currentItem()) return; |
491 | MAILLIB::ATYPE mailtype = ((MailListViewItem*)mailView->currentItem() )->wrapperType(); | 492 | MAILLIB::ATYPE mailtype = ((MailListViewItem*)mailView->currentItem() )->wrapperType(); |
492 | /* just the RIGHT button - or hold on pda */ | 493 | /* just the RIGHT button - or hold on pda */ |
493 | if (button!=2) {return;} | 494 | if (button!=2) {return;} |
494 | if (!item) return; | 495 | if (!item) return; |
495 | QPopupMenu *m = new QPopupMenu(0); | 496 | QPopupMenu *m = new QPopupMenu(0); |
496 | if (m) | 497 | if (m) |
497 | { | 498 | { |
498 | if (mailtype==MAILLIB::A_NNTP) { | 499 | if (mailtype==MAILLIB::A_NNTP) { |
499 | m->insertItem(i18n("Read this posting"),this,SLOT(displayMail())); | 500 | m->insertItem(i18n("Read this posting"),this,SLOT(displayMail())); |
500 | m->insertItem(i18n("Copy this posting"),this,SLOT(slotMoveCopyMail())); | 501 | m->insertItem(i18n("Copy this posting"),this,SLOT(slotMoveCopyMail())); |
501 | m->insertSeparator(); | 502 | m->insertSeparator(); |
502 | m->insertItem(i18n("Copy all selected postings"),this,SLOT(slotMoveCopyAllMail())); | 503 | m->insertItem(i18n("Copy all selected postings"),this,SLOT(slotMoveCopyAllMail())); |
503 | m->insertItem(i18n("Clear selection"),this,SLOT(clearSelection())); | 504 | m->insertItem(i18n("Clear selection"),this,SLOT(clearSelection())); |
504 | } else { | 505 | } else { |
505 | if (folderView->currentisDraft()) { | 506 | if (folderView->currentisDraft()) { |
506 | m->insertItem(i18n("Edit this mail"),this,SLOT(reEditMail())); | 507 | m->insertItem(i18n("Edit this mail"),this,SLOT(reEditMail())); |
507 | } | 508 | } |
508 | m->insertItem(i18n("Reply to this mail"),this,SLOT(replyMail())); | 509 | m->insertItem(i18n("Reply to this mail"),this,SLOT(replyMail())); |
509 | m->insertItem(i18n("Read this mail"),this,SLOT(displayMail())); | 510 | m->insertItem(i18n("Read this mail"),this,SLOT(displayMail())); |
510 | m->insertSeparator(); | 511 | m->insertSeparator(); |
511 | m->insertItem(i18n("Move/Copy this mail"),this,SLOT(slotMoveCopyMail())); | 512 | m->insertItem(i18n("Move/Copy this mail"),this,SLOT(slotMoveCopyMail())); |
512 | m->insertItem(i18n("Delete this mail"),this,SLOT(slotDeleteMail())); | 513 | m->insertItem(i18n("Delete this mail"),this,SLOT(slotDeleteMail())); |
513 | m->insertSeparator(); | 514 | m->insertSeparator(); |
514 | m->insertItem(i18n("Move/Copy all selected mail"),this,SLOT(slotMoveCopyAllMail())); | 515 | m->insertItem(i18n("Move/Copy all selected mail"),this,SLOT(slotMoveCopyAllMail())); |
515 | m->insertItem(i18n("Delete all selected mails"),this,SLOT(slotDeleteAllMail())); | 516 | m->insertItem(i18n("Delete all selected mails"),this,SLOT(slotDeleteAllMail())); |
516 | m->insertSeparator(); | 517 | m->insertSeparator(); |
517 | m->insertItem(i18n("Clear selection"),this,SLOT(clearSelection())); | 518 | m->insertItem(i18n("Clear selection"),this,SLOT(clearSelection())); |
518 | } | 519 | } |
519 | m->setFocus(); | 520 | m->setFocus(); |
520 | m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); | 521 | m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); |
521 | delete m; | 522 | delete m; |
522 | } | 523 | } |
523 | } | 524 | } |
524 | 525 | ||
525 | void OpieMail::slotShowFolders( bool show ) | 526 | void OpieMail::slotShowFolders( bool show ) |
526 | { | 527 | { |
527 | if ( show && folderView->isHidden() ) | 528 | if ( show && folderView->isHidden() ) |
528 | { | 529 | { |
529 | folderView->show(); | 530 | folderView->show(); |
530 | } | 531 | } |
531 | else if ( !show && !folderView->isHidden() ) | 532 | else if ( !show && !folderView->isHidden() ) |
532 | { | 533 | { |
533 | folderView->hide(); | 534 | folderView->hide(); |
534 | } | 535 | } |
535 | } | 536 | } |
536 | 537 | ||
537 | void OpieMail::refreshMailView(const QValueList<RecMailP>&list) | 538 | void OpieMail::refreshMailView(const QValueList<RecMailP>&list) |
538 | { | 539 | { |
539 | MailListViewItem*item = 0; | 540 | MailListViewItem*item = 0; |
540 | mailView->clear(); | 541 | mailView->clear(); |
541 | 542 | ||
542 | QValueList<RecMailP>::ConstIterator it; | 543 | QValueList<RecMailP>::ConstIterator it; |
543 | for (it = list.begin(); it != list.end();++it) | 544 | for (it = list.begin(); it != list.end();++it) |
544 | { | 545 | { |
545 | item = new MailListViewItem(mailView,item); | 546 | item = new MailListViewItem(mailView,item); |
546 | item->storeData((*it)); | 547 | item->storeData((*it)); |
547 | item->showEntry(); | 548 | item->showEntry(); |
548 | } | 549 | } |
549 | mailView->setSorting ( 4, false ); | 550 | mailView->setSorting ( 4, false ); |
550 | } | 551 | } |
551 | 552 | ||
552 | void OpieMail::mailLeftClicked( QListViewItem *item ) | 553 | void OpieMail::mailLeftClicked( QListViewItem *item ) |
553 | { | 554 | { |
554 | mailView->clearSelection(); | 555 | mailView->clearSelection(); |
555 | /* just LEFT button - or tap with stylus on pda */ | 556 | /* just LEFT button - or tap with stylus on pda */ |
556 | //if (button!=1) return; | 557 | //if (button!=1) return; |
557 | if (!item) return; | 558 | if (!item) return; |
558 | if (folderView->currentisDraft()) { | 559 | if (folderView->currentisDraft()) { |
559 | reEditMail(); | 560 | reEditMail(); |
560 | } else { | 561 | } else { |
561 | displayMail(); | 562 | displayMail(); |
562 | } | 563 | } |
563 | } | 564 | } |
564 | 565 | ||
565 | void OpieMail::slotMoveCopyMail() | 566 | void OpieMail::slotMoveCopyMail() |
566 | { | 567 | { |
567 | if (!mailView->currentItem()) return; | 568 | if (!mailView->currentItem()) return; |
diff --git a/kmicromail/viewmailbase.cpp b/kmicromail/viewmailbase.cpp index 3a41ba0..3bb964e 100644 --- a/kmicromail/viewmailbase.cpp +++ b/kmicromail/viewmailbase.cpp | |||
@@ -1,106 +1,109 @@ | |||
1 | // CHANGED 2004-08-06 Lutz Rogowski | 1 | // CHANGED 2004-08-06 Lutz Rogowski |
2 | #include <qtextbrowser.h> | 2 | #include <qtextbrowser.h> |
3 | #include <qlistview.h> | 3 | #include <qlistview.h> |
4 | #include <qaction.h> | 4 | #include <qaction.h> |
5 | #include <qlabel.h> | 5 | #include <qlabel.h> |
6 | #include <qvbox.h> | 6 | #include <qvbox.h> |
7 | #include <qapplication.h> | ||
7 | 8 | ||
8 | #include <qtoolbar.h> | 9 | #include <qtoolbar.h> |
9 | #include <qmenubar.h> | 10 | #include <qmenubar.h> |
10 | #include <kiconloader.h> | 11 | #include <kiconloader.h> |
11 | //#include <qpe/resource.h> | 12 | //#include <qpe/resource.h> |
12 | #include <klocale.h> | 13 | #include <klocale.h> |
13 | 14 | ||
14 | #include "viewmailbase.h" | 15 | #include "viewmailbase.h" |
15 | //#include "opendiag.h" | 16 | //#include "opendiag.h" |
16 | 17 | ||
17 | ViewMailBase::ViewMailBase(QWidget *parent, const char *name, WFlags fl) | 18 | ViewMailBase::ViewMailBase(QWidget *parent, const char *name, WFlags fl) |
18 | : QMainWindow(parent, name, fl) | 19 | : QMainWindow(parent, name, fl) |
19 | { | 20 | { |
20 | 21 | ||
21 | setToolBarsMovable(false); | 22 | setToolBarsMovable(false); |
22 | 23 | ||
23 | toolbar = new QToolBar(this); | 24 | toolbar = new QToolBar(this); |
24 | menubar = new QMenuBar( toolbar ); | 25 | menubar = new QMenuBar( toolbar ); |
25 | mailmenu = new QPopupMenu( menubar ); | 26 | mailmenu = new QPopupMenu( menubar ); |
26 | menubar->insertItem( i18n( "Mail" ), mailmenu ); | 27 | menubar->insertItem( i18n( "Mail" ), mailmenu ); |
27 | 28 | ||
28 | toolbar->setHorizontalStretchable(true); | 29 | toolbar->setHorizontalStretchable(true); |
29 | addToolBar(toolbar); | 30 | addToolBar(toolbar); |
30 | 31 | ||
31 | viewSource = new QAction(i18n("View Source"), 0, 0, this); | 32 | viewSource = new QAction(i18n("View Source"), 0, 0, this); |
32 | viewSource->addTo(mailmenu); | 33 | viewSource->addTo(mailmenu); |
33 | 34 | ||
34 | downloadMail= new QAction(i18n("Download Mail"),SmallIcon("add"), 0, 0, this); | 35 | downloadMail= new QAction(i18n("Download Mail"),SmallIcon("add"), 0, 0, this); |
35 | downloadMail->addTo(toolbar); | 36 | downloadMail->addTo(toolbar); |
36 | downloadMail->addTo(mailmenu); | 37 | downloadMail->addTo(mailmenu); |
37 | 38 | ||
38 | 39 | ||
39 | reply = new QAction(i18n("Reply"),SmallIcon("reply"), 0, 0, this); | 40 | reply = new QAction(i18n("Reply"),SmallIcon("reply"), 0, 0, this); |
40 | reply->addTo(toolbar); | 41 | reply->addTo(toolbar); |
41 | reply->addTo(mailmenu); | 42 | reply->addTo(mailmenu); |
42 | 43 | ||
43 | forward = new QAction(i18n("Forward"),SmallIcon("forward"), 0, 0, this); | 44 | forward = new QAction(i18n("Forward"),SmallIcon("forward"), 0, 0, this); |
44 | forward->addTo(toolbar); | 45 | forward->addTo(toolbar); |
45 | forward->addTo(mailmenu); | 46 | forward->addTo(mailmenu); |
46 | 47 | ||
47 | attachbutton = new QAction(i18n("Attachments"),SmallIcon("attach"), 0, 0, this, 0, true); | 48 | attachbutton = new QAction(i18n("Attachments"),SmallIcon("attach"), 0, 0, this, 0, true); |
48 | attachbutton->addTo(toolbar); | 49 | attachbutton->addTo(toolbar); |
49 | attachbutton->addTo(mailmenu); | 50 | attachbutton->addTo(mailmenu); |
50 | connect(attachbutton, SIGNAL(toggled(bool)), SLOT(slotChangeAttachview(bool))); | 51 | connect(attachbutton, SIGNAL(toggled(bool)), SLOT(slotChangeAttachview(bool))); |
51 | 52 | ||
52 | showHtml = new QAction( i18n( "Show Html" ), SmallIcon( "html" ), 0, 0, this, 0, true ); | 53 | showHtml = new QAction( i18n( "Show Html" ), SmallIcon( "html" ), 0, 0, this, 0, true ); |
53 | showHtml->addTo( toolbar ); | 54 | showHtml->addTo( toolbar ); |
54 | showHtml->addTo( mailmenu ); | 55 | showHtml->addTo( mailmenu ); |
55 | 56 | ||
56 | deleteMail = new QAction(i18n("Delete Mail"),SmallIcon("trash"), 0, 0, this); | 57 | deleteMail = new QAction(i18n("Delete Mail"),SmallIcon("trash"), 0, 0, this); |
57 | deleteMail->addTo(toolbar); | 58 | deleteMail->addTo(toolbar); |
58 | deleteMail->addTo(mailmenu); | 59 | deleteMail->addTo(mailmenu); |
59 | 60 | ||
60 | nextMail = new QAction(i18n("Show next mail"),SmallIcon("enter"), 0, 0, this); | 61 | nextMail = new QAction(i18n("Show next mail"),SmallIcon("enter"), 0, 0, this); |
61 | QLabel *spacer = new QLabel(toolbar); | 62 | QLabel *spacer = new QLabel(toolbar); |
62 | nextMail->addTo(toolbar); | 63 | nextMail->addTo(toolbar); |
63 | nextMail->addTo(mailmenu); | 64 | nextMail->addTo(mailmenu); |
64 | 65 | ||
65 | closeMail = new QAction(i18n("Close"),SmallIcon("exit"), 0, 0, this); | 66 | closeMail = new QAction(i18n("Close"),SmallIcon("exit"), 0, 0, this); |
66 | //QLabel *spacer = new QLabel(toolbar); | 67 | //QLabel *spacer = new QLabel(toolbar); |
67 | spacer->setBackgroundMode(QWidget::PaletteButton); | 68 | spacer->setBackgroundMode(QWidget::PaletteButton); |
68 | toolbar->setStretchableWidget(spacer); | 69 | toolbar->setStretchableWidget(spacer); |
69 | closeMail->addTo(toolbar); | 70 | closeMail->addTo(toolbar); |
70 | closeMail->addTo(mailmenu); | 71 | closeMail->addTo(mailmenu); |
71 | QVBox *view = new QVBox(this); | 72 | QVBox *view = new QVBox(this); |
72 | setCentralWidget(view); | 73 | setCentralWidget(view); |
73 | 74 | ||
74 | attachments = new QListView(view); | 75 | attachments = new QListView(view); |
75 | attachments->setMinimumHeight(90); | 76 | int fixh = 100; |
76 | attachments->setMaximumHeight(90); | 77 | if ( QApplication::desktop()->width() > 320 ) |
78 | fixh = 200; | ||
79 | attachments->setFixedHeight(fixh); | ||
77 | attachments->setAllColumnsShowFocus(true); | 80 | attachments->setAllColumnsShowFocus(true); |
78 | attachments->addColumn("Mime Type", 60); | 81 | attachments->addColumn("Mime Type", fixh-30); |
79 | attachments->addColumn(i18n("Description"), 100); | 82 | attachments->addColumn(i18n("Description"), 100); |
80 | attachments->addColumn(i18n("Filename"), 80); | 83 | attachments->addColumn(i18n("Filename"), 80); |
81 | attachments->addColumn(i18n("Size"), 80); | 84 | attachments->addColumn(i18n("Size"), 80); |
82 | attachments->setSorting(-1); | 85 | attachments->setSorting(-1); |
83 | attachments->hide(); | 86 | attachments->hide(); |
84 | 87 | ||
85 | browser = new QTextBrowser(view); | 88 | browser = new QTextBrowser(view); |
86 | 89 | ||
87 | //openDiag = new OpenDiag(view); | 90 | //openDiag = new OpenDiag(view); |
88 | //openDiag->hide(); | 91 | //openDiag->hide(); |
89 | 92 | ||
90 | } | 93 | } |
91 | 94 | ||
92 | void ViewMailBase::slotChangeAttachview(bool state) | 95 | void ViewMailBase::slotChangeAttachview(bool state) |
93 | { | 96 | { |
94 | if (state) attachments->show(); | 97 | if (state) attachments->show(); |
95 | else attachments->hide(); | 98 | else attachments->hide(); |
96 | } | 99 | } |
97 | 100 | ||
98 | void ViewMailBase::keyPressEvent ( QKeyEvent * e ) | 101 | void ViewMailBase::keyPressEvent ( QKeyEvent * e ) |
99 | { | 102 | { |
100 | if( e->key()==Qt::Key_Escape ) { | 103 | if( e->key()==Qt::Key_Escape ) { |
101 | close(); | 104 | close(); |
102 | e->accept(); | 105 | e->accept(); |
103 | return; | 106 | return; |
104 | } | 107 | } |
105 | QWidget::keyPressEvent(e); | 108 | QWidget::keyPressEvent(e); |
106 | } | 109 | } |
diff --git a/kmicromail/viewmailbase.h b/kmicromail/viewmailbase.h index 7ad1eec..7c075eb 100644 --- a/kmicromail/viewmailbase.h +++ b/kmicromail/viewmailbase.h | |||
@@ -1,39 +1,44 @@ | |||
1 | // CHANGED 2004-08-06 Lutz Rogowski | 1 | // CHANGED 2004-08-06 Lutz Rogowski |
2 | #ifndef VIEWMAILBASE_H | 2 | #ifndef VIEWMAILBASE_H |
3 | #define VIEWMAILBASE_H | 3 | #define VIEWMAILBASE_H |
4 | 4 | ||
5 | #include <qmainwindow.h> | 5 | #include <qmainwindow.h> |
6 | 6 | ||
7 | #ifndef DESKTOP_VERSION | ||
8 | #include <qpe/qpemenubar.h> | ||
9 | #define QMenuBar QPEMenuBar | ||
10 | #endif | ||
11 | |||
7 | class QAction; | 12 | class QAction; |
8 | class OpenDiag; | 13 | class OpenDiag; |
9 | class QListView; | 14 | class QListView; |
10 | class QToolBar; | 15 | class QToolBar; |
11 | class QTextBrowser; | 16 | class QTextBrowser; |
12 | class QMenuBar; | 17 | class QMenuBar; |
13 | class QPopupMenu; | 18 | class QPopupMenu; |
14 | 19 | ||
15 | class ViewMailBase : public QMainWindow | 20 | class ViewMailBase : public QMainWindow |
16 | { | 21 | { |
17 | Q_OBJECT | 22 | Q_OBJECT |
18 | 23 | ||
19 | public: | 24 | public: |
20 | ViewMailBase(QWidget *parent = 0, const char *name = 0, WFlags fl = 0); | 25 | ViewMailBase(QWidget *parent = 0, const char *name = 0, WFlags fl = 0); |
21 | 26 | ||
22 | protected: | 27 | protected: |
23 | QAction *reply, *forward, *attachbutton, *deleteMail, *showHtml, *closeMail, *nextMail, *downloadMail, *viewSource; | 28 | QAction *reply, *forward, *attachbutton, *deleteMail, *showHtml, *closeMail, *nextMail, *downloadMail, *viewSource; |
24 | QListView *attachments; | 29 | QListView *attachments; |
25 | QToolBar *toolbar; | 30 | QToolBar *toolbar; |
26 | QTextBrowser *browser; | 31 | QTextBrowser *browser; |
27 | OpenDiag *openDiag; | 32 | OpenDiag *openDiag; |
28 | QMenuBar *menubar; | 33 | QMenuBar *menubar; |
29 | QPopupMenu *mailmenu; | 34 | QPopupMenu *mailmenu; |
30 | 35 | ||
31 | protected slots: | 36 | protected slots: |
32 | void slotChangeAttachview(bool state); | 37 | void slotChangeAttachview(bool state); |
33 | virtual void keyPressEvent ( QKeyEvent * e ); | 38 | virtual void keyPressEvent ( QKeyEvent * e ); |
34 | 39 | ||
35 | 40 | ||
36 | }; | 41 | }; |
37 | 42 | ||
38 | #endif | 43 | #endif |
39 | 44 | ||