mailsourceviewer.cpp
00001
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
00030
00031
00032 #ifdef HAVE_CONFIG_H
00033 #include <config.h>
00034 #endif
00035
00036 #include "mailsourceviewer.h"
00037
00038 #include <kapplication.h>
00039 #include <kwin.h>
00040
00041 #include <qregexp.h>
00042 #include <qaccel.h>
00043 #include <qsyntaxhighlighter.h>
00044
00045 namespace KMail {
00046
00047 class MailSourceHighlighter : public QSyntaxHighlighter
00048 {
00049 public:
00050 MailSourceHighlighter( QTextEdit* edit )
00051 : QSyntaxHighlighter( edit )
00052 {}
00053 int highlightParagraph( const QString& text, int ) {
00054 QRegExp regexp( "^([\\w-]+:\\s)" );
00055 if( regexp.search( text ) != -1 ) {
00056 QFont font = textEdit()->currentFont();
00057 font.setBold( true );
00058 setFormat( 0, regexp.matchedLength(), font );
00059 }
00060 return 0;
00061 }
00062 };
00063
00064 MailSourceViewer::MailSourceViewer( QWidget *parent, const char *name )
00065 : KTextBrowser( parent, name )
00066 {
00067 setWFlags( WDestructiveClose );
00068 QAccel *accel = new QAccel( this, "browser close-accel" );
00069 accel->connectItem( accel->insertItem( Qt::Key_Escape ), this , SLOT( close() ));
00070 setTextFormat( Qt::PlainText );
00071 setWordWrap( KTextBrowser::NoWrap );
00072 new MailSourceHighlighter( this );
00073 KWin::setIcons(winId(), kapp->icon(), kapp->miniIcon());
00074 }
00075
00076 }
This file is part of the documentation for kmail Library Version 3.2.2.