30#include "filterlogdlg.h"
34#include <tdefiledialog.h>
36#include <tdemessagebox.h>
38#include <tqcheckbox.h>
41#include <tqstringlist.h>
42#include <tqtextedit.h>
44#include <tqwhatsthis.h>
45#include <tqvgroupbox.h>
54FilterLogDialog::FilterLogDialog( TQWidget * parent )
55: KDialogBase( parent,
"FilterLogDlg", false, i18n(
"Filter Log Viewer" ),
56 User1|User2|Close, Close, true, KStdGuiItem::clear(), KStdGuiItem::saveAs() )
58 setWFlags( WDestructiveClose );
59 TQVBox *page = makeVBoxMainWidget();
61 mTextEdit =
new TQTextEdit( page );
62 mTextEdit->setReadOnly(
true );
63 mTextEdit->setWordWrap( TQTextEdit::NoWrap );
64 mTextEdit->setTextFormat( TQTextEdit::LogText );
67 for ( TQStringList::Iterator it = logEntries.begin();
68 it != logEntries.end(); ++it )
70 mTextEdit->append( *it );
73 mLogActiveBox =
new TQCheckBox( i18n(
"&Log filter activities"), page );
75 connect( mLogActiveBox, TQ_SIGNAL(clicked()),
76 this, TQ_SLOT(slotSwitchLogState(
void)) );
77 TQWhatsThis::add( mLogActiveBox,
78 i18n(
"You can turn logging of filter activities on and off here. "
79 "Of course, log data is collected and shown only when logging "
82 mLogDetailsBox =
new TQVGroupBox( i18n(
"Logging Details" ), page );
83 mLogDetailsBox->setEnabled( mLogActiveBox->isChecked() );
84 connect( mLogActiveBox, TQ_SIGNAL( toggled(
bool ) ),
85 mLogDetailsBox, TQ_SLOT( setEnabled(
bool ) ) );
87 mLogPatternDescBox =
new TQCheckBox( i18n(
"Log pattern description"),
89 mLogPatternDescBox->setChecked(
91 connect( mLogPatternDescBox, TQ_SIGNAL(clicked()),
92 this, TQ_SLOT(slotChangeLogDetail(
void)) );
97 mLogRuleEvaluationBox =
new TQCheckBox( i18n(
"Log filter &rule evaluation"),
99 mLogRuleEvaluationBox->setChecked(
101 connect( mLogRuleEvaluationBox, TQ_SIGNAL(clicked()),
102 this, TQ_SLOT(slotChangeLogDetail(
void)) );
103 TQWhatsThis::add( mLogRuleEvaluationBox,
104 i18n(
"You can control the feedback in the log concerning the "
105 "evaluation of the filter rules of applied filters: "
106 "having this option checked will give detailed feedback "
107 "for each single filter rule; alternatively, only "
108 "feedback about the result of the evaluation of all rules "
109 "of a single filter will be given." ) );
111 mLogPatternResultBox =
new TQCheckBox( i18n(
"Log filter pattern evaluation"),
113 mLogPatternResultBox->setChecked(
115 connect( mLogPatternResultBox, TQ_SIGNAL(clicked()),
116 this, TQ_SLOT(slotChangeLogDetail(
void)) );
121 mLogFilterActionBox =
new TQCheckBox( i18n(
"Log filter actions"),
123 mLogFilterActionBox->setChecked(
125 connect( mLogFilterActionBox, TQ_SIGNAL(clicked()),
126 this, TQ_SLOT(slotChangeLogDetail(
void)) );
131 TQHBox * hbox =
new TQHBox( page );
132 new TQLabel( i18n(
"Log size limit:"), hbox );
133 mLogMemLimitSpin =
new TQSpinBox( hbox );
134 mLogMemLimitSpin->setMinValue( 1 );
135 mLogMemLimitSpin->setMaxValue( 1024 * 256 );
138 mLogMemLimitSpin->setSuffix(
" KB" );
139 mLogMemLimitSpin->setSpecialValueText( i18n(
"unlimited") );
140 connect( mLogMemLimitSpin, TQ_SIGNAL(valueChanged(
int)),
141 this, TQ_SLOT(slotChangeLogMemLimit(
int)) );
142 TQWhatsThis::add( mLogMemLimitSpin,
143 i18n(
"Collecting log data uses memory to temporarily store the "
144 "log data; here you can limit the maximum amount of memory "
145 "to be used: if the size of the collected log data exceeds "
146 "this limit then the oldest data will be discarded until "
147 "the limit is no longer exceeded. " ) );
150 this, TQ_SLOT(slotLogEntryAdded(TQString)));
152 this, TQ_SLOT(slotLogShrinked(
void)));
154 this, TQ_SLOT(slotLogStateChanged(
void)));
156 setInitialSize( TQSize( 500, 500 ) );
160void FilterLogDialog::slotLogEntryAdded( TQString logEntry )
162 mTextEdit->append( logEntry );
166void FilterLogDialog::slotLogShrinked()
170 if ( mTextEdit->maxLogLines() == -1 )
171 mTextEdit->setMaxLogLines( mTextEdit->lines() );
175void FilterLogDialog::slotLogStateChanged()
178 mLogPatternDescBox->setChecked(
180 mLogRuleEvaluationBox->setChecked(
182 mLogPatternResultBox->setChecked(
184 mLogFilterActionBox->setChecked(
189 if ( mLogMemLimitSpin->value() != newLogSize )
190 mLogMemLimitSpin->setValue( newLogSize );
194void FilterLogDialog::slotChangeLogDetail()
196 if ( mLogPatternDescBox->isChecked() !=
199 mLogPatternDescBox->isChecked() );
201 if ( mLogRuleEvaluationBox->isChecked() !=
204 mLogRuleEvaluationBox->isChecked() );
206 if ( mLogPatternResultBox->isChecked() !=
209 mLogPatternResultBox->isChecked() );
211 if ( mLogFilterActionBox->isChecked() !=
214 mLogFilterActionBox->isChecked() );
218void FilterLogDialog::slotSwitchLogState()
224void FilterLogDialog::slotChangeLogMemLimit(
int value )
230void FilterLogDialog::slotUser1()
237void FilterLogDialog::slotUser2()
240 KFileDialog fdlg( TQString(), TQString(),
this, 0,
true );
242 fdlg.setMode( KFile::File );
243 fdlg.setSelection(
"kmail-filter.log" );
244 fdlg.setOperationMode( KFileDialog::Saving );
247 fileName = fdlg.selectedFile();
250 KMessageBox::error(
this,
251 i18n(
"Could not write the file %1:\n"
252 "\"%2\" is the detailed error description." )
254 TQString::fromLocal8Bit( strerror( errno ) ) ),
255 i18n(
"KMail Error" ) );
261#include "filterlogdlg.moc"
const TQStringList & getLogEntries()
get access to the log entries
void setMaxLogSize(long size=-1)
control the size of the log
void clear()
discard collected log data
void setLogging(bool active)
set the logging state
void setContentTypeEnabled(ContentType contentType, bool b)
add/remove a content type to the set of logged ones
bool isContentTypeEnabled(ContentType contentType)
check a content type for inclusion in the set of logged ones
static FilterLog * instance()
access to the singleton instance