From ac4217ef2f9a40288359b74102c91ed18a5eebe4 Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Wed, 12 May 2021 17:08:31 -0700 Subject: [PATCH] use isEmpty in preference to checking length against 0 in gvedit Qt QStrings have two methods, isEmpty and length, analogous to empty and length on std::string, respectively. Checking isEmpty is equivalent to checking length against 0, is clearer, and has the potential to be more performant. --- cmd/gvedit/csettings.cpp | 5 ++--- cmd/gvedit/mainwindow.cpp | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/cmd/gvedit/csettings.cpp b/cmd/gvedit/csettings.cpp index 1905460fe..79540e093 100644 --- a/cmd/gvedit/csettings.cpp +++ b/cmd/gvedit/csettings.cpp @@ -199,7 +199,7 @@ void CFrmSettings::addSlot() } QString _value = WIDGET(QLineEdit, leValue)->text(); - if (_value.trimmed().length() == 0) + if (_value.trimmed().isEmpty()) QMessageBox::warning(this, tr("GvEdit"), tr ("Please enter a value for selected attribute!"), @@ -268,8 +268,7 @@ void CFrmSettings::openSlot() void CFrmSettings::saveSlot() { - if (WIDGET(QTextEdit, teAttributes)->toPlainText().trimmed(). - length() == 0) { + if (WIDGET(QTextEdit, teAttributes)->toPlainText().trimmed().isEmpty()) { QMessageBox::warning(this, tr("GvEdit"), tr("Nothing to save!"), QMessageBox::Ok, QMessageBox::Ok); return; diff --git a/cmd/gvedit/mainwindow.cpp b/cmd/gvedit/mainwindow.cpp index 0d1ef3918..cfebeb29a 100644 --- a/cmd/gvedit/mainwindow.cpp +++ b/cmd/gvedit/mainwindow.cpp @@ -322,7 +322,7 @@ void CMainWindow::slotNewLog() void CMainWindow::slotSaveLog() { - if (globTextEdit->toPlainText().trimmed().length() == 0) { + if (globTextEdit->toPlainText().trimmed().isEmpty()) { QMessageBox::warning(this, tr("GvEdit"), tr("Nothing to save!"), QMessageBox::Ok, QMessageBox::Ok); return; -- 2.40.0