20#include "kdcoppropertyproxy.h" 
   23#include <tqmetaobject.h> 
   28#include <tqpointarray.h> 
   38class KDCOPPropertyProxyPrivate
 
   41  KDCOPPropertyProxyPrivate()
 
   44  ~KDCOPPropertyProxyPrivate()
 
   53  d = 
new KDCOPPropertyProxyPrivate;
 
   68                                                 TQCString &replyType, TQByteArray &replyData )
 
   80  if ( fun == 
"property(TQCString)" ||
 
   81       fun == 
"setProperty(TQCString,TQVariant)" ||
 
   82       fun == 
"propertyNames(bool)" )
 
   86  TQCString propName, arg;
 
   87  return decodePropertyRequestInternal( fun, 
object, set, propName, arg );
 
   92  TQValueList<TQCString> res;
 
   93  res << 
"TQVariant property(TQCString property)";
 
   94  res << 
"bool setProperty(TQCString name,TQVariant property)";
 
   95  res << 
"TQValueList<TQCString> propertyNames(bool super)";
 
   97  TQMetaObject *metaObj = 
object->metaObject();
 
   98  TQStrList properties = metaObj->propertyNames( 
true );
 
   99  TQStrListIterator it( properties );
 
  100  for (; it.current(); ++it )
 
  102    const TQMetaProperty *metaProp = metaObj->property( metaObj->findProperty( it.current(), 
true ), 
true );
 
  106    TQCString name = it.current();
 
  108    name.prepend( metaProp->type() );
 
  112    if ( metaProp->writable() )
 
  114      TQCString setName = it.current();
 
  115      setName[ 0 ] = toupper( setName[ 0 ] );
 
  116      setName = 
"void set" + setName + 
"(" + metaProp->type() + 
" " + it.current() + 
")";
 
  124#define MARSHAL( type ) \ 
  125  case TQVariant::type: \ 
  127    reply << prop.to##type(); \ 
  131#define DEMARSHAL( type, val ) \ 
  132  case TQVariant::type: \ 
  136    prop = TQVariant( v ); \ 
  141                                                 TQCString &replyType, TQByteArray &replyData,
 
  144  if ( fun == 
"property(TQCString)" )
 
  147    TQDataStream stream( data, IO_ReadOnly );
 
  150    replyType = 
"TQVariant";
 
  151    TQDataStream reply( replyData, IO_WriteOnly );
 
  152    reply << 
object->property( propName );
 
  156  if ( fun == 
"setProperty(TQCString,TQVariant)" )
 
  160    TQDataStream stream( data, IO_ReadOnly );
 
  161    stream >> propName >> propValue;
 
  164    TQDataStream reply( replyData, IO_WriteOnly );
 
  165    reply << (TQ_INT8)object->setProperty( propName, propValue );
 
  169  if ( fun == 
"propertyNames(bool)" )
 
  172    TQDataStream stream( data, IO_ReadOnly );
 
  175    TQValueList<TQCString> res;
 
  176    TQStrList props = 
object->metaObject()->propertyNames( 
static_cast<bool>( b ) );
 
  177    TQStrListIterator it( props );
 
  178    for (; it.current(); ++it )
 
  179      res.append( it.current() );
 
  181    replyType = 
"TQValueList<TQCString>";
 
  182    TQDataStream reply( replyData, IO_WriteOnly );
 
  188  TQCString propName, arg;
 
  190  bool res = decodePropertyRequestInternal( fun, 
object, set, propName, arg );
 
  197    TQDataStream stream( data, IO_ReadOnly );
 
  199    TQVariant::Type type = TQVariant::nameToType( arg );
 
  200    if ( type == TQVariant::Invalid )
 
  203    typedef TQValueList<TQVariant> ListType;
 
  204    typedef TQStringVariantMap MapType;
 
  208      DEMARSHAL( Cursor, TQCursor )
 
  209      DEMARSHAL( Bitmap, TQBitmap )
 
  210      DEMARSHAL( PointArray, TQPointArray )
 
  211      DEMARSHAL( Region, TQRegion )
 
  212      DEMARSHAL( List, ListType )
 
  213      DEMARSHAL( Map, MapType )
 
  214      DEMARSHAL( String, TQString )
 
  215      DEMARSHAL( CString, TQCString )
 
  216      DEMARSHAL( StringList, TQStringList )
 
  217      DEMARSHAL( Font, TQFont )
 
  218      DEMARSHAL( Pixmap, TQPixmap )
 
  219      DEMARSHAL( Image, TQImage )
 
  220      DEMARSHAL( Brush, TQBrush )
 
  221      DEMARSHAL( Point, TQPoint )
 
  222      DEMARSHAL( Rect, TQRect )
 
  223      DEMARSHAL( Size, TQSize )
 
  224      DEMARSHAL( Color, TQColor )
 
  225      DEMARSHAL( Palette, TQPalette )
 
  226      DEMARSHAL( ColorGroup, TQColorGroup )
 
  227      case TQVariant::IconSet:
 
  231        prop = TQVariant( TQIconSet( val ) );
 
  234      DEMARSHAL( Int, 
int )
 
  235      DEMARSHAL( UInt, uint )
 
  236      case TQVariant::Bool:
 
  240        prop = TQVariant( 
static_cast<bool>( v ) );
 
  243      DEMARSHAL( Double, 
double )
 
  249    return object->setProperty( propName, prop );
 
  253    TQVariant prop = 
object->property( propName );
 
  255    if ( prop.type() == TQVariant::Invalid )
 
  258    replyType = prop.typeName();
 
  259    TQDataStream reply( replyData, IO_WriteOnly );
 
  261    switch ( prop.type() )
 
  265      MARSHAL( PointArray )
 
  271      MARSHAL( StringList )
 
  281      MARSHAL( ColorGroup )
 
  282      case TQVariant::IconSet:
 
  283        reply << prop.toIconSet().pixmap();
 
  287      case TQVariant::Bool:
 
  288        reply << (TQ_INT8)prop.toBool();
 
  304bool KDCOPPropertyProxy::decodePropertyRequestInternal( 
const TQCString &fun, TQObject *
object, 
bool &set,
 
  305                                                        TQCString &propName, TQCString &arg )
 
  307  if ( fun.length() < 3 )
 
  314  if ( propName.left( 3 ) == 
"set" )
 
  318    propName = propName.mid( 3 );
 
  319    int p1 = propName.find( 
'(' );
 
  321    uint len = propName.length();
 
  323    if ( propName[ len - 1 ] != 
')' )
 
  326    arg = propName.mid( p1+1, len - p1 - 2 );
 
  327    propName.truncate( p1 );
 
  328    propName[ 0 ] = tolower( propName[ 0 ] );
 
  331    propName.truncate( propName.length() - 2 );
 
  333  if ( !object->metaObject()->propertyNames( 
true ).contains( propName ) )
 
~KDCOPPropertyProxy()
Destructor.
 
KDCOPPropertyProxy(TQObject *object)
Convenience constructor.
 
TQValueList< TQCString > functions()
Convenience method, when using this class as object.
 
bool processPropertyRequest(const TQCString &fun, const TQByteArray &data, TQCString &replyType, TQByteArray &replyData)
Convenience method, when using this class as object.
 
bool isPropertyRequest(const TQCString &fun)
Convenience method, when using this class as object.