kmail
kmfilter.h
Go to the documentation of this file.00001 /* -*- mode: C++; c-file-style: "gnu" -*- 00002 * kmail: KDE mail client 00003 * Copyright (c) 1996-1998 Stefan Taferner <taferner@kde.org> 00004 * 00005 * This program is free software; you can redistribute it and/or modify 00006 * it under the terms of the GNU General Public License as published by 00007 * the Free Software Foundation; either version 2 of the License, or 00008 * (at your option) any later version. 00009 * 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 * GNU 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 */ 00020 #ifndef kmfilter_h 00021 #define kmfilter_h 00022 00023 #include "kmsearchpattern.h" 00024 #include "kmpopheaders.h" 00025 00026 #include <kshortcut.h> 00027 00028 #include <qptrlist.h> 00029 00030 class QString; 00031 class KConfig; 00032 class KMMessage; 00033 class KMFilterAction; 00034 class KMFolder; 00035 00036 // maximum number of filter actions per filter 00037 const int FILTER_MAX_ACTIONS = 8; 00038 00039 00040 class KMFilter 00041 { 00042 public: 00054 enum ReturnCode { NoResult, GoOn, CriticalError }; 00055 00065 enum AccountType { All, ButImap, Checked }; 00066 00070 KMFilter( KConfig* aConfig=0 , bool popFilter = false); 00071 00073 KMFilter( const KMFilter & other ); 00074 00076 ~KMFilter() {} 00077 00079 QString name() const { 00080 return mPattern.name(); 00081 } 00082 00094 ReturnCode execActions( KMMessage* msg, bool& stopIt ) const ; 00095 00098 bool requiresBody(KMMsgBase* msgBase); 00099 00101 KMPopFilterAction action(); 00102 00104 void setAction(const KMPopFilterAction aAction); 00105 00110 void writeConfig( KConfig* config ) const; 00111 00116 void readConfig( KConfig* config ); 00117 00119 void purify(); 00120 00122 bool isEmpty() const; 00123 00127 QPtrList<KMFilterAction>* actions() { return &mActions; } 00128 00130 const QPtrList<KMFilterAction>* actions() const { return &mActions; } 00131 00135 KMSearchPattern* pattern() { return &mPattern; } 00136 00140 const KMSearchPattern* pattern() const { return &mPattern; } 00141 00146 void setApplyOnOutbound( bool aApply=true ) { bApplyOnOutbound = aApply; } 00147 00152 bool applyOnOutbound() const { return bApplyOnOutbound; } 00153 00158 void setApplyOnInbound( bool aApply=true ) { bApplyOnInbound = aApply; } 00159 00164 bool applyOnInbound() const { return bApplyOnInbound; } 00165 00170 void setApplyOnExplicit( bool aApply=true ) { bApplyOnExplicit = aApply; } 00171 00176 bool applyOnExplicit() const { return bApplyOnExplicit; } 00177 00185 void setApplicability( AccountType aApply=All ) { mApplicability = aApply; } 00186 00193 AccountType applicability() const { return mApplicability; } 00194 00201 void setApplyOnAccount( uint id, bool aApply=true ); 00202 00207 bool applyOnAccount( uint id ) const; 00208 00209 void setStopProcessingHere( bool aStop ) { bStopProcessingHere = aStop; } 00210 bool stopProcessingHere() const { return bStopProcessingHere; } 00211 00214 void setConfigureShortcut( bool aShort ) { 00215 bConfigureShortcut = aShort; 00216 bConfigureToolbar = bConfigureToolbar && bConfigureShortcut; 00217 } 00218 00223 bool configureShortcut() const { return bConfigureShortcut; } 00224 00229 void setConfigureToolbar( bool aTool ) { 00230 bConfigureToolbar = aTool && bConfigureShortcut; 00231 } 00232 00237 bool configureToolbar() const { return bConfigureToolbar; } 00238 00243 void setShortcut( const KShortcut & shortcut ) { mShortcut = shortcut; }; 00244 00248 const KShortcut & shortcut() const { return mShortcut; } 00249 00254 void setIcon( QString icon ) { mIcon = icon; } 00255 00259 QString icon() const { return mIcon; } 00260 00268 bool folderRemoved( KMFolder* aFolder, KMFolder* aNewFolder ); 00269 00273 #ifndef NDEBUG 00274 const QString asString() const; 00275 #endif 00276 00278 bool isPopFilter() const { 00279 return bPopFilter; 00280 } 00281 00286 void setAutoNaming( bool useAutomaticNames ) { 00287 bAutoNaming = useAutomaticNames; 00288 } 00289 00292 bool isAutoNaming() const { return bAutoNaming; } 00293 00294 private: 00295 KMSearchPattern mPattern; 00296 QPtrList<KMFilterAction> mActions; 00297 QValueList<int> mAccounts; 00298 KMPopFilterAction mAction; 00299 QString mIcon; 00300 KShortcut mShortcut; 00301 bool bPopFilter : 1; 00302 bool bApplyOnInbound : 1; 00303 bool bApplyOnOutbound : 1; 00304 bool bApplyOnExplicit : 1; 00305 bool bStopProcessingHere : 1; 00306 bool bConfigureShortcut : 1; 00307 bool bConfigureToolbar : 1; 00308 bool bAutoNaming : 1; 00309 AccountType mApplicability; 00310 }; 00311 00312 #endif /*kmfilter_h*/