author | alwin <alwin> | 2003-12-19 19:29:26 (UTC) |
---|---|---|
committer | alwin <alwin> | 2003-12-19 19:29:26 (UTC) |
commit | b66e2d718769a3ac1ae6bc1fc135c04f532bdbf3 (patch) (side-by-side diff) | |
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 @@ #include <qlabel.h> #include <qvbox.h> #include <qheader.h> #include <qtimer.h> #include <qlayout.h> #include <qmessagebox.h> +#include <qtextstream.h> #include <qpe/qpeapplication.h> #include <qpe/resource.h> #include "defines.h" #include "mainwindow.h" #include "viewmail.h" #include "mailtypes.h" #include "mailistviewitem.h" MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags ) : QMainWindow( parent, name, flags ) { setCaption( tr( "Mail" ) ); setToolBarsMovable( false ); toolBar = new QToolBar( this ); menuBar = new QMenuBar( toolBar ); mailMenu = new QPopupMenu( menuBar ); menuBar->insertItem( tr( "Mail" ), mailMenu ); settingsMenu = new QPopupMenu( menuBar ); menuBar->insertItem( tr( "Settings" ), settingsMenu ); addToolBar( toolBar ); @@ -72,91 +73,93 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags ) 0, 0, this ); editSettings->addTo( settingsMenu ); editAccounts = new QAction( tr( "Configure accounts" ), ICON_EDITACCOUNTS, 0, 0, this ); editAccounts->addTo( settingsMenu ); QWidget *view = new QWidget( this ); setCentralWidget( view ); layout = new QBoxLayout ( view, QBoxLayout::LeftToRight ); folderView = new AccountView( view ); folderView->header()->hide(); folderView->setRootIsDecorated( true ); folderView->addColumn( tr( "Mailbox" ) ); //folderView->hide(); layout->addWidget( folderView ); mailView = new QListView( view ); mailView->addColumn( tr( "" ) ); mailView->addColumn( tr( "Subject" ),QListView::Manual ); mailView->addColumn( tr( "Sender" ),QListView::Manual ); + mailView->addColumn( tr( "Size" ),QListView::Manual); mailView->addColumn( tr( "Date" )); mailView->setAllColumnsShowFocus(true); mailView->setSorting(-1); layout->addWidget( mailView ); layout->setStretchFactor( folderView, 1 ); layout->setStretchFactor( mailView, 2 ); slotAdjustLayout(); connect( mailView, SIGNAL( clicked( QListViewItem * ) ),this, SLOT( displayMail( QListViewItem * ) ) ); connect(folderView, SIGNAL(refreshMailview(QList<RecMail>*)),this,SLOT(refreshMailView(QList<RecMail>*))); QTimer::singleShot( 1000, this, SLOT( slotAdjustColumns() ) ); } void MainWindow::slotAdjustLayout() { QWidget *d = QApplication::desktop(); if ( d->width() < d->height() ) { layout->setDirection( QBoxLayout::TopToBottom ); } else { layout->setDirection( QBoxLayout::LeftToRight ); } delete d; } void MainWindow::slotAdjustColumns() { bool hidden = folderView->isHidden(); if ( hidden ) folderView->show(); folderView->setColumnWidth( 0, folderView->visibleWidth() ); if ( hidden ) folderView->hide(); mailView->setColumnWidth( 0, 10 ); mailView->setColumnWidth( 1, mailView->visibleWidth() - 130 ); mailView->setColumnWidth( 2, 80 ); mailView->setColumnWidth( 3, 50 ); + mailView->setColumnWidth( 4, 50 ); } void MainWindow::slotShowFolders( bool show ) { qDebug( "Show Folders" ); if ( show && folderView->isHidden() ) { qDebug( "-> showing" ); folderView->show(); } else if ( !show && !folderView->isHidden() ) { qDebug( "-> hiding" ); folderView->hide(); } } void MainWindow::refreshMailView(QList<RecMail>*list) { MailListViewItem*item = 0; mailView->clear(); for (unsigned int i = 0; i < list->count();++i) { item = new MailListViewItem(mailView,item); item->storeData(*(list->at(i))); item->showEntry(); } } @@ -181,44 +184,77 @@ void MainWindow::displayMail(QListViewItem*item) } void MainWindow::slotDeleteMail() { if (!mailView->currentItem()) return; RecMail mail = ((MailListViewItem*)mailView->currentItem() )->data(); 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 ) { mail.Wrapper()->deleteMail( mail ); folderView->refreshCurrent(); } } MailListViewItem::MailListViewItem(QListView * parent, MailListViewItem * item ) :QListViewItem(parent,item),mail_data() { } void MailListViewItem::showEntry() { if ( mail_data.getFlags().testBit( FLAG_ANSWERED ) == true) { setPixmap( 0, Resource::loadPixmap( "mail/kmmsgreplied") ); } else if ( mail_data.getFlags().testBit( FLAG_SEEN ) == true ) { - setPixmap( 0, Resource::loadPixmap( "mail/kmmsgunseen") ); + /* I think it looks nicer if there are not such a log of icons but only on mails + replied or new - Alwin*/ + //setPixmap( 0, Resource::loadPixmap( "mail/kmmsgunseen") ); } else { setPixmap( 0, Resource::loadPixmap( "mail/kmmsgnew") ); } + double s = mail_data.Msgsize(); + int w; + w=0; + + while (s>1024) { + s/=1024; + ++w; + if (w>=2) break; + } + + QString q=""; + QString fsize=""; + switch(w) { + case 1: + q="k"; + break; + case 2: + q="M"; + break; + default: + break; + } + + { + QTextOStream o(&fsize); + if (w>0) o.precision(2); else o.precision(0); + o.setf(QTextStream::fixed); + o << s << " " << q << "Byte"; + } + setText(1,mail_data.getSubject()); setText(2,mail_data.getFrom()); - setText(3,mail_data.getDate()); + setText(3,fsize); + setText(4,mail_data.getDate()); } void MailListViewItem::storeData(const RecMail&data) { mail_data = data; } const RecMail& MailListViewItem::data()const { return mail_data; } |