提交 cc11f83d 编写于 作者: 丁劲犇's avatar 丁劲犇 😸

Add server message display logs

上级 06dfac3e
......@@ -75,7 +75,7 @@ void QTcpClientTest::on_client_disconnected()
pSock->deleteLater();
}
}
void QTcpClientTest::displayError(QAbstractSocket::SocketError err)
void QTcpClientTest::displayError(QAbstractSocket::SocketError /*err*/)
{
QGHTcpClient * sock = qobject_cast<QGHTcpClient *> (sender());
if (sock)
......
#include "zpmainframe.h"
#include "ui_zpmainframe.h"
#include <functional>
#include <QDateTime>
using namespace ZPNetwork;
using namespace ZPTaskEngine;
ZPMainFrame::ZPMainFrame(QWidget *parent) :
......@@ -32,6 +32,9 @@ ZPMainFrame::ZPMainFrame(QWidget *parent) :
m_nTimerId = startTimer(500);
m_pMsgModel = new QStandardItemModel(this);
ui->listView_msg->setModel(m_pMsgModel);
}
ZPMainFrame::~ZPMainFrame()
......@@ -46,7 +49,6 @@ ZPMainFrame::~ZPMainFrame()
{
QCoreApplication::processEvents();
QThread::currentThread()->msleep(200);
//_sleep(100);
}
delete ui;
......@@ -64,14 +66,26 @@ void ZPMainFrame::changeEvent(QEvent *e)
}
}
//These Message is nessery.-------------------------------------
void ZPMainFrame::on_evt_Message(const QString &)
void ZPMainFrame::on_evt_Message(const QString & strMsg)
{
QDateTime dtm = QDateTime::currentDateTime();
QString msg = dtm.toString("yyyy-MM-dd HH:mm:ss.zzz") + " " + strMsg;
int nrows = m_pMsgModel->rowCount();
m_pMsgModel->insertRow(0,new QStandardItem(msg));
while (nrows-- > 16384)
m_pMsgModel->removeRow(m_pMsgModel->rowCount()-1);
}
//The socket error message
void ZPMainFrame::on_evt_SocketError(QObject * /*senderSock*/ ,QAbstractSocket::SocketError/* socketError*/)
void ZPMainFrame::on_evt_SocketError(QObject * senderSock ,QAbstractSocket::SocketError socketError)
{
QDateTime dtm = QDateTime::currentDateTime();
QString msg = dtm.toString("yyyy-MM-dd HH:mm:ss.zzz") + " " + QString("SockError %1 with code %2")
.arg((quint64)senderSock).arg((quint32)socketError);
int nrows = m_pMsgModel->rowCount();
m_pMsgModel->insertRow(0,new QStandardItem(msg));
while (nrows-- > 16384)
m_pMsgModel->removeRow(m_pMsgModel->rowCount()-1);
}
......
......@@ -2,6 +2,7 @@
#define ZPMAINFRAME_H
#include <QMainWindow>
#include <QStandardItemModel>
#include "network/zp_net_threadpool.h"
#include "pipeline/zp_pipeline.h"
#include "smartlink/st_client_table.h"
......@@ -20,6 +21,7 @@ public:
protected:
void changeEvent(QEvent *e);
void timerEvent(QTimerEvent *);
QStandardItemModel * m_pMsgModel;
private:
Ui::ZPMainFrame *ui;
ZPNetwork::zp_net_ThreadPool * m_netEngine;
......
......@@ -26,7 +26,7 @@
<normaloff>:/icons/Resources/Alienware (27).png</normaloff>:/icons/Resources/Alienware (27).png</iconset>
</attribute>
<attribute name="title">
<string>Network</string>
<string>Summary</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
......@@ -40,8 +40,13 @@
<normaloff>:/icons/Resources/Backup drive.png</normaloff>:/icons/Resources/Backup drive.png</iconset>
</attribute>
<attribute name="title">
<string>Task</string>
<string>Messages</string>
</attribute>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QListView" name="listView_msg"/>
</item>
</layout>
</widget>
</widget>
</item>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册