Path: blob/devel/ElmerGUI/PythonQt/src/PythonQtStdDecorators.cpp
3206 views
/*1*2* Copyright (C) 2006 MeVis Research GmbH All Rights Reserved.3*4* This library is free software; you can redistribute it and/or5* modify it under the terms of the GNU Lesser General Public6* License as published by the Free Software Foundation; either7* version 2.1 of the License, or (at your option) any later version.8*9* This library is distributed in the hope that it will be useful,10* but WITHOUT ANY WARRANTY; without even the implied warranty of11* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU12* Lesser General Public License for more details.13*14* Further, this software is distributed without any warranty that it is15* free of the rightful claim of any third person regarding infringement16* or the like. Any license provided herein, whether implied or17* otherwise, applies only to this software file. Patent licenses, if18* any, provided herein do not apply to combinations of this program with19* other software, or any other product whatsoever.20*21* You should have received a copy of the GNU Lesser General Public22* License along with this library; if not, write to the Free Software23* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA24*25* Contact information: MeVis Research GmbH, Universitaetsallee 29,26* 28359 Bremen, Germany or:27*28* http://www.mevis.de29*30*/3132//----------------------------------------------------------------------------------33/*!34// \file PythonQtStdDecorators.cpp35// \author Florian Link36// \author Last changed by $Author: florian $37// \date 2007-0438*/39//----------------------------------------------------------------------------------4041#include "PythonQtStdDecorators.h"42#include "PythonQt.h"43#include "PythonQtClassInfo.h"444546bool PythonQtStdDecorators::connect(QObject* sender, const QByteArray& signal, PyObject* callable)47{48QByteArray signalTmp("2");49signalTmp += signal;50if (sender) {51return PythonQt::self()->addSignalHandler(sender, signalTmp, callable);52} else {53return false;54}55}5657bool PythonQtStdDecorators::connect(QObject* sender, const QByteArray& signal, QObject* receiver, const QByteArray& slot)58{59bool r = false;60if (sender && receiver) {61QByteArray signalTmp("2");62signalTmp += signal;63QByteArray slotTmp("1");64slotTmp += slot;65if (receiver) {66r = QObject::connect(sender, signalTmp, receiver, slotTmp);67}68}69return r;70}7172bool PythonQtStdDecorators::disconnect(QObject* sender, const QByteArray& signal, PyObject* callable)73{74QByteArray signalTmp("2");75signalTmp += signal;76if (sender) {77return PythonQt::self()->removeSignalHandler(sender, signalTmp, callable);78} else {79return false;80}81}8283bool PythonQtStdDecorators::disconnect(QObject* sender, const QByteArray& signal, QObject* receiver, const QByteArray& slot)84{85bool r = false;86if (sender && receiver) {87QByteArray signalTmp("2");88signalTmp += signal;89QByteArray slotTmp("1");90slotTmp += slot;91if (receiver) {92r = QObject::disconnect(sender, signalTmp, receiver, slotTmp);93}94}95return r;96}9798QObject* PythonQtStdDecorators::parent(QObject* o) {99return o->parent();100}101102void PythonQtStdDecorators::setParent(QObject* o, QObject* parent)103{104o->setParent(parent);105}106107QVariantList PythonQtStdDecorators::children(QObject* o)108{109QVariantList v;110QListIterator<QObject*> it(o->children());111while (it.hasNext()) {112v << qVariantFromValue(it.next());113}114return v;115}116117118