Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

viewatt.cpp

Go to the documentation of this file.
00001 /**********************************************************************
00002 ** Copyright (C) 2001 Trolltech AS.  All rights reserved.
00003 **
00004 ** This file is part of Qt Palmtop Environment.
00005 **
00006 ** This file may be distributed and/or modified under the terms of the
00007 ** GNU General Public License version 2 as published by the Free Software
00008 ** Foundation and appearing in the file LICENSE.GPL included in the
00009 ** packaging of this file.
00010 **
00011 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00012 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00013 **
00014 ** See http://www.trolltech.com/gpl/ for GPL licensing information.
00015 **
00016 ** Contact info@trolltech.com if any conditions of this licensing are
00017 ** not clear to you.
00018 **
00019 **********************************************************************/
00020 #include <qpe/resource.h>
00021 #include "viewatt.h"
00022 #include <qwhatsthis.h>
00023 #include <qpe/applnk.h>
00024 #include <qpe/mimetype.h>
00025 
00026 ViewAtt::ViewAtt(QWidget *parent, const char *name, WFlags f)
00027         : QMainWindow(parent, name, f)
00028 {
00029         setCaption(tr("Exploring attatchments"));
00030 
00031         setToolBarsMovable( FALSE );
00032         bar = new QToolBar(this);
00033         installButton = new QAction( tr( "Install" ), Resource::loadPixmap( "exec" ), QString::null, CTRL + Key_C, this, 0 );
00034         connect(installButton, SIGNAL(activated()), this, SLOT(install()) );
00035         installButton->setWhatsThis(tr("Click here to install the attachment to your Documents"));
00036 
00037         listView = new QListView(this, "AttView");
00038         listView->addColumn( tr("Attatchment") );
00039         listView->addColumn( tr("Type") );
00040         listView->addColumn( tr("Installed") );
00041         setCentralWidget(listView);
00042         QWhatsThis::add(listView,QWidget::tr("This is an overview about all attachments in the mail"));
00043 }
00044 
00045 void ViewAtt::update(Email *mailIn, bool inbox)
00046 {
00047         QListViewItem *item;
00048         Enclosure *ePtr;
00049 
00050 
00051 
00052         listView->clear();
00053         if (inbox) {
00054                 bar->clear();
00055                 installButton->addTo( bar );
00056                 bar->show();
00057         } else {
00058                 bar->hide();
00059         }
00060 
00061         mail = mailIn;
00062         for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) {
00063 
00064                 QString isInstalled = tr("No");
00065                 if (ePtr->installed)
00066                         isInstalled = tr("Yes");
00067                 item = new QListViewItem(listView, ePtr->originalName, ePtr->contentType, isInstalled);
00068 
00069                 const QString& mtypeDef=(const QString&) ePtr->contentType+"/"+ePtr->contentAttribute;
00070 
00071                 MimeType mt(mtypeDef);
00072 
00073                 item->setPixmap(0, mt.pixmap());
00074 
00075                 /*
00076                 if (ePtr->contentType == "TEXT") {
00077                         actions = new QAction( tr("View"), Resource::loadPixmap("TextEditor"), QString::null, CTRL + Key_C, this, 0);
00078                         actions->addTo(bar);
00079                                 }
00080                 if (ePtr->contentType == "AUDIO") {
00081                         actions = new QAction( tr("Play"), Resource::loadPixmap("SoundPlayer"), QString::null, CTRL + Key_C, this, 0);
00082                         actions->addTo(bar);
00083                         item->setPixmap(0, Resource::loadPixmap("play"));
00084                 }
00085                 if (ePtr->contentType == "IMAGE") {
00086                         actions = new QAction( tr("Show"), Resource::loadPixmap("pixmap"), QString::null, CTRL + Key_C, this, 0);
00087                         actions->addTo(bar);
00088                         item->setPixmap(0, Resource::loadPixmap("pixmap"));
00089                 }*/
00090         }
00091 }
00092 
00093 void ViewAtt::install()
00094 {
00095         Enclosure *ePtr, *selPtr;
00096         QListViewItem *item;
00097         QString filename;
00098         DocLnk d;
00099 
00100         item = listView->selectedItem();
00101         if (item != NULL) {
00102                 filename  = item->text(0);
00103                 selPtr = NULL;
00104                 for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) {
00105                         if (ePtr->originalName == filename)
00106                                 selPtr = ePtr;
00107                 }
00108 
00109                 if (selPtr == NULL) {
00110                         qWarning("Internal error, file is not installed to documents");
00111                         return;
00112                 }
00113 
00114                 d.setName(selPtr->originalName);
00115                 d.setFile(selPtr->path + selPtr->name);
00116                 d.setType(selPtr->contentType + "/" + selPtr->contentAttribute);
00117                 d.writeLink();
00118                 selPtr->installed = TRUE;
00119                 item->setText(2, tr("Yes"));
00120         }
00121 }

Generated on Sat Nov 5 16:18:09 2005 for OPIE by  doxygen 1.4.2