KTutorial
0.5.1
|
00001 /*************************************************************************** 00002 * Copyright (C) 2010 by Daniel Calviño Sánchez <danxuliu@gmail.com> * 00003 * Copyright (C) 2011 by Daniel Calviño Sánchez <danxuliu@gmail.com> * 00004 * Copyright (C) 2012 by Daniel Calviño Sánchez <danxuliu@gmail.com> * 00005 * * 00006 * This program is free software; you can redistribute it and/or modify * 00007 * it under the terms of the GNU General Public License as published by * 00008 * the Free Software Foundation; either version 2 of the License, or * 00009 * (at your option) any later version. * 00010 * * 00011 * This program is distributed in the hope that it will be useful, * 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00014 * GNU General Public License for more details. * 00015 * * 00016 * You should have received a copy of the GNU General Public License * 00017 * along with this program; If not, see <http://www.gnu.org/licenses/>. * 00018 ***************************************************************************/ 00019 00020 #ifndef KTUTORIAL_EDITORSUPPORT_OBJECTREGISTER_H 00021 #define KTUTORIAL_EDITORSUPPORT_OBJECTREGISTER_H 00022 00023 #include <QHash> 00024 #include <QObject> 00025 00026 namespace ktutorial { 00027 namespace editorsupport { 00028 00043 class ObjectRegister: public QObject { 00044 Q_OBJECT 00045 public: 00046 00052 explicit ObjectRegister(QObject* parent = 0); 00053 00060 int idForObject(QObject* object); 00061 00068 QObject* objectForId(int objectId); 00069 00076 const QMetaObject* metaObjectForClassName(const QString& className) const; 00077 00081 void clear(); 00082 00088 void registerMetaObject(const QMetaObject* metaObject); 00089 00090 private: 00091 00095 int mNextId; 00096 00100 QHash<QObject*, int> mRegisteredIds; 00101 00105 QHash<int, QObject*> mRegisteredObjects; 00106 00110 QHash<QString, const QMetaObject*> mRegisteredMetaObjects; 00111 00112 private Q_SLOTS: 00113 00119 void deregister(QObject* object); 00120 00121 }; 00122 00123 } 00124 } 00125 00126 #endif