kmail

bodyvisitor.h

Go to the documentation of this file.
00001 /*  -*- mode: C++; c-file-style: "gnu" -*-
00002  *
00003  *  This file is part of KMail, the KDE mail client.
00004  *  Copyright (c) 2003 Carsten Burghardt <burghardt@kde.org>
00005  *
00006  *  KMail is free software; you can redistribute it and/or modify it
00007  *  under the terms of the GNU General Public License, version 2, as
00008  *  published by the Free Software Foundation.
00009  *
00010  *  KMail is distributed in the hope that it will be useful, but
00011  *  WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013  *  General Public License for more details.
00014  *
00015  *  You should have received a copy of the GNU General Public License
00016  *  along with this program; if not, write to the Free Software
00017  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00018  *
00019  *  In addition, as a special exception, the copyright holders give
00020  *  permission to link the code of this program with any edition of
00021  *  the Qt library by Trolltech AS, Norway (or with modified versions
00022  *  of Qt that use the same license as Qt), and distribute linked
00023  *  combinations including the two.  You must obey the GNU General
00024  *  Public License in all respects for all of the code used other than
00025  *  Qt.  If you modify this file, you may extend this exception to
00026  *  your version of the file, but you are not obligated to do so.  If
00027  *  you do not wish to do so, delete this exception statement from
00028  *  your version.
00029  */
00030 
00031 #ifndef bodyiterator_h
00032 #define bodyiterator_h
00033 
00034 #include <qptrlist.h>
00035 #include <qstringlist.h>
00036 
00037 class KMMessagePart;
00038 
00039 namespace KMail {
00040 
00041   class AttachmentStrategy;
00042 
00043   // Base class
00044   class BodyVisitor
00045   {
00046     public:
00047       BodyVisitor();
00048       virtual ~BodyVisitor();
00049 
00051       void visit( KMMessagePart * part );
00052       void visit( QPtrList<KMMessagePart> & list );
00053 
00055       QPtrList<KMMessagePart> partsToLoad();
00056 
00059       virtual bool addPartToList( KMMessagePart * part ) = 0;
00060 
00061     protected:
00066       static bool parentNeedsLoading( KMMessagePart * part );
00067       
00068     protected:
00069       QPtrList<KMMessagePart> mParts;
00070       QStringList mBasicList;
00071   };
00072 
00073   // Factory to create a visitor according to the Attachment Strategy 
00074   class BodyVisitorFactory
00075   {
00076     public:
00077       static BodyVisitor* getVisitor( const AttachmentStrategy* strategy );
00078   };
00079 
00080   // Visitor for smart attachment display
00081   class BodyVisitorSmart: public BodyVisitor
00082   {
00083     public:
00084       BodyVisitorSmart();
00085 
00086       bool addPartToList( KMMessagePart * part );
00087   };
00088   
00089   // Visitor for inline attachment display
00090   class BodyVisitorInline: public BodyVisitor
00091   {
00092     public:
00093       BodyVisitorInline();
00094 
00095       bool addPartToList( KMMessagePart * part );
00096   };
00097   
00098   // Visitor for hidden attachment display
00099   class BodyVisitorHidden: public BodyVisitor
00100   {
00101     public:
00102       BodyVisitorHidden();
00103 
00104       bool addPartToList( KMMessagePart * part );
00105   };
00106 
00107 }
00108 
00109 #endif