~ubuntu-branches/ubuntu/karmic/kdevelop/karmic

« back to all changes in this revision

Viewing changes to parts/documentation/protocols/chm/kchmpart.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Thomas
  • Date: 2009-05-25 19:34:26 UTC
  • mfrom: (1.1.11 upstream) (2.3.1 experimental)
  • Revision ID: james.westby@ubuntu.com-20090525193426-hdntv90rvflyew8g
Tags: 4:3.9.93-1ubuntu1
* Merge from Debian experimental, remaining changes:
  - Conflict/replace -kde4 packages

Show diffs side-by-side

added added

removed removed

Lines of Context:
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.
5
 
 
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.
10
 
 
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.
15
 
*/
16
 
 
17
 
#include "kchmpart.h"
18
 
#include <qstring.h>
19
 
 
20
 
#include <kinstance.h>
21
 
#include <kglobal.h>
22
 
#include <kdebug.h>
23
 
#include <klocale.h>
24
 
#include <kstandarddirs.h>
25
 
#include <kaboutdata.h>
26
 
 
27
 
extern "C"
28
 
{
29
 
   void* init_libkchmpart()
30
 
   {
31
 
      return new KChmPartFactory;
32
 
   }
33
 
}
34
 
 
35
 
KInstance* KChmPartFactory::s_instance = 0L;
36
 
KAboutData* KChmPartFactory::s_about = 0L;
37
 
 
38
 
KChmPartFactory::KChmPartFactory( QObject* parent, const char* name )
39
 
   : KParts::Factory( parent, name )
40
 
{
41
 
}
42
 
 
43
 
KChmPartFactory::~KChmPartFactory()
44
 
{
45
 
   delete s_instance;
46
 
   s_instance = 0L;
47
 
   delete s_about;
48
 
}
49
 
 
50
 
KParts::Part* KChmPartFactory::createPartObject( QWidget *parentWidget, const char *, QObject *,
51
 
                                 const char *name, const char *, const QStringList & )
52
 
{
53
 
   KChmPart* part = new KChmPart( parentWidget, name );
54
 
   return part;
55
 
}
56
 
 
57
 
KInstance* KChmPartFactory::instance()
58
 
{
59
 
   if( !s_instance )
60
 
   {
61
 
      s_about = new KAboutData( "kchmpart",
62
 
                                I18N_NOOP( "KChm" ), "1.0pre" );
63
 
      s_instance = new KInstance( s_about );
64
 
   }
65
 
   return s_instance;
66
 
}
67
 
 
68
 
 
69
 
KChmPart::KChmPart( QWidget * parent, const char * name )
70
 
        : KDevHTMLPart(  ), m_job(0)
71
 
{
72
 
   KInstance * instance = new KInstance( "kchmpart" );
73
 
   setInstance( instance );
74
 
   m_extension=new KParts::BrowserExtension(this);
75
 
   setOptions(-1);
76
 
}
77
 
 
78
 
bool KChmPart::openURL( const KURL &url )
79
 
{
80
 
   KURL chmURL = url;
81
 
   chmURL.setProtocol("ms-its");
82
 
   chmURL.addPath("/");
83
 
   return KDevHTMLPart::openURL(chmURL);
84
 
}
85
 
 
86
 
void KChmPart::slotDuplicate()
87
 
{
88
 
}
89
 
 
90
 
void KChmPart::slotOpenInNewWindow(const KURL &url)
91
 
{
92
 
}
93
 
 
94
 
 
95
 
/*
96
 
bool KChmPart::openFile()
97
 
{
98
 
   if (m_job!=0)
99
 
      m_job->kill();
100
 
 
101
 
   m_htmlData.truncate(0);
102
 
 
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 * ) ) );
106
 
   return true;
107
 
}
108
 
 
109
 
void KChmPart::readData(KIO::Job * , const QByteArray & data)
110
 
{
111
 
    m_htmlData += data;
112
 
}
113
 
 
114
 
void KChmPart::jobDone( KIO::Job *)
115
 
{
116
 
   m_job=0;
117
 
   begin();
118
 
   write(QString::fromLocal8Bit(m_htmlData));
119
 
   end();
120
 
}
121
 
*/
122
 
#include "kchmpart.moc"
123