kmail

filterlog.h
1/*
2 This file is part of KMail.
3 Copyright (c) 2003 Andreas Gungl <a.gungl@gmx.de>
4
5 KMail is free software; you can redistribute it and/or modify it
6 under the terms of the GNU General Public License, version 2, as
7 published by the Free Software Foundation.
8
9 KMail is distributed in the hope that it will be useful, but
10 WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
18 In addition, as a special exception, the copyright holders give
19 permission to link the code of this program with any edition of
20 the TQt library by Trolltech AS, Norway (or with modified versions
21 of TQt that use the same license as TQt), and distribute linked
22 combinations including the two. You must obey the GNU General
23 Public License in all respects for all of the code used other than
24 TQt. If you modify this file, you may extend this exception to
25 your version of the file, but you are not obligated to do so. If
26 you do not wish to do so, delete this exception statement from
27 your version.
28*/
29#ifndef KMAIL_FILTERLOG_H
30#define KMAIL_FILTERLOG_H
31
32#include <tqobject.h>
33#include <tqstringlist.h>
34#include <tqstylesheet.h>
35
36namespace KMail {
37
53 class FilterLog : public TQObject
54 {
55 TQ_OBJECT
56
57
58 public:
60 static FilterLog * instance();
61
64 {
65 meta = 1,
66 patternDesc = 2,
67 ruleResult = 4,
68 patternResult = 8,
69 appliedAction = 16
70 };
71
72
74 bool isLogging() { return mLogging; };
76 void setLogging( bool active )
77 {
78 mLogging = active;
79 emit logStateChanged();
80 };
81
82
84 void setMaxLogSize( long size = -1 );
85 long getMaxLogSize() { return mMaxLogSize; };
86
87
89 void setContentTypeEnabled( ContentType contentType, bool b )
90 {
91 if ( b )
92 mAllowedTypes |= contentType;
93 else
94 mAllowedTypes &= ~contentType;
95 emit logStateChanged();
96 };
97
100 {
101 return mAllowedTypes & contentType;
102 };
103
104
106 void add( TQString logEntry, ContentType contentType );
108 void addSeparator() { add( "------------------------------", meta ); };
110 void clear()
111 {
112 mLogEntries.clear();
113 mCurrentLogSize = 0;
114 emit logShrinked();
115 };
116
117
119 const TQStringList & getLogEntries() { return mLogEntries; };
121 void dump();
123 bool saveToFile( TQString fileName );
124
126 virtual ~FilterLog();
127
128 static TQString recode( const TQString & plain ) { return TQStyleSheet::escape(plain); };
129
130 signals:
131 void logEntryAdded( TQString );
132 void logShrinked();
133 void logStateChanged();
134
135 protected:
137 FilterLog();
138
140 TQStringList mLogEntries;
141
144
149 long mCurrentLogSize;
150
153
154 void checkLogSize();
155
156 private:
157 static FilterLog * mSelf;
158 };
159
160} // namespace KMail
161
162#endif // KMAIL_FILTERLOG_H
KMail Filter Log Collector.
Definition: filterlog.h:54
bool mLogging
the log status
Definition: filterlog.h:143
const TQStringList & getLogEntries()
get access to the log entries
Definition: filterlog.h:119
bool isLogging()
check the logging state
Definition: filterlog.h:74
TQStringList mLogEntries
The list contains the single log pieces.
Definition: filterlog.h:140
void addSeparator()
add a separating line in the log
Definition: filterlog.h:108
void setMaxLogSize(long size=-1)
control the size of the log
Definition: filterlog.cpp:88
void clear()
discard collected log data
Definition: filterlog.h:110
void setLogging(bool active)
set the logging state
Definition: filterlog.h:76
void setContentTypeEnabled(ContentType contentType, bool b)
add/remove a content type to the set of logged ones
Definition: filterlog.h:89
FilterLog()
Non-public constructor needed by the singleton implementation.
Definition: filterlog.cpp:46
bool saveToFile(TQString fileName)
save the log to a file - returns true if okay
Definition: filterlog.cpp:143
void add(TQString logEntry, ContentType contentType)
add a log entry
Definition: filterlog.cpp:71
bool isContentTypeEnabled(ContentType contentType)
check a content type for inclusion in the set of logged ones
Definition: filterlog.h:99
static FilterLog * instance()
access to the singleton instance
Definition: filterlog.cpp:64
long mMaxLogSize
max size for kept log items, when reached the last recently added items are discarded -1 means unlimi...
Definition: filterlog.h:148
void dump()
dump the log - for testing purposes
Definition: filterlog.cpp:101
virtual ~FilterLog()
destructor
Definition: filterlog.cpp:60
int mAllowedTypes
types currently allowed to be legged
Definition: filterlog.h:152
ContentType
log data types
Definition: filterlog.h:64
folderdiaquotatab.h
Definition: aboutdata.cpp:40