Skip to content

Commit 2361922

Browse files
committedApr 23, 2016
Use QT_NO_KEYWORDS
Allow to mix with libraries defining their own signals and slots.
1 parent f93442f commit 2361922

10 files changed

+25
-24
lines changed
 

‎CMakeLists.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ set(CMAKE_PREFIX_PATH
6363
"${CMAKE_PREFIX_PATH}"
6464
)
6565

66+
add_definitions(-DQT_NO_KEYWORDS)
6667
find_package(Qt5 REQUIRED Core Network)
6768
set(Qt5_INCLUDES ${Qt5_INCLUDES} ${Qt5Core_INCLUDE_DIRS} ${Qt5Network_INCLUDE_DIRS})
6869
set(Qt5_LIBRARIES ${Qt5_LIBRARIES} ${Qt5Core_LIBRARIES} ${Qt5Network_LIBRARIES} )
@@ -107,6 +108,6 @@ SET(CPACK_STRIP_FILES "")
107108
SET(CPACK_SOURCE_STRIP_FILES "")
108109
# set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
109110
set(CPACK_GENERATOR ${SPECIFIC_SYSTEM_PREFERED_CPACK_GENERATOR})
110-
set(CPACK_RPM_PACKAGE_REQUIRES "qt5 >= 5.2")
111+
# set(CPACK_RPM_PACKAGE_REQUIRES "qt5 >= 5.2")
111112

112113
INCLUDE(CPack)

‎examples/bodydata/bodydata.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class BodyData : public QObject
1212
public:
1313
BodyData();
1414

15-
private slots:
15+
private Q_SLOTS:
1616
void handleRequest(QHttpRequest *req, QHttpResponse *resp);
1717
};
1818

@@ -26,10 +26,10 @@ class Responder : public QObject
2626
Responder(QHttpRequest *req, QHttpResponse *resp);
2727
~Responder();
2828

29-
signals:
29+
Q_SIGNALS:
3030
void done();
3131

32-
private slots:
32+
private Q_SLOTS:
3333
void accumulate(const QByteArray &data);
3434
void reply();
3535

‎examples/greeting/greeting.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ class Greeting : public QObject
1111
public:
1212
Greeting();
1313

14-
private slots:
14+
private Q_SLOTS:
1515
void handleRequest(QHttpRequest *req, QHttpResponse *resp);
1616
};

‎examples/helloworld/helloworld.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ class HelloWorld : public QObject
1111
public:
1212
HelloWorld();
1313

14-
private slots:
14+
private Q_SLOTS:
1515
void handleRequest(QHttpRequest *req, QHttpResponse *resp);
1616
};

‎src/qhttpconnection.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ void QHttpConnection::socketDisconnected()
8080
return;
8181

8282
m_request->setSuccessful(false);
83-
emit m_request->end();
83+
Q_EMIT m_request->end();
8484
}
8585
}
8686

@@ -94,7 +94,7 @@ void QHttpConnection::updateWriteCount(qint64 count)
9494
{
9595
m_transmitLen = 0;
9696
m_transmitPos = 0;
97-
emit allBytesWritten();
97+
Q_EMIT allBytesWritten();
9898
}
9999
}
100100

@@ -219,7 +219,7 @@ int QHttpConnection::HeadersComplete(http_parser *parser)
219219
connect(response, SIGNAL(done()), theConnection, SLOT(responseDone()));
220220

221221
// we are good to go!
222-
emit theConnection->newRequest(theConnection->m_request, response);
222+
Q_EMIT theConnection->newRequest(theConnection->m_request, response);
223223
return 0;
224224
}
225225

@@ -230,7 +230,7 @@ int QHttpConnection::MessageComplete(http_parser *parser)
230230
Q_ASSERT(theConnection->m_request);
231231

232232
theConnection->m_request->setSuccessful(true);
233-
emit theConnection->m_request->end();
233+
Q_EMIT theConnection->m_request->end();
234234
return 0;
235235
}
236236

@@ -282,7 +282,7 @@ int QHttpConnection::Body(http_parser *parser, const char *at, size_t length)
282282
QHttpConnection *theConnection = static_cast<QHttpConnection *>(parser->data);
283283
Q_ASSERT(theConnection->m_request);
284284

285-
emit theConnection->m_request->data(QByteArray(at, length));
285+
Q_EMIT theConnection->m_request->data(QByteArray(at, length));
286286
return 0;
287287
}
288288

‎src/qhttpconnection.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,11 @@ class QHTTPSERVER_API QHttpConnection : public QObject
4141
void write(const QByteArray &data);
4242
void flush();
4343

44-
signals:
44+
Q_SIGNALS:
4545
void newRequest(QHttpRequest *, QHttpResponse *);
4646
void allBytesWritten();
4747

48-
private slots:
48+
private Q_SLOTS:
4949
void parseRequest();
5050
void responseDone();
5151
void socketDisconnected();

‎src/qhttprequest.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ class QHTTPSERVER_API QHttpRequest : public QObject
163163
@sa data() body() */
164164
void storeBody();
165165

166-
signals:
166+
Q_SIGNALS:
167167
/// Emitted when new body data has been received.
168168
/** @note This may be emitted zero or more times
169169
depending on the request type.
@@ -174,7 +174,7 @@ class QHTTPSERVER_API QHttpRequest : public QObject
174174
/** @note The no more data() signals will be emitted after this. */
175175
void end();
176176

177-
private slots:
177+
private Q_SLOTS:
178178
void appendBody(const QByteArray &body);
179179

180180
private:

‎src/qhttpresponse.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ void QHttpResponse::writeHeaders()
7474
if (m_finished)
7575
return;
7676

77-
foreach(const QString & name, m_headers.keys()) {
77+
Q_FOREACH(const QString & name, m_headers.keys()) {
7878
QString value = m_headers[name];
7979
if (name.compare("connection", Qt::CaseInsensitive) == 0) {
8080
m_sentConnectionHeader = true;
@@ -172,7 +172,7 @@ void QHttpResponse::end(const QByteArray &data)
172172
write(data);
173173
m_finished = true;
174174

175-
emit done();
175+
Q_EMIT done();
176176

177177
/// @todo End connection and delete ourselves. Is this a still valid note?
178178
deleteLater();
@@ -181,6 +181,6 @@ void QHttpResponse::end(const QByteArray &data)
181181
void QHttpResponse::connectionClosed()
182182
{
183183
m_finished = true;
184-
emit done();
184+
Q_EMIT done();
185185
deleteLater();
186186
}

‎src/qhttpresponse.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ class QHTTPSERVER_API QHttpResponse : public QObject
9191
friend class QHttpConnection;
9292
/// @endcond
9393

94-
public slots:
94+
public Q_SLOTS:
9595
/// Sets a response header @c field to @c value.
9696
/** @note You must call this with all your custom headers
9797
before calling writeHead(), write() or end().
@@ -118,12 +118,12 @@ public slots:
118118
and the connection itself will be closed if
119119
this is the last response.
120120
121-
This will emit done() and queue this object
121+
This will Q_EMIT done() and queue this object
122122
for deletion. For details see \ref memorymanagement.
123123
@param data Optional data to be written before finishing. */
124124
void end(const QByteArray &data = "");
125125

126-
signals:
126+
Q_SIGNALS:
127127
/// Emitted when all the data has been sent
128128
/** This signal indicates that the underlaying socket has transmitted all
129129
of it's buffered data. It is possible to implement memory-efficient
@@ -157,7 +157,7 @@ public slots:
157157
bool m_useChunkedEncoding;
158158
bool m_finished;
159159

160-
private slots:
160+
private Q_SLOTS:
161161
void connectionClosed();
162162
};
163163

‎src/qhttpserver.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -81,15 +81,15 @@ class QHTTPSERVER_API QHttpServer : public QObject
8181

8282
/// Stop the server and listening for new connections.
8383
void close();
84-
signals:
84+
Q_SIGNALS:
8585
/// Emitted when a client makes a new request to the server.
8686
/** The slot should use the given @c request and @c response
8787
objects to communicate with the client.
8888
@param request New incoming request.
8989
@param response Response object to the request. */
9090
void newRequest(QHttpRequest *request, QHttpResponse *response);
9191

92-
private slots:
92+
private Q_SLOTS:
9393
void newConnection();
9494

9595
private:

0 commit comments

Comments
 (0)
Please sign in to comment.