Skip to content

Commit

Permalink
Replace Qt3 stuff with Qt4 stuff
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@4759 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
g_j_m committed Jan 28, 2006
1 parent 6438f43 commit 3417434
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 23 deletions.
34 changes: 18 additions & 16 deletions src/core/qgscontexthelp.cpp
Expand Up @@ -17,14 +17,15 @@
***************************************************************************/
/* $Id$ */
#include <iostream>
#include <qstring.h>
#include <qdir.h>
#include <q3process.h>
#include <q3socket.h>

#include <QString>
#include <QProcess>
#include <QTcpSocket>
#include <QTextStream>

#include "qgscontexthelp.h"
#include "qgsapplication.h"
//Added by qt3to4:
#include <QTextStream>


// Note: QGSCONTEXTHELP_REUSE must be defined (or not) in qgscontexthelp.h.
// The flag determines if an existing viewer process should be reused or
Expand All @@ -50,8 +51,8 @@ QgsContextHelp::QgsContextHelp(int contextId)
mProcess = start(contextId);
#ifdef QGSCONTEXTHELP_REUSE
// Create socket to communicate with process
mSocket = new Q3Socket(this);
connect(mProcess, SIGNAL(readyReadStdout()), SLOT(readPort()));
mSocket = new QTcpSocket(this);
connect(mProcess, SIGNAL(readyReadStandardoutput()), SLOT(readPort()));
#else
// Placeholder for new process if terminating and restarting
mNextProcess = NULL;
Expand All @@ -69,22 +70,22 @@ QgsContextHelp::~QgsContextHelp()
delete mProcess;
}

Q3Process *QgsContextHelp::start(int contextId)
QProcess *QgsContextHelp::start(int contextId)
{
// Get the path to the help viewer
QString helpPath = QgsApplication::helpAppPath();
#ifdef QGISDEBUG
std::cout << "Help path is " << helpPath.toLocal8Bit().data() << std::endl;
#endif

Q3Process *process = new Q3Process(helpPath);
QString arg1;
arg1.setNum(contextId);
process->addArgument(arg1);
process->start();
QProcess *process = new QProcess;
process->start(helpPath, QStringList(arg1));

// Delete this object if the process terminates
connect(process, SIGNAL(processExited()), SLOT(processExited()));
connect(process, SIGNAL(finished(int, QProcess::ExitStatus)),
SLOT(processExited()));

// Delete the process if the application quits
connect(qApp, SIGNAL(aboutToQuit()), process, SLOT(tryTerminate()));
Expand All @@ -96,10 +97,11 @@ void QgsContextHelp::readPort()
{
#ifdef QGSCONTEXTHELP_REUSE
// Get port and connect socket to process
QString p = mProcess->readLineStdout();
QString p = mProcess->readAllStandardOutput();
Q_UINT16 port = p.toUShort();
mSocket->connectToHost("localhost", port);
disconnect(mProcess, SIGNAL(readyReadStdout()), this, SLOT(readPort()));
disconnect(mProcess, SIGNAL(readyReadStandardOutput()), this,
SLOT(readPort()));
#endif
}

Expand All @@ -120,7 +122,7 @@ void QgsContextHelp::showContext(int contextId)
// Start new help viewer process (asynchronous)
mNextProcess = start(contextId);
// Terminate existing help viewer process (asynchronous)
mProcess->tryTerminate();
mProcess->terminate();
#endif
}

Expand Down
16 changes: 9 additions & 7 deletions src/core/qgscontexthelp.h
Expand Up @@ -19,9 +19,11 @@
/* $Id$ */
#ifndef QGSCONTEXTHELP_H
#define QGSCONTEXTHELP_H
#include <qobject.h>
class Q3Process;
class Q3Socket;
#include <QObject>

class QProcess;
class QTcpSocket;

#ifdef Q_OS_MACX
#define QGSCONTEXTHELP_REUSE 1
#endif
Expand Down Expand Up @@ -55,17 +57,17 @@ private slots:
//! Destructor
~QgsContextHelp();

Q3Process *start(int contextId);
QProcess *start(int contextId);
void showContext(int contextId);

static QgsContextHelp *gContextHelp; // Singleton instance
Q3Process *mProcess;
QProcess *mProcess;
#ifdef QGSCONTEXTHELP_REUSE
// Communications socket when reusing existing process
Q3Socket *mSocket;
QTcpSocket *mSocket;
#else
// Replacement process when terminating and restarting
Q3Process *mNextProcess;
QProcess *mNextProcess;
#endif
};
#endif //QGSCONTEXTHELP_H

0 comments on commit 3417434

Please sign in to comment.