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 QObject
00054 {
00055 Q_OBJECT
00056
00057 public:
00059 static FilterLog * instance();
00060
00062 enum ContentType
00063 {
00064 meta = 1,
00065 patternDesc = 2,
00066 ruleResult = 4,
00067 patternResult = 8,
00068 appliedAction = 16
00069 };
00070
00071
00073 bool isLogging() { return mLogging; };
00075 void setLogging( bool active )
00076 {
00077 mLogging = active;
00078 emit logStateChanged();
00079 };
00080
00081
00083 void setMaxLogSize( long size = -1 );
00084 long getMaxLogSize() { return mMaxLogSize; };
00085
00086
00088 void setContentTypeEnabled( ContentType contentType, bool b )
00089 {
00090 if ( b )
00091 mAllowedTypes |= contentType;
00092 else
00093 mAllowedTypes &= ~contentType;
00094 emit logStateChanged();
00095 };
00096
00098 bool isContentTypeEnabled( ContentType contentType )
00099 {
00100 return mAllowedTypes & contentType;
00101 };
00102
00103
00105 void add( TQString logEntry, ContentType contentType );
00107 void addSeparator() { add( "------------------------------", meta ); };
00109 void clear()
00110 {
00111 mLogEntries.clear();
00112 mCurrentLogSize = 0;
00113 emit logShrinked();
00114 };
00115
00116
00118 const TQStringList & getLogEntries() { return mLogEntries; };
00120 void dump();
00122 bool saveToFile( TQString fileName );
00123
00125 virtual ~FilterLog();
00126
00127 static TQString recode( const TQString & plain ) { return TQStyleSheet::escape(plain); };
00128
00129 signals:
00130 void logEntryAdded( TQString );
00131 void logShrinked();
00132 void logStateChanged();
00133
00134 protected:
00136 FilterLog();
00137
00139 TQStringList mLogEntries;
00140
00142 bool mLogging;
00143
00147 long mMaxLogSize;
00148 long mCurrentLogSize;
00149
00151 int mAllowedTypes;
00152
00153 void checkLogSize();
00154
00155 private:
00156 static FilterLog * mSelf;
00157 };
00158
00159 }
00160
00161 #endif // KMAIL_FILTERLOG_H
|