1
/* This library is free software; you can redistribute it and/or
2
modify it under the terms of the GNU Library General Public
3
License as published by the Free Software Foundation; either
4
version 2 of the License, or (at your option) any later version.
6
This library is distributed in the hope that it will be useful,
7
but WITHOUT ANY WARRANTY; without even the implied warranty of
8
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
9
Library General Public License for more details.
11
You should have received a copy of the GNU Library General Public License
12
along with this library; see the file COPYING.LIB. If not, write to
13
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
14
Boston, MA 02111-1307, USA.
20
#include <kinstance.h>
24
#include <kstandarddirs.h>
25
#include <kaboutdata.h>
29
void* init_libkchmpart()
31
return new KChmPartFactory;
35
KInstance* KChmPartFactory::s_instance = 0L;
36
KAboutData* KChmPartFactory::s_about = 0L;
38
KChmPartFactory::KChmPartFactory( QObject* parent, const char* name )
39
: KParts::Factory( parent, name )
43
KChmPartFactory::~KChmPartFactory()
50
KParts::Part* KChmPartFactory::createPartObject( QWidget *parentWidget, const char *, QObject *,
51
const char *name, const char *, const QStringList & )
53
KChmPart* part = new KChmPart( parentWidget, name );
57
KInstance* KChmPartFactory::instance()
61
s_about = new KAboutData( "kchmpart",
62
I18N_NOOP( "KChm" ), "1.0pre" );
63
s_instance = new KInstance( s_about );
69
KChmPart::KChmPart( QWidget * parent, const char * name )
70
: KDevHTMLPart( ), m_job(0)
72
KInstance * instance = new KInstance( "kchmpart" );
73
setInstance( instance );
74
m_extension=new KParts::BrowserExtension(this);
78
bool KChmPart::openURL( const KURL &url )
81
chmURL.setProtocol("ms-its");
83
return KDevHTMLPart::openURL(chmURL);
86
void KChmPart::slotDuplicate()
90
void KChmPart::slotOpenInNewWindow(const KURL &url)
96
bool KChmPart::openFile()
101
m_htmlData.truncate(0);
103
m_job = KIO::get( QString("chm:")+m_file+"/", true, false );
104
connect( m_job, SIGNAL( data( KIO::Job *, const QByteArray &) ), SLOT( readData( KIO::Job *, const QByteArray &) ) );
105
connect( m_job, SIGNAL( result( KIO::Job * ) ), SLOT( jobDone( KIO::Job * ) ) );
109
void KChmPart::readData(KIO::Job * , const QByteArray & data)
114
void KChmPart::jobDone( KIO::Job *)
118
write(QString::fromLocal8Bit(m_htmlData));
122
#include "kchmpart.moc"