/* Copyright © 2010 yan Verdavaine This file is part of QExtend. QExtend is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or any later version. QExtend is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with QExtend. If not, see . */ #include "connector.hpp" using namespace QExtend; Emitter::Emitter(const QObject * obj, const char * signal) :m_emitter(obj),m_signal(signal),m_type(Qt::AutoConnection){} Emitter::Emitter(const char * signal) :m_signal(signal),m_type(Qt::AutoConnection){} const QObject * Emitter::emitter() const {return m_emitter;} const char * Emitter::signal() const {return m_signal;} void Emitter::replaceObject(const QObject * obj) { m_emitter = obj; } void Emitter::replaceSignal( const char * signal) { m_signal = signal; } void Emitter::replaceEmitter(const QObject * obj, const char * signal) { m_emitter = obj; m_signal = signal; } const Emitter & Emitter::operator >> (const Receiver & r) const { if(r.receiver()!= 0 && ! m_emitter.isNull()) { QObject::connect(m_emitter , m_signal , r.receiver() , r.slot() , m_type ); } m_type = Qt::AutoConnection; return *this; } const Emitter & Emitter::operator >> (const Emitter & s) const { if( !s.m_emitter.isNull() && ! m_emitter.isNull()) { QObject::connect(m_emitter , m_signal , s.m_emitter , s.m_signal , m_type ); } m_type = Qt::AutoConnection; return *this; } const Emitter & Emitter::operator << (const Emitter & s) const { if( !s.m_emitter.isNull() && ! m_emitter.isNull()) { QObject::connect(s.m_emitter , s.m_signal , m_emitter , m_signal , m_type ); } m_type = Qt::AutoConnection; return *this; } const Emitter & Emitter::operator >> (Qt::ConnectionType type) const { m_type = type; return *this; } Receiver::Receiver(const QObject * obj, const char * slot) :m_receiver(obj),m_slot(slot),m_type(Qt::AutoConnection){} Receiver::Receiver(const char * slot) :m_slot(slot),m_type(Qt::AutoConnection){} const QObject * Receiver::receiver() const { return m_receiver; } const char * Receiver::slot() const { return m_slot; } void Receiver::replaceObject(const QObject * obj) { m_receiver = obj; } void Receiver::replaceSlot( const char * slot) { m_slot = slot; } void Receiver::replaceReceiver(const QObject * obj, const char * slot) { m_receiver = obj; m_slot = slot; } const Receiver & Receiver::operator << (const Emitter & s) const { if(s.emitter() && ! m_receiver.isNull() ) { QObject::connect( s.emitter(), s.signal() , m_receiver , m_slot , m_type); } m_type = Qt::AutoConnection; return *this; } const Receiver & Receiver::operator << (Qt::ConnectionType type) const { m_type = type; return *this; }