~ubuntu-branches/ubuntu/natty/pyside/natty-proposed

« back to all changes in this revision

Viewing changes to PySide/QtGui/glue/qlayout_help_functions.h

  • Committer: Bazaar Package Importer
  • Author(s): Didier Raboud
  • Date: 2011-02-18 18:01:00 UTC
  • mfrom: (1.2.3 upstream) (6.1.6 experimental)
  • Revision ID: james.westby@ubuntu.com-20110218180100-vaczjij7g08fzfme
Tags: 1.0.0~rc1-1
* New 1.0.0~rc1 upstream release
  - Bump the B-D chain versions:
    + apiextractor to 0.10.0-2~
    + generatorrunner to 0.6.6
    + shiboken to 1.0.0~rc1
* Update patches to ~rc1.
* debian/watch: update to handle Release Candidates too.
* Bump XS-Python-Version to >= 2.6.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#ifndef QLAYOUT_HELP_FUNCTIONS
2
2
#define QLAYOUT_HELP_FUNCTIONS
3
3
 
4
 
void addLayoutOwnership(QLayout *layout, QLayoutItem *item);
 
4
void addLayoutOwnership(QLayout* layout, QLayoutItem* item);
5
5
 
6
 
inline QByteArray retrieveObjectName(PyObject *obj)
 
6
inline QByteArray retrieveObjectName(PyObject* obj)
7
7
{
8
8
    Shiboken::AutoDecRef objName(PyObject_Str(obj));
9
9
    return PyString_AsString(objName);
10
10
}
11
11
 
12
 
inline void addLayoutOwnership(QLayout *layout, QWidget *widget)
 
12
inline void addLayoutOwnership(QLayout* layout, QWidget* widget)
13
13
{
14
14
    //transfer ownership to parent widget
15
 
    QWidget *parent = layout->parentWidget();
 
15
    QWidget* parent = layout->parentWidget();
16
16
 
17
17
    if (!parent) {
18
18
        //keep the reference while the layout is orphan
19
19
        Shiboken::AutoDecRef pyParent(Shiboken::Converter<QWidget*>::toPython(layout));
20
20
        Shiboken::AutoDecRef pyChild(Shiboken::Converter<QWidget*>::toPython(widget));
21
 
        Shiboken::keepReference(reinterpret_cast<Shiboken::SbkBaseWrapper*>(pyParent.object()), retrieveObjectName(pyParent).data(), pyChild, true);
 
21
        Shiboken::Object::keepReference(reinterpret_cast<SbkObject*>(pyParent.object()), retrieveObjectName(pyParent).data(), pyChild, true);
22
22
    } else {
23
23
        Shiboken::AutoDecRef pyParent(Shiboken::Converter<QWidget*>::toPython(parent));
24
24
        Shiboken::AutoDecRef pyChild(Shiboken::Converter<QWidget*>::toPython(widget));
25
 
        Shiboken::setParent(pyParent, pyChild);
 
25
        Shiboken::Object::setParent(pyParent, pyChild);
26
26
    }
27
27
}
28
28
 
29
 
inline void addLayoutOwnership(QLayout *layout, QLayout *other)
 
29
inline void addLayoutOwnership(QLayout* layout, QLayout* other)
30
30
{
31
 
    //transfer all children widgetes from other to layout parent widget
32
 
    QWidget *parent = layout->parentWidget();
 
31
    //transfer all children widgets from other to layout parent widget
 
32
    QWidget* parent = layout->parentWidget();
33
33
    if (!parent) {
34
34
        //keep the reference while the layout is orphan
35
35
        Shiboken::AutoDecRef pyParent(Shiboken::Converter<QLayout*>::toPython(layout));
36
36
        Shiboken::AutoDecRef pyChild(Shiboken::Converter<QLayout*>::toPython(other));
37
 
        Shiboken::keepReference(reinterpret_cast<Shiboken::SbkBaseWrapper*>(pyParent.object()), retrieveObjectName(pyParent).data(), pyChild, true);
 
37
        Shiboken::Object::keepReference(reinterpret_cast<SbkObject*>(pyParent.object()), retrieveObjectName(pyParent).data(), pyChild, true);
38
38
        return;
39
39
    }
40
40
 
41
41
    for (int i=0, i_max=other->count(); i < i_max; i++) {
42
 
        addLayoutOwnership(layout, other->itemAt(i));
 
42
        QLayoutItem* item = other->itemAt(i);
 
43
        if (PyErr_Occurred() || !item)
 
44
            return;
 
45
 
 
46
        addLayoutOwnership(layout, item);
43
47
    }
44
48
 
45
49
    Shiboken::AutoDecRef pyParent(Shiboken::Converter<QLayout*>::toPython(layout));
46
50
    Shiboken::AutoDecRef pyChild(Shiboken::Converter<QLayout*>::toPython(other));
47
 
    Shiboken::setParent(pyParent, pyChild);
 
51
    Shiboken::Object::setParent(pyParent, pyChild);
48
52
 
49
53
}
50
54
 
51
 
inline void addLayoutOwnership(QLayout *layout, QLayoutItem *item)
 
55
inline void addLayoutOwnership(QLayout* layout, QLayoutItem* item)
52
56
{
53
 
    QWidget *w = item->widget();
 
57
    QWidget* w = item->widget();
54
58
    if (w)
55
59
        addLayoutOwnership(layout, w);
56
60
    else {
57
 
        QLayout *l = item->layout();
 
61
        QLayout* l = item->layout();
58
62
        if (l)
59
63
            addLayoutOwnership(layout, l);
60
64
    }
61
65
 
62
66
    Shiboken::AutoDecRef pyParent(Shiboken::Converter<QLayout*>::toPython(layout));
63
67
    Shiboken::AutoDecRef pyChild(Shiboken::Converter<QLayoutItem*>::toPython(item));
64
 
    Shiboken::setParent(pyParent, pyChild);
 
68
    Shiboken::Object::setParent(pyParent, pyChild);
65
69
}
66
70
 
67
71
#endif