Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
ElmerCSC
GitHub Repository: ElmerCSC/elmerfem
Path: blob/devel/ElmerGUI/PythonQt/src/PythonQtStdDecorators.cpp
3206 views
1
/*
2
*
3
* Copyright (C) 2006 MeVis Research GmbH All Rights Reserved.
4
*
5
* This library is free software; you can redistribute it and/or
6
* modify it under the terms of the GNU Lesser General Public
7
* License as published by the Free Software Foundation; either
8
* version 2.1 of the License, or (at your option) any later version.
9
*
10
* This library is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
* Lesser General Public License for more details.
14
*
15
* Further, this software is distributed without any warranty that it is
16
* free of the rightful claim of any third person regarding infringement
17
* or the like. Any license provided herein, whether implied or
18
* otherwise, applies only to this software file. Patent licenses, if
19
* any, provided herein do not apply to combinations of this program with
20
* other software, or any other product whatsoever.
21
*
22
* You should have received a copy of the GNU Lesser General Public
23
* License along with this library; if not, write to the Free Software
24
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25
*
26
* Contact information: MeVis Research GmbH, Universitaetsallee 29,
27
* 28359 Bremen, Germany or:
28
*
29
* http://www.mevis.de
30
*
31
*/
32
33
//----------------------------------------------------------------------------------
34
/*!
35
// \file PythonQtStdDecorators.cpp
36
// \author Florian Link
37
// \author Last changed by $Author: florian $
38
// \date 2007-04
39
*/
40
//----------------------------------------------------------------------------------
41
42
#include "PythonQtStdDecorators.h"
43
#include "PythonQt.h"
44
#include "PythonQtClassInfo.h"
45
46
47
bool PythonQtStdDecorators::connect(QObject* sender, const QByteArray& signal, PyObject* callable)
48
{
49
QByteArray signalTmp("2");
50
signalTmp += signal;
51
if (sender) {
52
return PythonQt::self()->addSignalHandler(sender, signalTmp, callable);
53
} else {
54
return false;
55
}
56
}
57
58
bool PythonQtStdDecorators::connect(QObject* sender, const QByteArray& signal, QObject* receiver, const QByteArray& slot)
59
{
60
bool r = false;
61
if (sender && receiver) {
62
QByteArray signalTmp("2");
63
signalTmp += signal;
64
QByteArray slotTmp("1");
65
slotTmp += slot;
66
if (receiver) {
67
r = QObject::connect(sender, signalTmp, receiver, slotTmp);
68
}
69
}
70
return r;
71
}
72
73
bool PythonQtStdDecorators::disconnect(QObject* sender, const QByteArray& signal, PyObject* callable)
74
{
75
QByteArray signalTmp("2");
76
signalTmp += signal;
77
if (sender) {
78
return PythonQt::self()->removeSignalHandler(sender, signalTmp, callable);
79
} else {
80
return false;
81
}
82
}
83
84
bool PythonQtStdDecorators::disconnect(QObject* sender, const QByteArray& signal, QObject* receiver, const QByteArray& slot)
85
{
86
bool r = false;
87
if (sender && receiver) {
88
QByteArray signalTmp("2");
89
signalTmp += signal;
90
QByteArray slotTmp("1");
91
slotTmp += slot;
92
if (receiver) {
93
r = QObject::disconnect(sender, signalTmp, receiver, slotTmp);
94
}
95
}
96
return r;
97
}
98
99
QObject* PythonQtStdDecorators::parent(QObject* o) {
100
return o->parent();
101
}
102
103
void PythonQtStdDecorators::setParent(QObject* o, QObject* parent)
104
{
105
o->setParent(parent);
106
}
107
108
QVariantList PythonQtStdDecorators::children(QObject* o)
109
{
110
QVariantList v;
111
QListIterator<QObject*> it(o->children());
112
while (it.hasNext()) {
113
v << qVariantFromValue(it.next());
114
}
115
return v;
116
}
117
118