From 0886ef9c5ffadab54c4cc427daef6d22e0afe3c4 Mon Sep 17 00:00:00 2001 From: Akhilesh Nema Date: Sat, 26 Dec 2015 11:47:07 +0100 Subject: [PATCH] Fixed #3192 (GUI: Allow opening project file without extra parameter from CLI) --- gui/mainwindow.cpp | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index 21cd5c4f3..3b67efabb 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -214,21 +214,26 @@ MainWindow::~MainWindow() void MainWindow::HandleCLIParams(const QStringList ¶ms) { + int index; if (params.contains("-p")) { - const int ind = params.indexOf("-p"); - if ((ind + 1) < params.length()) - LoadProjectFile(params[ind + 1]); + index = params.indexOf("-p"); + if ((index + 1) < params.length()) + LoadProjectFile(params[index + 1]); + } else if ((index = params.indexOf(QRegExp(".*\\.cppcheck$", Qt::CaseInsensitive), 0)) >= 0 && index < params.length() && QFile(params[index]).exists()) { + LoadProjectFile(params[index]); + } else if ((index = params.indexOf(QRegExp(".*\\.xml$", Qt::CaseInsensitive), 0)) >= 0 && index < params.length() && QFile(params[index]).exists()) { + LoadResults(params[index]); } else if (params.contains("-l")) { QString logFile; - const int ind = params.indexOf("-l"); - if ((ind + 1) < params.length()) - logFile = params[ind + 1]; + index = params.indexOf("-l"); + if ((index + 1) < params.length()) + logFile = params[index + 1]; if (params.contains("-d")) { QString checkedDir; - const int ind = params.indexOf("-d"); - if ((ind + 1) < params.length()) - checkedDir = params[ind + 1]; + index = params.indexOf("-d"); + if ((index + 1) < params.length()) + checkedDir = params[index + 1]; LoadResults(logFile, checkedDir); } else {