diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-02-24 01:49:02 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-02-24 01:49:02 +0000 |
commit | 5de3dd4762ca33a0f92e79ffa4fe2ff67069d531 (patch) | |
tree | bad482b7afa4cdf47422d60a5dd2c61c7e333b09 /src/gui/logview.cpp | |
download | ktechlab-5de3dd4762ca33a0f92e79ffa4fe2ff67069d531.tar.gz ktechlab-5de3dd4762ca33a0f92e79ffa4fe2ff67069d531.zip |
Added KDE3 version of ktechlab
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/ktechlab@1095338 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'src/gui/logview.cpp')
-rw-r--r-- | src/gui/logview.cpp | 132 |
1 files changed, 132 insertions, 0 deletions
diff --git a/src/gui/logview.cpp b/src/gui/logview.cpp new file mode 100644 index 0000000..fcb8caf --- /dev/null +++ b/src/gui/logview.cpp @@ -0,0 +1,132 @@ +/*************************************************************************** + * 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 <kdebug.h> +#include <kiconloader.h> +#include <katemdi.h> +#include <klocale.h> +#include <qpopupmenu.h> + + +//BEGIN class LogView +LogView::LogView( KateMDI::ToolView * parent, const char *name ) + : KTextEdit( parent, name ) +{ + setReadOnly(true); + setPaper( Qt::white ); + setTextFormat( LogText ); + setWordWrap( WidgetWidth ); + + // Connect up signal emitted when the user doubleclicks on a paragraph in the log view + connect( this, SIGNAL(clicked(int,int)), this, SLOT(slotParaClicked(int,int)) ); +} + + +LogView::~LogView() +{ +} + + +void LogView::clear() +{ + m_messageInfoMap.clear(); + KTextEdit::clear(); +} + + +void LogView::addOutput( QString text, OutputType outputType, MessageInfo messageInfo ) +{ + tidyText(text); + switch(outputType) + { + case LogView::ot_important: + append( QString("<font color=\"#000000\"><b>%1</b></font>").arg(text) ); + break; + + case LogView::ot_info: + append( QString("<font color=\"#000000\"><i>%1</i></font>").arg(text) ); + break; + + case LogView::ot_message: + append( QString("<font color=\"#000000\">%1</font>").arg(text) ); + break; + + case LogView::ot_warning: + append( QString("<font color=\"#666666\">%1</font>").arg(text) ); + break; + + case LogView::ot_error: + append( QString("<font color=\"#800000\">%1</font>").arg(text) ); + break; + } + + m_messageInfoMap[ paragraphs()-1 ] = messageInfo; +} + + +void LogView::slotParaClicked( int para, int /*pos*/ ) +{ + QString t = text(para); + untidyText(t); + emit paraClicked( t, m_messageInfoMap[para] ); +} + + +void LogView::tidyText( QString &t ) +{ + t.replace( "&", "&" ); + t.replace( "<", "<" ); + t.replace( ">", ">" ); +} + + +void LogView::untidyText( QString &t ) +{ + t.replace( "<", "<" ); + t.replace( ">", ">" ); + t.replace( "&", "&" ); +} + + +QPopupMenu * LogView::createPopupMenu( const QPoint & pos ) +{ + QPopupMenu * menu = KTextEdit::createPopupMenu( pos ); + + menu->insertSeparator(); + int id = menu->insertItem( i18n("Clear All"), this, SLOT(clear()) ); + + // "an empty textedit is always considered to have one paragraph" - qt 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( QString fileURL, int fileLine ) +{ + m_fileURL = fileURL; + m_fileLine = fileLine; +} +//END class MessageInfo + + +#include "logview.moc" |