libtdepim

htmldiffalgodisplay.cpp
1/*
2 This file is part of libtdepim.
3
4 Copyright (c) 2004 Tobias Koenig <tokoe@kde.org>
5
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version.
10
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
15
16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA.
20*/
21
22#include <tdeglobalsettings.h>
23
24#include <libtdepim/htmldiffalgodisplay.h>
25
26using namespace KPIM;
27
28static TQString textToHTML( const TQString &text )
29{
30 return TQStyleSheet::convertFromPlainText( text );
31}
32
33HTMLDiffAlgoDisplay::HTMLDiffAlgoDisplay( TQWidget *parent )
34 : KTextBrowser( parent )
35{
36 setWrapPolicy( TQTextEdit::AtWordBoundary );
37 setVScrollBarMode( TQScrollView::AlwaysOff );
38 setHScrollBarMode( TQScrollView::AlwaysOff );
39}
40
41void HTMLDiffAlgoDisplay::begin()
42{
43 clear();
44 mText = "";
45
46 mText.append( "<html>" );
47 mText.append( TQString( "<body text=\"%1\" bgcolor=\"%2\">" )
48 .arg( TDEGlobalSettings::textColor().name() )
49 .arg( TDEGlobalSettings::baseColor().name() ) );
50
51 mText.append( "<center><table>" );
52 mText.append( TQString( "<tr><th></th><th align=\"center\">%1</th><td> </td><th align=\"center\">%2</th></tr>" )
53 .arg( mLeftTitle )
54 .arg( mRightTitle ) );
55}
56
57void HTMLDiffAlgoDisplay::end()
58{
59 mText.append( "</table></center>"
60 "</body>"
61 "</html>" );
62
63 setText( mText );
64}
65
66void HTMLDiffAlgoDisplay::setLeftSourceTitle( const TQString &title )
67{
68 mLeftTitle = title;
69}
70
71void HTMLDiffAlgoDisplay::setRightSourceTitle( const TQString &title )
72{
73 mRightTitle = title;
74}
75
76void HTMLDiffAlgoDisplay::additionalLeftField( const TQString &id, const TQString &value )
77{
78 mText.append( TQString( "<tr><td align=\"right\"><b>%1:</b></td><td bgcolor=\"#9cff83\">%2</td><td></td><td></td></tr>" )
79 .arg( id )
80 .arg( textToHTML( value ) ) );
81}
82
83void HTMLDiffAlgoDisplay::additionalRightField( const TQString &id, const TQString &value )
84{
85 mText.append( TQString( "<tr><td align=\"right\"><b>%1:</b></td><td></td><td></td><td bgcolor=\"#9cff83\">%2</td></tr>" )
86 .arg( id )
87 .arg( textToHTML( value ) ) );
88}
89
90void HTMLDiffAlgoDisplay::conflictField( const TQString &id, const TQString &leftValue,
91 const TQString &rightValue )
92{
93 mText.append( TQString( "<tr><td align=\"right\"><b>%1:</b></td><td bgcolor=\"#ff8686\">%2</td><td></td><td bgcolor=\"#ff8686\">%3</td></tr>" )
94 .arg( id )
95 .arg( textToHTML( leftValue ) )
96 .arg( textToHTML( rightValue ) ) );
97}
TDEPIM classes for drag and drop of mails.