author | harlekin <harlekin> | 2003-12-09 18:02:33 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2003-12-09 18:02:33 (UTC) |
commit | 0b7d74768f00be986f44bfbd61a6342fc854cc3a (patch) (unidiff) | |
tree | 2e314f0d73e3c720783618870fb6d2e16b4acf3e | |
parent | a30efc4ca72e7689ee35b178d28db82054431fe9 (diff) | |
download | opie-0b7d74768f00be986f44bfbd61a6342fc854cc3a.zip opie-0b7d74768f00be986f44bfbd61a6342fc854cc3a.tar.gz opie-0b7d74768f00be986f44bfbd61a6342fc854cc3a.tar.bz2 |
more updates
-rw-r--r-- | noncore/net/mail/mainwindow.cpp | 28 | ||||
-rw-r--r-- | noncore/net/mail/mainwindow.h | 3 | ||||
-rw-r--r-- | noncore/net/mail/viewmail.cpp | 39 | ||||
-rw-r--r-- | noncore/net/mail/viewmail.h | 12 |
4 files changed, 58 insertions, 24 deletions
diff --git a/noncore/net/mail/mainwindow.cpp b/noncore/net/mail/mainwindow.cpp index b25db97..f19f93d 100644 --- a/noncore/net/mail/mainwindow.cpp +++ b/noncore/net/mail/mainwindow.cpp | |||
@@ -1,177 +1,185 @@ | |||
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 | 8 | ||
9 | #include "defines.h" | 9 | #include "defines.h" |
10 | #include "mainwindow.h" | 10 | #include "mainwindow.h" |
11 | #include "viewmail.h" | 11 | #include "viewmail.h" |
12 | #include "mailtypes.h" | 12 | #include "mailtypes.h" |
13 | #include "mailistviewitem.h" | 13 | #include "mailistviewitem.h" |
14 | 14 | ||
15 | MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags ) | 15 | MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags ) |
16 | : QMainWindow( parent, name, flags ) | 16 | : QMainWindow( parent, name, flags ) |
17 | { | 17 | { |
18 | setCaption( tr( "Opie-Mail" ) ); | 18 | setCaption( tr( "Opie-Mail" ) ); |
19 | setToolBarsMovable( false ); | 19 | setToolBarsMovable( false ); |
20 | 20 | ||
21 | toolBar = new QToolBar( this ); | 21 | toolBar = new QToolBar( this ); |
22 | menuBar = new QMenuBar( toolBar ); | 22 | menuBar = new QMenuBar( toolBar ); |
23 | mailMenu = new QPopupMenu( menuBar ); | 23 | mailMenu = new QPopupMenu( menuBar ); |
24 | menuBar->insertItem( tr( "Mail" ), mailMenu ); | 24 | menuBar->insertItem( tr( "Mail" ), mailMenu ); |
25 | settingsMenu = new QPopupMenu( menuBar ); | 25 | settingsMenu = new QPopupMenu( menuBar ); |
26 | menuBar->insertItem( tr( "Settings" ), settingsMenu ); | 26 | menuBar->insertItem( tr( "Settings" ), settingsMenu ); |
27 | 27 | ||
28 | addToolBar( toolBar ); | 28 | addToolBar( toolBar ); |
29 | toolBar->setHorizontalStretchable( true ); | 29 | toolBar->setHorizontalStretchable( true ); |
30 | 30 | ||
31 | QLabel *spacer = new QLabel( toolBar ); | 31 | QLabel *spacer = new QLabel( toolBar ); |
32 | spacer->setBackgroundMode( QWidget::PaletteButton ); | 32 | spacer->setBackgroundMode( QWidget::PaletteButton ); |
33 | toolBar->setStretchableWidget( spacer ); | 33 | toolBar->setStretchableWidget( spacer ); |
34 | 34 | ||
35 | composeMail = new QAction( tr( "Compose new mail" ), ICON_COMPOSEMAIL, | 35 | composeMail = new QAction( tr( "Compose new mail" ), ICON_COMPOSEMAIL, |
36 | 0, 0, this ); | 36 | 0, 0, this ); |
37 | composeMail->addTo( toolBar ); | 37 | composeMail->addTo( toolBar ); |
38 | composeMail->addTo( mailMenu ); | 38 | composeMail->addTo( mailMenu ); |
39 | 39 | ||
40 | sendQueued = new QAction( tr( "Send queued mails" ), ICON_SENDQUEUED, | 40 | sendQueued = new QAction( tr( "Send queued mails" ), ICON_SENDQUEUED, |
41 | 0, 0, this ); | 41 | 0, 0, this ); |
42 | sendQueued->addTo( toolBar ); | 42 | sendQueued->addTo( toolBar ); |
43 | sendQueued->addTo( mailMenu ); | 43 | sendQueued->addTo( mailMenu ); |
44 | 44 | ||
45 | syncFolders = new QAction( tr( "Sync mailfolders" ), ICON_SYNC, | 45 | syncFolders = new QAction( tr( "Sync mailfolders" ), ICON_SYNC, |
46 | 0, 0, this ); | 46 | 0, 0, this ); |
47 | syncFolders->addTo( toolBar ); | 47 | syncFolders->addTo( toolBar ); |
48 | syncFolders->addTo( mailMenu ); | 48 | syncFolders->addTo( mailMenu ); |
49 | 49 | ||
50 | showFolders = new QAction( tr( "Show/Hide folders" ), ICON_SHOWFOLDERS, | 50 | showFolders = new QAction( tr( "Show/Hide folders" ), ICON_SHOWFOLDERS, |
51 | 0, 0, this, 0, true ); | 51 | 0, 0, this, 0, true ); |
52 | showFolders->addTo( toolBar ); | 52 | showFolders->addTo( toolBar ); |
53 | showFolders->addTo( mailMenu ); | 53 | showFolders->addTo( mailMenu ); |
54 | connect(showFolders, SIGNAL( toggled( bool ) ), | 54 | connect(showFolders, SIGNAL( toggled( bool ) ), |
55 | SLOT( slotShowFolders( bool ) ) ); | 55 | SLOT( slotShowFolders( bool ) ) ); |
56 | 56 | ||
57 | searchMails = new QAction( tr( "Search mails" ), ICON_SEARCHMAILS, | 57 | searchMails = new QAction( tr( "Search mails" ), ICON_SEARCHMAILS, |
58 | 0, 0, this ); | 58 | 0, 0, this ); |
59 | searchMails->addTo( toolBar ); | 59 | searchMails->addTo( toolBar ); |
60 | searchMails->addTo( mailMenu ); | 60 | searchMails->addTo( mailMenu ); |
61 | 61 | ||
62 | 62 | ||
63 | editSettings = new QAction( tr( "Edit settings" ), ICON_EDITSETTINGS, | 63 | editSettings = new QAction( tr( "Edit settings" ), ICON_EDITSETTINGS, |
64 | 0, 0, this ); | 64 | 0, 0, this ); |
65 | editSettings->addTo( settingsMenu ); | 65 | editSettings->addTo( settingsMenu ); |
66 | 66 | ||
67 | editAccounts = new QAction( tr( "Configure accounts" ), ICON_EDITACCOUNTS, | 67 | editAccounts = new QAction( tr( "Configure accounts" ), ICON_EDITACCOUNTS, |
68 | 0, 0, this ); | 68 | 0, 0, this ); |
69 | editAccounts->addTo( settingsMenu ); | 69 | editAccounts->addTo( settingsMenu ); |
70 | 70 | ||
71 | QWidget *view = new QWidget( this ); | 71 | QWidget *view = new QWidget( this ); |
72 | setCentralWidget( view ); | 72 | setCentralWidget( view ); |
73 | 73 | ||
74 | 74 | layout = new QBoxLayout ( view, QBoxLayout::LeftToRight ); | |
75 | QWidget *d = QApplication::desktop(); | ||
76 | QBoxLayout *layout; | ||
77 | |||
78 | if ( d->width() < d->height() ) { | ||
79 | layout = new QVBoxLayout( view ); | ||
80 | } else { | ||
81 | layout = new QHBoxLayout( view ); | ||
82 | } | ||
83 | 75 | ||
84 | folderView = new AccountView( view ); | 76 | folderView = new AccountView( view ); |
85 | folderView->header()->hide(); | 77 | folderView->header()->hide(); |
86 | folderView->addColumn( tr( "Mailbox" ) ); | 78 | folderView->addColumn( tr( "Mailbox" ) ); |
87 | folderView->hide(); | 79 | folderView->hide(); |
88 | 80 | ||
89 | layout->addWidget( folderView ); | 81 | layout->addWidget( folderView ); |
90 | 82 | ||
91 | mailView = new QListView( view ); | 83 | mailView = new QListView( view ); |
92 | mailView->addColumn( tr( "Subject" ),QListView::Manual ); | 84 | mailView->addColumn( tr( "Subject" ),QListView::Manual ); |
93 | mailView->addColumn( tr( "Sender" ),QListView::Manual ); | 85 | mailView->addColumn( tr( "Sender" ),QListView::Manual ); |
94 | mailView->addColumn( tr( "Date" )); | 86 | mailView->addColumn( tr( "Date" )); |
95 | mailView->setAllColumnsShowFocus(true); | 87 | mailView->setAllColumnsShowFocus(true); |
96 | mailView->setSorting(-1); | 88 | mailView->setSorting(-1); |
97 | 89 | ||
98 | layout->addWidget( mailView ); | 90 | layout->addWidget( mailView ); |
99 | layout->setStretchFactor( folderView, 1 ); | 91 | layout->setStretchFactor( folderView, 1 ); |
100 | layout->setStretchFactor( mailView, 2 ); | 92 | layout->setStretchFactor( mailView, 2 ); |
101 | 93 | ||
94 | slotAdjustLayout(); | ||
95 | |||
102 | connect( mailView, SIGNAL( clicked( QListViewItem * ) ),this, | 96 | connect( mailView, SIGNAL( clicked( QListViewItem * ) ),this, |
103 | SLOT( displayMail( QListViewItem * ) ) ); | 97 | SLOT( displayMail( QListViewItem * ) ) ); |
104 | 98 | ||
105 | connect(folderView,SIGNAL(refreshMailview(QList<RecMail>*)),this,SLOT(refreshMailView(QList<RecMail>*))); | 99 | connect(folderView,SIGNAL(refreshMailview(QList<RecMail>*)),this,SLOT(refreshMailView(QList<RecMail>*))); |
106 | 100 | ||
107 | QTimer::singleShot( 1000, this, SLOT( slotAdjustColumns() ) ); | 101 | QTimer::singleShot( 1000, this, SLOT( slotAdjustColumns() ) ); |
108 | } | 102 | } |
109 | 103 | ||
104 | |||
105 | void MainWindow::slotAdjustLayout() { | ||
106 | |||
107 | QWidget *d = QApplication::desktop(); | ||
108 | |||
109 | if ( d->width() < d->height() ) { | ||
110 | layout->setDirection( QBoxLayout::TopToBottom ); | ||
111 | } else { | ||
112 | layout->setDirection( QBoxLayout::LeftToRight ); | ||
113 | } | ||
114 | delete d; | ||
115 | } | ||
116 | |||
110 | void MainWindow::slotAdjustColumns() | 117 | void MainWindow::slotAdjustColumns() |
111 | { | 118 | { |
112 | bool hidden = folderView->isHidden(); | 119 | bool hidden = folderView->isHidden(); |
113 | if ( hidden ) folderView->show(); | 120 | if ( hidden ) folderView->show(); |
114 | folderView->setColumnWidth( 0, folderView->visibleWidth() ); | 121 | folderView->setColumnWidth( 0, folderView->visibleWidth() ); |
115 | if ( hidden ) folderView->hide(); | 122 | if ( hidden ) folderView->hide(); |
116 | 123 | ||
117 | mailView->setColumnWidth( 0, mailView->visibleWidth() - 130 ); | 124 | mailView->setColumnWidth( 0, mailView->visibleWidth() - 130 ); |
118 | mailView->setColumnWidth( 1, 80 ); | 125 | mailView->setColumnWidth( 1, 80 ); |
119 | mailView->setColumnWidth( 2, 50 ); | 126 | mailView->setColumnWidth( 2, 50 ); |
120 | } | 127 | } |
121 | 128 | ||
122 | void MainWindow::slotShowFolders( bool show ) | 129 | void MainWindow::slotShowFolders( bool show ) |
123 | { | 130 | { |
124 | qDebug( "Show Folders" ); | 131 | qDebug( "Show Folders" ); |
125 | if ( show && folderView->isHidden() ) { | 132 | if ( show && folderView->isHidden() ) { |
126 | qDebug( "-> showing" ); | 133 | qDebug( "-> showing" ); |
127 | folderView->show(); | 134 | folderView->show(); |
128 | } else if ( !show && !folderView->isHidden() ) { | 135 | } else if ( !show && !folderView->isHidden() ) { |
129 | qDebug( "-> hiding" ); | 136 | qDebug( "-> hiding" ); |
130 | folderView->hide(); | 137 | folderView->hide(); |
131 | } | 138 | } |
132 | } | 139 | } |
133 | 140 | ||
134 | void MainWindow::refreshMailView(QList<RecMail>*list) | 141 | void MainWindow::refreshMailView(QList<RecMail>*list) |
135 | { | 142 | { |
136 | MailListViewItem*item = 0; | 143 | MailListViewItem*item = 0; |
137 | mailView->clear(); | 144 | mailView->clear(); |
138 | for (unsigned int i = 0; i < list->count();++i) { | 145 | for (unsigned int i = 0; i < list->count();++i) { |
139 | item = new MailListViewItem(mailView,item); | 146 | item = new MailListViewItem(mailView,item); |
140 | item->storeData(*(list->at(i))); | 147 | item->storeData(*(list->at(i))); |
141 | item->showEntry(); | 148 | item->showEntry(); |
142 | } | 149 | } |
143 | } | 150 | } |
144 | void MainWindow::displayMail(QListViewItem*item) | 151 | void MainWindow::displayMail(QListViewItem*item) |
145 | { | 152 | { |
146 | if (!item) return; | 153 | if (!item) return; |
147 | qDebug("View mail"); | 154 | qDebug("View mail"); |
148 | RecMail mail = ((MailListViewItem*)item)->data(); | 155 | RecMail mail = ((MailListViewItem*)item)->data(); |
149 | RecBody body = folderView->fetchBody(mail); | 156 | RecBody body = folderView->fetchBody(mail); |
150 | 157 | ||
151 | ViewMail readMail( this ); | 158 | ViewMail readMail( this ); |
152 | readMail.setMailInfo( mail.getFrom(), "", mail.getSubject(), "", "", body.Bodytext() ); | 159 | |
160 | readMail.setMailInfo( mail.getFrom(), mail.To(), mail.getSubject(), mail.CC(), mail.Bcc(), mail.getDate(), body.Bodytext() ); | ||
153 | readMail.showMaximized(); | 161 | readMail.showMaximized(); |
154 | readMail.exec(); | 162 | readMail.exec(); |
155 | } | 163 | } |
156 | 164 | ||
157 | MailListViewItem::MailListViewItem(QListView * parent, MailListViewItem * after ) | 165 | MailListViewItem::MailListViewItem(QListView * parent, MailListViewItem * after ) |
158 | :QListViewItem(parent,after),mail_data() | 166 | :QListViewItem(parent,after),mail_data() |
159 | { | 167 | { |
160 | } | 168 | } |
161 | 169 | ||
162 | void MailListViewItem::showEntry() | 170 | void MailListViewItem::showEntry() |
163 | { | 171 | { |
164 | setText(0,mail_data.getSubject()); | 172 | setText(0,mail_data.getSubject()); |
165 | setText(1,mail_data.getFrom()); | 173 | setText(1,mail_data.getFrom()); |
166 | setText(2,mail_data.getDate()); | 174 | setText(2,mail_data.getDate()); |
167 | } | 175 | } |
168 | 176 | ||
169 | void MailListViewItem::storeData(const RecMail&data) | 177 | void MailListViewItem::storeData(const RecMail&data) |
170 | { | 178 | { |
171 | mail_data = data; | 179 | mail_data = data; |
172 | } | 180 | } |
173 | 181 | ||
174 | const RecMail& MailListViewItem::data()const | 182 | const RecMail& MailListViewItem::data()const |
175 | { | 183 | { |
176 | return mail_data; | 184 | return mail_data; |
177 | } | 185 | } |
diff --git a/noncore/net/mail/mainwindow.h b/noncore/net/mail/mainwindow.h index 6c87261..6c1cda0 100644 --- a/noncore/net/mail/mainwindow.h +++ b/noncore/net/mail/mainwindow.h | |||
@@ -1,41 +1,42 @@ | |||
1 | #ifndef MAINWINDOW_H | 1 | #ifndef MAINWINDOW_H |
2 | #define MAINWINDOW_H | 2 | #define MAINWINDOW_H |
3 | 3 | ||
4 | #include <qmainwindow.h> | 4 | #include <qmainwindow.h> |
5 | #include <qlistview.h> | 5 | #include <qlistview.h> |
6 | #include <qaction.h> | 6 | #include <qaction.h> |
7 | 7 | ||
8 | #include <qtoolbar.h> | 8 | #include <qtoolbar.h> |
9 | #include <qmenubar.h> | 9 | #include <qmenubar.h> |
10 | 10 | ||
11 | #include "accountview.h" | 11 | #include "accountview.h" |
12 | 12 | ||
13 | class RecMail; | 13 | class RecMail; |
14 | 14 | ||
15 | class MainWindow : public QMainWindow | 15 | class MainWindow : public QMainWindow |
16 | { | 16 | { |
17 | Q_OBJECT | 17 | Q_OBJECT |
18 | 18 | ||
19 | public: | 19 | public: |
20 | MainWindow( QWidget *parent = 0, const char *name = 0, WFlags flags = 0 ); | 20 | MainWindow( QWidget *parent = 0, const char *name = 0, WFlags flags = 0 ); |
21 | 21 | ||
22 | public slots: | 22 | public slots: |
23 | void slotAdjustColumns(); | 23 | void slotAdjustColumns(); |
24 | 24 | ||
25 | protected slots: | 25 | protected slots: |
26 | virtual void slotShowFolders( bool show ); | 26 | virtual void slotShowFolders( bool show ); |
27 | virtual void refreshMailView(QList<RecMail>*); | 27 | virtual void refreshMailView(QList<RecMail>*); |
28 | virtual void displayMail(QListViewItem*); | 28 | virtual void displayMail(QListViewItem*); |
29 | void slotAdjustLayout(); | ||
29 | 30 | ||
30 | protected: | 31 | protected: |
31 | QToolBar *toolBar; | 32 | QToolBar *toolBar; |
32 | QMenuBar *menuBar; | 33 | QMenuBar *menuBar; |
33 | QPopupMenu *mailMenu, *settingsMenu; | 34 | QPopupMenu *mailMenu, *settingsMenu; |
34 | QAction *composeMail, *sendQueued, *showFolders, *searchMails, | 35 | QAction *composeMail, *sendQueued, *showFolders, *searchMails, |
35 | *editSettings, *editAccounts, *syncFolders; | 36 | *editSettings, *editAccounts, *syncFolders; |
36 | AccountView *folderView; | 37 | AccountView *folderView; |
37 | QListView *mailView; | 38 | QListView *mailView; |
38 | 39 | QBoxLayout *layout; | |
39 | }; | 40 | }; |
40 | 41 | ||
41 | #endif | 42 | #endif |
diff --git a/noncore/net/mail/viewmail.cpp b/noncore/net/mail/viewmail.cpp index b648b34..cba9948 100644 --- a/noncore/net/mail/viewmail.cpp +++ b/noncore/net/mail/viewmail.cpp | |||
@@ -1,216 +1,231 @@ | |||
1 | #include <qtextbrowser.h> | 1 | #include <qtextbrowser.h> |
2 | #include <qmessagebox.h> | 2 | #include <qmessagebox.h> |
3 | #include <qaction.h> | 3 | #include <qaction.h> |
4 | #include <qapplication.h> | 4 | #include <qapplication.h> |
5 | 5 | ||
6 | //#include "mailfactory.h" | 6 | //#include "mailfactory.h" |
7 | //#include "composer.h" | 7 | //#include "composer.h" |
8 | #include "viewmail.h" | 8 | #include "viewmail.h" |
9 | 9 | ||
10 | AttachItem::AttachItem(QListView *parent, AttachItemStore &attachItemStore) | 10 | AttachItem::AttachItem(QListView *parent, AttachItemStore &attachItemStore) |
11 | : QListViewItem(parent), _attachItemStore(attachItemStore) | 11 | : QListViewItem(parent), _attachItemStore(attachItemStore) |
12 | { | 12 | { |
13 | setText(0, _attachItemStore.mimeType()); | 13 | setText(0, _attachItemStore.mimeType()); |
14 | setText(1, _attachItemStore.fileName()); | 14 | setText(1, _attachItemStore.fileName()); |
15 | setText(2, _attachItemStore.description()); | 15 | setText(2, _attachItemStore.description()); |
16 | } | 16 | } |
17 | 17 | ||
18 | AttachItem::AttachItem(QListViewItem *parent, AttachItemStore &attachItemStore) | 18 | AttachItem::AttachItem(QListViewItem *parent, AttachItemStore &attachItemStore) |
19 | : QListViewItem(parent), _attachItemStore(attachItemStore) | 19 | : QListViewItem(parent), _attachItemStore(attachItemStore) |
20 | { | 20 | { |
21 | setText(0, _attachItemStore.mimeType()); | 21 | setText(0, _attachItemStore.mimeType()); |
22 | setText(1, _attachItemStore.fileName()); | 22 | setText(1, _attachItemStore.fileName()); |
23 | setText(2, _attachItemStore.description()); | 23 | setText(2, _attachItemStore.description()); |
24 | } | 24 | } |
25 | 25 | ||
26 | void ViewMail::setMailInfo( const QString & from, const QString & to, const QString & subject, const QString & cc, const QString & bcc, const QString & bodytext ) { | 26 | void ViewMail::setMailInfo( const QString & from, const QStringList & to, const QString & subject, const QStringList & cc, const QStringList & bcc, const QString & date, const QString & bodytext ) { |
27 | 27 | ||
28 | m_mail[0] = from; | 28 | m_mail[0] = from; |
29 | m_mail[1] = to; | 29 | m_mail2[0] = to; |
30 | m_mail[2] = subject; | 30 | m_mail[1] = subject; |
31 | m_mail[3] = cc; | 31 | m_mail2[1] = cc; |
32 | m_mail[4] = bcc; | 32 | m_mail2[2] = bcc; |
33 | m_mail[5] = bodytext; | 33 | m_mail[2] = bodytext; |
34 | m_mail[3] = date; | ||
34 | 35 | ||
35 | setText(); | 36 | setText(); |
36 | 37 | ||
37 | } | 38 | } |
38 | 39 | ||
39 | 40 | ||
40 | ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl) | 41 | ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl) |
41 | : ViewMailBase(parent, name, fl), _inLoop(false) | 42 | : ViewMailBase(parent, name, fl), _inLoop(false) |
42 | { | 43 | { |
43 | _gotBody = false; | 44 | _gotBody = false; |
44 | 45 | ||
45 | connect(reply, SIGNAL(activated()), SLOT(slotReply())); | 46 | connect(reply, SIGNAL(activated()), SLOT(slotReply())); |
46 | connect(forward, SIGNAL(activated()), SLOT(slotForward())); | 47 | connect(forward, SIGNAL(activated()), SLOT(slotForward())); |
47 | 48 | ||
48 | attachments->setEnabled(_gotBody); | 49 | attachments->setEnabled(_gotBody); |
49 | 50 | ||
50 | //_handler->iUid("FETCH", QString("%1 (BODY[1])").arg(mail.uid())); | 51 | //_handler->iUid("FETCH", QString("%1 (BODY[1])").arg(mail.uid())); |
51 | //connect(_handler, SIGNAL(gotResponse(IMAPResponse &)), SLOT(slotIMAPUid(IMAPResponse &))); | 52 | //connect(_handler, SIGNAL(gotResponse(IMAPResponse &)), SLOT(slotIMAPUid(IMAPResponse &))); |
52 | } | 53 | } |
53 | 54 | ||
54 | void ViewMail::setText() | 55 | void ViewMail::setText() |
55 | { | 56 | { |
56 | 57 | ||
58 | QString toString; | ||
59 | QString ccString; | ||
60 | QString bccString; | ||
61 | |||
62 | for ( QStringList::Iterator it = ( m_mail2[0] ).begin(); it != ( m_mail2[0] ).end(); ++it ) { | ||
63 | toString += (*it); | ||
64 | } | ||
65 | for ( QStringList::Iterator it = ( m_mail2[1] ).begin(); it != ( m_mail2[1] ).end(); ++it ) { | ||
66 | ccString += (*it); | ||
67 | } | ||
68 | for ( QStringList::Iterator it = ( m_mail2[2] ).begin(); it != ( m_mail2[2] ).end(); ++it ) { | ||
69 | bccString += (*it); | ||
70 | } | ||
71 | |||
57 | setCaption( caption().arg( m_mail[0] ) ); | 72 | setCaption( caption().arg( m_mail[0] ) ); |
58 | 73 | ||
59 | _mailHtml = tr( | 74 | _mailHtml = tr( |
60 | "<html><body>" | 75 | "<html><body>" |
61 | "<div align=center><b>%1</b></div>" | 76 | "<div align=center><b>%1</b></div>" |
62 | "<b>From:</b> %2<br>" | 77 | "<b>From:</b> %2<br>" |
63 | "<b>To:</b> %3<br>" | 78 | "<b>To:</b> %3<br>" |
64 | "%4" | 79 | "%4" |
65 | "%5" | 80 | "%5" |
66 | "<b>Date:</b> %6<hr>" | 81 | "<b>Date:</b> %6<hr>" |
67 | "<font face=fixed>%7</font>") | 82 | "<font face=fixed>%7</font>") |
68 | .arg( deHtml( m_mail[2] ) ) | ||
69 | .arg( deHtml( m_mail[0] ) ) | ||
70 | .arg( deHtml( m_mail[1] ) ) | 83 | .arg( deHtml( m_mail[1] ) ) |
71 | .arg( tr("<b>Cc:</b> %1<br>").arg( deHtml( m_mail[3] ) ) ) | 84 | .arg( deHtml( m_mail[0] ) ) |
72 | .arg( tr("<b>Bcc:</b> %1<br>").arg( deHtml( m_mail[4] ) ) ) | 85 | .arg( deHtml( toString ) ) |
73 | .arg( tr("(no date)" ) ) | 86 | .arg( tr("<b>Cc:</b> %1<br>").arg( deHtml( ccString ) ) ) |
87 | .arg( tr("<b>Bcc:</b> %1<br>").arg( deHtml( bccString ) ) ) | ||
88 | .arg( m_mail[3] ) | ||
74 | .arg("%1"); | 89 | .arg("%1"); |
75 | browser->setText( QString(_mailHtml) + deHtml( m_mail[5] ) ); | 90 | browser->setText( QString(_mailHtml) + deHtml( m_mail[2] ) ); |
76 | } | 91 | } |
77 | 92 | ||
78 | 93 | ||
79 | 94 | ||
80 | ViewMail::~ViewMail() | 95 | ViewMail::~ViewMail() |
81 | { | 96 | { |
82 | hide(); | 97 | hide(); |
83 | } | 98 | } |
84 | 99 | ||
85 | void ViewMail::hide() | 100 | void ViewMail::hide() |
86 | { | 101 | { |
87 | QWidget::hide(); | 102 | QWidget::hide(); |
88 | 103 | ||
89 | if (_inLoop) { | 104 | if (_inLoop) { |
90 | _inLoop = false; | 105 | _inLoop = false; |
91 | qApp->exit_loop(); | 106 | qApp->exit_loop(); |
92 | } | 107 | } |
93 | } | 108 | } |
94 | 109 | ||
95 | void ViewMail::exec() | 110 | void ViewMail::exec() |
96 | { | 111 | { |
97 | show(); | 112 | show(); |
98 | 113 | ||
99 | if (!_inLoop) { | 114 | if (!_inLoop) { |
100 | _inLoop = true; | 115 | _inLoop = true; |
101 | qApp->enter_loop(); | 116 | qApp->enter_loop(); |
102 | } | 117 | } |
103 | } | 118 | } |
104 | 119 | ||
105 | QString ViewMail::deHtml(const QString &string) | 120 | QString ViewMail::deHtml(const QString &string) |
106 | { | 121 | { |
107 | QString string_ = string; | 122 | QString string_ = string; |
108 | string_.replace(QRegExp("&"), "&"); | 123 | string_.replace(QRegExp("&"), "&"); |
109 | string_.replace(QRegExp("<"), "<"); | 124 | string_.replace(QRegExp("<"), "<"); |
110 | string_.replace(QRegExp(">"), ">"); | 125 | string_.replace(QRegExp(">"), ">"); |
111 | string_.replace(QRegExp("\\n"), "<br>"); | 126 | string_.replace(QRegExp("\\n"), "<br>"); |
112 | return string_; | 127 | return string_; |
113 | } | 128 | } |
114 | 129 | ||
115 | void ViewMail::slotReply() | 130 | void ViewMail::slotReply() |
116 | { | 131 | { |
117 | if (!_gotBody) { | 132 | if (!_gotBody) { |
118 | QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot reply yet."), tr("Ok")); | 133 | QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot reply yet."), tr("Ok")); |
119 | return; | 134 | return; |
120 | } | 135 | } |
121 | 136 | ||
122 | QString rtext; | 137 | QString rtext; |
123 | // rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose | 138 | // rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose |
124 | // .arg(_mail.envelope().from()[0].toString()) | 139 | // .arg(_mail.envelope().from()[0].toString()) |
125 | // .arg(_mail.envelope().mailDate()); | 140 | // .arg(_mail.envelope().mailDate()); |
126 | 141 | ||
127 | //QString text = _mail.bodyPart(1).data(); | 142 | //QString text = _mail.bodyPart(1).data(); |
128 | //QStringList lines = QStringList::split(QRegExp("\\n"), text); | 143 | //QStringList lines = QStringList::split(QRegExp("\\n"), text); |
129 | QStringList::Iterator it; | 144 | QStringList::Iterator it; |
130 | //for (it = lines.begin(); it != lines.end(); it++) { | 145 | //for (it = lines.begin(); it != lines.end(); it++) { |
131 | // rtext += "> " + *it + "\n"; | 146 | // rtext += "> " + *it + "\n"; |
132 | //} | 147 | //} |
133 | rtext += "\n"; | 148 | rtext += "\n"; |
134 | 149 | ||
135 | QString prefix; | 150 | QString prefix; |
136 | //if (_mail.envelope().subject().find(QRegExp("^Re: *$")) != -1) prefix = ""; | 151 | //if (_mail.envelope().subject().find(QRegExp("^Re: *$")) != -1) prefix = ""; |
137 | // else prefix = "Re: "; // no i18n on purpose | 152 | // else prefix = "Re: "; // no i18n on purpose |
138 | 153 | ||
139 | //SendMail sendMail; | 154 | //SendMail sendMail; |
140 | //sendMail.setTo(_mail.envelope().from()[0].toString()); | 155 | //sendMail.setTo(_mail.envelope().from()[0].toString()); |
141 | //sendMail.setSubject(prefix + _mail.envelope().subject()); | 156 | //sendMail.setSubject(prefix + _mail.envelope().subject()); |
142 | //sendMail.setInReplyTo(_mail.envelope().messageId()); | 157 | //sendMail.setInReplyTo(_mail.envelope().messageId()); |
143 | //sendMail.setMessage(rtext); | 158 | //sendMail.setMessage(rtext); |
144 | 159 | ||
145 | //Composer composer(this, 0, true); | 160 | //Composer composer(this, 0, true); |
146 | //composer.setSendMail(sendMail); | 161 | //composer.setSendMail(sendMail); |
147 | //composer.showMaximized(); | 162 | //composer.showMaximized(); |
148 | //composer.exec(); | 163 | //composer.exec(); |
149 | } | 164 | } |
150 | 165 | ||
151 | void ViewMail::slotForward() | 166 | void ViewMail::slotForward() |
152 | { | 167 | { |
153 | if (!_gotBody) { | 168 | if (!_gotBody) { |
154 | QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot forward yet."), tr("Ok")); | 169 | QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot forward yet."), tr("Ok")); |
155 | return; | 170 | return; |
156 | } | 171 | } |
157 | 172 | ||
158 | QString ftext; | 173 | QString ftext; |
159 | /*ftext += QString("\n----- Forwarded message from %1 -----\n\n") | 174 | /*ftext += QString("\n----- Forwarded message from %1 -----\n\n") |
160 | .arg(_mail.envelope().from()[0].toString()); | 175 | .arg(_mail.envelope().from()[0].toString()); |
161 | if (!_mail.envelope().mailDate().isNull()) | 176 | if (!_mail.envelope().mailDate().isNull()) |
162 | ftext += QString("Date: %1\n") | 177 | ftext += QString("Date: %1\n") |
163 | .arg(_mail.envelope().mailDate()); | 178 | .arg(_mail.envelope().mailDate()); |
164 | if (!_mail.envelope().from()[0].toString().isNull()) | 179 | if (!_mail.envelope().from()[0].toString().isNull()) |
165 | ftext += QString("From: %1\n") | 180 | ftext += QString("From: %1\n") |
166 | .arg(_mail.envelope().from()[0].toString()); | 181 | .arg(_mail.envelope().from()[0].toString()); |
167 | if (!_mail.envelope().to().toString().isNull()) | 182 | if (!_mail.envelope().to().toString().isNull()) |
168 | ftext += QString("To: %1\n") | 183 | ftext += QString("To: %1\n") |
169 | .arg(_mail.envelope().to().toString()); | 184 | .arg(_mail.envelope().to().toString()); |
170 | if (!_mail.envelope().cc().toString().isNull()) | 185 | if (!_mail.envelope().cc().toString().isNull()) |
171 | ftext += QString("Cc: %1\n") | 186 | ftext += QString("Cc: %1\n") |
172 | .arg(_mail.envelope().cc().toString()); | 187 | .arg(_mail.envelope().cc().toString()); |
173 | if (!_mail.envelope().bcc().toString().isNull()) | 188 | if (!_mail.envelope().bcc().toString().isNull()) |
174 | ftext += QString("Bcc: %1\n") | 189 | ftext += QString("Bcc: %1\n") |
175 | .arg(_mail.envelope().bcc().toString()); | 190 | .arg(_mail.envelope().bcc().toString()); |
176 | if (!_mail.envelope().subject().isNull()) | 191 | if (!_mail.envelope().subject().isNull()) |
177 | ftext += QString("Subject: %1\n") | 192 | ftext += QString("Subject: %1\n") |
178 | .arg(_mail.envelope().subject()); | 193 | .arg(_mail.envelope().subject()); |
179 | 194 | ||
180 | ftext += QString("\n%1\n") | 195 | ftext += QString("\n%1\n") |
181 | .arg(_mail.bodyPart(1).data()); | 196 | .arg(_mail.bodyPart(1).data()); |
182 | 197 | ||
183 | ftext += QString("----- End forwarded message -----\n"); | 198 | ftext += QString("----- End forwarded message -----\n"); |
184 | */ | 199 | */ |
185 | /* | 200 | /* |
186 | SendMail sendMail; | 201 | SendMail sendMail; |
187 | sendMail.setSubject("Fwd: " + _mail.envelope().subject()); | 202 | sendMail.setSubject("Fwd: " + _mail.envelope().subject()); |
188 | sendMail.setMessage(ftext); | 203 | sendMail.setMessage(ftext); |
189 | 204 | ||
190 | Composer composer(this, 0, true); | 205 | Composer composer(this, 0, true); |
191 | composer.setSendMail(sendMail); | 206 | composer.setSendMail(sendMail); |
192 | composer.showMaximized(); | 207 | composer.showMaximized(); |
193 | composer.exec(); | 208 | composer.exec(); |
194 | */ | 209 | */ |
195 | } | 210 | } |
196 | 211 | ||
197 | /* | 212 | /* |
198 | void ViewMail::slotIMAPUid(IMAPResponse &response) | 213 | void ViewMail::slotIMAPUid(IMAPResponse &response) |
199 | { | 214 | { |
200 | disconnect(_handler, SIGNAL(gotResponse(IMAPResponse &)), this, SLOT(slotIMAPUid(IMAPResponse &))); | 215 | disconnect(_handler, SIGNAL(gotResponse(IMAPResponse &)), this, SLOT(slotIMAPUid(IMAPResponse &))); |
201 | 216 | ||
202 | if (response.statusResponse().status() == IMAPResponseEnums::OK) { | 217 | if (response.statusResponse().status() == IMAPResponseEnums::OK) { |
203 | QValueList<IMAPResponseBodyPart> bodyParts; | 218 | QValueList<IMAPResponseBodyPart> bodyParts; |
204 | bodyParts.append(response.FETCH()[0].bodyPart(0)); | 219 | bodyParts.append(response.FETCH()[0].bodyPart(0)); |
205 | _mail.setBodyParts(bodyParts); | 220 | _mail.setBodyParts(bodyParts); |
206 | 221 | ||
207 | browser->setText(QString(_mailHtml).arg(deHtml(response.FETCH()[0].bodyPart(0).data()))); | 222 | browser->setText(QString(_mailHtml).arg(deHtml(response.FETCH()[0].bodyPart(0).data()))); |
208 | 223 | ||
209 | // fillList(response.FETCH()[0].bodyStructure()); | 224 | // fillList(response.FETCH()[0].bodyStructure()); |
210 | 225 | ||
211 | _gotBody = true; | 226 | _gotBody = true; |
212 | } else { | 227 | } else { |
213 | QMessageBox::warning(this, tr("Error"), tr("<p>I was unable to retrieve the mail from the server. You can try again later or give up.</p>"), tr("Ok")); | 228 | QMessageBox::warning(this, tr("Error"), tr("<p>I was unable to retrieve the mail from the server. You can try again later or give up.</p>"), tr("Ok")); |
214 | } | 229 | } |
215 | } | 230 | } |
216 | */ | 231 | */ |
diff --git a/noncore/net/mail/viewmail.h b/noncore/net/mail/viewmail.h index 9d3c6e4..615939a 100644 --- a/noncore/net/mail/viewmail.h +++ b/noncore/net/mail/viewmail.h | |||
@@ -1,75 +1,85 @@ | |||
1 | #ifndef VIEWMAIL_H | 1 | #ifndef VIEWMAIL_H |
2 | #define VIEWMAIL_H | 2 | #define VIEWMAIL_H |
3 | 3 | ||
4 | #include <qlistview.h> | 4 | #include <qlistview.h> |
5 | #include <qmap.h> | 5 | #include <qmap.h> |
6 | #include <qstringlist.h> | ||
6 | 7 | ||
7 | #include "viewmailbase.h" | 8 | #include "viewmailbase.h" |
8 | //#include "imapresponse.h" | 9 | //#include "imapresponse.h" |
9 | //#include "mailtable.h" | 10 | //#include "mailtable.h" |
10 | 11 | ||
11 | class AttachItemStore | 12 | class AttachItemStore |
12 | { | 13 | { |
13 | public: | 14 | public: |
14 | void setMimeType(QString mimeType) { _mimeType = mimeType; } | 15 | void setMimeType(QString mimeType) { _mimeType = mimeType; } |
15 | QString mimeType() { return _mimeType; } | 16 | QString mimeType() { return _mimeType; } |
16 | void setFileName(QString fileName) { _fileName = fileName; } | 17 | void setFileName(QString fileName) { _fileName = fileName; } |
17 | QString fileName() { return _fileName; } | 18 | QString fileName() { return _fileName; } |
18 | void setDescription(QString description) { _description = description; } | 19 | void setDescription(QString description) { _description = description; } |
19 | QString description() { return _description; } | 20 | QString description() { return _description; } |
20 | void setPartNum(QString partNum) { _partNum = partNum; } | 21 | void setPartNum(QString partNum) { _partNum = partNum; } |
21 | QString partNum() { return _partNum; } | 22 | QString partNum() { return _partNum; } |
22 | 23 | ||
23 | private: | 24 | private: |
24 | QString _mimeType, _fileName, _description, _partNum; | 25 | QString _mimeType, _fileName, _description, _partNum; |
25 | 26 | ||
26 | }; | 27 | }; |
27 | 28 | ||
28 | class AttachItem : public QListViewItem | 29 | class AttachItem : public QListViewItem |
29 | { | 30 | { |
30 | public: | 31 | public: |
31 | AttachItem(QListView *parent, AttachItemStore &attachment); | 32 | AttachItem(QListView *parent, AttachItemStore &attachment); |
32 | AttachItem(QListViewItem *parent, AttachItemStore &attachment); | 33 | AttachItem(QListViewItem *parent, AttachItemStore &attachment); |
33 | 34 | ||
34 | AttachItemStore attachItemStore() { return _attachItemStore; } | 35 | AttachItemStore attachItemStore() { return _attachItemStore; } |
35 | 36 | ||
36 | private: | 37 | private: |
37 | AttachItemStore _attachItemStore; | 38 | AttachItemStore _attachItemStore; |
38 | 39 | ||
39 | }; | 40 | }; |
40 | 41 | ||
41 | class ViewMail : public ViewMailBase | 42 | class ViewMail : public ViewMailBase |
42 | { | 43 | { |
43 | Q_OBJECT | 44 | Q_OBJECT |
44 | 45 | ||
45 | public: | 46 | public: |
46 | ViewMail( QWidget *parent = 0, const char *name = 0, WFlags fl = Qt::WType_Modal); | 47 | ViewMail( QWidget *parent = 0, const char *name = 0, WFlags fl = Qt::WType_Modal); |
47 | ~ViewMail(); | 48 | ~ViewMail(); |
48 | 49 | ||
49 | void hide(); | 50 | void hide(); |
50 | void exec(); | 51 | void exec(); |
51 | static QString appName() { return QString::fromLatin1("mail"); } | 52 | static QString appName() { return QString::fromLatin1("mail"); } |
52 | void setMailInfo( const QString & from, const QString & to, const QString & subject, const QString & cc, const QString & bcc, const QString & bodytext ); | 53 | void setMailInfo( const QString & from, const QStringList & to, const QString & subject, const QStringList & cc, const QStringList & bcc,const QString & date, const QString & bodytext ); |
53 | 54 | ||
54 | protected: | 55 | protected: |
55 | //void fillList(IMAPResponseBODYSTRUCTURE &structure); | 56 | //void fillList(IMAPResponseBODYSTRUCTURE &structure); |
56 | QString deHtml(const QString &string); | 57 | QString deHtml(const QString &string); |
57 | 58 | ||
58 | protected slots: | 59 | protected slots: |
59 | void slotReply(); | 60 | void slotReply(); |
60 | void slotForward(); | 61 | void slotForward(); |
61 | void setText(); | 62 | void setText(); |
62 | 63 | ||
63 | //void slotIMAPUid(IMAPResponse &response); | 64 | //void slotIMAPUid(IMAPResponse &response); |
64 | 65 | ||
65 | private: | 66 | private: |
66 | bool _inLoop; | 67 | bool _inLoop; |
67 | //IMAPResponseFETCH _mail; | 68 | //IMAPResponseFETCH _mail; |
68 | //IMAPHandler *_handler; | 69 | //IMAPHandler *_handler; |
69 | QString _mailHtml; | 70 | QString _mailHtml; |
70 | bool _gotBody; | 71 | bool _gotBody; |
72 | |||
73 | // 0 from | ||
74 | // 1 subject | ||
75 | // 2 bodytext | ||
76 | // 3 date | ||
71 | QMap <int,QString> m_mail; | 77 | QMap <int,QString> m_mail; |
78 | // 0 to | ||
79 | // 1 cc | ||
80 | // 2 bcc | ||
81 | QMap <int,QStringList> m_mail2; | ||
72 | 82 | ||
73 | }; | 83 | }; |
74 | 84 | ||
75 | #endif | 85 | #endif |