• Skip to content
  • Skip to link menu
KDE 3.5 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

kate

kateconsole.cpp

Go to the documentation of this file.
00001 /* This file is part of the KDE project
00002    Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org>
00003    Copyright (C) 2002 Joseph Wenninger <jowenn@kde.org>
00004    Copyright (C) 2002 Anders Lund <anders.lund@lund.tdcadsl.dk>
00005 
00006    This library is free software; you can redistribute it and/or
00007    modify it under the terms of the GNU Library General Public
00008    License version 2 as published by the Free Software Foundation.
00009 
00010    This library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Library General Public License for more details.
00014 
00015    You should have received a copy of the GNU Library General Public License
00016    along with this library; see the file COPYING.LIB.  If not, write to
00017    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00018    Boston, MA 02110-1301, USA.
00019 */
00020 
00021 #include "kateconsole.h"
00022 #include "kateconsole.moc"
00023 
00024 #include "katemain.h"
00025 #include "katemdi.h"
00026 #include "katemainwindow.h"
00027 #include "kateviewmanager.h"
00028 
00029 #include <kate/view.h>
00030 #include <kate/document.h>
00031 
00032 #include <kde_terminal_interface.h>
00033 
00034 #include <kparts/part.h>
00035 
00036 #include <kurl.h>
00037 #include <klibloader.h>
00038 #include <klocale.h>
00039 #include <kdebug.h>
00040 #include <kmessagebox.h>
00041 
00042 KateConsole::KateConsole (KateMainWindow *mw, KateMDI::ToolView* parent)
00043  : QVBox (parent)
00044  , m_part (0)
00045  , m_mw (mw)
00046  , m_toolView (parent)
00047 {
00048 }
00049 
00050 KateConsole::~KateConsole ()
00051 {
00052   if (m_part)
00053     disconnect ( m_part, SIGNAL(destroyed()), this, SLOT(slotDestroyed()) );
00054 }
00055 
00056 void KateConsole::loadConsoleIfNeeded()
00057 {
00058   if (m_part) return;
00059 
00060   if (!topLevelWidget() || !parentWidget()) return;
00061   if (!topLevelWidget() || !isVisibleTo(topLevelWidget())) return;
00062 
00063   KLibFactory *factory = KLibLoader::self()->factory("libkonsolepart");
00064 
00065   if (!factory) return;
00066 
00067   m_part = static_cast<KParts::ReadOnlyPart *>(factory->create(this,"libkonsolepart", "KParts::ReadOnlyPart"));
00068 
00069   if (!m_part) return;
00070 
00071   setFocusProxy(m_part->widget());
00072 
00073   KGlobal::locale()->insertCatalogue("konsole");
00074 
00075   m_part->widget()->show();
00076 
00077   connect ( m_part, SIGNAL(destroyed()), this, SLOT(slotDestroyed()) );
00078 
00079   if (m_mw->viewManager()->activeView())
00080     if (m_mw->viewManager()->activeView()->getDoc()->url().isValid())
00081       cd(KURL( m_mw->viewManager()->activeView()->getDoc()->url().path() ));
00082 }
00083 
00084 void KateConsole::slotDestroyed ()
00085 {
00086   m_part = 0;
00087 
00088   // hide the dockwidget
00089   if (parentWidget())
00090   {
00091     m_mw->hideToolView (m_toolView);
00092     m_mw->centralWidget()->setFocus ();
00093   }
00094 }
00095 
00096 void KateConsole::showEvent(QShowEvent *)
00097 {
00098   if (m_part) return;
00099 
00100   loadConsoleIfNeeded();
00101 }
00102 
00103 void KateConsole::cd (const KURL &url)
00104 {
00105   loadConsoleIfNeeded();
00106 
00107   if (!m_part) return;
00108 
00109   m_part->openURL (url);
00110 }
00111 
00112 void KateConsole::sendInput( const QString& text )
00113 {
00114   loadConsoleIfNeeded();
00115 
00116   if (!m_part) return;
00117 
00118   TerminalInterface *t = static_cast<TerminalInterface*>( m_part->qt_cast( "TerminalInterface" ) );
00119 
00120   if (!t) return;
00121 
00122   t->sendInput (text);
00123 }
00124 
00125 void KateConsole::slotPipeToConsole ()
00126 {
00127   if (KMessageBox::warningContinueCancel
00128       (m_mw
00129        , i18n ("Do you really want to pipe the text to the console? This will execute any contained commands with your user rights.")
00130        , i18n ("Pipe to Console?")
00131        , i18n("Pipe to Console"), "Pipe To Console Warning") != KMessageBox::Continue)
00132     return;
00133 
00134   Kate::View *v = m_mw->viewManager()->activeView();
00135 
00136   if (!v)
00137     return;
00138 
00139   if (v->getDoc()->hasSelection ())
00140     sendInput (v->getDoc()->selection());
00141   else
00142     sendInput (v->getDoc()->text());
00143 }

kate

Skip menu "kate"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members

API Reference

Skip menu "API Reference"
  • kate
Generated for API Reference by doxygen 1.5.9
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal