GUI: Refactor tags

This commit is contained in:
Daniel Marjamäki 2020-07-16 20:19:36 +02:00
parent 0632f86449
commit b249d9be31
4 changed files with 5 additions and 18 deletions

View File

@ -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();

View File

@ -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, [=]() {

View File

@ -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;

View File

@ -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);
/**