summaryrefslogtreecommitdiffstats
path: root/parts/documentation/protocols/chm/kchmpart.cpp
blob: f985bf43f78fab700b2634bf2c27c3c64d1947d6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/*  This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public License
    along with this library; see the file COPYING.LIB.  If not, write to
    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
    Boston, MA 02110-1301, USA.
*/

#include "kchmpart.h"
#include <tqstring.h>

#include <kinstance.h>
#include <kglobal.h>
#include <kdebug.h>
#include <klocale.h>
#include <kstandarddirs.h>
#include <tdeaboutdata.h>

extern "C"
{
   void* init_libkchmpart()
   {
      return new KChmPartFactory;
   }
}

TDEInstance* KChmPartFactory::s_instance = 0L;
TDEAboutData* KChmPartFactory::s_about = 0L;

KChmPartFactory::KChmPartFactory( TQObject* parent, const char* name )
   : KParts::Factory( parent, name )
{
}

KChmPartFactory::~KChmPartFactory()
{
   delete s_instance;
   s_instance = 0L;
   delete s_about;
}

KParts::Part* KChmPartFactory::createPartObject( TQWidget *parentWidget, const char *, TQObject *,
                                 const char *name, const char *, const TQStringList & )
{
   KChmPart* part = new KChmPart( parentWidget, name );
   return part;
}

TDEInstance* KChmPartFactory::instance()
{
   if( !s_instance )
   {
      s_about = new TDEAboutData( "kchmpart",
                                I18N_NOOP( "KChm" ), "1.0pre" );
      s_instance = new TDEInstance( s_about );
   }
   return s_instance;
}


KChmPart::KChmPart( TQWidget * parent, const char * name )
	: KDevHTMLPart(  ), m_job(0)
{
   TDEInstance * instance = new TDEInstance( "kchmpart" );
   setInstance( instance );
   m_extension=new KParts::BrowserExtension(this);
   setOptions(-1);
}

bool KChmPart::openURL( const KURL &url )
{
   KURL chmURL = url;
   chmURL.setProtocol("ms-its");
   chmURL.addPath("/");
   return KDevHTMLPart::openURL(chmURL);
}

void KChmPart::slotDuplicate()
{
}

void KChmPart::slotOpenInNewWindow(const KURL &url)
{
}


/*
bool KChmPart::openFile()
{
   if (m_job!=0)
      m_job->kill();

   m_htmlData.truncate(0);

   m_job = TDEIO::get( TQString("chm:")+m_file+"/", true, false );
   connect( m_job, TQT_SIGNAL( data( TDEIO::Job *, const TQByteArray &) ), TQT_SLOT( readData( TDEIO::Job *, const TQByteArray &) ) );
   connect( m_job, TQT_SIGNAL( result( TDEIO::Job * ) ), TQT_SLOT( jobDone( TDEIO::Job * ) ) );
   return true;
}

void KChmPart::readData(TDEIO::Job * , const TQByteArray & data)
{
    m_htmlData += data;
}

void KChmPart::jobDone( TDEIO::Job *)
{
   m_job=0;
   begin();
   write(TQString::fromLocal8Bit(m_htmlData));
   end();
}
*/
#include "kchmpart.moc"