summaryrefslogtreecommitdiffstats
path: root/examples/serialbus/modbus
diff options
context:
space:
mode:
authorDenis Shienkov <denis.shienkov@gmail.com>2016-04-21 15:24:16 +0300
committerDenis Shienkov <denis.shienkov@gmail.com>2016-04-22 11:36:32 +0000
commitedf55f657a46fe16bf80d63f523848bb9b71d9f3 (patch)
tree0c32d61ffd423c9c1b045ac343b6cc3eada0194a /examples/serialbus/modbus
parent33d19928d7c5beeacdc3d3c57bc5ed95d26934a5 (diff)
Use 'auto' where it is possible
Change-Id: I3d915a6230a1f35317abc39d6266a9d46a5d9be6 Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com> Reviewed-by: André Hartmann <aha_1980@gmx.de>
Diffstat (limited to 'examples/serialbus/modbus')
-rw-r--r--examples/serialbus/modbus/adueditor/mainwindow.cpp2
-rw-r--r--examples/serialbus/modbus/adueditor/modbustcpclient_p.h4
-rw-r--r--examples/serialbus/modbus/master/mainwindow.cpp10
-rw-r--r--examples/serialbus/modbus/master/writeregistermodel.cpp2
4 files changed, 9 insertions, 9 deletions
diff --git a/examples/serialbus/modbus/adueditor/mainwindow.cpp b/examples/serialbus/modbus/adueditor/mainwindow.cpp
index 51f1840..c4149e0 100644
--- a/examples/serialbus/modbus/adueditor/mainwindow.cpp
+++ b/examples/serialbus/modbus/adueditor/mainwindow.cpp
@@ -137,7 +137,7 @@ void MainWindow::on_sendButton_clicked()
void MainWindow::on_connectButton_clicked()
{
if (tcpRadio->isChecked()) {
- ModbusTcpClient *device = new ModbusTcpClient;
+ auto device = new ModbusTcpClient;
using signature = void (QSpinBox::*)(int);
connect(ti1Spin, static_cast<signature>(&QSpinBox::valueChanged), device,
&ModbusTcpClient::valueChanged);
diff --git a/examples/serialbus/modbus/adueditor/modbustcpclient_p.h b/examples/serialbus/modbus/adueditor/modbustcpclient_p.h
index fa9fa6d..561cfda 100644
--- a/examples/serialbus/modbus/adueditor/modbustcpclient_p.h
+++ b/examples/serialbus/modbus/adueditor/modbustcpclient_p.h
@@ -80,8 +80,8 @@ public:
return nullptr;
Q_Q(ModbusTcpClient);
- QModbusReply *const reply = new QModbusReply(type, m_uId, q);
- const QueueElement element = QueueElement{ reply, request, unit, m_numberOfRetries,
+ auto reply = new QModbusReply(type, m_uId, q);
+ const auto element = QueueElement{ reply, request, unit, m_numberOfRetries,
m_responseTimeoutDuration };
m_transactionStore.insert(m_tId, element);
diff --git a/examples/serialbus/modbus/master/mainwindow.cpp b/examples/serialbus/modbus/master/mainwindow.cpp
index efa0e90..ae45e31 100644
--- a/examples/serialbus/modbus/master/mainwindow.cpp
+++ b/examples/serialbus/modbus/master/mainwindow.cpp
@@ -83,7 +83,7 @@ MainWindow::MainWindow(QWidget *parent)
ui->connectType->setCurrentIndex(0);
on_connectType_currentIndexChanged(0);
- QStandardItemModel *model = new QStandardItemModel(10, 1, this);
+ auto model = new QStandardItemModel(10, 1, this);
for (int i = 0; i < 10; ++i)
model->setItem(i, new QStandardItem(QStringLiteral("%1").arg(i + 1)));
ui->writeSize->setModel(model);
@@ -142,7 +142,7 @@ void MainWindow::on_connectType_currentIndexChanged(int index)
modbusDevice = nullptr;
}
- ModbusConnection type = static_cast<ModbusConnection> (index);
+ auto type = static_cast<ModbusConnection> (index);
if (type == Serial) {
modbusDevice = new QModbusRtuSerialMaster(this);
} else if (type == Tcp) {
@@ -236,7 +236,7 @@ void MainWindow::on_readButton_clicked()
void MainWindow::readReady()
{
- QModbusReply *reply = qobject_cast<QModbusReply *>(sender());
+ auto reply = qobject_cast<QModbusReply *>(sender());
if (!reply)
return;
@@ -341,7 +341,7 @@ void MainWindow::on_writeTable_currentIndexChanged(int index)
QModbusDataUnit MainWindow::readRequest() const
{
- const QModbusDataUnit::RegisterType table =
+ const auto table =
static_cast<QModbusDataUnit::RegisterType> (ui->writeTable->currentData().toInt());
int startAddress = ui->readAddress->value();
@@ -354,7 +354,7 @@ QModbusDataUnit MainWindow::readRequest() const
QModbusDataUnit MainWindow::writeRequest() const
{
- const QModbusDataUnit::RegisterType table =
+ const auto table =
static_cast<QModbusDataUnit::RegisterType> (ui->writeTable->currentData().toInt());
int startAddress = ui->writeAddress->value();
diff --git a/examples/serialbus/modbus/master/writeregistermodel.cpp b/examples/serialbus/modbus/master/writeregistermodel.cpp
index f0ed26e..bb57d20 100644
--- a/examples/serialbus/modbus/master/writeregistermodel.cpp
+++ b/examples/serialbus/modbus/master/writeregistermodel.cpp
@@ -113,7 +113,7 @@ bool WriteRegisterModel::setData(const QModelIndex &index, const QVariant &value
Q_ASSERT(m_holdingRegisters.count() == ROW_COUNT);
if (index.column() == COLUMN_COILS && role == Qt::CheckStateRole) { // coils
- Qt::CheckState s = static_cast<Qt::CheckState>(value.toUInt());
+ auto s = static_cast<Qt::CheckState>(value.toUInt());
s == Qt::Checked ? m_coils.setBit(index.row()) : m_coils.clearBit(index.row());
emit dataChanged(index, index);
return true;