From ed7e93dccf3844e0af2f3b5e525d83767abdc566 Mon Sep 17 00:00:00 2001 From: Martchus Date: Sun, 26 Apr 2020 19:43:27 +0200 Subject: [PATCH] Reduce nesting in MainWindow::fileSelected() --- gui/mainwindow.cpp | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index f589889..694cb89 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -273,21 +273,23 @@ void MainWindow::pathEntered() */ void MainWindow::fileSelected() { - if (!m_internalFileSelection) { - const QModelIndexList selectedIndexes = m_ui->filesTreeView->selectionModel()->selectedRows(); - if (selectedIndexes.count() == 1) { - const QString path(m_fileModel->filePath(m_fileFilterModel->mapToSource(selectedIndexes.at(0)))); - const QFileInfo fileInfo(path); - if (fileInfo.isFile()) { - startParsing(path); - m_ui->pathLineEdit->setText(fileInfo.dir().path()); - } else if (fileInfo.isDir()) { - m_ui->pathLineEdit->setText(path); - } - m_ui->pathLineEdit->setProperty("classNames", QStringList()); - updateStyle(m_ui->pathLineEdit); - } + if (m_internalFileSelection) { + return; } + const QModelIndexList selectedIndexes = m_ui->filesTreeView->selectionModel()->selectedRows(); + if (selectedIndexes.count() != 1) { + return; + } + const QString path(m_fileModel->filePath(m_fileFilterModel->mapToSource(selectedIndexes.at(0)))); + const QFileInfo fileInfo(path); + if (fileInfo.isFile()) { + startParsing(path); + m_ui->pathLineEdit->setText(fileInfo.dir().path()); + } else if (fileInfo.isDir()) { + m_ui->pathLineEdit->setText(path); + } + m_ui->pathLineEdit->setProperty("classNames", QStringList()); + updateStyle(m_ui->pathLineEdit); } /*!