# kparts Library API Documentation

Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Source Files

# browserinterface.cpp

    00001
    00002 #include "browserinterface.h"
    00003
    00004 #include <qmetaobject.h>
    00005
    00006 #include <config.h>
    00007 #if QT_VERSION >= 300
    00008 #include <private/qucomextra_p.h>
    00009 #endif
    00010
    00011 using namespace KParts;
    00012
    00013 BrowserInterface::BrowserInterface( QObject *parent, const char *name )
    00014     : QObject( parent, name )
    00015 {
    00016 }
    00017
    00018 BrowserInterface::~BrowserInterface()
    00019 {
    00020 }
    00021
    00022 void BrowserInterface::callMethod( const char *name, const QVariant &argument )
    00023 {
    00024 #if QT_VERSION < 300
    00025     QMetaData *mdata = metaObject()->slot( name );
    00026
    00027     if ( !mdata )
    00028         return;
    00029
    00030     // only the most common types for now
    00031     typedef void (QObject::*VoidMethod)(void);
    00032     typedef void (QObject::*StringMethod)(const QString &);
    00033     typedef void (QObject::*StringListMethod)(const QStringList &);
    00034     typedef void (QObject::*IntMethod)(int);
    00035     typedef void (QObject::*UIntMethod)(uint);
    00036     typedef void (QObject::*BoolMethod)(bool);
    00037
    00038     switch ( argument.type() )
    00039     {
    00040         case QVariant::Invalid:
    00041             (this->*((VoidMethod)mdata->ptr))();
    00042             break;
    00043         case QVariant::String:
    00044             (this->*((StringMethod)mdata->ptr))( argument.toString() );
    00045             break;
    00046         case QVariant::StringList:
    00047             (this->*((StringListMethod)mdata->ptr))( argument.toStringList() );
    00048             break;
    00049         case QVariant::Int:
    00050             (this->*((IntMethod)mdata->ptr))( argument.toInt() );
    00051             break;
    00052         case QVariant::UInt:
    00053             (this->*((UIntMethod)mdata->ptr))( argument.toUInt() );
    00054             break;
    00055         case QVariant::Bool:
    00056             (this->*((BoolMethod)mdata->ptr))( argument.toBool() );
    00057             break;
    00058         default: break;
    00059     }
    00060 #else
    00061     int slot = metaObject()->findSlot( name );
    00062
    00063     if ( slot == -1 )
    00064         return;
    00065
    00066     QUObject o[ 2 ];
    00067     QStringList strLst;
    00068     uint i;
    00069
    00070     switch ( argument.type() )
    00071     {
    00072         case QVariant::Invalid:
    00073             break;
    00074         case QVariant::String:
    00075             static_QUType_QString.set( o + 1, argument.toString() );
    00076             break;
    00077         case QVariant::StringList:
    00078             strLst = argument.toStringList();
    00079             static_QUType_ptr.set( o + 1, &strLst );
    00080             break;
    00081         case QVariant::Int:
    00082             static_QUType_int.set( o + 1, argument.toInt() );
    00083             break;
    00084         case QVariant::UInt:
    00085             i = argument.toUInt();
    00086             static_QUType_ptr.set( o + 1, &i );
    00087             break;
    00088         case QVariant::Bool:
    00089             static_QUType_bool.set( o + 1, argument.toBool() );
    00090             break;
    00091         default: return;
    00092     }
    00093
    00094     qt_invoke( slot, o );
    00095 #endif
    00096 }
    00097
    00098 #include "browserinterface.moc"

This file is part of the documentation for kdelibs Version 3.1.5.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Wed Jan 28 13:26:50 2004 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001