kate Library API Documentation

kateconsole.cpp

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., 59 Temple Place - Suite 330,
00018    Boston, MA 02111-1307, USA.
00019 */
00020 
00021 #include "kateconsole.h"
00022 #include "kateconsole.moc"
00023 
00024 #include <kurl.h>
00025 #include <qlayout.h>
00026 #include <klibloader.h>
00027 #include <klocale.h>
00028 #include <kapplication.h>
00029 #include <kdebug.h>
00030 
00031 #include <kate/view.h>
00032 #include <kate/document.h>
00033 
00034 #include "katemainwindow.h"
00035 
00036 KateConsole::KateConsole (QWidget* parent, const char* name, Kate::ViewManager *kvm) : QWidget (parent, name),part(0)
00037 {
00038 
00039     lo = new QVBoxLayout(this);
00040     m_kvm=kvm;
00041 }
00042 
00043 KateConsole::~KateConsole ()
00044 {
00045 }
00046 
00047 
00048 void KateConsole::loadConsoleIfNeeded()
00049 {
00050   kdDebug(13001)<<"================================ loadConsoleIfNeeded()"<<endl;
00051   if (part!=0) return;
00052   if (!kapp->loopLevel()) {
00053     connect(kapp,SIGNAL(onEventLoopEnter()),this,SLOT(loadConsoleIfNeeded()));
00054     return;
00055   }
00056 
00057   if (!topLevelWidget() || !parentWidget()) return;
00058   if (!topLevelWidget() || !isVisibleTo(topLevelWidget())) return;
00059 
00060   kdDebug(13001)<<"CREATING A CONSOLE PART"<<endl;
00061 
00062     KLibFactory *factory = 0;
00063     factory = KLibLoader::self()->factory("libkonsolepart");
00064     part = 0L;
00065       if (factory)
00066         {
00067           part = static_cast<KParts::ReadOnlyPart *>(factory->create(this,"libkonsolepart",
00068         "KParts::ReadOnlyPart"));
00069       if (part)
00070         {
00071               KGlobal::locale()->insertCatalogue("konsole");
00072               part->widget()->show();
00073               lo->addWidget(part->widget());
00074               connect ( part, SIGNAL(destroyed()), this, SLOT(slotDestroyed()) );
00075           if (m_kvm->activeView())
00076             if (m_kvm->activeView()->getDoc()->url().isValid())
00077             cd(m_kvm->activeView()->getDoc()->url().path());
00078             }
00079         }
00080 }
00081 
00082 void KateConsole::showEvent(QShowEvent *)
00083 {
00084     if (!part) loadConsoleIfNeeded();
00085 }
00086 
00087 void KateConsole::cd (KURL url)
00088 {
00089   if (part) part->openURL (url);
00090 }
00091 
00092 void KateConsole::slotDestroyed ()
00093 {
00094   part=0;
00095   
00096   // hide the dockwidget
00097   if (parentWidget())
00098     parentWidget()->hide ();
00099 }
KDE Logo
This file is part of the documentation for kate Library Version 3.2.1.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Fri Mar 5 04:41:10 2004 by doxygen 1.3.6-20040222 written by Dimitri van Heesch, © 1997-2003