debugger: make shrinking of log buffer faster

Change-Id: I09ff0bf0c5fcc7df5c5dc9a05752754faee9320a
Reviewed-by: hjk <qthjk@ovi.com>
This commit is contained in:
hjk
2012-06-26 17:27:20 +02:00
parent f004876500
commit ec06d3f1af
2 changed files with 19 additions and 6 deletions

View File

@@ -156,7 +156,6 @@ public:
DebuggerPane(QWidget *parent)
: QPlainTextEdit(parent)
{
setMaximumBlockCount(100000);
setFrameStyle(QFrame::NoFrame);
m_clearContentsAction = new QAction(this);
m_clearContentsAction->setText(tr("Clear Contents"));
@@ -183,6 +182,18 @@ public:
delete menu;
}
void append(const QString &text)
{
const int N = 100000;
if (blockCount() > N) {
QTextBlock block = document()->findBlock(9 * N / 10);
QTextCursor tc(block);
tc.movePosition(QTextCursor::Start, QTextCursor::MoveAnchor);
tc.removeSelectedText();
}
appendPlainText(text);
}
private slots:
void saveContents();
@@ -434,7 +445,7 @@ void LogWindow::showOutput(int channel, const QString &output)
}
pos = nnpos + 1;
}
m_combinedText->appendPlainText(out);
m_combinedText->append(out);
if (atEnd) {
cursor.movePosition(QTextCursor::End);
@@ -455,8 +466,8 @@ void LogWindow::showInput(int channel, const QString &input)
return;
}
if (debuggerCore()->boolSetting(LogTimeStamps))
m_inputText->appendPlainText(logTimeStamp());
m_inputText->appendPlainText(input);
m_inputText->append(logTimeStamp());
m_inputText->append(input);
QTextCursor cursor = m_inputText->textCursor();
cursor.movePosition(QTextCursor::End);
m_inputText->setTextCursor(cursor);