| 
    kmailkmfiltermgr.hGo to the documentation of this file.00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 #ifndef kmfiltermgr_h
00021 #define kmfiltermgr_h
00022 
00023 #include "kmfilteraction.h" 
00024 #include "kmfolder.h"
00025 
00026 #include <qguardedptr.h>
00027 #include <qobject.h>
00028 
00029 class KMFilter;
00030 class KMFilterDlg;
00031 template <typename T> class QValueVector;
00032 template <typename T> class QValueList;
00033 
00034 class KMFilterMgr: public QObject
00035 {
00036   Q_OBJECT
00037 
00038 public:
00039   KMFilterMgr(bool popFilter = false);
00040   virtual ~KMFilterMgr();
00041 
00043   void clear();
00044 
00045   enum FilterSet { NoSet = 0x0, Inbound = 0x1, Outbound = 0x2, Explicit = 0x4,
00046            All = Inbound|Outbound|Explicit };
00047 
00049   void readConfig(void);
00050 
00052   void writeConfig(bool withSync=TRUE);
00053   
00057   void openDialog( QWidget *parent, bool checkForEmptyFilterList = true );
00058 
00061   void createFilter( const QCString & field, const QString & value );
00062 
00063   bool beginFiltering(KMMsgBase *msgBase) const;
00064   int moveMessage(KMMessage *msg) const;
00065   void endFiltering(KMMsgBase *msgBase) const;
00066 
00072   bool atLeastOneFilterAppliesTo( unsigned int accountID ) const;
00078   bool atLeastOneIncomingFilterAppliesTo( unsigned int accountID ) const;
00082   bool atLeastOneOnlineImapFolderTarget();
00083 
00086   const QString createUniqueName( const QString & name );
00087 
00091   void appendFilters( const QValueList<KMFilter*> &filters,
00092                       bool replaceIfNameExists = false );
00093 
00096   void setFilters( const QValueList<KMFilter*> &filters );
00097 
00099   const QValueList<KMFilter*> & filters() const { return mFilters; }
00100 
00115   int process( KMMessage * msg, FilterSet aSet = Inbound,
00116            bool account = false, uint accountId = 0 );
00117 
00122   int process( KMMessage * msg, const KMFilter * filter );
00123 
00126   int process( Q_UINT32 serNum, const KMFilter * filter );
00127 
00128   void cleanup();
00131   void ref();
00137   void deref(bool force = false);
00138 
00143   int tempOpenFolder(KMFolder* aFolder);
00144 
00147   void beginUpdate() {}
00148 
00150   void endUpdate();
00151 
00153 #ifndef NDEBUG
00154   void dump() const;
00155 #endif
00156 
00161   bool folderRemoved(KMFolder* aFolder, KMFolder* aNewFolder);
00162 
00165   void folderCreated(KMFolder*) {}
00166 
00168   void setShowLaterMsgs( bool show ) {
00169     mShowLater = show;
00170   }
00171 
00173   bool showLaterMsgs() const {
00174     return mShowLater;
00175   }
00176 public slots:
00177   void slotFolderRemoved( KMFolder *aFolder );
00178 
00179 signals:
00180   void filterListUpdated();
00181 
00182 private:
00183   int processPop( KMMessage *msg ) const;
00185   bool isMatching( Q_UINT32 serNum, const KMFilter *filter );
00186 
00187   QGuardedPtr<KMFilterDlg> mEditDialog;
00188   QValueVector<KMFolder *> mOpenFolders;
00189   QValueList<KMFilter *> mFilters;
00190   bool bPopFilter;
00191   bool mShowLater;
00192   bool mDirtyBufferedFolderTarget;
00193   bool mBufferedFolderTarget;
00194 
00195   int mRefCount;
00196 };
00197 
00198 #endif 
          
         |