17
17
***************************************************************************/
18
18
/* $Id$ */
19
19
#include < iostream>
20
- #include < qstring.h>
21
- #include < qdir.h>
22
- #include < q3process.h>
23
- #include < q3socket.h>
20
+
21
+ #include < QString>
22
+ #include < QProcess>
23
+ #include < QTcpSocket>
24
+ #include < QTextStream>
25
+
24
26
#include " qgscontexthelp.h"
25
27
#include " qgsapplication.h"
26
- // Added by qt3to4:
27
- #include < QTextStream>
28
+
28
29
29
30
// Note: QGSCONTEXTHELP_REUSE must be defined (or not) in qgscontexthelp.h.
30
31
// The flag determines if an existing viewer process should be reused or
@@ -50,8 +51,8 @@ QgsContextHelp::QgsContextHelp(int contextId)
50
51
mProcess = start (contextId);
51
52
#ifdef QGSCONTEXTHELP_REUSE
52
53
// Create socket to communicate with process
53
- mSocket = new Q3Socket (this );
54
- connect (mProcess , SIGNAL (readyReadStdout ()), SLOT (readPort ()));
54
+ mSocket = new QTcpSocket (this );
55
+ connect (mProcess , SIGNAL (readyReadStandardoutput ()), SLOT (readPort ()));
55
56
#else
56
57
// Placeholder for new process if terminating and restarting
57
58
mNextProcess = NULL ;
@@ -69,22 +70,22 @@ QgsContextHelp::~QgsContextHelp()
69
70
delete mProcess ;
70
71
}
71
72
72
- Q3Process *QgsContextHelp::start (int contextId)
73
+ QProcess *QgsContextHelp::start (int contextId)
73
74
{
74
75
// Get the path to the help viewer
75
76
QString helpPath = QgsApplication::helpAppPath ();
76
77
#ifdef QGISDEBUG
77
78
std::cout << " Help path is " << helpPath.toLocal8Bit ().data () << std::endl;
78
79
#endif
79
80
80
- Q3Process *process = new Q3Process (helpPath);
81
81
QString arg1;
82
82
arg1.setNum (contextId);
83
- process-> addArgument (arg1) ;
84
- process->start ();
83
+ QProcess * process = new QProcess ;
84
+ process->start (helpPath, QStringList (arg1) );
85
85
86
86
// Delete this object if the process terminates
87
- connect (process, SIGNAL (processExited ()), SLOT (processExited ()));
87
+ connect (process, SIGNAL (finished (int , QProcess::ExitStatus)),
88
+ SLOT (processExited ()));
88
89
89
90
// Delete the process if the application quits
90
91
connect (qApp, SIGNAL (aboutToQuit ()), process, SLOT (tryTerminate ()));
@@ -96,10 +97,11 @@ void QgsContextHelp::readPort()
96
97
{
97
98
#ifdef QGSCONTEXTHELP_REUSE
98
99
// Get port and connect socket to process
99
- QString p = mProcess ->readLineStdout ();
100
+ QString p = mProcess ->readAllStandardOutput ();
100
101
Q_UINT16 port = p.toUShort ();
101
102
mSocket ->connectToHost (" localhost" , port);
102
- disconnect (mProcess , SIGNAL (readyReadStdout ()), this , SLOT (readPort ()));
103
+ disconnect (mProcess , SIGNAL (readyReadStandardOutput ()), this ,
104
+ SLOT (readPort ()));
103
105
#endif
104
106
}
105
107
@@ -120,7 +122,7 @@ void QgsContextHelp::showContext(int contextId)
120
122
// Start new help viewer process (asynchronous)
121
123
mNextProcess = start (contextId);
122
124
// Terminate existing help viewer process (asynchronous)
123
- mProcess ->tryTerminate ();
125
+ mProcess ->terminate ();
124
126
#endif
125
127
}
126
128
0 commit comments