summaryrefslogtreecommitdiffstats
path: root/konq-plugins/domtreeviewer/plugin_domtreeviewer.cpp
blob: 26152633cdebe872e3c8da7320d6332bf8e9cae5 (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
#include "plugin_domtreeviewer.h"
#include "domtreewindow.h"
#include "domtreeview.h"

#include <kaction.h>
#include <kinstance.h>
#include <klibloader.h>

#include <kdebug.h>
#include <klocale.h>
#include <kgenericfactory.h>

#include <khtml_part.h>

typedef KGenericFactory<PluginDomtreeviewer> DomtreeviewerFactory;
K_EXPORT_COMPONENT_FACTORY( libdomtreeviewerplugin, DomtreeviewerFactory( "domtreeviewer" ) )

PluginDomtreeviewer::PluginDomtreeviewer( TQObject* tqparent, const char* name,
	                                  const TQStringList & )
  : Plugin( tqparent, name ), m_dialog( 0 )
{
  (void) new KAction( i18n("Show &DOM Tree"),
                      "domtreeviewer", 0,
                      this, TQT_SLOT(slotShowDOMTree()),
                      actionCollection(), "viewdomtree" );
}

PluginDomtreeviewer::~PluginDomtreeviewer()
{
  kdDebug(90180) << k_funcinfo << endl;
  delete m_dialog;
}

void PluginDomtreeviewer::slotShowDOMTree()
{
  if ( m_dialog )
  {
    delete m_dialog;
    Q_ASSERT((DOMTreeWindow *)m_dialog == (DOMTreeWindow *)0);
  }
  if (KHTMLPart *part = ::tqqt_cast<KHTMLPart *>(tqparent()))
  {
    m_dialog = new DOMTreeWindow(this);
    connect( m_dialog, TQT_SIGNAL( destroyed() ), this, TQT_SLOT( slotDestroyed() ) );
    m_dialog->view()->setHtmlPart(part);
    m_dialog->show();
  }
}

void PluginDomtreeviewer::slotDestroyed()
{
  kdDebug(90180) << k_funcinfo << endl;
  m_dialog = 0;
}

#include <plugin_domtreeviewer.moc>