forked from qt-creator/qt-creator
Tasks: Create a container class for category data
Reduce the number of arguments that need to be passed around. Change-Id: I9fbfdcdf7b20f8f26e35f435bf8d65ba483e4114 Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -77,7 +77,7 @@ ClangCodeModelPlugin::~ClangCodeModelPlugin()
|
||||
|
||||
void ClangCodeModelPlugin::initialize()
|
||||
{
|
||||
TaskHub::addCategory(Constants::TASK_CATEGORY_DIAGNOSTICS, Tr::tr("Clang Code Model"));
|
||||
TaskHub::addCategory({Constants::TASK_CATEGORY_DIAGNOSTICS, Tr::tr("Clang Code Model")});
|
||||
CppEditor::CppModelManager::instance()->activateClangCodeModel(
|
||||
std::make_unique<ClangModelManagerSupport>());
|
||||
createCompilationDBAction();
|
||||
|
@@ -89,7 +89,7 @@ ClangToolsPlugin::~ClangToolsPlugin()
|
||||
|
||||
void ClangToolsPlugin::initialize()
|
||||
{
|
||||
TaskHub::addCategory(taskCategory(), Tr::tr("Clang Tools"));
|
||||
TaskHub::addCategory({taskCategory(), Tr::tr("Clang Tools")});
|
||||
|
||||
// Import tidy/clazy diagnostic configs from CppEditor now
|
||||
// instead of at opening time of the settings page
|
||||
|
@@ -723,7 +723,7 @@ DebuggerPluginPrivate::DebuggerPluginPrivate(const QStringList &arguments)
|
||||
|
||||
// Task integration.
|
||||
//: Category under which Analyzer tasks are listed in Issues view
|
||||
TaskHub::addCategory(ANALYZERTASK_ID, Tr::tr("Debugger"));
|
||||
TaskHub::addCategory({ANALYZERTASK_ID, Tr::tr("Debugger")});
|
||||
|
||||
const Context debuggerNotRunning(C_DEBUGGER_NOTRUNNING);
|
||||
ICore::addAdditionalContext(debuggerNotRunning);
|
||||
@@ -765,8 +765,8 @@ DebuggerPluginPrivate::DebuggerPluginPrivate(const QStringList &arguments)
|
||||
act->setEnabled(false);
|
||||
Command *cmd = ActionManager::registerAction(act, Constants::OPEN_MEMORY_EDITOR);
|
||||
|
||||
TaskHub::addCategory(TASK_CATEGORY_DEBUGGER_DEBUGINFO, Tr::tr("Debug Information"));
|
||||
TaskHub::addCategory(TASK_CATEGORY_DEBUGGER_RUNTIME, Tr::tr("Debugger Runtime"));
|
||||
TaskHub::addCategory({TASK_CATEGORY_DEBUGGER_DEBUGINFO, Tr::tr("Debug Information")});
|
||||
TaskHub::addCategory({TASK_CATEGORY_DEBUGGER_RUNTIME, Tr::tr("Debugger Runtime")});
|
||||
|
||||
m_debuggerSettings.readSettings();
|
||||
|
||||
|
@@ -97,7 +97,7 @@ void NimPlugin::extensionsInitialized()
|
||||
FileIconProvider::registerIconOverlayForMimeType(icon, Constants::C_NIM_SCRIPT_MIMETYPE);
|
||||
FileIconProvider::registerIconOverlayForMimeType(icon, Constants::C_NIMBLE_MIMETYPE);
|
||||
}
|
||||
TaskHub::addCategory(Constants::C_NIMPARSE_ID, "Nim");
|
||||
TaskHub::addCategory({Constants::C_NIMPARSE_ID, "Nim"});
|
||||
}
|
||||
|
||||
} // namespace Nim
|
||||
|
@@ -291,18 +291,18 @@ BuildManager *BuildManager::instance()
|
||||
|
||||
void BuildManager::extensionsInitialized()
|
||||
{
|
||||
TaskHub::addCategory(Constants::TASK_CATEGORY_COMPILE,
|
||||
TaskHub::addCategory({Constants::TASK_CATEGORY_COMPILE,
|
||||
Tr::tr("Compile", "Category for compiler issues listed under 'Issues'"),
|
||||
true, 100);
|
||||
TaskHub::addCategory(Constants::TASK_CATEGORY_BUILDSYSTEM,
|
||||
true, 100});
|
||||
TaskHub::addCategory({Constants::TASK_CATEGORY_BUILDSYSTEM,
|
||||
Tr::tr("Build System", "Category for build system issues listed under 'Issues'"),
|
||||
true, 100);
|
||||
TaskHub::addCategory(Constants::TASK_CATEGORY_DEPLOYMENT,
|
||||
true, 100});
|
||||
TaskHub::addCategory({Constants::TASK_CATEGORY_DEPLOYMENT,
|
||||
Tr::tr("Deployment", "Category for deployment issues listed under 'Issues'"),
|
||||
true, 100);
|
||||
TaskHub::addCategory(Constants::TASK_CATEGORY_AUTOTEST,
|
||||
true, 100});
|
||||
TaskHub::addCategory({Constants::TASK_CATEGORY_AUTOTEST,
|
||||
Tr::tr("Autotests", "Category for autotest issues listed under 'Issues'"),
|
||||
true, 100);
|
||||
true, 100});
|
||||
}
|
||||
|
||||
void BuildManager::buildProjectWithoutDependencies(Project *project)
|
||||
|
@@ -2074,9 +2074,9 @@ void ProjectExplorerPlugin::extensionsInitialized()
|
||||
dd->m_projectFilterString = filterStrings.join(filterSeparator);
|
||||
|
||||
BuildManager::extensionsInitialized();
|
||||
TaskHub::addCategory(Constants::TASK_CATEGORY_SANITIZER,
|
||||
Tr::tr("Sanitizer", "Category for sanitizer issues listed under 'Issues'"));
|
||||
TaskHub::addCategory(Constants::TASK_CATEGORY_TASKLIST_ID, Tr::tr("My Tasks"));
|
||||
TaskHub::addCategory({Constants::TASK_CATEGORY_SANITIZER,
|
||||
Tr::tr("Sanitizer", "Category for sanitizer issues listed under 'Issues'")});
|
||||
TaskHub::addCategory({Constants::TASK_CATEGORY_TASKLIST_ID, Tr::tr("My Tasks")});
|
||||
|
||||
SshSettings::loadSettings(ICore::settings());
|
||||
const auto searchPathRetriever = [] {
|
||||
|
@@ -107,13 +107,12 @@ TaskHub::~TaskHub()
|
||||
m_instance = nullptr;
|
||||
}
|
||||
|
||||
void TaskHub::addCategory(Utils::Id categoryId, const QString &displayName, bool visible,
|
||||
int priority)
|
||||
void TaskHub::addCategory(const TaskCategory &category)
|
||||
{
|
||||
QTC_CHECK(!displayName.isEmpty());
|
||||
QTC_ASSERT(!m_registeredCategories.contains(categoryId), return);
|
||||
m_registeredCategories.push_back(categoryId);
|
||||
emit m_instance->categoryAdded(categoryId, displayName, visible, priority);
|
||||
QTC_CHECK(!category.displayName.isEmpty());
|
||||
QTC_ASSERT(!m_registeredCategories.contains(category.id), return);
|
||||
m_registeredCategories.push_back(category.id);
|
||||
emit m_instance->categoryAdded(category);
|
||||
}
|
||||
|
||||
TaskHub *TaskHub::instance()
|
||||
|
@@ -12,6 +12,15 @@ namespace ProjectExplorer {
|
||||
|
||||
class ProjectExplorerPlugin;
|
||||
|
||||
class PROJECTEXPLORER_EXPORT TaskCategory
|
||||
{
|
||||
public:
|
||||
Utils::Id id;
|
||||
QString displayName;
|
||||
bool visible = true;
|
||||
int priority = 0;
|
||||
};
|
||||
|
||||
class PROJECTEXPLORER_EXPORT TaskHub : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
@@ -28,8 +37,7 @@ public slots:
|
||||
static void removeTask(const ProjectExplorer::Task &task);
|
||||
|
||||
public:
|
||||
static void addCategory(Utils::Id categoryId, const QString &displayName, bool visible = true,
|
||||
int priority = 0);
|
||||
static void addCategory(const TaskCategory &category);
|
||||
static void updateTaskFileName(const Task &task, const QString &fileName);
|
||||
static void updateTaskLineNumber(const Task &task, int line);
|
||||
static void taskMarkClicked(const Task &task);
|
||||
@@ -39,8 +47,7 @@ public:
|
||||
static void requestPopup();
|
||||
|
||||
signals:
|
||||
void categoryAdded(Utils::Id categoryId, const QString &displayName, bool visible,
|
||||
int priority);
|
||||
void categoryAdded(const TaskCategory &category);
|
||||
void taskAdded(const ProjectExplorer::Task &task);
|
||||
void taskRemoved(const ProjectExplorer::Task &task);
|
||||
void tasksCleared(Utils::Id categoryId);
|
||||
|
@@ -60,13 +60,13 @@ bool TaskModel::hasFile(const QModelIndex &index) const
|
||||
return !m_tasks.at(row).file.isEmpty();
|
||||
}
|
||||
|
||||
void TaskModel::addCategory(Utils::Id categoryId, const QString &categoryName, int priority)
|
||||
void TaskModel::addCategory(const TaskCategory &category)
|
||||
{
|
||||
QTC_ASSERT(categoryId.isValid(), return);
|
||||
QTC_ASSERT(category.id.isValid(), return);
|
||||
CategoryData data;
|
||||
data.displayName = categoryName;
|
||||
data.priority = priority;
|
||||
m_categories.insert(categoryId, data);
|
||||
data.displayName = category.displayName;
|
||||
data.priority = category.priority;
|
||||
m_categories.insert(category.id, data);
|
||||
}
|
||||
|
||||
Tasks TaskModel::tasks(Utils::Id categoryId) const
|
||||
|
@@ -11,6 +11,8 @@
|
||||
#include "task.h"
|
||||
|
||||
namespace ProjectExplorer {
|
||||
class TaskCategory;
|
||||
|
||||
namespace Internal {
|
||||
|
||||
class TaskModel : public QAbstractItemModel
|
||||
@@ -31,7 +33,7 @@ public:
|
||||
|
||||
QList<Utils::Id> categoryIds() const;
|
||||
QString categoryDisplayName(Utils::Id categoryId) const;
|
||||
void addCategory(Utils::Id categoryId, const QString &categoryName, int priority);
|
||||
void addCategory(const TaskCategory &category);
|
||||
|
||||
Tasks tasks(Utils::Id categoryId = Utils::Id()) const;
|
||||
void addTask(const Task &t);
|
||||
|
@@ -365,12 +365,12 @@ void TaskWindow::visibilityChanged(bool visible)
|
||||
delayedInitialization();
|
||||
}
|
||||
|
||||
void TaskWindow::addCategory(Id categoryId, const QString &displayName, bool visible, int priority)
|
||||
void TaskWindow::addCategory(const TaskCategory &category)
|
||||
{
|
||||
d->m_model->addCategory(categoryId, displayName, priority);
|
||||
if (!visible) {
|
||||
d->m_model->addCategory(category);
|
||||
if (!category.visible) {
|
||||
QList<Id> filters = d->m_filter->filteredCategories();
|
||||
filters += categoryId;
|
||||
filters += category.id;
|
||||
d->m_filter->setFilteredCategories(filters);
|
||||
}
|
||||
}
|
||||
|
@@ -14,6 +14,7 @@ class QPoint;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace ProjectExplorer {
|
||||
class TaskCategory;
|
||||
class TaskHub;
|
||||
class Task;
|
||||
|
||||
@@ -60,7 +61,7 @@ signals:
|
||||
private:
|
||||
void updateFilter() override;
|
||||
|
||||
void addCategory(Utils::Id categoryId, const QString &displayName, bool visible, int priority);
|
||||
void addCategory(const TaskCategory &category);
|
||||
void addTask(const ProjectExplorer::Task &task);
|
||||
void removeTask(const ProjectExplorer::Task &task);
|
||||
void updatedTaskFileName(const Task &task, const QString &fileName);
|
||||
|
@@ -70,7 +70,7 @@ void PythonPlugin::extensionsInitialized()
|
||||
::Constants::FILEOVERLAY_PY);
|
||||
FileIconProvider::registerIconOverlayForSuffix(imageFile, "py");
|
||||
|
||||
TaskHub::addCategory(PythonErrorTaskCategory, "Python", true);
|
||||
TaskHub::addCategory({PythonErrorTaskCategory, "Python", true});
|
||||
}
|
||||
|
||||
} // Python::Internal
|
||||
|
@@ -38,8 +38,8 @@ namespace QmlDesigner {
|
||||
|
||||
AssetExporterPlugin::AssetExporterPlugin()
|
||||
{
|
||||
ProjectExplorer::TaskHub::addCategory( Constants::TASK_CATEGORY_ASSET_EXPORT,
|
||||
tr("Asset Export"), false);
|
||||
ProjectExplorer::TaskHub::addCategory({Constants::TASK_CATEGORY_ASSET_EXPORT,
|
||||
tr("Asset Export"), false});
|
||||
|
||||
auto *designerPlugin = QmlDesigner::QmlDesignerPlugin::instance();
|
||||
auto &viewManager = designerPlugin->viewManager();
|
||||
|
@@ -205,8 +205,8 @@ void QmlJSEditorPlugin::extensionsInitialized()
|
||||
FileIconProvider::registerIconOverlayForMimeType(ProjectExplorer::Constants::FILEOVERLAY_UI,
|
||||
"application/x-qt.ui+qml");
|
||||
|
||||
TaskHub::addCategory(Constants::TASK_CATEGORY_QML, Tr::tr("QML"));
|
||||
TaskHub::addCategory(Constants::TASK_CATEGORY_QML_ANALYSIS, Tr::tr("QML Analysis"), false);
|
||||
TaskHub::addCategory({Constants::TASK_CATEGORY_QML, Tr::tr("QML")});
|
||||
TaskHub::addCategory({Constants::TASK_CATEGORY_QML_ANALYSIS, Tr::tr("QML Analysis"), false});
|
||||
QmllsSettingsManager::instance()->setupAutoupdate();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user