GammaRay  2.2.0
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Macros Pages
propertycontroller.h
1 /*
2  propertycontroller.h
3 
4  This file is part of GammaRay, the Qt application inspection and
5  manipulation tool.
6 
7  Copyright (C) 2013-2014 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com
8  Author: Volker Krause <volker.krause@kdab.com>
9 
10  This program is free software; you can redistribute it and/or modify
11  it under the terms of the GNU General Public License as published by
12  the Free Software Foundation, either version 2 of the License, or
13  (at your option) any later version.
14 
15  This program is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  GNU General Public License for more details.
19 
20  You should have received a copy of the GNU General Public License
21  along with this program. If not, see <http://www.gnu.org/licenses/>.
22 */
23 
24 #ifndef GAMMARAY_PROPERTYCONTROLLER_H
25 #define GAMMARAY_PROPERTYCONTROLLER_H
26 
27 #include "gammaray_core_export.h"
28 #include "propertycontrollerextension.h"
29 
30 #include <common/propertycontrollerinterface.h>
31 
32 #include <QPointer>
33 #include <QVector>
34 
35 class QAbstractItemModel;
36 
37 namespace GammaRay {
38 
39 class ConnectionFilterProxyModel;
40 
42 class GAMMARAY_CORE_EXPORT PropertyController : public PropertyControllerInterface
43 {
44  Q_OBJECT
46 public:
47  explicit PropertyController(const QString &baseName, QObject *parent);
49 
50  const QString &objectBaseName();
51 
52  void setObject(QObject *object);
53  void setObject(void *object, const QString &className);
54  void setMetaObject(const QMetaObject *metaObject);
55 
56  void registerModel(QAbstractItemModel *model, const QString &nameSuffix);
57 
58  template<typename T>
59  static void registerExtension()
60  {
61  PropertyControllerExtensionFactoryBase *factory = new PropertyControllerExtensionFactory<T>();
62  s_extensionFactories << factory;
63  foreach (PropertyController *instance, s_instances)
64  instance->loadExtension(factory);
65  }
66 
67 private slots:
68  void objectDestroyed();
69 
70 private:
71  void loadExtension(PropertyControllerExtensionFactoryBase *factory);
72 
73 private:
74  QString m_objectBaseName;
75 
76  QPointer<QObject> m_object;
77  QVector<PropertyControllerExtension*> m_extensions;
78 
79  static QVector<PropertyControllerExtensionFactoryBase*> s_extensionFactories;
80  static QVector<PropertyController*> s_instances;
81 };
82 
83 }
84 
85 #endif // GAMMARAY_PROPERTYCONTROLLER_H

Klarälvdalens Datakonsult AB (KDAB)
"The Qt Experts"
http://www.kdab.com/
GammaRay
Qt-application inspection and manipulation tool
http://www.kdab.com/kdab-products/gammaray/