KDevelop API Documentation

kchmpart.cpp

Go to the documentation of this file.
00001 /*  This library is free software; you can redistribute it and/or
00002     modify it under the terms of the GNU Library General Public
00003     License as published by the Free Software Foundation; either
00004     version 2 of the License, or (at your option) any later version.
00005 
00006     This library is distributed in the hope that it will be useful,
00007     but WITHOUT ANY WARRANTY; without even the implied warranty of
00008     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00009     Library General Public License for more details.
00010 
00011     You should have received a copy of the GNU Library General Public License
00012     along with this library; see the file COPYING.LIB.  If not, write to
00013     the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00014     Boston, MA 02111-1307, USA.
00015 */
00016 
00017 #include "kchmpart.h"
00018 #include <qstring.h>
00019 
00020 #include <kinstance.h>
00021 #include <kglobal.h>
00022 #include <kdebug.h>
00023 #include <klocale.h>
00024 #include <kstddirs.h>
00025 #include <kaboutdata.h>
00026 
00027 extern "C"
00028 {
00029    void* init_libkchmpart()
00030    {
00031       return new KChmPartFactory;
00032    }
00033 }
00034 
00035 KInstance* KChmPartFactory::s_instance = 0L;
00036 KAboutData* KChmPartFactory::s_about = 0L;
00037 
00038 KChmPartFactory::KChmPartFactory( QObject* parent, const char* name )
00039    : KParts::Factory( parent, name )
00040 {
00041 }
00042 
00043 KChmPartFactory::~KChmPartFactory()
00044 {
00045    delete s_instance;
00046    s_instance = 0L;
00047    delete s_about;
00048 }
00049 
00050 KParts::Part* KChmPartFactory::createPartObject( QWidget *parentWidget, const char *, QObject *,
00051                                  const char *name, const char *, const QStringList & )
00052 {
00053    KChmPart* part = new KChmPart( parentWidget, name );
00054    return part;
00055 }
00056 
00057 KInstance* KChmPartFactory::instance()
00058 {
00059    if( !s_instance )
00060    {
00061       s_about = new KAboutData( "kchmpart",
00062                                 I18N_NOOP( "KChm" ), "1.0pre" );
00063       s_instance = new KInstance( s_about );
00064    }
00065    return s_instance;
00066 }
00067 
00068 
00069 KChmPart::KChmPart( QWidget * parent, const char * name )
00070     : KHTMLPart( parent, name ), m_job(0)
00071 {
00072    KInstance * instance = new KInstance( "kchmpart" );
00073    setInstance( instance );
00074    m_extension=new KParts::BrowserExtension(this);
00075 }
00076 
00077 bool KChmPart::openURL( const KURL &url )
00078 {
00079    KURL chmURL = url;
00080    chmURL.setProtocol("ms-its");
00081    chmURL.addPath("/");
00082    return KHTMLPart::openURL(chmURL);
00083 }
00084 
00085 /*
00086 bool KChmPart::openFile()
00087 {
00088    if (m_job!=0)
00089       m_job->kill();
00090 
00091    m_htmlData.truncate(0);
00092 
00093    m_job = KIO::get( QString("chm:")+m_file+"/", true, false );
00094    connect( m_job, SIGNAL( data( KIO::Job *, const QByteArray &) ), SLOT( readData( KIO::Job *, const QByteArray &) ) );
00095    connect( m_job, SIGNAL( result( KIO::Job * ) ), SLOT( jobDone( KIO::Job * ) ) );
00096    return true;
00097 }
00098 
00099 void KChmPart::readData(KIO::Job * , const QByteArray & data)
00100 {
00101     m_htmlData += data;
00102 }
00103 
00104 void KChmPart::jobDone( KIO::Job *)
00105 {
00106    m_job=0;
00107    begin();
00108    write(QString::fromLocal8Bit(m_htmlData));
00109    end();
00110 }
00111 */
00112 #include "kchmpart.moc"
00113 
KDE Logo
This file is part of the documentation for KDevelop Version 3.1.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Mar 23 00:03:55 2005 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2003