mirror of
https://github.com/Palm1r/QodeAssist.git
synced 2025-11-13 13:32:55 -05:00
feat: Add support QtCreator 18 (#246)
This commit is contained in:
@ -19,6 +19,7 @@
|
||||
|
||||
#include "GetIssuesListTool.hpp"
|
||||
|
||||
#include <Version.hpp>
|
||||
#include <logger/Logger.hpp>
|
||||
#include <projectexplorer/taskhub.h>
|
||||
#include <QJsonArray>
|
||||
@ -61,7 +62,16 @@ void IssuesTracker::onTaskAdded(const ProjectExplorer::Task &task)
|
||||
m_tasks.append(task);
|
||||
|
||||
QString typeStr;
|
||||
switch (task.type) {
|
||||
#if QODEASSIST_QT_CREATOR_VERSION >= QT_VERSION_CHECK(18, 0, 0)
|
||||
auto taskType = task.type();
|
||||
auto taskFile = task.file();
|
||||
auto taskLine = task.line();
|
||||
#else
|
||||
auto taskType = task.type;
|
||||
auto taskFile = task.file;
|
||||
auto taskLine = task.line;
|
||||
#endif
|
||||
switch (taskType) {
|
||||
case ProjectExplorer::Task::Error:
|
||||
typeStr = "ERROR";
|
||||
break;
|
||||
@ -76,8 +86,8 @@ void IssuesTracker::onTaskAdded(const ProjectExplorer::Task &task)
|
||||
LOG_MESSAGE(QString("IssuesTracker: Task added [%1] %2 at %3:%4 (total: %5)")
|
||||
.arg(typeStr)
|
||||
.arg(task.description())
|
||||
.arg(task.file.toUrlishString())
|
||||
.arg(task.line)
|
||||
.arg(taskFile.toUrlishString())
|
||||
.arg(taskLine)
|
||||
.arg(m_tasks.size()));
|
||||
}
|
||||
|
||||
@ -102,7 +112,11 @@ void IssuesTracker::onTasksCleared(Utils::Id categoryId)
|
||||
m_tasks.begin(),
|
||||
m_tasks.end(),
|
||||
[categoryId](const ProjectExplorer::Task &task) {
|
||||
#if QODEASSIST_QT_CREATOR_VERSION >= QT_VERSION_CHECK(18, 0, 0)
|
||||
return task.category() == categoryId;
|
||||
#else
|
||||
return task.category == categoryId;
|
||||
#endif
|
||||
}),
|
||||
m_tasks.end());
|
||||
int removedCount = beforeCount - m_tasks.size();
|
||||
@ -201,13 +215,27 @@ QFuture<QString> GetIssuesListTool::executeAsync(const QJsonObject &input)
|
||||
int processedCount = 0;
|
||||
|
||||
for (const ProjectExplorer::Task &task : tasks) {
|
||||
if (severityFilter == "error" && task.type != ProjectExplorer::Task::Error)
|
||||
|
||||
#if QODEASSIST_QT_CREATOR_VERSION >= QT_VERSION_CHECK(18, 0, 0)
|
||||
auto taskType = task.type();
|
||||
auto taskFile = task.file();
|
||||
auto taskLine = task.line();
|
||||
auto taskColumn = task.column();
|
||||
auto taskCategory = task.category();
|
||||
#else
|
||||
auto taskType = task.type;
|
||||
auto taskFile = task.file;
|
||||
auto taskLine = task.line;
|
||||
auto taskColumn = task.column;
|
||||
auto taskCategory = task.category;
|
||||
#endif
|
||||
if (severityFilter == "error" && taskType != ProjectExplorer::Task::Error)
|
||||
continue;
|
||||
if (severityFilter == "warning" && task.type != ProjectExplorer::Task::Warning)
|
||||
if (severityFilter == "warning" && taskType != ProjectExplorer::Task::Warning)
|
||||
continue;
|
||||
|
||||
QString typeStr;
|
||||
switch (task.type) {
|
||||
switch (taskType) {
|
||||
case ProjectExplorer::Task::Error:
|
||||
typeStr = "ERROR";
|
||||
errorCount++;
|
||||
@ -223,18 +251,18 @@ QFuture<QString> GetIssuesListTool::executeAsync(const QJsonObject &input)
|
||||
|
||||
QString issueText = QString("[%1] %2").arg(typeStr, task.description());
|
||||
|
||||
if (!task.file.isEmpty()) {
|
||||
issueText += QString("\n File: %1").arg(task.file.toUrlishString());
|
||||
if (task.line > 0) {
|
||||
issueText += QString(":%1").arg(task.line);
|
||||
if (task.column > 0) {
|
||||
issueText += QString(":%1").arg(task.column);
|
||||
if (!taskFile.isEmpty()) {
|
||||
issueText += QString("\n File: %1").arg(taskFile.toUrlishString());
|
||||
if (taskLine > 0) {
|
||||
issueText += QString(":%1").arg(taskLine);
|
||||
if (taskColumn > 0) {
|
||||
issueText += QString(":%1").arg(taskColumn);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!task.category.toString().isEmpty()) {
|
||||
issueText += QString("\n Category: %1").arg(task.category.toString());
|
||||
if (!taskCategory.toString().isEmpty()) {
|
||||
issueText += QString("\n Category: %1").arg(taskCategory.toString());
|
||||
}
|
||||
|
||||
results.append(issueText);
|
||||
|
||||
Reference in New Issue
Block a user