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

View File

@@ -47,6 +47,8 @@ QT_END_NAMESPACE
namespace Debugger { namespace Debugger {
namespace Internal { namespace Internal {
class DebuggerPane;
class LogWindow : public QWidget class LogWindow : public QWidget
{ {
Q_OBJECT Q_OBJECT
@@ -78,8 +80,8 @@ signals:
void statusMessageRequested(const QString &msg, int); void statusMessageRequested(const QString &msg, int);
private: private:
QPlainTextEdit *m_combinedText; // combined input/output DebuggerPane *m_combinedText; // combined input/output
QPlainTextEdit *m_inputText; // scriptable input alone DebuggerPane *m_inputText; // scriptable input alone
QLineEdit *m_commandEdit; QLineEdit *m_commandEdit;
QLabel *m_commandLabel; QLabel *m_commandLabel;
bool m_ignoreNextInputEcho; bool m_ignoreNextInputEcho;