36 #include "mailsourceviewer.h"
38 #include <tdeapplication.h>
46 int MailSourceHighlighter::highlightParagraph( const TQString& text, int ) {
47 TQRegExp regexp( "^([\\w-]+:\\s)" );
48 if( regexp.search( text ) != -1 ) {
49 TQFont font = textEdit()->currentFont();
51 setFormat( 0, regexp.matchedLength(), font );
56 MailSourceViewer::MailSourceViewer( TQWidget *parent, const char *name )
57 : KTextBrowser( parent, name ), mSourceHighLighter( 0 )
59 setWFlags( WDestructiveClose );
60 TQAccel *accel = new TQAccel( this, "browser close-accel" );
61 accel->connectItem( accel->insertItem( TQt::Key_Escape ), this , TQ_SLOT( close() ));
62 accel->connectItem( accel->insertItem( TQt::Key_W+CTRL ), this , TQ_SLOT( close() ));
63 setWordWrap( KTextBrowser::NoWrap );
64 KWin::setIcons(winId(), kapp->icon(), kapp->miniIcon());
67 MailSourceViewer::~MailSourceViewer()
69 delete mSourceHighLighter; mSourceHighLighter = 0;
72 void MailSourceViewer::setText( const TQString& text )
74 delete mSourceHighLighter; mSourceHighLighter = 0;
75 if ( text.length() > 500000 ) {
76 setTextFormat( TQt::LogText );
78 setTextFormat( TQt::PlainText );
79 mSourceHighLighter = new MailSourceHighlighter( this );
81 KTextBrowser::setText( text );
|