Index: trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk	(revision 72435)
+++ trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk	(revision 72444)
@@ -1184,4 +1184,5 @@
 	src/logviewer/UIVMLogViewerTextEdit.cpp \
 	src/medium/UIMediumEnumerator.cpp \
+	src/medium/UIMediumSelector.cpp \
 	src/runtime/UIActionPoolRuntime.cpp \
 	src/runtime/UIConsoleEventHandler.cpp \
@@ -1264,4 +1265,5 @@
 	src/logviewer/UIVMLogViewerTextEdit.cpp \
 	src/medium/UIMediumEnumerator.cpp \
+	src/medium/UIMediumSelector.cpp \
 	src/runtime/UIActionPoolRuntime.cpp \
 	src/selector/UIActionPoolSelector.cpp \
Index: trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumSelector.cpp
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumSelector.cpp	(revision 72435)
+++ trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumSelector.cpp	(revision 72444)
@@ -27,5 +27,7 @@
 
 /* GUI includes: */
+# include "QIComboBox.h"
 # include "QIDialogButtonBox.h"
+# include "QILineEdit.h"
 # include "QIMessageBox.h"
 # include "QITabWidget.h"
@@ -52,4 +54,86 @@
 
 #endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
+
+class UIMediumSearchWidget : public QWidget
+{
+    Q_OBJECT;
+
+public:
+
+    enum SearchType
+    {
+        SearchByName,
+        SearchByUUID,
+        SearchByMax
+    };
+
+signals:
+
+    void sigSearchTypeChanged(int newType);
+    void sigSearchTermChanged(QString searchTerm);
+
+public:
+
+    UIMediumSearchWidget(QWidget *pParent = 0);
+    SearchType searchType() const;
+    QString searchTerm() const;
+
+private:
+
+    void prepareWidgets();
+    QIComboBox *m_pSearchComboxBox;
+    QILineEdit *m_pSearchTermLineEdit;
+};
+
+UIMediumSearchWidget::UIMediumSearchWidget(QWidget *pParent)
+    :QWidget(pParent)
+    , m_pSearchComboxBox(0)
+    , m_pSearchTermLineEdit(0)
+{
+    prepareWidgets();
+}
+
+void UIMediumSearchWidget::prepareWidgets()
+{
+    QHBoxLayout *pLayout = new QHBoxLayout;
+    setLayout(pLayout);
+    pLayout->setContentsMargins(0, 0, 0, 0);
+    pLayout->setSpacing(0);
+
+    m_pSearchComboxBox = new QIComboBox;
+    if (m_pSearchComboxBox)
+    {
+        m_pSearchComboxBox->setEditable(false);
+        m_pSearchComboxBox->insertItem(SearchByName, "By Name");
+        m_pSearchComboxBox->insertItem(SearchByUUID, "By UUID");
+        pLayout->addWidget(m_pSearchComboxBox);
+
+        connect(m_pSearchComboxBox, static_cast<void(QIComboBox::*)(int)>(&QIComboBox::currentIndexChanged),
+                this, &UIMediumSearchWidget::sigSearchTypeChanged);
+
+    }
+
+    m_pSearchTermLineEdit = new QILineEdit;
+    if (pLayout)
+    {
+        pLayout->addWidget(m_pSearchTermLineEdit);
+        connect(m_pSearchTermLineEdit, &QILineEdit::textChanged,
+                this, &UIMediumSearchWidget::sigSearchTermChanged);
+    }
+}
+
+UIMediumSearchWidget::SearchType UIMediumSearchWidget::searchType() const
+{
+    if (!m_pSearchComboxBox || m_pSearchComboxBox->currentIndex() >= static_cast<int>(SearchByMax))
+        return SearchByMax;
+    return static_cast<SearchType>(m_pSearchComboxBox->currentIndex());
+}
+
+QString UIMediumSearchWidget::searchTerm() const
+{
+    if (!m_pSearchTermLineEdit)
+        return QString();
+    return m_pSearchTermLineEdit->text();
+}
 
 
@@ -66,4 +150,5 @@
     , m_pNotAttachedSubTreeRoot(0)
     , m_pParent(pParent)
+    , m_pSearchWidget(0)
 {
     configure();
@@ -185,4 +270,12 @@
         connect(m_pButtonBox, &QIDialogButtonBox::rejected, this, &UIMediumSelector::close);
         connect(m_pButtonBox, &QIDialogButtonBox::accepted, this, &UIMediumSelector::accept);
+    }
+
+    if (m_pSearchWidget)
+    {
+        connect(m_pSearchWidget, &UIMediumSearchWidget::sigSearchTypeChanged,
+                this, &UIMediumSelector::sltHandleSearchTypeChange);
+        connect(m_pSearchWidget, &UIMediumSearchWidget::sigSearchTermChanged,
+                this, &UIMediumSelector::sltHandleSearchTermChange);
     }
 }
@@ -313,4 +406,10 @@
     }
 
+    m_pSearchWidget = new UIMediumSearchWidget;
+    if (m_pSearchWidget)
+    {
+        m_pMainLayout->addWidget(m_pSearchWidget);
+    }
+
     m_pButtonBox = new QIDialogButtonBox;
     if (m_pButtonBox)
@@ -325,5 +424,4 @@
 
     repopulateTreeWidget();
-    //m_pMainLayout->addWidget(
 }
 
@@ -333,11 +431,4 @@
     vboxGlobal().openMediumWithFileOpenDialog(m_enmMediumType, this, strDefaultMachineFolder);
 }
-
-// void UIMediumSelector::sltHandleCurrentItemChanged()
-// {
-//     printf("%d\n", m_pTreeWidget->selectedItems().size());
-//     updateOkButton();
-
-// }
 
 void UIMediumSelector::sltHandleItemSelectionChanged()
@@ -368,4 +459,16 @@
     /* Initialize media enumation: */
     vboxGlobal().startMediumEnumeration();
+}
+
+void UIMediumSelector::sltHandleSearchTypeChange(int type)
+{
+    Q_UNUSED(type);
+    performMediumSearch();
+}
+
+void UIMediumSelector::sltHandleSearchTermChange(QString searchTerm)
+{
+    Q_UNUSED(searchTerm);
+    performMediumSearch();
 }
 
@@ -440,4 +543,5 @@
     /* uuid list of selected items: */
     /* Reset the related data structure: */
+    m_mediumItemList.clear();
     m_pTreeWidget->clear();
     m_pAttachedSubTreeRoot = 0;
@@ -474,9 +578,11 @@
                 pParent = m_pNotAttachedSubTreeRoot;
             }
-            menuItemVector.push_back(addTreeItem(medium, pParent));
+            UIMediumItem *treeItem = addTreeItem(medium, pParent);
+            m_mediumItemList.append(treeItem);
+            menuItemVector.push_back(treeItem);
         }
     }
     restoreSelection(selectedMediums, menuItemVector);
-
+    saveDefaultForeground();
     updateOkButton();
     if (m_pAttachedSubTreeRoot)
@@ -485,5 +591,22 @@
     if (m_pNotAttachedSubTreeRoot)
         m_pTreeWidget->expandItem(m_pNotAttachedSubTreeRoot);
-
+}
+
+void UIMediumSelector::saveDefaultForeground()
+{
+    if (!m_pTreeWidget)
+        return;
+    if (m_defaultItemForeground == QBrush() && m_pTreeWidget->topLevelItemCount() >= 1)
+    {
+        QTreeWidgetItem *item = m_pTreeWidget->topLevelItem(0);
+        if (item)
+        {
+            QVariant data = item->data(0, Qt::ForegroundRole);
+            if (data.canConvert<QBrush>())
+            {
+                m_defaultItemForeground = data.value<QBrush>();
+            }
+        }
+    }
 }
 
@@ -514,2 +637,42 @@
     return 0;
 }
+
+void UIMediumSelector::performMediumSearch()
+{
+    if (!m_pSearchWidget)
+        return;
+    /* Unmark all tree items to remove the highltights: */
+    for (int i = 0; i < m_mediumItemList.size(); ++i)
+    {
+        m_mediumItemList[i]->setData(0, Qt::ForegroundRole, m_defaultItemForeground);
+    }
+
+
+    UIMediumSearchWidget::SearchType searchType =
+        m_pSearchWidget->searchType();
+    if (searchType >= UIMediumSearchWidget::SearchByMax)
+        return;
+    QString strTerm = m_pSearchWidget->searchTerm();
+    if (strTerm.isEmpty())
+        return;
+
+    for (int i = 0; i < m_mediumItemList.size(); ++i)
+    {
+        if (!m_mediumItemList[i])
+            continue;
+        QString strMedium;
+        if (searchType == UIMediumSearchWidget::SearchByName)
+            strMedium = m_mediumItemList[i]->medium().name();
+        else if(searchType == UIMediumSearchWidget::SearchByUUID)
+            strMedium = m_mediumItemList[i]->medium().id();
+        if (strMedium.isEmpty())
+            continue;
+        if (strMedium.contains(strTerm, Qt::CaseInsensitive))
+        {
+            // mark the item
+            m_mediumItemList[i]->setData(0, Qt::ForegroundRole, QBrush(QColor(255, 0, 0)));
+        }
+    }
+}
+
+#include "UIMediumSelector.moc"
Index: trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumSelector.h
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumSelector.h	(revision 72435)
+++ trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumSelector.h	(revision 72444)
@@ -34,4 +34,5 @@
 class QIDialogButtonBox;
 class UIMediumItem;
+class UIMediumSearchWidget;
 class UIToolBar;
 
@@ -62,4 +63,6 @@
     void sltHandleMediumEnumerationFinish();
     void sltHandleRefresh();
+    void sltHandleSearchTypeChange(int type);
+    void sltHandleSearchTermChange(QString searchTerm);
 
 private:
@@ -83,25 +86,32 @@
     /** @} */
 
-    void repopulateTreeWidget();
+    void          repopulateTreeWidget();
     /** Disable/enable 'ok' button on the basis of having a selected item */
-    void updateOkButton();
+    void          updateOkButton();
     UIMediumItem* addTreeItem(const UIMedium &medium, QITreeWidgetItem *pParent);
-    void restoreSelection(const QStringList &selectedMediums, QVector<UIMediumItem*> &mediumList);
+    void          restoreSelection(const QStringList &selectedMediums, QVector<UIMediumItem*> &mediumList);
     /** Recursively create the hard disk hierarchy under the tree widget */
     UIMediumItem* createHardDiskItem(const UIMedium &medium, QITreeWidgetItem *pParent);
     UIMediumItem* searchItem(const QTreeWidgetItem *pParent, const QString &mediumId);
+    void          performMediumSearch();
+    /** Remember the default foreground brush of the tree so that we can reset tree items' foreground later */
+    void          saveDefaultForeground();
 
-    QVBoxLayout       *m_pMainLayout;
-    QITreeWidget      *m_pTreeWidget;
-    UIMediumType       m_enmMediumType;
-    QIDialogButtonBox *m_pButtonBox;
-    UIToolBar         *m_pToolBar;
-    QAction           *m_pActionAdd;
-    QAction           *m_pActionRefresh;
+    QVBoxLayout          *m_pMainLayout;
+    QITreeWidget         *m_pTreeWidget;
+    UIMediumType          m_enmMediumType;
+    QIDialogButtonBox    *m_pButtonBox;
+    UIToolBar            *m_pToolBar;
+    QAction              *m_pActionAdd;
+    QAction              *m_pActionRefresh;
     /** All the known media that are already attached to some vm are added under the following top level tree item */
-    QITreeWidgetItem  *m_pAttachedSubTreeRoot;
+    QITreeWidgetItem     *m_pAttachedSubTreeRoot;
     /** All the known media that are not attached to any vm are added under the following top level tree item */
-    QITreeWidgetItem  *m_pNotAttachedSubTreeRoot;
-    QWidget           *m_pParent;
+    QITreeWidgetItem     *m_pNotAttachedSubTreeRoot;
+    QWidget              *m_pParent;
+    UIMediumSearchWidget *m_pSearchWidget;
+    QList<UIMediumItem*>  m_mediumItemList;
+    QBrush                m_defaultItemForeground;
+
 };
 
