diff --git a/src/BookmarkHandler.cpp b/src/BookmarkHandler.cpp --- a/src/BookmarkHandler.cpp +++ b/src/BookmarkHandler.cpp @@ -66,12 +66,7 @@ KBookmarkManager *manager = KBookmarkManager::managerForFile(_file, QStringLiteral("konsole")); manager->setUpdate(true); - - if (toplevel) { - _bookmarkMenu = new KBookmarkMenu(manager, this, _menu, collection); - } else { - _bookmarkMenu = new KBookmarkMenu(manager, this, _menu, nullptr); - } + _bookmarkMenu = new KBookmarkMenu(manager, this, _menu, toplevel == true ? collection : nullptr); } BookmarkHandler::~BookmarkHandler() @@ -91,11 +86,8 @@ bool BookmarkHandler::enableOption(BookmarkOption option) const { - if (option == ShowAddBookmark || option == ShowEditBookmark) { - return _toplevel; - } else { - return KBookmarkOwner::enableOption(option); - } + const bool isTopLevel = (option == ShowAddBookmark || option == ShowEditBookmark); + return isTopLevel ? _toplevel : KBookmarkOwner::enableOption(option); } QUrl BookmarkHandler::currentUrl() const @@ -105,11 +97,7 @@ QUrl BookmarkHandler::urlForView(ViewProperties *view) const { - if (view != nullptr) { - return view->url(); - } else { - return QUrl(); - } + return view != nullptr ? view->url() : QUrl(); } QString BookmarkHandler::currentTitle() const @@ -128,13 +116,9 @@ return path; } else if (!url.host().isEmpty()) { - if (!url.userName().isEmpty()) { - return i18nc("@item:inmenu The user's name and host they are connected to via ssh", - "%1 on %2", url.userName(), url.host()); - } else { - return i18nc("@item:inmenu The host the user is connected to via ssh", "%1", - url.host()); - } + return !url.userName().isEmpty() + ? i18nc("@item:inmenu The user's name and host they are connected to via ssh", "%1 on %2", url.userName(), url.host()) + : i18nc("@item:inmenu The host the user is connected to via ssh", "%1", url.host()); } return url.toDisplayString(); @@ -147,11 +131,7 @@ QString BookmarkHandler::iconForView(ViewProperties *view) const { - if (view != nullptr) { - return view->icon().name(); - } else { - return QString(); - } + return view != nullptr ? view->icon().name() : QString(); } bool BookmarkHandler::supportsTabs() const diff --git a/src/ColorScheme.cpp b/src/ColorScheme.cpp --- a/src/ColorScheme.cpp +++ b/src/ColorScheme.cpp @@ -326,11 +326,7 @@ const ColorEntry *ColorScheme::colorTable() const { - if (_table != nullptr) { - return _table; - } else { - return defaultTable; - } + return _table != nullptr ? _table : defaultTable; } QColor ColorScheme::foregroundColor() const diff --git a/src/CopyInputDialog.cpp b/src/CopyInputDialog.cpp --- a/src/CopyInputDialog.cpp +++ b/src/CopyInputDialog.cpp @@ -138,11 +138,7 @@ { QAbstractItemModel *model = _ui->sessionList->model(); QModelIndex index = model->index(row, _model->checkColumn()); - if (checked) { - model->setData(index, static_cast(Qt::Checked), Qt::CheckStateRole); - } else { - model->setData(index, static_cast(Qt::Unchecked), Qt::CheckStateRole); - } + model->setData(index, static_cast( checked ? Qt::Checked : Qt::Unchecked), Qt::CheckStateRole); } CheckableSessionModel::CheckableSessionModel(QObject *parent) : @@ -173,17 +169,13 @@ QVariant CheckableSessionModel::data(const QModelIndex &index, int role) const { - if (role == Qt::CheckStateRole && index.column() == _checkColumn) { - Session *session = static_cast(index.internalPointer()); - - if (_checkedSessions.contains(session)) { - return QVariant::fromValue(static_cast(Qt::Checked)); - } else { - return QVariant::fromValue(static_cast(Qt::Unchecked)); - } - } else { + if (role != Qt::CheckStateRole || index.column() != _checkColumn) { return SessionListModel::data(index, role); } + + Session *session = static_cast(index.internalPointer()); + const bool hasSession = _checkedSessions.contains(session); + return QVariant::fromValue(static_cast( hasSession ? Qt::Checked : Qt::Unchecked)); } bool CheckableSessionModel::setData(const QModelIndex &index, const QVariant &value, int role) diff --git a/src/HistorySizeWidget.cpp b/src/HistorySizeWidget.cpp --- a/src/HistorySizeWidget.cpp +++ b/src/HistorySizeWidget.cpp @@ -109,16 +109,9 @@ Enum::HistoryModeEnum HistorySizeWidget::mode() const { - if (_ui->noHistoryButton->isChecked()) { - return Enum::NoHistory; - } else if (_ui->fixedSizeHistoryButton->isChecked()) { - return Enum::FixedSizeHistory; - } else if (_ui->unlimitedHistoryButton->isChecked()) { - return Enum::UnlimitedHistory; - } - - Q_ASSERT(false); - return Enum::NoHistory; + return _ui->unlimitedHistoryButton->isChecked() ? Enum::UnlimitedHistory + : _ui->fixedSizeHistoryButton->isChecked() ? Enum::FixedSizeHistory + : Enum::NoHistory; } void HistorySizeWidget::setLineCount(int lines) diff --git a/src/KeyboardTranslator.cpp b/src/KeyboardTranslator.cpp --- a/src/KeyboardTranslator.cpp +++ b/src/KeyboardTranslator.cpp @@ -60,12 +60,9 @@ void KeyboardTranslatorWriter::writeEntry(const KeyboardTranslator::Entry &entry) { - QString result; - if (entry.command() != KeyboardTranslator::NoCommand) { - result = entry.resultToString(); - } else { - result = QLatin1Char('\"') + entry.resultToString() + QLatin1Char('\"'); - } + QString result = entry.command() != KeyboardTranslator::NoCommand + ? entry.resultToString() + : QLatin1Char('\"') + entry.resultToString() + QLatin1Char('\"'); *_writer << "key " << entry.conditionToString() << " : " << result << '\n'; } diff --git a/src/ProcessInfo.cpp b/src/ProcessInfo.cpp --- a/src/ProcessInfo.cpp +++ b/src/ProcessInfo.cpp @@ -251,12 +251,7 @@ void ProcessInfo::setUserHomeDir() { - const QString &usersName = userName(); - if (!usersName.isEmpty()) { - _userHomeDir = KUser(usersName).homeDir(); - } else { - _userHomeDir = QDir::homePath(); - } + _userHomeDir = _userName.isEmpty() ? QDir::homePath() : KUser(_userName).homeDir(); } void ProcessInfo::setParentPid(int pid)