2009-03-01 08:38:21 +01:00
|
|
|
/*
|
|
|
|
* Cppcheck - A tool for static C/C++ code analysis
|
2009-05-30 07:48:12 +02:00
|
|
|
* Copyright (C) 2007-2009 Daniel Marjamäki and Cppcheck team.
|
2009-03-01 08:38:21 +01:00
|
|
|
*
|
|
|
|
* 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/
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef RESULTSTREE_H
|
|
|
|
#define RESULTSTREE_H
|
|
|
|
|
|
|
|
#include <QTreeView>
|
|
|
|
#include <QStandardItemModel>
|
|
|
|
#include <QStandardItem>
|
|
|
|
#include <QSettings>
|
2009-05-23 13:26:04 +02:00
|
|
|
#include <QContextMenuEvent>
|
2009-03-22 18:39:44 +01:00
|
|
|
#include "common.h"
|
2009-05-23 13:26:04 +02:00
|
|
|
#include "applicationlist.h"
|
2009-03-01 08:38:21 +01:00
|
|
|
|
2009-05-23 10:17:27 +02:00
|
|
|
|
2009-03-01 08:38:21 +01:00
|
|
|
/**
|
|
|
|
* @brief Cppcheck's results are shown in this tree
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
class ResultsTree : public QTreeView
|
|
|
|
{
|
2009-05-23 13:26:04 +02:00
|
|
|
Q_OBJECT
|
2009-03-01 08:38:21 +01:00
|
|
|
public:
|
2009-05-23 13:26:04 +02:00
|
|
|
ResultsTree(QSettings &settings, ApplicationList &list);
|
2009-03-01 08:38:21 +01:00
|
|
|
virtual ~ResultsTree();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Add a new item to the tree
|
|
|
|
*
|
|
|
|
* @param file filename
|
|
|
|
* @param severity error severity
|
2009-05-23 18:29:24 +02:00
|
|
|
* @param message error message
|
|
|
|
* @param files list of files affected by the error
|
|
|
|
* @param lines list of file line numers affected by the error
|
2009-03-01 08:38:21 +01:00
|
|
|
*/
|
|
|
|
void AddErrorItem(const QString &file,
|
|
|
|
const QString &severity,
|
2009-03-01 21:44:42 +01:00
|
|
|
const QString &message,
|
|
|
|
const QStringList &files,
|
2009-05-23 10:17:27 +02:00
|
|
|
const QVariantList &lines);
|
2009-03-01 08:38:21 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Clear all errors from the tree
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
void Clear();
|
2009-03-22 18:39:44 +01:00
|
|
|
|
2009-06-01 23:52:14 +02:00
|
|
|
/**
|
|
|
|
* @brief Function to show/hide certain type of errors
|
2009-05-23 18:29:24 +02:00
|
|
|
* Refreshes the tree.
|
2009-06-01 23:52:14 +02:00
|
|
|
*
|
|
|
|
* @param type Type of error to show/hide
|
|
|
|
* @param Should specified errors be shown (true) or hidden (false)
|
2009-05-23 18:29:24 +02:00
|
|
|
*/
|
2009-03-22 18:39:44 +01:00
|
|
|
void ShowResults(ShowTypes type, bool show);
|
2009-05-23 13:26:04 +02:00
|
|
|
protected slots:
|
2009-06-01 23:52:14 +02:00
|
|
|
/**
|
|
|
|
* @brief Slot to quickstart an error with default application
|
|
|
|
*
|
|
|
|
* @param index Model index to specify which error item to open
|
2009-05-23 18:29:24 +02:00
|
|
|
*/
|
2009-05-23 17:45:05 +02:00
|
|
|
void QuickStartApplication(const QModelIndex &index);
|
2009-05-23 18:29:24 +02:00
|
|
|
|
2009-05-23 13:26:04 +02:00
|
|
|
/**
|
|
|
|
* @brief Slot for context menu item to open an error with specified application
|
|
|
|
*
|
|
|
|
* @param application Index of the application to open the error
|
|
|
|
*/
|
|
|
|
void Context(int application);
|
2009-03-01 08:38:21 +01:00
|
|
|
protected:
|
2009-06-01 23:52:14 +02:00
|
|
|
/**
|
|
|
|
* @brief Convert a severity string to a icon filename
|
|
|
|
*
|
|
|
|
* @param severity Severity string
|
|
|
|
* @param Icon filename
|
2009-05-26 17:21:39 +02:00
|
|
|
*/
|
|
|
|
QString SeverityToIcon(const QString &severity);
|
2009-05-23 18:29:24 +02:00
|
|
|
|
2009-06-01 23:52:14 +02:00
|
|
|
/**
|
2009-05-23 18:29:24 +02:00
|
|
|
* @brief Helper function to open an error within target with application
|
2009-06-01 23:52:14 +02:00
|
|
|
*
|
|
|
|
*
|
|
|
|
* @param target Error tree item to open
|
|
|
|
* @param application Index of the application to open with
|
2009-05-23 18:29:24 +02:00
|
|
|
*/
|
2009-05-23 17:45:05 +02:00
|
|
|
void StartApplication(QStandardItem *target, int application);
|
2009-05-23 18:29:24 +02:00
|
|
|
|
2009-06-01 23:52:14 +02:00
|
|
|
/**
|
|
|
|
* @brief Context menu event (user right clicked on the tree)
|
|
|
|
*
|
|
|
|
* @param e Event
|
2009-05-23 18:29:24 +02:00
|
|
|
*/
|
2009-05-23 13:26:04 +02:00
|
|
|
void contextMenuEvent(QContextMenuEvent * e);
|
|
|
|
|
2009-06-01 23:52:14 +02:00
|
|
|
/**
|
|
|
|
* @brief Add a new error item beneath a file or a backtrace item beneath an error
|
|
|
|
*
|
|
|
|
* @param parent Parent for the item. Either a file item or an error item
|
2009-05-23 18:29:24 +02:00
|
|
|
* @param file Filename of the error
|
|
|
|
* @param line Line numer
|
|
|
|
* @param severity Error severity
|
|
|
|
* @param message Error message
|
2009-05-26 17:21:39 +02:00
|
|
|
* @param hide Should this be hidden (true) or shown (false)
|
2009-06-01 23:52:14 +02:00
|
|
|
* @param addicon Should a default backtrace item icon be added
|
|
|
|
* @return newly created QStandardItem *
|
2009-05-23 18:29:24 +02:00
|
|
|
*/
|
2009-05-23 10:17:27 +02:00
|
|
|
QStandardItem *AddBacktraceFiles(QStandardItem *parent,
|
2009-05-23 13:26:04 +02:00
|
|
|
const QString &file,
|
|
|
|
const int line,
|
|
|
|
const QString &severity,
|
|
|
|
const QString &message,
|
2009-05-26 17:21:39 +02:00
|
|
|
const bool hide,
|
|
|
|
const QString &icon);
|
2009-05-23 10:17:27 +02:00
|
|
|
|
2009-05-23 18:29:24 +02:00
|
|
|
|
2009-06-01 23:52:14 +02:00
|
|
|
/**
|
2009-05-23 18:29:24 +02:00
|
|
|
* @brief Refresh tree by checking which of the items should be shown
|
2009-06-01 23:52:14 +02:00
|
|
|
* and which should be hidden
|
|
|
|
*
|
2009-05-23 18:29:24 +02:00
|
|
|
*/
|
2009-03-22 18:39:44 +01:00
|
|
|
void RefreshTree();
|
2009-05-23 18:29:24 +02:00
|
|
|
|
2009-06-01 23:52:14 +02:00
|
|
|
/**
|
|
|
|
* @brief Convert QVariant (that contains an int) to Showtypes value
|
|
|
|
*
|
|
|
|
* @param data QVariant (that contains an int) to be converted
|
|
|
|
* @return data converted to ShowTypes
|
2009-05-23 18:29:24 +02:00
|
|
|
*/
|
2009-05-23 10:17:27 +02:00
|
|
|
ShowTypes VariantToShowType(const QVariant &data);
|
2009-05-23 18:29:24 +02:00
|
|
|
|
2009-06-01 23:52:14 +02:00
|
|
|
/**
|
|
|
|
* @brief Convert severity string to ShowTypes value
|
2009-05-23 18:29:24 +02:00
|
|
|
* @param severity Error severity string
|
2009-06-01 23:52:14 +02:00
|
|
|
* @return Severity converted to ShowTypes value
|
2009-05-23 18:29:24 +02:00
|
|
|
*/
|
2009-03-22 18:39:44 +01:00
|
|
|
ShowTypes SeverityToShowType(const QString &severity);
|
|
|
|
|
2009-03-01 08:38:21 +01:00
|
|
|
/**
|
|
|
|
* @brief Load all settings
|
|
|
|
* Colum widths
|
|
|
|
*/
|
|
|
|
void LoadSettings();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Save all settings
|
|
|
|
* Colum widths
|
|
|
|
*/
|
|
|
|
void SaveSettings();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Create a new QStandardItem
|
|
|
|
*
|
|
|
|
* @param name name for the item
|
|
|
|
* @return new QStandardItem
|
|
|
|
*/
|
|
|
|
QStandardItem *CreateItem(const QString &name);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Finds a file item
|
|
|
|
*
|
|
|
|
* @param name name of the file item to find
|
|
|
|
* @return pointer to file item or null if none found
|
|
|
|
*/
|
|
|
|
QStandardItem *FindFileItem(const QString &name);
|
|
|
|
|
2009-05-23 10:17:27 +02:00
|
|
|
|
2009-05-23 13:26:04 +02:00
|
|
|
/**
|
|
|
|
* @brief Ensures there's a item in the model for the specified file
|
|
|
|
*
|
|
|
|
* @param name Filename
|
|
|
|
* @return QStandardItem to be used as a parent for all errors for specified file
|
2009-05-23 10:17:27 +02:00
|
|
|
*/
|
|
|
|
QStandardItem *EnsureFileItem(const QString &name);
|
|
|
|
|
2009-05-23 13:26:04 +02:00
|
|
|
/**
|
|
|
|
* @brief Show a file item
|
|
|
|
*
|
|
|
|
* @param name Filename of the fileitem
|
2009-05-23 10:17:27 +02:00
|
|
|
*/
|
|
|
|
void ShowFileItem(const QString &name);
|
|
|
|
|
2009-03-01 08:38:21 +01:00
|
|
|
/**
|
|
|
|
* @brief Item model for tree
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
QStandardItemModel mModel;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Program settings
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
QSettings &mSettings;
|
2009-03-22 18:39:44 +01:00
|
|
|
|
2009-06-01 23:52:14 +02:00
|
|
|
/**
|
2009-05-23 18:29:24 +02:00
|
|
|
* @brief List of bools to determine which of ShowTypes to display on the tree
|
2009-06-01 23:52:14 +02:00
|
|
|
* (true) and which of them should be hidden (false)
|
|
|
|
*
|
2009-05-23 18:29:24 +02:00
|
|
|
*/
|
2009-03-22 18:39:44 +01:00
|
|
|
bool mShowTypes[SHOW_NONE];
|
2009-05-23 13:26:04 +02:00
|
|
|
|
2009-06-01 23:52:14 +02:00
|
|
|
/**
|
|
|
|
* @brief List of applications to open errors with
|
|
|
|
*
|
2009-05-23 18:29:24 +02:00
|
|
|
*/
|
2009-05-23 13:26:04 +02:00
|
|
|
ApplicationList &mApplications;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Right clicked item (used by context menu slots)
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
QStandardItem *mContextItem;
|
2009-03-01 08:38:21 +01:00
|
|
|
private:
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // RESULTSTREE_H
|