From 5de3dd4762ca33a0f92e79ffa4fe2ff67069d531 Mon Sep 17 00:00:00 2001 From: tpearson Date: Wed, 24 Feb 2010 01:49:02 +0000 Subject: Added KDE3 version of ktechlab git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/ktechlab@1095338 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- src/gui/contexthelp.cpp | 107 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 107 insertions(+) create mode 100644 src/gui/contexthelp.cpp (limited to 'src/gui/contexthelp.cpp') diff --git a/src/gui/contexthelp.cpp b/src/gui/contexthelp.cpp new file mode 100644 index 0000000..3444737 --- /dev/null +++ b/src/gui/contexthelp.cpp @@ -0,0 +1,107 @@ +/*************************************************************************** + * 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 "cnitem.h" +#include "cnitemgroup.h" +#include "contexthelp.h" +#include "itemlibrary.h" +#include "katemdi.h" + +#include + +#include +#include +#include +#include +#include + +#include + +ContextHelp * ContextHelp::m_pSelf = 0l; + +ContextHelp * ContextHelp::self( KateMDI::ToolView * parent ) +{ + if (!m_pSelf) + { + assert(parent); + m_pSelf = new ContextHelp(parent); + } + return m_pSelf; +} + + +ContextHelp::ContextHelp( KateMDI::ToolView * parent ) + : QWidget( parent, "Context Help" ) +{ + QWhatsThis::add( this, i18n("Provides context-sensitive help relevant to the current editing being performed.") ); + + QVBoxLayout *vlayout = new QVBoxLayout( this, 0, 6 ); + + m_nameLbl = new QLabel( this, "" ); + vlayout->addWidget(m_nameLbl); + vlayout->addSpacing(8); + + m_info = new QTextBrowser( this, "" ); + vlayout->addWidget(m_info); + m_info->setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding ); + + QSpacerItem *spacer3 = new QSpacerItem( 1, 1, QSizePolicy::Preferred, QSizePolicy::Preferred ); + vlayout->addItem(spacer3); + + slotClear(); +} + + +ContextHelp::~ContextHelp() +{ +} + + +void ContextHelp::slotUpdate( Item *item ) +{ + if (!item) + { + slotClear(); + return; + } + m_nameLbl->setText("

"+item->name()+"

"); + m_info->setText( ""+item->description() ); +} + + +void ContextHelp::slotClear() +{ + m_nameLbl->setText(i18n("

No Item Selected

")); + m_info->setText(""); +} + + +void ContextHelp::slotMultipleSelected() +{ + m_nameLbl->setText(i18n("

Multiple Items

")); + m_info->setText(""); +} + + +void ContextHelp::setContextHelp(const QString& name, const QString& help) +{ + m_nameLbl->setText("

"+name+"

"); + QString parsed = help; + parseInfo(parsed); + m_info->setText( ""+parsed ); +} + +void ContextHelp::parseInfo( QString &info ) +{ + info.replace("","

Example:
"); + info.replace("","
"); +} + +#include "contexthelp.moc" -- cgit v1.2.3