forked from qt-creator/qt-creator
ProjectExplorer: Delay-create TaskHub
Effectively only by a few lines. Change-Id: Ieb548d0a2f5ced033881106c76adc9a5e3e16663 Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
@@ -37,7 +37,7 @@ ProjectInfo::ConstPtr ProjectInfoGenerator::generate(const QPromise<ProjectInfo:
|
|||||||
const auto projectInfo = ProjectInfo::create(m_projectUpdateInfo, projectParts);
|
const auto projectInfo = ProjectInfo::create(m_projectUpdateInfo, projectParts);
|
||||||
|
|
||||||
static const auto showWarning = [](const QString &message) {
|
static const auto showWarning = [](const QString &message) {
|
||||||
QTimer::singleShot(0, TaskHub::instance(), [message] {
|
QTimer::singleShot(0, &taskHub(), [message] {
|
||||||
TaskHub::addTask(BuildSystemTask(Task::Warning, message));
|
TaskHub::addTask(BuildSystemTask(Task::Warning, message));
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@@ -46,14 +46,14 @@ static inline QByteArray msgFileComparisonFail(const Utils::FilePath &f1, const
|
|||||||
// test functions:
|
// test functions:
|
||||||
OutputParserTester::OutputParserTester()
|
OutputParserTester::OutputParserTester()
|
||||||
{
|
{
|
||||||
connect(TaskHub::instance(), &TaskHub::taskAdded, this, [this](const Task &t) {
|
connect(&taskHub(), &TaskHub::taskAdded, this, [this](const Task &t) {
|
||||||
m_receivedTasks.append(t);
|
m_receivedTasks.append(t);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
OutputParserTester::~OutputParserTester()
|
OutputParserTester::~OutputParserTester()
|
||||||
{
|
{
|
||||||
TaskHub::instance()->disconnect(this);
|
taskHub().disconnect(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OutputParserTester::testParsing(const QString &lines,
|
void OutputParserTester::testParsing(const QString &lines,
|
||||||
|
@@ -660,8 +660,6 @@ public:
|
|||||||
|
|
||||||
ToolChainOptionsPage m_toolChainOptionsPage;
|
ToolChainOptionsPage m_toolChainOptionsPage;
|
||||||
|
|
||||||
TaskHub m_taskHub;
|
|
||||||
|
|
||||||
ProjectWelcomePage m_welcomePage;
|
ProjectWelcomePage m_welcomePage;
|
||||||
|
|
||||||
CustomWizardMetaFactory<CustomProjectWizard> m_customProjectWizard{IWizardFactory::ProjectWizard};
|
CustomWizardMetaFactory<CustomProjectWizard> m_customProjectWizard{IWizardFactory::ProjectWizard};
|
||||||
|
@@ -13,8 +13,6 @@
|
|||||||
#include <utils/threadutils.h>
|
#include <utils/threadutils.h>
|
||||||
#include <utils/utilsicons.h>
|
#include <utils/utilsicons.h>
|
||||||
|
|
||||||
#include <QApplication>
|
|
||||||
|
|
||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
|
|
||||||
namespace ProjectExplorer {
|
namespace ProjectExplorer {
|
||||||
@@ -23,8 +21,7 @@ namespace ProjectExplorer {
|
|||||||
const char TASK_MARK_WARNING[] = "Task.Mark.Warning";
|
const char TASK_MARK_WARNING[] = "Task.Mark.Warning";
|
||||||
const char TASK_MARK_ERROR[] = "Task.Mark.Error";
|
const char TASK_MARK_ERROR[] = "Task.Mark.Error";
|
||||||
|
|
||||||
static TaskHub *m_instance = nullptr;
|
static QVector<Id> s_registeredCategories;
|
||||||
QVector<Utils::Id> TaskHub::m_registeredCategories;
|
|
||||||
|
|
||||||
static TextEditor::TextMarkCategory categoryForType(Task::TaskType type)
|
static TextEditor::TextMarkCategory categoryForType(Task::TaskType type)
|
||||||
{
|
{
|
||||||
@@ -45,8 +42,8 @@ public:
|
|||||||
TextMark(task.file, task.line, categoryForType(task.type)),
|
TextMark(task.file, task.line, categoryForType(task.type)),
|
||||||
m_task(task)
|
m_task(task)
|
||||||
{
|
{
|
||||||
setColor(task.type == Task::Error ? Utils::Theme::ProjectExplorer_TaskError_TextMarkColor
|
setColor(task.type == Task::Error ? Theme::ProjectExplorer_TaskError_TextMarkColor
|
||||||
: Utils::Theme::ProjectExplorer_TaskWarn_TextMarkColor);
|
: Theme::ProjectExplorer_TaskWarn_TextMarkColor);
|
||||||
setDefaultToolTip(task.type == Task::Error ? Tr::tr("Error")
|
setDefaultToolTip(task.type == Task::Error ? Tr::tr("Error")
|
||||||
: Tr::tr("Warning"));
|
: Tr::tr("Warning"));
|
||||||
setPriority(task.type == Task::Error ? TextEditor::TextMark::NormalPriority
|
setPriority(task.type == Task::Error ? TextEditor::TextMark::NormalPriority
|
||||||
@@ -97,30 +94,21 @@ void TaskMark::clicked()
|
|||||||
|
|
||||||
TaskHub::TaskHub()
|
TaskHub::TaskHub()
|
||||||
{
|
{
|
||||||
m_instance = this;
|
|
||||||
qRegisterMetaType<ProjectExplorer::Task>("ProjectExplorer::Task");
|
qRegisterMetaType<ProjectExplorer::Task>("ProjectExplorer::Task");
|
||||||
qRegisterMetaType<Tasks >("Tasks");
|
qRegisterMetaType<Tasks >("Tasks");
|
||||||
}
|
}
|
||||||
|
|
||||||
TaskHub::~TaskHub()
|
TaskHub::~TaskHub() = default;
|
||||||
{
|
|
||||||
m_instance = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
void TaskHub::addCategory(const TaskCategory &category)
|
void TaskHub::addCategory(const TaskCategory &category)
|
||||||
{
|
{
|
||||||
QTC_CHECK(!category.displayName.isEmpty());
|
QTC_CHECK(!category.displayName.isEmpty());
|
||||||
QTC_ASSERT(!m_registeredCategories.contains(category.id), return);
|
QTC_ASSERT(!s_registeredCategories.contains(category.id), return);
|
||||||
m_registeredCategories.push_back(category.id);
|
s_registeredCategories.push_back(category.id);
|
||||||
emit m_instance->categoryAdded(category);
|
emit taskHub().categoryAdded(category);
|
||||||
}
|
}
|
||||||
|
|
||||||
TaskHub *TaskHub::instance()
|
void TaskHub::addTask(Task::TaskType type, const QString &description, Id category)
|
||||||
{
|
|
||||||
return m_instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
void TaskHub::addTask(Task::TaskType type, const QString &description, Utils::Id category)
|
|
||||||
{
|
{
|
||||||
addTask(Task(type, description, {}, -1, category));
|
addTask(Task(type, description, {}, -1, category));
|
||||||
}
|
}
|
||||||
@@ -135,7 +123,7 @@ void TaskHub::addTask(Task task)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QTC_ASSERT(m_registeredCategories.contains(task.category), return);
|
QTC_ASSERT(s_registeredCategories.contains(task.category), return);
|
||||||
QTC_ASSERT(!task.description().isEmpty(), return);
|
QTC_ASSERT(!task.description().isEmpty(), return);
|
||||||
QTC_ASSERT(!task.isNull(), return);
|
QTC_ASSERT(!task.isNull(), return);
|
||||||
QTC_ASSERT(task.m_mark.isNull(), return);
|
QTC_ASSERT(task.m_mark.isNull(), return);
|
||||||
@@ -146,49 +134,55 @@ void TaskHub::addTask(Task task)
|
|||||||
|
|
||||||
if ((task.options & Task::AddTextMark) && task.line != -1 && task.type != Task::Unknown)
|
if ((task.options & Task::AddTextMark) && task.line != -1 && task.type != Task::Unknown)
|
||||||
task.setMark(new TaskMark(task));
|
task.setMark(new TaskMark(task));
|
||||||
emit m_instance->taskAdded(task);
|
emit taskHub().taskAdded(task);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TaskHub::clearTasks(Utils::Id categoryId)
|
void TaskHub::clearTasks(Id categoryId)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(!categoryId.isValid() || m_registeredCategories.contains(categoryId), return);
|
QTC_ASSERT(!categoryId.isValid() || s_registeredCategories.contains(categoryId), return);
|
||||||
emit m_instance->tasksCleared(categoryId);
|
emit taskHub().tasksCleared(categoryId);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TaskHub::removeTask(const Task &task)
|
void TaskHub::removeTask(const Task &task)
|
||||||
{
|
{
|
||||||
emit m_instance->taskRemoved(task);
|
emit taskHub().taskRemoved(task);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TaskHub::updateTaskFileName(const Task &task, const QString &fileName)
|
void TaskHub::updateTaskFileName(const Task &task, const QString &fileName)
|
||||||
{
|
{
|
||||||
emit m_instance->taskFileNameUpdated(task, fileName);
|
emit taskHub().taskFileNameUpdated(task, fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TaskHub::updateTaskLineNumber(const Task &task, int line)
|
void TaskHub::updateTaskLineNumber(const Task &task, int line)
|
||||||
{
|
{
|
||||||
emit m_instance->taskLineNumberUpdated(task, line);
|
emit taskHub().taskLineNumberUpdated(task, line);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TaskHub::taskMarkClicked(const Task &task)
|
void TaskHub::taskMarkClicked(const Task &task)
|
||||||
{
|
{
|
||||||
emit m_instance->showTask(task);
|
emit taskHub().showTask(task);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TaskHub::showTaskInEditor(const Task &task)
|
void TaskHub::showTaskInEditor(const Task &task)
|
||||||
{
|
{
|
||||||
emit m_instance->openTask(task);
|
emit taskHub().openTask(task);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TaskHub::setCategoryVisibility(Utils::Id categoryId, bool visible)
|
void TaskHub::setCategoryVisibility(Id categoryId, bool visible)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(m_registeredCategories.contains(categoryId), return);
|
QTC_ASSERT(s_registeredCategories.contains(categoryId), return);
|
||||||
emit m_instance->categoryVisibilityChanged(categoryId, visible);
|
emit taskHub().categoryVisibilityChanged(categoryId, visible);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TaskHub::requestPopup()
|
void TaskHub::requestPopup()
|
||||||
{
|
{
|
||||||
emit m_instance->popupRequested(Core::IOutputPane::NoModeSwitch);
|
emit taskHub().popupRequested(Core::IOutputPane::NoModeSwitch);
|
||||||
|
}
|
||||||
|
|
||||||
|
TaskHub &taskHub()
|
||||||
|
{
|
||||||
|
static TaskHub theTaskHub;
|
||||||
|
return theTaskHub;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace ProjectExplorer
|
} // namespace ProjectExplorer
|
||||||
|
@@ -22,12 +22,11 @@ public:
|
|||||||
int priority = 0;
|
int priority = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class PROJECTEXPLORER_EXPORT TaskHub : public QObject
|
class PROJECTEXPLORER_EXPORT TaskHub final : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
|
||||||
static TaskHub *instance();
|
|
||||||
|
|
||||||
|
public:
|
||||||
// Convenience overload
|
// Convenience overload
|
||||||
static void addTask(Task::TaskType type, const QString &description,
|
static void addTask(Task::TaskType type, const QString &description,
|
||||||
Utils::Id category);
|
Utils::Id category);
|
||||||
@@ -60,12 +59,12 @@ signals:
|
|||||||
void openTask(const Task &task);
|
void openTask(const Task &task);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
friend TaskHub &taskHub();
|
||||||
|
|
||||||
TaskHub();
|
TaskHub();
|
||||||
~TaskHub() override;
|
~TaskHub() final;
|
||||||
|
|
||||||
static QVector<Utils::Id> m_registeredCategories;
|
|
||||||
|
|
||||||
friend class ProjectExplorerPluginPrivate;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
PROJECTEXPLORER_EXPORT TaskHub &taskHub();
|
||||||
|
|
||||||
} // namespace ProjectExplorer
|
} // namespace ProjectExplorer
|
||||||
|
@@ -233,7 +233,7 @@ TaskWindow::TaskWindow() : d(std::make_unique<TaskWindowPrivate>())
|
|||||||
setupFilterUi("IssuesPane.Filter");
|
setupFilterUi("IssuesPane.Filter");
|
||||||
setFilteringEnabled(true);
|
setFilteringEnabled(true);
|
||||||
|
|
||||||
TaskHub *hub = TaskHub::instance();
|
TaskHub *hub = &taskHub();
|
||||||
connect(hub, &TaskHub::categoryAdded, this, &TaskWindow::addCategory);
|
connect(hub, &TaskHub::categoryAdded, this, &TaskWindow::addCategory);
|
||||||
connect(hub, &TaskHub::taskAdded, this, &TaskWindow::addTask);
|
connect(hub, &TaskHub::taskAdded, this, &TaskWindow::addTask);
|
||||||
connect(hub, &TaskHub::taskRemoved, this, &TaskWindow::removeTask);
|
connect(hub, &TaskHub::taskRemoved, this, &TaskWindow::removeTask);
|
||||||
|
@@ -135,7 +135,7 @@ AssetExportDialog::AssetExportDialog(const FilePath &exportPath,
|
|||||||
connect(&m_assetExporter, &AssetExporter::exportProgressChanged,
|
connect(&m_assetExporter, &AssetExporter::exportProgressChanged,
|
||||||
this, &AssetExportDialog::updateExportProgress);
|
this, &AssetExportDialog::updateExportProgress);
|
||||||
|
|
||||||
connect(TaskHub::instance(), &TaskHub::taskAdded, this, &AssetExportDialog::onTaskAdded);
|
connect(&taskHub(), &TaskHub::taskAdded, this, &AssetExportDialog::onTaskAdded);
|
||||||
|
|
||||||
using namespace Layouting;
|
using namespace Layouting;
|
||||||
|
|
||||||
|
@@ -43,7 +43,7 @@ static void addTask(Task::TaskType type,
|
|||||||
const Utils::FilePath &file = {},
|
const Utils::FilePath &file = {},
|
||||||
int line = -1)
|
int line = -1)
|
||||||
{
|
{
|
||||||
QMetaObject::invokeMethod(TaskHub::instance(), [=]() {
|
QMetaObject::invokeMethod(&taskHub(), [=] {
|
||||||
TaskHub::addTask(BuildSystemTask(type, description, file, line));
|
TaskHub::addTask(BuildSystemTask(type, description, file, line));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@@ -50,7 +50,7 @@ void CompilerOutputProcessor::start()
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
connect(ProjectExplorer::TaskHub::instance(), &ProjectExplorer::TaskHub::taskAdded,
|
connect(&ProjectExplorer::taskHub(), &ProjectExplorer::TaskHub::taskAdded,
|
||||||
this, &CompilerOutputProcessor::handleTask);
|
this, &CompilerOutputProcessor::handleTask);
|
||||||
while (!m_source.atEnd()) {
|
while (!m_source.atEnd()) {
|
||||||
parser.appendMessage(QString::fromLocal8Bit(m_source.readLine().trimmed()),
|
parser.appendMessage(QString::fromLocal8Bit(m_source.readLine().trimmed()),
|
||||||
|
Reference in New Issue
Block a user