Kross
childreninterface.h
Go to the documentation of this file.00001 /*************************************************************************** 00002 * childreninterface.h 00003 * This file is part of the KDE project 00004 * copyright (C)2004-2006 by Sebastian Sauer (mail@dipe.org) 00005 * 00006 * This program is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU Library General Public 00008 * License as published by the Free Software Foundation; either 00009 * version 2 of the License, or (at your option) any later version. 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 * Library General Public License for more details. 00014 * You should have received a copy of the GNU Library General Public License 00015 * along with this program; see the file COPYING. If not, write to 00016 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00017 * Boston, MA 02110-1301, USA. 00018 ***************************************************************************/ 00019 00020 #ifndef KROSS_CHILDRENINTERFACE_H 00021 #define KROSS_CHILDRENINTERFACE_H 00022 00023 00024 #include <QtCore/QHash> 00025 #include <QtCore/QObject> 00026 00027 #include "krossconfig.h" 00028 00029 namespace Kross { 00030 00038 class KROSSCORE_EXPORT ChildrenInterface 00039 { 00040 public: 00041 00045 enum Options { 00046 NoOption = 0x00, 00047 AutoConnectSignals = 0x01, 00048 00049 //TODO probably add more options like; 00050 //ScriptableSlots = 0x01, ///< Publish slots that have Q_SCRIPTABLE defined. 00051 //NonScriptableSlots = 0x02, ///< Publish slots that don't have Q_SCRIPTABLE defined. 00052 //PrivateSlots = 0x04, ///< Publish private slots. 00053 //ProtectedSlots = 0x08, ///< Publish protected slots. 00054 //PublicSlots = 0x10, ///< Publish public slots. 00055 //AllSlots = ScriptableSlots|NonScriptableSlots|PrivateSlots|ProtectedSlots|PublicSlots, 00056 //ScriptableSignals = 0x100, ///< Publish signals that have Q_SCRIPTABLE defined. 00057 //NonScriptableSignals = 0x200, ///< Publish signals that don't have Q_SCRIPTABLE defined. 00058 //PrivateSignals = 0x400, ///< Publish private signals. 00059 //ProtectedSignals = 0x800, ///< Publish protected signals. 00060 //PublicSignals = 0x1000, ///< Publish public signals. 00061 //AllSignals = ScriptableSignals|NonScriptableSignals|PrivateSignals|ProtectedSignals|PublicSignals, 00062 //ScriptableProperties = 0x10000, ///< Publish properties that have Q_SCRIPTABLE defined. 00063 //NonScriptableProperties = 0x20000, ///< Publish properties that don't have Q_SCRIPTABLE defined. 00064 //AllProperties = ScriptableProperties|NonScriptableProperties, 00065 //GetParentObject = 0x100000, ///< Provide access to the parent QObject the QObject has. 00066 //SetParentObject = 0x200000, ///< Be able to set the parent QObject the QObject has. 00067 //ChildObjects = 0x400000, ///< Provide access to the child QObject's the QObject has. 00068 //AllObjects = GetParentObject|SetParentObject|ChildObjects 00069 00070 LastOption = 0x1000000 00071 }; 00072 00080 void addObject(QObject* object, const QString& name = QString(), Options options = NoOption) { 00081 QString n = name.isNull() ? object->objectName() : name; 00082 m_objects.insert(n, object); 00083 if( options != NoOption ) 00084 m_options.insert(n, options); 00085 } 00086 00090 bool hasObject(const QString& name) const { 00091 return m_objects.contains(name); 00092 } 00093 00097 QObject* object(const QString& name) const { 00098 return m_objects.contains(name) ? m_objects.value(name) : 0; 00099 } 00100 00104 QHash< QString, QObject* > objects() const { 00105 return m_objects; 00106 } 00107 00111 Options objectOption(const QString& name) const { 00112 return m_options.contains(name) ? m_options.value(name) : NoOption; 00113 } 00114 00118 QHash< QString, Options > objectOptions() const { 00119 return m_options; 00120 } 00121 00122 private: 00123 QHash< QString, QObject* > m_objects; 00124 QHash< QString, Options > m_options; 00125 }; 00126 00127 } 00128 00129 #endif 00130