TDE personal information management applications
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

98 lines
3.1KB

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