Files
qt-creator/src/plugins/projectexplorer/compileoutputwindow.cpp

164 lines
4.1 KiB
C++
Raw Normal View History

/**************************************************************************
2008-12-02 12:01:29 +01:00
**
** This file is part of Qt Creator
**
2010-03-05 11:25:49 +01:00
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
2008-12-02 12:01:29 +01:00
**
** Contact: Nokia Corporation (qt-info@nokia.com)
2008-12-02 12:01:29 +01:00
**
** 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
2009-08-14 09:30:56 +02:00
** contact the sales department at http://qt.nokia.com/contact.
2008-12-02 12:01:29 +01:00
**
**************************************************************************/
2008-12-02 16:19:05 +01:00
2008-12-02 12:01:29 +01:00
#include "compileoutputwindow.h"
#include "buildmanager.h"
#include "showoutputtaskhandler.h"
#include "task.h"
2008-12-02 12:01:29 +01:00
#include <find/basetextfind.h>
#include <aggregation/aggregate.h>
#include <extensionsystem/pluginmanager.h>
2008-12-02 12:01:29 +01:00
#include <QtGui/QKeyEvent>
#include <QtGui/QIcon>
2010-07-13 16:36:37 +02:00
#include <QtGui/QTextCharFormat>
#include <QtGui/QTextBlock>
#include <QtGui/QTextCursor>
2008-12-02 12:01:29 +01:00
#include <QtGui/QTextEdit>
#include <QtGui/QScrollBar>
#include <QtGui/QPlainTextEdit>
2008-12-02 12:01:29 +01:00
using namespace ProjectExplorer;
using namespace ProjectExplorer::Internal;
namespace {
const int MAX_LINECOUNT = 10000;
}
2008-12-02 12:01:29 +01:00
CompileOutputWindow::CompileOutputWindow(BuildManager * /*bm*/)
{
m_outputWindow = new OutputWindow();
m_outputWindow->setWindowTitle(tr("Compile Output"));
m_outputWindow->setWindowIcon(QIcon(":/qt4projectmanager/images/window.png"));
m_outputWindow->setReadOnly(true);
2008-12-02 12:01:29 +01:00
Aggregation::Aggregate *agg = new Aggregation::Aggregate;
agg->add(m_outputWindow);
agg->add(new Find::BaseTextFind(m_outputWindow));
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;
2008-12-02 12:01:29 +01:00
}
bool CompileOutputWindow::hasFocus()
{
return m_outputWindow->hasFocus();
2008-12-02 12:01:29 +01:00
}
bool CompileOutputWindow::canFocus()
{
return true;
}
void CompileOutputWindow::setFocus()
{
m_outputWindow->setFocus();
2008-12-02 12:01:29 +01:00
}
QWidget *CompileOutputWindow::outputWidget(QWidget *)
{
return m_outputWindow;
2008-12-02 12:01:29 +01:00
}
void CompileOutputWindow::appendText(const QString &text, const QTextCharFormat &textCharFormat)
2008-12-02 12:01:29 +01:00
{
m_outputWindow->appendText(text, textCharFormat, MAX_LINECOUNT);
2008-12-02 12:01:29 +01:00
}
void CompileOutputWindow::clearContents()
{
m_outputWindow->clear();
m_taskPositions.clear();
2008-12-02 12:01:29 +01:00
}
void CompileOutputWindow::visibilityChanged(bool)
2008-12-02 12:01:29 +01:00
{
2008-12-02 12:01:29 +01:00
}
int CompileOutputWindow::priorityInStatusBar() const
{
return 50;
}
bool CompileOutputWindow::canNext()
{
return false;
}
bool CompileOutputWindow::canPrevious()
{
return false;
}
void CompileOutputWindow::goToNext()
{
}
void CompileOutputWindow::goToPrev()
{
}
bool CompileOutputWindow::canNavigate()
{
return false;
}
void CompileOutputWindow::registerPositionOf(const Task &task)
{
int blocknumber = m_outputWindow->blockCount();
if (blocknumber > MAX_LINECOUNT)
return;
m_taskPositions.insert(task.taskId, blocknumber - 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_outputWindow->document()->findBlockByNumber(position));
newCursor.movePosition(QTextCursor::EndOfBlock, QTextCursor::KeepAnchor);
m_outputWindow->setTextCursor(newCursor);
}