From b249d9be313dec9fcb7fe58f0dfb1413a39fb7c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Thu, 16 Jul 2020 20:19:36 +0200 Subject: [PATCH] GUI: Refactor tags --- gui/mainwindow.cpp | 4 ---- gui/resultstree.cpp | 9 +++++---- gui/resultstree.h | 6 ------ gui/resultsview.h | 4 ---- 4 files changed, 5 insertions(+), 18 deletions(-) diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index e721b605c..eab66d82f 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -1524,8 +1524,6 @@ QString MainWindow::getLastResults() const bool MainWindow::loadLastResults() { - if (mProjectFile) - mUI.mResults->setTags(mProjectFile->getTags()); const QString &lastResults = getLastResults(); if (lastResults.isEmpty()) return false; @@ -1548,7 +1546,6 @@ void MainWindow::analyzeProject(const ProjectFile *projectFile, const bool check QDir::setCurrent(inf.absolutePath()); mThread->setAddonsAndTools(projectFile->getAddonsAndTools()); - mUI.mResults->setTags(projectFile->getTags()); // If the root path is not given or is not "current dir", use project // file's location directory as root path @@ -1652,7 +1649,6 @@ void MainWindow::closeProjectFile() delete mProjectFile; mProjectFile = nullptr; mUI.mResults->clear(true); - mUI.mResults->setTags(QStringList()); enableProjectActions(false); enableProjectOpenActions(true); formatAndSetTitle(); diff --git a/gui/resultstree.cpp b/gui/resultstree.cpp index 27274c176..48e481b4f 100644 --- a/gui/resultstree.cpp +++ b/gui/resultstree.cpp @@ -50,8 +50,8 @@ #include "xmlreportv2.h" // These must match column headers given in ResultsTree::translate() -static const unsigned int COLUMN_SINCE_DATE = 6; -static const unsigned int COLUMN_TAGS = 7; +static const int COLUMN_SINCE_DATE = 6; +static const int COLUMN_TAGS = 7; static QString getFunction(QStandardItem *item) { @@ -673,7 +673,8 @@ void ResultsTree::contextMenuEvent(QContextMenuEvent * e) connect(suppressCppcheckID, &QAction::triggered, this, &ResultsTree::suppressCppcheckID); connect(opencontainingfolder, SIGNAL(triggered()), this, SLOT(openContainingFolder())); - if (!mTags.isEmpty()) { + const ProjectFile *currentProject = ProjectFile::getActiveProject(); + if (currentProject && !currentProject->getTags().isEmpty()) { menu.addSeparator(); QMenu *tagMenu = menu.addMenu(tr("Tag")); { @@ -684,7 +685,7 @@ void ResultsTree::contextMenuEvent(QContextMenuEvent * e) }); } - foreach (const QString tagstr, mTags) { + foreach (const QString tagstr, currentProject->getTags()) { QAction *action = new QAction(tagstr, tagMenu); tagMenu->addAction(action); connect(action, &QAction::triggered, [=]() { diff --git a/gui/resultstree.h b/gui/resultstree.h index 349ea855f..cc7dacd35 100644 --- a/gui/resultstree.h +++ b/gui/resultstree.h @@ -52,10 +52,6 @@ public: virtual ~ResultsTree(); void initialize(QSettings *settings, ApplicationList *list, ThreadHandler *checkThreadHandler); - void setTags(const QStringList &tags) { - mTags = tags; - } - /** * @brief Add a new item to the tree * @@ -532,8 +528,6 @@ private: /** @brief Convert GUI error item into data error item */ void readErrorItem(const QStandardItem *error, ErrorItem *item) const; - QStringList mTags; - QStringList mHiddenMessageId; QItemSelectionModel *mSelectionModel; diff --git a/gui/resultsview.h b/gui/resultsview.h index bd623b836..15f98e9cb 100644 --- a/gui/resultsview.h +++ b/gui/resultsview.h @@ -50,10 +50,6 @@ public: virtual ~ResultsView(); ResultsView &operator=(const ResultsView &) = delete; - void setTags(const QStringList &tags) { - mUI.mTree->setTags(tags); - } - void setAddedContracts(const QStringList &addedContracts); /**