/*************************************************************************** * Copyright (C) 2003-2005 by David Saxton * * david@bluehaze.org * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * ***************************************************************************/ #include "logview.h" #include #include #include #include #include //BEGIN class LogView LogView::LogView( KateMDI::ToolView * parent, const char *name ) : KTextEdit( parent, name ) { setReadOnly(true); setPaper( TQt::white ); setTextFormat( LogText ); setWordWrap( WidgetWidth ); // Connect up signal emitted when the user doubleclicks on a paragraph in the log view connect( this, TQ_SIGNAL(clicked(int,int)), this, TQ_SLOT(slotParaClicked(int,int)) ); } LogView::~LogView() { } void LogView::clear() { m_messageInfoMap.clear(); KTextEdit::clear(); } void LogView::addOutput( TQString text, OutputType outputType, MessageInfo messageInfo ) { tidyText(text); switch(outputType) { case LogView::ot_important: append( TQString("%1").arg(text) ); break; case LogView::ot_info: append( TQString("%1").arg(text) ); break; case LogView::ot_message: append( TQString("%1").arg(text) ); break; case LogView::ot_warning: append( TQString("%1").arg(text) ); break; case LogView::ot_error: append( TQString("%1").arg(text) ); break; } m_messageInfoMap[ paragraphs()-1 ] = messageInfo; } void LogView::slotParaClicked( int para, int /*pos*/ ) { TQString t = text(para); untidyText(t); emit paraClicked( t, m_messageInfoMap[para] ); } void LogView::tidyText( TQString &t ) { t.replace( "&", "&" ); t.replace( "<", "<" ); t.replace( ">", ">" ); } void LogView::untidyText( TQString &t ) { t.replace( "<", "<" ); t.replace( ">", ">" ); t.replace( "&", "&" ); } TQPopupMenu * LogView::createPopupMenu( const TQPoint & pos ) { TQPopupMenu * menu = KTextEdit::createPopupMenu( pos ); menu->insertSeparator(); int id = menu->insertItem( i18n("Clear All"), this, TQ_SLOT(clear()) ); // "an empty textedit is always considered to have one paragraph" - tqt documentation // although this does not always seem to be the case, so I don't know... menu->setItemEnabled( id, paragraphs() > 1 ); return menu; } //END class LogView //BEGIN class MessageInfo MessageInfo::MessageInfo() { m_fileLine = -1; } MessageInfo::MessageInfo( TQString fileURL, int fileLine ) { m_fileURL = fileURL; m_fileLine = fileLine; } //END class MessageInfo #include "logview.moc"