kmail

kmmimeparttree.h
1 /* -*- c++ -*-
2  kmmimeparttree.cpp A MIME part tree viwer.
3 
4  This file is part of KMail, the KDE mail client.
5  Copyright (c) 2002-2004 Klarälvdalens Datakonsult AB
6 
7  KMail is free software; you can redistribute it and/or modify it
8  under the terms of the GNU General Public License, version 2, as
9  published by the Free Software Foundation.
10 
11  KMail is distributed in the hope that it will be useful, but
12  WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with this program; if not, write to the Free Software
18  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 
20  In addition, as a special exception, the copyright holders give
21  permission to link the code of this program with any edition of
22  the TQt library by Trolltech AS, Norway (or with modified versions
23  of TQt that use the same license as TQt), and distribute linked
24  combinations including the two. You must obey the GNU General
25  Public License in all respects for all of the code used other than
26  TQt. If you modify this file, you may extend this exception to
27  your version of the file, but you are not obligated to do so. If
28  you do not wish to do so, delete this exception statement from
29  your version.
30 */
31 
32 
33 
34 // -*- c++ -*-
35 #ifndef KMMIMEPARTTREE_H
36 #define KMMIMEPARTTREE_H
37 
38 #include <tdelistview.h>
39 #include <tdeio/global.h>
40 
41 #include <tqstring.h>
42 
43 class partNode;
44 class KMReaderWin;
45 class KMMimePartTreeItem;
46 
47 class KMMimePartTree : public TDEListView
48 {
49  Q_OBJECT
50 
51  friend class ::KMReaderWin;
52 
53 public:
54  KMMimePartTree( KMReaderWin* readerWin,
55  TQWidget* parent,
56  const char* name = 0 );
57  virtual ~KMMimePartTree();
58 
59  void correctSize( TQListViewItem * item );
60 
61 protected slots:
62  void itemClicked( TQListViewItem* );
63  void itemRightClicked( TQListViewItem*, const TQPoint& );
64  void slotSaveAs();
65  void slotSaveAsEncoded();
66  void slotSaveAll();
67  void slotDelete();
68  void slotEdit();
69  void slotOpen();
70  void slotOpenWith();
71  void slotView();
72  void slotProperties();
73  void slotCopy();
74 
75 protected:
78  void styleChange( TQStyle& oldStyle );
79 
82  void setStyleDependantFrameWidth();
83 
84  void saveSelectedBodyParts( bool encoded );
85  void restoreLayoutIfPresent();
86 
87  /* reimpl */
88  void startDrag();
89 
90  void startHandleAttachmentCommand( int type );
91 
92 protected:
93  KMReaderWin* mReaderWin;
94  KMMimePartTreeItem* mCurrentContextMenuItem;
95  int mSizeColumn;
96 };
97 
98 class KMMimePartTreeItem :public TQListViewItem
99 {
100 public:
101  KMMimePartTreeItem( KMMimePartTree * parent,
102  partNode* node,
103  const TQString & labelDescr,
104  const TQString & labelCntType = TQString(),
105  const TQString & labelEncoding = TQString(),
106  TDEIO::filesize_t size=0 );
107  KMMimePartTreeItem( KMMimePartTreeItem * parent,
108  partNode* node,
109  const TQString & labelDescr,
110  const TQString & labelCntType = TQString(),
111  const TQString & labelEncoding = TQString(),
112  TDEIO::filesize_t size=0,
113  bool revertOrder = false );
114  partNode* node() const { return mPartNode; }
115 
116  TDEIO::filesize_t origSize() const { return mOrigSize; }
117  void setOrigSize( TDEIO::filesize_t size ) { mOrigSize = size; }
118 
119 private:
120  void setIconAndTextForType( const TQString & mimetype );
121 
122  partNode* mPartNode;
123  TDEIO::filesize_t mOrigSize;
124 };
125 
126 #endif // KMMIMEPARTTREE_H