forked from qt-creator/qt-creator
TaskWindow: Fix warnings about leaking X11 pixmap data.
Attach icons to TaskModel. Reviewed-by: Daniel Molkentin <daniel.molkentin@nokia.com>
This commit is contained in:
@@ -53,27 +53,12 @@
|
|||||||
#include <QtGui/QMenu>
|
#include <QtGui/QMenu>
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
const int TASK_ICON_SIZE = 16;
|
const int TASK_ICON_SIZE = 16;
|
||||||
const int TASK_ICON_MARGIN = 2;
|
const int TASK_ICON_MARGIN = 2;
|
||||||
|
|
||||||
const QIcon ERROR_ICON(":/projectexplorer/images/compile_error.png");
|
|
||||||
const QIcon WARNING_ICON(":/projectexplorer/images/compile_warning.png");
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace ProjectExplorer {
|
namespace ProjectExplorer {
|
||||||
|
|
||||||
QIcon Task::icon() const
|
|
||||||
{
|
|
||||||
if (type == ProjectExplorer::Task::Error)
|
|
||||||
return ERROR_ICON;
|
|
||||||
else if (type == ProjectExplorer::Task::Warning)
|
|
||||||
return WARNING_ICON;
|
|
||||||
else
|
|
||||||
return QIcon();
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
class TaskView : public QListView
|
class TaskView : public QListView
|
||||||
@@ -141,6 +126,8 @@ public:
|
|||||||
|
|
||||||
enum Roles { File = Qt::UserRole, Line, Description, FileNotFound, Type, Category, Icon, Task_t };
|
enum Roles { File = Qt::UserRole, Line, Description, FileNotFound, Type, Category, Icon, Task_t };
|
||||||
|
|
||||||
|
QIcon taskTypeIcon(Task::TaskType t) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QHash<QString,QString> m_categories; // category id -> display name
|
QHash<QString,QString> m_categories; // category id -> display name
|
||||||
QList<Task> m_tasks; // all tasks (in order of insertion)
|
QList<Task> m_tasks; // all tasks (in order of insertion)
|
||||||
@@ -148,8 +135,8 @@ private:
|
|||||||
|
|
||||||
QHash<QString,bool> m_fileNotFound;
|
QHash<QString,bool> m_fileNotFound;
|
||||||
int m_maxSizeOfFileName;
|
int m_maxSizeOfFileName;
|
||||||
QIcon m_errorIcon;
|
const QIcon m_errorIcon;
|
||||||
QIcon m_warningIcon;
|
const QIcon m_warningIcon;
|
||||||
};
|
};
|
||||||
|
|
||||||
class TaskFilterModel : public QSortFilterProxyModel
|
class TaskFilterModel : public QSortFilterProxyModel
|
||||||
@@ -224,11 +211,24 @@ void TaskView::keyPressEvent(QKeyEvent *e)
|
|||||||
// TaskModel
|
// TaskModel
|
||||||
/////
|
/////
|
||||||
|
|
||||||
TaskModel::TaskModel()
|
TaskModel::TaskModel() :
|
||||||
|
m_maxSizeOfFileName(0),
|
||||||
|
m_errorIcon(QLatin1String(":/projectexplorer/images/compile_error.png")),
|
||||||
|
m_warningIcon(QLatin1String(":/projectexplorer/images/compile_warning.png"))
|
||||||
{
|
{
|
||||||
m_maxSizeOfFileName = 0;
|
}
|
||||||
m_errorIcon = QIcon(":/projectexplorer/images/compile_error.png");
|
|
||||||
m_warningIcon = QIcon(":/projectexplorer/images/compile_warning.png");
|
QIcon TaskModel::taskTypeIcon(Task::TaskType t) const
|
||||||
|
{
|
||||||
|
switch (t) {
|
||||||
|
case Task::Warning:
|
||||||
|
return m_warningIcon;
|
||||||
|
case Task::Error:
|
||||||
|
return m_errorIcon;
|
||||||
|
case Task::Unknown:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return QIcon();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TaskModel::addCategory(const QString &categoryId, const QString &categoryName)
|
void TaskModel::addCategory(const QString &categoryId, const QString &categoryName)
|
||||||
@@ -353,7 +353,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;
|
return m_tasks.at(index.row()).category;
|
||||||
} else if (role == TaskModel::Icon) {
|
} else if (role == TaskModel::Icon) {
|
||||||
return m_tasks.at(index.row()).icon();
|
return taskTypeIcon(m_tasks.at(index.row()).type);
|
||||||
} else if (role == TaskModel::Task_t) {
|
} else if (role == TaskModel::Task_t) {
|
||||||
return QVariant::fromValue(m_tasks.at(index.row()));
|
return QVariant::fromValue(m_tasks.at(index.row()));
|
||||||
}
|
}
|
||||||
@@ -495,7 +495,7 @@ TaskWindow::TaskWindow()
|
|||||||
connect(m_listview, SIGNAL(clicked(QModelIndex)),
|
connect(m_listview, SIGNAL(clicked(QModelIndex)),
|
||||||
this, SLOT(showTaskInFile(QModelIndex)));
|
this, SLOT(showTaskInFile(QModelIndex)));
|
||||||
|
|
||||||
m_filterWarningsButton = createFilterButton(WARNING_ICON,
|
m_filterWarningsButton = createFilterButton(taskTypeIcon(Task::Warning),
|
||||||
tr("Show Warnings"),
|
tr("Show Warnings"),
|
||||||
this, SLOT(setShowWarnings(bool)));
|
this, SLOT(setShowWarnings(bool)));
|
||||||
|
|
||||||
@@ -771,6 +771,11 @@ void TaskWindow::updateActions()
|
|||||||
m_copyAction->setEnabled(m_model->tasks().count() > 0);
|
m_copyAction->setEnabled(m_model->tasks().count() > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QIcon TaskWindow::taskTypeIcon(Task::TaskType t) const
|
||||||
|
{
|
||||||
|
return m_model->taskTypeIcon(t);
|
||||||
|
}
|
||||||
|
|
||||||
/////
|
/////
|
||||||
// Delegate
|
// Delegate
|
||||||
/////
|
/////
|
||||||
|
|||||||
@@ -86,9 +86,6 @@ struct PROJECTEXPLORER_EXPORT Task {
|
|||||||
// doesn't work if you split it up, nor are our parsers
|
// doesn't work if you split it up, nor are our parsers
|
||||||
// anywhere near being that good
|
// anywhere near being that good
|
||||||
QList<QTextLayout::FormatRange> formats;
|
QList<QTextLayout::FormatRange> formats;
|
||||||
|
|
||||||
/// Get the icon used to represent this task
|
|
||||||
QIcon icon() const;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class PROJECTEXPLORER_EXPORT TaskWindow : public Core::IOutputPane
|
class PROJECTEXPLORER_EXPORT TaskWindow : public Core::IOutputPane
|
||||||
@@ -128,6 +125,8 @@ public:
|
|||||||
void goToNext();
|
void goToNext();
|
||||||
void goToPrev();
|
void goToPrev();
|
||||||
|
|
||||||
|
QIcon taskTypeIcon(Task::TaskType t) const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void tasksChanged();
|
void tasksChanged();
|
||||||
|
|
||||||
|
|||||||
@@ -35,6 +35,9 @@
|
|||||||
#include "qt4projectmanagerconstants.h"
|
#include "qt4projectmanagerconstants.h"
|
||||||
#include "qt4target.h"
|
#include "qt4target.h"
|
||||||
|
|
||||||
|
#include <utils/qtcassert.h>
|
||||||
|
#include <extensionsystem/pluginmanager.h>
|
||||||
|
|
||||||
#include <QtGui/QFileDialog>
|
#include <QtGui/QFileDialog>
|
||||||
#include <QtGui/QHeaderView>
|
#include <QtGui/QHeaderView>
|
||||||
#include <QtGui/QLabel>
|
#include <QtGui/QLabel>
|
||||||
@@ -442,21 +445,26 @@ QPair<QIcon, QString> TargetSetupPage::reportIssues(Qt4ProjectManager::QtVersion
|
|||||||
if (m_proFilePath.isEmpty())
|
if (m_proFilePath.isEmpty())
|
||||||
return qMakePair(QIcon(), QString());
|
return qMakePair(QIcon(), QString());
|
||||||
|
|
||||||
|
const ProjectExplorer::TaskWindow *taskWindow = ExtensionSystem::PluginManager::instance()
|
||||||
|
->getObject<ProjectExplorer::TaskWindow>();
|
||||||
|
QTC_ASSERT(taskWindow, return qMakePair(QIcon(), QString()));
|
||||||
|
|
||||||
QList<ProjectExplorer::Task> issues = version->reportIssues(m_proFilePath);
|
QList<ProjectExplorer::Task> issues = version->reportIssues(m_proFilePath);
|
||||||
|
|
||||||
|
|
||||||
QString text;
|
QString text;
|
||||||
QIcon icon;
|
QIcon icon;
|
||||||
foreach (const ProjectExplorer::Task t, issues) {
|
foreach (const ProjectExplorer::Task &t, issues) {
|
||||||
if (!text.isEmpty())
|
if (!text.isEmpty())
|
||||||
text.append(QLatin1String("<br>"));
|
text.append(QLatin1String("<br>"));
|
||||||
// set severity:
|
// set severity:
|
||||||
QString severity;
|
QString severity;
|
||||||
if (t.type == ProjectExplorer::Task::Error) {
|
if (t.type == ProjectExplorer::Task::Error) {
|
||||||
icon = t.icon();
|
icon = taskWindow->taskTypeIcon(t.type);
|
||||||
severity = tr("<b>Error:</b> ", "Severity is Task::Error");
|
severity = tr("<b>Error:</b> ", "Severity is Task::Error");
|
||||||
} else if (t.type == ProjectExplorer::Task::Warning) {
|
} else if (t.type == ProjectExplorer::Task::Warning) {
|
||||||
if (icon.isNull())
|
if (icon.isNull())
|
||||||
icon = t.icon();
|
icon = taskWindow->taskTypeIcon(t.type);
|
||||||
severity = tr("<b>Warning:</b> ", "Severity is Task::Warning");
|
severity = tr("<b>Warning:</b> ", "Severity is Task::Warning");
|
||||||
}
|
}
|
||||||
text.append(severity + t.description);
|
text.append(severity + t.description);
|
||||||
|
|||||||
Reference in New Issue
Block a user