mirror of
https://github.com/x-tools-author/x-tools.git
synced 2025-09-15 15:28:40 +08:00
refactor: rename data member
This commit is contained in:
parent
5e2f9f624d
commit
8fa75ffd95
@ -17,7 +17,7 @@ void xToolsBaseToolUi::initialize(xToolsBaseTool *tool,
|
||||
const QString &settingsGroup,
|
||||
const char *loggingCategory)
|
||||
{
|
||||
mTool = tool;
|
||||
m_tool = tool;
|
||||
if (mLoggingCategory) {
|
||||
delete mLoggingCategory;
|
||||
mLoggingCategory = nullptr;
|
||||
|
||||
@ -28,5 +28,5 @@ protected:
|
||||
|
||||
protected:
|
||||
QLoggingCategory *mLoggingCategory{nullptr};
|
||||
xToolsBaseTool *mTool{nullptr};
|
||||
xToolsBaseTool *m_tool{nullptr};
|
||||
};
|
||||
|
||||
@ -23,20 +23,21 @@ xToolsSerialPortToolUi::~xToolsSerialPortToolUi()
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void xToolsSerialPortToolUi::onBaseToolUiInitialized(xToolsBaseTool *tool, const QString &settingsGroup)
|
||||
void xToolsSerialPortToolUi::onBaseToolUiInitialized(xToolsBaseTool *tool,
|
||||
const QString &settingsGroup)
|
||||
{
|
||||
if (!(tool && tool->inherits("xToolsSerialPortTool"))) {
|
||||
qWarning() << "Invalid type of communication tool!";
|
||||
return;
|
||||
}
|
||||
|
||||
mTool = qobject_cast<xToolsSerialPortTool *>(tool);
|
||||
mTool->setPortName(ui->comboBoxPortNames->currentText());
|
||||
mTool->setBaudRate(ui->comboBoxBaudRate->currentData().toInt());
|
||||
mTool->setDataBits(ui->comboBoxDataBits->currentData().toInt());
|
||||
mTool->setStopBits(ui->comboBoxStopBits->currentData().toInt());
|
||||
mTool->setParity(ui->comboBoxParity->currentData().toInt());
|
||||
mTool->setFlowControl(ui->comboBoxFlowControl->currentData().toInt());
|
||||
m_tool = qobject_cast<xToolsSerialPortTool *>(tool);
|
||||
m_tool->setPortName(ui->comboBoxPortNames->currentText());
|
||||
m_tool->setBaudRate(ui->comboBoxBaudRate->currentData().toInt());
|
||||
m_tool->setDataBits(ui->comboBoxDataBits->currentData().toInt());
|
||||
m_tool->setStopBits(ui->comboBoxStopBits->currentData().toInt());
|
||||
m_tool->setParity(ui->comboBoxParity->currentData().toInt());
|
||||
m_tool->setFlowControl(ui->comboBoxFlowControl->currentData().toInt());
|
||||
|
||||
connect(ui->comboBoxPortNames,
|
||||
&QComboBox::currentTextChanged,
|
||||
@ -73,40 +74,40 @@ void xToolsSerialPortToolUi::onBaseToolUiInitialized(xToolsBaseTool *tool, const
|
||||
|
||||
void xToolsSerialPortToolUi::checkInitializingStatus()
|
||||
{
|
||||
Q_ASSERT_X(mTool, __FUNCTION__, "Please call initialze() first!");
|
||||
Q_ASSERT_X(m_tool, __FUNCTION__, "Please call initialze() first!");
|
||||
}
|
||||
|
||||
void xToolsSerialPortToolUi::onComboBoxPortNamesCurrentTextChanged()
|
||||
{
|
||||
checkInitializingStatus();
|
||||
mTool->setPortName(ui->comboBoxPortNames->currentText());
|
||||
m_tool->setPortName(ui->comboBoxPortNames->currentText());
|
||||
}
|
||||
|
||||
void xToolsSerialPortToolUi::onComboBoxBaudRateCurrentIndexChanged()
|
||||
{
|
||||
checkInitializingStatus();
|
||||
mTool->setBaudRate(ui->comboBoxBaudRate->currentData().toInt());
|
||||
m_tool->setBaudRate(ui->comboBoxBaudRate->currentData().toInt());
|
||||
}
|
||||
|
||||
void xToolsSerialPortToolUi::onComboBoxDataBitsCurrentIndexChanged()
|
||||
{
|
||||
checkInitializingStatus();
|
||||
mTool->setDataBits(ui->comboBoxDataBits->currentData().toInt());
|
||||
m_tool->setDataBits(ui->comboBoxDataBits->currentData().toInt());
|
||||
}
|
||||
|
||||
void xToolsSerialPortToolUi::onComboBoxStopBitsCurrentIndexChanged()
|
||||
{
|
||||
mTool->setStopBits(ui->comboBoxStopBits->currentData().toInt());
|
||||
m_tool->setStopBits(ui->comboBoxStopBits->currentData().toInt());
|
||||
}
|
||||
|
||||
void xToolsSerialPortToolUi::onComboBoxParityCurrentIndexChanged()
|
||||
{
|
||||
checkInitializingStatus();
|
||||
mTool->setParity(ui->comboBoxParity->currentData().toInt());
|
||||
m_tool->setParity(ui->comboBoxParity->currentData().toInt());
|
||||
}
|
||||
|
||||
void xToolsSerialPortToolUi::onComboBoxFlowControlCurrentIndexChanged()
|
||||
{
|
||||
checkInitializingStatus();
|
||||
mTool->setFlowControl(ui->comboBoxFlowControl->currentData().toInt());
|
||||
m_tool->setFlowControl(ui->comboBoxFlowControl->currentData().toInt());
|
||||
}
|
||||
|
||||
@ -25,7 +25,7 @@ public:
|
||||
virtual void onBaseToolUiInitialized(xToolsBaseTool *tool, const QString &settingsGroup) final;
|
||||
|
||||
private:
|
||||
xToolsSerialPortTool *mTool{nullptr};
|
||||
xToolsSerialPortTool *m_tool{nullptr};
|
||||
const QLoggingCategory mLoggingCategory{"sak.serialporttoolui"};
|
||||
|
||||
private:
|
||||
|
||||
@ -18,7 +18,6 @@ xToolsSocketClientToolUi::xToolsSocketClientToolUi(QWidget *parent)
|
||||
, ui(new Ui::xToolsSocketClientToolUi)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->widgetAuthentication->hide();
|
||||
|
||||
connect(ui->comboBoxClientAddress,
|
||||
static_cast<void (QComboBox::*)(int)>(&QComboBox::activated),
|
||||
@ -82,13 +81,12 @@ void xToolsSocketClientToolUi::onBaseToolUiInitialized(xToolsBaseTool *tool,
|
||||
if (!tool->inherits("xToolsWebSocketClientTool")) {
|
||||
ui->labelMessageType->hide();
|
||||
ui->comboBoxMessageType->hide();
|
||||
} else {
|
||||
ui->widgetAuthentication->show();
|
||||
ui->widgetAuthentication->hide();
|
||||
}
|
||||
|
||||
mTool = qobject_cast<xToolsSocketClientTool *>(tool);
|
||||
if (!mTool) {
|
||||
qWarning() << "qobject_cast<>() return nullptr";
|
||||
m_tool = qobject_cast<xToolsSocketClientTool *>(tool);
|
||||
if (!m_tool) {
|
||||
Q_ASSERT_X(m_tool, __FUNCTION__, "Invalid xToolsSocketClientTool object!");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -102,77 +100,77 @@ void xToolsSocketClientToolUi::onBaseToolUiInitialized(xToolsBaseTool *tool,
|
||||
ui->lineEditUserName->setGroupKey(settingsGroup, "username");
|
||||
ui->lineEditPassword->setGroupKey(settingsGroup, "password");
|
||||
|
||||
mTool->setClientIp(ui->comboBoxClientAddress->currentText().trimmed());
|
||||
mTool->setClientPort(ui->spinBoxClientPort->value());
|
||||
mTool->setServerIp(ui->comboBoxServerAddress->currentText().trimmed());
|
||||
mTool->setServerPort(ui->spinBoxServerPort->value());
|
||||
mTool->setSpecifyClientIpPort(ui->checkBoxSpecifyIpAndPort->isChecked());
|
||||
m_tool->setClientIp(ui->comboBoxClientAddress->currentText().trimmed());
|
||||
m_tool->setClientPort(ui->spinBoxClientPort->value());
|
||||
m_tool->setServerIp(ui->comboBoxServerAddress->currentText().trimmed());
|
||||
m_tool->setServerPort(ui->spinBoxServerPort->value());
|
||||
m_tool->setSpecifyClientIpPort(ui->checkBoxSpecifyIpAndPort->isChecked());
|
||||
|
||||
connect(mTool, &xToolsSocketClientTool::bindingIpPortChanged, this, [=]() {
|
||||
QString ipport = mTool->bindingIpPort();
|
||||
connect(m_tool, &xToolsSocketClientTool::bindingIpPortChanged, this, [=]() {
|
||||
QString ipport = m_tool->bindingIpPort();
|
||||
ui->labelContext->setText(ipport);
|
||||
});
|
||||
connect(mTool, &xToolsSocketClientTool::finished, this, [=]() {
|
||||
connect(m_tool, &xToolsSocketClientTool::finished, this, [=]() {
|
||||
ui->labelContext->setText(tr("Closed"));
|
||||
});
|
||||
}
|
||||
|
||||
void xToolsSocketClientToolUi::onComboBoxClientAddressActivated()
|
||||
{
|
||||
if (mTool) {
|
||||
if (m_tool) {
|
||||
QString ip = ui->comboBoxClientAddress->currentText().trimmed();
|
||||
mTool->setClientIp(ip);
|
||||
m_tool->setClientIp(ip);
|
||||
}
|
||||
}
|
||||
|
||||
void xToolsSocketClientToolUi::onSpinBoxClientPortValueChanged(int value)
|
||||
{
|
||||
if (mTool) {
|
||||
mTool->setClientPort(value);
|
||||
if (m_tool) {
|
||||
m_tool->setClientPort(value);
|
||||
}
|
||||
}
|
||||
|
||||
void xToolsSocketClientToolUi::onComboBoxServerAddressCurrentTextChanged()
|
||||
{
|
||||
if (mTool) {
|
||||
if (m_tool) {
|
||||
QString ip = ui->comboBoxServerAddress->currentText().trimmed();
|
||||
mTool->setServerIp(ip);
|
||||
m_tool->setServerIp(ip);
|
||||
}
|
||||
}
|
||||
|
||||
void xToolsSocketClientToolUi::onSpinBoxServerPortValueChanged(int value)
|
||||
{
|
||||
if (mTool) {
|
||||
mTool->setServerPort(value);
|
||||
if (m_tool) {
|
||||
m_tool->setServerPort(value);
|
||||
}
|
||||
}
|
||||
|
||||
void xToolsSocketClientToolUi::onCheckBoxSpecifyIpAndPortClicked()
|
||||
{
|
||||
if (mTool) {
|
||||
if (m_tool) {
|
||||
bool checked = ui->checkBoxSpecifyIpAndPort->isChecked();
|
||||
mTool->setSpecifyClientIpPort(checked);
|
||||
m_tool->setSpecifyClientIpPort(checked);
|
||||
}
|
||||
}
|
||||
|
||||
void xToolsSocketClientToolUi::onAuthenticationCheckBoxClicked()
|
||||
{
|
||||
if (mTool) {
|
||||
if (m_tool) {
|
||||
bool checked = ui->checkBoxAuthentication->isChecked();
|
||||
mTool->setAuthentication(checked);
|
||||
m_tool->setAuthentication(checked);
|
||||
}
|
||||
}
|
||||
|
||||
void xToolsSocketClientToolUi::onUserNameLineEditTextChanged(const QString &text)
|
||||
{
|
||||
if (mTool) {
|
||||
mTool->setUserName(text);
|
||||
if (m_tool) {
|
||||
m_tool->setUserName(text);
|
||||
}
|
||||
}
|
||||
|
||||
void xToolsSocketClientToolUi::onPasswordLineEditTextChanged(const QString &text)
|
||||
{
|
||||
if (mTool) {
|
||||
mTool->setPassword(text);
|
||||
if (m_tool) {
|
||||
m_tool->setPassword(text);
|
||||
}
|
||||
}
|
||||
@ -25,12 +25,9 @@ public:
|
||||
virtual void onIsWorkingChanged(bool isWorking) final;
|
||||
virtual void onBaseToolUiInitialized(xToolsBaseTool *tool, const QString &settingsGroup) final;
|
||||
|
||||
private:
|
||||
const QLoggingCategory mLoggingCategory{"sak.socketclienttoolui"};
|
||||
xToolsSocketClientTool *mTool{nullptr};
|
||||
|
||||
private:
|
||||
Ui::xToolsSocketClientToolUi *ui{nullptr};
|
||||
xToolsSocketClientTool *m_tool{nullptr};
|
||||
|
||||
public slots:
|
||||
void onComboBoxClientAddressActivated();
|
||||
|
||||
@ -52,7 +52,8 @@ void xToolsSocketServerToolUi::onIsWorkingChanged(bool isWorking)
|
||||
ui->checkBoxSpecifyIpAndPort->setEnabled(!isWorking);
|
||||
}
|
||||
|
||||
void xToolsSocketServerToolUi::onBaseToolUiInitialized(xToolsBaseTool *tool, const QString &settingsGroup)
|
||||
void xToolsSocketServerToolUi::onBaseToolUiInitialized(xToolsBaseTool *tool,
|
||||
const QString &settingsGroup)
|
||||
{
|
||||
if (!tool) {
|
||||
return;
|
||||
@ -74,8 +75,8 @@ void xToolsSocketServerToolUi::onBaseToolUiInitialized(xToolsBaseTool *tool, con
|
||||
ui->checkBoxSpecifyIpAndPort->hide();
|
||||
}
|
||||
|
||||
mTool = qobject_cast<xToolsSocketServerTool *>(tool);
|
||||
if (!mTool) {
|
||||
m_tool = qobject_cast<xToolsSocketServerTool *>(tool);
|
||||
if (!m_tool) {
|
||||
qWarning() << "qobject_cast<>() return nullptr";
|
||||
return;
|
||||
}
|
||||
@ -89,23 +90,23 @@ void xToolsSocketServerToolUi::onBaseToolUiInitialized(xToolsBaseTool *tool, con
|
||||
int port = ui->spinBoxServerPort->value();
|
||||
bool specified = ui->checkBoxSpecifyIpAndPort->isChecked();
|
||||
int messageType = ui->comboBoxMessageType->currentData().toInt();
|
||||
mTool->setServerIp(ip);
|
||||
m_tool->setServerIp(ip);
|
||||
;
|
||||
mTool->setServerPort(port);
|
||||
mTool->setSpecifyIpAndPort(specified);
|
||||
mTool->setMessageType(messageType);
|
||||
m_tool->setServerPort(port);
|
||||
m_tool->setSpecifyIpAndPort(specified);
|
||||
m_tool->setMessageType(messageType);
|
||||
|
||||
connect(mTool, &xToolsSocketServerTool::bindingIpPortChanged, this, [=]() {
|
||||
QString ipport = mTool->bindingIpPort();
|
||||
connect(m_tool, &xToolsSocketServerTool::bindingIpPortChanged, this, [=]() {
|
||||
QString ipport = m_tool->bindingIpPort();
|
||||
ui->labelBindingInfo->setText(ipport);
|
||||
});
|
||||
connect(mTool, &xToolsSocketServerTool::finished, this, [=]() {
|
||||
connect(m_tool, &xToolsSocketServerTool::finished, this, [=]() {
|
||||
ui->labelBindingInfo->setText(tr("Closed"));
|
||||
});
|
||||
connect(mTool, &xToolsSocketServerTool::clientsChanged, this, [=]() {
|
||||
connect(m_tool, &xToolsSocketServerTool::clientsChanged, this, [=]() {
|
||||
int index = ui->comboBoxClientList->currentIndex();
|
||||
QString first = ui->comboBoxClientList->itemText(0);
|
||||
QStringList clients = mTool->clients();
|
||||
QStringList clients = m_tool->clients();
|
||||
int count = ui->comboBoxClientList->count();
|
||||
|
||||
ui->comboBoxClientList->clear();
|
||||
@ -119,32 +120,32 @@ void xToolsSocketServerToolUi::onBaseToolUiInitialized(xToolsBaseTool *tool, con
|
||||
|
||||
void xToolsSocketServerToolUi::onComboBoxServerIpActived()
|
||||
{
|
||||
if (mTool) {
|
||||
mTool->setServerIp(ui->comboBoxServerIp->currentText().trimmed());
|
||||
if (m_tool) {
|
||||
m_tool->setServerIp(ui->comboBoxServerIp->currentText().trimmed());
|
||||
}
|
||||
}
|
||||
|
||||
void xToolsSocketServerToolUi::onSpinBoxServerPortValueChanged(int value)
|
||||
{
|
||||
if (mTool) {
|
||||
mTool->setServerPort(value);
|
||||
if (m_tool) {
|
||||
m_tool->setServerPort(value);
|
||||
}
|
||||
}
|
||||
|
||||
void xToolsSocketServerToolUi::onComboBoxClientsIndexChanged()
|
||||
{
|
||||
int index = ui->comboBoxClientList->currentIndex();
|
||||
mTool->setClientIndex(index - 1);
|
||||
m_tool->setClientIndex(index - 1);
|
||||
}
|
||||
|
||||
void xToolsSocketServerToolUi::onComboBoxMessageTypeIndexChanged()
|
||||
{
|
||||
int messageType = ui->comboBoxMessageType->currentData().toInt();
|
||||
mTool->setMessageType(messageType);
|
||||
m_tool->setMessageType(messageType);
|
||||
}
|
||||
|
||||
void xToolsSocketServerToolUi::onCheckBoxSpecifyIpAndPortClicked()
|
||||
{
|
||||
bool specified = ui->checkBoxSpecifyIpAndPort->isChecked();
|
||||
mTool->setSpecifyIpAndPort(specified);
|
||||
m_tool->setSpecifyIpAndPort(specified);
|
||||
}
|
||||
|
||||
@ -26,7 +26,7 @@ public:
|
||||
virtual void onBaseToolUiInitialized(xToolsBaseTool *tool, const QString &settingsGroup) final;
|
||||
|
||||
private:
|
||||
xToolsSocketServerTool *mTool{nullptr};
|
||||
xToolsSocketServerTool *m_tool{nullptr};
|
||||
const QLoggingCategory mLoggingCategory{"sak.socketservertoolui"};
|
||||
|
||||
private:
|
||||
|
||||
@ -17,7 +17,7 @@ xToolsTransmitterToolUi::xToolsTransmitterToolUi(const char *lg, QWidget *parent
|
||||
void xToolsTransmitterToolUi::afterRowEdited(int row)
|
||||
{
|
||||
xToolsTransmitterTool *cookedTool = Q_NULLPTR;
|
||||
cookedTool = qobject_cast<xToolsTransmitterTool *>(mTool);
|
||||
cookedTool = qobject_cast<xToolsTransmitterTool *>(m_tool);
|
||||
if (!cookedTool) {
|
||||
return;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user