30 #include "filterlogdlg.h"
31 #include "filterlog.h"
34 #include <tdeversion.h>
35 #include <tdefiledialog.h>
36 #include <tdelocale.h>
37 #include <tdemessagebox.h>
39 #include <tqcheckbox.h>
41 #include <tqspinbox.h>
42 #include <tqstringlist.h>
43 #include <tqtextedit.h>
45 #include <tqwhatsthis.h>
46 #include <tqvgroupbox.h>
50 #include <X11/Xatom.h>
52 using namespace KMail;
56 : KDialogBase( parent,
"FilterLogDlg", false, i18n(
"Filter Log Viewer" ),
57 User1|User2|Close, Close, true, KStdGuiItem::clear(), KStdGuiItem::saveAs() )
59 setWFlags( WDestructiveClose );
60 TQVBox *page = makeVBoxMainWidget();
62 mTextEdit =
new TQTextEdit( page );
63 mTextEdit->setReadOnly(
true );
64 mTextEdit->setWordWrap( TQTextEdit::NoWrap );
65 mTextEdit->setTextFormat( TQTextEdit::LogText );
68 for ( TQStringList::Iterator it = logEntries.begin();
69 it != logEntries.end(); ++it )
71 mTextEdit->append( *it );
74 mLogActiveBox =
new TQCheckBox( i18n(
"&Log filter activities"), page );
76 connect( mLogActiveBox, TQ_SIGNAL(clicked()),
77 this, TQ_SLOT(slotSwitchLogState(
void)) );
78 TQWhatsThis::add( mLogActiveBox,
79 i18n(
"You can turn logging of filter activities on and off here. "
80 "Of course, log data is collected and shown only when logging "
83 mLogDetailsBox =
new TQVGroupBox( i18n(
"Logging Details" ), page );
84 mLogDetailsBox->setEnabled( mLogActiveBox->isChecked() );
85 connect( mLogActiveBox, TQ_SIGNAL( toggled(
bool ) ),
86 mLogDetailsBox, TQ_SLOT( setEnabled(
bool ) ) );
88 mLogPatternDescBox =
new TQCheckBox( i18n(
"Log pattern description"),
90 mLogPatternDescBox->setChecked(
92 connect( mLogPatternDescBox, TQ_SIGNAL(clicked()),
93 this, TQ_SLOT(slotChangeLogDetail(
void)) );
98 mLogRuleEvaluationBox =
new TQCheckBox( i18n(
"Log filter &rule evaluation"),
100 mLogRuleEvaluationBox->setChecked(
102 connect( mLogRuleEvaluationBox, TQ_SIGNAL(clicked()),
103 this, TQ_SLOT(slotChangeLogDetail(
void)) );
104 TQWhatsThis::add( mLogRuleEvaluationBox,
105 i18n(
"You can control the feedback in the log concerning the "
106 "evaluation of the filter rules of applied filters: "
107 "having this option checked will give detailed feedback "
108 "for each single filter rule; alternatively, only "
109 "feedback about the result of the evaluation of all rules "
110 "of a single filter will be given." ) );
112 mLogPatternResultBox =
new TQCheckBox( i18n(
"Log filter pattern evaluation"),
114 mLogPatternResultBox->setChecked(
116 connect( mLogPatternResultBox, TQ_SIGNAL(clicked()),
117 this, TQ_SLOT(slotChangeLogDetail(
void)) );
122 mLogFilterActionBox =
new TQCheckBox( i18n(
"Log filter actions"),
124 mLogFilterActionBox->setChecked(
126 connect( mLogFilterActionBox, TQ_SIGNAL(clicked()),
127 this, TQ_SLOT(slotChangeLogDetail(
void)) );
132 TQHBox * hbox =
new TQHBox( page );
133 new TQLabel( i18n(
"Log size limit:"), hbox );
134 mLogMemLimitSpin =
new TQSpinBox( hbox );
135 mLogMemLimitSpin->setMinValue( 1 );
136 mLogMemLimitSpin->setMaxValue( 1024 * 256 );
139 mLogMemLimitSpin->setSuffix(
" KB" );
140 mLogMemLimitSpin->setSpecialValueText( i18n(
"unlimited") );
141 connect( mLogMemLimitSpin, TQ_SIGNAL(valueChanged(
int)),
142 this, TQ_SLOT(slotChangeLogMemLimit(
int)) );
143 TQWhatsThis::add( mLogMemLimitSpin,
144 i18n(
"Collecting log data uses memory to temporarily store the "
145 "log data; here you can limit the maximum amount of memory "
146 "to be used: if the size of the collected log data exceeds "
147 "this limit then the oldest data will be discarded until "
148 "the limit is no longer exceeded. " ) );
151 this, TQ_SLOT(slotLogEntryAdded(TQString)));
153 this, TQ_SLOT(slotLogShrinked(
void)));
155 this, TQ_SLOT(slotLogStateChanged(
void)));
157 setInitialSize( TQSize( 500, 500 ) );
158 #if !KDE_IS_VERSION( 3, 2, 91 )
162 XDeleteProperty( tqt_xdisplay(), winId(), XA_WM_TRANSIENT_FOR );
167 void FilterLogDialog::slotLogEntryAdded( TQString logEntry )
169 mTextEdit->append( logEntry );
173 void FilterLogDialog::slotLogShrinked()
177 if ( mTextEdit->maxLogLines() == -1 )
178 mTextEdit->setMaxLogLines( mTextEdit->lines() );
182 void FilterLogDialog::slotLogStateChanged()
185 mLogPatternDescBox->setChecked(
187 mLogRuleEvaluationBox->setChecked(
189 mLogPatternResultBox->setChecked(
191 mLogFilterActionBox->setChecked(
196 if ( mLogMemLimitSpin->value() != newLogSize )
197 mLogMemLimitSpin->setValue( newLogSize );
201 void FilterLogDialog::slotChangeLogDetail()
203 if ( mLogPatternDescBox->isChecked() !=
206 mLogPatternDescBox->isChecked() );
208 if ( mLogRuleEvaluationBox->isChecked() !=
211 mLogRuleEvaluationBox->isChecked() );
213 if ( mLogPatternResultBox->isChecked() !=
216 mLogPatternResultBox->isChecked() );
218 if ( mLogFilterActionBox->isChecked() !=
221 mLogFilterActionBox->isChecked() );
225 void FilterLogDialog::slotSwitchLogState()
231 void FilterLogDialog::slotChangeLogMemLimit(
int value )
237 void FilterLogDialog::slotUser1()
244 void FilterLogDialog::slotUser2()
247 KFileDialog fdlg( TQString(), TQString(),
this, 0,
true );
249 fdlg.setMode( KFile::File );
250 fdlg.setSelection(
"kmail-filter.log" );
251 fdlg.setOperationMode( KFileDialog::Saving );
254 fileName = fdlg.selectedFile();
257 KMessageBox::error(
this,
258 i18n(
"Could not write the file %1:\n"
259 "\"%2\" is the detailed error description." )
261 TQString::fromLocal8Bit( strerror( errno ) ) ),
262 i18n(
"KMail Error" ) );
268 #include "filterlogdlg.moc"
FilterLogDialog(TQWidget *parent)
constructor
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