00001 #include "viewmailbase.h"
00002
00003
00004 #include <opie2/oresource.h>
00005 using namespace Opie::Core;
00006
00007
00008 #include <qtextbrowser.h>
00009 #include <qlistview.h>
00010 #include <qaction.h>
00011 #include <qlabel.h>
00012 #include <qvbox.h>
00013 #include <qtoolbar.h>
00014 #include <qlayout.h>
00015 #include <qmenubar.h>
00016
00017 ViewMailBase::ViewMailBase(QWidget *parent, const char *name, WFlags fl)
00018 : QMainWindow(parent, name, fl)
00019 {
00020 setCaption(tr("E-Mail view"));
00021 setToolBarsMovable(false);
00022
00023 toolbar = new QToolBar(this);
00024 menubar = new QMenuBar( toolbar );
00025 mailmenu = new QPopupMenu( menubar );
00026 menubar->insertItem( tr( "Mail" ), mailmenu );
00027 toolbar->setHorizontalStretchable(true);
00028 addToolBar(toolbar);
00029 QLabel *spacer = new QLabel(toolbar);
00030 spacer->setBackgroundMode(QWidget::PaletteButton);
00031 toolbar->setStretchableWidget(spacer);
00032
00033 reply = new QAction(tr("Reply"), OResource::loadPixmap("mail/reply", OResource::SmallIcon), 0, 0, this);
00034 reply->addTo(toolbar);
00035 reply->addTo(mailmenu);
00036
00037 forward = new QAction(tr("Forward"), OResource::loadPixmap("mail/forward", OResource::SmallIcon), 0, 0, this);
00038 forward->addTo(toolbar);
00039 forward->addTo(mailmenu);
00040
00041 attachbutton = new QAction(tr("Attachments"), OResource::loadPixmap("mail/attach", OResource::SmallIcon), 0, 0, this, 0, true);
00042 attachbutton->addTo(toolbar);
00043 attachbutton->addTo(mailmenu);
00044 connect(attachbutton, SIGNAL(toggled(bool)), SLOT(slotChangeAttachview(bool)));
00045
00046
00047 showHtml = new QAction( tr( "Show Html" ), OResource::loadPixmap( "mail/html", OResource::SmallIcon ), 0, 0, this, 0, true );
00048 showHtml->addTo( toolbar );
00049 showHtml->addTo( mailmenu );
00050
00051 showPicsInline= new QAction(tr("Show image preview inline"), OResource::loadPixmap("pixmap", OResource::SmallIcon), 0, 0, this);
00052 showPicsInline->setToggleAction(true);
00053 showPicsInline->addTo(toolbar);
00054 showPicsInline->addTo(mailmenu);
00055
00056 deleteMail = new QAction(tr("Delete Mail"), OResource::loadPixmap("trash", OResource::SmallIcon), 0, 0, this);
00057 deleteMail->addTo(toolbar);
00058 deleteMail->addTo(mailmenu);
00059
00060 QVBox * view = new QVBox(this);
00061 view->setSpacing(1);
00062 view->setMargin(0);
00063 setCentralWidget(view);
00064
00065 attachments = new QListView(view);
00066 attachments->setMinimumHeight(90);
00067 attachments->setMaximumHeight(90);
00068 attachments->setAllColumnsShowFocus(true);
00069 attachments->addColumn("Mime Type", 60);
00070 attachments->addColumn(tr("Description"), 100);
00071 attachments->addColumn(tr("Filename"), 80);
00072 attachments->addColumn(tr("Size"), 80);
00073 attachments->setSorting(-1);
00074
00075 browser = new QTextBrowser(view);
00076 adjustSize();
00077 attachments->hide();
00078 }
00079
00080 void ViewMailBase::slotChangeAttachview(bool state)
00081 {
00082 if (state) attachments->show();
00083 else attachments->hide();
00084 }
00085
00086 void ViewMailBase::keyPressEvent ( QKeyEvent * e )
00087 {
00088 if( e->key()==Qt::Key_Escape ) {
00089 close();
00090 e->accept();
00091 return;
00092 }
00093 QWidget::keyPressEvent(e);
00094 }