Index: /trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerSearchPanel.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerSearchPanel.cpp	(revision 70241)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerSearchPanel.cpp	(revision 70242)
@@ -51,6 +51,7 @@
     , m_pMatchWholeWordCheckBox(0)
     , m_pHighlightAllCheckBox(0)
-    , m_pWarningSpacer(0), m_pWarningIcon(0), m_pWarningLabel(0)
+    , m_pWarningSpacer(0), m_pWarningIcon(0), m_pInfoLabel(0)
     , m_iSearchPosition(0)
+    , m_iMatchCount(-1)
 {
     /* Prepare: */
@@ -58,4 +59,32 @@
 }
 
+void UIVMLogViewerSearchPanel::refresh()
+{
+    m_iSearchPosition = 0;
+    search(BackwardSearch, true);
+}
+
+void UIVMLogViewerSearchPanel::reset()
+{
+    m_iSearchPosition = 0;
+    if (m_pHighlightAllCheckBox)
+    {
+        if (m_pHighlightAllCheckBox->checkState() == Qt::Checked)
+            m_pHighlightAllCheckBox->setCheckState(Qt::Unchecked);
+    }
+}
+
+void UIVMLogViewerSearchPanel::hideEvent(QHideEvent *pEvent)
+{
+    /* Get focus-widget: */
+    QWidget *pFocus = QApplication::focusWidget();
+    /* If focus-widget is valid and child-widget of search-panel,
+     * focus next child-widget in line: */
+    if (pFocus && pFocus->parent() == this)
+        focusNextPrevChild(true);
+    /* Call to base-class: */
+    QWidget::hideEvent(pEvent);
+    reset();
+}
 
 void UIVMLogViewerSearchPanel::find(int iButton)
@@ -80,5 +109,5 @@
         /* Reset the position to force the search restart from the document's beginnig: */
         m_iSearchPosition = 0;
-        search(ForwardSearch);
+        search(BackwardSearch, true);
     }
     /* If search-string is not valid, reset cursor position: */
@@ -111,10 +140,13 @@
         if (searchString.isEmpty())
             return;
-        highlightAll(pDocument, constructFindFlags(ForwardSearch), searchString);
+        highlightAll(pDocument, searchString);
     }
     else
     {
+        if (m_iMatchCount != 0)
+            m_iMatchCount = -1;
         pDocument->undo();
     }
+    configureInfoLabels();
 }
 
@@ -232,5 +264,4 @@
         }
 
-
         /* Create warning-spacer: */
         m_pWarningSpacer = new QSpacerItem(0, 0, QSizePolicy::Fixed, QSizePolicy::Minimum);
@@ -255,17 +286,17 @@
 
         /* Create warning-label: */
-        m_pWarningLabel = new QLabel;
-        AssertPtrReturnVoid(m_pWarningLabel);
+        m_pInfoLabel = new QLabel;
+        AssertPtrReturnVoid(m_pInfoLabel);
         {
             /* Configure warning-label: */
-            m_pWarningLabel->hide();
+            m_pInfoLabel->hide();
             /* Prepare font: */
 #ifdef VBOX_DARWIN_USE_NATIVE_CONTROLS
-            QFont font = m_pWarningLabel->font();
+            QFont font = m_pInfoLabel->font();
             font.setPointSize(::darwinSmallFontSize());
-            m_pWarningLabel->setFont(font);
+            m_pInfoLabel->setFont(font);
 #endif /* VBOX_DARWIN_USE_NATIVE_CONTROLS */
             /* Add warning-label to main-layout: */
-            m_pMainLayout->addWidget(m_pWarningLabel);
+            m_pMainLayout->addWidget(m_pInfoLabel);
         }
 
@@ -310,5 +341,8 @@
     m_pHighlightAllCheckBox->setToolTip(UIVMLogViewerWidget::tr("All occurence of the search text are highlighted"));
 
-    m_pWarningLabel->setText(UIVMLogViewerWidget::tr("String not found"));
+    if (m_iMatchCount == 0)
+        m_pInfoLabel->setText(UIVMLogViewerWidget::tr("String not found"));
+    else if (m_iMatchCount > 0)
+        m_pInfoLabel->setText(UIVMLogViewerWidget::tr("%1 Matches Found").arg(m_iMatchCount));
 }
 
@@ -417,17 +451,5 @@
 }
 
-void UIVMLogViewerSearchPanel::hideEvent(QHideEvent *pEvent)
-{
-    /* Get focus-widget: */
-    QWidget *pFocus = QApplication::focusWidget();
-    /* If focus-widget is valid and child-widget of search-panel,
-     * focus next child-widget in line: */
-    if (pFocus && pFocus->parent() == this)
-        focusNextPrevChild(true);
-    /* Call to base-class: */
-    QWidget::hideEvent(pEvent);
-}
-
-void UIVMLogViewerSearchPanel::search(SearchDirection direction)
+void UIVMLogViewerSearchPanel::search(SearchDirection direction, bool highlight)
 {
    QPlainTextEdit *pTextEdit = m_pViewer->currentLogPage();
@@ -445,9 +467,11 @@
    QTextCursor startCursor(pDocument);
 
-   /* Construct the find flags for QTextDocument::find function: */
-   QTextDocument::FindFlags findFlags = constructFindFlags(direction);
-
    if (m_pHighlightAllCheckBox->isChecked())
-       highlightAll(pDocument, findFlags, searchString);
+   {
+       if (highlight)
+           highlightAll(pDocument, searchString);
+   }
+   else
+       m_iMatchCount = -1;
 
    QTextCursor resultCursor(pDocument);
@@ -455,5 +479,5 @@
    if (direction == BackwardSearch)
        startPosition -= searchString.length();
-   resultCursor = pDocument->find(searchString, startPosition, findFlags);
+   resultCursor = pDocument->find(searchString, startPosition, constructFindFlags(direction));
 
    /* Decide whether to wrap around or to end the search */
@@ -464,5 +488,8 @@
            (direction == BackwardSearch && startPosition == endCursor.position()))
        {
-           toggleWarning(false);
+           /* Set the match count 0 here since we did not call highLightAll function: */
+           if (!m_pHighlightAllCheckBox->isChecked())
+               m_iMatchCount = 0;
+           configureInfoLabels();
            return;
        }
@@ -471,5 +498,5 @@
        {
            m_iSearchPosition = startCursor.position();
-           search(ForwardSearch);
+           search(ForwardSearch, false);
            return;
        }
@@ -479,5 +506,5 @@
               able to find the string at the end of the document: */
            m_iSearchPosition = endCursor.position() + searchString.length();
-           search(BackwardSearch);
+           search(BackwardSearch, false);
            return;
        }
@@ -485,21 +512,21 @@
    pTextEdit->setTextCursor(resultCursor);
    m_iSearchPosition = resultCursor.position();
-   toggleWarning(true);
+   configureInfoLabels();
 }
 
 void UIVMLogViewerSearchPanel::findNext()
 {
-    search(ForwardSearch);
+    search(ForwardSearch, false);
 }
 
 void UIVMLogViewerSearchPanel::findBack()
 {
-    search(BackwardSearch);
+    search(BackwardSearch, false);
 }
 
 void UIVMLogViewerSearchPanel::highlightAll(QTextDocument *pDocument,
-                                            const QTextDocument::FindFlags &findFlags,
                                             const QString &searchString)
 {
+    m_iMatchCount = 0;
     if (!pDocument)
         return;
@@ -512,31 +539,43 @@
     QTextCursor cursor(pDocument);
     cursor.beginEditBlock();
-
     colorFormat.setBackground(Qt::yellow);
 
     while (!highlightCursor.isNull() && !highlightCursor.atEnd())
     {
-        highlightCursor = pDocument->find(searchString, highlightCursor, findFlags);
+        /* Hightlighting searches is always from the top of the document forward: */
+        highlightCursor = pDocument->find(searchString, highlightCursor, constructFindFlags(ForwardSearch));
 
         if (!highlightCursor.isNull())
+        {
             highlightCursor.mergeCharFormat(colorFormat);
+            ++m_iMatchCount;
+        }
     }
     cursor.endEditBlock();
 }
 
-void UIVMLogViewerSearchPanel::toggleWarning(bool fHide)
-{
-    /* Adjust size of warning-spacer accordingly: */
-    m_pWarningSpacer->changeSize(fHide ? 0 : 16, 0, QSizePolicy::Fixed, QSizePolicy::Minimum);
-    /* If visible mark the error for search-editor (changes text-color): */
-    if (!fHide)
+void UIVMLogViewerSearchPanel::configureInfoLabels()
+{
+    /* If no match has been found, mark the search editor: */
+    if (m_iMatchCount == 0)
+    {
         m_pSearchEditor->markError();
-    /* If hidden unmark the error for search-editor (changes text-color): */
+        m_pWarningIcon->setVisible(true);
+        m_pInfoLabel->setVisible(true);
+    }
+    else if (m_iMatchCount == -1)
+    {
+        m_pSearchEditor->unmarkError();
+        m_pWarningIcon->setVisible(false);
+        m_pInfoLabel->setVisible(false);
+    }
     else
+    {
         m_pSearchEditor->unmarkError();
-    /* Show/hide the warning-icon: */
-    m_pWarningIcon->setHidden(fHide);
-    /* Show/hide the warning-label: */
-    m_pWarningLabel->setHidden(fHide);
+        m_pWarningIcon->setVisible(false);
+        m_pInfoLabel->setVisible(true);
+    }
+    /* Retranslate to get the label text corectly: */
+    retranslateUi();
 }
 
Index: /trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerSearchPanel.h
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerSearchPanel.h	(revision 70241)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerSearchPanel.h	(revision 70242)
@@ -47,4 +47,11 @@
       * @param  pViewer  Specifies instance of VM Log-Viewer. */
     UIVMLogViewerSearchPanel(QWidget *pParent, UIVMLogViewerWidget *pViewer);
+    /** Resets the saech position and starts a new search. */
+    void refresh();
+    void reset();
+
+protected:
+
+    virtual void hideEvent(QHideEvent* pEvent) /* override */;
 
 private slots:
@@ -75,17 +82,19 @@
     /** Handles Qt show @a pEvent. */
     void showEvent(QShowEvent *pEvent);
-    /** Handles Qt hide @a pEvent. */
-    void hideEvent(QHideEvent *pEvent);
+
 
     /** Search routine.
-      * @param  eDirection     Specifies the seach direction */
-    void search(SearchDirection eDirection);
+      * @param  eDirection     Specifies the seach direction
+      * @param  highlight      if false highlight function is not called
+                               thus we avoid calling highlighting for the same string repeatedly. */
+    void search(SearchDirection eDirection, bool highlight);
     /** Forward search routine wrapper. */
     void findNext();
     /** Backward search routine wrapper. */
     void findBack();
-    void highlightAll(QTextDocument *pDocument, const QTextDocument::FindFlags &findFlags, const QString &searchString);
-    /** Shows/hides the search border warning using @a fHide as hint. */
-    void toggleWarning(bool fHide);
+    void highlightAll(QTextDocument *pDocument, const QString &searchString);
+    /** Controls the visibility of the warning icon and info labels.
+     Also marks the search editor in case of no match.*/
+    void configureInfoLabels();
     /** Constructs the find flags for QTextDocument::find function. */
     QTextDocument::FindFlags constructFindFlags(SearchDirection eDirection);
@@ -111,10 +120,15 @@
     /** Holds the instance of warning icon we create. */
     QLabel      *m_pWarningIcon;
-    /** Holds the instance of warning label we create. */
-    QLabel      *m_pWarningLabel;
+    /** Holds the instance of info label we create. */
+    QLabel      *m_pInfoLabel;
     /** Holds the instance of spacer item we create. */
     QSpacerItem *m_pSpacerItem;
     /** Holds the position where we start the next search. */
     int          m_iSearchPosition;
+    /** Holds the number of the matches for the string.
+     -1: highLightAll function is not called
+      0: no matches found
+      n > 0: n matches found. */
+    int          m_iMatchCount;
 };
 
Index: /trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerWidget.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerWidget.cpp	(revision 70241)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerWidget.cpp	(revision 70242)
@@ -165,4 +165,6 @@
     m_pViewerContainer->setEnabled(!noLogsToShow);
     m_pViewerContainer->show();
+    if (m_pSearchPanel && m_pSearchPanel->isVisible())
+        m_pSearchPanel->refresh();
 }
 
