From 159e4baf6227f79f4fb12c847e79c4676ddd86b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20K=C3=BCgler?= Date: Tue, 19 Sep 2017 14:51:27 +0200 Subject: [PATCH] Use QString for number parsing Instead of our hand-baked version, use QString::toInt() to convert to numbers. --- src/doctor/doctor.cpp | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/src/doctor/doctor.cpp b/src/doctor/doctor.cpp index cf5d9e62..900899cf 100644 --- a/src/doctor/doctor.cpp +++ b/src/doctor/doctor.cpp @@ -198,7 +198,7 @@ void Doctor::parsePositionalArgs() } } if (output_id == -1) { - output_id = parseInt(ops[1], ok); + output_id = ops[1].toInt(&ok); if (!ok) { cerr << "Unable to parse output id" << ops[1] << endl; qApp->exit(3); @@ -231,8 +231,8 @@ void Doctor::parsePositionalArgs() qApp->exit(5); return; } - int x = parseInt(_pos[0], ok); - int y = parseInt(_pos[1], ok); + int x = _pos[0].toInt(&ok); + int y = _pos[1].toInt(&ok); if (!ok) { cerr << "Unable to parse position" << ops[3] << endl; qApp->exit(5); @@ -268,17 +268,6 @@ void Doctor::parsePositionalArgs() } } -int Doctor::parseInt(const QString &str, bool &ok) const -{ - int _id = str.toInt(); - if (QString::number(_id) == str) { - ok = true; - return _id; - } - ok = false; - return 0; -} - void Doctor::configReceived(KScreen::ConfigOperation *op) { m_config = op->config(); -- GitLab