2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2010-06-16 14:12:30 +02:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2010-06-16 14:12:30 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2010-06-16 14:12:30 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
2016-01-15 14:57:40 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
2010-06-16 14:12:30 +02:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** GNU General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
2010-12-17 16:01:08 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2010-06-16 14:12:30 +02:00
|
|
|
|
|
|
|
|
#include "task.h"
|
|
|
|
|
|
2015-11-23 16:41:54 +01:00
|
|
|
#include <coreplugin/coreicons.h>
|
2014-04-10 12:44:13 +02:00
|
|
|
#include <utils/qtcassert.h>
|
|
|
|
|
|
2014-06-20 14:32:40 +02:00
|
|
|
#include "projectexplorerconstants.h"
|
|
|
|
|
|
2010-06-16 14:12:30 +02:00
|
|
|
namespace ProjectExplorer
|
|
|
|
|
{
|
|
|
|
|
|
2014-09-22 15:49:14 +02:00
|
|
|
static QIcon taskTypeIcon(Task::TaskType t)
|
2013-11-12 21:59:43 +01:00
|
|
|
{
|
2014-09-22 15:49:14 +02:00
|
|
|
static QIcon icons[3] = { QIcon(),
|
2015-11-23 16:41:54 +01:00
|
|
|
Core::Icons::ERROR.icon(),
|
|
|
|
|
Core::Icons::WARNING.icon()};
|
2014-09-22 15:49:14 +02:00
|
|
|
|
|
|
|
|
if (t < 0 || t > 2)
|
|
|
|
|
t = Task::Unknown;
|
|
|
|
|
|
|
|
|
|
return icons[t];
|
2013-11-12 21:59:43 +01:00
|
|
|
}
|
|
|
|
|
|
2010-08-04 14:56:32 +02:00
|
|
|
unsigned int Task::s_nextId = 1;
|
2010-06-30 16:37:07 +02:00
|
|
|
|
2011-04-14 12:58:14 +02:00
|
|
|
/*!
|
|
|
|
|
\class ProjectExplorer::Task
|
2013-06-05 14:29:24 +02:00
|
|
|
\brief The Task class represents a build issue (warning or error).
|
2011-04-14 12:58:14 +02:00
|
|
|
\sa ProjectExplorer::TaskHub
|
|
|
|
|
*/
|
|
|
|
|
|
2010-06-24 16:17:11 +02:00
|
|
|
Task::Task(TaskType type_, const QString &description_,
|
2013-11-12 21:59:43 +01:00
|
|
|
const Utils::FileName &file_, int line_, Core::Id category_,
|
|
|
|
|
const Utils::FileName &iconFile) :
|
2012-01-26 13:38:25 +01:00
|
|
|
taskId(s_nextId), type(type_), description(description_),
|
2013-11-12 21:59:43 +01:00
|
|
|
file(file_), line(line_), movedLine(line_), category(category_),
|
2014-09-22 15:49:14 +02:00
|
|
|
icon(iconFile.isEmpty() ? taskTypeIcon(type_) : QIcon(iconFile.toString()))
|
2010-06-24 16:14:29 +02:00
|
|
|
{
|
2010-06-30 16:37:07 +02:00
|
|
|
++s_nextId;
|
2010-06-24 16:14:29 +02:00
|
|
|
}
|
|
|
|
|
|
2014-06-20 14:32:40 +02:00
|
|
|
Task Task::compilerMissingTask()
|
|
|
|
|
{
|
|
|
|
|
return Task(Task::Error,
|
|
|
|
|
QCoreApplication::translate("ProjectExplorer::Task",
|
|
|
|
|
"Qt Creator needs a compiler set up to build. "
|
|
|
|
|
"Configure a compiler in the kit options."),
|
|
|
|
|
Utils::FileName(), -1,
|
2014-10-13 22:37:28 +03:00
|
|
|
Constants::TASK_CATEGORY_BUILDSYSTEM);
|
2014-06-20 14:32:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Task Task::buildConfigurationMissingTask()
|
|
|
|
|
{
|
|
|
|
|
return Task(Task::Error,
|
|
|
|
|
QCoreApplication::translate("ProjectExplorer::Task",
|
|
|
|
|
"Qt Creator needs a build configuration set up to build. "
|
|
|
|
|
"Configure a build configuration in the project settings."),
|
|
|
|
|
Utils::FileName(), -1,
|
2014-10-13 22:37:28 +03:00
|
|
|
Constants::TASK_CATEGORY_BUILDSYSTEM);
|
2014-06-20 14:32:40 +02:00
|
|
|
}
|
|
|
|
|
|
2016-04-11 13:27:42 +02:00
|
|
|
void Task::setMark(TextEditor::TextMark *mark)
|
2012-02-03 16:07:13 +01:00
|
|
|
{
|
2016-04-11 13:27:42 +02:00
|
|
|
QTC_ASSERT(mark, return);
|
2014-04-10 12:44:13 +02:00
|
|
|
QTC_ASSERT(m_mark.isNull(), return);
|
2014-07-19 11:27:28 +02:00
|
|
|
m_mark = QSharedPointer<TextEditor::TextMark>(mark);
|
2012-02-03 16:07:13 +01:00
|
|
|
}
|
|
|
|
|
|
2010-08-04 14:56:32 +02:00
|
|
|
bool Task::isNull() const
|
2013-08-01 14:16:10 +02:00
|
|
|
{
|
|
|
|
|
return taskId == 0;
|
|
|
|
|
}
|
2010-08-04 14:56:32 +02:00
|
|
|
|
2013-05-03 15:58:01 +02:00
|
|
|
void Task::clear()
|
|
|
|
|
{
|
|
|
|
|
taskId = 0;
|
2016-04-11 13:25:12 +02:00
|
|
|
type = Task::Unknown;
|
2013-05-03 15:58:01 +02:00
|
|
|
description.clear();
|
|
|
|
|
file = Utils::FileName();
|
|
|
|
|
line = -1;
|
|
|
|
|
movedLine = -1;
|
|
|
|
|
category = Core::Id();
|
2013-11-12 21:59:43 +01:00
|
|
|
icon = QIcon();
|
2016-04-11 13:25:12 +02:00
|
|
|
formats.clear();
|
|
|
|
|
m_mark.clear();
|
2013-05-03 15:58:01 +02:00
|
|
|
}
|
|
|
|
|
|
2010-06-16 14:12:30 +02:00
|
|
|
//
|
|
|
|
|
// functions
|
|
|
|
|
//
|
|
|
|
|
bool operator==(const Task &t1, const Task &t2)
|
|
|
|
|
{
|
2010-06-30 16:37:07 +02:00
|
|
|
return t1.taskId == t2.taskId;
|
2010-06-16 14:12:30 +02:00
|
|
|
}
|
|
|
|
|
|
2011-05-12 11:51:17 +02:00
|
|
|
bool operator<(const Task &a, const Task &b)
|
|
|
|
|
{
|
|
|
|
|
if (a.type != b.type) {
|
2014-10-13 22:37:28 +03:00
|
|
|
if (a.type == Task::Error)
|
2011-05-12 11:51:17 +02:00
|
|
|
return true;
|
2014-10-13 22:37:28 +03:00
|
|
|
if (b.type == Task::Error)
|
2011-05-12 11:51:17 +02:00
|
|
|
return false;
|
2014-10-13 22:37:28 +03:00
|
|
|
if (a.type == Task::Warning)
|
2011-05-12 11:51:17 +02:00
|
|
|
return true;
|
2014-10-13 22:37:28 +03:00
|
|
|
if (b.type == Task::Warning)
|
2011-05-12 11:51:17 +02:00
|
|
|
return false;
|
|
|
|
|
// Can't happen
|
|
|
|
|
return true;
|
|
|
|
|
} else {
|
2015-06-19 14:37:17 +02:00
|
|
|
if (a.category < b.category)
|
2011-05-12 11:51:17 +02:00
|
|
|
return true;
|
2015-06-19 14:37:17 +02:00
|
|
|
if (b.category < a.category)
|
2011-05-12 11:51:17 +02:00
|
|
|
return false;
|
|
|
|
|
return a.taskId < b.taskId;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2010-06-16 14:12:30 +02:00
|
|
|
uint qHash(const Task &task)
|
|
|
|
|
{
|
2010-06-30 16:37:07 +02:00
|
|
|
return task.taskId;
|
2010-06-16 14:12:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace ProjectExplorer
|