blob: 0163e1fce5b4279244dcece41c612b2f1071aaa0 (
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
/*
**************************************************************************
description
--------------------
copyright : (C) 2002 by Andreas Zehender
email : zehender@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 "pmmetaobject.h"
PMPropertyBase::PMPropertyBase( const TQString& name,
PMVariant::PMVariantDataType t,
bool readOnly, bool writeOnly )
{
m_name = name;
m_type = t;
m_pEnumList = 0;
m_readOnly = readOnly;
m_writeOnly = writeOnly;
}
PMPropertyBase::PMPropertyBase( const PMPropertyBase& p )
{
m_name = p.m_name;
m_type = p.m_type;
m_readOnly = p.m_readOnly;
m_writeOnly = p.m_writeOnly;
if( p.m_pEnumList )
m_pEnumList = new TQStringList( *( p.m_pEnumList ) );
else
m_pEnumList = 0;
}
PMPropertyBase::~PMPropertyBase( )
{
delete m_pEnumList;
}
bool PMPropertyBase::setProperty( PMObject* obj, const PMVariant& v )
{
if( m_readOnly )
return false;
PMVariant cp = v;
if( cp.convertTo( m_type ) )
return setProtected( obj, cp );
return false;
}
PMVariant PMPropertyBase::getProperty( const PMObject* obj )
{
if( m_writeOnly )
return PMVariant( );
return getProtected( obj );
}
PMMetaObject::PMMetaObject( const TQString& className, PMMetaObject* superClass,
PMObjectFactoryMethod factory )
{
m_className = className;
m_pSuperClass = superClass;
m_factory = factory;
// add the properties of the super class to the dictionary
if( m_pSuperClass )
m_propertiesDict = superClass->m_propertiesDict;
}
PMMetaObject::~PMMetaObject( )
{
m_properties.setAutoDelete( true );
m_properties.clear( );
}
void PMMetaObject::addProperty( PMPropertyBase* p )
{
m_properties.append( p );
m_propertiesDict.insert( p->name( ), p );
}
PMObject* PMMetaObject::newObject( PMPart* part ) const
{
if( m_factory )
return m_factory( part );
return 0;
}
|