@@ -404,13 +404,10 void PythonQtClassInfo::listDecoratorSlotsFromDecoratorProvider(QStringList& lis | |||||
404 | } |
|
404 | } | |
405 | } |
|
405 | } | |
406 |
|
406 | |||
407 |
QStringList PythonQtClassInfo:: |
|
407 | QStringList PythonQtClassInfo::propertyList() | |
408 | { |
|
408 | { | |
409 | decorator(); |
|
|||
410 |
|
||||
411 | QStringList l; |
|
409 | QStringList l; | |
412 | QString h; |
|
410 | if (_isQObject && _meta) { | |
413 | if (_isQObject && _meta && !metaOnly) { |
|
|||
414 | int i; |
|
411 | int i; | |
415 | int numProperties = _meta->propertyCount(); |
|
412 | int numProperties = _meta->propertyCount(); | |
416 | for (i = 0; i < numProperties; i++) { |
|
413 | for (i = 0; i < numProperties; i++) { | |
@@ -418,6 +415,18 QStringList PythonQtClassInfo::memberList(bool metaOnly) | |||||
418 | l << QString(p.name()); |
|
415 | l << QString(p.name()); | |
419 | } |
|
416 | } | |
420 | } |
|
417 | } | |
|
418 | return l; | |||
|
419 | } | |||
|
420 | ||||
|
421 | QStringList PythonQtClassInfo::memberList(bool metaOnly) | |||
|
422 | { | |||
|
423 | decorator(); | |||
|
424 | ||||
|
425 | QStringList l; | |||
|
426 | QString h; | |||
|
427 | if (_isQObject && _meta && !metaOnly) { | |||
|
428 | l = propertyList(); | |||
|
429 | } | |||
421 |
|
430 | |||
422 | // normal slots of QObject (or wrapper QObject) |
|
431 | // normal slots of QObject (or wrapper QObject) | |
423 | if (!metaOnly && _meta) { |
|
432 | if (!metaOnly && _meta) { |
@@ -148,6 +148,9 public: | |||||
148 | //! get help string for the metaobject |
|
148 | //! get help string for the metaobject | |
149 | QString help(); |
|
149 | QString help(); | |
150 |
|
150 | |||
|
151 | //! get list of all properties (on QObjects only, otherwise the list is empty) | |||
|
152 | QStringList propertyList(); | |||
|
153 | ||||
151 | //! get list of all members |
|
154 | //! get list of all members | |
152 | QStringList memberList(bool metaOnly = false); |
|
155 | QStringList memberList(bool metaOnly = false); | |
153 |
|
156 |
@@ -225,17 +225,21 static PyObject *PythonQtInstanceWrapper_getattro(PyObject *obj,PyObject *name) | |||||
225 | } |
|
225 | } | |
226 |
|
226 | |||
227 | if (qstrcmp(attributeName, "__dict__")==0) { |
|
227 | if (qstrcmp(attributeName, "__dict__")==0) { | |
228 | QStringList l = wrapper->classInfo()->memberList(false); |
|
228 | PyObject* dict = PyBaseObject_Type.tp_getattro(obj, name); | |
229 |
|
|
229 | dict = PyDict_Copy(dict); | |
|
230 | ||||
|
231 | // only the properties are missing, the rest is already available from | |||
|
232 | // PythonQtClassWrapper... | |||
|
233 | QStringList l = wrapper->classInfo()->propertyList(); | |||
230 | foreach (QString name, l) { |
|
234 | foreach (QString name, l) { | |
231 | PyObject* o = PyObject_GetAttrString(obj, name.toLatin1().data()); |
|
235 | PyObject* o = PyObject_GetAttrString(obj, name.toLatin1().data()); | |
|
236 | if (o) { | |||
232 | PyDict_SetItemString(dict, name.toLatin1().data(), o); |
|
237 | PyDict_SetItemString(dict, name.toLatin1().data(), o); | |
233 | Py_DECREF(o); |
|
238 | Py_DECREF(o); | |
|
239 | } else { | |||
|
240 | std::cerr << "PythonQtInstanceWrapper: something is wrong, could not get attribute " << name.toLatin1().data(); | |||
|
241 | } | |||
234 | } |
|
242 | } | |
235 | // TODO xxx: |
|
|||
236 | // this does include python member methods, but not attributes, from where can we get |
|
|||
237 | // the correct dict with the attributes of the derive |
|
|||
238 |
|
||||
239 | // Note: we do not put children into the dict, is would look confusing?! |
|
243 | // Note: we do not put children into the dict, is would look confusing?! | |
240 | return dict; |
|
244 | return dict; | |
241 | } |
|
245 | } |
General Comments 0
You need to be logged in to leave comments.
Login now