2022-01-28 15:56:11 +01:00
|
|
|
/*
|
|
|
|
* Cppcheck - A tool for static C/C++ code analysis
|
|
|
|
* Copyright (C) 2007-2021 Cppcheck team.
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2018-01-01 09:22:11 +01:00
|
|
|
#include "mainwindow.h"
|
2022-02-02 16:17:28 +01:00
|
|
|
|
2018-01-01 09:22:11 +01:00
|
|
|
#include "ui_mainwindow.h"
|
2022-02-02 16:17:28 +01:00
|
|
|
|
|
|
|
#include <cstdlib>
|
|
|
|
#include <ctime>
|
|
|
|
|
2018-01-01 09:22:11 +01:00
|
|
|
#include <QClipboard>
|
|
|
|
#include <QDir>
|
2019-11-01 09:29:00 +01:00
|
|
|
#include <QDirIterator>
|
2022-02-02 16:17:28 +01:00
|
|
|
#include <QFile>
|
2018-01-02 23:39:30 +01:00
|
|
|
#include <QFileDialog>
|
2022-02-02 16:17:28 +01:00
|
|
|
#include <QFileInfo>
|
2019-11-01 09:29:00 +01:00
|
|
|
#include <QMimeDatabase>
|
2022-02-02 16:17:28 +01:00
|
|
|
#include <QProcess>
|
|
|
|
#include <QProgressDialog>
|
2022-03-23 18:16:22 +01:00
|
|
|
#include <QRegularExpression>
|
2022-02-02 16:17:28 +01:00
|
|
|
#include <QTextStream>
|
2018-01-01 09:22:11 +01:00
|
|
|
|
|
|
|
const QString WORK_FOLDER(QDir::homePath() + "/triage");
|
2018-02-08 22:18:50 +01:00
|
|
|
const QString DACA2_PACKAGES(QDir::homePath() + "/daca2-packages");
|
2018-01-01 09:22:11 +01:00
|
|
|
|
2019-03-09 11:01:22 +01:00
|
|
|
const int MAX_ERRORS = 100;
|
|
|
|
|
2018-01-01 09:22:11 +01:00
|
|
|
MainWindow::MainWindow(QWidget *parent) :
|
|
|
|
QMainWindow(parent),
|
2019-11-04 07:10:31 +01:00
|
|
|
ui(new Ui::MainWindow),
|
2022-03-23 18:16:22 +01:00
|
|
|
mVersionRe("^(master|main|your|head|[12].[0-9][0-9]?) (.*)$"),
|
2021-08-09 10:46:56 +02:00
|
|
|
hFiles{"*.hpp", "*.h", "*.hxx", "*.hh", "*.tpp", "*.txx", "*.ipp", "*.ixx"},
|
2019-11-04 07:10:31 +01:00
|
|
|
srcFiles{"*.cpp", "*.cxx", "*.cc", "*.c++", "*.C", "*.c", "*.cl"}
|
2018-01-01 09:22:11 +01:00
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
2022-03-11 21:42:46 +01:00
|
|
|
std::srand(static_cast<unsigned int>(std::time(nullptr)));
|
2019-01-12 09:16:43 +01:00
|
|
|
QDir workFolder(WORK_FOLDER);
|
|
|
|
if (!workFolder.exists()) {
|
|
|
|
workFolder.mkdir(WORK_FOLDER);
|
|
|
|
}
|
2019-11-04 07:10:31 +01:00
|
|
|
|
2021-12-22 18:58:11 +01:00
|
|
|
ui->results->setContextMenuPolicy(Qt::CustomContextMenu);
|
|
|
|
connect(ui->results, &QListWidget::customContextMenuRequested,
|
|
|
|
this, &MainWindow::resultsContextMenu);
|
|
|
|
|
2019-11-04 07:10:31 +01:00
|
|
|
mFSmodel.setRootPath(WORK_FOLDER);
|
|
|
|
mFSmodel.setReadOnly(true);
|
|
|
|
mFSmodel.setFilter(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot);
|
|
|
|
ui->directoryTree->setModel(&mFSmodel);
|
2019-11-01 09:29:00 +01:00
|
|
|
QHeaderView * header = ui->directoryTree->header();
|
2021-01-06 17:13:44 +01:00
|
|
|
for (int i = 1; i < header->length(); ++i) // hide all except [0]
|
2019-11-01 09:29:00 +01:00
|
|
|
header->hideSection(i);
|
2019-11-04 07:10:31 +01:00
|
|
|
ui->directoryTree->setRootIndex(mFSmodel.index(WORK_FOLDER));
|
|
|
|
|
|
|
|
ui->hFilesFilter->setToolTip(hFiles.join(','));
|
|
|
|
ui->srcFilesFilter->setToolTip(srcFiles.join(','));
|
2018-01-01 09:22:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
MainWindow::~MainWindow()
|
|
|
|
{
|
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
|
2018-01-02 23:39:30 +01:00
|
|
|
void MainWindow::loadFile()
|
2018-01-01 09:22:11 +01:00
|
|
|
{
|
2019-01-12 09:16:43 +01:00
|
|
|
ui->statusBar->clearMessage();
|
2020-01-03 19:33:42 +01:00
|
|
|
const QString fileName = QFileDialog::getOpenFileName(this, tr("daca results file"), WORK_FOLDER, tr("Text files (*.txt *.log);;All (*.*)"));
|
2018-01-02 23:39:30 +01:00
|
|
|
if (fileName.isEmpty())
|
|
|
|
return;
|
|
|
|
QFile file(fileName);
|
|
|
|
file.open(QIODevice::ReadOnly | QIODevice::Text);
|
|
|
|
QTextStream textStream(&file);
|
2019-01-14 17:49:10 +01:00
|
|
|
load(textStream);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::loadFromClipboard()
|
|
|
|
{
|
|
|
|
ui->statusBar->clearMessage();
|
|
|
|
QString clipboardContent = QApplication::clipboard()->text();
|
|
|
|
QTextStream textStream(&clipboardContent);
|
|
|
|
load(textStream);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::load(QTextStream &textStream)
|
|
|
|
{
|
2018-01-01 09:22:11 +01:00
|
|
|
QString url;
|
2018-02-04 09:12:41 +01:00
|
|
|
QString errorMessage;
|
2019-03-09 11:01:22 +01:00
|
|
|
QStringList versions;
|
|
|
|
mAllErrors.clear();
|
2018-01-02 23:39:30 +01:00
|
|
|
while (true) {
|
2019-01-01 17:01:23 +01:00
|
|
|
QString line = textStream.readLine();
|
2018-01-02 23:39:30 +01:00
|
|
|
if (line.isNull())
|
|
|
|
break;
|
2018-02-04 09:12:41 +01:00
|
|
|
if (line.startsWith("ftp://")) {
|
2018-01-01 09:22:11 +01:00
|
|
|
url = line;
|
2019-01-01 17:01:23 +01:00
|
|
|
if (!errorMessage.isEmpty())
|
2019-03-09 11:01:22 +01:00
|
|
|
mAllErrors << errorMessage;
|
2018-02-04 09:12:41 +01:00
|
|
|
errorMessage.clear();
|
2022-04-11 19:15:42 +02:00
|
|
|
} else if (!url.isEmpty()) {
|
|
|
|
static const QRegularExpression severityRe("^.*: (error|warning|style|note):.*$");
|
|
|
|
if (severityRe.match(line).hasMatch())
|
|
|
|
continue;
|
2022-03-23 18:16:22 +01:00
|
|
|
const QRegularExpressionMatch matchRes = mVersionRe.match(line);
|
|
|
|
if (matchRes.hasMatch()) {
|
|
|
|
const QString version = matchRes.captured(1);
|
2019-03-09 11:01:22 +01:00
|
|
|
if (versions.indexOf(version) < 0)
|
|
|
|
versions << version;
|
|
|
|
}
|
2018-11-24 21:36:59 +01:00
|
|
|
if (line.indexOf(": note:") > 0)
|
|
|
|
errorMessage += '\n' + line;
|
|
|
|
else if (errorMessage.isEmpty()) {
|
|
|
|
errorMessage = url + '\n' + line;
|
|
|
|
} else {
|
2019-03-09 11:01:22 +01:00
|
|
|
mAllErrors << errorMessage;
|
2018-11-24 21:36:59 +01:00
|
|
|
errorMessage = url + '\n' + line;
|
|
|
|
}
|
2018-01-01 09:22:11 +01:00
|
|
|
}
|
|
|
|
}
|
2018-11-24 21:36:59 +01:00
|
|
|
if (!errorMessage.isEmpty())
|
2019-03-09 11:01:22 +01:00
|
|
|
mAllErrors << errorMessage;
|
|
|
|
|
|
|
|
ui->version->clear();
|
|
|
|
if (versions.size() > 1)
|
|
|
|
ui->version->addItem("");
|
|
|
|
ui->version->addItems(versions);
|
|
|
|
|
|
|
|
filter("");
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::refreshResults()
|
|
|
|
{
|
|
|
|
filter(ui->version->currentText());
|
|
|
|
}
|
|
|
|
|
2022-05-08 20:42:06 +02:00
|
|
|
void MainWindow::filter(const QString& filter)
|
2019-03-09 11:01:22 +01:00
|
|
|
{
|
|
|
|
QStringList allErrors;
|
|
|
|
|
2019-06-30 21:43:25 +02:00
|
|
|
for (const QString &errorItem : mAllErrors) {
|
2019-03-09 11:01:22 +01:00
|
|
|
if (filter.isEmpty()) {
|
|
|
|
allErrors << errorItem;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
const QStringList lines = errorItem.split("\n");
|
|
|
|
if (lines.size() < 2)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (lines[1].startsWith(filter))
|
|
|
|
allErrors << errorItem;
|
|
|
|
}
|
|
|
|
|
|
|
|
ui->results->clear();
|
|
|
|
|
|
|
|
if (ui->random100->isChecked() && allErrors.size() > MAX_ERRORS) {
|
2018-02-09 21:44:53 +01:00
|
|
|
// remove items in /test/
|
2019-03-09 11:01:22 +01:00
|
|
|
for (int i = allErrors.size() - 1; i >= 0 && allErrors.size() > MAX_ERRORS; --i) {
|
2018-02-09 21:44:53 +01:00
|
|
|
if (allErrors[i].indexOf("test") > 0)
|
|
|
|
allErrors.removeAt(i);
|
|
|
|
}
|
2018-02-04 16:14:33 +01:00
|
|
|
std::random_shuffle(allErrors.begin(), allErrors.end());
|
2019-11-04 07:10:31 +01:00
|
|
|
ui->results->addItems(allErrors.mid(0, MAX_ERRORS));
|
2018-05-02 12:59:34 +02:00
|
|
|
ui->results->sortItems();
|
2018-02-04 16:14:33 +01:00
|
|
|
} else {
|
|
|
|
ui->results->addItems(allErrors);
|
|
|
|
}
|
2018-01-01 09:22:11 +01:00
|
|
|
}
|
|
|
|
|
2019-01-12 09:16:43 +01:00
|
|
|
bool MainWindow::runProcess(const QString &programName, const QStringList &arguments)
|
2018-02-08 22:18:50 +01:00
|
|
|
{
|
2021-06-13 10:51:42 +02:00
|
|
|
QProgressDialog dialog("Running external process: " + programName, "Kill", 0 /*min*/, 1 /*max*/, this);
|
|
|
|
dialog.setWindowModality(Qt::WindowModal);
|
|
|
|
dialog.setMinimumDuration(0 /*msec*/);
|
|
|
|
dialog.setValue(0);
|
|
|
|
|
2018-02-08 22:18:50 +01:00
|
|
|
QProcess process;
|
|
|
|
process.setWorkingDirectory(WORK_FOLDER);
|
2021-06-13 10:51:42 +02:00
|
|
|
process.start(programName, arguments); // async action
|
|
|
|
|
|
|
|
bool success = false;
|
|
|
|
bool state = (QProcess::Running == process.state() || QProcess::Starting == process.state());
|
|
|
|
while (!success && state) {
|
|
|
|
success = process.waitForFinished(50 /*msec*/);
|
|
|
|
// Not the best way to keep UI unfreeze, keep work async in other thread much more a Qt style
|
|
|
|
QCoreApplication::processEvents();
|
|
|
|
if (dialog.wasCanceled()) {
|
|
|
|
process.kill();
|
|
|
|
success = false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
state = (QProcess::Running == process.state() || QProcess::Starting == process.state());
|
|
|
|
}
|
|
|
|
dialog.setValue(1);
|
2019-01-12 09:16:43 +01:00
|
|
|
if (!success) {
|
|
|
|
QString errorstr(programName);
|
|
|
|
errorstr.append(": ");
|
|
|
|
errorstr.append(process.errorString());
|
|
|
|
ui->statusBar->showMessage(errorstr);
|
|
|
|
} else {
|
|
|
|
int exitCode = process.exitCode();
|
|
|
|
if (exitCode != 0) {
|
|
|
|
success = false;
|
|
|
|
const QByteArray stderrOutput = process.readAllStandardError();
|
|
|
|
QString errorstr(programName);
|
|
|
|
errorstr.append(QString(": exited with %1: ").arg(exitCode));
|
|
|
|
errorstr.append(stderrOutput);
|
|
|
|
ui->statusBar->showMessage(errorstr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return success;
|
|
|
|
}
|
|
|
|
|
2019-02-16 17:52:36 +01:00
|
|
|
bool MainWindow::wget(const QString &url)
|
2019-01-12 09:16:43 +01:00
|
|
|
{
|
2019-11-04 07:10:31 +01:00
|
|
|
return runProcess("wget", QStringList{url});
|
2018-02-08 22:18:50 +01:00
|
|
|
}
|
|
|
|
|
2019-02-16 17:52:36 +01:00
|
|
|
bool MainWindow::unpackArchive(const QString &archiveName)
|
2018-02-08 22:18:50 +01:00
|
|
|
{
|
|
|
|
// Unpack archive
|
|
|
|
QStringList args;
|
2019-01-12 09:16:43 +01:00
|
|
|
#ifdef Q_OS_WIN
|
|
|
|
/* On Windows --force-local is necessary because tar wants to connect to a remote system
|
|
|
|
* when a colon is found in the archiveName. So "C:/Users/blah/triage/package" would not work
|
|
|
|
* without it. */
|
|
|
|
args << "--force-local";
|
|
|
|
#endif
|
2018-02-08 22:18:50 +01:00
|
|
|
if (archiveName.endsWith(".tar.gz"))
|
2019-01-12 09:16:43 +01:00
|
|
|
args << "-xzvf";
|
2018-02-08 22:18:50 +01:00
|
|
|
else if (archiveName.endsWith(".tar.bz2"))
|
2019-01-12 09:16:43 +01:00
|
|
|
args << "-xjvf";
|
2018-02-08 22:18:50 +01:00
|
|
|
else if (archiveName.endsWith(".tar.xz"))
|
2019-01-12 09:16:43 +01:00
|
|
|
args << "-xJvf";
|
|
|
|
else {
|
|
|
|
// Try to automatically find an (un)compressor for this archive
|
|
|
|
args << "-xavf";
|
|
|
|
}
|
2018-02-08 22:18:50 +01:00
|
|
|
args << archiveName;
|
|
|
|
|
2019-01-12 09:16:43 +01:00
|
|
|
return runProcess("tar", args);
|
2018-02-08 22:18:50 +01:00
|
|
|
}
|
|
|
|
|
2018-01-01 09:22:11 +01:00
|
|
|
void MainWindow::showResult(QListWidgetItem *item)
|
|
|
|
{
|
2019-01-12 09:16:43 +01:00
|
|
|
ui->statusBar->clearMessage();
|
2018-01-01 09:22:11 +01:00
|
|
|
if (!item->text().startsWith("ftp://"))
|
|
|
|
return;
|
|
|
|
const QStringList lines = item->text().split("\n");
|
2018-02-04 09:12:41 +01:00
|
|
|
if (lines.size() < 2)
|
2018-01-01 09:22:11 +01:00
|
|
|
return;
|
|
|
|
const QString url = lines[0];
|
2018-08-29 22:07:31 +02:00
|
|
|
QString msg = lines[1];
|
2022-03-23 18:16:22 +01:00
|
|
|
const QRegularExpressionMatch matchRes = mVersionRe.match(msg);
|
|
|
|
if (matchRes.hasMatch())
|
|
|
|
msg = matchRes.captured(2);
|
2018-01-01 09:22:11 +01:00
|
|
|
const QString archiveName = url.mid(url.lastIndexOf("/") + 1);
|
|
|
|
const int pos1 = msg.indexOf(":");
|
|
|
|
const int pos2 = msg.indexOf(":", pos1+1);
|
2019-01-12 09:16:43 +01:00
|
|
|
const QString fileName = WORK_FOLDER + '/' + msg.left(msg.indexOf(":"));
|
2022-04-15 18:49:24 +02:00
|
|
|
const int lineNumber = msg.mid(pos1+1, pos2-pos1-1).toInt();
|
2018-01-01 09:22:11 +01:00
|
|
|
|
2019-02-16 17:52:36 +01:00
|
|
|
if (!QFileInfo::exists(fileName)) {
|
2019-11-04 07:10:31 +01:00
|
|
|
const QString daca2archiveFile {DACA2_PACKAGES + '/' + archiveName.mid(0,archiveName.indexOf(".tar.")) + ".tar.xz"};
|
|
|
|
if (QFileInfo::exists(daca2archiveFile)) {
|
|
|
|
if (!unpackArchive(daca2archiveFile))
|
2018-02-08 22:18:50 +01:00
|
|
|
return;
|
|
|
|
} else {
|
2019-11-04 07:10:31 +01:00
|
|
|
const QString archiveFullPath {WORK_FOLDER + '/' + archiveName};
|
|
|
|
if (!QFileInfo::exists(archiveFullPath)) {
|
2018-02-08 22:18:50 +01:00
|
|
|
// Download archive
|
|
|
|
if (!wget(url))
|
|
|
|
return;
|
|
|
|
}
|
2019-11-04 07:10:31 +01:00
|
|
|
if (!unpackArchive(archiveFullPath))
|
2018-02-08 22:18:50 +01:00
|
|
|
return;
|
|
|
|
}
|
2018-01-01 10:52:51 +01:00
|
|
|
}
|
2019-11-01 09:29:00 +01:00
|
|
|
showSrcFile(fileName, url, lineNumber);
|
|
|
|
}
|
2018-01-01 09:22:11 +01:00
|
|
|
|
2019-11-01 09:29:00 +01:00
|
|
|
void MainWindow::showSrcFile(const QString &fileName, const QString &url, const int lineNumber)
|
|
|
|
{
|
2018-01-01 09:22:11 +01:00
|
|
|
// Open file
|
|
|
|
ui->code->setFocus();
|
2019-01-12 09:16:43 +01:00
|
|
|
QFile f(fileName);
|
|
|
|
if (!f.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
|
|
|
const QString errorMsg =
|
2019-02-16 17:52:36 +01:00
|
|
|
QString("Opening file %1 failed: %2").arg(f.fileName(), f.errorString());
|
2019-01-12 09:16:43 +01:00
|
|
|
ui->statusBar->showMessage(errorMsg);
|
|
|
|
} else {
|
|
|
|
QTextStream textStream(&f);
|
|
|
|
const QString fileData = textStream.readAll();
|
|
|
|
ui->code->setError(fileData, lineNumber, QStringList());
|
|
|
|
f.close();
|
2019-11-04 07:10:31 +01:00
|
|
|
|
|
|
|
ui->urlEdit->setText(url);
|
|
|
|
ui->fileEdit->setText(fileName);
|
|
|
|
ui->directoryTree->setCurrentIndex(mFSmodel.index(fileName));
|
2019-11-01 09:29:00 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-11 21:42:46 +01:00
|
|
|
void MainWindow::fileTreeFilter(const QString &str)
|
2019-11-04 07:10:31 +01:00
|
|
|
{
|
|
|
|
mFSmodel.setNameFilters(QStringList{"*" + str + "*"});
|
|
|
|
mFSmodel.setNameFilterDisables(false);
|
2019-11-01 09:29:00 +01:00
|
|
|
}
|
|
|
|
|
2019-11-04 07:10:31 +01:00
|
|
|
void MainWindow::findInFilesClicked()
|
|
|
|
{
|
2019-11-01 09:29:00 +01:00
|
|
|
ui->tabWidget->setCurrentIndex(1);
|
|
|
|
ui->inFilesResult->clear();
|
2019-11-04 07:10:31 +01:00
|
|
|
const QString text = ui->filterEdit->text();
|
2019-11-01 09:29:00 +01:00
|
|
|
|
2019-11-03 08:30:30 +01:00
|
|
|
QStringList filter;
|
2021-01-06 17:13:44 +01:00
|
|
|
if (ui->hFilesFilter->isChecked())
|
2019-11-04 07:10:31 +01:00
|
|
|
filter.append(hFiles);
|
2021-01-06 17:13:44 +01:00
|
|
|
if (ui->srcFilesFilter->isChecked())
|
2019-11-04 07:10:31 +01:00
|
|
|
filter.append(srcFiles);
|
2019-11-01 09:29:00 +01:00
|
|
|
|
|
|
|
QMimeDatabase mimeDatabase;
|
|
|
|
QDirIterator it(WORK_FOLDER, filter, QDir::AllEntries | QDir::NoSymLinks | QDir::NoDotAndDotDot, QDirIterator::Subdirectories);
|
|
|
|
|
2019-11-19 20:02:24 +01:00
|
|
|
const auto common_path_len = WORK_FOLDER.length() + 1; // let's remove common part of path improve UI
|
2019-11-03 08:30:30 +01:00
|
|
|
|
2019-11-01 09:29:00 +01:00
|
|
|
while (it.hasNext()) {
|
|
|
|
const QString fileName = it.next();
|
|
|
|
const QMimeType mimeType = mimeDatabase.mimeTypeForFile(fileName);
|
|
|
|
|
|
|
|
if (mimeType.isValid() && !mimeType.inherits(QStringLiteral("text/plain"))) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
QFile file(fileName);
|
|
|
|
if (file.open(QIODevice::ReadOnly)) {
|
|
|
|
int lineN = 0;
|
|
|
|
QTextStream in(&file);
|
|
|
|
while (!in.atEnd()) {
|
|
|
|
++lineN;
|
2022-03-21 16:05:38 +01:00
|
|
|
QString line = in.readLine();
|
2019-11-01 09:29:00 +01:00
|
|
|
if (line.contains(text, Qt::CaseInsensitive)) {
|
2019-11-03 08:30:30 +01:00
|
|
|
ui->inFilesResult->addItem(fileName.mid(common_path_len) + QString{":"} + QString::number(lineN));
|
2019-11-01 09:29:00 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-01-12 09:16:43 +01:00
|
|
|
}
|
2018-01-01 09:22:11 +01:00
|
|
|
}
|
2019-11-01 09:29:00 +01:00
|
|
|
|
2019-11-04 07:10:31 +01:00
|
|
|
void MainWindow::directorytreeDoubleClick()
|
|
|
|
{
|
|
|
|
showSrcFile(mFSmodel.filePath(ui->directoryTree->currentIndex()), "", 1);
|
2019-11-01 09:29:00 +01:00
|
|
|
}
|
|
|
|
|
2019-11-04 07:10:31 +01:00
|
|
|
void MainWindow::searchResultsDoubleClick()
|
|
|
|
{
|
2019-11-01 09:29:00 +01:00
|
|
|
QString filename = ui->inFilesResult->currentItem()->text();
|
|
|
|
const auto idx = filename.lastIndexOf(':');
|
2022-04-15 18:49:24 +02:00
|
|
|
const int line = filename.mid(idx + 1).toInt();
|
2019-11-03 08:30:30 +01:00
|
|
|
showSrcFile(WORK_FOLDER + QString{"/"} + filename.left(idx), "", line);
|
2019-11-01 09:29:00 +01:00
|
|
|
}
|
2021-12-22 18:58:11 +01:00
|
|
|
|
|
|
|
void MainWindow::resultsContextMenu(const QPoint& pos)
|
|
|
|
{
|
|
|
|
if (ui->results->selectedItems().isEmpty())
|
|
|
|
return;
|
|
|
|
QMenu submenu;
|
|
|
|
submenu.addAction("Copy");
|
|
|
|
QAction* menuItem = submenu.exec(ui->results->mapToGlobal(pos));
|
|
|
|
if (menuItem && menuItem->text().contains("Copy"))
|
|
|
|
{
|
|
|
|
QString text;
|
|
|
|
for (const auto *res: ui->results->selectedItems())
|
|
|
|
text += res->text() + "\n";
|
|
|
|
QApplication::clipboard()->setText(text);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|