kmail

kmmimeparttree.h

Go to the documentation of this file.
00001 /* -*- c++ -*-
00002     kmmimeparttree.cpp A MIME part tree viwer.
00003 
00004     This file is part of KMail, the KDE mail client.
00005     Copyright (c) 2002-2004 Klarälvdalens Datakonsult AB
00006 
00007     KMail is free software; you can redistribute it and/or modify it
00008     under the terms of the GNU General Public License, version 2, as
00009     published by the Free Software Foundation.
00010 
00011     KMail is distributed in the hope that it will be useful, but
00012     WITHOUT ANY WARRANTY; without even the implied warranty of
00013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014     General Public License for more details.
00015 
00016     You should have received a copy of the GNU General Public License
00017     along with this program; if not, write to the Free Software
00018     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00019 
00020     In addition, as a special exception, the copyright holders give
00021     permission to link the code of this program with any edition of
00022     the Qt library by Trolltech AS, Norway (or with modified versions
00023     of Qt that use the same license as Qt), and distribute linked
00024     combinations including the two.  You must obey the GNU General
00025     Public License in all respects for all of the code used other than
00026     Qt.  If you modify this file, you may extend this exception to
00027     your version of the file, but you are not obligated to do so.  If
00028     you do not wish to do so, delete this exception statement from
00029     your version.
00030 */
00031 
00032 
00033 
00034 // -*- c++ -*-
00035 #ifndef KMMIMEPARTTREE_H
00036 #define KMMIMEPARTTREE_H
00037 
00038 #include <klistview.h>
00039 #include <kio/global.h>
00040 
00041 #include <qstring.h>
00042 
00043 class partNode;
00044 class KMReaderWin;
00045 class KMMimePartTreeItem;
00046 
00047 class KMMimePartTree : public KListView
00048 {
00049   Q_OBJECT
00050   friend class ::KMReaderWin;
00051 
00052 public:
00053   KMMimePartTree( KMReaderWin* readerWin,
00054                   QWidget* parent,
00055                   const char* name = 0 );
00056   virtual ~KMMimePartTree();
00057 
00058   void correctSize( QListViewItem * item );
00059 
00060 protected slots:
00061   void itemClicked( QListViewItem* );
00062   void itemRightClicked( QListViewItem*, const QPoint& );
00063   void slotSaveAs();
00064   void slotSaveAsEncoded();
00065   void slotSaveAll();
00066   void slotDelete();
00067   void slotEdit();
00068   void slotOpen();
00069   void slotOpenWith();
00070   void slotView();
00071   void slotProperties();
00072   void slotCopy();
00073 
00074 protected:
00077   void styleChange( QStyle& oldStyle );
00078 
00081   void setStyleDependantFrameWidth();
00082 
00083   void saveSelectedBodyParts( bool encoded );
00084   void restoreLayoutIfPresent();
00085 
00086   /* reimpl */
00087   void startDrag();
00088 
00089   void startHandleAttachmentCommand( int type );
00090 
00091 protected:
00092   KMReaderWin* mReaderWin;
00093   KMMimePartTreeItem* mCurrentContextMenuItem;
00094   int mSizeColumn;
00095 };
00096 
00097 class KMMimePartTreeItem :public QListViewItem
00098 {
00099 public:
00100   KMMimePartTreeItem( KMMimePartTree * parent,
00101                       partNode* node,
00102                       const QString & labelDescr,
00103                       const QString & labelCntType  = QString::null,
00104                       const QString & labelEncoding = QString::null,
00105                       KIO::filesize_t size=0 );
00106   KMMimePartTreeItem( KMMimePartTreeItem * parent,
00107                       partNode* node,
00108                       const QString & labelDescr,
00109                       const QString & labelCntType  = QString::null,
00110                       const QString & labelEncoding = QString::null,
00111                       KIO::filesize_t size=0,
00112                       bool revertOrder = false );
00113   partNode* node() const { return mPartNode; }
00114 
00115   KIO::filesize_t origSize() const { return mOrigSize; }
00116   void setOrigSize( KIO::filesize_t size ) { mOrigSize = size; }
00117 
00118 private:
00119   void setIconAndTextForType( const QString & mimetype );
00120 
00121   partNode* mPartNode;
00122   KIO::filesize_t mOrigSize;
00123 };
00124 
00125 #endif // KMMIMEPARTTREE_H