diff options
Diffstat (limited to 'src/plugins')
7 files changed, 175 insertions, 0 deletions
diff --git a/src/plugins/projectexplorer/buildmanager.cpp b/src/plugins/projectexplorer/buildmanager.cpp index 272e38e0be..45b5c0645b 100644 --- a/src/plugins/projectexplorer/buildmanager.cpp +++ b/src/plugins/projectexplorer/buildmanager.cpp @@ -282,6 +282,7 @@ void BuildManager::showBuildResults() void BuildManager::addToTaskWindow(const ProjectExplorer::Task &task) { + m_outputWindow->registerPositionOf(task); m_taskWindow->addTask(task); } diff --git a/src/plugins/projectexplorer/compileoutputwindow.cpp b/src/plugins/projectexplorer/compileoutputwindow.cpp index a0856c7675..78a5646223 100644 --- a/src/plugins/projectexplorer/compileoutputwindow.cpp +++ b/src/plugins/projectexplorer/compileoutputwindow.cpp @@ -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); +} diff --git a/src/plugins/projectexplorer/compileoutputwindow.h b/src/plugins/projectexplorer/compileoutputwindow.h index 1ad0aba28a..2065af56a8 100644 --- a/src/plugins/projectexplorer/compileoutputwindow.h +++ b/src/plugins/projectexplorer/compileoutputwindow.h @@ -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 diff --git a/src/plugins/projectexplorer/projectexplorer.pro b/src/plugins/projectexplorer/projectexplorer.pro index 96e0b66b7e..53a543de1d 100644 --- a/src/plugins/projectexplorer/projectexplorer.pro +++ b/src/plugins/projectexplorer/projectexplorer.pro @@ -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 \ diff --git a/src/plugins/projectexplorer/projectexplorerconstants.h b/src/plugins/projectexplorer/projectexplorerconstants.h index 7a4509972f..5a09c20c61 100644 --- a/src/plugins/projectexplorer/projectexplorerconstants.h +++ b/src/plugins/projectexplorer/projectexplorerconstants.h @@ -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"; diff --git a/src/plugins/projectexplorer/showoutputtaskhandler.cpp b/src/plugins/projectexplorer/showoutputtaskhandler.cpp new file mode 100644 index 0000000000..c02f6e623d --- /dev/null +++ b/src/plugins/projectexplorer/showoutputtaskhandler.cpp @@ -0,0 +1,65 @@ +/************************************************************************** +** +** 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; +} diff --git a/src/plugins/projectexplorer/showoutputtaskhandler.h b/src/plugins/projectexplorer/showoutputtaskhandler.h new file mode 100644 index 0000000000..157de4757c --- /dev/null +++ b/src/plugins/projectexplorer/showoutputtaskhandler.h @@ -0,0 +1,58 @@ +/************************************************************************** +** +** 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 |