Source Code (Use browser search to find items of interest.)
Class Index
qt'QSocketNotifier (./qt-2.1.0/src/kernel/qsocketnotifier.h:34)
class Q_EXPORT QSocketNotifier : public QObject
{
Q_OBJECT
public:
enum Type { Read, Write, Exception };
QSocketNotifier( int socket, Type, QObject *parent=0, const char *name=0 );
~QSocketNotifier();
int socket() const;
Type type() const;
bool isEnabled() const;
virtual void setEnabled( bool );
signals:
void activated( int socket );
protected:
bool event( QEvent * );
private:
int sockfd;
Type sntype;
bool snenabled;
private: // Disabled copy constructor and operator=
#if defined(Q_DISABLE_COPY)
QSocketNotifier( const QSocketNotifier & );
QSocketNotifier &operator=( const QSocketNotifier & );
#endif
};
inline int QSocketNotifier::socket() const
{ return sockfd; }
inline QSocketNotifier::Type QSocketNotifier::type() const
{ return sntype; }
inline bool QSocketNotifier::isEnabled() const
{ return snenabled; }
qt'QSocketNotifier::isEnabled() (./qt-2.1.0/include/qsocketnotifier.h:74)
inline bool QSocketNotifier::isEnabled() const
{ return snenabled; }
qt'QSocketNotifier::QSocketNotifier() (./qt-2.1.0/src/kernel/qsocketnotifier.cpp:141)
QSocketNotifier::QSocketNotifier( int socket, Type type, QObject *parent,
const char *name )
: QObject( parent, name )
{
#if defined(CHECK_RANGE)
if ( socket < 0 )
qWarning( "QSocketNotifier: Invalid socket specified" );
#endif
sockfd = socket;
sntype = type;
snenabled = TRUE;
qt_set_socket_handler( sockfd, sntype, this, TRUE );
}
/*!
Destructs the socket notifier.
*/
qt'QSocketNotifier::~QSocketNotifier() (./qt-2.1.0/src/kernel/qsocketnotifier.cpp:159)
QSocketNotifier::~QSocketNotifier()
{
setEnabled( FALSE );
}
/*!
\fn void QSocketNotifier::activated( int socket )
This signal is emitted under certain conditions, specified by the
notifier \link type() type\endlink:
<ol>
<li> \c QSocketNotifier::Read: There is data to be read (socket read event).
<li> \c QSocketNotifier::Write: Data can be written (socket write event).
<li> \c QSocketNofifier::Exception: An exception has occured (socket
exception event).
</ol>
The \e socket argument is the \link socket() socket\endlink identifier.
\sa type(), socket()
*/
/*!
\fn int QSocketNotifier::socket() const
Returns the socket identifier specified to the constructor.
\sa type()
*/
/*!
\fn Type QSocketNotifier::type() const
Returns the socket event type specified to the constructor;
\c QSocketNotifier::Read, \c QSocketNotifier::Write or
\c QSocketNotifier::Exception.
\sa socket()
*/
/*!
\fn bool QSocketNotifier::isEnabled() const
Returns TRUE if the notifier is enabled, or FALSE if it is disabled.
\sa setEnabled()
*/
/*!
Enables the notifier if \e enable is TRUE, or disables it if \e enable is
FALSE.
The notifier is by default enabled.
If the notifier is enabled, it emits the activated() signal whenever a
socket event corresponding to its \link type() type\endlink occurs. If
it is disabled, it ignores socket events (the same effect as not creating
the socket notifier).
Write notifiers should normally be disabled immediately after the
activated() signal has been emitted; see discussion of write
notifiers in the class description above.
\sa isEnabled(), activated()
*/
qt'QSocketNotifier::setEnabled() (./qt-2.1.0/src/kernel/qsocketnotifier.cpp:222)
void QSocketNotifier::setEnabled( bool enable )
{
if ( sockfd < 0 )
return;
if ( snenabled == enable ) // no change
return;
snenabled = enable;
qt_set_socket_handler( sockfd, sntype, this, snenabled );
}
/*!\reimp
*/
qt'QSocketNotifier::event() (./qt-2.1.0/src/kernel/qsocketnotifier.cpp:235)
bool QSocketNotifier::event( QEvent *e )
{
// Emits the activated() signal when a \c QEvent::SockAct is
// received.
QObject::event( e ); // will activate filters
if ( e->type() == QEvent::SockAct ) {
emit activated( sockfd );
return TRUE;
}
return FALSE;
}
qt'QSocketNotifier::isEnabled() (./qt-2.1.0/src/kernel/qsocketnotifier.h:74)
inline bool QSocketNotifier::isEnabled() const
{ return snenabled; }