summaryrefslogtreecommitdiffstats
path: root/kpovmodeler/pmmetaobject.cpp
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commit47d455dd55be855e4cc691c32f687f723d9247ee (patch)
tree52e236aaa2576bdb3840ebede26619692fed6d7d /kpovmodeler/pmmetaobject.cpp
downloadtdegraphics-47d455dd55be855e4cc691c32f687f723d9247ee.tar.gz
tdegraphics-47d455dd55be855e4cc691c32f687f723d9247ee.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdegraphics@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kpovmodeler/pmmetaobject.cpp')
-rw-r--r--kpovmodeler/pmmetaobject.cpp95
1 files changed, 95 insertions, 0 deletions
diff --git a/kpovmodeler/pmmetaobject.cpp b/kpovmodeler/pmmetaobject.cpp
new file mode 100644
index 00000000..a7e98b9b
--- /dev/null
+++ b/kpovmodeler/pmmetaobject.cpp
@@ -0,0 +1,95 @@
+/*
+**************************************************************************
+ description
+ --------------------
+ copyright : (C) 2002 by Andreas Zehender
+**************************************************************************
+
+**************************************************************************
+* *
+* 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 QString& 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 QStringList( *( 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 QString& 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;
+}