File indexing completed on 2024-04-28 16:26:32
0001 /************************************************************************************* 0002 begin : Sun Dec 21 2003 0003 copyright : (C) 2003 by Jeroen Wijnhout (Jeroen.Wijnhout@kdemail.net) 0004 (C) 2009-2012 by Michel Ludwig (michel.ludwig@kdemail.net) 0005 *************************************************************************************/ 0006 0007 /*************************************************************************** 0008 * * 0009 * This program is free software; you can redistribute it and/or modify * 0010 * it under the terms of the GNU General Public License as published by * 0011 * the Free Software Foundation; either version 2 of the License, or * 0012 * (at your option) any later version. * 0013 * * 0014 ****************************************************************************/ 0015 0016 #include "widgets/outputview.h" 0017 0018 #include <KColorScheme> 0019 0020 #include "kiledebug.h" 0021 0022 namespace KileWidget { 0023 0024 OutputView::OutputView(QWidget *parent) : KTextEdit(parent) 0025 { 0026 setReadOnly(true); 0027 setAcceptRichText(false); 0028 } 0029 0030 OutputView::~OutputView() 0031 { 0032 } 0033 0034 void OutputView::receive(const QString& str) 0035 { 0036 static QString line; 0037 0038 //find newline symbol 0039 //only output if we have receive one or more 0040 //full lines of text 0041 int newLineAt = str.lastIndexOf('\n'); 0042 if(newLineAt != -1) { 0043 line += str.left(newLineAt); //don't copy the newline char 0044 append(line); 0045 line = str.mid(newLineAt + 1); 0046 } 0047 else { 0048 line += str; 0049 } 0050 } 0051 0052 void OutputView::paintEvent(QPaintEvent *ev) 0053 { 0054 QPalette customPalette = palette(); 0055 KColorScheme::adjustBackground(customPalette, KColorScheme::NormalBackground, 0056 QPalette::Base, KColorScheme::View); 0057 setPalette(customPalette); 0058 KTextEdit::paintEvent(ev); 0059 } 0060 0061 } 0062