-rw-r--r-- | noncore/net/mail/mainwindow.cpp | 4 | ||||
-rw-r--r-- | noncore/net/mail/viewmail.cpp | 7 |
2 files changed, 6 insertions, 5 deletions
diff --git a/noncore/net/mail/mainwindow.cpp b/noncore/net/mail/mainwindow.cpp index 560715c..8ef7ddd 100644 --- a/noncore/net/mail/mainwindow.cpp +++ b/noncore/net/mail/mainwindow.cpp | |||
@@ -1,195 +1,195 @@ | |||
1 | #include <qlabel.h> | 1 | #include <qlabel.h> |
2 | #include <qvbox.h> | 2 | #include <qvbox.h> |
3 | #include <qheader.h> | 3 | #include <qheader.h> |
4 | #include <qtimer.h> | 4 | #include <qtimer.h> |
5 | #include <qlayout.h> | 5 | #include <qlayout.h> |
6 | 6 | ||
7 | #include <qpe/qpeapplication.h> | 7 | #include <qpe/qpeapplication.h> |
8 | #include <qpe/resource.h> | 8 | #include <qpe/resource.h> |
9 | 9 | ||
10 | #include "defines.h" | 10 | #include "defines.h" |
11 | #include "mainwindow.h" | 11 | #include "mainwindow.h" |
12 | #include "viewmail.h" | 12 | #include "viewmail.h" |
13 | #include "mailtypes.h" | 13 | #include "mailtypes.h" |
14 | #include "mailistviewitem.h" | 14 | #include "mailistviewitem.h" |
15 | 15 | ||
16 | MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags ) | 16 | MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags ) |
17 | : QMainWindow( parent, name, flags ) | 17 | : QMainWindow( parent, name, flags ) |
18 | { | 18 | { |
19 | setCaption( tr( "Mail" ) ); | 19 | setCaption( tr( "Mail" ) ); |
20 | setToolBarsMovable( false ); | 20 | setToolBarsMovable( false ); |
21 | 21 | ||
22 | toolBar = new QToolBar( this ); | 22 | toolBar = new QToolBar( this ); |
23 | menuBar = new QMenuBar( toolBar ); | 23 | menuBar = new QMenuBar( toolBar ); |
24 | mailMenu = new QPopupMenu( menuBar ); | 24 | mailMenu = new QPopupMenu( menuBar ); |
25 | menuBar->insertItem( tr( "Mail" ), mailMenu ); | 25 | menuBar->insertItem( tr( "Mail" ), mailMenu ); |
26 | settingsMenu = new QPopupMenu( menuBar ); | 26 | settingsMenu = new QPopupMenu( menuBar ); |
27 | menuBar->insertItem( tr( "Settings" ), settingsMenu ); | 27 | menuBar->insertItem( tr( "Settings" ), settingsMenu ); |
28 | 28 | ||
29 | addToolBar( toolBar ); | 29 | addToolBar( toolBar ); |
30 | toolBar->setHorizontalStretchable( true ); | 30 | toolBar->setHorizontalStretchable( true ); |
31 | 31 | ||
32 | QLabel *spacer = new QLabel( toolBar ); | 32 | QLabel *spacer = new QLabel( toolBar ); |
33 | spacer->setBackgroundMode( QWidget::PaletteButton ); | 33 | spacer->setBackgroundMode( QWidget::PaletteButton ); |
34 | toolBar->setStretchableWidget( spacer ); | 34 | toolBar->setStretchableWidget( spacer ); |
35 | 35 | ||
36 | composeMail = new QAction( tr( "Compose new mail" ), ICON_COMPOSEMAIL, | 36 | composeMail = new QAction( tr( "Compose new mail" ), ICON_COMPOSEMAIL, |
37 | 0, 0, this ); | 37 | 0, 0, this ); |
38 | composeMail->addTo( toolBar ); | 38 | composeMail->addTo( toolBar ); |
39 | composeMail->addTo( mailMenu ); | 39 | composeMail->addTo( mailMenu ); |
40 | 40 | ||
41 | sendQueued = new QAction( tr( "Send queued mails" ), ICON_SENDQUEUED, | 41 | sendQueued = new QAction( tr( "Send queued mails" ), ICON_SENDQUEUED, |
42 | 0, 0, this ); | 42 | 0, 0, this ); |
43 | sendQueued->addTo( toolBar ); | 43 | sendQueued->addTo( toolBar ); |
44 | sendQueued->addTo( mailMenu ); | 44 | sendQueued->addTo( mailMenu ); |
45 | 45 | ||
46 | syncFolders = new QAction( tr( "Sync mailfolders" ), ICON_SYNC, | 46 | syncFolders = new QAction( tr( "Sync mailfolders" ), ICON_SYNC, |
47 | 0, 0, this ); | 47 | 0, 0, this ); |
48 | syncFolders->addTo( toolBar ); | 48 | syncFolders->addTo( toolBar ); |
49 | syncFolders->addTo( mailMenu ); | 49 | syncFolders->addTo( mailMenu ); |
50 | 50 | ||
51 | showFolders = new QAction( tr( "Show/Hide folders" ), ICON_SHOWFOLDERS, | 51 | showFolders = new QAction( tr( "Show/Hide folders" ), ICON_SHOWFOLDERS, |
52 | 0, 0, this, 0, true ); | 52 | 0, 0, this, 0, true ); |
53 | showFolders->addTo( toolBar ); | 53 | showFolders->addTo( toolBar ); |
54 | showFolders->addTo( mailMenu ); | 54 | showFolders->addTo( mailMenu ); |
55 | connect(showFolders, SIGNAL( toggled( bool ) ), | 55 | connect(showFolders, SIGNAL( toggled( bool ) ), |
56 | SLOT( slotShowFolders( bool ) ) ); | 56 | SLOT( slotShowFolders( bool ) ) ); |
57 | 57 | ||
58 | searchMails = new QAction( tr( "Search mails" ), ICON_SEARCHMAILS, | 58 | searchMails = new QAction( tr( "Search mails" ), ICON_SEARCHMAILS, |
59 | 0, 0, this ); | 59 | 0, 0, this ); |
60 | searchMails->addTo( toolBar ); | 60 | searchMails->addTo( toolBar ); |
61 | searchMails->addTo( mailMenu ); | 61 | searchMails->addTo( mailMenu ); |
62 | 62 | ||
63 | 63 | ||
64 | editSettings = new QAction( tr( "Edit settings" ), ICON_EDITSETTINGS, | 64 | editSettings = new QAction( tr( "Edit settings" ), ICON_EDITSETTINGS, |
65 | 0, 0, this ); | 65 | 0, 0, this ); |
66 | editSettings->addTo( settingsMenu ); | 66 | editSettings->addTo( settingsMenu ); |
67 | 67 | ||
68 | editAccounts = new QAction( tr( "Configure accounts" ), ICON_EDITACCOUNTS, | 68 | editAccounts = new QAction( tr( "Configure accounts" ), ICON_EDITACCOUNTS, |
69 | 0, 0, this ); | 69 | 0, 0, this ); |
70 | editAccounts->addTo( settingsMenu ); | 70 | editAccounts->addTo( settingsMenu ); |
71 | 71 | ||
72 | QWidget *view = new QWidget( this ); | 72 | QWidget *view = new QWidget( this ); |
73 | setCentralWidget( view ); | 73 | setCentralWidget( view ); |
74 | 74 | ||
75 | layout = new QBoxLayout ( view, QBoxLayout::LeftToRight ); | 75 | layout = new QBoxLayout ( view, QBoxLayout::LeftToRight ); |
76 | 76 | ||
77 | folderView = new AccountView( view ); | 77 | folderView = new AccountView( view ); |
78 | folderView->header()->hide(); | 78 | folderView->header()->hide(); |
79 | folderView->addColumn( tr( "Mailbox" ) ); | 79 | folderView->addColumn( tr( "Mailbox" ) ); |
80 | folderView->hide(); | 80 | folderView->hide(); |
81 | 81 | ||
82 | layout->addWidget( folderView ); | 82 | layout->addWidget( folderView ); |
83 | 83 | ||
84 | mailView = new QListView( view ); | 84 | mailView = new QListView( view ); |
85 | mailView->addColumn( tr( "Status" ) ); | 85 | mailView->addColumn( tr( "" ) ); |
86 | mailView->addColumn( tr( "Subject" ),QListView::Manual ); | 86 | mailView->addColumn( tr( "Subject" ),QListView::Manual ); |
87 | mailView->addColumn( tr( "Sender" ),QListView::Manual ); | 87 | mailView->addColumn( tr( "Sender" ),QListView::Manual ); |
88 | mailView->addColumn( tr( "Date" )); | 88 | mailView->addColumn( tr( "Date" )); |
89 | mailView->setAllColumnsShowFocus(true); | 89 | mailView->setAllColumnsShowFocus(true); |
90 | mailView->setSorting(-1); | 90 | mailView->setSorting(-1); |
91 | 91 | ||
92 | layout->addWidget( mailView ); | 92 | layout->addWidget( mailView ); |
93 | layout->setStretchFactor( folderView, 1 ); | 93 | layout->setStretchFactor( folderView, 1 ); |
94 | layout->setStretchFactor( mailView, 2 ); | 94 | layout->setStretchFactor( mailView, 2 ); |
95 | 95 | ||
96 | slotAdjustLayout(); | 96 | slotAdjustLayout(); |
97 | 97 | ||
98 | connect( mailView, SIGNAL( clicked( QListViewItem * ) ),this, | 98 | connect( mailView, SIGNAL( clicked( QListViewItem * ) ),this, |
99 | SLOT( displayMail( QListViewItem * ) ) ); | 99 | SLOT( displayMail( QListViewItem * ) ) ); |
100 | 100 | ||
101 | connect(folderView,SIGNAL(refreshMailview(QList<RecMail>*)),this,SLOT(refreshMailView(QList<RecMail>*))); | 101 | connect(folderView,SIGNAL(refreshMailview(QList<RecMail>*)),this,SLOT(refreshMailView(QList<RecMail>*))); |
102 | 102 | ||
103 | QTimer::singleShot( 1000, this, SLOT( slotAdjustColumns() ) ); | 103 | QTimer::singleShot( 1000, this, SLOT( slotAdjustColumns() ) ); |
104 | } | 104 | } |
105 | 105 | ||
106 | 106 | ||
107 | void MainWindow::slotAdjustLayout() { | 107 | void MainWindow::slotAdjustLayout() { |
108 | 108 | ||
109 | QWidget *d = QApplication::desktop(); | 109 | QWidget *d = QApplication::desktop(); |
110 | 110 | ||
111 | if ( d->width() < d->height() ) { | 111 | if ( d->width() < d->height() ) { |
112 | layout->setDirection( QBoxLayout::TopToBottom ); | 112 | layout->setDirection( QBoxLayout::TopToBottom ); |
113 | } else { | 113 | } else { |
114 | layout->setDirection( QBoxLayout::LeftToRight ); | 114 | layout->setDirection( QBoxLayout::LeftToRight ); |
115 | } | 115 | } |
116 | delete d; | 116 | delete d; |
117 | } | 117 | } |
118 | 118 | ||
119 | void MainWindow::slotAdjustColumns() | 119 | void MainWindow::slotAdjustColumns() |
120 | { | 120 | { |
121 | bool hidden = folderView->isHidden(); | 121 | bool hidden = folderView->isHidden(); |
122 | if ( hidden ) folderView->show(); | 122 | if ( hidden ) folderView->show(); |
123 | folderView->setColumnWidth( 0, folderView->visibleWidth() ); | 123 | folderView->setColumnWidth( 0, folderView->visibleWidth() ); |
124 | if ( hidden ) folderView->hide(); | 124 | if ( hidden ) folderView->hide(); |
125 | 125 | ||
126 | mailView->setColumnWidth( 0, 10 ); | 126 | mailView->setColumnWidth( 0, 10 ); |
127 | mailView->setColumnWidth( 1, mailView->visibleWidth() - 130 ); | 127 | mailView->setColumnWidth( 1, mailView->visibleWidth() - 130 ); |
128 | mailView->setColumnWidth( 2, 80 ); | 128 | mailView->setColumnWidth( 2, 80 ); |
129 | mailView->setColumnWidth( 3, 50 ); | 129 | mailView->setColumnWidth( 3, 50 ); |
130 | } | 130 | } |
131 | 131 | ||
132 | void MainWindow::slotShowFolders( bool show ) | 132 | void MainWindow::slotShowFolders( bool show ) |
133 | { | 133 | { |
134 | qDebug( "Show Folders" ); | 134 | qDebug( "Show Folders" ); |
135 | if ( show && folderView->isHidden() ) { | 135 | if ( show && folderView->isHidden() ) { |
136 | qDebug( "-> showing" ); | 136 | qDebug( "-> showing" ); |
137 | folderView->show(); | 137 | folderView->show(); |
138 | } else if ( !show && !folderView->isHidden() ) { | 138 | } else if ( !show && !folderView->isHidden() ) { |
139 | qDebug( "-> hiding" ); | 139 | qDebug( "-> hiding" ); |
140 | folderView->hide(); | 140 | folderView->hide(); |
141 | } | 141 | } |
142 | } | 142 | } |
143 | 143 | ||
144 | void MainWindow::refreshMailView(QList<RecMail>*list) | 144 | void MainWindow::refreshMailView(QList<RecMail>*list) |
145 | { | 145 | { |
146 | MailListViewItem*item = 0; | 146 | MailListViewItem*item = 0; |
147 | mailView->clear(); | 147 | mailView->clear(); |
148 | for (unsigned int i = 0; i < list->count();++i) { | 148 | for (unsigned int i = 0; i < list->count();++i) { |
149 | item = new MailListViewItem(mailView,item); | 149 | item = new MailListViewItem(mailView,item); |
150 | item->storeData(*(list->at(i))); | 150 | item->storeData(*(list->at(i))); |
151 | item->showEntry(); | 151 | item->showEntry(); |
152 | } | 152 | } |
153 | } | 153 | } |
154 | void MainWindow::displayMail(QListViewItem*item) | 154 | void MainWindow::displayMail(QListViewItem*item) |
155 | { | 155 | { |
156 | if (!item) return; | 156 | if (!item) return; |
157 | RecMail mail = ((MailListViewItem*)item)->data(); | 157 | RecMail mail = ((MailListViewItem*)item)->data(); |
158 | RecBody body = folderView->fetchBody(mail); | 158 | RecBody body = folderView->fetchBody(mail); |
159 | 159 | ||
160 | ViewMail readMail( this ); | 160 | ViewMail readMail( this ); |
161 | readMail.setBody( body ); | 161 | readMail.setBody( body ); |
162 | readMail.setMail( mail ); | 162 | readMail.setMail( mail ); |
163 | readMail.showMaximized(); | 163 | readMail.showMaximized(); |
164 | readMail.exec(); | 164 | readMail.exec(); |
165 | ( (MailListViewItem*)item )->setPixmap( 0, Resource::loadPixmap( "opiemail/kmmsgunseen") ); | 165 | ( (MailListViewItem*)item )->setPixmap( 0, Resource::loadPixmap( "opiemail/kmmsgunseen") ); |
166 | } | 166 | } |
167 | 167 | ||
168 | MailListViewItem::MailListViewItem(QListView * parent, MailListViewItem * item ) | 168 | MailListViewItem::MailListViewItem(QListView * parent, MailListViewItem * item ) |
169 | :QListViewItem(parent,item),mail_data() | 169 | :QListViewItem(parent,item),mail_data() |
170 | { | 170 | { |
171 | } | 171 | } |
172 | 172 | ||
173 | void MailListViewItem::showEntry() | 173 | void MailListViewItem::showEntry() |
174 | { | 174 | { |
175 | if ( mail_data.getFlags().testBit( FLAG_SEEN ) == true ) { | 175 | if ( mail_data.getFlags().testBit( FLAG_SEEN ) == true ) { |
176 | setPixmap( 0, Resource::loadPixmap( "opiemail/kmmsgunseen") ); | 176 | setPixmap( 0, Resource::loadPixmap( "opiemail/kmmsgunseen") ); |
177 | } else { | 177 | } else { |
178 | setPixmap( 0, Resource::loadPixmap( "opiemail/kmmsgnew") ); | 178 | setPixmap( 0, Resource::loadPixmap( "opiemail/kmmsgnew") ); |
179 | } | 179 | } |
180 | setText(1,mail_data.getSubject()); | 180 | setText(1,mail_data.getSubject()); |
181 | setText(2,mail_data.getFrom()); | 181 | setText(2,mail_data.getFrom()); |
182 | setText(3,mail_data.getDate()); | 182 | setText(3,mail_data.getDate()); |
183 | } | 183 | } |
184 | 184 | ||
185 | void MailListViewItem::storeData(const RecMail&data) | 185 | void MailListViewItem::storeData(const RecMail&data) |
186 | { | 186 | { |
187 | mail_data = data; | 187 | mail_data = data; |
188 | } | 188 | } |
189 | 189 | ||
190 | const RecMail& MailListViewItem::data()const | 190 | const RecMail& MailListViewItem::data()const |
191 | { | 191 | { |
192 | return mail_data; | 192 | return mail_data; |
193 | } | 193 | } |
194 | 194 | ||
195 | 195 | ||
diff --git a/noncore/net/mail/viewmail.cpp b/noncore/net/mail/viewmail.cpp index a73dac5..42707e3 100644 --- a/noncore/net/mail/viewmail.cpp +++ b/noncore/net/mail/viewmail.cpp | |||
@@ -1,316 +1,317 @@ | |||
1 | #include <qtextbrowser.h> | 1 | #include <qtextbrowser.h> |
2 | #include <qmessagebox.h> | 2 | #include <qmessagebox.h> |
3 | #include <qtextstream.h> | 3 | #include <qtextstream.h> |
4 | #include <qaction.h> | 4 | #include <qaction.h> |
5 | #include <qpopupmenu.h> | 5 | #include <qpopupmenu.h> |
6 | #include <qapplication.h> | 6 | #include <qapplication.h> |
7 | 7 | ||
8 | #include <opie/ofiledialog.h> | 8 | #include <opie/ofiledialog.h> |
9 | 9 | ||
10 | #include "settings.h" | 10 | #include "settings.h" |
11 | #include "composemail.h" | 11 | #include "composemail.h" |
12 | #include "viewmail.h" | 12 | #include "viewmail.h" |
13 | #include "abstractmail.h" | 13 | #include "abstractmail.h" |
14 | 14 | ||
15 | AttachItem::AttachItem(QListView * parent,QListViewItem *after, const QString&mime,const QString&file,const QString&desc,int num) | 15 | AttachItem::AttachItem(QListView * parent,QListViewItem *after, const QString&mime,const QString&file,const QString&desc,int num) |
16 | : QListViewItem(parent,after),_partNum(num) | 16 | : QListViewItem(parent,after),_partNum(num) |
17 | { | 17 | { |
18 | setText(0, mime); | 18 | setText(0, mime); |
19 | setText(1, file); | 19 | setText(1, file); |
20 | setText(2, desc); | 20 | setText(2, desc); |
21 | } | 21 | } |
22 | 22 | ||
23 | void ViewMail::setBody( RecBody body ) { | 23 | void ViewMail::setBody( RecBody body ) { |
24 | 24 | ||
25 | m_body = body; | 25 | m_body = body; |
26 | m_mail[2] = body.Bodytext(); | 26 | m_mail[2] = body.Bodytext(); |
27 | attachbutton->setEnabled(body.Parts().count()>0); | 27 | attachbutton->setEnabled(body.Parts().count()>0); |
28 | attachments->setEnabled(body.Parts().count()>0); | 28 | attachments->setEnabled(body.Parts().count()>0); |
29 | if (body.Parts().count()==0) { | 29 | if (body.Parts().count()==0) { |
30 | return; | 30 | return; |
31 | } | 31 | } |
32 | AttachItem * curItem=0; | 32 | AttachItem * curItem=0; |
33 | QString type=body.Description().Type()+"/"+body.Description().Subtype(); | 33 | QString type=body.Description().Type()+"/"+body.Description().Subtype(); |
34 | QString desc; | 34 | QString desc; |
35 | double s = body.Description().Size(); | 35 | double s = body.Description().Size(); |
36 | int w; | 36 | int w; |
37 | w=0; | 37 | w=0; |
38 | 38 | ||
39 | while (s>1024) { | 39 | while (s>1024) { |
40 | s/=1024; | 40 | s/=1024; |
41 | ++w; | 41 | ++w; |
42 | if (w>=2) break; | 42 | if (w>=2) break; |
43 | } | 43 | } |
44 | 44 | ||
45 | QString q=""; | 45 | QString q=""; |
46 | switch(w) { | 46 | switch(w) { |
47 | case 1: | 47 | case 1: |
48 | q="k"; | 48 | q="k"; |
49 | break; | 49 | break; |
50 | case 2: | 50 | case 2: |
51 | q="M"; | 51 | q="M"; |
52 | break; | 52 | break; |
53 | default: | 53 | default: |
54 | break; | 54 | break; |
55 | } | 55 | } |
56 | 56 | ||
57 | { | 57 | { |
58 | /* I did not found a method to make a CONTENT reset on a QTextStream | 58 | /* I did not found a method to make a CONTENT reset on a QTextStream |
59 | so I use this construct that the stream will re-constructed in each | 59 | so I use this construct that the stream will re-constructed in each |
60 | loop. To let it work, the textstream is packed into a own area of | 60 | loop. To let it work, the textstream is packed into a own area of |
61 | code is it will be destructed after finishing its small job. | 61 | code is it will be destructed after finishing its small job. |
62 | */ | 62 | */ |
63 | QTextOStream o(&desc); | 63 | QTextOStream o(&desc); |
64 | if (w>0) o.precision(2); else o.precision(0); | 64 | if (w>0) o.precision(2); else o.precision(0); |
65 | o.setf(QTextStream::fixed); | 65 | o.setf(QTextStream::fixed); |
66 | o << s << " " << q << "Byte"; | 66 | o << s << " " << q << "Byte"; |
67 | } | 67 | } |
68 | 68 | ||
69 | curItem=new AttachItem(attachments,curItem,type,"Mailbody",desc,-1); | 69 | curItem=new AttachItem(attachments,curItem,type,"Mailbody",desc,-1); |
70 | QString filename = ""; | 70 | QString filename = ""; |
71 | for (unsigned int i = 0; i < body.Parts().count();++i) { | 71 | for (unsigned int i = 0; i < body.Parts().count();++i) { |
72 | type = body.Parts()[i].Type()+"/"+body.Parts()[i].Subtype(); | 72 | type = body.Parts()[i].Type()+"/"+body.Parts()[i].Subtype(); |
73 | part_plist_t::ConstIterator it = body.Parts()[i].Parameters().begin(); | 73 | part_plist_t::ConstIterator it = body.Parts()[i].Parameters().begin(); |
74 | for (;it!=body.Parts()[i].Parameters().end();++it) { | 74 | for (;it!=body.Parts()[i].Parameters().end();++it) { |
75 | if (it.key().lower()=="name") { | 75 | if (it.key().lower()=="name") { |
76 | filename=it.data(); | 76 | filename=it.data(); |
77 | } | 77 | } |
78 | } | 78 | } |
79 | s = body.Parts()[i].Size(); | 79 | s = body.Parts()[i].Size(); |
80 | w = 0; | 80 | w = 0; |
81 | while (s>1024) { | 81 | while (s>1024) { |
82 | s/=1024; | 82 | s/=1024; |
83 | ++w; | 83 | ++w; |
84 | if (w>=2) break; | 84 | if (w>=2) break; |
85 | } | 85 | } |
86 | switch(w) { | 86 | switch(w) { |
87 | case 1: | 87 | case 1: |
88 | q="k"; | 88 | q="k"; |
89 | break; | 89 | break; |
90 | case 2: | 90 | case 2: |
91 | q="M"; | 91 | q="M"; |
92 | break; | 92 | break; |
93 | default: | 93 | default: |
94 | q=""; | 94 | q=""; |
95 | break; | 95 | break; |
96 | } | 96 | } |
97 | QTextOStream o(&desc); | 97 | QTextOStream o(&desc); |
98 | if (w>0) o.precision(2); else o.precision(0); | 98 | if (w>0) o.precision(2); else o.precision(0); |
99 | o.setf(QTextStream::fixed); | 99 | o.setf(QTextStream::fixed); |
100 | o << s << " " << q << "Byte"; | 100 | o << s << " " << q << "Byte"; |
101 | curItem=new AttachItem(attachments,curItem,type,filename,desc,i); | 101 | curItem=new AttachItem(attachments,curItem,type,filename,desc,i); |
102 | } | 102 | } |
103 | } | 103 | } |
104 | 104 | ||
105 | void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int c ) { | 105 | void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int c ) { |
106 | if (!item ) | 106 | if (!item ) |
107 | return; | 107 | return; |
108 | 108 | ||
109 | QPopupMenu *menu = new QPopupMenu(); | 109 | QPopupMenu *menu = new QPopupMenu(); |
110 | int ret=0; | 110 | int ret=0; |
111 | 111 | ||
112 | if ( item->text( 0 ).left( 4 ) == "text" ) { | 112 | if ( item->text( 0 ).left( 4 ) == "text" ) { |
113 | menu->insertItem( tr( "Show Text" ), 1 ); | 113 | menu->insertItem( tr( "Show Text" ), 1 ); |
114 | } | 114 | } |
115 | menu->insertItem( tr( "Save Attachemt" ), 0 ); | 115 | menu->insertItem( tr( "Save Attachment" ), 0 ); |
116 | menu->insertSeparator(1); | 116 | menu->insertSeparator(1); |
117 | 117 | ||
118 | ret = menu->exec( point, 0 ); | 118 | ret = menu->exec( point, 0 ); |
119 | 119 | ||
120 | switch(ret) { | 120 | switch(ret) { |
121 | case 0: | 121 | case 0: |
122 | { MimeTypes types; | 122 | { MimeTypes types; |
123 | types.insert( "all", "*" ); | 123 | types.insert( "all", "*" ); |
124 | QString str = OFileDialog::getSaveFileName( 1, | 124 | QString str = OFileDialog::getSaveFileName( 1, |
125 | "/", item->text( 1 ) , types, 0 ); | 125 | "/", item->text( 1 ) , types, 0 ); |
126 | 126 | ||
127 | if( !str.isEmpty() ) { | 127 | if( !str.isEmpty() ) { |
128 | qDebug( " first we will need a MIME wrapper" ); | 128 | qDebug( "first we will need a MIME wrapper" ); |
129 | } | 129 | } |
130 | } | 130 | } |
131 | break ; | 131 | break ; |
132 | 132 | ||
133 | case 1: | 133 | case 1: |
134 | qDebug( QString( "Test selected" ).arg( ( ( AttachItem* )item )->Partnumber() ) ); | ||
135 | if ( ( ( AttachItem* )item )->Partnumber() == -1 ) { | 134 | if ( ( ( AttachItem* )item )->Partnumber() == -1 ) { |
136 | setText(); | 135 | setText(); |
137 | } else { | 136 | } else { |
137 | if ( m_recMail.Wrapper() != 0l ) { // make sure that there is a wrapper , even after delete or simular actions | ||
138 | browser->setText( m_recMail.Wrapper()->fetchPart( m_recMail, m_body.Parts()[ ( ( AttachItem* )item )->Partnumber() ] ) ); | 138 | browser->setText( m_recMail.Wrapper()->fetchPart( m_recMail, m_body.Parts()[ ( ( AttachItem* )item )->Partnumber() ] ) ); |
139 | } | ||
139 | } | 140 | } |
140 | break; | 141 | break; |
141 | } | 142 | } |
142 | delete menu; | 143 | delete menu; |
143 | } | 144 | } |
144 | 145 | ||
145 | 146 | ||
146 | void ViewMail::setMail( RecMail mail ) { | 147 | void ViewMail::setMail( RecMail mail ) { |
147 | 148 | ||
148 | m_recMail = mail; | 149 | m_recMail = mail; |
149 | 150 | ||
150 | m_mail[0] = mail.getFrom(); | 151 | m_mail[0] = mail.getFrom(); |
151 | m_mail[1] = mail.getSubject(); | 152 | m_mail[1] = mail.getSubject(); |
152 | m_mail[3] = mail.getDate(); | 153 | m_mail[3] = mail.getDate(); |
153 | m_mail[4] = mail.Msgid(); | 154 | m_mail[4] = mail.Msgid(); |
154 | 155 | ||
155 | m_mail2[0] = mail.To(); | 156 | m_mail2[0] = mail.To(); |
156 | m_mail2[1] = mail.CC(); | 157 | m_mail2[1] = mail.CC(); |
157 | m_mail2[2] = mail.Bcc(); | 158 | m_mail2[2] = mail.Bcc(); |
158 | 159 | ||
159 | setText(); | 160 | setText(); |
160 | } | 161 | } |
161 | 162 | ||
162 | 163 | ||
163 | 164 | ||
164 | ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl) | 165 | ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl) |
165 | : ViewMailBase(parent, name, fl), _inLoop(false) | 166 | : ViewMailBase(parent, name, fl), _inLoop(false) |
166 | { | 167 | { |
167 | m_gotBody = false; | 168 | m_gotBody = false; |
168 | 169 | ||
169 | connect(reply, SIGNAL(activated()), SLOT(slotReply())); | 170 | connect(reply, SIGNAL(activated()), SLOT(slotReply())); |
170 | connect(forward, SIGNAL(activated()), SLOT(slotForward())); | 171 | connect(forward, SIGNAL(activated()), SLOT(slotForward())); |
171 | 172 | ||
172 | attachments->setEnabled(m_gotBody); | 173 | attachments->setEnabled(m_gotBody); |
173 | connect( attachments, SIGNAL( clicked ( QListViewItem *, const QPoint & , int ) ), SLOT( slotItemClicked( QListViewItem *, const QPoint & , int ) ) ); | 174 | connect( attachments, SIGNAL( clicked ( QListViewItem *, const QPoint & , int ) ), SLOT( slotItemClicked( QListViewItem *, const QPoint & , int ) ) ); |
174 | 175 | ||
175 | } | 176 | } |
176 | 177 | ||
177 | void ViewMail::setText() | 178 | void ViewMail::setText() |
178 | { | 179 | { |
179 | 180 | ||
180 | QString toString; | 181 | QString toString; |
181 | QString ccString; | 182 | QString ccString; |
182 | QString bccString; | 183 | QString bccString; |
183 | 184 | ||
184 | for ( QStringList::Iterator it = ( m_mail2[0] ).begin(); it != ( m_mail2[0] ).end(); ++it ) { | 185 | for ( QStringList::Iterator it = ( m_mail2[0] ).begin(); it != ( m_mail2[0] ).end(); ++it ) { |
185 | toString += (*it); | 186 | toString += (*it); |
186 | } | 187 | } |
187 | for ( QStringList::Iterator it = ( m_mail2[1] ).begin(); it != ( m_mail2[1] ).end(); ++it ) { | 188 | for ( QStringList::Iterator it = ( m_mail2[1] ).begin(); it != ( m_mail2[1] ).end(); ++it ) { |
188 | ccString += (*it); | 189 | ccString += (*it); |
189 | } | 190 | } |
190 | for ( QStringList::Iterator it = ( m_mail2[2] ).begin(); it != ( m_mail2[2] ).end(); ++it ) { | 191 | for ( QStringList::Iterator it = ( m_mail2[2] ).begin(); it != ( m_mail2[2] ).end(); ++it ) { |
191 | bccString += (*it); | 192 | bccString += (*it); |
192 | } | 193 | } |
193 | 194 | ||
194 | setCaption( caption().arg( m_mail[0] ) ); | 195 | setCaption( caption().arg( m_mail[0] ) ); |
195 | 196 | ||
196 | m_mailHtml = "<html><body>" | 197 | m_mailHtml = "<html><body>" |
197 | "<table width=\"100%\" border=\"0\"><tr bgcolor=\"#FFDD76\"><td>" | 198 | "<table width=\"100%\" border=\"0\"><tr bgcolor=\"#FFDD76\"><td>" |
198 | "<div align=left><b>" + deHtml( m_mail[1] ) + "</b></div>" | 199 | "<div align=left><b>" + deHtml( m_mail[1] ) + "</b></div>" |
199 | "</td></tr><tr bgcolor=\"#EEEEE6\"><td>" | 200 | "</td></tr><tr bgcolor=\"#EEEEE6\"><td>" |
200 | "<b>" + tr( "From" ) + ": </b><font color=#6C86C0>" + deHtml( m_mail[0] ) + "</font><br>" | 201 | "<b>" + tr( "From" ) + ": </b><font color=#6C86C0>" + deHtml( m_mail[0] ) + "</font><br>" |
201 | "<b>" + tr( "To" ) + ": </b><font color=#6C86C0>" + deHtml( toString ) + "</font><br><b>" + | 202 | "<b>" + tr( "To" ) + ": </b><font color=#6C86C0>" + deHtml( toString ) + "</font><br><b>" + |
202 | tr( "Cc" ) + ": </b>" + deHtml( ccString ) + "<br>" | 203 | tr( "Cc" ) + ": </b>" + deHtml( ccString ) + "<br>" |
203 | "<b>" + tr( "Date" ) + ": </b> " + m_mail[3] + | 204 | "<b>" + tr( "Date" ) + ": </b> " + m_mail[3] + |
204 | "</td></tr></table><font face=fixed>"; | 205 | "</td></tr></table><font face=fixed>"; |
205 | 206 | ||
206 | browser->setText( QString( m_mailHtml) + deHtml( m_mail[2] ) + "</font></html>" ); | 207 | browser->setText( QString( m_mailHtml) + deHtml( m_mail[2] ) + "</font></html>" ); |
207 | // remove later in favor of a real handling | 208 | // remove later in favor of a real handling |
208 | m_gotBody = true; | 209 | m_gotBody = true; |
209 | } | 210 | } |
210 | 211 | ||
211 | 212 | ||
212 | ViewMail::~ViewMail() | 213 | ViewMail::~ViewMail() |
213 | { | 214 | { |
214 | hide(); | 215 | hide(); |
215 | } | 216 | } |
216 | 217 | ||
217 | void ViewMail::hide() | 218 | void ViewMail::hide() |
218 | { | 219 | { |
219 | QWidget::hide(); | 220 | QWidget::hide(); |
220 | 221 | ||
221 | if (_inLoop) { | 222 | if (_inLoop) { |
222 | _inLoop = false; | 223 | _inLoop = false; |
223 | qApp->exit_loop(); | 224 | qApp->exit_loop(); |
224 | 225 | ||
225 | } | 226 | } |
226 | 227 | ||
227 | } | 228 | } |
228 | 229 | ||
229 | void ViewMail::exec() | 230 | void ViewMail::exec() |
230 | { | 231 | { |
231 | show(); | 232 | show(); |
232 | 233 | ||
233 | if (!_inLoop) { | 234 | if (!_inLoop) { |
234 | _inLoop = true; | 235 | _inLoop = true; |
235 | qApp->enter_loop(); | 236 | qApp->enter_loop(); |
236 | } | 237 | } |
237 | 238 | ||
238 | } | 239 | } |
239 | 240 | ||
240 | QString ViewMail::deHtml(const QString &string) | 241 | QString ViewMail::deHtml(const QString &string) |
241 | { | 242 | { |
242 | QString string_ = string; | 243 | QString string_ = string; |
243 | string_.replace(QRegExp("&"), "&"); | 244 | string_.replace(QRegExp("&"), "&"); |
244 | string_.replace(QRegExp("<"), "<"); | 245 | string_.replace(QRegExp("<"), "<"); |
245 | string_.replace(QRegExp(">"), ">"); | 246 | string_.replace(QRegExp(">"), ">"); |
246 | string_.replace(QRegExp("\\n"), "<br>"); | 247 | string_.replace(QRegExp("\\n"), "<br>"); |
247 | return string_; | 248 | return string_; |
248 | } | 249 | } |
249 | 250 | ||
250 | void ViewMail::slotReply() | 251 | void ViewMail::slotReply() |
251 | { | 252 | { |
252 | if (!m_gotBody) { | 253 | if (!m_gotBody) { |
253 | QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot reply yet."), tr("Ok")); | 254 | QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot reply yet."), tr("Ok")); |
254 | return; | 255 | return; |
255 | } | 256 | } |
256 | 257 | ||
257 | QString rtext; | 258 | QString rtext; |
258 | rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose | 259 | rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose |
259 | .arg( m_mail[1] ) | 260 | .arg( m_mail[1] ) |
260 | .arg( m_mail[3] ); | 261 | .arg( m_mail[3] ); |
261 | 262 | ||
262 | QString text = m_mail[2]; | 263 | QString text = m_mail[2]; |
263 | QStringList lines = QStringList::split(QRegExp("\\n"), text); | 264 | QStringList lines = QStringList::split(QRegExp("\\n"), text); |
264 | QStringList::Iterator it; | 265 | QStringList::Iterator it; |
265 | for (it = lines.begin(); it != lines.end(); it++) { | 266 | for (it = lines.begin(); it != lines.end(); it++) { |
266 | rtext += "> " + *it + "\n"; | 267 | rtext += "> " + *it + "\n"; |
267 | } | 268 | } |
268 | rtext += "\n"; | 269 | rtext += "\n"; |
269 | 270 | ||
270 | QString prefix; | 271 | QString prefix; |
271 | if ( m_mail[1].find(QRegExp("^Re: *$")) != -1) prefix = ""; | 272 | if ( m_mail[1].find(QRegExp("^Re: *$")) != -1) prefix = ""; |
272 | else prefix = "Re: "; // no i18n on purpose | 273 | else prefix = "Re: "; // no i18n on purpose |
273 | 274 | ||
274 | Settings *settings = new Settings(); | 275 | Settings *settings = new Settings(); |
275 | ComposeMail composer( settings ,this, 0, true); | 276 | ComposeMail composer( settings ,this, 0, true); |
276 | composer.setTo( m_mail[0] ); | 277 | composer.setTo( m_mail[0] ); |
277 | composer.setSubject( "Re: " + m_mail[1] ); | 278 | composer.setSubject( "Re: " + m_mail[1] ); |
278 | composer.setMessage( rtext ); | 279 | composer.setMessage( rtext ); |
279 | composer.showMaximized(); | 280 | composer.showMaximized(); |
280 | composer.exec(); | 281 | composer.exec(); |
281 | 282 | ||
282 | } | 283 | } |
283 | 284 | ||
284 | void ViewMail::slotForward() | 285 | void ViewMail::slotForward() |
285 | { | 286 | { |
286 | if (!m_gotBody) { | 287 | if (!m_gotBody) { |
287 | QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot forward yet."), tr("Ok")); | 288 | QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot forward yet."), tr("Ok")); |
288 | return; | 289 | return; |
289 | } | 290 | } |
290 | 291 | ||
291 | QString ftext; | 292 | QString ftext; |
292 | ftext += QString("\n----- Forwarded message from %1 -----\n\n") | 293 | ftext += QString("\n----- Forwarded message from %1 -----\n\n") |
293 | .arg( m_mail[0] ); | 294 | .arg( m_mail[0] ); |
294 | if (!m_mail[3].isNull()) | 295 | if (!m_mail[3].isNull()) |
295 | ftext += QString("Date: %1\n") | 296 | ftext += QString("Date: %1\n") |
296 | .arg( m_mail[3] ); | 297 | .arg( m_mail[3] ); |
297 | if (!m_mail[0].isNull()) | 298 | if (!m_mail[0].isNull()) |
298 | ftext += QString("From: %1\n") | 299 | ftext += QString("From: %1\n") |
299 | .arg( m_mail[0] ); | 300 | .arg( m_mail[0] ); |
300 | if (!m_mail[1].isNull()) | 301 | if (!m_mail[1].isNull()) |
301 | ftext += QString("Subject: %1\n") | 302 | ftext += QString("Subject: %1\n") |
302 | .arg( m_mail[1] ); | 303 | .arg( m_mail[1] ); |
303 | 304 | ||
304 | ftext += QString("\n%1\n") | 305 | ftext += QString("\n%1\n") |
305 | .arg( m_mail[2]); | 306 | .arg( m_mail[2]); |
306 | 307 | ||
307 | ftext += QString("----- End forwarded message -----\n"); | 308 | ftext += QString("----- End forwarded message -----\n"); |
308 | 309 | ||
309 | Settings *settings = new Settings(); | 310 | Settings *settings = new Settings(); |
310 | ComposeMail composer( settings ,this, 0, true); | 311 | ComposeMail composer( settings ,this, 0, true); |
311 | composer.setSubject( "Fwd: " + m_mail[1] ); | 312 | composer.setSubject( "Fwd: " + m_mail[1] ); |
312 | composer.setMessage( ftext ); | 313 | composer.setMessage( ftext ); |
313 | composer.showMaximized(); | 314 | composer.showMaximized(); |
314 | composer.exec(); | 315 | composer.exec(); |
315 | } | 316 | } |
316 | 317 | ||