summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/mainwindow.cpp1
1 files changed, 1 insertions, 0 deletions
diff --git a/noncore/net/mail/mainwindow.cpp b/noncore/net/mail/mainwindow.cpp
index 2b5870a..391b55e 100644
--- a/noncore/net/mail/mainwindow.cpp
+++ b/noncore/net/mail/mainwindow.cpp
@@ -1,216 +1,217 @@
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
16MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags ) 16MainWindow::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); 63 deleteMails = new QAction(tr("Delete Mail"), QIconSet(Resource::loadPixmap("mail/delete")), 0, 0, this);
64 deleteMails->addTo( toolBar ); 64 deleteMails->addTo( toolBar );
65 deleteMails->addTo( mailMenu ); 65 deleteMails->addTo( mailMenu );
66 connect( deleteMails, SIGNAL( activated() ), 66 connect( deleteMails, SIGNAL( activated() ),
67 SLOT( slotDeleteMail() ) ); 67 SLOT( slotDeleteMail() ) );
68 68
69 editSettings = new QAction( tr( "Edit settings" ), ICON_EDITSETTINGS, 69 editSettings = new QAction( tr( "Edit settings" ), ICON_EDITSETTINGS,
70 0, 0, this ); 70 0, 0, this );
71 editSettings->addTo( settingsMenu ); 71 editSettings->addTo( settingsMenu );
72 72
73 editAccounts = new QAction( tr( "Configure accounts" ), ICON_EDITACCOUNTS, 73 editAccounts = new QAction( tr( "Configure accounts" ), ICON_EDITACCOUNTS,
74 0, 0, this ); 74 0, 0, this );
75 editAccounts->addTo( settingsMenu ); 75 editAccounts->addTo( settingsMenu );
76 76
77 QWidget *view = new QWidget( this ); 77 QWidget *view = new QWidget( this );
78 setCentralWidget( view ); 78 setCentralWidget( view );
79 79
80 layout = new QBoxLayout ( view, QBoxLayout::LeftToRight ); 80 layout = new QBoxLayout ( view, QBoxLayout::LeftToRight );
81 81
82 folderView = new AccountView( view ); 82 folderView = new AccountView( view );
83 folderView->header()->hide(); 83 folderView->header()->hide();
84 folderView->setRootIsDecorated( false );
84 folderView->addColumn( tr( "Mailbox" ) ); 85 folderView->addColumn( tr( "Mailbox" ) );
85 folderView->hide(); 86 folderView->hide();
86 87
87 layout->addWidget( folderView ); 88 layout->addWidget( folderView );
88 89
89 mailView = new QListView( view ); 90 mailView = new QListView( view );
90 mailView->addColumn( tr( "" ) ); 91 mailView->addColumn( tr( "" ) );
91 mailView->addColumn( tr( "Subject" ),QListView::Manual ); 92 mailView->addColumn( tr( "Subject" ),QListView::Manual );
92 mailView->addColumn( tr( "Sender" ),QListView::Manual ); 93 mailView->addColumn( tr( "Sender" ),QListView::Manual );
93 mailView->addColumn( tr( "Date" )); 94 mailView->addColumn( tr( "Date" ));
94 mailView->setAllColumnsShowFocus(true); 95 mailView->setAllColumnsShowFocus(true);
95 mailView->setSorting(-1); 96 mailView->setSorting(-1);
96 97
97 layout->addWidget( mailView ); 98 layout->addWidget( mailView );
98 layout->setStretchFactor( folderView, 1 ); 99 layout->setStretchFactor( folderView, 1 );
99 layout->setStretchFactor( mailView, 2 ); 100 layout->setStretchFactor( mailView, 2 );
100 101
101 slotAdjustLayout(); 102 slotAdjustLayout();
102 103
103 connect( mailView, SIGNAL( clicked( QListViewItem * ) ),this, 104 connect( mailView, SIGNAL( clicked( QListViewItem * ) ),this,
104 SLOT( displayMail( QListViewItem * ) ) ); 105 SLOT( displayMail( QListViewItem * ) ) );
105 106
106 connect(folderView, SIGNAL(refreshMailview(QList<RecMail>*)),this,SLOT(refreshMailView(QList<RecMail>*))); 107 connect(folderView, SIGNAL(refreshMailview(QList<RecMail>*)),this,SLOT(refreshMailView(QList<RecMail>*)));
107 108
108 QTimer::singleShot( 1000, this, SLOT( slotAdjustColumns() ) ); 109 QTimer::singleShot( 1000, this, SLOT( slotAdjustColumns() ) );
109} 110}
110 111
111 112
112void MainWindow::slotAdjustLayout() { 113void MainWindow::slotAdjustLayout() {
113 114
114 QWidget *d = QApplication::desktop(); 115 QWidget *d = QApplication::desktop();
115 116
116 if ( d->width() < d->height() ) { 117 if ( d->width() < d->height() ) {
117 layout->setDirection( QBoxLayout::TopToBottom ); 118 layout->setDirection( QBoxLayout::TopToBottom );
118 } else { 119 } else {
119 layout->setDirection( QBoxLayout::LeftToRight ); 120 layout->setDirection( QBoxLayout::LeftToRight );
120 } 121 }
121 delete d; 122 delete d;
122} 123}
123 124
124void MainWindow::slotAdjustColumns() 125void MainWindow::slotAdjustColumns()
125{ 126{
126 bool hidden = folderView->isHidden(); 127 bool hidden = folderView->isHidden();
127 if ( hidden ) folderView->show(); 128 if ( hidden ) folderView->show();
128 folderView->setColumnWidth( 0, folderView->visibleWidth() ); 129 folderView->setColumnWidth( 0, folderView->visibleWidth() );
129 if ( hidden ) folderView->hide(); 130 if ( hidden ) folderView->hide();
130 131
131 mailView->setColumnWidth( 0, 10 ); 132 mailView->setColumnWidth( 0, 10 );
132 mailView->setColumnWidth( 1, mailView->visibleWidth() - 130 ); 133 mailView->setColumnWidth( 1, mailView->visibleWidth() - 130 );
133 mailView->setColumnWidth( 2, 80 ); 134 mailView->setColumnWidth( 2, 80 );
134 mailView->setColumnWidth( 3, 50 ); 135 mailView->setColumnWidth( 3, 50 );
135} 136}
136 137
137void MainWindow::slotShowFolders( bool show ) 138void MainWindow::slotShowFolders( bool show )
138{ 139{
139 qDebug( "Show Folders" ); 140 qDebug( "Show Folders" );
140 if ( show && folderView->isHidden() ) { 141 if ( show && folderView->isHidden() ) {
141 qDebug( "-> showing" ); 142 qDebug( "-> showing" );
142 folderView->show(); 143 folderView->show();
143 } else if ( !show && !folderView->isHidden() ) { 144 } else if ( !show && !folderView->isHidden() ) {
144 qDebug( "-> hiding" ); 145 qDebug( "-> hiding" );
145 folderView->hide(); 146 folderView->hide();
146 } 147 }
147} 148}
148 149
149void MainWindow::refreshMailView(QList<RecMail>*list) 150void MainWindow::refreshMailView(QList<RecMail>*list)
150{ 151{
151 MailListViewItem*item = 0; 152 MailListViewItem*item = 0;
152 mailView->clear(); 153 mailView->clear();
153 for (unsigned int i = 0; i < list->count();++i) { 154 for (unsigned int i = 0; i < list->count();++i) {
154 item = new MailListViewItem(mailView,item); 155 item = new MailListViewItem(mailView,item);
155 item->storeData(*(list->at(i))); 156 item->storeData(*(list->at(i)));
156 item->showEntry(); 157 item->showEntry();
157 } 158 }
158} 159}
159void MainWindow::displayMail(QListViewItem*item) 160void MainWindow::displayMail(QListViewItem*item)
160{ 161{
161 162
162 if (!item) return; 163 if (!item) return;
163 RecMail mail = ((MailListViewItem*)item)->data(); 164 RecMail mail = ((MailListViewItem*)item)->data();
164 RecBody body = folderView->fetchBody(mail); 165 RecBody body = folderView->fetchBody(mail);
165 166
166 ViewMail readMail( this ); 167 ViewMail readMail( this );
167 readMail.setBody( body ); 168 readMail.setBody( body );
168 readMail.setMail( mail ); 169 readMail.setMail( mail );
169 readMail.showMaximized(); 170 readMail.showMaximized();
170 readMail.exec(); 171 readMail.exec();
171 172
172 if ( readMail.deleted ) { 173 if ( readMail.deleted ) {
173 folderView->refreshCurrent(); 174 folderView->refreshCurrent();
174 } else { 175 } else {
175 ( (MailListViewItem*)item )->setPixmap( 0, Resource::loadPixmap( "opiemail/kmmsgunseen") ); 176 ( (MailListViewItem*)item )->setPixmap( 0, Resource::loadPixmap( "opiemail/kmmsgunseen") );
176 } 177 }
177} 178}
178 179
179void MainWindow::slotDeleteMail() 180void MainWindow::slotDeleteMail()
180{ 181{
181 if (!mailView->currentItem()) return; 182 if (!mailView->currentItem()) return;
182 RecMail mail = ((MailListViewItem*)mailView->currentItem() )->data(); 183 RecMail mail = ((MailListViewItem*)mailView->currentItem() )->data();
183 mail.Wrapper()->deleteMail( mail ); 184 mail.Wrapper()->deleteMail( mail );
184 folderView->refreshCurrent(); 185 folderView->refreshCurrent();
185} 186}
186 187
187 188
188 189
189MailListViewItem::MailListViewItem(QListView * parent, MailListViewItem * item ) 190MailListViewItem::MailListViewItem(QListView * parent, MailListViewItem * item )
190 :QListViewItem(parent,item),mail_data() 191 :QListViewItem(parent,item),mail_data()
191{ 192{
192} 193}
193 194
194void MailListViewItem::showEntry() 195void MailListViewItem::showEntry()
195{ 196{
196 if ( mail_data.getFlags().testBit( FLAG_SEEN ) == true ) { 197 if ( mail_data.getFlags().testBit( FLAG_SEEN ) == true ) {
197 setPixmap( 0, Resource::loadPixmap( "opiemail/kmmsgunseen") ); 198 setPixmap( 0, Resource::loadPixmap( "opiemail/kmmsgunseen") );
198 } else { 199 } else {
199 setPixmap( 0, Resource::loadPixmap( "opiemail/kmmsgnew") ); 200 setPixmap( 0, Resource::loadPixmap( "opiemail/kmmsgnew") );
200 } 201 }
201 setText(1,mail_data.getSubject()); 202 setText(1,mail_data.getSubject());
202 setText(2,mail_data.getFrom()); 203 setText(2,mail_data.getFrom());
203 setText(3,mail_data.getDate()); 204 setText(3,mail_data.getDate());
204} 205}
205 206
206void MailListViewItem::storeData(const RecMail&data) 207void MailListViewItem::storeData(const RecMail&data)
207{ 208{
208 mail_data = data; 209 mail_data = data;
209} 210}
210 211
211const RecMail& MailListViewItem::data()const 212const RecMail& MailListViewItem::data()const
212{ 213{
213 return mail_data; 214 return mail_data;
214} 215}
215 216
216 217