author | alwin <alwin> | 2005-03-06 00:09:33 (UTC) |
---|---|---|
committer | alwin <alwin> | 2005-03-06 00:09:33 (UTC) |
commit | 7e44f77d3749db2f43a1313d835a06684ecc1cd6 (patch) (unidiff) | |
tree | 13499da9a407e9b384db0f3abdd381fe3bb9b6f4 | |
parent | 0baadaef5a3da4fda08df75394475f577af58828 (diff) | |
download | opie-7e44f77d3749db2f43a1313d835a06684ecc1cd6.zip opie-7e44f77d3749db2f43a1313d835a06684ecc1cd6.tar.gz opie-7e44f77d3749db2f43a1313d835a06684ecc1cd6.tar.bz2 |
attached images may views inside the mailview and not as extra dialog
-rw-r--r-- | noncore/net/mail/viewmail.cpp | 46 | ||||
-rw-r--r-- | noncore/net/mail/viewmail.h | 9 | ||||
-rw-r--r-- | noncore/net/mail/viewmailbase.cpp | 26 | ||||
-rw-r--r-- | noncore/net/mail/viewmailbase.h | 2 |
4 files changed, 64 insertions, 19 deletions
diff --git a/noncore/net/mail/viewmail.cpp b/noncore/net/mail/viewmail.cpp index d2f1584..a64a168 100644 --- a/noncore/net/mail/viewmail.cpp +++ b/noncore/net/mail/viewmail.cpp | |||
@@ -1,517 +1,553 @@ | |||
1 | #include "composemail.h" | 1 | #include "composemail.h" |
2 | #include "viewmail.h" | 2 | #include "viewmail.h" |
3 | 3 | ||
4 | #include <libmailwrapper/settings.h> | 4 | #include <libmailwrapper/settings.h> |
5 | #include <libmailwrapper/abstractmail.h> | 5 | #include <libmailwrapper/abstractmail.h> |
6 | #include <libmailwrapper/mailtypes.h> | 6 | #include <libmailwrapper/mailtypes.h> |
7 | 7 | ||
8 | /* OPIE */ | 8 | /* OPIE */ |
9 | #include <opie2/odebug.h> | 9 | #include <opie2/odebug.h> |
10 | #include <opie2/ofiledialog.h> | 10 | #include <opie2/ofiledialog.h> |
11 | #include <opie2/oimagescrollview.h> | 11 | #include <opie2/oimagescrollview.h> |
12 | #include <qpe/config.h> | 12 | #include <qpe/config.h> |
13 | #include <qpe/qpeapplication.h> | 13 | #include <qpe/qpeapplication.h> |
14 | 14 | ||
15 | /* QT */ | 15 | /* QT */ |
16 | #include <qtextbrowser.h> | 16 | #include <qtextbrowser.h> |
17 | #include <qmessagebox.h> | 17 | #include <qmessagebox.h> |
18 | #include <qtextstream.h> | 18 | #include <qtextstream.h> |
19 | #include <qaction.h> | 19 | #include <qaction.h> |
20 | #include <qpopupmenu.h> | 20 | #include <qpopupmenu.h> |
21 | #include <qfile.h> | 21 | #include <qfile.h> |
22 | #include <qlayout.h> | 22 | #include <qlayout.h> |
23 | #include <qstylesheet.h> | 23 | #include <qstylesheet.h> |
24 | 24 | ||
25 | using namespace Opie::Ui; | 25 | using namespace Opie::Ui; |
26 | using namespace Opie::Core; | 26 | using namespace Opie::Core; |
27 | 27 | ||
28 | AttachItem::AttachItem(QListView * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, | 28 | AttachItem::AttachItem(QListView * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, |
29 | const QString&fsize,int num,const QValueList<int>&path) | 29 | const QString&fsize,int num,const QValueList<int>&path) |
30 | : QListViewItem(parent,after),_partNum(num) | 30 | : QListViewItem(parent,after),_partNum(num) |
31 | { | 31 | { |
32 | _path=path; | 32 | _path=path; |
33 | setText(0, mime); | 33 | setText(0, mime); |
34 | setText(1, desc); | 34 | setText(1, desc); |
35 | setText(2, file); | 35 | setText(2, file); |
36 | setText(3, fsize); | 36 | setText(3, fsize); |
37 | } | 37 | } |
38 | 38 | ||
39 | AttachItem::AttachItem(QListViewItem * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, | 39 | AttachItem::AttachItem(QListViewItem * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, |
40 | const QString&fsize,int num,const QValueList<int>&path) | 40 | const QString&fsize,int num,const QValueList<int>&path) |
41 | : QListViewItem(parent,after),_partNum(num) | 41 | : QListViewItem(parent,after),_partNum(num) |
42 | { | 42 | { |
43 | _path=path; | 43 | _path=path; |
44 | setText(0, mime); | 44 | setText(0, mime); |
45 | setText(1, desc); | 45 | setText(1, desc); |
46 | setText(2, file); | 46 | setText(2, file); |
47 | setText(3, fsize); | 47 | setText(3, fsize); |
48 | } | 48 | } |
49 | 49 | ||
50 | bool AttachItem::isParentof(const QValueList<int>&path) | 50 | bool AttachItem::isParentof(const QValueList<int>&path) |
51 | { | 51 | { |
52 | /* if not set, then no parent */ | 52 | /* if not set, then no parent */ |
53 | if (path.count()==0||_path.count()==0) return false; | 53 | if (path.count()==0||_path.count()==0) return false; |
54 | /* the parent must have one digit less then a child */ | 54 | /* the parent must have one digit less then a child */ |
55 | if (path.count()!=_path.count()+1) return false; | 55 | if (path.count()!=_path.count()+1) return false; |
56 | for (unsigned int i=0; i < _path.count();++i) | 56 | for (unsigned int i=0; i < _path.count();++i) |
57 | { | 57 | { |
58 | if (_path[i]!=path[i]) return false; | 58 | if (_path[i]!=path[i]) return false; |
59 | } | 59 | } |
60 | return true; | 60 | return true; |
61 | } | 61 | } |
62 | 62 | ||
63 | AttachItem* ViewMail::searchParent(const QValueList<int>&path) | 63 | AttachItem* ViewMail::searchParent(const QValueList<int>&path) |
64 | { | 64 | { |
65 | QListViewItemIterator it( attachments ); | 65 | QListViewItemIterator it( attachments ); |
66 | for ( ; it.current(); ++it ) | 66 | for ( ; it.current(); ++it ) |
67 | { | 67 | { |
68 | AttachItem*ati = (AttachItem*)it.current(); | 68 | AttachItem*ati = (AttachItem*)it.current(); |
69 | if (ati->isParentof(path)) return ati; | 69 | if (ati->isParentof(path)) return ati; |
70 | } | 70 | } |
71 | return 0; | 71 | return 0; |
72 | } | 72 | } |
73 | 73 | ||
74 | AttachItem* ViewMail::lastChild(AttachItem*parent) | 74 | AttachItem* ViewMail::lastChild(AttachItem*parent) |
75 | { | 75 | { |
76 | if (!parent) return 0; | 76 | if (!parent) return 0; |
77 | AttachItem* item = (AttachItem*)parent->firstChild(); | 77 | AttachItem* item = (AttachItem*)parent->firstChild(); |
78 | if (!item) return item; | 78 | if (!item) return item; |
79 | AttachItem*temp=0; | 79 | AttachItem*temp=0; |
80 | while( (temp=(AttachItem*)item->nextSibling())) | 80 | while( (temp=(AttachItem*)item->nextSibling())) |
81 | { | 81 | { |
82 | item = temp; | 82 | item = temp; |
83 | } | 83 | } |
84 | return item; | 84 | return item; |
85 | } | 85 | } |
86 | 86 | ||
87 | void ViewMail::setBody(const RecBodyP&body ) | 87 | void ViewMail::setBody(const RecBodyP&body ) |
88 | { | 88 | { |
89 | 89 | ||
90 | m_body = body; | 90 | m_body = body; |
91 | m_mail[2] = body->Bodytext(); | 91 | m_mail[2] = body->Bodytext(); |
92 | attachbutton->setEnabled(body->Parts().count()>0); | 92 | attachbutton->setEnabled(body->Parts().count()>0); |
93 | attachments->setEnabled(body->Parts().count()>0); | 93 | attachments->setEnabled(body->Parts().count()>0); |
94 | if (body->Parts().count()==0) | 94 | if (body->Parts().count()==0) |
95 | { | 95 | { |
96 | return; | 96 | return; |
97 | } | 97 | } |
98 | AttachItem * curItem=0; | 98 | AttachItem * curItem=0; |
99 | AttachItem * parentItem = 0; | 99 | AttachItem * parentItem = 0; |
100 | QString type=body->Description()->Type()+"/"+body->Description()->Subtype(); | 100 | QString type=body->Description()->Type()+"/"+body->Description()->Subtype(); |
101 | QString desc,fsize; | 101 | QString desc,fsize; |
102 | double s = body->Description()->Size(); | 102 | double s = body->Description()->Size(); |
103 | int w; | 103 | int w; |
104 | w=0; | 104 | w=0; |
105 | 105 | ||
106 | while (s>1024) | 106 | while (s>1024) |
107 | { | 107 | { |
108 | s/=1024; | 108 | s/=1024; |
109 | ++w; | 109 | ++w; |
110 | if (w>=2) break; | 110 | if (w>=2) break; |
111 | } | 111 | } |
112 | 112 | ||
113 | QString q=""; | 113 | QString q=""; |
114 | switch(w) | 114 | switch(w) |
115 | { | 115 | { |
116 | case 1: | 116 | case 1: |
117 | q="k"; | 117 | q="k"; |
118 | break; | 118 | break; |
119 | case 2: | 119 | case 2: |
120 | q="M"; | 120 | q="M"; |
121 | break; | 121 | break; |
122 | default: | 122 | default: |
123 | break; | 123 | break; |
124 | } | 124 | } |
125 | 125 | ||
126 | { | 126 | { |
127 | /* I did not found a method to make a CONTENT reset on a QTextStream | 127 | /* I did not found a method to make a CONTENT reset on a QTextStream |
128 | so I use this construct that the stream will re-constructed in each | 128 | so I use this construct that the stream will re-constructed in each |
129 | loop. To let it work, the textstream is packed into a own area of | 129 | loop. To let it work, the textstream is packed into a own area of |
130 | code is it will be destructed after finishing its small job. | 130 | code is it will be destructed after finishing its small job. |
131 | */ | 131 | */ |
132 | QTextOStream o(&fsize); | 132 | QTextOStream o(&fsize); |
133 | if (w>0) o.precision(2); else o.precision(0); | 133 | if (w>0) o.precision(2); else o.precision(0); |
134 | o.setf(QTextStream::fixed); | 134 | o.setf(QTextStream::fixed); |
135 | o << s << " " << q << "Byte"; | 135 | o << s << " " << q << "Byte"; |
136 | } | 136 | } |
137 | 137 | ||
138 | curItem=new AttachItem(attachments,curItem,type,"Mailbody","",fsize,-1,body->Description()->Positionlist()); | 138 | curItem=new AttachItem(attachments,curItem,type,"Mailbody","",fsize,-1,body->Description()->Positionlist()); |
139 | QString filename = ""; | 139 | QString filename = ""; |
140 | 140 | ||
141 | for (unsigned int i = 0; i < body->Parts().count();++i) | 141 | for (unsigned int i = 0; i < body->Parts().count();++i) |
142 | { | 142 | { |
143 | filename = ""; | 143 | filename = ""; |
144 | type = body->Parts()[i]->Type()+"/"+body->Parts()[i]->Subtype(); | 144 | type = body->Parts()[i]->Type()+"/"+body->Parts()[i]->Subtype(); |
145 | part_plist_t::ConstIterator it = body->Parts()[i]->Parameters().begin(); | 145 | part_plist_t::ConstIterator it = body->Parts()[i]->Parameters().begin(); |
146 | for (;it!=body->Parts()[i]->Parameters().end();++it) | 146 | for (;it!=body->Parts()[i]->Parameters().end();++it) |
147 | { | 147 | { |
148 | odebug << it.key() << oendl; | 148 | odebug << it.key() << oendl; |
149 | if (it.key().lower()=="name") | 149 | if (it.key().lower()=="name") |
150 | { | 150 | { |
151 | filename=it.data(); | 151 | filename=it.data(); |
152 | } | 152 | } |
153 | } | 153 | } |
154 | s = body->Parts()[i]->Size(); | 154 | s = body->Parts()[i]->Size(); |
155 | w = 0; | 155 | w = 0; |
156 | while (s>1024) | 156 | while (s>1024) |
157 | { | 157 | { |
158 | s/=1024; | 158 | s/=1024; |
159 | ++w; | 159 | ++w; |
160 | if (w>=2) break; | 160 | if (w>=2) break; |
161 | } | 161 | } |
162 | switch(w) | 162 | switch(w) |
163 | { | 163 | { |
164 | case 1: | 164 | case 1: |
165 | q="k"; | 165 | q="k"; |
166 | break; | 166 | break; |
167 | case 2: | 167 | case 2: |
168 | q="M"; | 168 | q="M"; |
169 | break; | 169 | break; |
170 | default: | 170 | default: |
171 | q=""; | 171 | q=""; |
172 | break; | 172 | break; |
173 | } | 173 | } |
174 | QTextOStream o(&fsize); | 174 | QTextOStream o(&fsize); |
175 | if (w>0) o.precision(2); else o.precision(0); | 175 | if (w>0) o.precision(2); else o.precision(0); |
176 | o.setf(QTextStream::fixed); | 176 | o.setf(QTextStream::fixed); |
177 | o << s << " " << q << "Byte"; | 177 | o << s << " " << q << "Byte"; |
178 | desc = body->Parts()[i]->Description(); | 178 | desc = body->Parts()[i]->Description(); |
179 | parentItem = searchParent(body->Parts()[i]->Positionlist()); | 179 | parentItem = searchParent(body->Parts()[i]->Positionlist()); |
180 | if (parentItem) | 180 | if (parentItem) |
181 | { | 181 | { |
182 | AttachItem*temp = lastChild(parentItem); | 182 | AttachItem*temp = lastChild(parentItem); |
183 | if (temp) curItem = temp; | 183 | if (temp) curItem = temp; |
184 | curItem=new AttachItem(parentItem,curItem,type,desc,filename,fsize,i,body->Parts()[i]->Positionlist()); | 184 | curItem=new AttachItem(parentItem,curItem,type,desc,filename,fsize,i,body->Parts()[i]->Positionlist()); |
185 | attachments->setRootIsDecorated(true); | 185 | attachments->setRootIsDecorated(true); |
186 | curItem = parentItem; | 186 | curItem = parentItem; |
187 | } | 187 | } |
188 | else | 188 | else |
189 | { | 189 | { |
190 | curItem=new AttachItem(attachments,curItem,type,desc,filename,fsize,i,body->Parts()[i]->Positionlist()); | 190 | curItem=new AttachItem(attachments,curItem,type,desc,filename,fsize,i,body->Parts()[i]->Positionlist()); |
191 | } | 191 | } |
192 | } | 192 | } |
193 | } | 193 | } |
194 | 194 | ||
195 | 195 | ||
196 | void ViewMail::slotShowHtml( bool state ) | 196 | void ViewMail::slotShowHtml( bool state ) |
197 | { | 197 | { |
198 | m_showHtml = state; | 198 | m_showHtml = state; |
199 | setText(); | 199 | setText(); |
200 | } | 200 | } |
201 | 201 | ||
202 | void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int ) | 202 | void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int ) |
203 | { | 203 | { |
204 | if (!item ) | 204 | if (!item ) |
205 | return; | 205 | return; |
206 | 206 | ||
207 | if ( ( ( AttachItem* )item )->Partnumber() == -1 ) | 207 | if ( ( ( AttachItem* )item )->Partnumber() == -1 ) |
208 | { | 208 | { |
209 | setText(); | 209 | setText(); |
210 | return; | 210 | return; |
211 | } | 211 | } |
212 | QPopupMenu *menu = new QPopupMenu(); | 212 | QPopupMenu *menu = new QPopupMenu(); |
213 | int ret=0; | 213 | int ret=0; |
214 | 214 | ||
215 | if ( item->text( 0 ).left( 5 ) == "text/" || item->text(0)=="message/rfc822" ) | 215 | if ( item->text( 0 ).left( 5 ) == "text/" || item->text(0)=="message/rfc822" ) |
216 | { | 216 | { |
217 | menu->insertItem( tr( "Show Text" ), 1 ); | 217 | menu->insertItem( tr( "Show Text" ), 1 ); |
218 | } | 218 | } |
219 | if (item->text(0).left(6)=="image/") { | 219 | if (item->text(0).left(6)=="image/") { |
220 | menu->insertItem(tr("Display image preview"),2); | 220 | menu->insertItem(tr("Display image preview"),2); |
221 | } | 221 | } |
222 | menu->insertItem( tr( "Save Attachment" ), 0 ); | 222 | menu->insertItem( tr( "Save Attachment" ), 0 ); |
223 | menu->insertSeparator(1); | 223 | menu->insertSeparator(1); |
224 | 224 | ||
225 | ret = menu->exec( point, 0 ); | 225 | ret = menu->exec( point, 0 ); |
226 | 226 | ||
227 | switch(ret) | 227 | switch(ret) |
228 | { | 228 | { |
229 | case 0: | 229 | case 0: |
230 | { | 230 | { |
231 | MimeTypes types; | 231 | MimeTypes types; |
232 | types.insert( "all", "*" ); | 232 | types.insert( "all", "*" ); |
233 | QString str = OFileDialog::getSaveFileName( 1, | 233 | QString str = OFileDialog::getSaveFileName( 1, |
234 | "/", item->text( 2 ) , types, 0 ); | 234 | "/", item->text( 2 ) , types, 0 ); |
235 | 235 | ||
236 | if( !str.isEmpty() ) | 236 | if( !str.isEmpty() ) |
237 | { | 237 | { |
238 | encodedString*content = m_recMail->Wrapper()->fetchDecodedPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ); | 238 | encodedString*content = m_recMail->Wrapper()->fetchDecodedPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ); |
239 | if (content) | 239 | if (content) |
240 | { | 240 | { |
241 | QFile output(str); | 241 | QFile output(str); |
242 | output.open(IO_WriteOnly); | 242 | output.open(IO_WriteOnly); |
243 | output.writeBlock(content->Content(),content->Length()); | 243 | output.writeBlock(content->Content(),content->Length()); |
244 | output.close(); | 244 | output.close(); |
245 | delete content; | 245 | delete content; |
246 | } | 246 | } |
247 | } | 247 | } |
248 | } | 248 | } |
249 | break ; | 249 | break ; |
250 | 250 | ||
251 | case 2: | 251 | case 2: |
252 | { | 252 | { |
253 | QString tmpfile = "/tmp/opiemail-image"; | 253 | QString tmpfile = QString("/tmp/opiemail-image-%1").arg(_icounter++); |
254 | encodedString*content = m_recMail->Wrapper()->fetchDecodedPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ); | 254 | encodedString*content = m_recMail->Wrapper()->fetchDecodedPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ); |
255 | if (content) { | 255 | if (content && content->Length()) { |
256 | QFile output(tmpfile); | 256 | QFile output(tmpfile); |
257 | output.open(IO_WriteOnly); | 257 | output.open(IO_WriteOnly); |
258 | output.writeBlock(content->Content(),content->Length()); | 258 | output.writeBlock(content->Content(),content->Length()); |
259 | output.close(); | 259 | output.close(); |
260 | delete content; | 260 | delete content; |
261 | MailImageDlg iview(""); | 261 | if (!m_PicsInline) { |
262 | iview.setName(tmpfile); | 262 | MailImageDlg iview(""); |
263 | QPEApplication::execDialog(&iview); | 263 | iview.setName(tmpfile); |
264 | QPEApplication::execDialog(&iview); | ||
265 | } else { | ||
266 | if (!m_lastdlg) { | ||
267 | m_lastdlg=new Opie::MM::OImageScrollView("",browser->parentWidget(),false); | ||
268 | m_lastdlg->setAutoScale(true); | ||
269 | } | ||
270 | //m_lastdlg->setImage(""); | ||
271 | m_lastdlg->setImage(tmpfile); | ||
272 | browser->hide(); | ||
273 | m_lastdlg->show(); | ||
274 | } | ||
264 | output.remove(); | 275 | output.remove(); |
276 | } else { | ||
277 | QMessageBox::critical(this, tr("Reading attachment"), tr("Could not read content of attachment")); | ||
265 | } | 278 | } |
266 | } | 279 | } |
267 | break; | 280 | break; |
268 | case 1: | 281 | case 1: |
269 | if ( ( ( AttachItem* )item )->Partnumber() == -1 ) | 282 | if ( ( ( AttachItem* )item )->Partnumber() == -1 ) |
270 | { | 283 | { |
271 | setText(); | 284 | setText(); |
272 | } | 285 | } |
273 | else | 286 | else |
274 | { | 287 | { |
275 | if ( m_recMail->Wrapper() != 0l ) | 288 | if ( m_recMail->Wrapper() != 0l ) |
276 | { // make sure that there is a wrapper , even after delete or simular actions | 289 | { // make sure that there is a wrapper , even after delete or simular actions |
277 | browser->setText( m_recMail->Wrapper()->fetchTextPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ) ); | 290 | browser->setText( m_recMail->Wrapper()->fetchTextPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ) ); |
278 | } | 291 | } |
279 | } | 292 | } |
280 | break; | 293 | break; |
281 | } | 294 | } |
282 | delete menu; | 295 | delete menu; |
283 | } | 296 | } |
284 | 297 | ||
285 | 298 | ||
286 | void ViewMail::setMail(const RecMailP&mail ) | 299 | void ViewMail::setMail(const RecMailP&mail ) |
287 | { | 300 | { |
288 | 301 | ||
289 | m_recMail = mail; | 302 | m_recMail = mail; |
290 | 303 | ||
291 | m_mail[0] = mail->getFrom(); | 304 | m_mail[0] = mail->getFrom(); |
292 | m_mail[1] = mail->getSubject(); | 305 | m_mail[1] = mail->getSubject(); |
293 | m_mail[3] = mail->getStringDate(); | 306 | m_mail[3] = mail->getStringDate(); |
294 | m_mail[4] = mail->Msgid(); | 307 | m_mail[4] = mail->Msgid(); |
295 | 308 | ||
296 | m_mail2[0] = mail->To(); | 309 | m_mail2[0] = mail->To(); |
297 | m_mail2[1] = mail->CC(); | 310 | m_mail2[1] = mail->CC(); |
298 | m_mail2[2] = mail->Bcc(); | 311 | m_mail2[2] = mail->Bcc(); |
299 | 312 | ||
300 | setCaption(tr("E-Mail by %1").arg( m_mail[0] ) ); | 313 | setCaption(tr("E-Mail by %1").arg( m_mail[0] ) ); |
301 | setText(); | 314 | setText(); |
302 | } | 315 | } |
303 | 316 | ||
304 | 317 | ||
305 | 318 | ||
306 | ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl) | 319 | ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl) |
307 | : ViewMailBase(parent, name, fl), _inLoop(false) | 320 | : ViewMailBase(parent, name, fl), _inLoop(false) |
308 | { | 321 | { |
309 | m_gotBody = false; | 322 | m_gotBody = false; |
310 | deleted = false; | 323 | deleted = false; |
311 | 324 | ||
312 | connect( reply, SIGNAL(activated()), SLOT(slotReply())); | 325 | connect( reply, SIGNAL(activated()), SLOT(slotReply())); |
313 | connect( forward, SIGNAL(activated()), SLOT(slotForward())); | 326 | connect( forward, SIGNAL(activated()), SLOT(slotForward())); |
314 | connect( deleteMail, SIGNAL( activated() ), SLOT( slotDeleteMail() ) ); | 327 | connect( deleteMail, SIGNAL( activated() ), SLOT( slotDeleteMail() ) ); |
315 | connect( showHtml, SIGNAL( toggled(bool) ), SLOT( slotShowHtml(bool) ) ); | 328 | connect( showHtml, SIGNAL( toggled(bool) ), SLOT( slotShowHtml(bool) ) ); |
329 | connect( showPicsInline, SIGNAL( toggled(bool) ), SLOT( slotImageInline(bool) ) ); | ||
316 | 330 | ||
317 | attachments->setEnabled(m_gotBody); | 331 | attachments->setEnabled(m_gotBody); |
318 | connect( attachments, SIGNAL( clicked(QListViewItem*,const QPoint&, int) ), SLOT( slotItemClicked(QListViewItem*,const QPoint&, int) ) ); | 332 | connect( attachments, SIGNAL( clicked(QListViewItem*,const QPoint&, int) ), SLOT( slotItemClicked(QListViewItem*,const QPoint&, int) ) ); |
333 | m_lastdlg = 0; | ||
334 | _icounter = 0; | ||
319 | 335 | ||
320 | readConfig(); | 336 | readConfig(); |
321 | attachments->setSorting(-1); | 337 | attachments->setSorting(-1); |
322 | } | 338 | } |
323 | 339 | ||
340 | void ViewMail::slotImageInline(bool how) | ||
341 | { | ||
342 | Config cfg( "mail" ); | ||
343 | cfg.writeEntry( "showPicsInline", how); | ||
344 | m_PicsInline = how; | ||
345 | if (m_lastdlg&&!how) { | ||
346 | browser->show(); | ||
347 | m_lastdlg->hide(); | ||
348 | m_lastdlg->reparent(0,QPoint(0,0),false); | ||
349 | delete m_lastdlg; | ||
350 | m_lastdlg = 0; | ||
351 | } | ||
352 | } | ||
353 | |||
324 | void ViewMail::readConfig() | 354 | void ViewMail::readConfig() |
325 | { | 355 | { |
326 | Config cfg( "mail" ); | 356 | Config cfg( "mail" ); |
327 | cfg.setGroup( "Settings" ); | 357 | cfg.setGroup( "Settings" ); |
328 | m_showHtml = cfg.readBoolEntry( "showHtml", false ); | 358 | m_showHtml = cfg.readBoolEntry( "showHtml", false ); |
359 | m_PicsInline = cfg.readBoolEntry( "showPicsInline", true ); | ||
360 | showPicsInline->setOn(m_PicsInline); | ||
329 | showHtml->setOn( m_showHtml ); | 361 | showHtml->setOn( m_showHtml ); |
330 | } | 362 | } |
331 | 363 | ||
332 | void ViewMail::setText() | 364 | void ViewMail::setText() |
333 | { | 365 | { |
334 | QString toString; | 366 | QString toString; |
335 | QString ccString; | 367 | QString ccString; |
336 | QString bccString; | 368 | QString bccString; |
337 | QString mailHtml; | 369 | QString mailHtml; |
338 | 370 | ||
371 | if (m_lastdlg) { | ||
372 | m_lastdlg->hide(); | ||
373 | } | ||
374 | browser->show(); | ||
339 | for ( QStringList::Iterator it = ( m_mail2[0] ).begin(); it != ( m_mail2[0] ).end(); ++it ) | 375 | for ( QStringList::Iterator it = ( m_mail2[0] ).begin(); it != ( m_mail2[0] ).end(); ++it ) |
340 | { | 376 | { |
341 | toString += (*it); | 377 | toString += (*it); |
342 | } | 378 | } |
343 | for ( QStringList::Iterator it = ( m_mail2[1] ).begin(); it != ( m_mail2[1] ).end(); ++it ) | 379 | for ( QStringList::Iterator it = ( m_mail2[1] ).begin(); it != ( m_mail2[1] ).end(); ++it ) |
344 | { | 380 | { |
345 | ccString += (*it); | 381 | ccString += (*it); |
346 | } | 382 | } |
347 | for ( QStringList::Iterator it = ( m_mail2[2] ).begin(); it != ( m_mail2[2] ).end(); ++it ) | 383 | for ( QStringList::Iterator it = ( m_mail2[2] ).begin(); it != ( m_mail2[2] ).end(); ++it ) |
348 | { | 384 | { |
349 | bccString += (*it); | 385 | bccString += (*it); |
350 | } | 386 | } |
351 | browser->setTextFormat(Qt::RichText); | 387 | browser->setTextFormat(Qt::RichText); |
352 | mailHtml = "<html><body>" | 388 | mailHtml = "<html><body>" |
353 | "<table width=\"100%\" border=\"0\"><tr bgcolor=\"#FFDD76\"><td>" | 389 | "<table width=\"100%\" border=\"0\"><tr bgcolor=\"#FFDD76\"><td>" |
354 | "<div align=left><b>" + deHtml(m_mail[1]) + "</b></div>" | 390 | "<div align=left><b>" + deHtml(m_mail[1]) + "</b></div>" |
355 | "</td></tr><tr bgcolor=\"#EEEEE6\"><td>" | 391 | "</td></tr><tr bgcolor=\"#EEEEE6\"><td>" |
356 | "<b>" + tr( "From" ) + ": </b><font color=#6C86C0>" + deHtml( m_mail[0] ) + "</font><br>" | 392 | "<b>" + tr( "From" ) + ": </b><font color=#6C86C0>" + deHtml( m_mail[0] ) + "</font><br>" |
357 | "<b>" + tr( "To" ) + ": </b><font color=#6C86C0>" + deHtml( toString ) + "</font><br><b>" + | 393 | "<b>" + tr( "To" ) + ": </b><font color=#6C86C0>" + deHtml( toString ) + "</font><br><b>" + |
358 | tr( "Cc" ) + ": </b>" + deHtml( ccString ) + "<br>" | 394 | tr( "Cc" ) + ": </b>" + deHtml( ccString ) + "<br>" |
359 | "<b>" + tr( "Date" ) + ": </b> " + m_mail[3] + | 395 | "<b>" + tr( "Date" ) + ": </b> " + m_mail[3] + |
360 | "</td></tr></table>"; | 396 | "</td></tr></table>"; |
361 | if ( !m_showHtml ) { | 397 | if ( !m_showHtml ) { |
362 | browser->setText( mailHtml+"<font face=fixed>" + QStyleSheet::convertFromPlainText(m_mail[2]) + "</font></body></html>" ); | 398 | browser->setText( mailHtml+"<font face=fixed>" + QStyleSheet::convertFromPlainText(m_mail[2]) + "</font></body></html>" ); |
363 | } else { | 399 | } else { |
364 | browser->setText(mailHtml+m_mail[2].simplifyWhiteSpace()+"</html>"); | 400 | browser->setText(mailHtml+m_mail[2].simplifyWhiteSpace()+"</html>"); |
365 | } | 401 | } |
366 | // remove later in favor of a real handling | 402 | // remove later in favor of a real handling |
367 | m_gotBody = true; | 403 | m_gotBody = true; |
368 | } | 404 | } |
369 | 405 | ||
370 | 406 | ||
371 | ViewMail::~ViewMail() | 407 | ViewMail::~ViewMail() |
372 | { | 408 | { |
373 | m_recMail->Wrapper()->cleanMimeCache(); | 409 | m_recMail->Wrapper()->cleanMimeCache(); |
374 | hide(); | 410 | hide(); |
375 | } | 411 | } |
376 | 412 | ||
377 | void ViewMail::hide() | 413 | void ViewMail::hide() |
378 | { | 414 | { |
379 | QWidget::hide(); | 415 | QWidget::hide(); |
380 | 416 | ||
381 | if (_inLoop) | 417 | if (_inLoop) |
382 | { | 418 | { |
383 | _inLoop = false; | 419 | _inLoop = false; |
384 | qApp->exit_loop(); | 420 | qApp->exit_loop(); |
385 | 421 | ||
386 | } | 422 | } |
387 | 423 | ||
388 | } | 424 | } |
389 | 425 | ||
390 | void ViewMail::exec() | 426 | void ViewMail::exec() |
391 | { | 427 | { |
392 | show(); | 428 | show(); |
393 | 429 | ||
394 | if (!_inLoop) | 430 | if (!_inLoop) |
395 | { | 431 | { |
396 | _inLoop = true; | 432 | _inLoop = true; |
397 | qApp->enter_loop(); | 433 | qApp->enter_loop(); |
398 | } | 434 | } |
399 | 435 | ||
400 | } | 436 | } |
401 | 437 | ||
402 | QString ViewMail::deHtml(const QString &aString) | 438 | QString ViewMail::deHtml(const QString &aString) |
403 | { | 439 | { |
404 | QString string_ = aString; | 440 | QString string_ = aString; |
405 | string_.replace(QRegExp("&"), "&"); | 441 | string_.replace(QRegExp("&"), "&"); |
406 | string_.replace(QRegExp("<"), "<"); | 442 | string_.replace(QRegExp("<"), "<"); |
407 | string_.replace(QRegExp(">"), ">"); | 443 | string_.replace(QRegExp(">"), ">"); |
408 | string_.replace(QRegExp("\\n"), "<br>"); | 444 | string_.replace(QRegExp("\\n"), "<br>"); |
409 | return string_; | 445 | return string_; |
410 | } | 446 | } |
411 | 447 | ||
412 | void ViewMail::slotReply() | 448 | void ViewMail::slotReply() |
413 | { | 449 | { |
414 | if (!m_gotBody) | 450 | if (!m_gotBody) |
415 | { | 451 | { |
416 | QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot reply yet."), tr("Ok")); | 452 | QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot reply yet."), tr("Ok")); |
417 | return; | 453 | return; |
418 | } | 454 | } |
419 | 455 | ||
420 | QString rtext; | 456 | QString rtext; |
421 | rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose | 457 | rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose |
422 | .arg( m_mail[0] ) | 458 | .arg( m_mail[0] ) |
423 | .arg( m_mail[3] ); | 459 | .arg( m_mail[3] ); |
424 | 460 | ||
425 | QString text = m_mail[2]; | 461 | QString text = m_mail[2]; |
426 | QStringList lines = QStringList::split(QRegExp("\\n"), text); | 462 | QStringList lines = QStringList::split(QRegExp("\\n"), text); |
427 | QStringList::Iterator it; | 463 | QStringList::Iterator it; |
428 | for (it = lines.begin(); it != lines.end(); it++) | 464 | for (it = lines.begin(); it != lines.end(); it++) |
429 | { | 465 | { |
430 | rtext += "> " + *it + "\n"; | 466 | rtext += "> " + *it + "\n"; |
431 | } | 467 | } |
432 | rtext += "\n"; | 468 | rtext += "\n"; |
433 | 469 | ||
434 | QString prefix; | 470 | QString prefix; |
435 | if ( m_mail[1].find(QRegExp("^Re: .*$")) != -1) prefix = ""; | 471 | if ( m_mail[1].find(QRegExp("^Re: .*$")) != -1) prefix = ""; |
436 | else prefix = "Re: "; // no i18n on purpose | 472 | else prefix = "Re: "; // no i18n on purpose |
437 | 473 | ||
438 | Settings *settings = new Settings(); | 474 | Settings *settings = new Settings(); |
439 | ComposeMail composer( settings ,this, 0, true); | 475 | ComposeMail composer( settings ,this, 0, true); |
440 | if (m_recMail->Replyto().isEmpty()) { | 476 | if (m_recMail->Replyto().isEmpty()) { |
441 | composer.setTo( m_recMail->getFrom()); | 477 | composer.setTo( m_recMail->getFrom()); |
442 | } else { | 478 | } else { |
443 | composer.setTo( m_recMail->Replyto()); | 479 | composer.setTo( m_recMail->Replyto()); |
444 | } | 480 | } |
445 | composer.setSubject( prefix + m_mail[1] ); | 481 | composer.setSubject( prefix + m_mail[1] ); |
446 | composer.setMessage( rtext ); | 482 | composer.setMessage( rtext ); |
447 | composer.setInReplyTo(m_recMail->Msgid()); | 483 | composer.setInReplyTo(m_recMail->Msgid()); |
448 | 484 | ||
449 | if ( QDialog::Accepted == QPEApplication::execDialog( &composer ) ) | 485 | if ( QDialog::Accepted == QPEApplication::execDialog( &composer ) ) |
450 | { | 486 | { |
451 | m_recMail->Wrapper()->answeredMail(m_recMail); | 487 | m_recMail->Wrapper()->answeredMail(m_recMail); |
452 | } | 488 | } |
453 | } | 489 | } |
454 | 490 | ||
455 | void ViewMail::slotForward() | 491 | void ViewMail::slotForward() |
456 | { | 492 | { |
457 | if (!m_gotBody) | 493 | if (!m_gotBody) |
458 | { | 494 | { |
459 | QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot forward yet."), tr("Ok")); | 495 | QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot forward yet."), tr("Ok")); |
460 | return; | 496 | return; |
461 | } | 497 | } |
462 | 498 | ||
463 | QString ftext; | 499 | QString ftext; |
464 | ftext += QString("\n----- Forwarded message from %1 -----\n\n") | 500 | ftext += QString("\n----- Forwarded message from %1 -----\n\n") |
465 | .arg( m_mail[0] ); | 501 | .arg( m_mail[0] ); |
466 | if (!m_mail[3].isNull()) | 502 | if (!m_mail[3].isNull()) |
467 | ftext += QString("Date: %1\n") | 503 | ftext += QString("Date: %1\n") |
468 | .arg( m_mail[3] ); | 504 | .arg( m_mail[3] ); |
469 | if (!m_mail[0].isNull()) | 505 | if (!m_mail[0].isNull()) |
470 | ftext += QString("From: %1\n") | 506 | ftext += QString("From: %1\n") |
471 | .arg( m_mail[0] ); | 507 | .arg( m_mail[0] ); |
472 | if (!m_mail[1].isNull()) | 508 | if (!m_mail[1].isNull()) |
473 | ftext += QString("Subject: %1\n") | 509 | ftext += QString("Subject: %1\n") |
474 | .arg( m_mail[1] ); | 510 | .arg( m_mail[1] ); |
475 | 511 | ||
476 | ftext += QString("\n%1\n") | 512 | ftext += QString("\n%1\n") |
477 | .arg( m_mail[2]); | 513 | .arg( m_mail[2]); |
478 | 514 | ||
479 | ftext += QString("----- End forwarded message -----\n"); | 515 | ftext += QString("----- End forwarded message -----\n"); |
480 | 516 | ||
481 | Settings *settings = new Settings(); | 517 | Settings *settings = new Settings(); |
482 | ComposeMail composer( settings ,this, 0, true); | 518 | ComposeMail composer( settings ,this, 0, true); |
483 | composer.setSubject( "Fwd: " + m_mail[1] ); | 519 | composer.setSubject( "Fwd: " + m_mail[1] ); |
484 | composer.setMessage( ftext ); | 520 | composer.setMessage( ftext ); |
485 | if ( QDialog::Accepted == QPEApplication::execDialog( &composer )) | 521 | if ( QDialog::Accepted == QPEApplication::execDialog( &composer )) |
486 | { | 522 | { |
487 | } | 523 | } |
488 | } | 524 | } |
489 | 525 | ||
490 | void ViewMail::slotDeleteMail( ) | 526 | void ViewMail::slotDeleteMail( ) |
491 | { | 527 | { |
492 | if ( QMessageBox::warning(this, tr("Delete Mail"), QString( tr("<p>Do you really want to delete this mail? <br><br>" ) + m_mail[0] + " - " + m_mail[1] ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) | 528 | if ( QMessageBox::warning(this, tr("Delete Mail"), QString( tr("<p>Do you really want to delete this mail? <br><br>" ) + m_mail[0] + " - " + m_mail[1] ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) |
493 | { | 529 | { |
494 | m_recMail->Wrapper()->deleteMail( m_recMail ); | 530 | m_recMail->Wrapper()->deleteMail( m_recMail ); |
495 | hide(); | 531 | hide(); |
496 | deleted = true; | 532 | deleted = true; |
497 | } | 533 | } |
498 | } | 534 | } |
499 | 535 | ||
500 | MailImageDlg::MailImageDlg(const QString&fname,QWidget *parent, const char *name, bool modal, WFlags f) | 536 | MailImageDlg::MailImageDlg(const QString&fname,QWidget *parent, const char *name, bool modal, WFlags f) |
501 | : Opie::Ui::ODialog(parent,name,modal,f) | 537 | : Opie::Ui::ODialog(parent,name,modal,f) |
502 | { | 538 | { |
503 | QVBoxLayout*dlglayout = new QVBoxLayout(this); | 539 | QVBoxLayout*dlglayout = new QVBoxLayout(this); |
504 | dlglayout->setSpacing(2); | 540 | dlglayout->setSpacing(2); |
505 | dlglayout->setMargin(1); | 541 | dlglayout->setMargin(1); |
506 | m_imageview = new Opie::MM::OImageScrollView(this); | 542 | m_imageview = new Opie::MM::OImageScrollView(this); |
507 | dlglayout->addWidget(m_imageview); | 543 | dlglayout->addWidget(m_imageview); |
508 | } | 544 | } |
509 | 545 | ||
510 | MailImageDlg::~MailImageDlg() | 546 | MailImageDlg::~MailImageDlg() |
511 | { | 547 | { |
512 | } | 548 | } |
513 | 549 | ||
514 | void MailImageDlg::setName(const QString&fname) | 550 | void MailImageDlg::setName(const QString&fname) |
515 | { | 551 | { |
516 | m_imageview->setImage(fname); | 552 | m_imageview->setImage(fname); |
517 | } | 553 | } |
diff --git a/noncore/net/mail/viewmail.h b/noncore/net/mail/viewmail.h index 297836b..f5033f0 100644 --- a/noncore/net/mail/viewmail.h +++ b/noncore/net/mail/viewmail.h | |||
@@ -1,86 +1,93 @@ | |||
1 | #ifndef VIEWMAIL_H | 1 | #ifndef VIEWMAIL_H |
2 | #define VIEWMAIL_H | 2 | #define VIEWMAIL_H |
3 | 3 | ||
4 | #include "viewmailbase.h" | 4 | #include "viewmailbase.h" |
5 | #include <libmailwrapper/mailtypes.h> | 5 | #include <libmailwrapper/mailtypes.h> |
6 | 6 | ||
7 | #include <opie2/odialog.h> | 7 | #include <opie2/odialog.h> |
8 | 8 | ||
9 | #include <qlistview.h> | 9 | #include <qlistview.h> |
10 | #include <qmap.h> | 10 | #include <qmap.h> |
11 | #include <qstringlist.h> | 11 | #include <qstringlist.h> |
12 | #include <qvaluelist.h> | 12 | #include <qvaluelist.h> |
13 | 13 | ||
14 | class MailImageDlg; | ||
15 | |||
14 | namespace Opie { namespace MM { class OImageScrollView; } } | 16 | namespace Opie { namespace MM { class OImageScrollView; } } |
15 | 17 | ||
16 | class AttachItem : public QListViewItem | 18 | class AttachItem : public QListViewItem |
17 | { | 19 | { |
18 | public: | 20 | public: |
19 | AttachItem(QListView * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, | 21 | AttachItem(QListView * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, |
20 | const QString&fsize,int num,const QValueList<int>&path); | 22 | const QString&fsize,int num,const QValueList<int>&path); |
21 | AttachItem(QListViewItem * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, | 23 | AttachItem(QListViewItem * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, |
22 | const QString&fsize,int num,const QValueList<int>&path); | 24 | const QString&fsize,int num,const QValueList<int>&path); |
23 | int Partnumber() { return _partNum; } | 25 | int Partnumber() { return _partNum; } |
24 | bool isParentof(const QValueList<int>&path); | 26 | bool isParentof(const QValueList<int>&path); |
25 | 27 | ||
26 | private: | 28 | private: |
27 | int _partNum; | 29 | int _partNum; |
28 | /* needed for a better display of attachments */ | 30 | /* needed for a better display of attachments */ |
29 | QValueList<int> _path; | 31 | QValueList<int> _path; |
30 | }; | 32 | }; |
31 | 33 | ||
32 | class ViewMail : public ViewMailBase | 34 | class ViewMail : public ViewMailBase |
33 | { | 35 | { |
34 | Q_OBJECT | 36 | Q_OBJECT |
35 | 37 | ||
36 | public: | 38 | public: |
37 | ViewMail( QWidget *parent = 0, const char *name = 0, WFlags fl = 0); | 39 | ViewMail( QWidget *parent = 0, const char *name = 0, WFlags fl = 0); |
38 | ~ViewMail(); | 40 | ~ViewMail(); |
39 | 41 | ||
40 | void hide(); | 42 | void hide(); |
41 | void exec(); | 43 | void exec(); |
42 | void setMail(const RecMailP&mail ); | 44 | void setMail(const RecMailP&mail ); |
43 | void setBody(const RecBodyP&body); | 45 | void setBody(const RecBodyP&body); |
44 | bool deleted; | 46 | bool deleted; |
45 | 47 | ||
46 | protected: | 48 | protected: |
47 | QString deHtml(const QString &string); | 49 | QString deHtml(const QString &string); |
48 | AttachItem* searchParent(const QValueList<int>&path); | 50 | AttachItem* searchParent(const QValueList<int>&path); |
49 | AttachItem* lastChild(AttachItem*parent); | 51 | AttachItem* lastChild(AttachItem*parent); |
50 | 52 | ||
53 | Opie::MM::OImageScrollView*m_lastdlg; | ||
54 | |||
51 | protected slots: | 55 | protected slots: |
52 | void slotReply(); | 56 | void slotReply(); |
53 | void slotForward(); | 57 | void slotForward(); |
54 | void setText(); | 58 | void setText(); |
55 | void slotItemClicked( QListViewItem * item , const QPoint & point, int c ); | 59 | void slotItemClicked( QListViewItem * item , const QPoint & point, int c ); |
56 | void slotDeleteMail( ); | 60 | void slotDeleteMail( ); |
57 | void slotShowHtml( bool ); | 61 | void slotShowHtml( bool ); |
62 | void slotImageInline(bool); | ||
58 | 63 | ||
59 | private: | 64 | private: |
60 | void readConfig(); | 65 | void readConfig(); |
61 | 66 | ||
62 | bool _inLoop; | 67 | bool _inLoop; |
63 | QString m_mailHtml; | 68 | QString m_mailHtml; |
64 | bool m_gotBody; | 69 | bool m_gotBody; |
65 | RecBodyP m_body; | 70 | RecBodyP m_body; |
66 | RecMailP m_recMail; | 71 | RecMailP m_recMail; |
67 | bool m_showHtml; | 72 | bool m_showHtml:1; |
73 | bool m_PicsInline:1; | ||
74 | unsigned int _icounter; | ||
68 | 75 | ||
69 | // 0 from 1 subject 2 bodytext 3 date | 76 | // 0 from 1 subject 2 bodytext 3 date |
70 | QMap <int,QString> m_mail; | 77 | QMap <int,QString> m_mail; |
71 | // 0 to 1 cc 2 bcc | 78 | // 0 to 1 cc 2 bcc |
72 | QMap <int,QStringList> m_mail2; | 79 | QMap <int,QStringList> m_mail2; |
73 | }; | 80 | }; |
74 | 81 | ||
75 | class MailImageDlg:public Opie::Ui::ODialog | 82 | class MailImageDlg:public Opie::Ui::ODialog |
76 | { | 83 | { |
77 | Q_OBJECT | 84 | Q_OBJECT |
78 | public: | 85 | public: |
79 | MailImageDlg(const QString&,QWidget *parent = 0, const char *name = 0, bool modal = true, WFlags f = 0); | 86 | MailImageDlg(const QString&,QWidget *parent = 0, const char *name = 0, bool modal = true, WFlags f = 0); |
80 | ~MailImageDlg(); | 87 | ~MailImageDlg(); |
81 | void setName(const QString&); | 88 | void setName(const QString&); |
82 | protected: | 89 | protected: |
83 | Opie::MM::OImageScrollView*m_imageview; | 90 | Opie::MM::OImageScrollView*m_imageview; |
84 | }; | 91 | }; |
85 | 92 | ||
86 | #endif | 93 | #endif |
diff --git a/noncore/net/mail/viewmailbase.cpp b/noncore/net/mail/viewmailbase.cpp index 49a0e6a..65ad0d6 100644 --- a/noncore/net/mail/viewmailbase.cpp +++ b/noncore/net/mail/viewmailbase.cpp | |||
@@ -1,90 +1,92 @@ | |||
1 | #include <qtextbrowser.h> | 1 | #include <qtextbrowser.h> |
2 | #include <qlistview.h> | 2 | #include <qlistview.h> |
3 | #include <qaction.h> | 3 | #include <qaction.h> |
4 | #include <qlabel.h> | 4 | #include <qlabel.h> |
5 | #include <qvbox.h> | 5 | #include <qvbox.h> |
6 | 6 | ||
7 | #include <qtoolbar.h> | 7 | #include <qtoolbar.h> |
8 | #include <qlayout.h> | ||
8 | #include <qmenubar.h> | 9 | #include <qmenubar.h> |
9 | #include <qpe/resource.h> | 10 | #include <qpe/resource.h> |
10 | 11 | ||
11 | #include "viewmailbase.h" | 12 | #include "viewmailbase.h" |
12 | //#include "opendiag.h" | 13 | //#include "opendiag.h" |
13 | 14 | ||
14 | ViewMailBase::ViewMailBase(QWidget *parent, const char *name, WFlags fl) | 15 | ViewMailBase::ViewMailBase(QWidget *parent, const char *name, WFlags fl) |
15 | : QMainWindow(parent, name, fl) | 16 | : QMainWindow(parent, name, fl) |
16 | { | 17 | { |
17 | setCaption(tr("E-Mail view")); | 18 | setCaption(tr("E-Mail view")); |
18 | setToolBarsMovable(false); | 19 | setToolBarsMovable(false); |
19 | 20 | ||
20 | toolbar = new QToolBar(this); | 21 | toolbar = new QToolBar(this); |
21 | menubar = new QMenuBar( toolbar ); | 22 | menubar = new QMenuBar( toolbar ); |
22 | mailmenu = new QPopupMenu( menubar ); | 23 | mailmenu = new QPopupMenu( menubar ); |
23 | menubar->insertItem( tr( "Mail" ), mailmenu ); | 24 | menubar->insertItem( tr( "Mail" ), mailmenu ); |
24 | |||
25 | toolbar->setHorizontalStretchable(true); | 25 | toolbar->setHorizontalStretchable(true); |
26 | addToolBar(toolbar); | 26 | addToolBar(toolbar); |
27 | |||
28 | QLabel *spacer = new QLabel(toolbar); | 27 | QLabel *spacer = new QLabel(toolbar); |
29 | spacer->setBackgroundMode(QWidget::PaletteButton); | 28 | spacer->setBackgroundMode(QWidget::PaletteButton); |
30 | toolbar->setStretchableWidget(spacer); | 29 | toolbar->setStretchableWidget(spacer); |
31 | 30 | ||
32 | reply = new QAction(tr("Reply"), QIconSet(Resource::loadPixmap("mail/reply")), 0, 0, this); | 31 | reply = new QAction(tr("Reply"), QIconSet(Resource::loadPixmap("mail/reply")), 0, 0, this); |
33 | reply->addTo(toolbar); | 32 | reply->addTo(toolbar); |
34 | reply->addTo(mailmenu); | 33 | reply->addTo(mailmenu); |
35 | 34 | ||
36 | forward = new QAction(tr("Forward"), QIconSet(Resource::loadPixmap("mail/forward")), 0, 0, this); | 35 | forward = new QAction(tr("Forward"), QIconSet(Resource::loadPixmap("mail/forward")), 0, 0, this); |
37 | forward->addTo(toolbar); | 36 | forward->addTo(toolbar); |
38 | forward->addTo(mailmenu); | 37 | forward->addTo(mailmenu); |
39 | 38 | ||
40 | attachbutton = new QAction(tr("Attachments"), QIconSet(Resource::loadPixmap("mail/attach")), 0, 0, this, 0, true); | 39 | attachbutton = new QAction(tr("Attachments"), QIconSet(Resource::loadPixmap("mail/attach")), 0, 0, this, 0, true); |
41 | attachbutton->addTo(toolbar); | 40 | attachbutton->addTo(toolbar); |
42 | attachbutton->addTo(mailmenu); | 41 | attachbutton->addTo(mailmenu); |
43 | connect(attachbutton, SIGNAL(toggled(bool)), SLOT(slotChangeAttachview(bool))); | 42 | connect(attachbutton, SIGNAL(toggled(bool)), SLOT(slotChangeAttachview(bool))); |
44 | 43 | ||
45 | 44 | ||
46 | showHtml = new QAction( tr( "Show Html" ), QIconSet( Resource::loadPixmap( "mail/html" ) ), 0, 0, this, 0, true ); | 45 | showHtml = new QAction( tr( "Show Html" ), QIconSet( Resource::loadPixmap( "mail/html" ) ), 0, 0, this, 0, true ); |
47 | showHtml->addTo( toolbar ); | 46 | showHtml->addTo( toolbar ); |
48 | showHtml->addTo( mailmenu ); | 47 | showHtml->addTo( mailmenu ); |
48 | |||
49 | showPicsInline= new QAction(tr("Show image preview inline"), QIconSet(Resource::loadPixmap("pixmap")), 0, 0, this); | ||
50 | showPicsInline->setToggleAction(true); | ||
51 | showPicsInline->addTo(toolbar); | ||
52 | showPicsInline->addTo(mailmenu); | ||
49 | 53 | ||
50 | deleteMail = new QAction(tr("Delete Mail"), QIconSet(Resource::loadPixmap("trash")), 0, 0, this); | 54 | deleteMail = new QAction(tr("Delete Mail"), QIconSet(Resource::loadPixmap("trash")), 0, 0, this); |
51 | deleteMail->addTo(toolbar); | 55 | deleteMail->addTo(toolbar); |
52 | deleteMail->addTo(mailmenu); | 56 | deleteMail->addTo(mailmenu); |
53 | 57 | ||
54 | QVBox *view = new QVBox(this); | 58 | QVBox * view = new QVBox(this); |
59 | view->setSpacing(1); | ||
60 | view->setMargin(0); | ||
55 | setCentralWidget(view); | 61 | setCentralWidget(view); |
56 | 62 | ||
57 | attachments = new QListView(view); | 63 | attachments = new QListView(view); |
58 | attachments->setMinimumHeight(90); | 64 | attachments->setMinimumHeight(90); |
59 | attachments->setMaximumHeight(90); | 65 | attachments->setMaximumHeight(90); |
60 | attachments->setAllColumnsShowFocus(true); | 66 | attachments->setAllColumnsShowFocus(true); |
61 | attachments->addColumn("Mime Type", 60); | 67 | attachments->addColumn("Mime Type", 60); |
62 | attachments->addColumn(tr("Description"), 100); | 68 | attachments->addColumn(tr("Description"), 100); |
63 | attachments->addColumn(tr("Filename"), 80); | 69 | attachments->addColumn(tr("Filename"), 80); |
64 | attachments->addColumn(tr("Size"), 80); | 70 | attachments->addColumn(tr("Size"), 80); |
65 | attachments->setSorting(-1); | 71 | attachments->setSorting(-1); |
66 | attachments->hide(); | ||
67 | 72 | ||
68 | //header = new QTextBrowser(view); | ||
69 | browser = new QTextBrowser(view); | 73 | browser = new QTextBrowser(view); |
70 | 74 | adjustSize(); | |
71 | // openDiag = new OpenDiag(view); | 75 | attachments->hide(); |
72 | // openDiag->hide(); | ||
73 | |||
74 | } | 76 | } |
75 | 77 | ||
76 | void ViewMailBase::slotChangeAttachview(bool state) | 78 | void ViewMailBase::slotChangeAttachview(bool state) |
77 | { | 79 | { |
78 | if (state) attachments->show(); | 80 | if (state) attachments->show(); |
79 | else attachments->hide(); | 81 | else attachments->hide(); |
80 | } | 82 | } |
81 | 83 | ||
82 | void ViewMailBase::keyPressEvent ( QKeyEvent * e ) | 84 | void ViewMailBase::keyPressEvent ( QKeyEvent * e ) |
83 | { | 85 | { |
84 | if( e->key()==Qt::Key_Escape ) { | 86 | if( e->key()==Qt::Key_Escape ) { |
85 | close(); | 87 | close(); |
86 | e->accept(); | 88 | e->accept(); |
87 | return; | 89 | return; |
88 | } | 90 | } |
89 | QWidget::keyPressEvent(e); | 91 | QWidget::keyPressEvent(e); |
90 | } | 92 | } |
diff --git a/noncore/net/mail/viewmailbase.h b/noncore/net/mail/viewmailbase.h index 583b1f6..59179a4 100644 --- a/noncore/net/mail/viewmailbase.h +++ b/noncore/net/mail/viewmailbase.h | |||
@@ -1,38 +1,38 @@ | |||
1 | #ifndef VIEWMAILBASE_H | 1 | #ifndef VIEWMAILBASE_H |
2 | #define VIEWMAILBASE_H | 2 | #define VIEWMAILBASE_H |
3 | 3 | ||
4 | #include <qmainwindow.h> | 4 | #include <qmainwindow.h> |
5 | 5 | ||
6 | class QAction; | 6 | class QAction; |
7 | class OpenDiag; | 7 | class OpenDiag; |
8 | class QListView; | 8 | class QListView; |
9 | class QToolBar; | 9 | class QToolBar; |
10 | class QTextBrowser; | 10 | class QTextBrowser; |
11 | class QMenuBar; | 11 | class QMenuBar; |
12 | class QPopupMenu; | 12 | class QPopupMenu; |
13 | 13 | ||
14 | class ViewMailBase : public QMainWindow | 14 | class ViewMailBase : public QMainWindow |
15 | { | 15 | { |
16 | Q_OBJECT | 16 | Q_OBJECT |
17 | 17 | ||
18 | public: | 18 | public: |
19 | ViewMailBase(QWidget *parent = 0, const char *name = 0, WFlags fl = 0); | 19 | ViewMailBase(QWidget *parent = 0, const char *name = 0, WFlags fl = 0); |
20 | 20 | ||
21 | protected: | 21 | protected: |
22 | QAction *reply, *forward, *attachbutton, *deleteMail, *showHtml; | 22 | QAction *reply, *forward, *attachbutton, *deleteMail, *showHtml,*showPicsInline; |
23 | QListView *attachments; | 23 | QListView *attachments; |
24 | QToolBar *toolbar; | 24 | QToolBar *toolbar; |
25 | QTextBrowser *browser;//,*header; | 25 | QTextBrowser *browser;//,*header; |
26 | OpenDiag *openDiag; | 26 | OpenDiag *openDiag; |
27 | QMenuBar *menubar; | 27 | QMenuBar *menubar; |
28 | QPopupMenu *mailmenu; | 28 | QPopupMenu *mailmenu; |
29 | 29 | ||
30 | protected slots: | 30 | protected slots: |
31 | void slotChangeAttachview(bool state); | 31 | void slotChangeAttachview(bool state); |
32 | virtual void keyPressEvent ( QKeyEvent * e ); | 32 | virtual void keyPressEvent ( QKeyEvent * e ); |
33 | 33 | ||
34 | 34 | ||
35 | }; | 35 | }; |
36 | 36 | ||
37 | #endif | 37 | #endif |
38 | 38 | ||