Commit 20cbf7d3 authored by Petar Perisin's avatar Petar Perisin

Add icons in Task

Change-Id: I6c96cb90cd22c9ece225bc99470068a9168dabe4
Reviewed-by: default avatarTobias Hunger <tobias.hunger@digia.com>
parent 4a5af14b
...@@ -32,6 +32,19 @@ ...@@ -32,6 +32,19 @@
namespace ProjectExplorer namespace ProjectExplorer
{ {
static QString taskTypeIcon(Task::TaskType t)
{
switch (t) {
case Task::Warning:
return QLatin1String(":/projectexplorer/images/compile_warning.png");
case Task::Error:
return QLatin1String(":/projectexplorer/images/compile_error.png");
case Task::Unknown:
break;
}
return QString();
}
unsigned int Task::s_nextId = 1; unsigned int Task::s_nextId = 1;
/*! /*!
...@@ -44,9 +57,11 @@ Task::Task() : taskId(0), type(Unknown), line(-1) ...@@ -44,9 +57,11 @@ Task::Task() : taskId(0), type(Unknown), line(-1)
{ } { }
Task::Task(TaskType type_, const QString &description_, 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 Utils::FileName &iconFile) :
taskId(s_nextId), type(type_), description(description_), taskId(s_nextId), type(type_), description(description_),
file(file_), line(line_), movedLine(line_), category(category_) file(file_), line(line_), movedLine(line_), category(category_),
icon(iconFile.isEmpty() ? taskTypeIcon(type_) : iconFile.toString())
{ {
++s_nextId; ++s_nextId;
} }
...@@ -70,6 +85,7 @@ void Task::clear() ...@@ -70,6 +85,7 @@ void Task::clear()
movedLine = -1; movedLine = -1;
category = Core::Id(); category = Core::Id();
type = Task::Unknown; type = Task::Unknown;
icon = QIcon();
} }
// //
......
...@@ -54,7 +54,8 @@ public: ...@@ -54,7 +54,8 @@ public:
Task(); Task();
Task(TaskType type, const QString &description, 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 Utils::FileName &iconName = Utils::FileName());
bool isNull() const; bool isNull() const;
void clear(); void clear();
...@@ -66,6 +67,7 @@ public: ...@@ -66,6 +67,7 @@ public:
int line; int line;
int movedLine; // contains a line number if the line was moved in the editor int movedLine; // contains a line number if the line was moved in the editor
Core::Id category; Core::Id category;
QIcon icon;
void addMark(TextEditor::BaseTextMark *mark); void addMark(TextEditor::BaseTextMark *mark);
// Having a QList<QTextLayout::FormatRange> in Task isn't that great // Having a QList<QTextLayout::FormatRange> in Task isn't that great
......
...@@ -117,7 +117,7 @@ void TaskHub::addTask(Task task) ...@@ -117,7 +117,7 @@ void TaskHub::addTask(Task task)
if (task.line != -1 && !task.file.isEmpty()) { if (task.line != -1 && !task.file.isEmpty()) {
bool visible = (task.type == Task::Warning || task.type == Task::Error); bool visible = (task.type == Task::Warning || task.type == Task::Error);
TaskMark *mark = new TaskMark(task.taskId, task.file.toString(), task.line, visible); TaskMark *mark = new TaskMark(task.taskId, task.file.toString(), task.line, visible);
mark->setIcon(taskTypeIcon(task.type)); mark->setIcon(task.icon);
mark->setPriority(TextEditor::ITextMark::LowPriority); mark->setPriority(TextEditor::ITextMark::LowPriority);
task.addMark(mark); task.addMark(mark);
emit m_instance->taskAdded(task); emit m_instance->taskAdded(task);
...@@ -167,16 +167,3 @@ void TaskHub::requestPopup() ...@@ -167,16 +167,3 @@ void TaskHub::requestPopup()
emit m_instance->popupRequested(Core::IOutputPane::NoModeSwitch); emit m_instance->popupRequested(Core::IOutputPane::NoModeSwitch);
} }
QIcon TaskHub::taskTypeIcon(Task::TaskType t)
{
switch (t) {
case Task::Warning:
return m_instance->m_warningIcon;
case Task::Error:
return m_instance->m_errorIcon;
case Task::Unknown:
break;
}
return QIcon();
}
...@@ -66,8 +66,6 @@ public: ...@@ -66,8 +66,6 @@ public:
static void requestPopup(); static void requestPopup();
static QIcon taskTypeIcon(ProjectExplorer::Task::TaskType t);
signals: signals:
void categoryAdded(Core::Id categoryId, const QString &displayName, bool visible); void categoryAdded(Core::Id categoryId, const QString &displayName, bool visible);
void taskAdded(const ProjectExplorer::Task &task); void taskAdded(const ProjectExplorer::Task &task);
......
...@@ -255,7 +255,7 @@ QVariant TaskModel::data(const QModelIndex &index, int role) const ...@@ -255,7 +255,7 @@ QVariant TaskModel::data(const QModelIndex &index, int role) const
else if (role == TaskModel::Category) else if (role == TaskModel::Category)
return m_tasks.at(index.row()).category.uniqueIdentifier(); return m_tasks.at(index.row()).category.uniqueIdentifier();
else if (role == TaskModel::Icon) else if (role == TaskModel::Icon)
return TaskHub::taskTypeIcon(m_tasks.at(index.row()).type); return m_tasks.at(index.row()).icon;
else if (role == TaskModel::Task_t) else if (role == TaskModel::Task_t)
return QVariant::fromValue(task(index)); return QVariant::fromValue(task(index));
return QVariant(); return QVariant();
......
...@@ -261,9 +261,9 @@ TaskWindow::TaskWindow() : d(new TaskWindowPrivate) ...@@ -261,9 +261,9 @@ TaskWindow::TaskWindow() : d(new TaskWindowPrivate)
d->m_listview->setContextMenuPolicy(Qt::ActionsContextMenu); d->m_listview->setContextMenuPolicy(Qt::ActionsContextMenu);
d->m_filterWarningsButton = createFilterButton(TaskHub::taskTypeIcon(Task::Warning), d->m_filterWarningsButton = createFilterButton(
tr("Show Warnings"), QIcon(QLatin1String(":/projectexplorer/images/compile_warning.png")),
this, SLOT(setShowWarnings(bool))); tr("Show Warnings"), this, SLOT(setShowWarnings(bool)));
d->m_categoriesButton = new QToolButton; d->m_categoriesButton = new QToolButton;
d->m_categoriesButton->setIcon(QIcon(QLatin1String(Core::Constants::ICON_FILTER))); d->m_categoriesButton->setIcon(QIcon(QLatin1String(Core::Constants::ICON_FILTER)));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment