add more spacing
[personal-kdebase.git] / runtime / kioslave / man / kmanpart.cpp
blob53db6965f40336375134d9320270f25edd74eb6d
1 /* This file is part of the KDE project
2 Copyright (C) 2002 Alexander Neundorf <neundorf@kde.org>
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301, USA.
20 #include "kmanpart.h"
23 #include <kcomponentdata.h>
24 #include <kglobal.h>
25 #include <kdebug.h>
26 #include <klocale.h>
27 #include <kstandarddirs.h>
28 #include <kaboutdata.h>
29 #include <kdeversion.h>
31 extern "C"
33 KDE_EXPORT void* init_libkmanpart()
35 return new KManPartFactory;
39 KComponentData *KManPartFactory::s_instance = 0L;
40 KAboutData* KManPartFactory::s_about = 0L;
42 KManPartFactory::KManPartFactory( QObject* parent )
43 : KParts::Factory( parent )
46 KManPartFactory::~KManPartFactory()
48 delete s_instance;
49 s_instance = 0L;
50 delete s_about;
53 KParts::Part* KManPartFactory::createPartObject( QWidget * parentWidget, QObject *,
54 const char* /*className*/,const QStringList & )
56 KManPart* part = new KManPart(parentWidget);
57 return part;
60 const KComponentData &KManPartFactory::componentData()
62 if( !s_instance )
64 s_about = new KAboutData( "kmanpart", 0,
65 ki18n( "KMan" ), KDE_VERSION_STRING );
66 s_instance = new KComponentData(s_about);
68 return *s_instance;
72 KManPart::KManPart( QWidget * parent )
73 : KHTMLPart( parent )
74 ,m_job(0)
76 setComponentData(KComponentData("kmanpart"));
77 m_extension=new KParts::BrowserExtension(this);
80 bool KManPart::openUrl( const KUrl &url )
82 return KParts::ReadOnlyPart::openUrl(url);
85 bool KManPart::openFile()
87 if (m_job!=0)
88 m_job->kill();
90 begin();
92 KUrl url;
93 url.setProtocol( "man" );
94 url.setPath( localFilePath() );
96 m_job = KIO::get( url, KIO::NoReload, KIO::HideProgressInfo );
97 connect( m_job, SIGNAL( data( KIO::Job *, const QByteArray &) ), SLOT( readData( KIO::Job *, const QByteArray &) ) );
98 connect( m_job, SIGNAL( result(KJob*) ), SLOT( jobDone(KJob*) ) );
99 return true;
102 void KManPart::readData(KIO::Job * , const QByteArray & data)
104 write(data,data.size());
107 void KManPart::jobDone( KJob *)
109 m_job=0;
110 end();
113 #include "kmanpart.moc"