Commit 7c11c4d8 authored by dt's avatar dt
Browse files

Move TaskWindow::Task out of the nesting to ProjectExplorer::

Since otherwise we can't forward declare it.
parent 4d8a264f
......@@ -84,8 +84,8 @@ void AbstractProcessStep::setOutputParser(ProjectExplorer::IOutputParser *parser
if (m_outputParserChain) {
connect(parser, SIGNAL(addOutput(QString)),
this, SLOT(outputAdded(QString)));
connect(parser, SIGNAL(addTask(ProjectExplorer::TaskWindow::Task)),
this, SLOT(taskAdded(ProjectExplorer::TaskWindow::Task)));
connect(parser, SIGNAL(addTask(ProjectExplorer::Task)),
this, SLOT(taskAdded(ProjectExplorer::Task)));
}
}
......@@ -258,9 +258,9 @@ void AbstractProcessStep::checkForCancel()
}
}
void AbstractProcessStep::taskAdded(const ProjectExplorer::TaskWindow::Task &task)
void AbstractProcessStep::taskAdded(const ProjectExplorer::Task &task)
{
TaskWindow::Task editable(task);
Task editable(task);
QString filePath = QDir::cleanPath(task.file.trimmed());
if (!filePath.isEmpty() && !QDir::isAbsolutePath(filePath)) {
// We have no save way to decide which file in which subfolder
......
......@@ -144,7 +144,7 @@ private slots:
void slotProcessFinished(int, QProcess::ExitStatus);
void checkForCancel();
void taskAdded(const ProjectExplorer::TaskWindow::Task &task);
void taskAdded(const ProjectExplorer::Task &task);
void outputAdded(const QString &string);
private:
......
......@@ -133,8 +133,8 @@ void BuildManager::cancel()
// (And we want those to be before the cancel message.)
QTimer::singleShot(0, this, SLOT(emitCancelMessage()));
disconnect(m_currentBuildStep, SIGNAL(addTask(ProjectExplorer::TaskWindow::Task)),
this, SLOT(addToTaskWindow(ProjectExplorer::TaskWindow::Task)));
disconnect(m_currentBuildStep, SIGNAL(addTask(ProjectExplorer::Task)),
this, SLOT(addToTaskWindow(ProjectExplorer::Task)));
disconnect(m_currentBuildStep, SIGNAL(addOutput(QString)),
this, SLOT(addToOutputWindow(QString)));
decrementActiveBuildSteps(m_currentBuildStep->buildConfiguration()->target()->project());
......@@ -171,8 +171,8 @@ void BuildManager::clearBuildQueue()
{
foreach (BuildStep *bs, m_buildQueue) {
decrementActiveBuildSteps(bs->buildConfiguration()->target()->project());
disconnect(bs, SIGNAL(addTask(ProjectExplorer::TaskWindow::Task)),
this, SLOT(addToTaskWindow(ProjectExplorer::TaskWindow::Task)));
disconnect(bs, SIGNAL(addTask(ProjectExplorer::Task)),
this, SLOT(addToTaskWindow(ProjectExplorer::Task)));
disconnect(bs, SIGNAL(addOutput(QString)),
this, SLOT(addToOutputWindow(QString)));
}
......@@ -260,7 +260,7 @@ void BuildManager::showBuildResults()
//toggleTaskWindow();
}
void BuildManager::addToTaskWindow(const ProjectExplorer::TaskWindow::Task &task)
void BuildManager::addToTaskWindow(const ProjectExplorer::Task &task)
{
m_taskWindow->addTask(task);
}
......@@ -275,8 +275,8 @@ void BuildManager::nextBuildQueue()
if (m_canceling)
return;
disconnect(m_currentBuildStep, SIGNAL(addTask(ProjectExplorer::TaskWindow::Task)),
this, SLOT(addToTaskWindow(ProjectExplorer::TaskWindow::Task)));
disconnect(m_currentBuildStep, SIGNAL(addTask(ProjectExplorer::Task)),
this, SLOT(addToTaskWindow(ProjectExplorer::Task)));
disconnect(m_currentBuildStep, SIGNAL(addOutput(QString)),
this, SLOT(addToOutputWindow(QString)));
......@@ -343,8 +343,8 @@ bool BuildManager::buildQueueAppend(QList<BuildStep *> steps)
int i = 0;
for (; i < count; ++i) {
BuildStep *bs = steps.at(i);
connect(bs, SIGNAL(addTask(ProjectExplorer::TaskWindow::Task)),
this, SLOT(addToTaskWindow(ProjectExplorer::TaskWindow::Task)));
connect(bs, SIGNAL(addTask(ProjectExplorer::Task)),
this, SLOT(addToTaskWindow(ProjectExplorer::Task)));
connect(bs, SIGNAL(addOutput(QString)),
this, SLOT(addToOutputWindow(QString)));
init = bs->init();
......@@ -364,8 +364,8 @@ bool BuildManager::buildQueueAppend(QList<BuildStep *> steps)
// disconnect the buildsteps again
for (int j = 0; j <= i; ++j) {
BuildStep *bs = steps.at(j);
disconnect(bs, SIGNAL(addTask(ProjectExplorer::TaskWindow::Task)),
this, SLOT(addToTaskWindow(ProjectExplorer::TaskWindow::Task)));
disconnect(bs, SIGNAL(addTask(ProjectExplorer::Task)),
this, SLOT(addToTaskWindow(ProjectExplorer::Task)));
disconnect(bs, SIGNAL(addOutput(QString)),
this, SLOT(addToOutputWindow(QString)));
}
......
......@@ -92,7 +92,7 @@ signals:
void tasksChanged();
private slots:
void addToTaskWindow(const ProjectExplorer::TaskWindow::Task &task);
void addToTaskWindow(const ProjectExplorer::Task &task);
void addToOutputWindow(const QString &string);
void nextBuildQueue();
......
......@@ -102,7 +102,7 @@ public:
signals:
// Add a task.
void addTask(const ProjectExplorer::TaskWindow::Task &task);
void addTask(const ProjectExplorer::Task &task);
// The string is added to the generated output, usually in the output
// window.
// It should be in html format, that is properly escaped
......
This diff is collapsed.
......@@ -70,9 +70,9 @@ void GnuMakeParser::removeDirectory(const QString &dir)
m_directories.removeAll(dir);
}
void GnuMakeParser::taskAdded(const ProjectExplorer::TaskWindow::Task &task)
void GnuMakeParser::taskAdded(const ProjectExplorer::Task &task)
{
ProjectExplorer::TaskWindow::Task editable(task);
ProjectExplorer::Task editable(task);
QString filePath(QDir::cleanPath(task.file.trimmed()));
if (!filePath.isEmpty() && !QDir::isAbsolutePath(filePath)) {
......
......@@ -47,7 +47,7 @@ public:
virtual void stdOutput(const QString &line);
public slots:
virtual void taskAdded(const ProjectExplorer::TaskWindow::Task &task);
virtual void taskAdded(const ProjectExplorer::Task &task);
private:
void addDirectory(const QString &dir);
......
......@@ -52,8 +52,8 @@ void IOutputParser::appendOutputParser(IOutputParser *parser)
m_parser = parser;
connect(parser, SIGNAL(addOutput(QString)),
this, SLOT(outputAdded(QString)));
connect(parser, SIGNAL(addTask(ProjectExplorer::TaskWindow::Task)),
this, SLOT(taskAdded(ProjectExplorer::TaskWindow::Task)));
connect(parser, SIGNAL(addTask(ProjectExplorer::Task)),
this, SLOT(taskAdded(ProjectExplorer::Task)));
}
IOutputParser *IOutputParser::takeOutputParserChain()
......@@ -85,7 +85,7 @@ void IOutputParser::outputAdded(const QString &string)
emit addOutput(string);
}
void IOutputParser::taskAdded(const ProjectExplorer::TaskWindow::Task &task)
void IOutputParser::taskAdded(const ProjectExplorer::Task &task)
{
emit addTask(task);
}
......
......@@ -69,7 +69,7 @@ signals:
/// line!
void addOutput(const QString &string);
/// Should be emitted for each task seen in the output.
void addTask(const ProjectExplorer::TaskWindow::Task &task);
void addTask(const ProjectExplorer::Task &task);
public slots:
/// Subparsers have their addOutput signal connected to this slot.
......@@ -77,7 +77,7 @@ public slots:
virtual void outputAdded(const QString &string);
/// Subparsers have their addTask signal connected to this slot.
/// This method can be overwritten to change the task.
virtual void taskAdded(const ProjectExplorer::TaskWindow::Task &task);
virtual void taskAdded(const ProjectExplorer::Task &task);
private:
IOutputParser *m_parser;
......
......@@ -40,7 +40,8 @@ class SessionManager;
class IApplicationOutput;
class IOutputParser;
class GlobalConfigManagerInterface;
struct TaskWindow::Task;
class Project;
class Task;
namespace Internal {
class CommandQObject;
......@@ -56,7 +57,7 @@ Q_DECLARE_METATYPE(QList<ProjectExplorer::Internal::CommandQObject*>)
Q_DECLARE_METATYPE(ProjectExplorer::IOutputParser*)
Q_DECLARE_METATYPE(ProjectExplorer::GlobalConfigManagerInterface*)
Q_DECLARE_METATYPE(ProjectExplorer::TaskWindow::Task)
Q_DECLARE_METATYPE(QList<ProjectExplorer::TaskWindow::Task>)
Q_DECLARE_METATYPE(ProjectExplorer::Task)
Q_DECLARE_METATYPE(QList<ProjectExplorer::Task>)
#endif // PROJECTEXPLORERMETATYPEDECLARATIONS_H
......@@ -44,11 +44,11 @@ void MsvcParser::stdOutput(const QString &line)
{
QString lne = line.trimmed();
if (m_compileRegExp.indexIn(lne) > -1 && m_compileRegExp.numCaptures() == 4) {
emit addTask(TaskWindow::Task(toType(m_compileRegExp.cap(3).toInt()) /* task type */,
m_compileRegExp.cap(4) /* description */,
m_compileRegExp.cap(1) /* filename */,
m_compileRegExp.cap(2).toInt() /* linenumber */,
Constants::TASK_CATEGORY_COMPILE));
emit addTask(Task(toType(m_compileRegExp.cap(3).toInt()) /* task type */,
m_compileRegExp.cap(4) /* description */,
m_compileRegExp.cap(1) /* filename */,
m_compileRegExp.cap(2).toInt() /* linenumber */,
Constants::TASK_CATEGORY_COMPILE));
return;
}
if (m_linkRegExp.indexIn(lne) > -1 && m_linkRegExp.numCaptures() == 3) {
......@@ -56,22 +56,22 @@ void MsvcParser::stdOutput(const QString &line)
if (fileName.contains(QLatin1String("LINK"), Qt::CaseSensitive))
fileName.clear();
emit addTask(TaskWindow::Task(toType(m_linkRegExp.cap(2).toInt()) /* task type */,
m_linkRegExp.cap(3) /* description */,
fileName /* filename */,
-1 /* line number */,
Constants::TASK_CATEGORY_COMPILE));
emit addTask(Task(toType(m_linkRegExp.cap(2).toInt()) /* task type */,
m_linkRegExp.cap(3) /* description */,
fileName /* filename */,
-1 /* line number */,
Constants::TASK_CATEGORY_COMPILE));
return;
}
IOutputParser::stdError(line);
}
TaskWindow::TaskType MsvcParser::toType(int number)
Task::TaskType MsvcParser::toType(int number)
{
if (number == 0)
return TaskWindow::Unknown;
return Task::Unknown;
else if (number > 4000 && number < 5000)
return TaskWindow::Warning;
return Task::Warning;
else
return TaskWindow::Error;
return Task::Error;
}
......@@ -48,7 +48,7 @@ public:
virtual void stdOutput(const QString &line);
private:
TaskWindow::TaskType toType(int number);
Task::TaskType toType(int number);
QRegExp m_compileRegExp;
QRegExp m_linkRegExp;
};
......
......@@ -47,7 +47,7 @@ OutputParserTester::~OutputParserTester()
// test methods:
void OutputParserTester::testParsing(const QString &lines,
Channel inputChannel,
QList<TaskWindow::Task> tasks,
QList<Task> tasks,
const QString &childStdOutLines,
const QString &childStdErrLines,
const QString &outputLines)
......@@ -78,8 +78,8 @@ void OutputParserTester::testParsing(const QString &lines,
}
}
void OutputParserTester::testTaskMangling(const TaskWindow::Task input,
const TaskWindow::Task output)
void OutputParserTester::testTaskMangling(const Task input,
const Task output)
{
reset();
childParser()->taskAdded(input);
......@@ -145,7 +145,7 @@ void OutputParserTester::outputAdded(const QString &line)
m_receivedOutput.append(line);
}
void OutputParserTester::taskAdded(const ProjectExplorer::TaskWindow::Task &task)
void OutputParserTester::taskAdded(const ProjectExplorer::Task &task)
{
m_receivedTasks.append(task);
}
......
......@@ -50,12 +50,12 @@ public:
// test methods:
void testParsing(const QString &lines, Channel inputChannel,
QList<TaskWindow::Task> tasks,
QList<Task> tasks,
const QString &childStdOutLines,
const QString &childStdErrLines,
const QString &outputLines);
void testTaskMangling(const TaskWindow::Task input,
const TaskWindow::Task output);
void testTaskMangling(const Task input,
const Task output);
void testOutputMangling(const QString &input,
const QString &output);
......@@ -69,7 +69,7 @@ public:
private slots:
void outputAdded(const QString &line);
void taskAdded(const ProjectExplorer::TaskWindow::Task &task);
void taskAdded(const ProjectExplorer::Task &task);
private:
void reset();
......@@ -78,7 +78,7 @@ private:
QString m_receivedStdErrChildLine;
QString m_receivedStdOutChildLine;
QList<TaskWindow::Task> m_receivedTasks;
QList<Task> m_receivedTasks;
QString m_receivedOutput;
};
......
......@@ -110,8 +110,8 @@ public:
QString categoryDisplayName(const QString &categoryId) const;
void addCategory(const QString &categoryId, const QString &categoryName);
QList<TaskWindow::Task> tasks(const QString &categoryId = QString()) const;
void addTask(const TaskWindow::Task &task);
QList<Task> tasks(const QString &categoryId = QString()) const;
void addTask(const Task &task);
void clearTasks(const QString &categoryId = QString());
int sizeOfFile();
......@@ -120,12 +120,12 @@ public:
enum Roles { File = Qt::UserRole, Line, Description, FileNotFound, Type, Category };
QIcon iconFor(TaskWindow::TaskType type);
QIcon iconFor(Task::TaskType type);
private:
QHash<QString,QString> m_categories; // category id -> display name
QList<TaskWindow::Task> m_tasks; // all tasks (in order of insertion)
QMap<QString,QList<TaskWindow::Task> > m_tasksInCategory; // categoryId->tasks
QList<Task> m_tasks; // all tasks (in order of insertion)
QMap<QString,QList<Task> > m_tasksInCategory; // categoryId->tasks
QHash<QString,bool> m_fileNotFound;
int m_maxSizeOfFileName;
......@@ -219,7 +219,7 @@ void TaskModel::addCategory(const QString &categoryId, const QString &categoryNa
m_categories.insert(categoryId, categoryName);
}
QList<TaskWindow::Task> TaskModel::tasks(const QString &categoryId) const
QList<Task> TaskModel::tasks(const QString &categoryId) const
{
if (categoryId.isEmpty()) {
return m_tasks;
......@@ -228,11 +228,11 @@ QList<TaskWindow::Task> TaskModel::tasks(const QString &categoryId) const
}
}
void TaskModel::addTask(const TaskWindow::Task &task)
void TaskModel::addTask(const Task &task)
{
Q_ASSERT(m_categories.keys().contains(task.category));
QList<TaskWindow::Task> tasksInCategory = m_tasksInCategory.value(task.category);
QList<Task> tasksInCategory = m_tasksInCategory.value(task.category);
tasksInCategory.append(task);
m_tasksInCategory.insert(task.category, tasksInCategory);
......@@ -271,14 +271,14 @@ void TaskModel::clearTasks(const QString &categoryId)
m_maxSizeOfFileName = 0;
} else {
// TODO: Optimize this for consecutive rows
foreach (const TaskWindow::Task &task, m_tasksInCategory.value(categoryId)) {
foreach (const Task &task, m_tasksInCategory.value(categoryId)) {
int index = m_tasks.indexOf(task);
Q_ASSERT(index >= 0);
beginRemoveRows(QModelIndex(), index, index);
m_tasks.removeAt(index);
QList<TaskWindow::Task> tasksInCategory = m_tasksInCategory.value(categoryId);
QList<Task> tasksInCategory = m_tasksInCategory.value(categoryId);
tasksInCategory.removeOne(task);
m_tasksInCategory.insert(categoryId, tasksInCategory);
......@@ -347,11 +347,11 @@ QString TaskModel::categoryDisplayName(const QString &categoryId) const
return m_categories.value(categoryId);
}
QIcon TaskModel::iconFor(TaskWindow::TaskType type)
QIcon TaskModel::iconFor(Task::TaskType type)
{
if (type == TaskWindow::Error)
if (type == Task::Error)
return m_errorIcon;
else if (type == TaskWindow::Warning)
else if (type == Task::Warning)
return m_warningIcon;
else
return QIcon();
......@@ -399,15 +399,15 @@ bool TaskFilterModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceP
bool accept = true;
QModelIndex index = sourceModel()->index(sourceRow, 0, sourceParent);
TaskWindow::TaskType type = TaskWindow::TaskType(index.data(TaskModel::Type).toInt());
Task::TaskType type = Task::TaskType(index.data(TaskModel::Type).toInt());
switch (type) {
case TaskWindow::Unknown:
case Task::Unknown:
accept = m_includeUnknowns;
break;
case TaskWindow::Warning:
case Task::Warning:
accept = m_includeWarnings;
break;
case TaskWindow::Error:
case Task::Error:
accept = m_includeErrors;
break;
}
......@@ -423,7 +423,7 @@ bool TaskFilterModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceP
// TaskWindow
/////
static QToolButton *createFilterButton(TaskWindow::TaskType type,
static QToolButton *createFilterButton(Task::TaskType type,
const QString &toolTip, TaskModel *model,
QObject *receiver, const char *slot)
{
......@@ -474,7 +474,7 @@ TaskWindow::TaskWindow()
connect(m_copyAction, SIGNAL(triggered()), SLOT(copy()));
m_filterWarningsButton = createFilterButton(TaskWindow::Warning,
m_filterWarningsButton = createFilterButton(Task::Warning,
tr("Show Warnings"), m_model,
this, SLOT(setShowWarnings(bool)));
......@@ -489,8 +489,8 @@ TaskWindow::TaskWindow()
m_categoriesButton->setPopupMode(QToolButton::InstantPopup);
m_categoriesButton->setMenu(m_categoriesMenu);
qRegisterMetaType<ProjectExplorer::TaskWindow::Task>("ProjectExplorer::TaskWindow::Task");
qRegisterMetaType<QList<ProjectExplorer::TaskWindow::Task> >("QList<ProjectExplorer::TaskWindow::Task>");
qRegisterMetaType<ProjectExplorer::Task>("ProjectExplorer::Task");
qRegisterMetaType<QList<ProjectExplorer::Task> >("QList<ProjectExplorer::Task>");
updateActions();
}
......@@ -570,10 +570,10 @@ void TaskWindow::copy()
QString description = index.data(TaskModel::Description).toString();
QString type;
switch (index.data(TaskModel::Type).toInt()) {
case TaskWindow::Error:
case Task::Error:
type = "error: ";
break;
case TaskWindow::Warning:
case Task::Warning:
type = "warning: ";
break;
}
......@@ -633,7 +633,7 @@ int TaskWindow::errorTaskCount(const QString &categoryId) const
int errorTaskCount = 0;
foreach (const Task &task, m_model->tasks(categoryId)) {
if (task.type == TaskWindow::Error)
if (task.type == Task::Error)
++ errorTaskCount;
}
......@@ -821,7 +821,7 @@ void TaskDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
painter->setPen(textColor);
TaskModel *model = static_cast<TaskFilterModel *>(view->model())->taskModel();
TaskWindow::TaskType type = TaskWindow::TaskType(index.data(TaskModel::Type).toInt());
Task::TaskType type = Task::TaskType(index.data(TaskModel::Type).toInt());
QIcon icon = model->iconFor(type);
painter->drawPixmap(TASK_ICON_MARGIN, opt.rect.top() + TASK_ICON_MARGIN, icon.pixmap(TASK_ICON_SIZE, TASK_ICON_SIZE));
......@@ -916,7 +916,7 @@ QWidget *TaskWindowContext::widget()
//
// functions
//
bool ProjectExplorer::operator==(const TaskWindow::Task &t1, const TaskWindow::Task &t2)
bool ProjectExplorer::operator==(const Task &t1, const Task &t2)
{
return t1.type == t2.type
&& t1.line == t2.line
......@@ -925,7 +925,7 @@ bool ProjectExplorer::operator==(const TaskWindow::Task &t1, const TaskWindow::T
&& t1.category == t2.category;
}
uint ProjectExplorer::qHash(const TaskWindow::Task &task)
uint ProjectExplorer::qHash(const Task &task)
{
return qHash(task.file) + task.line;
}
......
......@@ -50,6 +50,33 @@ class TaskWindowContext;
} // namespace Internal
struct Task {
enum TaskType {
Unknown,
Error,
Warning
};
Task() : type(Unknown), line(-1)
{ }
Task(TaskType type_, const QString &description_,
const QString &file_, int line_, const QString &category_) :
type(type_), description(description_), file(file_), line(line_), category(category_)
{ }
Task(const Task &source) :
type(source.type), description(source.description), file(source.file),
line(source.line), category(source.category)
{ }
~Task()
{ }
TaskType type;
QString description;
QString file;
int line;
QString category;
};
class PROJECTEXPLORER_EXPORT TaskWindow : public Core::IOutputPane
{
Q_OBJECT
......@@ -58,33 +85,6 @@ public:
TaskWindow();
~TaskWindow();
enum TaskType {
Unknown,
Error,
Warning
};
struct Task {
Task() : type(Unknown), line(-1)
{ }
Task(TaskType type_, const QString &description_,
const QString &file_, int line_, const QString &category_) :
type(type_), description(description_), file(file_), line(line_), category(category_)
{ }
Task(const Task &source) :
type(source.type), description(source.description), file(source.file),
line(source.line), category(source.category)
{ }
~Task()
{ }
TaskType type;
QString description;
QString file;
int line;
QString category;
};
void addCategory(const QString &categoryId, const QString &displayName);
void addTask(const Task &task);
......@@ -137,8 +137,8 @@ private:
QMenu *m_categoriesMenu;
};
bool operator==(const TaskWindow::Task &t1, const TaskWindow::Task &t2);
uint qHash(const TaskWindow::Task &task);
bool operator==(const Task &t1, const Task &t2);
uint qHash(const Task &task);
} //namespace ProjectExplorer
......
......@@ -54,12 +54,12 @@ void QmlTaskManager::documentUpdated(QmlJS::Document::Ptr /*doc*/)
m_taskWindow->clearTasks(Constants::TASK_CATEGORY_QML);
foreach (const QmlJS::DiagnosticMessage &msg, doc->diagnosticMessages()) {
ProjectExplorer::TaskWindow::TaskType type
= msg.isError() ? ProjectExplorer::TaskWindow::Error
: ProjectExplorer::TaskWindow::Warning;
ProjectExplorer::Task::TaskType type
= msg.isError() ? ProjectExplorer::Task::Error
: ProjectExplorer::Task::Warning;
ProjectExplorer::TaskWindow::Task task(type, msg.message, doc->fileName(), msg.loc.startLine,
Constants::TASK_CATEGORY_QML);
ProjectExplorer::Task task(type, msg.message, doc->fileName(), msg.loc.startLine,