Commit d4ed1e2b authored by Tobias Hunger's avatar Tobias Hunger
Browse files

Add show output task handler

 * Add a taskhandler that shows the compile output that
   originally created the task.

Task-number: QTCREATORBUG-107
Reviewed-by: dt
parent fa6e6bc7
......@@ -282,6 +282,7 @@ void BuildManager::showBuildResults()
void BuildManager::addToTaskWindow(const ProjectExplorer::Task &task)
{
m_outputWindow->registerPositionOf(task);
m_taskWindow->addTask(task);
}
......
......@@ -29,12 +29,17 @@
#include "compileoutputwindow.h"
#include "buildmanager.h"
#include "showoutputtaskhandler.h"
#include "task.h"
#include <find/basetextfind.h>
#include <aggregation/aggregate.h>
#include <extensionsystem/pluginmanager.h>
#include <QtGui/QKeyEvent>
#include <QtGui/QIcon>
#include <QtGui/QTextBlock>
#include <QtGui/QTextCursor>
#include <QtGui/QTextEdit>
#include <QtGui/QScrollBar>
#include <QtGui/QPlainTextEdit>
......@@ -54,6 +59,15 @@ CompileOutputWindow::CompileOutputWindow(BuildManager * /*bm*/)
agg->add(new Find::BaseTextFind(m_textEdit));
qRegisterMetaType<QTextCharFormat>("QTextCharFormat");
m_handler = new ShowOutputTaskHandler(this);
ExtensionSystem::PluginManager::instance()->addObject(m_handler);
}
CompileOutputWindow::~CompileOutputWindow()
{
ExtensionSystem::PluginManager::instance()->removeObject(m_handler);
delete m_handler;
}
bool CompileOutputWindow::hasFocus()
......@@ -91,6 +105,7 @@ void CompileOutputWindow::appendText(const QString &text, const QTextCharFormat
void CompileOutputWindow::clearContents()
{
m_textEdit->clear();
m_taskPositions.clear();
}
void CompileOutputWindow::visibilityChanged(bool b)
......@@ -128,3 +143,22 @@ bool CompileOutputWindow::canNavigate()
{
return false;
}
void CompileOutputWindow::registerPositionOf(const Task &task)
{
QTextBlock block(m_textEdit->textCursor().block());
m_taskPositions.insert(task.taskId, block.position() + block.length() + 1);
}
bool CompileOutputWindow::knowsPositionOf(const Task &task)
{
return (m_taskPositions.contains(task.taskId));
}
void CompileOutputWindow::showPositionOf(const Task &task)
{
int position = m_taskPositions.value(task.taskId);
QTextCursor newCursor(m_textEdit->document()->findBlock(position));
newCursor.movePosition(QTextCursor::EndOfBlock, QTextCursor::KeepAnchor);
m_textEdit->setTextCursor(newCursor);
}
......@@ -31,6 +31,9 @@
#define COMPILEOUTPUTWINDOW_H
#include <coreplugin/ioutputpane.h>
#include <QtCore/QHash>
#include <QtGui/QColor>
#include <QtGui/QTextCharFormat>
......@@ -41,15 +44,20 @@ QT_END_NAMESPACE
namespace ProjectExplorer {
class BuildManager;
class Task;
namespace Internal {
class ShowOutputTaskHandler;
class CompileOutputWindow : public Core::IOutputPane
{
Q_OBJECT
public:
CompileOutputWindow(BuildManager *bm);
~CompileOutputWindow();
QWidget *outputWidget(QWidget *);
QList<QWidget*> toolBarWidgets() const { return QList<QWidget *>(); }
QString displayName() const { return tr("Compile Output"); }
......@@ -67,8 +75,14 @@ public:
void goToPrev();
bool canNavigate();
void registerPositionOf(const Task &task);
bool knowsPositionOf(const Task &task);
void showPositionOf(const Task &task);
private:
QPlainTextEdit *m_textEdit;
QHash<unsigned int, int> m_taskPositions;
ShowOutputTaskHandler * m_handler;
};
} // namespace Internal
......
......@@ -20,6 +20,7 @@ HEADERS += projectexplorer.h \
itaskhandler.h \
copytaskhandler.h \
showineditortaskhandler.h \
showoutputtaskhandler.h \
vcsannotatetaskhandler.h \
taskwindow.h \
outputwindow.h \
......@@ -100,6 +101,7 @@ SOURCES += projectexplorer.cpp \
task.cpp \
copytaskhandler.cpp \
showineditortaskhandler.cpp \
showoutputtaskhandler.cpp \
vcsannotatetaskhandler.cpp \
taskwindow.cpp \
outputwindow.cpp \
......
......@@ -78,6 +78,7 @@ const char * const RENAMEFILE = "ProjectExplorer.RenameFile";
const char * const SHOW_TASK_IN_EDITOR = "ProjectExplorer.ShowTaskInEditor";
const char * const VCS_ANNOTATE_TASK = "ProjectExplorer.VcsAnnotateTask";
const char * const SHOW_TASK_OUTPUT = "ProjectExplorer.ShowTaskOutput";
// Run modes
const char * const RUNMODE = "ProjectExplorer.RunMode";
......
/**************************************************************************
**
** 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 "showoutputtaskhandler.h"
#include "projectexplorerconstants.h"
#include "task.h"
#include "compileoutputwindow.h"
#include <QtGui/QAction>
using namespace ProjectExplorer::Internal;
ShowOutputTaskHandler::ShowOutputTaskHandler(CompileOutputWindow *window) :
ITaskHandler(QLatin1String(Constants::SHOW_TASK_OUTPUT)),
m_window(window)
{
Q_ASSERT(m_window);
}
bool ShowOutputTaskHandler::canHandle(const ProjectExplorer::Task &task)
{
return m_window->knowsPositionOf(task);
}
void ShowOutputTaskHandler::handle(const ProjectExplorer::Task &task)
{
Q_ASSERT(canHandle(task));
m_window->popup(); // popup first as this does move the visible area!
m_window->showPositionOf(task);
}
QAction *ShowOutputTaskHandler::createAction(QObject *parent)
{
QAction *outputAction = new QAction(tr("Show &Output"), parent);
outputAction->setToolTip(tr("Show output generating this issue."));
return outputAction;
}
/**************************************************************************
**
** 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 PROJECTEXPLORER_SHOWOUTPUTTASKHANDLER_H
#define PROJECTEXPLORER_SHOWOUTPUTTASKHANDLER_H
#include "projectexplorer_export.h"
#include "itaskhandler.h"
namespace ProjectExplorer {
namespace Internal {
class CompileOutputWindow;
class PROJECTEXPLORER_EXPORT ShowOutputTaskHandler : public ITaskHandler
{
public:
ShowOutputTaskHandler(CompileOutputWindow *);
bool canHandle(const Task &);
void handle(const Task &task);
QAction *createAction(QObject *parent = 0);
private:
CompileOutputWindow * m_window;
};
} // namespace Internal
} // namespace ProjectExplorer
#endif // PROJECTEXPLORER_SHOWOUTPUTTASKHANDLER_H
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