summaryrefslogtreecommitdiffstats
path: root/kspy
diff options
context:
space:
mode:
Diffstat (limited to 'kspy')
-rw-r--r--kspy/Makefile.am30
-rw-r--r--kspy/README12
-rw-r--r--kspy/classinfoview.cpp58
-rw-r--r--kspy/classinfoview.h40
-rw-r--r--kspy/kspy.h44
-rw-r--r--kspy/main.cpp52
-rw-r--r--kspy/navview.cpp88
-rw-r--r--kspy/navview.h57
-rw-r--r--kspy/navviewitem.cpp40
-rw-r--r--kspy/navviewitem.h38
-rw-r--r--kspy/propsview.cpp196
-rw-r--r--kspy/propsview.h40
-rw-r--r--kspy/receiversview.cpp80
-rw-r--r--kspy/receiversview.h40
-rw-r--r--kspy/sigslotview.cpp73
-rw-r--r--kspy/sigslotview.h40
-rw-r--r--kspy/spy.cpp115
-rw-r--r--kspy/spy.h59
18 files changed, 1102 insertions, 0 deletions
diff --git a/kspy/Makefile.am b/kspy/Makefile.am
new file mode 100644
index 00000000..37af3c20
--- /dev/null
+++ b/kspy/Makefile.am
@@ -0,0 +1,30 @@
+
+lib_LTLIBRARIES = libkspy.la
+libkspy_la_SOURCES = navviewitem.cpp propsview.cpp navview.cpp spy.cpp sigslotview.cpp \
+ receiversview.cpp classinfoview.cpp
+
+include_HEADERS = kspy.h
+
+noinst_HEADERS = spy.h navview.h propsview.h navviewitem.h receiversview.h classinfoview.h
+
+libkspy_la_LIBADD = $(LIB_QT) $(LIB_KDECORE) $(LIB_KDEUI) $(LIBSOCKET)
+
+# set the include path for X, qt and KDE
+INCLUDES= $(all_includes)
+
+libkspy_la_LDFLAGS = $(all_libraries) -version-info 3:0:2 -no-undefined $(USER_LDFLAGS)
+
+EXTRA_DIST = main.cpp spy.cpp spy.h navview.cpp navview.h propsview.cpp \
+ propsview.h navviewitem.cpp navviewitem.h sigslotview.h receiversview.h classinfoview.h
+
+METASOURCES = AUTO
+
+messages:
+ LIST=`find . -name \*.h -o -name \*.hh -o -name \*.H -o -name \*.hxx -o -name \*.hpp -o -name \*.cpp -o -name \*.cc -o -name \*.cxx -o -name \*.ecpp -o -name \*.C`; \
+ if test -n "$$LIST"; then \
+ $(XGETTEXT) $$LIST -o $(podir)/spy.pot; \
+ fi
+
+check_PROGRAMS = testkspy
+testkspy_SOURCES = main.cpp
+testkspy_LDADD = libkspy.la
diff --git a/kspy/README b/kspy/README
new file mode 100644
index 00000000..ad810112
--- /dev/null
+++ b/kspy/README
@@ -0,0 +1,12 @@
+KSpy
+====
+
+KSpy is a utility intended to help developers examine the internal
+state of a Qt/KDE application. KSpy graphically displays all the
+QObjects in use, and allows you to browse their properties. Using KSpy
+is very simple, include kspy.h and call KSpy::invoke() when you want
+to looks inside your app. The KSpy function is inline and the main
+part of KSpy is dynamically loaded, so you may even want to leave this
+in the release build of an application.
+
+Richard Moore, <rich@kde.org>
diff --git a/kspy/classinfoview.cpp b/kspy/classinfoview.cpp
new file mode 100644
index 00000000..1b976cfa
--- /dev/null
+++ b/kspy/classinfoview.cpp
@@ -0,0 +1,58 @@
+/***************************************************************************
+ classinfoview.cpp - description
+ -------------------
+ begin : Tue Jan 11 2005
+ copyright : (C) 2005 by Richard Dale
+ email : Richard_Dale@tipitina.demon.co.uk
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#include <qobjectdict.h>
+#include <qobjectlist.h>
+#include <qmetaobject.h>
+#include <qstrlist.h>
+#include <qvariant.h>
+
+#include <klocale.h>
+
+#include "classinfoview.h"
+
+ClassInfoView::ClassInfoView(QWidget *parent, const char *name ) : KListView(parent,name)
+{
+ addColumn( i18n( "Name" ) );
+ addColumn( i18n( "Value" ) );
+
+ setRootIsDecorated( true );
+ setAllColumnsShowFocus( true );
+ setFullWidth( true );
+}
+
+ClassInfoView::~ClassInfoView()
+{
+}
+
+void ClassInfoView::buildList( QObject *o )
+{
+ QMetaObject *mo = o->metaObject();
+
+ for (int index = 0; index < mo->numClassInfo(true); index++) {
+ const QClassInfo * classInfo = mo->classInfo(index, true);
+ new KListViewItem( this, classInfo->name, classInfo->value );
+ }
+}
+
+void ClassInfoView::setTarget( QObject *o )
+{
+ clear();
+ buildList( o );
+}
+
+#include "classinfoview.moc"
diff --git a/kspy/classinfoview.h b/kspy/classinfoview.h
new file mode 100644
index 00000000..e8b4440b
--- /dev/null
+++ b/kspy/classinfoview.h
@@ -0,0 +1,40 @@
+/***************************************************************************
+ classinfoview.h - description
+ -------------------
+ begin : Tue Jan 11 2005
+ copyright : (C) 2005 by Richard Dale
+ email : Richard_Dale@tipitina.demon.co.uk
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef CLASSINFOVIEW_H
+#define CLASSINFOVIEW_H
+
+#include <qwidget.h>
+#include <klistview.h>
+
+/**
+ *@author Richard Dale
+ */
+
+class ClassInfoView : public KListView {
+ Q_OBJECT
+public:
+ ClassInfoView(QWidget *parent=0, const char *name=0);
+ ~ClassInfoView();
+
+ void buildList( QObject *o );
+
+public slots:
+ void setTarget( QObject * );
+};
+
+#endif
diff --git a/kspy/kspy.h b/kspy/kspy.h
new file mode 100644
index 00000000..e2878125
--- /dev/null
+++ b/kspy/kspy.h
@@ -0,0 +1,44 @@
+// -*- c++ -*-
+
+#ifndef KSPY_H
+#define KSPY_H
+
+#include <klibloader.h>
+
+/**
+ * Loader for the QObject debugging tool. The usage is simple, just call
+ * KSpy::invoke(), then use the spy window to examine the state of your
+ * QObjects.
+ *
+ * @author Richard Moore, rich@kde.org
+ * @version $Id$
+ */
+class KSpy
+{
+public:
+ /**
+ * Loads and invokes the KSpy utility.
+ */
+ static void invoke() {
+ KLibLoader *loader = KLibLoader::self();
+ KLibrary *lib = loader->library( "libkspy" );
+
+ if ( !lib ) {
+ qWarning( "Unable to load KSpy library\n" );
+ return;
+ }
+
+ lib->factory(); // Ensure the factory is loaded
+
+ // We don't need to do any more, KSpy is fired up by the loader hook
+ // in the shared library.
+ }
+
+private:
+ // Prevent instantiation.
+ KSpy() {}
+ ~KSpy() {}
+};
+
+#endif // KSPY_H
+
diff --git a/kspy/main.cpp b/kspy/main.cpp
new file mode 100644
index 00000000..ab8a3594
--- /dev/null
+++ b/kspy/main.cpp
@@ -0,0 +1,52 @@
+/***************************************************************************
+ main.cpp - description
+ -------------------
+ begin : Tue May 1 02:59:33 BST 2001
+ copyright : (C) 2001 by Richard Moore
+ email : rich@kde.org
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#include <kcmdlineargs.h>
+#include <kaboutdata.h>
+#include <klocale.h>
+
+#include "spy.h"
+
+static const char description[] =
+ I18N_NOOP("Spy");
+// INSERT A DESCRIPTION FOR YOUR APPLICATION HERE
+
+
+static KCmdLineOptions options[] =
+{
+ KCmdLineLastOption
+ // INSERT YOUR COMMANDLINE OPTIONS HERE
+};
+
+int main(int argc, char *argv[])
+{
+
+ KAboutData aboutData( "spy", I18N_NOOP("Spy"),
+ VERSION, description, KAboutData::License_GPL,
+ "(c) 2001, Richard Moore", 0, 0, "rich@kde.org");
+ aboutData.addAuthor("Richard Moore",0, "rich@kde.org");
+ KCmdLineArgs::init( argc, argv, &aboutData );
+ KCmdLineArgs::addCmdLineOptions( options ); // Add our own options.
+
+ KApplication a;
+ Spy *spy = new Spy();
+ a.setMainWidget(spy);
+
+ spy->show();
+
+ return a.exec();
+}
diff --git a/kspy/navview.cpp b/kspy/navview.cpp
new file mode 100644
index 00000000..8f6afc8e
--- /dev/null
+++ b/kspy/navview.cpp
@@ -0,0 +1,88 @@
+/***************************************************************************
+ navview.cpp - description
+ -------------------
+ begin : Tue May 1 2001
+ copyright : (C) 2001 by Richard Moore
+ email : rich@kde.org
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#include <qobjectlist.h>
+#include <qobjectdict.h>
+
+#include <klocale.h>
+
+#include "navview.h"
+#include "navviewitem.h"
+
+NavView::NavView(QWidget *parent, const char *name ) : KListView(parent,name)
+{
+ addColumn( i18n( "Name" ) );
+ addColumn( i18n( "Type" ) );
+
+ setRootIsDecorated( true );
+ setAllColumnsShowFocus( true );
+ setFullWidth( true );
+
+ connect( this, SIGNAL( selectionChanged( QListViewItem * ) ),
+ this, SLOT( selectItem( QListViewItem * ) ) );
+}
+
+NavView::~NavView(){
+}
+
+void NavView::buildTree()
+{
+ const QObjectList *roots = QObject::objectTrees();
+ QObjectListIt it( *roots );
+
+ QObject * obj;
+ while ( (obj = it.current()) != 0 ) {
+ ++it;
+ NavViewItem *item = new NavViewItem( this, obj );
+ createSubTree( item );
+ }
+}
+
+void NavView::expandVisibleTree()
+{
+ QListViewItemIterator it( this, QListViewItemIterator::Visible |
+ QListViewItemIterator::Expandable );
+
+ while ( it.current() ) {
+ setOpen( *it, true );
+ ++it;
+ }
+}
+
+void NavView::selectItem( QListViewItem *item )
+{
+ NavViewItem *navItem = static_cast<NavViewItem*>( item );
+
+ emit selected( navItem->data );
+}
+
+void NavView::createSubTree( NavViewItem *parent )
+{
+ const QObjectList *kids = parent->data->children();
+ if ( !kids )
+ return;
+
+ QObject * obj;
+ QObjectListIt it( *kids );
+ while ( (obj=it.current()) != 0 ) {
+ ++it;
+ NavViewItem *item = new NavViewItem( parent, obj );
+ createSubTree( item );
+ }
+}
+
+#include "navview.moc"
diff --git a/kspy/navview.h b/kspy/navview.h
new file mode 100644
index 00000000..326f7790
--- /dev/null
+++ b/kspy/navview.h
@@ -0,0 +1,57 @@
+/***************************************************************************
+ navview.h - description
+ -------------------
+ begin : Tue May 1 2001
+ copyright : (C) 2001 by Richard Moore
+ email : rich@kde.org
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef NAVVIEW_H
+#define NAVVIEW_H
+
+#include <qwidget.h>
+#include <klistview.h>
+
+class NavViewItem;
+
+/**
+ * @author Richard Moore
+ */
+class NavView : public KListView
+{
+ Q_OBJECT
+
+ public:
+ NavView( QWidget *parent = 0, const char *name = 0 );
+ ~NavView();
+
+ /**
+ Builds the complete tree.
+ */
+ void buildTree();
+
+ /**
+ Expands all currently visible items.
+ */
+ void expandVisibleTree();
+
+ signals:
+ void selected( QObject *object );
+
+ protected slots:
+ void selectItem( QListViewItem *item );
+
+ private:
+ void createSubTree( NavViewItem* );
+};
+
+#endif
diff --git a/kspy/navviewitem.cpp b/kspy/navviewitem.cpp
new file mode 100644
index 00000000..de372b4f
--- /dev/null
+++ b/kspy/navviewitem.cpp
@@ -0,0 +1,40 @@
+/***************************************************************************
+ navviewitem.cpp - description
+ -------------------
+ begin : Tue May 1 2001
+ copyright : (C) 2001 by Richard Moore
+ email : rich@kde.org
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#include <qobject.h>
+
+#include "navview.h"
+#include "navviewitem.h"
+
+NavViewItem::NavViewItem(NavView *parent, QObject *obj )
+ : KListViewItem(parent, obj->name(), obj->className() )
+{
+ data = obj;
+ setExpandable( true );
+}
+
+NavViewItem::NavViewItem(NavViewItem *parent, QObject *obj )
+ : KListViewItem(parent, obj->name(), obj->className() )
+{
+ data = obj;
+ setExpandable( true );
+}
+
+NavViewItem::~NavViewItem()
+{
+}
+
diff --git a/kspy/navviewitem.h b/kspy/navviewitem.h
new file mode 100644
index 00000000..35a66c07
--- /dev/null
+++ b/kspy/navviewitem.h
@@ -0,0 +1,38 @@
+/***************************************************************************
+ navviewitem.h - description
+ -------------------
+ begin : Tue May 1 2001
+ copyright : (C) 2001 by Richard Moore
+ email : rich@kde.org
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef NAVVIEWITEM_H
+#define NAVVIEWITEM_H
+
+#include <qlistview.h>
+
+class NavView;
+
+/**
+ *@author Richard Moore
+ */
+
+class NavViewItem : public KListViewItem {
+public:
+ NavViewItem(NavView *parent, QObject *item );
+ NavViewItem(NavViewItem *parent, QObject *item );
+ ~NavViewItem();
+
+ QObject *data;
+};
+
+#endif
diff --git a/kspy/propsview.cpp b/kspy/propsview.cpp
new file mode 100644
index 00000000..12b855c0
--- /dev/null
+++ b/kspy/propsview.cpp
@@ -0,0 +1,196 @@
+/***************************************************************************
+ propsview.cpp - description
+ -------------------
+ begin : Tue May 1 2001
+ copyright : (C) 2001 by Richard Moore
+ email : rich@kde.org
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#include <qobjectdict.h>
+#include <qobjectlist.h>
+#include <qmetaobject.h>
+#include <qstrlist.h>
+#include <qvariant.h>
+#include <qcursor.h>
+
+#include <klocale.h>
+
+#include "propsview.h"
+
+class KSpyItem : KListViewItem
+{
+public:
+ KSpyItem( QListView * parent, QString label1, QString label2 = QString::null, QString label3 = QString::null, QString label4 = QString::null, QString label5 = QString::null, QString label6 = QString::null )
+ : KListViewItem(parent, label1, label2, label3, label4, label5, label6)
+ {
+ }
+protected:
+ void paintCell( QPainter * p, const QColorGroup & cg,
+ int column, int width, int alignment )
+ {
+ if (column == 1 && text(2) == "QColor") {
+ QColorGroup color_cg( cg.foreground(), cg.background(),
+ cg.light(), cg.dark(), cg.mid(),
+ QColor(text(1)), QColor(text(1)) );
+ QListViewItem::paintCell(p, color_cg, column, width, alignment);
+ } else {
+ KListViewItem::paintCell(p, cg, column, width, alignment);
+ }
+ }
+};
+
+PropsView::PropsView(QWidget *parent, const char *name ) : KListView(parent,name)
+{
+ addColumn( i18n( "Name" ) );
+ addColumn( i18n( "Value" ) );
+ addColumn( i18n( "Type" ) );
+ addColumn( i18n( "Access" ) );
+ addColumn( i18n( "Designable" ) );
+ addColumn( i18n( "Type Flags" ) );
+
+ setAllColumnsShowFocus( true );
+ setColumnAlignment( 3, AlignCenter );
+ setColumnAlignment( 4, AlignCenter );
+ setFullWidth( true );
+}
+
+PropsView::~PropsView()
+{
+}
+
+void PropsView::buildList( QObject *o )
+{
+ QMetaObject *mo = o->metaObject();
+ QStrList names = mo->propertyNames( true );
+
+ for ( uint i = 0; i < names.count(); i++ ) {
+ char *prop = names.at( i );
+ QVariant v = o->property( prop );
+ const QMetaProperty *mp = mo->property( mo->findProperty(prop, true), true );
+
+ QString val( "????" );
+ switch( v.type() ) {
+ case QVariant::String:
+ case QVariant::CString:
+ val = v.toString();
+ break;
+ case QVariant::Bool:
+ val = ( v.toBool() ? "True" : "False" );
+ break;
+ case QVariant::Color:
+ {
+ QColor c = v.toColor();
+ val = c.name();
+ break;
+ }
+ case QVariant::Cursor:
+ {
+ QCursor c = v.toCursor();
+ val = QString("shape=%1").arg(c.shape());
+ break;
+ }
+ case QVariant::Font:
+ {
+ QFont f = v.toFont();
+ val = QString("family=%1, pointSize=%2, weight=%3, italic=%4, bold=%5, underline=%6, strikeOut=%7")
+ .arg(f.family())
+ .arg(f.pointSize())
+ .arg(f.weight())
+ .arg(f.italic())
+ .arg(f.bold())
+ .arg(f.underline())
+ .arg(f.strikeOut());
+ break;
+ }
+ case QVariant::Int:
+ val.setNum( v.toInt() );
+ if (mp->isEnumType()) {
+ QMetaObject * metaObject = *(mp->meta);
+ val = QString("%1::%2").arg(metaObject->className()).arg(mp->valueToKey(val.toInt()));
+ }
+ break;
+ case QVariant::Point:
+ {
+ QPoint p = v.toPoint();
+ val = QString("x=%1, y=%2").arg(p.x()).arg(p.y());
+ break;
+ }
+ case QVariant::Rect:
+ {
+ QRect r = v.toRect();
+ val = QString("left=%1, right=%2, top=%3, bottom=%4")
+ .arg(r.left())
+ .arg(r.right())
+ .arg(r.top())
+ .arg(r.bottom());
+ break;
+ }
+ case QVariant::Size:
+ {
+ QSize s = v.toSize();
+ val = QString("width=%1, height=%2").arg(s.width()).arg(s.height());
+ break;
+ }
+ case QVariant::SizePolicy:
+ {
+ QSizePolicy s = v.toSizePolicy();
+ val = QString("horData=%1, verData=%2").arg(s.horData()).arg(s.verData());
+ break;
+ }
+ case QVariant::Double:
+ val.setNum( v.toDouble() );
+ break;
+ default:
+ break;
+ }
+
+ QString ro("R/O");
+ QString rw("R/W");
+ QString st("Set");
+ QString et("Enum");
+ QString yes("Yes");
+ QString no("No");
+
+ QString writable = ( mp->writable() ? rw : ro );
+ QString setType = ( mp->isSetType() ? st : QString::null );
+ QString enumType = ( mp->isEnumType() ? et : QString::null );
+ QString designable = ( mp->designable(o) ? yes : no );
+
+ QString flags;
+ bool first = true;
+ if ( !setType.isNull() ) {
+ if ( first )
+ first = false;
+ else
+ flags += " | ";
+
+ flags += setType;
+ }
+ if ( !enumType.isNull() ) {
+ if ( first )
+ first = false;
+ else
+ flags += " | ";
+
+ flags += enumType;
+ }
+
+ new KSpyItem( this, prop, val, v.typeName(), writable, designable, flags );
+ }
+}
+
+void PropsView::setTarget( QObject *o )
+{
+ clear();
+ buildList( o );
+}
+#include "propsview.moc"
diff --git a/kspy/propsview.h b/kspy/propsview.h
new file mode 100644
index 00000000..62eb5e8d
--- /dev/null
+++ b/kspy/propsview.h
@@ -0,0 +1,40 @@
+/***************************************************************************
+ propsview.h - description
+ -------------------
+ begin : Tue May 1 2001
+ copyright : (C) 2001 by Richard Moore
+ email : rich@kde.org
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef PROPSVIEW_H
+#define PROPSVIEW_H
+
+#include <qwidget.h>
+#include <klistview.h>
+
+/**
+ *@author Richard Moore
+ */
+
+class PropsView : public KListView {
+ Q_OBJECT
+public:
+ PropsView(QWidget *parent=0, const char *name=0);
+ ~PropsView();
+
+ void buildList( QObject *o );
+
+public slots:
+ void setTarget( QObject * );
+};
+
+#endif
diff --git a/kspy/receiversview.cpp b/kspy/receiversview.cpp
new file mode 100644
index 00000000..e1da1127
--- /dev/null
+++ b/kspy/receiversview.cpp
@@ -0,0 +1,80 @@
+/***************************************************************************
+ receiversview.cpp - description
+ -------------------
+ begin : Tue Jan 11 2005
+ copyright : (C) 2005 by Richard Dale
+ email : Richard_Dale@tipitina.demon.co.uk
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#include <qobjectdict.h>
+#include <qobjectlist.h>
+#include <qmetaobject.h>
+#include <qstrlist.h>
+#include <qvariant.h>
+#include <qsignalslotimp.h>
+
+#include <klocale.h>
+
+#include "receiversview.h"
+
+class UnencapsulatedQObject : public QObject {
+public:
+ QConnectionList *public_receivers(int signal) const { return receivers(signal); }
+};
+
+ReceiversView::ReceiversView(QWidget *parent, const char *name ) : KListView(parent,name)
+{
+ addColumn( i18n( "Object" ) );
+ addColumn( i18n( "Type" ) );
+ addColumn( i18n( "Member Name" ) );
+
+ setRootIsDecorated( true );
+ setAllColumnsShowFocus( true );
+ setFullWidth( true );
+}
+
+ReceiversView::~ReceiversView()
+{
+}
+
+void ReceiversView::buildList( QObject *o )
+{
+ QMetaObject *mo = o->metaObject();
+
+ UnencapsulatedQObject * qobject = (UnencapsulatedQObject *) o;
+ QStrList signalNames = mo->signalNames(true);
+
+ for (int sig = 0; sig < mo->numSignals(true); sig++) {
+ QConnectionList * clist = qobject->public_receivers(sig);
+ if (clist != 0) {
+ KListViewItem *conn = new KListViewItem( this, signalNames.at(sig) );
+
+ for ( QConnection * connection = clist->first();
+ connection != 0;
+ connection = clist->next() )
+ {
+ new KListViewItem( conn,
+ connection->object()->name(),
+ connection->memberType() == 1 ? "SLOT" : "SIGNAL",
+ connection->memberName() );
+ }
+ }
+ }
+}
+
+void ReceiversView::setTarget( QObject *o )
+{
+ clear();
+ buildList( o );
+}
+
+#include "receiversview.moc"
diff --git a/kspy/receiversview.h b/kspy/receiversview.h
new file mode 100644
index 00000000..31768883
--- /dev/null
+++ b/kspy/receiversview.h
@@ -0,0 +1,40 @@
+/***************************************************************************
+ receiversview.h - description
+ -------------------
+ begin : Tue Jan 11 2005
+ copyright : (C) 2005 by Richard Dale
+ email : Richard_Dale@tipitina.demon.co.uk
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef RECEIVERSVIEW_H
+#define RECEIVERSVIEW_H
+
+#include <qwidget.h>
+#include <klistview.h>
+
+/**
+ *@author Richard Dale
+ */
+
+class ReceiversView : public KListView {
+ Q_OBJECT
+public:
+ ReceiversView(QWidget *parent=0, const char *name=0);
+ ~ReceiversView();
+
+ void buildList( QObject *o );
+
+public slots:
+ void setTarget( QObject * );
+};
+
+#endif
diff --git a/kspy/sigslotview.cpp b/kspy/sigslotview.cpp
new file mode 100644
index 00000000..2e04cfa7
--- /dev/null
+++ b/kspy/sigslotview.cpp
@@ -0,0 +1,73 @@
+/***************************************************************************
+ sigslotview.cpp - description
+ -------------------
+ begin : Tue May 1 2001
+ copyright : (C) 2001 by Richard Moore
+ email : rich@kde.org
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#include <qobjectdict.h>
+#include <qobjectlist.h>
+#include <qmetaobject.h>
+#include <qstrlist.h>
+#include <qvariant.h>
+
+#include <klocale.h>
+
+#include "sigslotview.h"
+
+SigSlotView::SigSlotView(QWidget *parent, const char *name ) : KListView(parent,name)
+{
+ addColumn( i18n( "Signals/Slots" ) );
+
+ setRootIsDecorated( true );
+ setAllColumnsShowFocus( true );
+ setFullWidth( true );
+}
+
+SigSlotView::~SigSlotView()
+{
+}
+
+void SigSlotView::buildList( QObject *o )
+{
+ QMetaObject *mo = o->metaObject();
+
+ KListViewItem *sigs = new KListViewItem( this, "Signals" );
+ QStrList sigList = mo->signalNames( true );
+ QStrListIterator sigIt( sigList );
+ char *si;
+ while ( (si=sigIt.current()) != 0 ) {
+ ++sigIt;
+ new KListViewItem( sigs, si /*, "someSignal()"*/ );
+ }
+
+ KListViewItem *slts = new KListViewItem( this, "Slots" );
+ QStrList sltList = mo->slotNames( true );
+ QStrListIterator sltIt( sltList );
+ char *sl;
+ while ( (sl=sltIt.current()) != 0 ) {
+ ++sltIt;
+ new KListViewItem( slts, sl/*, "someSlot()"*/ );
+ }
+
+ setOpen( sigs, false );
+ setOpen( slts, false );
+}
+
+void SigSlotView::setTarget( QObject *o )
+{
+ clear();
+ buildList( o );
+}
+
+#include "sigslotview.moc"
diff --git a/kspy/sigslotview.h b/kspy/sigslotview.h
new file mode 100644
index 00000000..86138fd1
--- /dev/null
+++ b/kspy/sigslotview.h
@@ -0,0 +1,40 @@
+/***************************************************************************
+ sigslotview.h - description
+ -------------------
+ begin : Tue May 1 2001
+ copyright : (C) 2001 by Richard Moore
+ email : rich@kde.org
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef SIGSLOTVIEW_H
+#define SIGSLOTVIEW_H
+
+#include <qwidget.h>
+#include <klistview.h>
+
+/**
+ *@author Richard Moore
+ */
+
+class SigSlotView : public KListView {
+ Q_OBJECT
+public:
+ SigSlotView(QWidget *parent=0, const char *name=0);
+ ~SigSlotView();
+
+ void buildList( QObject *o );
+
+public slots:
+ void setTarget( QObject * );
+};
+
+#endif
diff --git a/kspy/spy.cpp b/kspy/spy.cpp
new file mode 100644
index 00000000..341f5b62
--- /dev/null
+++ b/kspy/spy.cpp
@@ -0,0 +1,115 @@
+/***************************************************************************
+ spy.cpp - description
+ -------------------
+ begin : Tue May 1 02:59:33 BST 2001
+ copyright : (C) 2001 by Richard Moore
+ email : rich@kde.org
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#include <klistviewsearchline.h>
+#include <klocale.h>
+
+#include <qlabel.h>
+#include <qlayout.h>
+#include <qlistview.h>
+#include <qsplitter.h>
+#include <ktabwidget.h>
+#include <qvbox.h>
+
+#include "navview.h"
+#include "propsview.h"
+#include "sigslotview.h"
+#include "receiversview.h"
+#include "classinfoview.h"
+#include "spy.h"
+
+extern "C"
+{
+ KDE_EXPORT void* init_libkspy()
+ {
+ qWarning( "KSpy: Initialising...\n" );
+ Spy *s = new Spy();
+ s->show();
+
+ return 0;
+ }
+}
+
+Spy::Spy( QWidget *parent, const char *name )
+ : QWidget( parent, name )
+{
+ QVBoxLayout *layout = new QVBoxLayout( this, 11, 6 );
+
+ QSplitter *div = new QSplitter( this );
+ layout->addWidget( div );
+
+ QVBox *leftPane = new QVBox( div );
+
+ KListViewSearchLine *searchLine = new KListViewSearchLine( leftPane, "search line" );
+ mNavView = new NavView( leftPane, "navigation view" );
+ searchLine->setListView( mNavView );
+
+ KTabWidget *tabs = new KTabWidget( div );
+
+ mPropsView = new PropsView( tabs, "properties view" );
+ tabs->addTab( mPropsView, i18n( "Properties" ) );
+
+ mSigSlotView = new SigSlotView( tabs, "signals and slots view" );
+ tabs->addTab( mSigSlotView, i18n( "Signals && Slots" ) );
+
+ mReceiversView = new ReceiversView( tabs, "receivers view" );
+ tabs->addTab( mReceiversView, i18n( "Receivers" ) );
+
+ mClassInfoView = new ClassInfoView( tabs, "class info view" );
+ tabs->addTab( mClassInfoView, i18n( "Class Info" ) );
+
+ mNavView->buildTree();
+
+ connect( mNavView, SIGNAL( selected( QObject * ) ),
+ mPropsView, SLOT( setTarget( QObject * ) ) );
+ connect( mNavView, SIGNAL( selected( QObject * ) ),
+ mSigSlotView, SLOT( setTarget( QObject * ) ) );
+ connect( mNavView, SIGNAL( selected( QObject * ) ),
+ mReceiversView, SLOT( setTarget( QObject * ) ) );
+ connect( mNavView, SIGNAL( selected( QObject * ) ),
+ mClassInfoView, SLOT( setTarget( QObject * ) ) );
+}
+
+Spy::~Spy()
+{
+}
+
+
+void Spy::setTarget( QWidget *target )
+{
+ mTarget = target;
+ mPropsView->buildList( mTarget );
+ mSigSlotView->buildList( mTarget );
+ mReceiversView->buildList( mTarget );
+ mClassInfoView->buildList( mTarget );
+}
+
+void Spy::keyPressEvent( QKeyEvent *event )
+{
+ if ( event->key() == Qt::Key_Up ) {
+ event->accept();
+ QApplication::postEvent( mNavView, new QKeyEvent( QEvent::KeyPress, Qt::Key_Up, 0, 0 ) );
+ } else if ( event->key() == Qt::Key_Down ) {
+ event->accept();
+ QApplication::postEvent( mNavView, new QKeyEvent( QEvent::KeyPress, Qt::Key_Down, 0, 0 ) );
+ } else if ( event->key() == Qt::Key_Return ) {
+ event->accept();
+ mNavView->expandVisibleTree();
+ }
+}
+
+#include "spy.moc"
diff --git a/kspy/spy.h b/kspy/spy.h
new file mode 100644
index 00000000..61d80162
--- /dev/null
+++ b/kspy/spy.h
@@ -0,0 +1,59 @@
+/***************************************************************************
+ spy.h - description
+ -------------------
+ begin : Tue May 1 02:59:33 BST 2001
+ copyright : (C) 2001 by Richard Moore
+ email : rich@kde.org
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef SPY_H
+#define SPY_H
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <kapplication.h>
+#include <qwidget.h>
+
+class NavView;
+class PropsView;
+class SigSlotView;
+class ReceiversView;
+class ClassInfoView;
+
+/**
+ Spy is the main window class of the project.
+ */
+class Spy : public QWidget
+{
+ Q_OBJECT
+
+ public:
+ Spy( QWidget *parent = 0, const char *name = 0 );
+ ~Spy();
+
+ void setTarget( QWidget *target );
+
+ protected:
+ virtual void keyPressEvent( QKeyEvent* );
+
+ private:
+ QWidget *mTarget;
+ PropsView *mPropsView;
+ SigSlotView *mSigSlotView;
+ ReceiversView *mReceiversView;
+ ClassInfoView *mClassInfoView;
+ NavView *mNavView;
+};
+
+#endif