00001 /* 00002 Copyright © 2010 yan Verdavaine 00003 00004 This file is part of QExtend. 00005 00006 QExtend is free software: you can redistribute it and/or modify 00007 it under the terms of the GNU General Public License as published by 00008 the Free Software Foundation, either version 3 of the License, or 00009 any later version. 00010 00011 QExtend is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 GNU General Public License for more details. 00015 00016 You should have received a copy of the GNU General Public License 00017 along with QExtend. If not, see <http://www.gnu.org/licenses/>. 00018 */ 00019 00020 #ifndef QEXTEND_CONNECTOR_H 00021 #define QEXTEND_CONNECTOR_H 00022 #include "extendptr.hpp" 00023 #include <QObject> 00024 namespace QExtend 00025 { 00026 00027 class Receiver; 00028 00029 00030 00031 00033 00035 00041 class QEXTEND_EXPORT Emitter 00042 { 00043 ExtendPtr<const QObject,WEAK> m_emitter; 00044 const char * m_signal; 00045 mutable Qt::ConnectionType m_type; 00046 00047 public: 00048 00049 00051 00052 00054 00068 Emitter(const QObject * obj = 0, const char * signal = 0); 00069 00070 00071 00073 00074 00076 00088 Emitter(const char * signal ); 00089 00090 00091 00093 00094 00096 const QObject * emitter() const; 00097 00098 00099 00100 00101 00103 00104 00106 const char * signal() const; 00107 00108 00109 00110 00111 00113 00114 00116 00127 void replaceObject(const QObject * obj); 00128 00129 00130 00132 00133 00135 00146 void replaceSignal( const char * signal); 00147 00148 00149 00151 00152 00154 00168 void replaceEmitter(const QObject * obj, const char * signal); 00169 00170 00171 00173 00174 00176 00187 const Emitter & operator >> (const Receiver & r) const; 00188 00189 00190 00191 00193 00194 00196 00207 const Emitter & operator >> (const Emitter & e) const; 00208 00209 const Emitter & operator << (const Emitter & e) const; 00210 00211 00212 00213 00215 00216 00218 00229 const Emitter & operator >> (Qt::ConnectionType type) const ; 00230 00231 00232 00233 }; 00234 00235 00237 00239 00245 class QEXTEND_EXPORT Receiver 00246 { 00247 ExtendPtr<const QObject,WEAK> m_receiver; 00248 const char * m_slot; 00249 mutable Qt::ConnectionType m_type; 00250 00251 public: 00252 00253 00255 00256 00258 00272 Receiver(const QObject * obj = 0, const char * slot = 0); 00273 00274 00275 00277 00278 00280 00292 Receiver( const char * slot ); 00293 00294 00295 00297 00298 00300 const QObject * receiver() const; 00301 00302 00303 00305 00306 00308 const char * slot() const; 00309 00310 00311 00313 00314 00316 00327 void replaceObject(const QObject * obj); 00328 00329 00330 00332 00333 00335 00346 void replaceSlot( const char * slot); 00347 00348 00349 00350 00352 00353 00355 00369 void replaceReceiver(const QObject * obj, const char * slot); 00370 00371 00372 00374 00375 00377 00388 const Receiver & operator << (const Emitter & e) const; 00389 00390 00391 00393 00394 00396 00407 const Receiver & operator << (Qt::ConnectionType type) const; 00408 00409 }; 00410 00411 00412 00414 00416 00428 #define EMITTER(x,y) Emitter(x,SIGNAL(y)) 00429 00430 00432 00434 00446 #define RECEIVER(x,y) Receiver(x,SLOT(y)) 00447 } 00448 #endif
© 2000-2025 - www.developpez.com