Commit 0a751084 authored by dt's avatar dt
Browse files

Task hub

parent f552e1d0
......@@ -38,6 +38,7 @@
#include "projectexplorersettings.h"
#include "target.h"
#include "taskwindow.h"
#include "taskhub.h"
#include "buildconfiguration.h"
#include <coreplugin/icore.h>
......@@ -91,12 +92,10 @@ BuildManager::BuildManager(ProjectExplorerPlugin *parent)
m_outputWindow = new CompileOutputWindow(this);
pm->addObject(m_outputWindow);
m_taskWindow = new TaskWindow;
m_taskHub = pm->getObject<TaskHub>();
m_taskWindow = new TaskWindow(m_taskHub);
pm->addObject(m_taskWindow);
m_taskWindow->addCategory(Constants::TASK_CATEGORY_COMPILE, tr("Compile", "Category for compiler isses listened under 'Build Issues'"));
m_taskWindow->addCategory(Constants::TASK_CATEGORY_BUILDSYSTEM, tr("Build System", "Category for build system isses listened under 'Build Issues'"));
connect(m_taskWindow, SIGNAL(tasksChanged()),
this, SLOT(updateTaskCount()));
......@@ -106,6 +105,12 @@ BuildManager::BuildManager(ProjectExplorerPlugin *parent)
this, SLOT(finish()));
}
void BuildManager::extensionsInitialized()
{
m_taskHub->addCategory(Constants::TASK_CATEGORY_COMPILE, tr("Compile", "Category for compiler isses listened under 'Build Issues'"));
m_taskHub->addCategory(Constants::TASK_CATEGORY_BUILDSYSTEM, tr("Build System", "Category for build system isses listened under 'Build Issues'"));
}
BuildManager::~BuildManager()
{
cancel();
......@@ -155,7 +160,7 @@ void BuildManager::cancel()
this, SLOT(addToOutputWindow(QString, QTextCharFormat)));
decrementActiveBuildSteps(m_currentBuildStep->buildConfiguration()->target()->project());
m_progressFutureInterface->setProgressValueAndText(m_progress*100, "Build canceled"); //TODO NBS fix in qtconcurrent
m_progressFutureInterface->setProgressValueAndText(m_progress*100, tr("Build canceled")); //TODO NBS fix in qtconcurrent
clearBuildQueue();
}
return;
......@@ -231,11 +236,6 @@ bool BuildManager::tasksAvailable() const
return m_taskWindow->taskCount() > 0;
}
void BuildManager::gotoTaskWindow()
{
m_taskWindow->popup(true);
}
void BuildManager::startBuildQueue()
{
if (m_buildQueue.isEmpty()) {
......@@ -248,8 +248,8 @@ void BuildManager::startBuildQueue()
m_progressFutureInterface = new QFutureInterface<void>;
m_progressWatcher.setFuture(m_progressFutureInterface->future());
m_outputWindow->clearContents();
m_taskWindow->clearTasks(Constants::TASK_CATEGORY_COMPILE);
m_taskWindow->clearTasks(Constants::TASK_CATEGORY_BUILDSYSTEM);
m_taskHub->clearTasks(Constants::TASK_CATEGORY_COMPILE);
m_taskHub->clearTasks(Constants::TASK_CATEGORY_BUILDSYSTEM);
progressManager->setApplicationLabel("");
Core::FutureProgress *progress = progressManager->addTask(m_progressFutureInterface->future(),
tr("Build"),
......@@ -283,7 +283,8 @@ void BuildManager::showBuildResults()
void BuildManager::addToTaskWindow(const ProjectExplorer::Task &task)
{
m_outputWindow->registerPositionOf(task);
m_taskWindow->addTask(task);
// Distribute to all others
m_taskHub->addTask(task);
}
void BuildManager::addToOutputWindow(const QString &string, const QTextCharFormat &format)
......
......@@ -44,13 +44,14 @@ namespace ProjectExplorer {
namespace Internal {
class CompileOutputWindow;
class BuildProgressFuture;
class TaskWindow;
}
class BuildStep;
class Project;
class ProjectExplorerPlugin;
class BuildConfiguration;
class TaskWindow;
class TaskHub;
class PROJECTEXPLORER_EXPORT BuildManager
: public QObject
......@@ -65,11 +66,11 @@ public:
BuildManager(ProjectExplorerPlugin *parent);
~BuildManager();
void extensionsInitialized();
bool isBuilding() const;
bool tasksAvailable() const;
//shows with focus
void gotoTaskWindow();
void buildProject(BuildConfiguration *bc);
void buildProjects(const QList<BuildConfiguration *> &configurations);
......@@ -114,7 +115,8 @@ private:
void decrementActiveBuildSteps(Project *pro);
Internal::CompileOutputWindow *m_outputWindow;
TaskWindow *m_taskWindow;
TaskHub *m_taskHub;
Internal::TaskWindow *m_taskWindow;
QList<BuildStep *> m_buildQueue;
QStringList m_configurations; // the corresponding configuration to the m_buildQueue
......
......@@ -72,6 +72,7 @@
#include "buildconfiguration.h"
#include "buildconfigdialog.h"
#include "miniprojecttargetselector.h"
#include "taskhub.h"
#include <coreplugin/basemode.h>
#include <coreplugin/coreconstants.h>
......@@ -236,6 +237,9 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
{
if (!parseArguments(arguments, error))
return false;
addObject(this);
addAutoReleasedObject(new TaskHub);
Core::ICore *core = Core::ICore::instance();
Core::ActionManager *am = core->actionManager();
......@@ -243,7 +247,6 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
d->m_welcomePage = new ProjectWelcomePage;
connect(d->m_welcomePage, SIGNAL(manageSessions()), this, SLOT(showSessionManager()));
addObject(d->m_welcomePage);
addObject(this);
connect(core->fileManager(), SIGNAL(currentFileChanged(QString)),
this, SLOT(setCurrentFile(QString)));
......@@ -899,6 +902,8 @@ void ProjectExplorerPlugin::extensionsInitialized()
// class factories
foreach(Core::IWizard *cpw, ProjectExplorer::CustomWizard::createWizards())
addAutoReleasedObject(cpw);
d->m_buildManager->extensionsInitialized();
}
void ProjectExplorerPlugin::aboutToShutdown()
......@@ -1890,11 +1895,6 @@ void ProjectExplorerPlugin::invalidateProject(Project *project)
updateActions();
}
void ProjectExplorerPlugin::goToTaskWindow()
{
d->m_buildManager->gotoTaskWindow();
}
void ProjectExplorerPlugin::updateContextMenuActions(Node *node)
{
d->m_addExistingFilesAction->setEnabled(false);
......
......@@ -162,7 +162,6 @@ private slots:
void runProject();
void runProjectContextMenu();
void savePersistentSettings();
void goToTaskWindow();
void addNewFile();
void addExistingFiles();
......
......@@ -88,7 +88,8 @@ HEADERS += projectexplorer.h \
outputformatter.h \
runconfigurationmodel.h \
buildconfigurationmodel.h \
abstractprocessstep.h
abstractprocessstep.h \
taskhub.h
SOURCES += projectexplorer.cpp \
projectwindow.cpp \
buildmanager.cpp \
......@@ -161,7 +162,8 @@ SOURCES += projectexplorer.cpp \
linuxiccparser.cpp \
outputformatter.cpp \
runconfigurationmodel.cpp \
buildconfigurationmodel.cpp
buildconfigurationmodel.cpp \
taskhub.cpp
FORMS += processstep.ui \
editorsettingspropertiespage.ui \
runsettingspropertiespage.ui \
......
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at http://qt.nokia.com/contact.
**
**************************************************************************/
#include "taskhub.h"
#include <QtCore/QMetaType>
using namespace ProjectExplorer;
TaskHub::TaskHub()
: m_errorIcon(QLatin1String(":/projectexplorer/images/compile_error.png")),
m_warningIcon(QLatin1String(":/projectexplorer/images/compile_warning.png"))
{
qRegisterMetaType<ProjectExplorer::Task>("ProjectExplorer::Task");
qRegisterMetaType<QList<ProjectExplorer::Task> >("QList<ProjectExplorer::Task>");
}
TaskHub::~TaskHub()
{
}
void TaskHub::addCategory(const QString &categoryId, const QString &displayName)
{
emit categoryAdded(categoryId, displayName);
}
void TaskHub::addTask(const Task &task)
{
emit taskAdded(task);
}
void TaskHub::clearTasks(const QString &categoryId)
{
emit tasksCleared(categoryId);
}
void TaskHub::removeTask(const Task &task)
{
emit taskRemoved(task);
}
QIcon TaskHub::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();
}
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at http://qt.nokia.com/contact.
**
**************************************************************************/
#ifndef TASKHUB_H
#define TASKHUB_H
#include "task.h"
#include "projectexplorer_export.h"
#include <QtCore/QObject>
#include <QtGui/QIcon>
namespace ProjectExplorer {
class Task;
class PROJECTEXPLORER_EXPORT TaskHub : public QObject
{
Q_OBJECT
public:
TaskHub();
virtual ~TaskHub();
void addCategory(const QString &categoryId, const QString &displayName);
void addTask(const Task &task);
void clearTasks(const QString &categoryId = QString());
void removeTask(const Task &task);
// TODO now there are two places for icons
QIcon taskTypeIcon(ProjectExplorer::Task::TaskType t) const;
signals:
void categoryAdded(const QString &categoryId, const QString &displayName);
void taskAdded(const ProjectExplorer::Task &task);
void taskRemoved(const ProjectExplorer::Task &task);
void tasksCleared(const QString &categoryId);
private:
const QIcon m_errorIcon;
const QIcon m_warningIcon;
};
} // namespace ProjectExplorer
#endif // TASKHUB_H
......@@ -32,6 +32,7 @@
#include "itaskhandler.h"
#include "projectexplorerconstants.h"
#include "task.h"
#include "taskhub.h"
#include <coreplugin/actionmanager/actionmanager.h>
#include <coreplugin/actionmanager/command.h>
......@@ -476,8 +477,6 @@ bool TaskFilterModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceP
return accept;
}
} // namespace Internal
/////
// TaskWindow
/////
......@@ -495,6 +494,7 @@ public:
QToolButton *m_filterWarningsButton;
QToolButton *m_categoriesButton;
QMenu *m_categoriesMenu;
TaskHub *m_taskHub;
};
static QToolButton *createFilterButton(QIcon icon, const QString &toolTip,
......@@ -511,7 +511,7 @@ static QToolButton *createFilterButton(QIcon icon, const QString &toolTip,
return button;
}
TaskWindow::TaskWindow() : d(new TaskWindowPrivate)
TaskWindow::TaskWindow(TaskHub *taskhub) : d(new TaskWindowPrivate)
{
d->m_defaultHandler = 0;
......@@ -530,6 +530,8 @@ TaskWindow::TaskWindow() : d(new TaskWindowPrivate)
d->m_listview->setAttribute(Qt::WA_MacShowFocusRect, false);
d->m_taskWindowContext = new Internal::TaskWindowContext(d->m_listview);
d->m_taskHub = taskhub;
Core::ICore::instance()->addContextObject(d->m_taskWindowContext);
connect(d->m_listview->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)),
......@@ -549,9 +551,9 @@ TaskWindow::TaskWindow() : d(new TaskWindowPrivate)
connect(d->m_listview, SIGNAL(customContextMenuRequested(QPoint)),
this, SLOT(showContextMenu(QPoint)));
d->m_filterWarningsButton = createFilterButton(taskTypeIcon(Task::Warning),
tr("Show Warnings"),
this, SLOT(setShowWarnings(bool)));
d->m_filterWarningsButton = createFilterButton(d->m_model->taskTypeIcon(Task::Warning),
tr("Show Warnings"),
this, SLOT(setShowWarnings(bool)));
d->m_categoriesMenu = new QMenu;
connect(d->m_categoriesMenu, SIGNAL(aboutToShow()), this, SLOT(updateCategoriesMenu()));
......@@ -564,8 +566,14 @@ TaskWindow::TaskWindow() : d(new TaskWindowPrivate)
d->m_categoriesButton->setPopupMode(QToolButton::InstantPopup);
d->m_categoriesButton->setMenu(d->m_categoriesMenu);
qRegisterMetaType<ProjectExplorer::Task>("ProjectExplorer::Task");
qRegisterMetaType<QList<ProjectExplorer::Task> >("QList<ProjectExplorer::Task>");
connect(d->m_taskHub, SIGNAL(categoryAdded(QString, QString)),
this, SLOT(addCategory(QString, QString)));
connect(d->m_taskHub, SIGNAL(taskAdded(ProjectExplorer::Task)),
this, SLOT(addTask(ProjectExplorer::Task)));
connect(d->m_taskHub, SIGNAL(taskRemoved(ProjectExplorer::Task)),
this, SLOT(removeTask(ProjectExplorer::Task)));
connect(d->m_taskHub, SIGNAL(tasksCleared(QString)),
this, SLOT(clearTasks(QString)));
}
TaskWindow::~TaskWindow()
......@@ -747,7 +755,9 @@ int TaskWindow::priorityInStatusBar() const
void TaskWindow::clearContents()
{
clearTasks();
// clear all tasks in all displays
// Yeah we are that special
d->m_taskHub->clearTasks(QString());
}
bool TaskWindow::hasFocus()
......@@ -819,12 +829,6 @@ bool TaskWindow::canNavigate()
return true;
}
QIcon TaskWindow::taskTypeIcon(int t) const
{
return d->m_model->taskTypeIcon(static_cast<Task::TaskType>(t));
}
namespace Internal {
/////
// Delegate
/////
......
......@@ -30,10 +30,8 @@
#ifndef TASKWINDOW_H
#define TASKWINDOW_H
#include "projectexplorer_export.h"
#include "task.h"
#include <coreplugin/ioutputpane.h>
#include <QtGui/QIcon>
QT_BEGIN_NAMESPACE
......@@ -42,24 +40,20 @@ class QModelIndex;
QT_END_NAMESPACE
namespace ProjectExplorer {
class Task;
class TaskHub;
namespace Internal {
class TaskWindowPrivate;
// Show build issues (warnings or errors) and open the editor on click.
class PROJECTEXPLORER_EXPORT TaskWindow : public Core::IOutputPane
class TaskWindow : public Core::IOutputPane
{
Q_OBJECT
public:
TaskWindow();
TaskWindow(ProjectExplorer::TaskHub *taskHub);
virtual ~TaskWindow();
void addCategory(const QString &categoryId, const QString &displayName);
void addTask(const Task &task);
void removeTask(const Task &task);
void clearTasks(const QString &categoryId = QString());
int taskCount() const;
int errorTaskCount() const;
......@@ -82,12 +76,15 @@ public:
void goToNext();
void goToPrev();
QIcon taskTypeIcon(int t) const;
signals:
void tasksChanged();
private slots:
void addCategory(const QString &categoryId, const QString &displayName);
void addTask(const ProjectExplorer::Task &task);
void removeTask(const ProjectExplorer::Task &task);
void clearTasks(const QString &categoryId);
void triggerDefaultHandler(const QModelIndex &index);
void showContextMenu(const QPoint &position);
void contextMenuEntryTriggered(QAction *);
......@@ -102,6 +99,7 @@ private:
TaskWindowPrivate *d;
};
} //namespace ProjectExplorer
} // namespace Internal
} // namespace ProjectExplorer
#endif // TASKWINDOW_H
......@@ -46,7 +46,7 @@
#include <texteditor/texteditoractionhandler.h>
#include <projectexplorer/taskwindow.h>
#include <projectexplorer/taskhub.h>
#include <qmljs/qmljsmodelmanagerinterface.h>
#include <QtCore/QtPlugin>
......@@ -89,15 +89,14 @@ bool QmlProjectPlugin::initialize(const QStringList &, QString *errorMessage)
Core::FileIconProvider *iconProvider = Core::FileIconProvider::instance();
iconProvider->registerIconOverlayForSuffix(QIcon(":/qmlproject/images/qmlproject.png"), "qmlproject");
return true;
}
void QmlProjectPlugin::extensionsInitialized()
{
ExtensionSystem::PluginManager *pluginManager = ExtensionSystem::PluginManager::instance();
ProjectExplorer::TaskWindow *taskWindow = pluginManager->getObject<ProjectExplorer::TaskWindow>();
m_qmlTaskManager->setTaskWindow(taskWindow);
ProjectExplorer::TaskHub *taskHub = pluginManager->getObject<ProjectExplorer::TaskHub>();
taskHub->addCategory(Constants::TASK_CATEGORY_QML, tr("QML"));
QmlJS::ModelManagerInterface *modelManager = pluginManager->getObject<QmlJS::ModelManagerInterface>();
Q_ASSERT(modelManager);
......
......@@ -31,7 +31,7 @@
#include "qmlprojectconstants.h"
#include <extensionsystem/pluginmanager.h>
#include <projectexplorer/taskwindow.h>
#include <projectexplorer/taskhub.h>
#include <QDebug>
......@@ -40,8 +40,9 @@ namespace Internal {
QmlTaskManager::QmlTaskManager(QObject *parent) :
QObject(parent),
m_taskWindow(0)
m_taskHub(0)
{
m_taskHub = ExtensionSystem::PluginManager::instance()->getObject<ProjectExplorer::TaskHub>();
}
QmlTaskManager *QmlTaskManager::instance()
......@@ -50,14 +51,6 @@ QmlTaskManager *QmlTaskManager::instance()
return pluginManager->getObject<QmlTaskManager>();
}
void QmlTaskManager::setTaskWindow(ProjectExplorer::TaskWindow *taskWindow)
{
Q_ASSERT(taskWindow);
m_taskWindow = taskWindow;
m_taskWindow->addCategory(Constants::TASK_CATEGORY_QML, tr("QML"));
}
void QmlTaskManager::documentChangedOnDisk(QmlJS::Document::Ptr doc)
{
const QString fileName = doc->fileName();
......@@ -85,7 +78,7 @@ void QmlTaskManager::insertTask(const QString &fileName, const ProjectExplorer::
QList<ProjectExplorer::Task> tasks = m_docsWithTasks.value(fileName);
tasks.append(task);
m_docsWithTasks.insert(fileName, tasks);
m_taskWindow->addTask(task);
m_taskHub->addTask(task);
}
void QmlTaskManager::removeTasksForFile(const QString &fileName)
......@@ -93,7 +86,7 @@ void QmlTaskManager::removeTasksForFile(const QString &fileName)
if (m_docsWithTasks.contains(fileName)) {
const QList<ProjectExplorer::Task> tasks = m_docsWithTasks.value(fileName);
foreach (const ProjectExplorer::Task &task, tasks)
m_taskWindow->removeTask(task);
m_taskHub->removeTask(task);
m_docsWithTasks.remove(fileName);
}
}
......
......@@ -39,7 +39,7 @@
#include <QtCore/QString>
namespace ProjectExplorer {
class TaskWindow;
class TaskHub;
} // namespace ProjectExplorer
namespace QmlProjectManager {
......@@ -51,8 +51,6 @@ class QmlTaskManager : public QObject
public:
QmlTaskManager(QObject *parent = 0);
void setTaskWindow(ProjectExplorer::TaskWindow *taskWindow);
static QmlTaskManager *instance();
public slots:
......@@ -64,7 +62,7 @@ private:
void removeTasksForFile(const QString &fileName);
private:
ProjectExplorer::TaskWindow *m_taskWindow;
ProjectExplorer::TaskHub *m_taskHub;
QMap<QString, QList<ProjectExplorer::Task> > m_docsWithTasks;
};
......
......@@ -37,6 +37,7 @@
#include <extensionsystem/pluginmanager.h>
#include <projectexplorer/task.h>
#include <projectexplorer/taskhub.h>
#include <utils/qtcassert.h>
#include <QtGui/QFileDialog>
......@@ -471,9 +472,9 @@ QPair<QIcon, QString> TargetSetupPage::reportIssues(Qt4ProjectManager::QtVersion
if (m_proFilePath.isEmpty())
return qMakePair(QIcon(), QString());