itom  4.1.0
widgetWrapper.h
1 /* ********************************************************************
2  itom software
3  URL: http://www.uni-stuttgart.de/ito
4  Copyright (C) 2020, Institut fuer Technische Optik (ITO),
5  Universitaet Stuttgart, Germany
6 
7  This file is part of itom.
8 
9  itom is free software; you can redistribute it and/or modify it
10  under the terms of the GNU Library General Public Licence as published by
11  the Free Software Foundation; either version 2 of the Licence, or (at
12  your option) any later version.
13 
14  itom is distributed in the hope that it will be useful, but
15  WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library
17  General Public Licence for more details.
18 
19  You should have received a copy of the GNU Library General Public License
20  along with itom. If not, see <http://www.gnu.org/licenses/>.
21 *********************************************************************** */
22 
23 #ifndef WIDGETWRAPPER_H
24 #define WIDGETWRAPPER_H
25 
26 #include "../python/pythonItomMetaObject.h"
27 
28 #include <qobject.h>
29 #include <qhash.h>
30 #include <qmetaobject.h>
31 #include "../global.h"
32 
33 // a bunch of forward declarations
34 class QListWidget;
35 class QComboBox;
36 class QTabWidget;
37 class QTableView;
38 class QSplitter;
39 class QStatusBar;
40 class QMainWindow;
41 class QWidget;
42 class QTableWidget;
43 class QToolBar;
44 class QAction;
45 class QLayout;
46 class QFormLayout;
47 class QGridLayout;
48 class QBoxLayout;
49 
50 namespace ito
51 {
52 
53 class UiOrganizer; // forward declaration
54 
56 {
57 public:
58  WidgetWrapper(UiOrganizer *uiOrganizer); //constructor
59  ~WidgetWrapper(); //destructor
60 
61  MethodDescriptionList getMethodList(QObject *object);
62  ito::RetVal call(QObject *object, int methodIndex, void **_a);
63 
64  QMetaProperty fakeProperty(const QObject *baseObject, const QString &fakePropertyName, QObject **destinationObject);
65 
66 private:
67  void initMethodHash();
68  MethodDescription buildMethodDescription(QByteArray signature, QString retType, int methodIndex, bool &ok);
69 
70  ito::RetVal callObject(QObject *object, int methodIndex, void **_a);
71  ito::RetVal callListWidget(QListWidget *listWidget, int methodIndex, void **_a);
72  ito::RetVal callComboBox(QComboBox *comboBox, int methodIndex, void **_a);
73  ito::RetVal callTabWidget(QTabWidget *tabWidget, int methodIndex, void **_a);
74  ito::RetVal callTableView(QTableView *tableView, int methodIndex, void **_a);
75  ito::RetVal callSplitter(QSplitter *splitter, int methodIndex, void **_a);
76  ito::RetVal callStatusBar(QStatusBar *statusBar, int methodIndex, void **_a);
77  ito::RetVal callMainWindow(QMainWindow *mainWindow, int methodIndex, void **_a);
78  ito::RetVal callWidget(QWidget *widget, int methodIndex, void **_a);
79  ito::RetVal callTableWidget(QTableWidget *tableWidget, int methodIndex, void **_a);
80  ito::RetVal callToolBar(QToolBar *toolbar, int methodIndex, void **_a);
81  ito::RetVal callAction(QAction *action, int methodIndex, void **_a);
82  ito::RetVal callLayout(QLayout *layout, int methodIndex, void **_a);
83  ito::RetVal callFormLayout(QFormLayout *layout, int methodIndex, void **_a);
84  ito::RetVal callGridLayout(QGridLayout *layout, int methodIndex, void **_a);
85  ito::RetVal callBoxLayout(QBoxLayout *layout, int methodIndex, void **_a);
86 
87  QHash<QString, MethodDescriptionList> m_methodHash;
91  UiOrganizer *m_pUiOrganizer;
92 };
93 
94 } //end namespace ito
95 
96 #endif
97 
The UiOrganizer is started as singleton instance within itom and organizes all main windows...
Definition: uiOrganizer.h:306
int m_methodIndexNotFound
Definition: widgetWrapper.h:89
MethodDescription buildMethodDescription(QByteArray signature, QString retType, int methodIndex, bool &ok)
creates an instance of MethodDescription which contains all necessary information in order to call th...
Definition: widgetWrapper.cpp:299
Class for managing status values (like errors or warning)
Definition: retVal.h:54
~WidgetWrapper()
destructor
Definition: widgetWrapper.cpp:79
Definition: apiFunctionsGraph.cpp:39
Small wrapper class with all necessary information for any method, signal or slot of class which shou...
Definition: pythonItomMetaObject.h:63
MethodDescriptionList getMethodList(QObject *object)
returns a list of MethodDescription, which contains all wrapped methods of the given object and all i...
Definition: widgetWrapper.cpp:268
One instance of this class acts as wrapper for several import public methods of classes, derived from QObject, which should be made available by the call-method in python.
Definition: widgetWrapper.h:55
WidgetWrapper(UiOrganizer *uiOrganizer)
constructor
Definition: widgetWrapper.cpp:69
QHash< QString, MethodDescriptionList > m_methodHash
Definition: widgetWrapper.h:87
QMetaProperty fakeProperty(const QObject *baseObject, const QString &fakePropertyName, QObject **destinationObject)
Method is able to handle unexisting properties and map them to existing ones (compatibility to QtDesi...
Definition: widgetWrapper.cpp:2000
ito::RetVal call(QObject *object, int methodIndex, void **_a)
call method which calls a wrapped method of any class derived from QObject at runtime. This call is for exampled executed by UiOrganizer::callMethod.
Definition: widgetWrapper.cpp:377
void initMethodHash()
initializes the hash table containing information about all methods which should be wrapped...
Definition: widgetWrapper.cpp:101
bool m_initialized
Definition: widgetWrapper.h:88