ProjectExplorer: Introduce new Task::setFile() method

This method can be useful when need to update a task file later,
after the task creation.

Change-Id: I42419e4c975e8644335a5f33a7bbf9a7c068322f
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
Denis Shienkov
2019-05-08 00:03:13 +03:00
parent 50b12945b7
commit 086eb4d598
3 changed files with 16 additions and 9 deletions

View File

@@ -97,7 +97,7 @@ void IarParser::amendFilePath()
QString filePath; QString filePath;
while (!m_filePathParts.isEmpty()) while (!m_filePathParts.isEmpty())
filePath.append(m_filePathParts.takeFirst().trimmed()); filePath.append(m_filePathParts.takeFirst().trimmed());
m_lastTask.file = Utils::FileName::fromUserInput(filePath); m_lastTask.setFile(Utils::FileName::fromUserInput(filePath));
m_expectFilePath = false; m_expectFilePath = false;
} }

View File

@@ -65,17 +65,11 @@ Task::Task(TaskType type_, const QString &description_,
const Utils::FileName &file_, int line_, Core::Id category_, const Utils::FileName &file_, int line_, Core::Id category_,
const QIcon &icon, Options options) : const QIcon &icon, Options options) :
taskId(s_nextId), type(type_), options(options), description(description_), taskId(s_nextId), type(type_), options(options), description(description_),
file(file_), line(line_), movedLine(line_), category(category_), line(line_), movedLine(line_), category(category_),
icon(icon.isNull() ? taskTypeIcon(type_) : icon) icon(icon.isNull() ? taskTypeIcon(type_) : icon)
{ {
++s_nextId; ++s_nextId;
if (!file.isEmpty() && !file.toFileInfo().isAbsolute()) { setFile(file_);
Utils::FileNameList possiblePaths = Internal::findFileInSession(file);
if (possiblePaths.length() == 1)
file = possiblePaths.first();
else
fileCandidates = possiblePaths;
}
} }
Task Task::compilerMissingTask() Task Task::compilerMissingTask()
@@ -126,6 +120,18 @@ void Task::clear()
m_mark.clear(); m_mark.clear();
} }
void Task::setFile(const Utils::FileName &file_)
{
file = file_;
if (!file.isEmpty() && !file.toFileInfo().isAbsolute()) {
Utils::FileNameList possiblePaths = Internal::findFileInSession(file);
if (possiblePaths.length() == 1)
file = possiblePaths.first();
else
fileCandidates = possiblePaths;
}
}
// //
// functions // functions
// //

View File

@@ -70,6 +70,7 @@ public:
bool isNull() const; bool isNull() const;
void clear(); void clear();
void setFile(const Utils::FileName &file);
unsigned int taskId = 0; unsigned int taskId = 0;
TaskType type = Unknown; TaskType type = Unknown;