htmldiffalgodisplay.cpp
00001 /* 00002 This file is part of libtdepim. 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., 51 Franklin Street, Fifth Floor, 00019 Boston, MA 02110-1301, USA. 00020 */ 00021 00022 #include <tdeglobalsettings.h> 00023 00024 #include "htmldiffalgodisplay.h" 00025 00026 using namespace KSync; 00027 00028 static TQString textToHTML( const TQString &text ) 00029 { 00030 return TQStyleSheet::convertFromPlainText( text ); 00031 } 00032 00033 HTMLDiffAlgoDisplay::HTMLDiffAlgoDisplay( TQWidget *parent ) 00034 : KTextBrowser( parent ) 00035 { 00036 setWrapPolicy( TQTextEdit::AtWordBoundary ); 00037 setVScrollBarMode( TQScrollView::AlwaysOff ); 00038 setHScrollBarMode( TQScrollView::AlwaysOff ); 00039 } 00040 00041 void HTMLDiffAlgoDisplay::begin() 00042 { 00043 clear(); 00044 mText = ""; 00045 00046 mText.append( "<html>" ); 00047 mText.append( TQString( "<body text=\"%1\" bgcolor=\"%2\">" ) 00048 .arg( TDEGlobalSettings::textColor().name() ) 00049 .arg( TDEGlobalSettings::baseColor().name() ) ); 00050 00051 mText.append( "<center><table>" ); 00052 mText.append( TQString( "<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 TQString &title ) 00067 { 00068 mLeftTitle = title; 00069 } 00070 00071 void HTMLDiffAlgoDisplay::setRightSourceTitle( const TQString &title ) 00072 { 00073 mRightTitle = title; 00074 } 00075 00076 void HTMLDiffAlgoDisplay::additionalLeftField( const TQString &id, const TQString &value ) 00077 { 00078 mText.append( TQString( "<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 TQString &id, const TQString &value ) 00084 { 00085 mText.append( TQString( "<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 TQString &id, const TQString &leftValue, 00091 const TQString &rightValue ) 00092 { 00093 mText.append( TQString( "<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 }