libkdepim Library API Documentation

htmldiffalgodisplay.cpp

00001 /* 00002 This file is part of libkdepim. 00003 00004 Copyright (c) 2004 Tobias Koenig <tokoe@kde.org> 00005 00006 This library is free software; you can redistribute it and/or 00007 modify it under the terms of the GNU Library General Public 00008 License as published by the Free Software Foundation; either 00009 version 2 of the License, or (at your option) any later version. 00010 00011 This library is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 Library General Public License for more details. 00015 00016 You should have received a copy of the GNU Library General Public License 00017 along with this library; see the file COPYING.LIB. If not, write to 00018 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 00019 Boston, MA 02111-1307, USA. 00020 */ 00021 00022 #include <kglobalsettings.h> 00023 00024 #include <libkdepim/htmldiffalgodisplay.h> 00025 00026 using namespace KPIM; 00027 00028 static QString textToHTML( const QString &text ) 00029 { 00030 return QStyleSheet::convertFromPlainText( text ); 00031 } 00032 00033 HTMLDiffAlgoDisplay::HTMLDiffAlgoDisplay( QWidget *parent ) 00034 : KTextBrowser( parent ) 00035 { 00036 setWrapPolicy( QTextEdit::AtWordBoundary ); 00037 setVScrollBarMode( QScrollView::AlwaysOff ); 00038 setHScrollBarMode( QScrollView::AlwaysOff ); 00039 } 00040 00041 void HTMLDiffAlgoDisplay::begin() 00042 { 00043 clear(); 00044 mText = ""; 00045 00046 mText.append( "<html>" ); 00047 mText.append( QString( "<body text=\"%1\" bgcolor=\"%2\">" ) 00048 .arg( KGlobalSettings::textColor().name() ) 00049 .arg( KGlobalSettings::baseColor().name() ) ); 00050 00051 mText.append( "<center><table>" ); 00052 mText.append( QString( "<tr><th></th><th align=\"center\">%1</th><td> </td><th align=\"center\">%2</th></tr>" ) 00053 .arg( mLeftTitle ) 00054 .arg( mRightTitle ) ); 00055 } 00056 00057 void HTMLDiffAlgoDisplay::end() 00058 { 00059 mText.append( "</table></center>" 00060 "</body>" 00061 "</html>" ); 00062 00063 setText( mText ); 00064 } 00065 00066 void HTMLDiffAlgoDisplay::setLeftSourceTitle( const QString &title ) 00067 { 00068 mLeftTitle = title; 00069 } 00070 00071 void HTMLDiffAlgoDisplay::setRightSourceTitle( const QString &title ) 00072 { 00073 mRightTitle = title; 00074 } 00075 00076 void HTMLDiffAlgoDisplay::additionalLeftField( const QString &id, const QString &value ) 00077 { 00078 mText.append( QString( "<tr><td align=\"right\"><b>%1:</b></td><td bgcolor=\"#9cff83\">%2</td><td></td><td></td></tr>" ) 00079 .arg( id ) 00080 .arg( textToHTML( value ) ) ); 00081 } 00082 00083 void HTMLDiffAlgoDisplay::additionalRightField( const QString &id, const QString &value ) 00084 { 00085 mText.append( QString( "<tr><td align=\"right\"><b>%1:</b></td><td></td><td></td><td bgcolor=\"#9cff83\">%2</td></tr>" ) 00086 .arg( id ) 00087 .arg( textToHTML( value ) ) ); 00088 } 00089 00090 void HTMLDiffAlgoDisplay::conflictField( const QString &id, const QString &leftValue, 00091 const QString &rightValue ) 00092 { 00093 mText.append( QString( "<tr><td align=\"right\"><b>%1:</b></td><td bgcolor=\"#ff8686\">%2</td><td></td><td bgcolor=\"#ff8686\">%3</td></tr>" ) 00094 .arg( id ) 00095 .arg( textToHTML( leftValue ) ) 00096 .arg( textToHTML( rightValue ) ) ); 00097 }
KDE Logo
This file is part of the documentation for libkdepim Library Version 3.3.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Thu Oct 21 19:46:29 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003