Index: /trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk	(revision 70553)
+++ /trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk	(revision 70554)
@@ -341,4 +341,5 @@
 	src/logviewer/UIVMLogViewerPanel.h \
 	src/logviewer/UIVMLogViewerSearchPanel.h \
+	src/logviewer/UIVMLogViewerTextEdit.h \
 	src/logviewer/UIVMLogViewerWidget.h \
 	src/medium/UIMediumDetailsWidget.h \
@@ -548,6 +549,6 @@
 	src/globals/UIMainEventListener.cpp \
 	src/globals/UIThreadPool.cpp \
-	src/logviewer/UIVMLogPage.cpp \
 	src/logviewer/UIVMLogViewerFilterPanel.cpp \
+	src/logviewer/UIVMLogViewerTextEdit.cpp \
 	src/medium/UIMediumEnumerator.cpp \
 	src/runtime/UIActionPoolRuntime.cpp \
@@ -660,4 +661,5 @@
 	src/logviewer/UIVMLogViewerPanel.cpp \
 	src/logviewer/UIVMLogViewerSearchPanel.cpp \
+	src/logviewer/UIVMLogViewerTextEdit.cpp \
 	src/logviewer/UIVMLogViewerWidget.cpp \
 	src/medium/UIMediumDefs.cpp \
Index: /trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogPage.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogPage.cpp	(revision 70553)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogPage.cpp	(revision 70554)
@@ -28,155 +28,12 @@
 # endif
 # include <QPainter>
-# include <QPlainTextEdit>
 # include <QScrollBar>
 # include <QTextBlock>
 
 /* GUI includes: */
-# include "QIFileDialog.h"
-# include "QITabWidget.h"
-# include "UIExtraDataManager.h"
-# include "UIIconPool.h"
-# include "UIMessageCenter.h"
 # include "UIVMLogPage.h"
-# include "UIVMLogViewerBookmarksPanel.h"
-# include "UIVMLogViewerFilterPanel.h"
-# include "UIVMLogViewerSearchPanel.h"
-# include "UIToolBar.h"
-
-/* COM includes: */
-# include "CSystemProperties.h"
-
-# include "VBoxGlobal.h"
+# include "UIVMLogViewerTextEdit.h"
 
 #endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
-
-
-/** We use a modified scrollbar style for our QPlainTextEdits to get the
-    markings on the scrollbars correctly. The default scrollbarstyle does not
-    reveal the height of the pushbuttons on the scrollbar (on either side of it, with arrow on them)
-    to compute the marking locations correctly. Thus we turn these push buttons off: */
-const QString verticalScrollBarStyle("QScrollBar:vertical {"
-                                     "border: 1px ridge grey; "
-                                     "margin: 0px 0px 0 0px;}"
-                                     "QScrollBar::handle:vertical {"
-                                     "min-height: 10px;"
-                                     "background: grey;}"
-                                     "QScrollBar::add-line:vertical {"
-                                     "width: 0px;}"
-                                     "QScrollBar::sub-line:vertical {"
-                                     "width: 0px;}");
-
-const QString horizontalScrollBarStyle("QScrollBar:horizontal {"
-                                       "border: 1px ridge grey; "
-                                       "margin: 0px 0px 0 0px;}"
-                                       "QScrollBar::handle:horizontal {"
-                                       "min-height: 10px;"
-                                       "background: grey;}"
-                                       "QScrollBar::add-line:horizontal {"
-                                       "height: 0px;}"
-                                       "QScrollBar::sub-line:horizontal {"
-                                       "height: 0px;}");
-
-class UIIndicatorScrollBar : public QScrollBar
-{
-    Q_OBJECT;
-
-public:
-
-    UIIndicatorScrollBar(QWidget *parent = 0)
-        :QScrollBar(parent)
-    {
-        setStyleSheet(verticalScrollBarStyle);
-    }
-
-    void setMarkingsVector(const QVector<float> &vector)
-    {
-        m_markingsVector = vector;
-    }
-
-    void clearMarkingsVector()
-    {
-        m_markingsVector.clear();
-    }
-
-protected:
-
-    virtual void paintEvent(QPaintEvent *pEvent) /* override */
-    {
-        QScrollBar::paintEvent(pEvent);
-        /* Put a red line to marking position: */
-        for (int i = 0; i < m_markingsVector.size(); ++i)
-        {
-            QPointF p1 = QPointF(0, m_markingsVector[i] * height());
-            QPointF p2 = QPointF(width(), m_markingsVector[i] * height());
-
-            QPainter painter(this);
-            painter.setRenderHint(QPainter::Antialiasing, true);
-            painter.setPen(QPen(QColor(255, 0, 0, 75), 1.1f));
-            painter.drawLine(p1, p2);
-        }
-    }
-
-private:
-
-    /* Stores the relative (to scrollbar's height) positions of markings,
-       where we draw a horizontal line. Values are in [0.0, 1.0]*/
-    QVector<float> m_markingsVector;
-};
-
-/* Sub-class QPlainTextEdit for some addtional context menu items: */
-class UIVMLogViewerTextEdit : public QPlainTextEdit
-{
-    Q_OBJECT;
-
-signals:
-
-    void sigContextMenuBookmarkAction(LogBookmark bookmark);
-
-public:
-    UIVMLogViewerTextEdit(QWidget* parent = 0)
-        :QPlainTextEdit(parent)
-    {
-        //setStyleSheet("background-color: rgba(240, 240, 240, 75%) ");
-    }
-
-protected:
-
-    void contextMenuEvent(QContextMenuEvent *pEvent)
-    {
-        QMenu *menu = createStandardContextMenu();
-        QAction *pAction = menu->addAction(tr("Bookmark"));
-        QTextBlock block = cursorForPosition(pEvent->pos()).block();
-        m_iContextMenuBookmark.first = block.firstLineNumber();
-        m_iContextMenuBookmark.second = block.text();
-
-        if (pAction)
-            connect(pAction, &QAction::triggered, this, &UIVMLogViewerTextEdit::sltBookmark);
-
-        menu->exec(pEvent->globalPos());
-
-        if (pAction)
-            disconnect(pAction, &QAction::triggered, this, &UIVMLogViewerTextEdit::sltBookmark);
-
-        delete menu;
-    }
-
-    virtual void mousePressEvent(QMouseEvent *pEvent)
-    {
-        QPlainTextEdit::mousePressEvent(pEvent);
-    }
-
-private slots:
-
-    void sltBookmark()
-    {
-        emit sigContextMenuBookmarkAction(m_iContextMenuBookmark);
-    }
-
-private:
-
-    /* Line number and text at the context menu position */
-    LogBookmark m_iContextMenuBookmark;
-};
 
 
@@ -184,5 +41,5 @@
     : QIWithRetranslateUI<QWidget>(pParent)
     , m_pMainLayout(0)
-    , m_pPlainTextEdit(0)
+    , m_pTextEdit(0)
     , m_tabIndex(tabIndex)
 {
@@ -197,11 +54,11 @@
 int UIVMLogPage::defaultLogPageWidth() const
 {
-    if (!m_pPlainTextEdit)
+    if (!m_pTextEdit)
         return 0;
 
     /* Compute a width for 132 characters plus scrollbar and frame width: */
-    int iDefaultWidth = m_pPlainTextEdit->fontMetrics().width(QChar('x')) * 132 +
-                        m_pPlainTextEdit->verticalScrollBar()->width() +
-                        m_pPlainTextEdit->frameWidth() * 2;
+    int iDefaultWidth = m_pTextEdit->fontMetrics().width(QChar('x')) * 132 +
+                        m_pTextEdit->verticalScrollBar()->width() +
+                        m_pTextEdit->frameWidth() * 2;
 
     return iDefaultWidth;
@@ -222,24 +79,8 @@
     m_pMainLayout->setContentsMargins(0, 0, 0, 0);
 
-    m_pPlainTextEdit = new UIVMLogViewerTextEdit(this);
-    m_pMainLayout->addWidget(m_pPlainTextEdit);
-
-    m_pPlainTextEdit->setVerticalScrollBar(new UIIndicatorScrollBar());
-    m_pPlainTextEdit->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
-    QScrollBar *pHorizontalScrollBar = m_pPlainTextEdit->horizontalScrollBar();
-    if (pHorizontalScrollBar)
-        pHorizontalScrollBar->setStyleSheet(horizontalScrollBarStyle);
-
-#if defined(RT_OS_SOLARIS)
-    /* Use system fixed-width font on Solaris hosts as the Courier family fonts don't render well. */
-    QFont font = QFontDatabase::systemFont(QFontDatabase::FixedFont);
-#else
-    QFont font;
-    font.setFamily("Courier New,courier");
-#endif
-    m_pPlainTextEdit->setFont(font);
-    m_pPlainTextEdit->setWordWrapMode(QTextOption::NoWrap);
-    m_pPlainTextEdit->setReadOnly(true);
-    connect(qobject_cast<UIVMLogViewerTextEdit*>(m_pPlainTextEdit), &UIVMLogViewerTextEdit::sigContextMenuBookmarkAction,
+    m_pTextEdit = new UIVMLogViewerTextEdit(this);
+    m_pMainLayout->addWidget(m_pTextEdit);
+
+    connect(qobject_cast<UIVMLogViewerTextEdit*>(m_pTextEdit), &UIVMLogViewerTextEdit::sigContextMenuBookmarkAction,
             this, &UIVMLogPage::sltAddBookmark);
 }
@@ -247,12 +88,12 @@
 QPlainTextEdit *UIVMLogPage::textEdit()
 {
-    return m_pPlainTextEdit;
+    return m_pTextEdit;
 }
 
 QTextDocument* UIVMLogPage::document()
 {
-    if (!m_pPlainTextEdit)
+    if (!m_pTextEdit)
         return 0;
-    return m_pPlainTextEdit->document();
+    return m_pTextEdit->document();
 }
 
@@ -297,9 +138,9 @@
 void UIVMLogPage::setTextEdit(const QString &strText)
 {
-    m_pPlainTextEdit->setPlainText(strText);
+    m_pTextEdit->setPlainText(strText);
     /* Move the cursor position to end: */
-    QTextCursor cursor = m_pPlainTextEdit->textCursor();
+    QTextCursor cursor = m_pTextEdit->textCursor();
     cursor.movePosition(QTextCursor::End, QTextCursor::MoveAnchor);
-    m_pPlainTextEdit->setTextCursor(cursor);
+    m_pTextEdit->setTextCursor(cursor);
     repaint();
 }
@@ -307,16 +148,14 @@
 void UIVMLogPage::markForError()
 {
-    QPalette pal = m_pPlainTextEdit->palette();
+    QPalette pal = m_pTextEdit->palette();
     pal.setColor(QPalette::Base, pal.color(QPalette::Window));
-    m_pPlainTextEdit->setPalette(pal);
+    m_pTextEdit->setPalette(pal);
 }
 
 void UIVMLogPage::setScrollBarMarkingsVector(const QVector<float> &vector)
 {
-    if (!m_pPlainTextEdit)
-        return;
-    UIIndicatorScrollBar* scrollBar = qobject_cast<UIIndicatorScrollBar*>(m_pPlainTextEdit->verticalScrollBar());
-    if (scrollBar)
-        scrollBar->setMarkingsVector(vector);
+    if (!m_pTextEdit)
+        return;
+    m_pTextEdit->setScrollBarMarkingsVector(vector);
     repaint();
 }
@@ -324,9 +163,7 @@
 void UIVMLogPage::clearScrollBarMarkingsVector()
 {
-    if (!m_pPlainTextEdit)
-        return;
-    UIIndicatorScrollBar* scrollBar = qobject_cast<UIIndicatorScrollBar*>(m_pPlainTextEdit->verticalScrollBar());
-    if (scrollBar)
-        scrollBar->clearMarkingsVector();
+    if (!m_pTextEdit)
+        return;
+    m_pTextEdit->clearScrollBarMarkingsVector();
     repaint();
 }
@@ -334,8 +171,8 @@
 void UIVMLogPage::documentUndo()
 {
-    if (!m_pPlainTextEdit)
-        return;
-    if (m_pPlainTextEdit->document())
-        m_pPlainTextEdit->document()->undo();
+    if (!m_pTextEdit)
+        return;
+    if (m_pTextEdit->document())
+        m_pTextEdit->document()->undo();
 }
 
@@ -355,5 +192,5 @@
 void UIVMLogPage::scrollToBookmark(int bookmarkIndex)
 {
-    if(!m_pPlainTextEdit)
+    if(!m_pTextEdit)
         return;
     if (bookmarkIndex >= m_bookmarkVector.size())
@@ -361,10 +198,12 @@
 
     int lineNumber = m_bookmarkVector.at(bookmarkIndex).first;
-    QTextDocument* document = m_pPlainTextEdit->document();
+    QTextDocument* document = m_pTextEdit->document();
     if(!document)
         return;
 
     QTextCursor cursor(document->findBlockByLineNumber(lineNumber));
-    m_pPlainTextEdit->setTextCursor(cursor);
+    m_pTextEdit->moveCursor(QTextCursor::End);
+    m_pTextEdit->setTextCursor(cursor);
+
 }
 
@@ -393,5 +232,2 @@
     // sltCreateBookmarkAtLine(bookmark);
 //}
-
-
-#include "UIVMLogPage.moc"
Index: /trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogPage.h
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogPage.h	(revision 70553)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogPage.h	(revision 70554)
@@ -28,17 +28,9 @@
 #include "QIWithRetranslateUI.h"
 
-/* COM includes: */
-#include "COMEnums.h"
-#include "CMachine.h"
-
 /* Forward declarations: */
 class QITabWidget;
+class QHBoxLayout;
 class QPlainTextEdit;
-class QHBoxLayout;
-class UIToolBar;
-class UIVMLogViewerBookmarksPanel;
-class UIVMLogViewerFilterPanel;
-class UIVMLogViewerPanel;
-class UIVMLogViewerSearchPanel;
+class UIVMLogViewerTextEdit;
 
 /* Type definitions: */
@@ -109,5 +101,5 @@
 
     QHBoxLayout    *m_pMainLayout;
-    QPlainTextEdit *m_pPlainTextEdit;
+    UIVMLogViewerTextEdit *m_pTextEdit;
     /** Stores the log file (unmodified) content. */
     QString         m_strLog;
Index: /trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerTextEdit.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerTextEdit.cpp	(revision 70554)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerTextEdit.cpp	(revision 70554)
@@ -0,0 +1,278 @@
+/* $Id$ */
+/** @file
+ * VBox Qt GUI - UIVMLogViewer class implementation.
+ */
+
+/*
+ * Copyright (C) 2010-2017 Oracle Corporation
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ */
+
+#ifdef VBOX_WITH_PRECOMPILED_HEADERS
+# include <precomp.h>
+#else  /* !VBOX_WITH_PRECOMPILED_HEADERS */
+
+/* Qt includes: */
+# if defined(RT_OS_SOLARIS)
+#  include <QFontDatabase>
+# endif
+# include <QMenu>
+# include <QPainter>
+# include <QPlainTextEdit>
+# include <QScrollBar>
+# include <QTextBlock>
+
+/* GUI includes: */
+# include "UIVMLogViewerTextEdit.h"
+
+#endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
+
+/** We use a modified scrollbar style for our QPlainTextEdits to get the
+    markings on the scrollbars correctly. The default scrollbarstyle does not
+    reveal the height of the pushbuttons on the scrollbar (on either side of it, with arrow on them)
+    to compute the marking locations correctly. Thus we turn these push buttons off: */
+const QString verticalScrollBarStyle("QScrollBar:vertical {"
+                                     "border: 1px ridge grey; "
+                                     "margin: 0px 0px 0 0px;}"
+                                     "QScrollBar::handle:vertical {"
+                                     "min-height: 10px;"
+                                     "background: grey;}"
+                                     "QScrollBar::add-line:vertical {"
+                                     "width: 0px;}"
+                                     "QScrollBar::sub-line:vertical {"
+                                     "width: 0px;}");
+
+const QString horizontalScrollBarStyle("QScrollBar:horizontal {"
+                                       "border: 1px ridge grey; "
+                                       "margin: 0px 0px 0 0px;}"
+                                       "QScrollBar::handle:horizontal {"
+                                       "min-height: 10px;"
+                                       "background: grey;}"
+                                       "QScrollBar::add-line:horizontal {"
+                                       "height: 0px;}"
+                                       "QScrollBar::sub-line:horizontal {"
+                                       "height: 0px;}");
+
+class UIIndicatorScrollBar : public QScrollBar
+{
+    Q_OBJECT;
+
+public:
+
+    UIIndicatorScrollBar(QWidget *parent = 0)
+        :QScrollBar(parent)
+    {
+        setStyleSheet(verticalScrollBarStyle);
+    }
+
+    void setMarkingsVector(const QVector<float> &vector)
+    {
+        m_markingsVector = vector;
+    }
+
+    void clearMarkingsVector()
+    {
+        m_markingsVector.clear();
+    }
+
+protected:
+
+    virtual void paintEvent(QPaintEvent *pEvent) /* override */
+    {
+        QScrollBar::paintEvent(pEvent);
+        /* Put a red line to marking position: */
+        for (int i = 0; i < m_markingsVector.size(); ++i)
+        {
+            QPointF p1 = QPointF(0, m_markingsVector[i] * height());
+            QPointF p2 = QPointF(width(), m_markingsVector[i] * height());
+
+            QPainter painter(this);
+            painter.setRenderHint(QPainter::Antialiasing, true);
+            painter.setPen(QPen(QColor(255, 0, 0, 75), 1.1f));
+            painter.drawLine(p1, p2);
+        }
+    }
+
+private:
+
+    /* Stores the relative (to scrollbar's height) positions of markings,
+       where we draw a horizontal line. Values are in [0.0, 1.0]*/
+    QVector<float> m_markingsVector;
+};
+
+class UILineNumberArea : public QWidget
+{
+public:
+    UILineNumberArea(UIVMLogViewerTextEdit *textEdit)
+        :QWidget(textEdit)
+        , m_pTextEdit(textEdit){}
+
+    QSize sizeHint() const override
+    {
+        return QSize(m_pTextEdit->lineNumberAreaWidth(), 0);
+    }
+
+protected:
+
+    void paintEvent(QPaintEvent *event) override
+    {
+        m_pTextEdit->lineNumberAreaPaintEvent(event);
+    }
+
+private:
+    UIVMLogViewerTextEdit *m_pTextEdit;
+};
+
+
+UIVMLogViewerTextEdit::UIVMLogViewerTextEdit(QWidget* parent /* = 0 */)
+    :QPlainTextEdit(parent)
+    , m_pLineNumberArea(0)
+{
+
+    //setStyleSheet("background-color: rgba(240, 240, 240, 75%) ");
+    prepare();
+}
+
+void UIVMLogViewerTextEdit::prepare()
+{
+    prepareWidgets();
+}
+
+void UIVMLogViewerTextEdit::prepareWidgets()
+{
+    m_pLineNumberArea = new UILineNumberArea(this);
+
+    connect(this, &UIVMLogViewerTextEdit::blockCountChanged, this, &UIVMLogViewerTextEdit::sltUpdateLineNumberAreaWidth);
+    connect(this, &UIVMLogViewerTextEdit::updateRequest, this, &UIVMLogViewerTextEdit::sltUpdateLineNumberArea);
+    sltUpdateLineNumberAreaWidth(0);
+
+    setVerticalScrollBar(new UIIndicatorScrollBar());
+    setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
+    QScrollBar *pHorizontalScrollBar = horizontalScrollBar();
+    if (pHorizontalScrollBar)
+        pHorizontalScrollBar->setStyleSheet(horizontalScrollBarStyle);
+
+
+#if defined(RT_OS_SOLARIS)
+    /* Use system fixed-width font on Solaris hosts as the Courier family fonts don't render well. */
+    QFont font = QFontDatabase::systemFont(QFontDatabase::FixedFont);
+#else
+    QFont font;
+    font.setFamily("Courier New,courier");
+#endif
+    setFont(font);
+    setWordWrapMode(QTextOption::NoWrap);
+    setReadOnly(true);
+    if(m_pLineNumberArea)
+        m_pLineNumberArea->setFont(font);
+
+}
+
+int UIVMLogViewerTextEdit::lineNumberAreaWidth()
+{
+    int digits = 1;
+    int max = qMax(1, blockCount());
+    while (max >= 10) {
+        max /= 10;
+        ++digits;
+    }
+
+    int space = 3 + fontMetrics().width(QLatin1Char('9')) * digits;
+
+    return space;
+}
+
+void UIVMLogViewerTextEdit::lineNumberAreaPaintEvent(QPaintEvent *event)
+{
+    QPainter painter(m_pLineNumberArea);
+    painter.fillRect(event->rect(), Qt::lightGray);
+    QTextBlock block = firstVisibleBlock();
+    int blockNumber = block.blockNumber();
+    int top = (int) blockBoundingGeometry(block).translated(contentOffset()).top();
+    int bottom = top + (int) blockBoundingRect(block).height();
+    while (block.isValid() && top <= event->rect().bottom()) {
+        if (block.isVisible() && bottom >= event->rect().top()) {
+            QString number = QString::number(blockNumber + 1);
+            painter.setPen(Qt::black);
+            painter.drawText(0, top, m_pLineNumberArea->width(), m_pLineNumberArea->fontMetrics().lineSpacing(),
+                             Qt::AlignRight, number);
+        }
+        block = block.next();
+        top = bottom;
+        bottom = top + (int) blockBoundingRect(block).height();
+        ++blockNumber;
+    }
+}
+
+void UIVMLogViewerTextEdit::contextMenuEvent(QContextMenuEvent *pEvent)
+{
+    QMenu *menu = createStandardContextMenu();
+    QAction *pAction = menu->addAction(tr("Bookmark"));
+    QTextBlock block = cursorForPosition(pEvent->pos()).block();
+    m_iContextMenuBookmark.first = block.firstLineNumber();
+    m_iContextMenuBookmark.second = block.text();
+
+    if (pAction)
+        connect(pAction, &QAction::triggered, this, &UIVMLogViewerTextEdit::sltBookmark);
+
+    menu->exec(pEvent->globalPos());
+
+    if (pAction)
+        disconnect(pAction, &QAction::triggered, this, &UIVMLogViewerTextEdit::sltBookmark);
+
+    delete menu;
+}
+
+void UIVMLogViewerTextEdit::resizeEvent(QResizeEvent *pEvent)
+{
+    QPlainTextEdit::resizeEvent(pEvent);
+
+    QRect cr = contentsRect();
+    m_pLineNumberArea->setGeometry(QRect(cr.left(), cr.top(), lineNumberAreaWidth(), cr.height()));
+}
+
+
+void UIVMLogViewerTextEdit::sltUpdateLineNumberAreaWidth(int /* newBlockCount */)
+{
+    setViewportMargins(lineNumberAreaWidth(), 0, 0, 0);
+}
+
+void UIVMLogViewerTextEdit::sltUpdateLineNumberArea(const QRect &rect, int dy)
+{
+    if (dy)
+        m_pLineNumberArea->scroll(0, dy);
+    else
+        m_pLineNumberArea->update(0, rect.y(), m_pLineNumberArea->width(), rect.height());
+
+    if (rect.contains(viewport()->rect()))
+        sltUpdateLineNumberAreaWidth(0);
+}
+
+void UIVMLogViewerTextEdit::sltBookmark()
+{
+    emit sigContextMenuBookmarkAction(m_iContextMenuBookmark);
+}
+
+void UIVMLogViewerTextEdit::setScrollBarMarkingsVector(const QVector<float> &vector)
+{
+    UIIndicatorScrollBar* vScrollBar = qobject_cast<UIIndicatorScrollBar*>(verticalScrollBar());
+    if(vScrollBar)
+        vScrollBar->setMarkingsVector(vector);
+}
+
+void UIVMLogViewerTextEdit::clearScrollBarMarkingsVector()
+{
+    UIIndicatorScrollBar* vScrollBar = qobject_cast<UIIndicatorScrollBar*>(verticalScrollBar());
+    if(vScrollBar)
+        vScrollBar->clearMarkingsVector();
+}
+
+
+#include "UIVMLogViewerTextEdit.moc"
Index: /trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerTextEdit.h
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerTextEdit.h	(revision 70554)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerTextEdit.h	(revision 70554)
@@ -0,0 +1,70 @@
+/* $Id$ */
+/** @file
+ * VBox Qt GUI - UIVMLogViewer class declaration.
+ */
+
+/*
+ * Copyright (C) 2010-2017 Oracle Corporation
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ */
+
+#ifndef ___UIVMLogViewerTextEdit_h___
+#define ___UIVMLogViewerTextEdit_h___
+
+/* Qt includes: */
+#include <QPlainTextEdit>
+#include <QPair>
+
+
+/* QPlainTextEdit extension for some addtional context menu items,
+   a special scrollbar, line number area, and bookmark support: */
+class UIVMLogViewerTextEdit : public QPlainTextEdit
+{
+    Q_OBJECT;
+
+signals:
+
+    void sigContextMenuBookmarkAction(QPair<int, QString> bookmark);
+
+public:
+
+    UIVMLogViewerTextEdit(QWidget* parent = 0);
+    int  lineNumberAreaWidth();
+    void lineNumberAreaPaintEvent(QPaintEvent *event);
+    /** Forwards the call to scroll bar class */
+    void setScrollBarMarkingsVector(const QVector<float> &vector);
+    /** Forwards the call to scroll bar class */
+    void clearScrollBarMarkingsVector();
+
+protected:
+
+    void contextMenuEvent(QContextMenuEvent *pEvent);
+    void resizeEvent(QResizeEvent *pEvent);
+
+private slots:
+
+    void sltBookmark();
+    void sltUpdateLineNumberAreaWidth(int newBlockCount);
+    void sltUpdateLineNumberArea(const QRect &, int);
+
+private:
+
+    void prepare();
+    void prepareWidgets();
+
+    /* Line number and text at the context menu position */
+    QPair<int, QString>  m_iContextMenuBookmark;
+    QWidget             *m_pLineNumberArea;
+};
+
+
+
+
+#endif /* !___UIVMLogPage_h___ */
