author | harlekin <harlekin> | 2003-12-14 00:20:38 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2003-12-14 00:20:38 (UTC) |
commit | ff2b84787e454f8a11aaef7a4ce18941ac0d28fd (patch) (unidiff) | |
tree | 44bf51f9a3935542cdcfa5dafcc212e4f01ee8ce | |
parent | b0a71314013a3367767526b68928a7168b4ad460 (diff) | |
download | opie-ff2b84787e454f8a11aaef7a4ce18941ac0d28fd.zip opie-ff2b84787e454f8a11aaef7a4ce18941ac0d28fd.tar.gz opie-ff2b84787e454f8a11aaef7a4ce18941ac0d28fd.tar.bz2 |
deleting of mails working
-rw-r--r-- | noncore/net/mail/accountview.cpp | 26 | ||||
-rw-r--r-- | noncore/net/mail/accountview.h | 6 | ||||
-rw-r--r-- | noncore/net/mail/mainwindow.cpp | 29 | ||||
-rw-r--r-- | noncore/net/mail/mainwindow.h | 4 | ||||
-rw-r--r-- | noncore/net/mail/viewmail.cpp | 8 | ||||
-rw-r--r-- | noncore/net/mail/viewmail.h | 3 |
6 files changed, 64 insertions, 12 deletions
diff --git a/noncore/net/mail/accountview.cpp b/noncore/net/mail/accountview.cpp index 1069b9f..ac4f0e0 100644 --- a/noncore/net/mail/accountview.cpp +++ b/noncore/net/mail/accountview.cpp | |||
@@ -1,158 +1,170 @@ | |||
1 | #include "accountview.h" | 1 | #include "accountview.h" |
2 | #include "mailtypes.h" | 2 | #include "mailtypes.h" |
3 | #include "defines.h" | 3 | #include "defines.h" |
4 | 4 | ||
5 | 5 | ||
6 | /** | 6 | /** |
7 | * POP3 Account stuff | 7 | * POP3 Account stuff |
8 | */ | 8 | */ |
9 | 9 | ||
10 | POP3viewItem::POP3viewItem( POP3account *a, QListView *parent ) | 10 | POP3viewItem::POP3viewItem( POP3account *a, QListView *parent ) |
11 | : AccountViewItem( parent ) | 11 | : AccountViewItem( parent ) |
12 | { | 12 | { |
13 | account = a; | 13 | account = a; |
14 | wrapper = AbstractMail::getWrapper( account ); | 14 | wrapper = AbstractMail::getWrapper( account ); |
15 | setPixmap( 0, PIXMAP_POP3FOLDER ); | 15 | setPixmap( 0, PIXMAP_POP3FOLDER ); |
16 | setText( 0, account->getAccountName() ); | 16 | setText( 0, account->getAccountName() ); |
17 | } | 17 | } |
18 | 18 | ||
19 | POP3viewItem::~POP3viewItem() | 19 | POP3viewItem::~POP3viewItem() |
20 | { | 20 | { |
21 | delete wrapper; | 21 | delete wrapper; |
22 | } | 22 | } |
23 | 23 | ||
24 | void POP3viewItem::refresh( QList<RecMail> &target ) | 24 | void POP3viewItem::refresh( QList<RecMail> &target ) |
25 | { | 25 | { |
26 | qDebug( "POP3: refresh" ); | 26 | qDebug( "POP3: refresh" ); |
27 | wrapper->listMessages("INBOX", target ); | 27 | wrapper->listMessages("INBOX", target ); |
28 | } | 28 | } |
29 | 29 | ||
30 | 30 | ||
31 | RecBody POP3viewItem::fetchBody( const RecMail &mail ) | 31 | RecBody POP3viewItem::fetchBody( const RecMail &mail ) |
32 | { | 32 | { |
33 | qDebug( "POP3 fetchBody" ); | 33 | qDebug( "POP3 fetchBody" ); |
34 | return wrapper->fetchBody( mail ); | 34 | return wrapper->fetchBody( mail ); |
35 | } | 35 | } |
36 | 36 | ||
37 | /** | 37 | /** |
38 | * IMAP Account stuff | 38 | * IMAP Account stuff |
39 | */ | 39 | */ |
40 | 40 | ||
41 | IMAPviewItem::IMAPviewItem( IMAPaccount *a, QListView *parent ) | 41 | IMAPviewItem::IMAPviewItem( IMAPaccount *a, QListView *parent ) |
42 | : AccountViewItem( parent ) | 42 | : AccountViewItem( parent ) |
43 | { | 43 | { |
44 | account = a; | 44 | account = a; |
45 | wrapper = AbstractMail::getWrapper( account ); | 45 | wrapper = AbstractMail::getWrapper( account ); |
46 | setPixmap( 0, PIXMAP_IMAPFOLDER ); | 46 | setPixmap( 0, PIXMAP_IMAPFOLDER ); |
47 | setText( 0, account->getAccountName() ); | 47 | setText( 0, account->getAccountName() ); |
48 | setOpen( true ); | 48 | setOpen( true ); |
49 | } | 49 | } |
50 | 50 | ||
51 | IMAPviewItem::~IMAPviewItem() | 51 | IMAPviewItem::~IMAPviewItem() |
52 | { | 52 | { |
53 | delete wrapper; | 53 | delete wrapper; |
54 | } | 54 | } |
55 | 55 | ||
56 | AbstractMail *IMAPviewItem::getWrapper() | 56 | AbstractMail *IMAPviewItem::getWrapper() |
57 | { | 57 | { |
58 | return wrapper; | 58 | return wrapper; |
59 | } | 59 | } |
60 | 60 | ||
61 | void IMAPviewItem::refresh(QList<RecMail>&) | 61 | void IMAPviewItem::refresh(QList<RecMail>&) |
62 | { | 62 | { |
63 | QList<Folder> *folders = wrapper->listFolders(); | 63 | QList<Folder> *folders = wrapper->listFolders(); |
64 | 64 | ||
65 | QListViewItem *child = firstChild(); | 65 | QListViewItem *child = firstChild(); |
66 | while ( child ) { | 66 | while ( child ) { |
67 | QListViewItem *tmp = child; | 67 | QListViewItem *tmp = child; |
68 | child = child->nextSibling(); | 68 | child = child->nextSibling(); |
69 | delete tmp; | 69 | delete tmp; |
70 | } | 70 | } |
71 | 71 | ||
72 | Folder *it; | 72 | Folder *it; |
73 | for ( it = folders->first(); it; it = folders->next() ) { | 73 | for ( it = folders->first(); it; it = folders->next() ) { |
74 | (void) new IMAPfolderItem( it, this ); | 74 | (void) new IMAPfolderItem( it, this ); |
75 | } | 75 | } |
76 | } | 76 | } |
77 | 77 | ||
78 | RecBody IMAPviewItem::fetchBody(const RecMail&) | 78 | RecBody IMAPviewItem::fetchBody(const RecMail&) |
79 | { | 79 | { |
80 | return RecBody(); | 80 | return RecBody(); |
81 | } | 81 | } |
82 | 82 | ||
83 | IMAPfolderItem::~IMAPfolderItem() | 83 | IMAPfolderItem::~IMAPfolderItem() |
84 | { | 84 | { |
85 | delete folder; | 85 | delete folder; |
86 | } | 86 | } |
87 | 87 | ||
88 | IMAPfolderItem::IMAPfolderItem( Folder *folderInit, IMAPviewItem *parent ) | 88 | IMAPfolderItem::IMAPfolderItem( Folder *folderInit, IMAPviewItem *parent ) |
89 | : AccountViewItem( parent ) | 89 | : AccountViewItem( parent ) |
90 | { | 90 | { |
91 | folder = folderInit; | 91 | folder = folderInit; |
92 | imap = parent; | 92 | imap = parent; |
93 | setPixmap( 0, PIXMAP_IMAPFOLDER ); | 93 | setPixmap( 0, PIXMAP_IMAPFOLDER ); |
94 | setText( 0, folder->getDisplayName() ); | 94 | setText( 0, folder->getDisplayName() ); |
95 | } | 95 | } |
96 | 96 | ||
97 | void IMAPfolderItem::refresh(QList<RecMail>&target) | 97 | void IMAPfolderItem::refresh(QList<RecMail>&target) |
98 | { | 98 | { |
99 | imap->getWrapper()->listMessages( folder->getName(),target ); | 99 | imap->getWrapper()->listMessages( folder->getName(),target ); |
100 | } | 100 | } |
101 | 101 | ||
102 | RecBody IMAPfolderItem::fetchBody(const RecMail&aMail) | 102 | RecBody IMAPfolderItem::fetchBody(const RecMail&aMail) |
103 | { | 103 | { |
104 | return imap->getWrapper()->fetchBody(aMail); | 104 | return imap->getWrapper()->fetchBody(aMail); |
105 | } | 105 | } |
106 | 106 | ||
107 | /** | 107 | /** |
108 | * Generic stuff | 108 | * Generic stuff |
109 | */ | 109 | */ |
110 | 110 | ||
111 | AccountView::AccountView( QWidget *parent, const char *name, WFlags flags ) | 111 | AccountView::AccountView( QWidget *parent, const char *name, WFlags flags ) |
112 | : QListView( parent, name, flags ) | 112 | : QListView( parent, name, flags ) |
113 | { | 113 | { |
114 | connect( this, SIGNAL( clicked( QListViewItem * ) ), | 114 | connect( this, SIGNAL( clicked( QListViewItem * ) ), |
115 | SLOT( refresh( QListViewItem * ) ) ); | 115 | SLOT( refresh( QListViewItem * ) ) ); |
116 | } | 116 | } |
117 | 117 | ||
118 | void AccountView::populate( QList<Account> list ) | 118 | void AccountView::populate( QList<Account> list ) |
119 | { | 119 | { |
120 | clear(); | 120 | clear(); |
121 | 121 | ||
122 | Account *it; | 122 | Account *it; |
123 | for ( it = list.first(); it; it = list.next() ) { | 123 | for ( it = list.first(); it; it = list.next() ) { |
124 | if ( it->getType().compare( "IMAP" ) == 0 ) { | 124 | if ( it->getType().compare( "IMAP" ) == 0 ) { |
125 | IMAPaccount *imap = static_cast<IMAPaccount *>(it); | 125 | IMAPaccount *imap = static_cast<IMAPaccount *>(it); |
126 | qDebug( "added IMAP " + imap->getAccountName() ); | 126 | qDebug( "added IMAP " + imap->getAccountName() ); |
127 | (void) new IMAPviewItem( imap, this ); | 127 | (void) new IMAPviewItem( imap, this ); |
128 | } else if ( it->getType().compare( "POP3" ) == 0 ) { | 128 | } else if ( it->getType().compare( "POP3" ) == 0 ) { |
129 | POP3account *pop3 = static_cast<POP3account *>(it); | 129 | POP3account *pop3 = static_cast<POP3account *>(it); |
130 | qDebug( "added POP3 " + pop3->getAccountName() ); | 130 | qDebug( "added POP3 " + pop3->getAccountName() ); |
131 | (void) new POP3viewItem( pop3, this ); | 131 | (void) new POP3viewItem( pop3, this ); |
132 | } | 132 | } |
133 | } | 133 | } |
134 | } | 134 | } |
135 | 135 | ||
136 | void AccountView::refresh(QListViewItem *item) { | 136 | void AccountView::refresh(QListViewItem *item) { |
137 | |||
137 | qDebug("AccountView refresh..."); | 138 | qDebug("AccountView refresh..."); |
138 | if ( item ) { | 139 | if ( item ) { |
140 | m_currentItem = item; | ||
139 | QList<RecMail> headerlist; | 141 | QList<RecMail> headerlist; |
140 | headerlist.setAutoDelete(true); | 142 | headerlist.setAutoDelete(true); |
141 | AccountViewItem *view = static_cast<AccountViewItem *>(item); | 143 | AccountViewItem *view = static_cast<AccountViewItem *>(item); |
142 | view->refresh(headerlist); | 144 | view->refresh(headerlist); |
143 | emit refreshMailview(&headerlist); | 145 | emit refreshMailview(&headerlist); |
144 | } | 146 | } |
145 | } | 147 | } |
146 | 148 | ||
149 | void AccountView::refreshCurrent() | ||
150 | { | ||
151 | if ( !m_currentItem ) return; | ||
152 | QList<RecMail> headerlist; | ||
153 | headerlist.setAutoDelete(true); | ||
154 | AccountViewItem *view = static_cast<AccountViewItem *>(m_currentItem); | ||
155 | view->refresh(headerlist); | ||
156 | emit refreshMailview(&headerlist); | ||
157 | } | ||
158 | |||
147 | void AccountView::refreshAll() | 159 | void AccountView::refreshAll() |
148 | { | 160 | { |
149 | 161 | ||
150 | } | 162 | } |
151 | 163 | ||
152 | RecBody AccountView::fetchBody(const RecMail&aMail) | 164 | RecBody AccountView::fetchBody(const RecMail&aMail) |
153 | { | 165 | { |
154 | QListViewItem*item = selectedItem (); | 166 | QListViewItem*item = selectedItem (); |
155 | if (!item) return RecBody(); | 167 | if (!item) return RecBody(); |
156 | AccountViewItem *view = static_cast<AccountViewItem *>(item); | 168 | AccountViewItem *view = static_cast<AccountViewItem *>(item); |
157 | return view->fetchBody(aMail); | 169 | return view->fetchBody(aMail); |
158 | } | 170 | } |
diff --git a/noncore/net/mail/accountview.h b/noncore/net/mail/accountview.h index 83d49af..cdc87ce 100644 --- a/noncore/net/mail/accountview.h +++ b/noncore/net/mail/accountview.h | |||
@@ -1,85 +1,89 @@ | |||
1 | #ifndef ACCOUNTVIEW_H | 1 | #ifndef ACCOUNTVIEW_H |
2 | #define ACCOUNTVIEW_H | 2 | #define ACCOUNTVIEW_H |
3 | 3 | ||
4 | #include <qlistview.h> | 4 | #include <qlistview.h> |
5 | #include <qlist.h> | 5 | #include <qlist.h> |
6 | 6 | ||
7 | #include "settings.h" | 7 | #include "settings.h" |
8 | #include "mailwrapper.h" | 8 | #include "mailwrapper.h" |
9 | #include "abstractmail.h" | 9 | #include "abstractmail.h" |
10 | 10 | ||
11 | class POP3wrapper; | 11 | class POP3wrapper; |
12 | class RecMail; | 12 | class RecMail; |
13 | class RecBody; | 13 | class RecBody; |
14 | 14 | ||
15 | class AccountViewItem : public QListViewItem | 15 | class AccountViewItem : public QListViewItem |
16 | { | 16 | { |
17 | 17 | ||
18 | public: | 18 | public: |
19 | AccountViewItem( QListView *parent ) : QListViewItem( parent ) {} | 19 | AccountViewItem( QListView *parent ) : QListViewItem( parent ) {} |
20 | AccountViewItem( QListViewItem *parent ) : QListViewItem( parent ) {} | 20 | AccountViewItem( QListViewItem *parent ) : QListViewItem( parent ) {} |
21 | virtual void refresh(QList<RecMail>&)=0; | 21 | virtual void refresh(QList<RecMail>&)=0; |
22 | virtual RecBody fetchBody(const RecMail&)=0; | 22 | virtual RecBody fetchBody(const RecMail&)=0; |
23 | }; | 23 | }; |
24 | 24 | ||
25 | class POP3viewItem : public AccountViewItem | 25 | class POP3viewItem : public AccountViewItem |
26 | { | 26 | { |
27 | 27 | ||
28 | public: | 28 | public: |
29 | POP3viewItem( POP3account *a, QListView *parent ); | 29 | POP3viewItem( POP3account *a, QListView *parent ); |
30 | ~POP3viewItem(); | 30 | ~POP3viewItem(); |
31 | virtual void refresh( QList<RecMail> &target ); | 31 | virtual void refresh( QList<RecMail> &target ); |
32 | virtual RecBody fetchBody( const RecMail &mail ); | 32 | virtual RecBody fetchBody( const RecMail &mail ); |
33 | 33 | ||
34 | private: | 34 | private: |
35 | POP3account *account; | 35 | POP3account *account; |
36 | AbstractMail *wrapper; | 36 | AbstractMail *wrapper; |
37 | 37 | ||
38 | }; | 38 | }; |
39 | 39 | ||
40 | class IMAPviewItem : public AccountViewItem | 40 | class IMAPviewItem : public AccountViewItem |
41 | { | 41 | { |
42 | 42 | ||
43 | public: | 43 | public: |
44 | IMAPviewItem( IMAPaccount *a, QListView *parent ); | 44 | IMAPviewItem( IMAPaccount *a, QListView *parent ); |
45 | ~IMAPviewItem(); | 45 | ~IMAPviewItem(); |
46 | virtual void refresh(QList<RecMail>&); | 46 | virtual void refresh(QList<RecMail>&); |
47 | virtual RecBody fetchBody(const RecMail&); | 47 | virtual RecBody fetchBody(const RecMail&); |
48 | AbstractMail *getWrapper(); | 48 | AbstractMail *getWrapper(); |
49 | private: | 49 | private: |
50 | IMAPaccount *account; | 50 | IMAPaccount *account; |
51 | AbstractMail *wrapper; | 51 | AbstractMail *wrapper; |
52 | }; | 52 | }; |
53 | 53 | ||
54 | class IMAPfolderItem : public AccountViewItem | 54 | class IMAPfolderItem : public AccountViewItem |
55 | { | 55 | { |
56 | 56 | ||
57 | public: | 57 | public: |
58 | IMAPfolderItem( Folder *folder, IMAPviewItem *parent ); | 58 | IMAPfolderItem( Folder *folder, IMAPviewItem *parent ); |
59 | ~IMAPfolderItem(); | 59 | ~IMAPfolderItem(); |
60 | virtual void refresh(QList<RecMail>&); | 60 | virtual void refresh(QList<RecMail>&); |
61 | virtual RecBody fetchBody(const RecMail&); | 61 | virtual RecBody fetchBody(const RecMail&); |
62 | private: | 62 | private: |
63 | Folder *folder; | 63 | Folder *folder; |
64 | IMAPviewItem *imap; | 64 | IMAPviewItem *imap; |
65 | 65 | ||
66 | }; | 66 | }; |
67 | 67 | ||
68 | class AccountView : public QListView | 68 | class AccountView : public QListView |
69 | { | 69 | { |
70 | Q_OBJECT | 70 | Q_OBJECT |
71 | 71 | ||
72 | public: | 72 | public: |
73 | AccountView( QWidget *parent = 0, const char *name = 0, WFlags flags = 0 ); | 73 | AccountView( QWidget *parent = 0, const char *name = 0, WFlags flags = 0 ); |
74 | void populate( QList<Account> list ); | 74 | void populate( QList<Account> list ); |
75 | RecBody fetchBody(const RecMail&aMail); | 75 | RecBody fetchBody(const RecMail&aMail); |
76 | 76 | ||
77 | public slots: | 77 | public slots: |
78 | void refreshAll(); | 78 | void refreshAll(); |
79 | void refresh(QListViewItem *item); | 79 | void refresh(QListViewItem *item); |
80 | void refreshCurrent(); | ||
80 | 81 | ||
81 | signals: | 82 | signals: |
82 | void refreshMailview(QList<RecMail>*); | 83 | void refreshMailview(QList<RecMail>*); |
84 | |||
85 | private: | ||
86 | QListViewItem* m_currentItem; | ||
83 | }; | 87 | }; |
84 | 88 | ||
85 | #endif | 89 | #endif |
diff --git a/noncore/net/mail/mainwindow.cpp b/noncore/net/mail/mainwindow.cpp index 8ef7ddd..c410829 100644 --- a/noncore/net/mail/mainwindow.cpp +++ b/noncore/net/mail/mainwindow.cpp | |||
@@ -1,195 +1,218 @@ | |||
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 | deleteMails = new QAction(tr("Delete Mail"), QIconSet(Resource::loadPixmap("mail/delete")), 0, 0, this); | ||
64 | deleteMails->addTo( toolBar ); | ||
65 | deleteMails->addTo( mailMenu ); | ||
66 | connect( deleteMails, SIGNAL( activated() ), | ||
67 | SLOT( slotDeleteMail() ) ); | ||
63 | 68 | ||
64 | editSettings = new QAction( tr( "Edit settings" ), ICON_EDITSETTINGS, | 69 | editSettings = new QAction( tr( "Edit settings" ), ICON_EDITSETTINGS, |
65 | 0, 0, this ); | 70 | 0, 0, this ); |
66 | editSettings->addTo( settingsMenu ); | 71 | editSettings->addTo( settingsMenu ); |
67 | 72 | ||
68 | editAccounts = new QAction( tr( "Configure accounts" ), ICON_EDITACCOUNTS, | 73 | editAccounts = new QAction( tr( "Configure accounts" ), ICON_EDITACCOUNTS, |
69 | 0, 0, this ); | 74 | 0, 0, this ); |
70 | editAccounts->addTo( settingsMenu ); | 75 | editAccounts->addTo( settingsMenu ); |
71 | 76 | ||
72 | QWidget *view = new QWidget( this ); | 77 | QWidget *view = new QWidget( this ); |
73 | setCentralWidget( view ); | 78 | setCentralWidget( view ); |
74 | 79 | ||
75 | layout = new QBoxLayout ( view, QBoxLayout::LeftToRight ); | 80 | layout = new QBoxLayout ( view, QBoxLayout::LeftToRight ); |
76 | 81 | ||
77 | folderView = new AccountView( view ); | 82 | folderView = new AccountView( view ); |
78 | folderView->header()->hide(); | 83 | folderView->header()->hide(); |
79 | folderView->addColumn( tr( "Mailbox" ) ); | 84 | folderView->addColumn( tr( "Mailbox" ) ); |
80 | folderView->hide(); | 85 | folderView->hide(); |
81 | 86 | ||
82 | layout->addWidget( folderView ); | 87 | layout->addWidget( folderView ); |
83 | 88 | ||
84 | mailView = new QListView( view ); | 89 | mailView = new QListView( view ); |
85 | mailView->addColumn( tr( "" ) ); | 90 | mailView->addColumn( tr( "" ) ); |
86 | mailView->addColumn( tr( "Subject" ),QListView::Manual ); | 91 | mailView->addColumn( tr( "Subject" ),QListView::Manual ); |
87 | mailView->addColumn( tr( "Sender" ),QListView::Manual ); | 92 | mailView->addColumn( tr( "Sender" ),QListView::Manual ); |
88 | mailView->addColumn( tr( "Date" )); | 93 | mailView->addColumn( tr( "Date" )); |
89 | mailView->setAllColumnsShowFocus(true); | 94 | mailView->setAllColumnsShowFocus(true); |
90 | mailView->setSorting(-1); | 95 | mailView->setSorting(-1); |
91 | 96 | ||
92 | layout->addWidget( mailView ); | 97 | layout->addWidget( mailView ); |
93 | layout->setStretchFactor( folderView, 1 ); | 98 | layout->setStretchFactor( folderView, 1 ); |
94 | layout->setStretchFactor( mailView, 2 ); | 99 | layout->setStretchFactor( mailView, 2 ); |
95 | 100 | ||
96 | slotAdjustLayout(); | 101 | slotAdjustLayout(); |
97 | 102 | ||
98 | connect( mailView, SIGNAL( clicked( QListViewItem * ) ),this, | 103 | connect( mailView, SIGNAL( clicked( QListViewItem * ) ),this, |
99 | SLOT( displayMail( QListViewItem * ) ) ); | 104 | SLOT( displayMail( QListViewItem * ) ) ); |
100 | 105 | ||
101 | connect(folderView,SIGNAL(refreshMailview(QList<RecMail>*)),this,SLOT(refreshMailView(QList<RecMail>*))); | 106 | connect(folderView, SIGNAL(refreshMailview(QList<RecMail>*)),this,SLOT(refreshMailView(QList<RecMail>*))); |
102 | 107 | ||
103 | QTimer::singleShot( 1000, this, SLOT( slotAdjustColumns() ) ); | 108 | QTimer::singleShot( 1000, this, SLOT( slotAdjustColumns() ) ); |
104 | } | 109 | } |
105 | 110 | ||
106 | 111 | ||
107 | void MainWindow::slotAdjustLayout() { | 112 | void MainWindow::slotAdjustLayout() { |
108 | 113 | ||
109 | QWidget *d = QApplication::desktop(); | 114 | QWidget *d = QApplication::desktop(); |
110 | 115 | ||
111 | if ( d->width() < d->height() ) { | 116 | if ( d->width() < d->height() ) { |
112 | layout->setDirection( QBoxLayout::TopToBottom ); | 117 | layout->setDirection( QBoxLayout::TopToBottom ); |
113 | } else { | 118 | } else { |
114 | layout->setDirection( QBoxLayout::LeftToRight ); | 119 | layout->setDirection( QBoxLayout::LeftToRight ); |
115 | } | 120 | } |
116 | delete d; | 121 | delete d; |
117 | } | 122 | } |
118 | 123 | ||
119 | void MainWindow::slotAdjustColumns() | 124 | void MainWindow::slotAdjustColumns() |
120 | { | 125 | { |
121 | bool hidden = folderView->isHidden(); | 126 | bool hidden = folderView->isHidden(); |
122 | if ( hidden ) folderView->show(); | 127 | if ( hidden ) folderView->show(); |
123 | folderView->setColumnWidth( 0, folderView->visibleWidth() ); | 128 | folderView->setColumnWidth( 0, folderView->visibleWidth() ); |
124 | if ( hidden ) folderView->hide(); | 129 | if ( hidden ) folderView->hide(); |
125 | 130 | ||
126 | mailView->setColumnWidth( 0, 10 ); | 131 | mailView->setColumnWidth( 0, 10 ); |
127 | mailView->setColumnWidth( 1, mailView->visibleWidth() - 130 ); | 132 | mailView->setColumnWidth( 1, mailView->visibleWidth() - 130 ); |
128 | mailView->setColumnWidth( 2, 80 ); | 133 | mailView->setColumnWidth( 2, 80 ); |
129 | mailView->setColumnWidth( 3, 50 ); | 134 | mailView->setColumnWidth( 3, 50 ); |
130 | } | 135 | } |
131 | 136 | ||
132 | void MainWindow::slotShowFolders( bool show ) | 137 | void MainWindow::slotShowFolders( bool show ) |
133 | { | 138 | { |
134 | qDebug( "Show Folders" ); | 139 | qDebug( "Show Folders" ); |
135 | if ( show && folderView->isHidden() ) { | 140 | if ( show && folderView->isHidden() ) { |
136 | qDebug( "-> showing" ); | 141 | qDebug( "-> showing" ); |
137 | folderView->show(); | 142 | folderView->show(); |
138 | } else if ( !show && !folderView->isHidden() ) { | 143 | } else if ( !show && !folderView->isHidden() ) { |
139 | qDebug( "-> hiding" ); | 144 | qDebug( "-> hiding" ); |
140 | folderView->hide(); | 145 | folderView->hide(); |
141 | } | 146 | } |
142 | } | 147 | } |
143 | 148 | ||
144 | void MainWindow::refreshMailView(QList<RecMail>*list) | 149 | void MainWindow::refreshMailView(QList<RecMail>*list) |
145 | { | 150 | { |
146 | MailListViewItem*item = 0; | 151 | MailListViewItem*item = 0; |
147 | mailView->clear(); | 152 | mailView->clear(); |
148 | for (unsigned int i = 0; i < list->count();++i) { | 153 | for (unsigned int i = 0; i < list->count();++i) { |
149 | item = new MailListViewItem(mailView,item); | 154 | item = new MailListViewItem(mailView,item); |
150 | item->storeData(*(list->at(i))); | 155 | item->storeData(*(list->at(i))); |
151 | item->showEntry(); | 156 | item->showEntry(); |
152 | } | 157 | } |
153 | } | 158 | } |
154 | void MainWindow::displayMail(QListViewItem*item) | 159 | void MainWindow::displayMail(QListViewItem*item) |
155 | { | 160 | { |
161 | |||
162 | m_currentItem = item; | ||
163 | |||
156 | if (!item) return; | 164 | if (!item) return; |
157 | RecMail mail = ((MailListViewItem*)item)->data(); | 165 | RecMail mail = ((MailListViewItem*)item)->data(); |
158 | RecBody body = folderView->fetchBody(mail); | 166 | RecBody body = folderView->fetchBody(mail); |
159 | 167 | ||
160 | ViewMail readMail( this ); | 168 | ViewMail readMail( this ); |
161 | readMail.setBody( body ); | 169 | readMail.setBody( body ); |
162 | readMail.setMail( mail ); | 170 | readMail.setMail( mail ); |
163 | readMail.showMaximized(); | 171 | readMail.showMaximized(); |
164 | readMail.exec(); | 172 | readMail.exec(); |
165 | ( (MailListViewItem*)item )->setPixmap( 0, Resource::loadPixmap( "opiemail/kmmsgunseen") ); | 173 | |
174 | if ( readMail.deleted ) { | ||
175 | folderView->refreshCurrent(); | ||
176 | } else { | ||
177 | ( (MailListViewItem*)item )->setPixmap( 0, Resource::loadPixmap( "opiemail/kmmsgunseen") ); | ||
178 | } | ||
166 | } | 179 | } |
167 | 180 | ||
181 | void MainWindow::slotDeleteMail() | ||
182 | { | ||
183 | if (!m_currentItem) return; | ||
184 | RecMail mail = ((MailListViewItem*)m_currentItem)->data(); | ||
185 | mail.Wrapper()->deleteMail( mail ); | ||
186 | folderView->refreshCurrent(); | ||
187 | } | ||
188 | |||
189 | |||
190 | |||
168 | MailListViewItem::MailListViewItem(QListView * parent, MailListViewItem * item ) | 191 | MailListViewItem::MailListViewItem(QListView * parent, MailListViewItem * item ) |
169 | :QListViewItem(parent,item),mail_data() | 192 | :QListViewItem(parent,item),mail_data() |
170 | { | 193 | { |
171 | } | 194 | } |
172 | 195 | ||
173 | void MailListViewItem::showEntry() | 196 | void MailListViewItem::showEntry() |
174 | { | 197 | { |
175 | if ( mail_data.getFlags().testBit( FLAG_SEEN ) == true ) { | 198 | if ( mail_data.getFlags().testBit( FLAG_SEEN ) == true ) { |
176 | setPixmap( 0, Resource::loadPixmap( "opiemail/kmmsgunseen") ); | 199 | setPixmap( 0, Resource::loadPixmap( "opiemail/kmmsgunseen") ); |
177 | } else { | 200 | } else { |
178 | setPixmap( 0, Resource::loadPixmap( "opiemail/kmmsgnew") ); | 201 | setPixmap( 0, Resource::loadPixmap( "opiemail/kmmsgnew") ); |
179 | } | 202 | } |
180 | setText(1,mail_data.getSubject()); | 203 | setText(1,mail_data.getSubject()); |
181 | setText(2,mail_data.getFrom()); | 204 | setText(2,mail_data.getFrom()); |
182 | setText(3,mail_data.getDate()); | 205 | setText(3,mail_data.getDate()); |
183 | } | 206 | } |
184 | 207 | ||
185 | void MailListViewItem::storeData(const RecMail&data) | 208 | void MailListViewItem::storeData(const RecMail&data) |
186 | { | 209 | { |
187 | mail_data = data; | 210 | mail_data = data; |
188 | } | 211 | } |
189 | 212 | ||
190 | const RecMail& MailListViewItem::data()const | 213 | const RecMail& MailListViewItem::data()const |
191 | { | 214 | { |
192 | return mail_data; | 215 | return mail_data; |
193 | } | 216 | } |
194 | 217 | ||
195 | 218 | ||
diff --git a/noncore/net/mail/mainwindow.h b/noncore/net/mail/mainwindow.h index 6c1cda0..8641510 100644 --- a/noncore/net/mail/mainwindow.h +++ b/noncore/net/mail/mainwindow.h | |||
@@ -1,42 +1,44 @@ | |||
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 | virtual void slotDeleteMail(); | ||
29 | void slotAdjustLayout(); | 30 | void slotAdjustLayout(); |
30 | 31 | ||
31 | protected: | 32 | protected: |
32 | QToolBar *toolBar; | 33 | QToolBar *toolBar; |
33 | QMenuBar *menuBar; | 34 | QMenuBar *menuBar; |
34 | QPopupMenu *mailMenu, *settingsMenu; | 35 | QPopupMenu *mailMenu, *settingsMenu; |
35 | QAction *composeMail, *sendQueued, *showFolders, *searchMails, | 36 | QAction *composeMail, *sendQueued, *showFolders, *searchMails, *deleteMails, |
36 | *editSettings, *editAccounts, *syncFolders; | 37 | *editSettings, *editAccounts, *syncFolders; |
37 | AccountView *folderView; | 38 | AccountView *folderView; |
38 | QListView *mailView; | 39 | QListView *mailView; |
40 | QListViewItem* m_currentItem; | ||
39 | QBoxLayout *layout; | 41 | QBoxLayout *layout; |
40 | }; | 42 | }; |
41 | 43 | ||
42 | #endif | 44 | #endif |
diff --git a/noncore/net/mail/viewmail.cpp b/noncore/net/mail/viewmail.cpp index 42707e3..163ffb7 100644 --- a/noncore/net/mail/viewmail.cpp +++ b/noncore/net/mail/viewmail.cpp | |||
@@ -1,317 +1,325 @@ | |||
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 | #include "accountview.h" | ||
14 | 15 | ||
15 | AttachItem::AttachItem(QListView * parent,QListViewItem *after, const QString&mime,const QString&file,const QString&desc,int num) | 16 | AttachItem::AttachItem(QListView * parent,QListViewItem *after, const QString&mime,const QString&file,const QString&desc,int num) |
16 | : QListViewItem(parent,after),_partNum(num) | 17 | : QListViewItem(parent,after),_partNum(num) |
17 | { | 18 | { |
18 | setText(0, mime); | 19 | setText(0, mime); |
19 | setText(1, file); | 20 | setText(1, file); |
20 | setText(2, desc); | 21 | setText(2, desc); |
21 | } | 22 | } |
22 | 23 | ||
23 | void ViewMail::setBody( RecBody body ) { | 24 | void ViewMail::setBody( RecBody body ) { |
24 | 25 | ||
25 | m_body = body; | 26 | m_body = body; |
26 | m_mail[2] = body.Bodytext(); | 27 | m_mail[2] = body.Bodytext(); |
27 | attachbutton->setEnabled(body.Parts().count()>0); | 28 | attachbutton->setEnabled(body.Parts().count()>0); |
28 | attachments->setEnabled(body.Parts().count()>0); | 29 | attachments->setEnabled(body.Parts().count()>0); |
29 | if (body.Parts().count()==0) { | 30 | if (body.Parts().count()==0) { |
30 | return; | 31 | return; |
31 | } | 32 | } |
32 | AttachItem * curItem=0; | 33 | AttachItem * curItem=0; |
33 | QString type=body.Description().Type()+"/"+body.Description().Subtype(); | 34 | QString type=body.Description().Type()+"/"+body.Description().Subtype(); |
34 | QString desc; | 35 | QString desc; |
35 | double s = body.Description().Size(); | 36 | double s = body.Description().Size(); |
36 | int w; | 37 | int w; |
37 | w=0; | 38 | w=0; |
38 | 39 | ||
39 | while (s>1024) { | 40 | while (s>1024) { |
40 | s/=1024; | 41 | s/=1024; |
41 | ++w; | 42 | ++w; |
42 | if (w>=2) break; | 43 | if (w>=2) break; |
43 | } | 44 | } |
44 | 45 | ||
45 | QString q=""; | 46 | QString q=""; |
46 | switch(w) { | 47 | switch(w) { |
47 | case 1: | 48 | case 1: |
48 | q="k"; | 49 | q="k"; |
49 | break; | 50 | break; |
50 | case 2: | 51 | case 2: |
51 | q="M"; | 52 | q="M"; |
52 | break; | 53 | break; |
53 | default: | 54 | default: |
54 | break; | 55 | break; |
55 | } | 56 | } |
56 | 57 | ||
57 | { | 58 | { |
58 | /* I did not found a method to make a CONTENT reset on a QTextStream | 59 | /* 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 | 60 | 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 | 61 | 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. | 62 | code is it will be destructed after finishing its small job. |
62 | */ | 63 | */ |
63 | QTextOStream o(&desc); | 64 | QTextOStream o(&desc); |
64 | if (w>0) o.precision(2); else o.precision(0); | 65 | if (w>0) o.precision(2); else o.precision(0); |
65 | o.setf(QTextStream::fixed); | 66 | o.setf(QTextStream::fixed); |
66 | o << s << " " << q << "Byte"; | 67 | o << s << " " << q << "Byte"; |
67 | } | 68 | } |
68 | 69 | ||
69 | curItem=new AttachItem(attachments,curItem,type,"Mailbody",desc,-1); | 70 | curItem=new AttachItem(attachments,curItem,type,"Mailbody",desc,-1); |
70 | QString filename = ""; | 71 | QString filename = ""; |
71 | for (unsigned int i = 0; i < body.Parts().count();++i) { | 72 | for (unsigned int i = 0; i < body.Parts().count();++i) { |
72 | type = body.Parts()[i].Type()+"/"+body.Parts()[i].Subtype(); | 73 | type = body.Parts()[i].Type()+"/"+body.Parts()[i].Subtype(); |
73 | part_plist_t::ConstIterator it = body.Parts()[i].Parameters().begin(); | 74 | part_plist_t::ConstIterator it = body.Parts()[i].Parameters().begin(); |
74 | for (;it!=body.Parts()[i].Parameters().end();++it) { | 75 | for (;it!=body.Parts()[i].Parameters().end();++it) { |
75 | if (it.key().lower()=="name") { | 76 | if (it.key().lower()=="name") { |
76 | filename=it.data(); | 77 | filename=it.data(); |
77 | } | 78 | } |
78 | } | 79 | } |
79 | s = body.Parts()[i].Size(); | 80 | s = body.Parts()[i].Size(); |
80 | w = 0; | 81 | w = 0; |
81 | while (s>1024) { | 82 | while (s>1024) { |
82 | s/=1024; | 83 | s/=1024; |
83 | ++w; | 84 | ++w; |
84 | if (w>=2) break; | 85 | if (w>=2) break; |
85 | } | 86 | } |
86 | switch(w) { | 87 | switch(w) { |
87 | case 1: | 88 | case 1: |
88 | q="k"; | 89 | q="k"; |
89 | break; | 90 | break; |
90 | case 2: | 91 | case 2: |
91 | q="M"; | 92 | q="M"; |
92 | break; | 93 | break; |
93 | default: | 94 | default: |
94 | q=""; | 95 | q=""; |
95 | break; | 96 | break; |
96 | } | 97 | } |
97 | QTextOStream o(&desc); | 98 | QTextOStream o(&desc); |
98 | if (w>0) o.precision(2); else o.precision(0); | 99 | if (w>0) o.precision(2); else o.precision(0); |
99 | o.setf(QTextStream::fixed); | 100 | o.setf(QTextStream::fixed); |
100 | o << s << " " << q << "Byte"; | 101 | o << s << " " << q << "Byte"; |
101 | curItem=new AttachItem(attachments,curItem,type,filename,desc,i); | 102 | curItem=new AttachItem(attachments,curItem,type,filename,desc,i); |
102 | } | 103 | } |
103 | } | 104 | } |
104 | 105 | ||
105 | void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int c ) { | 106 | void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int c ) { |
106 | if (!item ) | 107 | if (!item ) |
107 | return; | 108 | return; |
108 | 109 | ||
109 | QPopupMenu *menu = new QPopupMenu(); | 110 | QPopupMenu *menu = new QPopupMenu(); |
110 | int ret=0; | 111 | int ret=0; |
111 | 112 | ||
112 | if ( item->text( 0 ).left( 4 ) == "text" ) { | 113 | if ( item->text( 0 ).left( 4 ) == "text" ) { |
113 | menu->insertItem( tr( "Show Text" ), 1 ); | 114 | menu->insertItem( tr( "Show Text" ), 1 ); |
114 | } | 115 | } |
115 | menu->insertItem( tr( "Save Attachment" ), 0 ); | 116 | menu->insertItem( tr( "Save Attachment" ), 0 ); |
116 | menu->insertSeparator(1); | 117 | menu->insertSeparator(1); |
117 | 118 | ||
118 | ret = menu->exec( point, 0 ); | 119 | ret = menu->exec( point, 0 ); |
119 | 120 | ||
120 | switch(ret) { | 121 | switch(ret) { |
121 | case 0: | 122 | case 0: |
122 | { MimeTypes types; | 123 | { MimeTypes types; |
123 | types.insert( "all", "*" ); | 124 | types.insert( "all", "*" ); |
124 | QString str = OFileDialog::getSaveFileName( 1, | 125 | QString str = OFileDialog::getSaveFileName( 1, |
125 | "/", item->text( 1 ) , types, 0 ); | 126 | "/", item->text( 1 ) , types, 0 ); |
126 | 127 | ||
127 | if( !str.isEmpty() ) { | 128 | if( !str.isEmpty() ) { |
128 | qDebug( "first we will need a MIME wrapper" ); | 129 | qDebug( "first we will need a MIME wrapper" ); |
129 | } | 130 | } |
130 | } | 131 | } |
131 | break ; | 132 | break ; |
132 | 133 | ||
133 | case 1: | 134 | case 1: |
134 | if ( ( ( AttachItem* )item )->Partnumber() == -1 ) { | 135 | if ( ( ( AttachItem* )item )->Partnumber() == -1 ) { |
135 | setText(); | 136 | setText(); |
136 | } else { | 137 | } else { |
137 | if ( m_recMail.Wrapper() != 0l ) { // make sure that there is a wrapper , even after delete or simular actions | 138 | 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() ] ) ); | 139 | browser->setText( m_recMail.Wrapper()->fetchPart( m_recMail, m_body.Parts()[ ( ( AttachItem* )item )->Partnumber() ] ) ); |
139 | } | 140 | } |
140 | } | 141 | } |
141 | break; | 142 | break; |
142 | } | 143 | } |
143 | delete menu; | 144 | delete menu; |
144 | } | 145 | } |
145 | 146 | ||
146 | 147 | ||
147 | void ViewMail::setMail( RecMail mail ) { | 148 | void ViewMail::setMail( RecMail mail ) { |
148 | 149 | ||
149 | m_recMail = mail; | 150 | m_recMail = mail; |
150 | 151 | ||
151 | m_mail[0] = mail.getFrom(); | 152 | m_mail[0] = mail.getFrom(); |
152 | m_mail[1] = mail.getSubject(); | 153 | m_mail[1] = mail.getSubject(); |
153 | m_mail[3] = mail.getDate(); | 154 | m_mail[3] = mail.getDate(); |
154 | m_mail[4] = mail.Msgid(); | 155 | m_mail[4] = mail.Msgid(); |
155 | 156 | ||
156 | m_mail2[0] = mail.To(); | 157 | m_mail2[0] = mail.To(); |
157 | m_mail2[1] = mail.CC(); | 158 | m_mail2[1] = mail.CC(); |
158 | m_mail2[2] = mail.Bcc(); | 159 | m_mail2[2] = mail.Bcc(); |
159 | 160 | ||
160 | setText(); | 161 | setText(); |
161 | } | 162 | } |
162 | 163 | ||
163 | 164 | ||
164 | 165 | ||
165 | ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl) | 166 | ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl) |
166 | : ViewMailBase(parent, name, fl), _inLoop(false) | 167 | : ViewMailBase(parent, name, fl), _inLoop(false) |
167 | { | 168 | { |
168 | m_gotBody = false; | 169 | m_gotBody = false; |
169 | 170 | ||
170 | connect(reply, SIGNAL(activated()), SLOT(slotReply())); | 171 | connect(reply, SIGNAL(activated()), SLOT(slotReply())); |
171 | connect(forward, SIGNAL(activated()), SLOT(slotForward())); | 172 | connect(forward, SIGNAL(activated()), SLOT(slotForward())); |
173 | connect( deleteMail, SIGNAL( activated() ), SLOT( slotDeleteMail( ) ) ); | ||
172 | 174 | ||
173 | attachments->setEnabled(m_gotBody); | 175 | attachments->setEnabled(m_gotBody); |
174 | connect( attachments, SIGNAL( clicked ( QListViewItem *, const QPoint & , int ) ), SLOT( slotItemClicked( QListViewItem *, const QPoint & , int ) ) ); | 176 | connect( attachments, SIGNAL( clicked ( QListViewItem *, const QPoint & , int ) ), SLOT( slotItemClicked( QListViewItem *, const QPoint & , int ) ) ); |
175 | 177 | ||
176 | } | 178 | } |
177 | 179 | ||
178 | void ViewMail::setText() | 180 | void ViewMail::setText() |
179 | { | 181 | { |
180 | 182 | ||
181 | QString toString; | 183 | QString toString; |
182 | QString ccString; | 184 | QString ccString; |
183 | QString bccString; | 185 | QString bccString; |
184 | 186 | ||
185 | for ( QStringList::Iterator it = ( m_mail2[0] ).begin(); it != ( m_mail2[0] ).end(); ++it ) { | 187 | for ( QStringList::Iterator it = ( m_mail2[0] ).begin(); it != ( m_mail2[0] ).end(); ++it ) { |
186 | toString += (*it); | 188 | toString += (*it); |
187 | } | 189 | } |
188 | for ( QStringList::Iterator it = ( m_mail2[1] ).begin(); it != ( m_mail2[1] ).end(); ++it ) { | 190 | for ( QStringList::Iterator it = ( m_mail2[1] ).begin(); it != ( m_mail2[1] ).end(); ++it ) { |
189 | ccString += (*it); | 191 | ccString += (*it); |
190 | } | 192 | } |
191 | for ( QStringList::Iterator it = ( m_mail2[2] ).begin(); it != ( m_mail2[2] ).end(); ++it ) { | 193 | for ( QStringList::Iterator it = ( m_mail2[2] ).begin(); it != ( m_mail2[2] ).end(); ++it ) { |
192 | bccString += (*it); | 194 | bccString += (*it); |
193 | } | 195 | } |
194 | 196 | ||
195 | setCaption( caption().arg( m_mail[0] ) ); | 197 | setCaption( caption().arg( m_mail[0] ) ); |
196 | 198 | ||
197 | m_mailHtml = "<html><body>" | 199 | m_mailHtml = "<html><body>" |
198 | "<table width=\"100%\" border=\"0\"><tr bgcolor=\"#FFDD76\"><td>" | 200 | "<table width=\"100%\" border=\"0\"><tr bgcolor=\"#FFDD76\"><td>" |
199 | "<div align=left><b>" + deHtml( m_mail[1] ) + "</b></div>" | 201 | "<div align=left><b>" + deHtml( m_mail[1] ) + "</b></div>" |
200 | "</td></tr><tr bgcolor=\"#EEEEE6\"><td>" | 202 | "</td></tr><tr bgcolor=\"#EEEEE6\"><td>" |
201 | "<b>" + tr( "From" ) + ": </b><font color=#6C86C0>" + deHtml( m_mail[0] ) + "</font><br>" | 203 | "<b>" + tr( "From" ) + ": </b><font color=#6C86C0>" + deHtml( m_mail[0] ) + "</font><br>" |
202 | "<b>" + tr( "To" ) + ": </b><font color=#6C86C0>" + deHtml( toString ) + "</font><br><b>" + | 204 | "<b>" + tr( "To" ) + ": </b><font color=#6C86C0>" + deHtml( toString ) + "</font><br><b>" + |
203 | tr( "Cc" ) + ": </b>" + deHtml( ccString ) + "<br>" | 205 | tr( "Cc" ) + ": </b>" + deHtml( ccString ) + "<br>" |
204 | "<b>" + tr( "Date" ) + ": </b> " + m_mail[3] + | 206 | "<b>" + tr( "Date" ) + ": </b> " + m_mail[3] + |
205 | "</td></tr></table><font face=fixed>"; | 207 | "</td></tr></table><font face=fixed>"; |
206 | 208 | ||
207 | browser->setText( QString( m_mailHtml) + deHtml( m_mail[2] ) + "</font></html>" ); | 209 | browser->setText( QString( m_mailHtml) + deHtml( m_mail[2] ) + "</font></html>" ); |
208 | // remove later in favor of a real handling | 210 | // remove later in favor of a real handling |
209 | m_gotBody = true; | 211 | m_gotBody = true; |
210 | } | 212 | } |
211 | 213 | ||
212 | 214 | ||
213 | ViewMail::~ViewMail() | 215 | ViewMail::~ViewMail() |
214 | { | 216 | { |
215 | hide(); | 217 | hide(); |
216 | } | 218 | } |
217 | 219 | ||
218 | void ViewMail::hide() | 220 | void ViewMail::hide() |
219 | { | 221 | { |
220 | QWidget::hide(); | 222 | QWidget::hide(); |
221 | 223 | ||
222 | if (_inLoop) { | 224 | if (_inLoop) { |
223 | _inLoop = false; | 225 | _inLoop = false; |
224 | qApp->exit_loop(); | 226 | qApp->exit_loop(); |
225 | 227 | ||
226 | } | 228 | } |
227 | 229 | ||
228 | } | 230 | } |
229 | 231 | ||
230 | void ViewMail::exec() | 232 | void ViewMail::exec() |
231 | { | 233 | { |
232 | show(); | 234 | show(); |
233 | 235 | ||
234 | if (!_inLoop) { | 236 | if (!_inLoop) { |
235 | _inLoop = true; | 237 | _inLoop = true; |
236 | qApp->enter_loop(); | 238 | qApp->enter_loop(); |
237 | } | 239 | } |
238 | 240 | ||
239 | } | 241 | } |
240 | 242 | ||
241 | QString ViewMail::deHtml(const QString &string) | 243 | QString ViewMail::deHtml(const QString &string) |
242 | { | 244 | { |
243 | QString string_ = string; | 245 | QString string_ = string; |
244 | string_.replace(QRegExp("&"), "&"); | 246 | string_.replace(QRegExp("&"), "&"); |
245 | string_.replace(QRegExp("<"), "<"); | 247 | string_.replace(QRegExp("<"), "<"); |
246 | string_.replace(QRegExp(">"), ">"); | 248 | string_.replace(QRegExp(">"), ">"); |
247 | string_.replace(QRegExp("\\n"), "<br>"); | 249 | string_.replace(QRegExp("\\n"), "<br>"); |
248 | return string_; | 250 | return string_; |
249 | } | 251 | } |
250 | 252 | ||
251 | void ViewMail::slotReply() | 253 | void ViewMail::slotReply() |
252 | { | 254 | { |
253 | if (!m_gotBody) { | 255 | if (!m_gotBody) { |
254 | QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot reply yet."), tr("Ok")); | 256 | QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot reply yet."), tr("Ok")); |
255 | return; | 257 | return; |
256 | } | 258 | } |
257 | 259 | ||
258 | QString rtext; | 260 | QString rtext; |
259 | rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose | 261 | rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose |
260 | .arg( m_mail[1] ) | 262 | .arg( m_mail[1] ) |
261 | .arg( m_mail[3] ); | 263 | .arg( m_mail[3] ); |
262 | 264 | ||
263 | QString text = m_mail[2]; | 265 | QString text = m_mail[2]; |
264 | QStringList lines = QStringList::split(QRegExp("\\n"), text); | 266 | QStringList lines = QStringList::split(QRegExp("\\n"), text); |
265 | QStringList::Iterator it; | 267 | QStringList::Iterator it; |
266 | for (it = lines.begin(); it != lines.end(); it++) { | 268 | for (it = lines.begin(); it != lines.end(); it++) { |
267 | rtext += "> " + *it + "\n"; | 269 | rtext += "> " + *it + "\n"; |
268 | } | 270 | } |
269 | rtext += "\n"; | 271 | rtext += "\n"; |
270 | 272 | ||
271 | QString prefix; | 273 | QString prefix; |
272 | if ( m_mail[1].find(QRegExp("^Re: *$")) != -1) prefix = ""; | 274 | if ( m_mail[1].find(QRegExp("^Re: *$")) != -1) prefix = ""; |
273 | else prefix = "Re: "; // no i18n on purpose | 275 | else prefix = "Re: "; // no i18n on purpose |
274 | 276 | ||
275 | Settings *settings = new Settings(); | 277 | Settings *settings = new Settings(); |
276 | ComposeMail composer( settings ,this, 0, true); | 278 | ComposeMail composer( settings ,this, 0, true); |
277 | composer.setTo( m_mail[0] ); | 279 | composer.setTo( m_mail[0] ); |
278 | composer.setSubject( "Re: " + m_mail[1] ); | 280 | composer.setSubject( "Re: " + m_mail[1] ); |
279 | composer.setMessage( rtext ); | 281 | composer.setMessage( rtext ); |
280 | composer.showMaximized(); | 282 | composer.showMaximized(); |
281 | composer.exec(); | 283 | composer.exec(); |
282 | 284 | ||
283 | } | 285 | } |
284 | 286 | ||
285 | void ViewMail::slotForward() | 287 | void ViewMail::slotForward() |
286 | { | 288 | { |
287 | if (!m_gotBody) { | 289 | if (!m_gotBody) { |
288 | QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot forward yet."), tr("Ok")); | 290 | QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot forward yet."), tr("Ok")); |
289 | return; | 291 | return; |
290 | } | 292 | } |
291 | 293 | ||
292 | QString ftext; | 294 | QString ftext; |
293 | ftext += QString("\n----- Forwarded message from %1 -----\n\n") | 295 | ftext += QString("\n----- Forwarded message from %1 -----\n\n") |
294 | .arg( m_mail[0] ); | 296 | .arg( m_mail[0] ); |
295 | if (!m_mail[3].isNull()) | 297 | if (!m_mail[3].isNull()) |
296 | ftext += QString("Date: %1\n") | 298 | ftext += QString("Date: %1\n") |
297 | .arg( m_mail[3] ); | 299 | .arg( m_mail[3] ); |
298 | if (!m_mail[0].isNull()) | 300 | if (!m_mail[0].isNull()) |
299 | ftext += QString("From: %1\n") | 301 | ftext += QString("From: %1\n") |
300 | .arg( m_mail[0] ); | 302 | .arg( m_mail[0] ); |
301 | if (!m_mail[1].isNull()) | 303 | if (!m_mail[1].isNull()) |
302 | ftext += QString("Subject: %1\n") | 304 | ftext += QString("Subject: %1\n") |
303 | .arg( m_mail[1] ); | 305 | .arg( m_mail[1] ); |
304 | 306 | ||
305 | ftext += QString("\n%1\n") | 307 | ftext += QString("\n%1\n") |
306 | .arg( m_mail[2]); | 308 | .arg( m_mail[2]); |
307 | 309 | ||
308 | ftext += QString("----- End forwarded message -----\n"); | 310 | ftext += QString("----- End forwarded message -----\n"); |
309 | 311 | ||
310 | Settings *settings = new Settings(); | 312 | Settings *settings = new Settings(); |
311 | ComposeMail composer( settings ,this, 0, true); | 313 | ComposeMail composer( settings ,this, 0, true); |
312 | composer.setSubject( "Fwd: " + m_mail[1] ); | 314 | composer.setSubject( "Fwd: " + m_mail[1] ); |
313 | composer.setMessage( ftext ); | 315 | composer.setMessage( ftext ); |
314 | composer.showMaximized(); | 316 | composer.showMaximized(); |
315 | composer.exec(); | 317 | composer.exec(); |
316 | } | 318 | } |
317 | 319 | ||
320 | void ViewMail::slotDeleteMail( ) | ||
321 | { | ||
322 | m_recMail.Wrapper()->deleteMail( m_recMail ); | ||
323 | hide(); | ||
324 | deleted = true; | ||
325 | } | ||
diff --git a/noncore/net/mail/viewmail.h b/noncore/net/mail/viewmail.h index bc12da1..765464c 100644 --- a/noncore/net/mail/viewmail.h +++ b/noncore/net/mail/viewmail.h | |||
@@ -1,57 +1,60 @@ | |||
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 | #include <qstringlist.h> |
7 | 7 | ||
8 | #include "viewmailbase.h" | 8 | #include "viewmailbase.h" |
9 | #include "mailtypes.h" | 9 | #include "mailtypes.h" |
10 | 10 | ||
11 | class AttachItem : public QListViewItem | 11 | class AttachItem : public QListViewItem |
12 | { | 12 | { |
13 | public: | 13 | public: |
14 | AttachItem(QListView * parent,QListViewItem *after, const QString&mime,const QString&file,const QString&desc,int num); | 14 | AttachItem(QListView * parent,QListViewItem *after, const QString&mime,const QString&file,const QString&desc,int num); |
15 | int Partnumber() { return _partNum; } | 15 | int Partnumber() { return _partNum; } |
16 | 16 | ||
17 | private: | 17 | private: |
18 | int _partNum; | 18 | int _partNum; |
19 | }; | 19 | }; |
20 | 20 | ||
21 | class ViewMail : public ViewMailBase | 21 | class ViewMail : public ViewMailBase |
22 | { | 22 | { |
23 | Q_OBJECT | 23 | Q_OBJECT |
24 | 24 | ||
25 | public: | 25 | public: |
26 | ViewMail( QWidget *parent = 0, const char *name = 0, WFlags fl = Qt::WType_Modal); | 26 | ViewMail( QWidget *parent = 0, const char *name = 0, WFlags fl = Qt::WType_Modal); |
27 | ~ViewMail(); | 27 | ~ViewMail(); |
28 | 28 | ||
29 | void hide(); | 29 | void hide(); |
30 | void exec(); | 30 | void exec(); |
31 | void setMail( RecMail mail ); | 31 | void setMail( RecMail mail ); |
32 | void setBody( RecBody body ); | 32 | void setBody( RecBody body ); |
33 | bool deleted; | ||
33 | 34 | ||
34 | protected: | 35 | protected: |
35 | QString deHtml(const QString &string); | 36 | QString deHtml(const QString &string); |
36 | 37 | ||
37 | protected slots: | 38 | protected slots: |
38 | void slotReply(); | 39 | void slotReply(); |
39 | void slotForward(); | 40 | void slotForward(); |
40 | void setText(); | 41 | void setText(); |
41 | void slotItemClicked( QListViewItem * item , const QPoint & point, int c ); | 42 | void slotItemClicked( QListViewItem * item , const QPoint & point, int c ); |
43 | void slotDeleteMail( ); | ||
44 | |||
42 | 45 | ||
43 | private: | 46 | private: |
44 | bool _inLoop; | 47 | bool _inLoop; |
45 | QString m_mailHtml; | 48 | QString m_mailHtml; |
46 | bool m_gotBody; | 49 | bool m_gotBody; |
47 | RecBody m_body; | 50 | RecBody m_body; |
48 | RecMail m_recMail; | 51 | RecMail m_recMail; |
49 | 52 | ||
50 | // 0 from 1 subject 2 bodytext 3 date | 53 | // 0 from 1 subject 2 bodytext 3 date |
51 | QMap <int,QString> m_mail; | 54 | QMap <int,QString> m_mail; |
52 | // 0 to 1 cc 2 bcc | 55 | // 0 to 1 cc 2 bcc |
53 | QMap <int,QStringList> m_mail2; | 56 | QMap <int,QStringList> m_mail2; |
54 | 57 | ||
55 | }; | 58 | }; |
56 | 59 | ||
57 | #endif | 60 | #endif |