QGIS/helpviewer/qgshelpserver.cpp
gsherman cd64a08047 Added helpviewer subdir to the top-level Makefile.am
Changes to helpviewer classes to allow compilation under Qt 4.0.1

Works on Linux; untested on other platforms.


git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@4252 c8812cc2-4d05-0410-92ff-de0c093fc19c
2005-11-21 05:51:31 +00:00

66 lines
2.3 KiB
C++

/***************************************************************************
qgshelpserver.cpp
Receive help context numbers from client process for help viewer
-------------------
begin : 2005-07-07
copyright : (C) 2005 by Tom Elwertowski
email : telwertowski at comcast.net
***************************************************************************/
/***************************************************************************
* *
* This program 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 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
/* $Id$ */
#include "qgshelpserver.h"
// The communications technique used here has been adapted from Qt Assistant.
// See qt/tools/assistant/ main.cpp and lib/qassistantclient.cpp (Qt 3.3.4).
QgsHelpContextServer::QgsHelpContextServer(QObject *parent) :
Q3ServerSocket(0x7f000001, 0, parent)
{
// Superclass listens for localhost connection
}
QgsHelpContextServer::~QgsHelpContextServer()
{
// Socket is automatically deleted here because it is a QQbject child
}
void QgsHelpContextServer::newConnection(int socket)
{
// Create socket in response to new connection
QgsHelpContextSocket *helpSocket = new QgsHelpContextSocket(socket, this);
// Pass context from socket upwards
connect(helpSocket, SIGNAL(setContext(const QString&)),
SIGNAL(setContext(const QString&)));
}
QgsHelpContextSocket::QgsHelpContextSocket(int socket, QObject *parent) :
Q3Socket(parent, 0)
{
connect(this, SIGNAL(readyRead()), SLOT(readClient()));
setSocket(socket);
}
QgsHelpContextSocket::~QgsHelpContextSocket()
{
}
void QgsHelpContextSocket::readClient()
{
// Read context numbers (one per line) and pass upwards
QString contextId;
while ( canReadLine() )
{
contextId = readLine();
contextId.remove('\n');
emit setContext(contextId);
}
}