Commit 8685dff3 authored by dt's avatar dt
Browse files

Fix scrolling of compile output windwow again

This time by porting to the ApplicationOutputwindow

cherry-pick of fd01cc976aff8da1efe55bc8ad9eeb05a04f08e1
parent 6fdfc659
......@@ -42,23 +42,27 @@
using namespace ProjectExplorer;
using namespace ProjectExplorer::Internal;
namespace {
const int MAX_LINECOUNT = 10000;
}
CompileOutputWindow::CompileOutputWindow(BuildManager * /*bm*/)
{
m_textEdit = new QPlainTextEdit();
m_textEdit->setWindowTitle(tr("Compile Output"));
m_textEdit->setWindowIcon(QIcon(":/qt4projectmanager/images/window.png"));
m_textEdit->setReadOnly(true);
m_textEdit->setFrameStyle(QFrame::NoFrame);
m_outputWindow = new OutputWindow();
m_outputWindow->setWindowTitle(tr("Compile Output"));
m_outputWindow->setWindowIcon(QIcon(":/qt4projectmanager/images/window.png"));
m_outputWindow->setReadOnly(true);
Aggregation::Aggregate *agg = new Aggregation::Aggregate;
agg->add(m_textEdit);
agg->add(new Find::BaseTextFind(m_textEdit));
agg->add(m_outputWindow);
agg->add(new Find::BaseTextFind(m_outputWindow));
qRegisterMetaType<QTextCharFormat>("QTextCharFormat");
}
bool CompileOutputWindow::hasFocus()
{
return m_textEdit->hasFocus();
return m_outputWindow->hasFocus();
}
bool CompileOutputWindow::canFocus()
......@@ -68,35 +72,27 @@ bool CompileOutputWindow::canFocus()
void CompileOutputWindow::setFocus()
{
m_textEdit->setFocus();
m_outputWindow->setFocus();
}
QWidget *CompileOutputWindow::outputWidget(QWidget *)
{
return m_textEdit;
return m_outputWindow;
}
void CompileOutputWindow::appendText(const QString &text, const QTextCharFormat &textCharFormat)
{
QString textWithNewline = text;
if (!textWithNewline.endsWith("\n"))
textWithNewline.append("\n");
QTextCursor cursor = QTextCursor(m_textEdit->document());
cursor.movePosition(QTextCursor::End);
cursor.beginEditBlock();
cursor.insertText(textWithNewline, textCharFormat);
cursor.endEditBlock();
m_outputWindow->appendText(text, textCharFormat, MAX_LINECOUNT);
}
void CompileOutputWindow::clearContents()
{
m_textEdit->clear();
m_outputWindow->clear();
}
void CompileOutputWindow::visibilityChanged(bool b)
void CompileOutputWindow::visibilityChanged(bool)
{
if (b)
m_textEdit->verticalScrollBar()->setValue(m_textEdit->verticalScrollBar()->maximum());
}
int CompileOutputWindow::priorityInStatusBar() const
......
......@@ -30,6 +30,7 @@
#ifndef COMPILEOUTPUTWINDOW_H
#define COMPILEOUTPUTWINDOW_H
#include "outputwindow.h"
#include <coreplugin/ioutputpane.h>
#include <QtGui/QColor>
#include <QtGui/QTextCharFormat>
......@@ -68,7 +69,7 @@ public:
bool canNavigate();
private:
QPlainTextEdit *m_textEdit;
OutputWindow *m_outputWindow;
};
} // namespace Internal
......
......@@ -201,6 +201,8 @@ void OutputPane::createNewOutputWindow(RunControl *rc)
}
if (!found) {
OutputWindow *ow = new OutputWindow(m_tabWidget);
ow->setWindowTitle(tr("Application Output Window"));
ow->setWindowIcon(QIcon(":/qt4projectmanager/images/window.png"));
ow->setFormatter(rc->createOutputFormatter(ow));
Aggregation::Aggregate *agg = new Aggregation::Aggregate;
agg->add(ow);
......@@ -356,8 +358,6 @@ OutputWindow::OutputWindow(QWidget *parent)
{
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
//setCenterOnScroll(false);
setWindowTitle(tr("Application Output Window"));
setWindowIcon(QIcon(":/qt4projectmanager/images/window.png"));
setFrameShape(QFrame::NoFrame);
setMouseTracking(true);
......@@ -494,6 +494,28 @@ void OutputWindow::appendMessage(const QString &out, bool isError)
enableUndoRedo();
}
// TODO rename
void OutputWindow::appendText(const QString &text, const QTextCharFormat &format, int maxLineCount)
{
if (document()->blockCount() > maxLineCount)
return;
const bool atBottom = isScrollbarAtBottom();
QTextCursor cursor = QTextCursor(document());
cursor.movePosition(QTextCursor::End);
cursor.beginEditBlock();
cursor.insertText(doNewlineEnfocement(text), format);
if (document()->blockCount() > maxLineCount) {
QTextCharFormat tmp;
tmp.setFontWeight(QFont::Bold);
cursor.insertText(tr("Additional output omitted\n"), tmp);
}
cursor.endEditBlock();
if (atBottom)
scrollToBottom();
}
bool OutputWindow::isScrollbarAtBottom() const
{
return verticalScrollBar()->value() == verticalScrollBar()->maximum();
......
......@@ -132,11 +132,19 @@ public:
void appendApplicationOutput(const QString &out, bool onStdErr);
void appendApplicationOutputInline(const QString &out, bool onStdErr);
void appendMessage(const QString &out, bool isError);
/// appends a \p text using \p format without using formater
void appendText(const QString &text, const QTextCharFormat &format, int maxLineCount);
void grayOutOldContent();
void showEvent(QShowEvent *);
void clear()
{
m_enforceNewline = false;
QPlainTextEdit::clear();
}
protected:
void mousePressEvent(QMouseEvent *e);
void mouseReleaseEvent(QMouseEvent *e);
......
Supports Markdown
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