author | alwin <alwin> | 2003-12-19 19:29:26 (UTC) |
---|---|---|
committer | alwin <alwin> | 2003-12-19 19:29:26 (UTC) |
commit | b66e2d718769a3ac1ae6bc1fc135c04f532bdbf3 (patch) (unidiff) | |
tree | 0fc344b67049b17c1c9dd010a915ef4a8a644256 | |
parent | 71aa0d1be1970a105d3324fcff5d88f3e042b3cd (diff) | |
download | opie-b66e2d718769a3ac1ae6bc1fc135c04f532bdbf3.zip opie-b66e2d718769a3ac1ae6bc1fc135c04f532bdbf3.tar.gz opie-b66e2d718769a3ac1ae6bc1fc135c04f532bdbf3.tar.bz2 |
-size of mail will be displayed
-only new/replied mail get an icon, I think it looks somewhat cleaner
-rw-r--r-- | noncore/net/mail/mainwindow.cpp | 40 |
1 files changed, 38 insertions, 2 deletions
diff --git a/noncore/net/mail/mainwindow.cpp b/noncore/net/mail/mainwindow.cpp index 89530ab..9a37510 100644 --- a/noncore/net/mail/mainwindow.cpp +++ b/noncore/net/mail/mainwindow.cpp | |||
@@ -1,30 +1,31 @@ | |||
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 | #include <qmessagebox.h> | 6 | #include <qmessagebox.h> |
7 | #include <qtextstream.h> | ||
7 | 8 | ||
8 | #include <qpe/qpeapplication.h> | 9 | #include <qpe/qpeapplication.h> |
9 | #include <qpe/resource.h> | 10 | #include <qpe/resource.h> |
10 | 11 | ||
11 | #include "defines.h" | 12 | #include "defines.h" |
12 | #include "mainwindow.h" | 13 | #include "mainwindow.h" |
13 | #include "viewmail.h" | 14 | #include "viewmail.h" |
14 | #include "mailtypes.h" | 15 | #include "mailtypes.h" |
15 | #include "mailistviewitem.h" | 16 | #include "mailistviewitem.h" |
16 | 17 | ||
17 | MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags ) | 18 | MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags ) |
18 | : QMainWindow( parent, name, flags ) | 19 | : QMainWindow( parent, name, flags ) |
19 | { | 20 | { |
20 | setCaption( tr( "Mail" ) ); | 21 | setCaption( tr( "Mail" ) ); |
21 | setToolBarsMovable( false ); | 22 | setToolBarsMovable( false ); |
22 | 23 | ||
23 | toolBar = new QToolBar( this ); | 24 | toolBar = new QToolBar( this ); |
24 | menuBar = new QMenuBar( toolBar ); | 25 | menuBar = new QMenuBar( toolBar ); |
25 | mailMenu = new QPopupMenu( menuBar ); | 26 | mailMenu = new QPopupMenu( menuBar ); |
26 | menuBar->insertItem( tr( "Mail" ), mailMenu ); | 27 | menuBar->insertItem( tr( "Mail" ), mailMenu ); |
27 | settingsMenu = new QPopupMenu( menuBar ); | 28 | settingsMenu = new QPopupMenu( menuBar ); |
28 | menuBar->insertItem( tr( "Settings" ), settingsMenu ); | 29 | menuBar->insertItem( tr( "Settings" ), settingsMenu ); |
29 | 30 | ||
30 | addToolBar( toolBar ); | 31 | addToolBar( toolBar ); |
@@ -72,91 +73,93 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags ) | |||
72 | 0, 0, this ); | 73 | 0, 0, this ); |
73 | editSettings->addTo( settingsMenu ); | 74 | editSettings->addTo( settingsMenu ); |
74 | 75 | ||
75 | editAccounts = new QAction( tr( "Configure accounts" ), ICON_EDITACCOUNTS, | 76 | editAccounts = new QAction( tr( "Configure accounts" ), ICON_EDITACCOUNTS, |
76 | 0, 0, this ); | 77 | 0, 0, this ); |
77 | editAccounts->addTo( settingsMenu ); | 78 | editAccounts->addTo( settingsMenu ); |
78 | 79 | ||
79 | QWidget *view = new QWidget( this ); | 80 | QWidget *view = new QWidget( this ); |
80 | setCentralWidget( view ); | 81 | setCentralWidget( view ); |
81 | 82 | ||
82 | layout = new QBoxLayout ( view, QBoxLayout::LeftToRight ); | 83 | layout = new QBoxLayout ( view, QBoxLayout::LeftToRight ); |
83 | 84 | ||
84 | folderView = new AccountView( view ); | 85 | folderView = new AccountView( view ); |
85 | folderView->header()->hide(); | 86 | folderView->header()->hide(); |
86 | folderView->setRootIsDecorated( true ); | 87 | folderView->setRootIsDecorated( true ); |
87 | folderView->addColumn( tr( "Mailbox" ) ); | 88 | folderView->addColumn( tr( "Mailbox" ) ); |
88 | //folderView->hide(); | 89 | //folderView->hide(); |
89 | 90 | ||
90 | layout->addWidget( folderView ); | 91 | layout->addWidget( folderView ); |
91 | 92 | ||
92 | mailView = new QListView( view ); | 93 | mailView = new QListView( view ); |
93 | mailView->addColumn( tr( "" ) ); | 94 | mailView->addColumn( tr( "" ) ); |
94 | mailView->addColumn( tr( "Subject" ),QListView::Manual ); | 95 | mailView->addColumn( tr( "Subject" ),QListView::Manual ); |
95 | mailView->addColumn( tr( "Sender" ),QListView::Manual ); | 96 | mailView->addColumn( tr( "Sender" ),QListView::Manual ); |
97 | mailView->addColumn( tr( "Size" ),QListView::Manual); | ||
96 | mailView->addColumn( tr( "Date" )); | 98 | mailView->addColumn( tr( "Date" )); |
97 | mailView->setAllColumnsShowFocus(true); | 99 | mailView->setAllColumnsShowFocus(true); |
98 | mailView->setSorting(-1); | 100 | mailView->setSorting(-1); |
99 | 101 | ||
100 | layout->addWidget( mailView ); | 102 | layout->addWidget( mailView ); |
101 | layout->setStretchFactor( folderView, 1 ); | 103 | layout->setStretchFactor( folderView, 1 ); |
102 | layout->setStretchFactor( mailView, 2 ); | 104 | layout->setStretchFactor( mailView, 2 ); |
103 | 105 | ||
104 | slotAdjustLayout(); | 106 | slotAdjustLayout(); |
105 | 107 | ||
106 | connect( mailView, SIGNAL( clicked( QListViewItem * ) ),this, | 108 | connect( mailView, SIGNAL( clicked( QListViewItem * ) ),this, |
107 | SLOT( displayMail( QListViewItem * ) ) ); | 109 | SLOT( displayMail( QListViewItem * ) ) ); |
108 | 110 | ||
109 | connect(folderView, SIGNAL(refreshMailview(QList<RecMail>*)),this,SLOT(refreshMailView(QList<RecMail>*))); | 111 | connect(folderView, SIGNAL(refreshMailview(QList<RecMail>*)),this,SLOT(refreshMailView(QList<RecMail>*))); |
110 | 112 | ||
111 | QTimer::singleShot( 1000, this, SLOT( slotAdjustColumns() ) ); | 113 | QTimer::singleShot( 1000, this, SLOT( slotAdjustColumns() ) ); |
112 | 114 | ||
113 | } | 115 | } |
114 | 116 | ||
115 | 117 | ||
116 | void MainWindow::slotAdjustLayout() { | 118 | void MainWindow::slotAdjustLayout() { |
117 | 119 | ||
118 | QWidget *d = QApplication::desktop(); | 120 | QWidget *d = QApplication::desktop(); |
119 | 121 | ||
120 | if ( d->width() < d->height() ) { | 122 | if ( d->width() < d->height() ) { |
121 | layout->setDirection( QBoxLayout::TopToBottom ); | 123 | layout->setDirection( QBoxLayout::TopToBottom ); |
122 | } else { | 124 | } else { |
123 | layout->setDirection( QBoxLayout::LeftToRight ); | 125 | layout->setDirection( QBoxLayout::LeftToRight ); |
124 | } | 126 | } |
125 | delete d; | 127 | delete d; |
126 | } | 128 | } |
127 | 129 | ||
128 | void MainWindow::slotAdjustColumns() | 130 | void MainWindow::slotAdjustColumns() |
129 | { | 131 | { |
130 | bool hidden = folderView->isHidden(); | 132 | bool hidden = folderView->isHidden(); |
131 | if ( hidden ) folderView->show(); | 133 | if ( hidden ) folderView->show(); |
132 | folderView->setColumnWidth( 0, folderView->visibleWidth() ); | 134 | folderView->setColumnWidth( 0, folderView->visibleWidth() ); |
133 | if ( hidden ) folderView->hide(); | 135 | if ( hidden ) folderView->hide(); |
134 | 136 | ||
135 | mailView->setColumnWidth( 0, 10 ); | 137 | mailView->setColumnWidth( 0, 10 ); |
136 | mailView->setColumnWidth( 1, mailView->visibleWidth() - 130 ); | 138 | mailView->setColumnWidth( 1, mailView->visibleWidth() - 130 ); |
137 | mailView->setColumnWidth( 2, 80 ); | 139 | mailView->setColumnWidth( 2, 80 ); |
138 | mailView->setColumnWidth( 3, 50 ); | 140 | mailView->setColumnWidth( 3, 50 ); |
141 | mailView->setColumnWidth( 4, 50 ); | ||
139 | } | 142 | } |
140 | 143 | ||
141 | void MainWindow::slotShowFolders( bool show ) | 144 | void MainWindow::slotShowFolders( bool show ) |
142 | { | 145 | { |
143 | qDebug( "Show Folders" ); | 146 | qDebug( "Show Folders" ); |
144 | if ( show && folderView->isHidden() ) { | 147 | if ( show && folderView->isHidden() ) { |
145 | qDebug( "-> showing" ); | 148 | qDebug( "-> showing" ); |
146 | folderView->show(); | 149 | folderView->show(); |
147 | } else if ( !show && !folderView->isHidden() ) { | 150 | } else if ( !show && !folderView->isHidden() ) { |
148 | qDebug( "-> hiding" ); | 151 | qDebug( "-> hiding" ); |
149 | folderView->hide(); | 152 | folderView->hide(); |
150 | } | 153 | } |
151 | } | 154 | } |
152 | 155 | ||
153 | void MainWindow::refreshMailView(QList<RecMail>*list) | 156 | void MainWindow::refreshMailView(QList<RecMail>*list) |
154 | { | 157 | { |
155 | MailListViewItem*item = 0; | 158 | MailListViewItem*item = 0; |
156 | mailView->clear(); | 159 | mailView->clear(); |
157 | for (unsigned int i = 0; i < list->count();++i) { | 160 | for (unsigned int i = 0; i < list->count();++i) { |
158 | item = new MailListViewItem(mailView,item); | 161 | item = new MailListViewItem(mailView,item); |
159 | item->storeData(*(list->at(i))); | 162 | item->storeData(*(list->at(i))); |
160 | item->showEntry(); | 163 | item->showEntry(); |
161 | } | 164 | } |
162 | } | 165 | } |
@@ -181,44 +184,77 @@ void MainWindow::displayMail(QListViewItem*item) | |||
181 | } | 184 | } |
182 | 185 | ||
183 | void MainWindow::slotDeleteMail() | 186 | void MainWindow::slotDeleteMail() |
184 | { | 187 | { |
185 | if (!mailView->currentItem()) return; | 188 | if (!mailView->currentItem()) return; |
186 | RecMail mail = ((MailListViewItem*)mailView->currentItem() )->data(); | 189 | RecMail mail = ((MailListViewItem*)mailView->currentItem() )->data(); |
187 | if ( QMessageBox::warning(this, tr("Delete Mail"), QString( tr("<p>Do you really want to delete this mail? <br><br>" ) + mail.getFrom() + " - " + mail.getSubject() ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) { | 190 | if ( QMessageBox::warning(this, tr("Delete Mail"), QString( tr("<p>Do you really want to delete this mail? <br><br>" ) + mail.getFrom() + " - " + mail.getSubject() ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) { |
188 | mail.Wrapper()->deleteMail( mail ); | 191 | mail.Wrapper()->deleteMail( mail ); |
189 | folderView->refreshCurrent(); | 192 | folderView->refreshCurrent(); |
190 | } | 193 | } |
191 | } | 194 | } |
192 | 195 | ||
193 | 196 | ||
194 | 197 | ||
195 | MailListViewItem::MailListViewItem(QListView * parent, MailListViewItem * item ) | 198 | MailListViewItem::MailListViewItem(QListView * parent, MailListViewItem * item ) |
196 | :QListViewItem(parent,item),mail_data() | 199 | :QListViewItem(parent,item),mail_data() |
197 | { | 200 | { |
198 | } | 201 | } |
199 | 202 | ||
200 | void MailListViewItem::showEntry() | 203 | void MailListViewItem::showEntry() |
201 | { | 204 | { |
202 | if ( mail_data.getFlags().testBit( FLAG_ANSWERED ) == true) { | 205 | if ( mail_data.getFlags().testBit( FLAG_ANSWERED ) == true) { |
203 | setPixmap( 0, Resource::loadPixmap( "mail/kmmsgreplied") ); | 206 | setPixmap( 0, Resource::loadPixmap( "mail/kmmsgreplied") ); |
204 | } else if ( mail_data.getFlags().testBit( FLAG_SEEN ) == true ) { | 207 | } else if ( mail_data.getFlags().testBit( FLAG_SEEN ) == true ) { |
205 | setPixmap( 0, Resource::loadPixmap( "mail/kmmsgunseen") ); | 208 | /* I think it looks nicer if there are not such a log of icons but only on mails |
209 | replied or new - Alwin*/ | ||
210 | //setPixmap( 0, Resource::loadPixmap( "mail/kmmsgunseen") ); | ||
206 | } else { | 211 | } else { |
207 | setPixmap( 0, Resource::loadPixmap( "mail/kmmsgnew") ); | 212 | setPixmap( 0, Resource::loadPixmap( "mail/kmmsgnew") ); |
208 | } | 213 | } |
214 | double s = mail_data.Msgsize(); | ||
215 | int w; | ||
216 | w=0; | ||
217 | |||
218 | while (s>1024) { | ||
219 | s/=1024; | ||
220 | ++w; | ||
221 | if (w>=2) break; | ||
222 | } | ||
223 | |||
224 | QString q=""; | ||
225 | QString fsize=""; | ||
226 | switch(w) { | ||
227 | case 1: | ||
228 | q="k"; | ||
229 | break; | ||
230 | case 2: | ||
231 | q="M"; | ||
232 | break; | ||
233 | default: | ||
234 | break; | ||
235 | } | ||
236 | |||
237 | { | ||
238 | QTextOStream o(&fsize); | ||
239 | if (w>0) o.precision(2); else o.precision(0); | ||
240 | o.setf(QTextStream::fixed); | ||
241 | o << s << " " << q << "Byte"; | ||
242 | } | ||
243 | |||
209 | setText(1,mail_data.getSubject()); | 244 | setText(1,mail_data.getSubject()); |
210 | setText(2,mail_data.getFrom()); | 245 | setText(2,mail_data.getFrom()); |
211 | setText(3,mail_data.getDate()); | 246 | setText(3,fsize); |
247 | setText(4,mail_data.getDate()); | ||
212 | } | 248 | } |
213 | 249 | ||
214 | void MailListViewItem::storeData(const RecMail&data) | 250 | void MailListViewItem::storeData(const RecMail&data) |
215 | { | 251 | { |
216 | mail_data = data; | 252 | mail_data = data; |
217 | } | 253 | } |
218 | 254 | ||
219 | const RecMail& MailListViewItem::data()const | 255 | const RecMail& MailListViewItem::data()const |
220 | { | 256 | { |
221 | return mail_data; | 257 | return mail_data; |
222 | } | 258 | } |
223 | 259 | ||
224 | 260 | ||