kmail
filterlog.h00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef KMAIL_FILTERLOG_H
00030 #define KMAIL_FILTERLOG_H
00031
00032 #include <tqobject.h>
00033 #include <tqstringlist.h>
00034 #include <tqstylesheet.h>
00035
00036 namespace KMail {
00037
00053 class FilterLog : public TQObject
00054 {
00055 Q_OBJECT
00056
00057
00058 public:
00060 static FilterLog * instance();
00061
00063 enum ContentType
00064 {
00065 meta = 1,
00066 patternDesc = 2,
00067 ruleResult = 4,
00068 patternResult = 8,
00069 appliedAction = 16
00070 };
00071
00072
00074 bool isLogging() { return mLogging; };
00076 void setLogging( bool active )
00077 {
00078 mLogging = active;
00079 emit logStateChanged();
00080 };
00081
00082
00084 void setMaxLogSize( long size = -1 );
00085 long getMaxLogSize() { return mMaxLogSize; };
00086
00087
00089 void setContentTypeEnabled( ContentType contentType, bool b )
00090 {
00091 if ( b )
00092 mAllowedTypes |= contentType;
00093 else
00094 mAllowedTypes &= ~contentType;
00095 emit logStateChanged();
00096 };
00097
00099 bool isContentTypeEnabled( ContentType contentType )
00100 {
00101 return mAllowedTypes & contentType;
00102 };
00103
00104
00106 void add( TQString logEntry, ContentType contentType );
00108 void addSeparator() { add( "------------------------------", meta ); };
00110 void clear()
00111 {
00112 mLogEntries.clear();
00113 mCurrentLogSize = 0;
00114 emit logShrinked();
00115 };
00116
00117
00119 const TQStringList & getLogEntries() { return mLogEntries; };
00121 void dump();
00123 bool saveToFile( TQString fileName );
00124
00126 virtual ~FilterLog();
00127
00128 static TQString recode( const TQString & plain ) { return TQStyleSheet::escape(plain); };
00129
00130 signals:
00131 void logEntryAdded( TQString );
00132 void logShrinked();
00133 void logStateChanged();
00134
00135 protected:
00137 FilterLog();
00138
00140 TQStringList mLogEntries;
00141
00143 bool mLogging;
00144
00148 long mMaxLogSize;
00149 long mCurrentLogSize;
00150
00152 int mAllowedTypes;
00153
00154 void checkLogSize();
00155
00156 private:
00157 static FilterLog * mSelf;
00158 };
00159
00160 }
00161
00162 #endif // KMAIL_FILTERLOG_H
|