From 7de55b09f8f873bbcd7f41ae97bf72888c30a275 Mon Sep 17 00:00:00 2001 From: Maksim Derbasov Date: Sun, 3 Nov 2019 10:30:30 +0300 Subject: [PATCH] Triage tool ui improvement (#2320) * triage tool: ui improvement * small code tweak * ci fix * ci fix 2nd attempt --- tools/triage/mainwindow.cpp | 16 +- tools/triage/mainwindow.ui | 565 +++++++++++++++++++----------------- 2 files changed, 315 insertions(+), 266 deletions(-) diff --git a/tools/triage/mainwindow.cpp b/tools/triage/mainwindow.cpp index e1f169658..ef4264779 100644 --- a/tools/triage/mainwindow.cpp +++ b/tools/triage/mainwindow.cpp @@ -264,13 +264,19 @@ void MainWindow::findInFilesClicked() { ui->inFilesResult->clear(); const QString text = ui->lineEdit->text(); - const QStringList filter { - "*.cpp","*.cxx","*.cc","*.c++","*.hpp","*.h","*.hxx","*.hh","*.tpp","*.txx","*.C","*.c","*.cl" - }; + QStringList filter; + if(ui->hFilesFilter->isChecked()) { + filter << "*.hpp" << "*.h" << "*.hxx" << "*.hh" << "*.tpp" << "*.txx"; + } + if(ui->srcFilter->isChecked()) { + filter << "*.cpp" << "*.cxx" << "*.cc" << "*.c++" << "*.C" << "*.c" << "*.cl"; + } QMimeDatabase mimeDatabase; QDirIterator it(WORK_FOLDER, filter, QDir::AllEntries | QDir::NoSymLinks | QDir::NoDotAndDotDot, QDirIterator::Subdirectories); + const auto common_path_len = WORK_FOLDER.length() + 1; // let's remove common part of path imporve UI + while (it.hasNext()) { const QString fileName = it.next(); const QMimeType mimeType = mimeDatabase.mimeTypeForFile(fileName); @@ -288,7 +294,7 @@ void MainWindow::findInFilesClicked() { ++lineN; line = in.readLine(); if (line.contains(text, Qt::CaseInsensitive)) { - ui->inFilesResult->addItem(fileName + ":" + QString::number(lineN)); + ui->inFilesResult->addItem(fileName.mid(common_path_len) + QString{":"} + QString::number(lineN)); break; } } @@ -304,5 +310,5 @@ void MainWindow::searchResultsDoubleClick() { QString filename = ui->inFilesResult->currentItem()->text(); const auto idx = filename.lastIndexOf(':'); const int line = filename.midRef(idx + 1).toInt(); - showSrcFile(filename.left(idx), "", line); + showSrcFile(WORK_FOLDER + QString{"/"} + filename.left(idx), "", line); } diff --git a/tools/triage/mainwindow.ui b/tools/triage/mainwindow.ui index c4ec8b886..edaffd814 100644 --- a/tools/triage/mainwindow.ui +++ b/tools/triage/mainwindow.ui @@ -7,7 +7,7 @@ 0 0 1057 - 538 + 637 @@ -16,79 +16,7 @@ - - - - - - - Load from file - - - - - - - Load from clipboard - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - - Show 100 random results - - - - - - - - - Version - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - + @@ -99,7 +27,7 @@ - + url @@ -109,7 +37,7 @@ - + file @@ -122,106 +50,104 @@ - - - - - - - - - 16777215 - 16777215 - - - - filter - - - true - - - - - - - In files - - - - - - - - - - 16777215 - 16777215 - - - - 0 - - - - Filesystem - - - - - 0 - 0 - 341 - 381 - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - true - - - false - - - - - - In Files Result - - - - - 0 - 0 - 341 - 381 - - - - - 0 - 0 - - - - - - - - + + + TopToolBarArea + + + false + + + + + + false + + + QDockWidget::DockWidgetFloatable|QDockWidget::DockWidgetMovable + + + 1 + + + + + + + + + + + Load from file + + + + + + + Load from clipboard + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + Show 100 random results + + + + + + + + + Version + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + @@ -232,15 +158,132 @@ - - - TopToolBarArea - - - false + + + QDockWidget::DockWidgetFloatable|QDockWidget::DockWidgetMovable + + + 2 + + + + + + + + + + + 16777215 + 16777215 + + + + filter + + + true + + + + + + + In files + + + + + + + + + + 16777215 + 16777215 + + + + 0 + + + + Filesystem + + + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + true + + + false + + + + + + + + In Files Result + + + + + + + 0 + 0 + + + + + + + + + + *.h, *.hpp,... + + + true + + + + + + + *.c, *.cpp,... + + + true + + + + + + + + + + + + + - @@ -252,86 +295,6 @@ - - results - itemDoubleClicked(QListWidgetItem*) - MainWindow - showResult(QListWidgetItem*) - - - 28 - 104 - - - 5 - 104 - - - - - loadFile - clicked() - MainWindow - loadFile() - - - 22 - 65 - - - 22 - 46 - - - - - loadFromClipboard - clicked() - MainWindow - loadFromClipboard() - - - 142 - 55 - - - 528 - 268 - - - - - version - currentIndexChanged(QString) - MainWindow - filter(QString) - - - 98 - 489 - - - 493 - 39 - - - - - random100 - clicked() - MainWindow - refreshResults() - - - 30 - 464 - - - 3 - 460 - - - lineEdit textChanged(QString) @@ -396,6 +359,86 @@ + + loadFile + clicked() + MainWindow + loadFile() + + + 22 + 65 + + + 22 + 46 + + + + + loadFromClipboard + clicked() + MainWindow + loadFromClipboard() + + + 142 + 55 + + + 528 + 268 + + + + + random100 + clicked() + MainWindow + refreshResults() + + + 30 + 464 + + + 3 + 460 + + + + + results + itemDoubleClicked(QListWidgetItem*) + MainWindow + showResult(QListWidgetItem*) + + + 28 + 104 + + + 5 + 104 + + + + + version + currentIndexChanged(QString) + MainWindow + filter(QString) + + + 98 + 489 + + + 493 + 39 + + + loadFile()