Index: trunk/src/VBox/Frontends/VirtualBox/nls/VirtualBox_ar.ts
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/nls/VirtualBox_ar.ts	(revision 30021)
+++ trunk/src/VBox/Frontends/VirtualBox/nls/VirtualBox_ar.ts	(revision 30022)
@@ -5664,5 +5664,5 @@
 </context>
 <context>
-    <name>VBoxVMListView</name>
+    <name>UIVMListView</name>
     <message>
         <source>Inaccessible</source>
Index: trunk/src/VBox/Frontends/VirtualBox/nls/VirtualBox_bg.ts
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/nls/VirtualBox_bg.ts	(revision 30021)
+++ trunk/src/VBox/Frontends/VirtualBox/nls/VirtualBox_bg.ts	(revision 30022)
@@ -6642,5 +6642,5 @@
 </context>
 <context>
-    <name>VBoxVMListView</name>
+    <name>UIVMListView</name>
     <message>
         <source>Inaccessible</source>
Index: trunk/src/VBox/Frontends/VirtualBox/nls/VirtualBox_ca.ts
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/nls/VirtualBox_ca.ts	(revision 30021)
+++ trunk/src/VBox/Frontends/VirtualBox/nls/VirtualBox_ca.ts	(revision 30022)
@@ -8972,5 +8972,5 @@
 </context>
 <context>
-    <name>VBoxVMListView</name>
+    <name>UIVMListView</name>
     <message>
         <source>Inaccessible</source>
Index: trunk/src/VBox/Frontends/VirtualBox/nls/VirtualBox_ca_VA.ts
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/nls/VirtualBox_ca_VA.ts	(revision 30021)
+++ trunk/src/VBox/Frontends/VirtualBox/nls/VirtualBox_ca_VA.ts	(revision 30022)
@@ -8950,5 +8950,5 @@
 </context>
 <context>
-    <name>VBoxVMListView</name>
+    <name>UIVMListView</name>
     <message>
         <source>Inaccessible</source>
Index: trunk/src/VBox/Frontends/VirtualBox/nls/VirtualBox_cs.ts
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/nls/VirtualBox_cs.ts	(revision 30021)
+++ trunk/src/VBox/Frontends/VirtualBox/nls/VirtualBox_cs.ts	(revision 30022)
@@ -8455,5 +8455,5 @@
 </context>
 <context>
-    <name>VBoxVMListView</name>
+    <name>UIVMListView</name>
     <message>
         <source>Inaccessible</source>
Index: trunk/src/VBox/Frontends/VirtualBox/nls/VirtualBox_da.ts
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/nls/VirtualBox_da.ts	(revision 30021)
+++ trunk/src/VBox/Frontends/VirtualBox/nls/VirtualBox_da.ts	(revision 30022)
@@ -6600,5 +6600,5 @@
 </context>
 <context>
-    <name>VBoxVMListView</name>
+    <name>UIVMListView</name>
     <message>
         <source>Inaccessible</source>
Index: trunk/src/VBox/Frontends/VirtualBox/nls/VirtualBox_de.ts
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/nls/VirtualBox_de.ts	(revision 30021)
+++ trunk/src/VBox/Frontends/VirtualBox/nls/VirtualBox_de.ts	(revision 30022)
@@ -4929,5 +4929,5 @@
 </context>
 <context>
-    <name>VBoxVMListView</name>
+    <name>UIVMListView</name>
     <message>
         <source>Inaccessible</source>
Index: trunk/src/VBox/Frontends/VirtualBox/nls/VirtualBox_el.ts
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/nls/VirtualBox_el.ts	(revision 30021)
+++ trunk/src/VBox/Frontends/VirtualBox/nls/VirtualBox_el.ts	(revision 30022)
@@ -4929,5 +4929,5 @@
 </context>
 <context>
-    <name>VBoxVMListView</name>
+    <name>UIVMListView</name>
     <message>
         <source>Inaccessible</source>
Index: trunk/src/VBox/Frontends/VirtualBox/nls/VirtualBox_es.ts
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/nls/VirtualBox_es.ts	(revision 30021)
+++ trunk/src/VBox/Frontends/VirtualBox/nls/VirtualBox_es.ts	(revision 30022)
@@ -9143,5 +9143,5 @@
 </context>
 <context>
-    <name>VBoxVMListView</name>
+    <name>UIVMListView</name>
     <message>
         <source>Inaccessible</source>
Index: trunk/src/VBox/Frontends/VirtualBox/nls/VirtualBox_eu.ts
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/nls/VirtualBox_eu.ts	(revision 30021)
+++ trunk/src/VBox/Frontends/VirtualBox/nls/VirtualBox_eu.ts	(revision 30022)
@@ -7599,5 +7599,5 @@
 </context>
 <context>
-    <name>VBoxVMListView</name>
+    <name>UIVMListView</name>
     <message>
         <source>Inaccessible</source>
Index: trunk/src/VBox/Frontends/VirtualBox/nls/VirtualBox_fi.ts
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/nls/VirtualBox_fi.ts	(revision 30021)
+++ trunk/src/VBox/Frontends/VirtualBox/nls/VirtualBox_fi.ts	(revision 30022)
@@ -7843,5 +7843,5 @@
 </context>
 <context>
-    <name>VBoxVMListView</name>
+    <name>UIVMListView</name>
     <message>
         <source>Inaccessible</source>
Index: trunk/src/VBox/Frontends/VirtualBox/nls/VirtualBox_fr.ts
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/nls/VirtualBox_fr.ts	(revision 30021)
+++ trunk/src/VBox/Frontends/VirtualBox/nls/VirtualBox_fr.ts	(revision 30022)
@@ -5413,5 +5413,5 @@
 </context>
 <context>
-    <name>VBoxVMListView</name>
+    <name>UIVMListView</name>
     <message>
         <source>Inaccessible</source>
Index: trunk/src/VBox/Frontends/VirtualBox/nls/VirtualBox_gl_ES.ts
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/nls/VirtualBox_gl_ES.ts	(revision 30021)
+++ trunk/src/VBox/Frontends/VirtualBox/nls/VirtualBox_gl_ES.ts	(revision 30022)
@@ -6367,5 +6367,5 @@
 </context>
 <context>
-    <name>VBoxVMListView</name>
+    <name>UIVMListView</name>
     <message>
         <source>Inaccessible</source>
Index: trunk/src/VBox/Frontends/VirtualBox/nls/VirtualBox_hu.ts
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/nls/VirtualBox_hu.ts	(revision 30021)
+++ trunk/src/VBox/Frontends/VirtualBox/nls/VirtualBox_hu.ts	(revision 30022)
@@ -8521,5 +8521,5 @@
 </context>
 <context>
-    <name>VBoxVMListView</name>
+    <name>UIVMListView</name>
     <message>
         <source>Inaccessible</source>
Index: trunk/src/VBox/Frontends/VirtualBox/nls/VirtualBox_id.ts
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/nls/VirtualBox_id.ts	(revision 30021)
+++ trunk/src/VBox/Frontends/VirtualBox/nls/VirtualBox_id.ts	(revision 30022)
@@ -8060,5 +8060,5 @@
 </context>
 <context>
-    <name>VBoxVMListView</name>
+    <name>UIVMListView</name>
     <message>
         <source>Inaccessible</source>
Index: trunk/src/VBox/Frontends/VirtualBox/nls/VirtualBox_it.ts
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/nls/VirtualBox_it.ts	(revision 30021)
+++ trunk/src/VBox/Frontends/VirtualBox/nls/VirtualBox_it.ts	(revision 30022)
@@ -9128,5 +9128,5 @@
 </context>
 <context>
-    <name>VBoxVMListView</name>
+    <name>UIVMListView</name>
     <message>
         <source>Inaccessible</source>
Index: trunk/src/VBox/Frontends/VirtualBox/nls/VirtualBox_ja.ts
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/nls/VirtualBox_ja.ts	(revision 30021)
+++ trunk/src/VBox/Frontends/VirtualBox/nls/VirtualBox_ja.ts	(revision 30022)
@@ -10587,12 +10587,12 @@
 </context>
 <context>
-    <name>VBoxVMListView</name>
-    <message>
-        <location filename="../src/VBoxVMListView.cpp" line="156"/>
+    <name>UIVMListView</name>
+    <message>
+        <location filename="../src/UIVMListView.cpp" line="156"/>
         <source>Inaccessible</source>
         <translation>アクセスできません</translation>
     </message>
     <message>
-        <location filename="../src/VBoxVMListView.cpp" line="172"/>
+        <location filename="../src/UIVMListView.cpp" line="172"/>
         <source>&lt;nobr&gt;%1&lt;br&gt;&lt;/nobr&gt;&lt;nobr&gt;%2 since %3&lt;/nobr&gt;&lt;br&gt;&lt;nobr&gt;Session %4&lt;/nobr&gt;</source>
         <comment>VM tooltip (name, last state change, session state)</comment>
@@ -10600,5 +10600,5 @@
     </message>
     <message>
-        <location filename="../src/VBoxVMListView.cpp" line="184"/>
+        <location filename="../src/UIVMListView.cpp" line="184"/>
         <source>&lt;nobr&gt;&lt;b&gt;%1&lt;/b&gt;&lt;br&gt;&lt;/nobr&gt;&lt;nobr&gt;Inaccessible since %2&lt;/nobr&gt;</source>
         <comment>Inaccessible VM tooltip (name, last state change)</comment>
Index: trunk/src/VBox/Frontends/VirtualBox/nls/VirtualBox_km_KH.ts
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/nls/VirtualBox_km_KH.ts	(revision 30021)
+++ trunk/src/VBox/Frontends/VirtualBox/nls/VirtualBox_km_KH.ts	(revision 30022)
@@ -6863,5 +6863,5 @@
 </context>
 <context>
-    <name>VBoxVMListView</name>
+    <name>UIVMListView</name>
     <message>
         <source>Inaccessible</source>
Index: trunk/src/VBox/Frontends/VirtualBox/nls/VirtualBox_ko.ts
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/nls/VirtualBox_ko.ts	(revision 30021)
+++ trunk/src/VBox/Frontends/VirtualBox/nls/VirtualBox_ko.ts	(revision 30022)
@@ -6610,5 +6610,5 @@
 </context>
 <context>
-    <name>VBoxVMListView</name>
+    <name>UIVMListView</name>
     <message>
         <source>Inaccessible</source>
Index: trunk/src/VBox/Frontends/VirtualBox/nls/VirtualBox_nl.ts
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/nls/VirtualBox_nl.ts	(revision 30021)
+++ trunk/src/VBox/Frontends/VirtualBox/nls/VirtualBox_nl.ts	(revision 30022)
@@ -6588,5 +6588,5 @@
 </context>
 <context>
-    <name>VBoxVMListView</name>
+    <name>UIVMListView</name>
     <message>
         <source>Inaccessible</source>
Index: trunk/src/VBox/Frontends/VirtualBox/nls/VirtualBox_pl.ts
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/nls/VirtualBox_pl.ts	(revision 30021)
+++ trunk/src/VBox/Frontends/VirtualBox/nls/VirtualBox_pl.ts	(revision 30022)
@@ -8872,5 +8872,5 @@
 </context>
 <context>
-    <name>VBoxVMListView</name>
+    <name>UIVMListView</name>
     <message>
         <source>Inaccessible</source>
Index: trunk/src/VBox/Frontends/VirtualBox/nls/VirtualBox_pt.ts
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/nls/VirtualBox_pt.ts	(revision 30021)
+++ trunk/src/VBox/Frontends/VirtualBox/nls/VirtualBox_pt.ts	(revision 30022)
@@ -8465,5 +8465,5 @@
 </context>
 <context>
-    <name>VBoxVMListView</name>
+    <name>UIVMListView</name>
     <message>
         <source>Inaccessible</source>
Index: trunk/src/VBox/Frontends/VirtualBox/nls/VirtualBox_pt_BR.ts
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/nls/VirtualBox_pt_BR.ts	(revision 30021)
+++ trunk/src/VBox/Frontends/VirtualBox/nls/VirtualBox_pt_BR.ts	(revision 30022)
@@ -9246,5 +9246,5 @@
 </context>
 <context>
-    <name>VBoxVMListView</name>
+    <name>UIVMListView</name>
     <message>
         <source>Inaccessible</source>
Index: trunk/src/VBox/Frontends/VirtualBox/nls/VirtualBox_ro.ts
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/nls/VirtualBox_ro.ts	(revision 30021)
+++ trunk/src/VBox/Frontends/VirtualBox/nls/VirtualBox_ro.ts	(revision 30022)
@@ -9185,5 +9185,5 @@
 </context>
 <context>
-    <name>VBoxVMListView</name>
+    <name>UIVMListView</name>
     <message>
         <source>Inaccessible</source>
Index: trunk/src/VBox/Frontends/VirtualBox/nls/VirtualBox_ru.ts
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/nls/VirtualBox_ru.ts	(revision 30021)
+++ trunk/src/VBox/Frontends/VirtualBox/nls/VirtualBox_ru.ts	(revision 30022)
@@ -6774,5 +6774,5 @@
 </context>
 <context>
-    <name>VBoxVMListView</name>
+    <name>UIVMListView</name>
     <message>
         <source>Inaccessible</source>
Index: trunk/src/VBox/Frontends/VirtualBox/nls/VirtualBox_sk.ts
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/nls/VirtualBox_sk.ts	(revision 30021)
+++ trunk/src/VBox/Frontends/VirtualBox/nls/VirtualBox_sk.ts	(revision 30022)
@@ -8206,5 +8206,5 @@
 </context>
 <context>
-    <name>VBoxVMListView</name>
+    <name>UIVMListView</name>
     <message>
         <source>Inaccessible</source>
Index: trunk/src/VBox/Frontends/VirtualBox/nls/VirtualBox_sr.ts
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/nls/VirtualBox_sr.ts	(revision 30021)
+++ trunk/src/VBox/Frontends/VirtualBox/nls/VirtualBox_sr.ts	(revision 30022)
@@ -6717,5 +6717,5 @@
 </context>
 <context>
-    <name>VBoxVMListView</name>
+    <name>UIVMListView</name>
     <message>
         <source>Inaccessible</source>
Index: trunk/src/VBox/Frontends/VirtualBox/nls/VirtualBox_sv.ts
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/nls/VirtualBox_sv.ts	(revision 30021)
+++ trunk/src/VBox/Frontends/VirtualBox/nls/VirtualBox_sv.ts	(revision 30022)
@@ -7269,5 +7269,5 @@
 </context>
 <context>
-    <name>VBoxVMListView</name>
+    <name>UIVMListView</name>
     <message>
         <source>Inaccessible</source>
Index: trunk/src/VBox/Frontends/VirtualBox/nls/VirtualBox_tr.ts
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/nls/VirtualBox_tr.ts	(revision 30021)
+++ trunk/src/VBox/Frontends/VirtualBox/nls/VirtualBox_tr.ts	(revision 30022)
@@ -8123,5 +8123,5 @@
 </context>
 <context>
-    <name>VBoxVMListView</name>
+    <name>UIVMListView</name>
     <message>
         <source>Inaccessible</source>
Index: trunk/src/VBox/Frontends/VirtualBox/nls/VirtualBox_uk.ts
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/nls/VirtualBox_uk.ts	(revision 30021)
+++ trunk/src/VBox/Frontends/VirtualBox/nls/VirtualBox_uk.ts	(revision 30022)
@@ -6740,5 +6740,5 @@
 </context>
 <context>
-    <name>VBoxVMListView</name>
+    <name>UIVMListView</name>
     <message>
         <source>Inaccessible</source>
Index: trunk/src/VBox/Frontends/VirtualBox/nls/VirtualBox_xx_YY.ts
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/nls/VirtualBox_xx_YY.ts	(revision 30021)
+++ trunk/src/VBox/Frontends/VirtualBox/nls/VirtualBox_xx_YY.ts	(revision 30022)
@@ -4922,5 +4922,5 @@
 </context>
 <context>
-    <name>VBoxVMListView</name>
+    <name>UIVMListView</name>
     <message>
         <source>Inaccessible</source>
Index: trunk/src/VBox/Frontends/VirtualBox/nls/VirtualBox_zh_CN.ts
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/nls/VirtualBox_zh_CN.ts	(revision 30021)
+++ trunk/src/VBox/Frontends/VirtualBox/nls/VirtualBox_zh_CN.ts	(revision 30022)
@@ -9079,5 +9079,5 @@
 </context>
 <context>
-    <name>VBoxVMListView</name>
+    <name>UIVMListView</name>
     <message>
         <source>Inaccessible</source>
Index: trunk/src/VBox/Frontends/VirtualBox/nls/VirtualBox_zh_TW.ts
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/nls/VirtualBox_zh_TW.ts	(revision 30021)
+++ trunk/src/VBox/Frontends/VirtualBox/nls/VirtualBox_zh_TW.ts	(revision 30022)
@@ -5382,5 +5382,5 @@
 </context>
 <context>
-    <name>VBoxVMListView</name>
+    <name>UIVMListView</name>
     <message>
         <source>Inaccessible</source>
Index: trunk/src/VBox/Frontends/VirtualBox/src/UIVMListView.cpp
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/src/UIVMListView.cpp	(revision 30022)
+++ trunk/src/VBox/Frontends/VirtualBox/src/UIVMListView.cpp	(revision 30022)
@@ -0,0 +1,958 @@
+/* $Id$ */
+/** @file
+ *
+ * VBox frontends: Qt GUI ("VirtualBox"):
+ * UIVMItem, UIVMItemModel, UIVMListView, UIVMItemPainter class implementation
+ */
+
+/*
+ * Copyright (C) 2006-2010 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 */
+#include "UIVMListView.h"
+#include "VBoxProblemReporter.h"
+#include "VBoxSelectorWnd.h"
+
+/* Qt includes */
+#include <QPainter>
+#include <QFileInfo>
+#include <QLinearGradient>
+
+#if defined (Q_WS_MAC)
+# include "VBoxUtils.h"
+# include <ApplicationServices/ApplicationServices.h>
+#endif
+#endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
+
+
+// Helpers
+////////////////////////////////////////////////////////////////////////////////
+
+/// @todo Remove. See @c todo in #switchTo() below.
+#if 0
+
+#if defined (Q_WS_WIN32)
+
+struct EnumWindowsProcData
+{
+    ULONG pid;
+    WId wid;
+};
+
+BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lParam)
+{
+    EnumWindowsProcData *d = (EnumWindowsProcData *) lParam;
+
+    DWORD pid = 0;
+    GetWindowThreadProcessId(hwnd, &pid);
+
+    if (d->pid == pid)
+    {
+        WINDOWINFO info;
+        if (!GetWindowInfo(hwnd, &info))
+            return TRUE;
+
+#if 0
+        LogFlowFunc(("pid=%d, wid=%08X\n", pid, hwnd));
+        LogFlowFunc(("  parent=%08X\n", GetParent(hwnd)));
+        LogFlowFunc(("  owner=%08X\n", GetWindow(hwnd, GW_OWNER)));
+        TCHAR buf [256];
+        LogFlowFunc(("  rcWindow=%d,%d;%d,%d\n",
+                      info.rcWindow.left, info.rcWindow.top,
+                      info.rcWindow.right, info.rcWindow.bottom));
+        LogFlowFunc(("  dwStyle=%08X\n", info.dwStyle));
+        LogFlowFunc(("  dwExStyle=%08X\n", info.dwExStyle));
+        GetClassName(hwnd, buf, 256);
+        LogFlowFunc(("  class=%ls\n", buf));
+        GetWindowText(hwnd, buf, 256);
+        LogFlowFunc(("  text=%ls\n", buf));
+#endif
+
+        /* we are interested in unowned top-level windows only */
+        if (!(info.dwStyle & (WS_CHILD | WS_POPUP)) &&
+            info.rcWindow.left < info.rcWindow.right &&
+            info.rcWindow.top < info.rcWindow.bottom &&
+            GetParent(hwnd) == NULL &&
+            GetWindow(hwnd, GW_OWNER) == NULL)
+        {
+            d->wid = hwnd;
+            /* if visible, stop the search immediately */
+            if (info.dwStyle & WS_VISIBLE)
+                return FALSE;
+            /* otherwise, give other top-level windows a chance
+             * (the last one wins) */
+        }
+    }
+
+    return TRUE;
+}
+
+#endif
+
+/**
+ * Searches for a main window of the given process.
+ *
+ * @param aPid process ID to search for
+ *
+ * @return window ID on success or <tt>(WId) ~0</tt> otherwise.
+ */
+static WId FindWindowIdFromPid(ULONG aPid)
+{
+#if defined (Q_WS_WIN32)
+
+    EnumWindowsProcData d = { aPid, (WId) ~0 };
+    EnumWindows(EnumWindowsProc, (LPARAM) &d);
+    LogFlowFunc(("SELECTED wid=%08X\n", d.wid));
+    return d.wid;
+
+#elif defined (Q_WS_X11)
+
+    NOREF(aPid);
+    return (WId) ~0;
+
+#elif defined (Q_WS_MAC)
+
+    /** @todo Figure out how to get access to another windows of another process...
+     * Or at least check that it's not a VBoxVRDP process. */
+    NOREF (aPid);
+    return (WId) 0;
+
+#else
+
+    return (WId) ~0;
+
+#endif
+}
+
+#endif
+
+UIVMItem::UIVMItem(const CMachine &aMachine)
+    : m_machine(aMachine)
+{
+    recache();
+}
+
+UIVMItem::~UIVMItem()
+{
+}
+
+// public members
+////////////////////////////////////////////////////////////////////////////////
+
+QString UIVMItem::sessionStateName() const
+{
+    return m_fAccessible ? vboxGlobal().toString(m_state) :
+           UIVMListView::tr("Inaccessible");
+}
+
+QString UIVMItem::toolTipText() const
+{
+    QString dateTime = (m_lastStateChange.date() == QDate::currentDate()) ?
+                        m_lastStateChange.time().toString(Qt::LocalDate) :
+                        m_lastStateChange.toString(Qt::LocalDate);
+
+    QString toolTip;
+
+    if (m_fAccessible)
+    {
+        toolTip = QString("<b>%1</b>").arg(m_strName);
+        if (!m_strSnapshotName.isNull())
+            toolTip += QString(" (%1)").arg(m_strSnapshotName);
+        toolTip = QString(UIVMListView::tr(
+            "<nobr>%1<br></nobr>"
+            "<nobr>%2 since %3</nobr><br>"
+            "<nobr>Session %4</nobr>",
+            "VM tooltip (name, last state change, session state)"))
+            .arg(toolTip)
+            .arg(vboxGlobal().toString(m_state))
+            .arg(dateTime)
+            .arg(vboxGlobal().toString(m_sessionState));
+    }
+    else
+    {
+        toolTip = QString(UIVMListView::tr(
+            "<nobr><b>%1</b><br></nobr>"
+            "<nobr>Inaccessible since %2</nobr>",
+            "Inaccessible VM tooltip (name, last state change)"))
+            .arg(m_strSettingsFile)
+            .arg(dateTime);
+    }
+
+    return toolTip;
+}
+
+bool UIVMItem::recache()
+{
+    bool needsResort = true;
+
+    m_strId = m_machine.GetId();
+    m_strSettingsFile = m_machine.GetSettingsFilePath();
+
+    m_fAccessible = m_machine.GetAccessible();
+    if (m_fAccessible)
+    {
+        QString name = m_machine.GetName();
+
+        CSnapshot snp = m_machine.GetCurrentSnapshot();
+        m_strSnapshotName = snp.isNull() ? QString::null : snp.GetName();
+        needsResort = name != m_strName;
+        m_strName = name;
+
+        m_state = m_machine.GetState();
+        m_lastStateChange.setTime_t(m_machine.GetLastStateChange() / 1000);
+        m_sessionState = m_machine.GetSessionState();
+        m_strOSTypeId = m_machine.GetOSTypeId();
+        m_cSnaphot = m_machine.GetSnapshotCount();
+
+        if (   m_state == KMachineState_PoweredOff
+            || m_state == KMachineState_Saved
+            || m_state == KMachineState_Teleported
+            || m_state == KMachineState_Aborted
+           )
+        {
+            m_pid = (ULONG) ~0;
+    /// @todo Remove. See @c todo in #switchTo() below.
+#if 0
+            mWinId = (WId) ~0;
+#endif
+        }
+        else
+        {
+            m_pid = m_machine.GetSessionPid();
+    /// @todo Remove. See @c todo in #switchTo() below.
+#if 0
+            mWinId = FindWindowIdFromPid(m_pid);
+#endif
+        }
+    }
+    else
+    {
+        m_accessError = m_machine.GetAccessError();
+
+        /* this should be in sync with
+         * VBoxProblemReporter::confirm_machineDeletion() */
+        QFileInfo fi(m_strSettingsFile);
+        QString name = fi.completeSuffix().toLower() == "xml" ?
+                       fi.completeBaseName() : fi.fileName();
+        needsResort = name != m_strName;
+        m_strName = name;
+        m_state = KMachineState_Null;
+        m_sessionState = KSessionState_Null;
+        m_lastStateChange = QDateTime::currentDateTime();
+        m_strOSTypeId = QString::null;
+        m_cSnaphot = 0;
+
+        m_pid = (ULONG) ~0;
+    /// @todo Remove. See @c todo in #switchTo() below.
+#if 0
+        mWinId = (WId) ~0;
+#endif
+    }
+
+    return needsResort;
+}
+
+/**
+ * Returns @a true if we can activate and bring the VM console window to
+ * foreground, and @a false otherwise.
+ */
+bool UIVMItem::canSwitchTo() const
+{
+    return const_cast <CMachine &>(m_machine).CanShowConsoleWindow();
+
+    /// @todo Remove. See @c todo in #switchTo() below.
+#if 0
+    return mWinId != (WId) ~0;
+#endif
+}
+
+/**
+ * Tries to switch to the main window of the VM process.
+ *
+ * @return true if successfully switched and false otherwise.
+ */
+bool UIVMItem::switchTo()
+{
+#ifdef Q_WS_MAC
+    ULONG64 id = m_machine.ShowConsoleWindow();
+#else
+    WId id = (WId) m_machine.ShowConsoleWindow();
+#endif
+    AssertWrapperOk(m_machine);
+    if (!m_machine.isOk())
+        return false;
+
+    /* winId = 0 it means the console window has already done everything
+     * necessary to implement the "show window" semantics. */
+    if (id == 0)
+        return true;
+
+#if defined (Q_WS_WIN32) || defined (Q_WS_X11)
+
+    return vboxGlobal().activateWindow(id, true);
+
+#elif defined (Q_WS_MAC)
+    /*
+     * This is just for the case were the other process cannot steal
+     * the focus from us. It will send us a PSN so we can try.
+     */
+    ProcessSerialNumber psn;
+    psn.highLongOfPSN = id >> 32;
+    psn.lowLongOfPSN = (UInt32)id;
+    OSErr rc = ::SetFrontProcess(&psn);
+    if (!rc)
+        Log(("GUI: %#RX64 couldn't do SetFrontProcess on itself, the selector (we) had to do it...\n", id));
+    else
+        Log(("GUI: Failed to bring %#RX64 to front. rc=%#x\n", id, rc));
+    return !rc;
+
+#endif
+
+    return false;
+
+    /// @todo Below is the old method of switching to the console window
+    //  based on the process ID of the console process. It should go away
+    //  after the new (callback-based) method is fully tested.
+#if 0
+
+    if (!canSwitchTo())
+        return false;
+
+#if defined (Q_WS_WIN32)
+
+    HWND hwnd = mWinId;
+
+    /* if there are ownees (modal and modeless dialogs, etc), find the
+     * topmost one */
+    HWND hwndAbove = NULL;
+    do
+    {
+        hwndAbove = GetNextWindow(hwnd, GW_HWNDPREV);
+        HWND hwndOwner;
+        if (hwndAbove != NULL &&
+            ((hwndOwner = GetWindow(hwndAbove, GW_OWNER)) == hwnd ||
+             hwndOwner  == hwndAbove))
+            hwnd = hwndAbove;
+        else
+            break;
+    }
+    while (1);
+
+    /* first, check that the primary window is visible */
+    if (IsIconic(mWinId))
+        ShowWindow(mWinId, SW_RESTORE);
+    else if (!IsWindowVisible(mWinId))
+        ShowWindow(mWinId, SW_SHOW);
+
+#if 0
+    LogFlowFunc(("mWinId=%08X hwnd=%08X\n", mWinId, hwnd));
+#endif
+
+    /* then, activate the topmost in the group */
+    AllowSetForegroundWindow(m_pid);
+    SetForegroundWindow(hwnd);
+
+    return true;
+
+#elif defined (Q_WS_X11)
+
+    return false;
+
+#elif defined (Q_WS_MAC)
+
+    ProcessSerialNumber psn;
+    OSStatus rc = ::GetProcessForPID(m_pid, &psn);
+    if (!rc)
+    {
+        rc = ::SetFrontProcess(&psn);
+
+        if (!rc)
+        {
+            ShowHideProcess(&psn, true);
+            return true;
+        }
+    }
+    return false;
+
+#else
+
+    return false;
+
+#endif
+
+#endif
+}
+
+/* UIVMItemModel class */
+
+void UIVMItemModel::addItem(UIVMItem *aItem)
+{
+    Assert(aItem);
+    int row = m_VMItemList.count();
+    emit layoutAboutToBeChanged();
+    beginInsertRows(QModelIndex(), row, row);
+    m_VMItemList << aItem;
+    endInsertRows();
+    refreshItem(aItem);
+}
+
+void UIVMItemModel::removeItem(UIVMItem *aItem)
+{
+    Assert(aItem);
+    int row = m_VMItemList.indexOf(aItem);
+    removeRows(row, 1);
+}
+
+bool UIVMItemModel::removeRows(int aRow, int aCount, const QModelIndex &aParent /* = QModelIndex() */)
+{
+    emit layoutAboutToBeChanged();
+    beginRemoveRows(aParent, aRow, aRow + aCount);
+    m_VMItemList.erase(m_VMItemList.begin() + aRow, m_VMItemList.begin() + aRow + aCount);
+    endRemoveRows();
+    emit layoutChanged();
+    return true;
+}
+
+/**
+ *  Refreshes the item corresponding to the given UUID.
+ */
+void UIVMItemModel::refreshItem(UIVMItem *aItem)
+{
+    Assert(aItem);
+    if (aItem->recache())
+        sort();
+    itemChanged(aItem);
+}
+
+void UIVMItemModel::itemChanged(UIVMItem *aItem)
+{
+    Assert(aItem);
+    int row = m_VMItemList.indexOf(aItem);
+    /* Emit an layout change signal for the case some dimensions of the item
+     * has changed also. */
+    emit layoutChanged();
+    /* Emit an data changed signal. */
+    emit dataChanged(index(row), index(row));
+}
+
+/**
+ *  Clear the item model list. Please note that the items itself are also
+ *  deleted.
+ */
+void UIVMItemModel::clear()
+{
+    qDeleteAll(m_VMItemList);
+}
+
+/**
+ *  Returns the list item with the given UUID.
+ */
+UIVMItem *UIVMItemModel::itemById(const QString &aId) const
+{
+    foreach(UIVMItem *item, m_VMItemList)
+        if (item->id() == aId)
+            return item;
+    return NULL;
+}
+
+UIVMItem *UIVMItemModel::itemByRow(int aRow) const
+{
+    return m_VMItemList.at(aRow);
+}
+
+QModelIndex UIVMItemModel::indexById(const QString &aId) const
+{
+    int row = rowById(aId);
+    if (row >= 0)
+        return index(row);
+    else
+        return QModelIndex();
+}
+
+int UIVMItemModel::rowById(const QString &aId) const
+{
+    for (int i=0; i < m_VMItemList.count(); ++i)
+    {
+        UIVMItem *item = m_VMItemList.at(i);
+        if (item->id() == aId)
+            return i;
+    }
+    return -1;
+}
+
+void UIVMItemModel::sort(int /* aColumn */, Qt::SortOrder aOrder /* = Qt::AscendingOrder */)
+{
+    emit layoutAboutToBeChanged();
+    switch (aOrder)
+    {
+        case Qt::AscendingOrder: qSort(m_VMItemList.begin(), m_VMItemList.end(), UIVMItemNameCompareLessThan); break;
+        case Qt::DescendingOrder: qSort(m_VMItemList.begin(), m_VMItemList.end(), UIVMItemNameCompareGreaterThan); break;
+    }
+    emit layoutChanged();
+}
+
+int UIVMItemModel::rowCount(const QModelIndex & /* aParent = QModelIndex() */) const
+{
+    return m_VMItemList.count();
+}
+
+QVariant UIVMItemModel::data(const QModelIndex &aIndex, int aRole) const
+{
+    if (!aIndex.isValid())
+        return QVariant();
+
+    if (aIndex.row() >= m_VMItemList.size())
+        return QVariant();
+
+    QVariant v;
+    switch (aRole)
+    {
+        case Qt::DisplayRole:
+        {
+            v = m_VMItemList.at(aIndex.row())->name();
+            break;
+        }
+        case Qt::DecorationRole:
+        {
+            v = m_VMItemList.at(aIndex.row())->osIcon();
+            break;
+        }
+        case Qt::ToolTipRole:
+        {
+            v = m_VMItemList.at(aIndex.row())->toolTipText();
+            break;
+        }
+        case Qt::FontRole:
+        {
+            QFont f = qApp->font();
+            f.setPointSize(f.pointSize() + 1);
+            f.setWeight(QFont::Bold);
+            v = f;
+            break;
+        }
+        case Qt::AccessibleTextRole:
+        {
+            UIVMItem *item = m_VMItemList.at(aIndex.row());
+            v = QString("%1 (%2)\n%3")
+                         .arg(item->name())
+                         .arg(item->snapshotName())
+                         .arg(item->sessionStateName());
+            break;
+        }
+        case SnapShotDisplayRole:
+        {
+            v = m_VMItemList.at(aIndex.row())->snapshotName();
+            break;
+        }
+        case SnapShotFontRole:
+        {
+            QFont f = qApp->font();
+            v = f;
+            break;
+        }
+        case SessionStateDisplayRole:
+        {
+            v = m_VMItemList.at(aIndex.row())->sessionStateName();
+            break;
+        }
+        case SessionStateDecorationRole:
+        {
+            v = m_VMItemList.at(aIndex.row())->sessionStateIcon();
+            break;
+        }
+        case SessionStateFontRole:
+        {
+            QFont f = qApp->font();
+            f.setPointSize(f.pointSize());
+            if (m_VMItemList.at(aIndex.row())->sessionState() != KSessionState_Closed)
+                f.setItalic(true);
+            v = f;
+            break;
+        }
+        case UIVMItemPtrRole:
+        {
+            v = qVariantFromValue(m_VMItemList.at(aIndex.row()));
+        }
+    }
+    return v;
+}
+
+QVariant UIVMItemModel::headerData(int /*aSection*/, Qt::Orientation /*aOrientation*/,
+                                  int /*aRole = Qt::DisplayRole */) const
+{
+    return QVariant();
+}
+
+bool UIVMItemModel::UIVMItemNameCompareLessThan(UIVMItem* aItem1, UIVMItem* aItem2)
+{
+    Assert(aItem1);
+    Assert(aItem2);
+    return aItem1->name().toLower() < aItem2->name().toLower();
+}
+
+bool UIVMItemModel::UIVMItemNameCompareGreaterThan(UIVMItem* aItem1, UIVMItem* aItem2)
+{
+    Assert(aItem1);
+    Assert(aItem2);
+    return aItem2->name().toLower() < aItem1->name().toLower();
+}
+
+/* UIVMListView class */
+
+UIVMListView::UIVMListView(QWidget *aParent /* = 0 */)
+    :QIListView(aParent)
+{
+    /* Create & set our delegation class */
+    UIVMItemPainter *delegate = new UIVMItemPainter(this);
+    setItemDelegate(delegate);
+    /* Default icon size */
+    setIconSize(QSize(32, 32));
+    /* Publish the activation of items */
+    connect(this, SIGNAL(activated(const QModelIndex &)),
+            this, SIGNAL(activated()));
+    /* Use the correct policy for the context menu */
+    setContextMenuPolicy(Qt::CustomContextMenu);
+}
+
+void UIVMListView::selectItemByRow(int row)
+{
+    setCurrentIndex(model()->index(row, 0));
+}
+
+void UIVMListView::selectItemById(const QString &aID)
+{
+    if (UIVMItemModel *m = qobject_cast <UIVMItemModel*>(model()))
+    {
+        QModelIndex i = m->indexById(aID);
+        if (i.isValid())
+            setCurrentIndex(i);
+    }
+}
+
+void UIVMListView::ensureSomeRowSelected(int aRowHint)
+{
+    UIVMItem *item = selectedItem();
+    if (!item)
+    {
+        aRowHint = qBound(0, aRowHint, model()->rowCount() - 1);
+        selectItemByRow(aRowHint);
+        item = selectedItem();
+        if (!item)
+            selectItemByRow(0);
+    }
+}
+
+UIVMItem * UIVMListView::selectedItem() const
+{
+    QModelIndexList indexes = selectedIndexes();
+    if (indexes.isEmpty())
+        return NULL;
+    return model()->data(indexes.first(), UIVMItemModel::UIVMItemPtrRole).value <UIVMItem *>();
+}
+
+void UIVMListView::ensureCurrentVisible()
+{
+    scrollTo(currentIndex(), QAbstractItemView::EnsureVisible);
+}
+
+void UIVMListView::selectionChanged(const QItemSelection &aSelected, const QItemSelection &aDeselected)
+{
+    QListView::selectionChanged(aSelected, aDeselected);
+    selectCurrent();
+    ensureCurrentVisible();
+    emit currentChanged();
+}
+
+void UIVMListView::currentChanged(const QModelIndex &aCurrent, const QModelIndex &aPrevious)
+{
+    QListView::currentChanged(aCurrent, aPrevious);
+    selectCurrent();
+    ensureCurrentVisible();
+    emit currentChanged();
+}
+
+void UIVMListView::dataChanged(const QModelIndex &aTopLeft, const QModelIndex &aBottomRight)
+{
+    QListView::dataChanged(aTopLeft, aBottomRight);
+    selectCurrent();
+//    ensureCurrentVisible();
+    emit currentChanged();
+}
+
+bool UIVMListView::selectCurrent()
+{
+    QModelIndexList indexes = selectionModel()->selectedIndexes();
+    if (indexes.isEmpty() ||
+        indexes.first() != currentIndex())
+    {
+        /* Make sure that the current is always selected */
+        selectionModel()->select(currentIndex(), QItemSelectionModel::Current | QItemSelectionModel::ClearAndSelect);
+        return true;
+    }
+    return false;
+}
+
+/* UIVMItemPainter class */
+/*
+ +----------------------------------------------+
+ |       marg                                   |
+ |   +----------+   m                           |
+ | m |          | m a  name_string___________ m |
+ | a |  OSType  | a r                         a |
+ | r |  icon    | r g  +--+                   r |
+ | g |          | g /  |si|  state_string     g |
+ |   +----------+   2  +--+                     |
+ |       marg                                   |
+ +----------------------------------------------+
+
+ si = state icon
+
+*/
+
+/* Little helper class for layout calculation */
+class QRectList: public QList<QRect *>
+{
+public:
+    void alignVCenterTo(QRect* aWhich)
+    {
+        QRect b;
+        foreach(QRect *rect, *this)
+            if(rect != aWhich)
+                b |= *rect;
+        if (b.width() > aWhich->width())
+            aWhich->moveCenter(QPoint(aWhich->center().x(), b.center().y()));
+        else
+        {
+            foreach(QRect *rect, *this)
+                if(rect != aWhich)
+                    rect->moveCenter(QPoint(rect->center().x(), aWhich->center().y()));
+        }
+    }
+};
+
+QSize UIVMItemPainter::sizeHint(const QStyleOptionViewItem &aOption,
+                                   const QModelIndex &aIndex) const
+{
+    /* Get the size of every item */
+    QRect osTypeRT = rect(aOption, aIndex, Qt::DecorationRole);
+    QRect vmNameRT = rect(aOption, aIndex, Qt::DisplayRole);
+    QRect shotRT = rect(aOption, aIndex, UIVMItemModel::SnapShotDisplayRole);
+    QRect stateIconRT = rect(aOption, aIndex, UIVMItemModel::SessionStateDecorationRole);
+    QRect stateRT = rect(aOption, aIndex, UIVMItemModel::SessionStateDisplayRole);
+    /* Calculate the position for every item */
+    calcLayout(aIndex, &osTypeRT, &vmNameRT, &shotRT, &stateIconRT, &stateRT);
+    /* Calc the bounding rect */
+    const QRect boundingRect = osTypeRT | vmNameRT | shotRT | stateIconRT | stateRT;
+    /* Return + left/top/right/bottom margin */
+    return (boundingRect.size() + QSize(2 * m_Margin, 2 * m_Margin));
+}
+
+void UIVMItemPainter::paint(QPainter *aPainter, const QStyleOptionViewItem &aOption,
+                               const QModelIndex &aIndex) const
+{
+    QStyleOptionViewItem option(aOption);
+    /* Highlight background if an item is selected in any case.
+     * (Fix for selector in the windows style.) */
+    option.showDecorationSelected = true;
+
+    /* Start drawing with the background */
+    drawBackground(aPainter, option, aIndex);
+
+    /* Blend the content */
+    blendContent(aPainter, option, aIndex);
+
+    /* Draw a focus rectangle when necessary */
+    drawFocus(aPainter, option, option.rect);
+}
+
+void UIVMItemPainter::paintContent(QPainter *pPainter, const QStyleOptionViewItem &option,
+                                   const QModelIndex &index) const
+{
+    /* Name and decoration */
+    const QString vmName = index.data(Qt::DisplayRole).toString();
+    const QFont nameFont = index.data(Qt::FontRole).value<QFont>();
+    const QPixmap osType = index.data(Qt::DecorationRole).value<QIcon>().pixmap(option.decorationSize, iconMode(option.state), iconState(option.state));
+
+    const QString shot = index.data(UIVMItemModel::SnapShotDisplayRole).toString();
+    const QFont shotFont = index.data(UIVMItemModel::SnapShotFontRole).value<QFont>();
+
+    const QString state = index.data(UIVMItemModel::SessionStateDisplayRole).toString();
+    const QFont stateFont = index.data(UIVMItemModel::SessionStateFontRole).value<QFont>();
+    const QPixmap stateIcon = index.data(UIVMItemModel::SessionStateDecorationRole).value<QIcon>().pixmap(QSize(16, 16), iconMode(option.state), iconState(option.state));
+
+    /* Get the sizes for all items */
+    QRect osTypeRT = rect(option, index, Qt::DecorationRole);
+    QRect vmNameRT = rect(option, index, Qt::DisplayRole);
+    QRect shotRT = rect(option, index, UIVMItemModel::SnapShotDisplayRole);
+    QRect stateIconRT = rect(option, index, UIVMItemModel::SessionStateDecorationRole);
+    QRect stateRT = rect(option, index, UIVMItemModel::SessionStateDisplayRole);
+
+    /* Calculate the positions for all items */
+    calcLayout(index, &osTypeRT, &vmNameRT, &shotRT, &stateIconRT, &stateRT);
+    /* Get the appropriate pen for the current state */
+    QPalette pal = option.palette;
+    QPen pen = pal.color(QPalette::Active, QPalette::Text);
+    if (option.state & QStyle::State_Selected &&
+        (option.state & QStyle::State_HasFocus ||
+        QApplication::style()->styleHint(QStyle::SH_ItemView_ChangeHighlightOnFocus, &option) == 0))
+        pen =  pal.color(QPalette::Active, QPalette::HighlightedText);
+    /* Set the current pen */
+    pPainter->setPen(pen);
+    /* os type icon */
+    pPainter->drawPixmap(osTypeRT, osType);
+    /* vm name */
+    pPainter->setFont(nameFont);
+    pPainter->drawText(vmNameRT, vmName);
+    /* current snapshot in braces */
+    if (!shot.isEmpty())
+    {
+        pPainter->setFont(shotFont);
+        pPainter->drawText(shotRT, QString("(%1)").arg(shot));
+    }
+    /* state icon */
+    pPainter->drawPixmap(stateIconRT, stateIcon);
+    /* textual state */
+    pPainter->setFont(stateFont);
+    pPainter->drawText(stateRT, state);
+    /* For debugging */
+//    QRect boundingRect = osTypeRT | vmNameRT | shotRT | stateIconRT | stateRT;
+//    pPainter->drawRect(boundingRect);
+}
+
+void UIVMItemPainter::blendContent(QPainter *pPainter, const QStyleOptionViewItem &option,
+                                   const QModelIndex &index) const
+{
+    QRect r = option.rect;
+    QWidget *pParent = qobject_cast<QListView *>(parent())->viewport();
+    /* This is as always a big fat mess on Mac OS X. We can't use QImage for
+     * rendering text, cause this looks like shit. We can't do all the drawing
+     * on the widget, cause the composition modes are not working correctly.
+     * The same count for doing composition on a QPixmap. The work around is to
+     * draw all into a QPixmap (also the background color/gradient, otherwise
+     * the antialiasing is messed up), bliting this into a QImage to make the
+     * composition stuff and finally bliting this QImage into the QWidget.
+     * Yipi a yeah. Btw, no problem on Linux at all. */
+    QPixmap basePixmap(r.width(), r.height());//
+    /* Initialize with the base image color. */
+    basePixmap.fill(pParent->palette().base().color());
+    /* Create the painter to operate on. */
+    QPainter basePainter(&basePixmap);
+    /* Initialize the painter with the corresponding widget */
+    basePainter.initFrom(pParent);
+    basePainter.setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing, true);
+    /* The translation is necessary, cause drawBackground expect the whole drawing area. */
+    basePainter.save();
+    basePainter.translate(-option.rect.x(), -option.rect.y());
+    drawBackground(&basePainter, option, index);
+    basePainter.restore();
+    /* Now paint the content. */
+    paintContent(&basePainter, option, index);
+    /* Finished with the OS dependent part. */
+    basePainter.end();
+    /* Time for the OS independent part (That is, use the QRasterEngine) */
+    QImage baseImage(r.width(), r.height(), QImage::Format_ARGB32_Premultiplied);
+    QPainter rasterPainter(&baseImage);
+    /* Initialize the painter with the corresponding widget */
+    rasterPainter.initFrom(pParent);
+    rasterPainter.setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing, true);
+    /* Fully copy the source to the destination */
+    rasterPainter.setCompositionMode(QPainter::CompositionMode_Source);
+    rasterPainter.drawPixmap(0, 0, basePixmap);
+    /* Now use the alpha value of the source to blend the destination in. */
+    rasterPainter.setCompositionMode(QPainter::CompositionMode_DestinationIn);
+
+    const int blendWidth = qMin(70, r.width());
+    QLinearGradient lg(r.width()-blendWidth, 0, r.width(), 0);
+    lg.setColorAt(0, QColor(Qt::white));
+    lg.setColorAt(0.95, QColor(Qt::transparent));
+    lg.setColorAt(1, QColor(Qt::transparent));
+    rasterPainter.fillRect(r.width()-blendWidth, 0, blendWidth, r.height(), lg);
+    /* Finished with the OS independent part. */
+    rasterPainter.end();
+
+    /* Finally blit our hard work on the widget. */
+    pPainter->drawImage(option.rect.x(), option.rect.y(), baseImage);
+}
+
+QRect UIVMItemPainter::rect(const QStyleOptionViewItem &aOption,
+                            const QModelIndex &aIndex, int aRole) const
+{
+    switch (aRole)
+    {
+        case Qt::DisplayRole:
+            {
+                QString text = aIndex.data(Qt::DisplayRole).toString();
+                QFontMetrics fm(fontMetric(aIndex, Qt::FontRole));
+                return QRect(QPoint(0, 0), fm.size(0, text));
+                break;
+            }
+        case Qt::DecorationRole:
+            {
+                QIcon icon = aIndex.data(Qt::DecorationRole).value<QIcon>();
+                return QRect(QPoint(0, 0), icon.actualSize(aOption.decorationSize, iconMode(aOption.state), iconState(aOption.state)));
+                break;
+            }
+        case UIVMItemModel::SnapShotDisplayRole:
+            {
+                QString text = aIndex.data(UIVMItemModel::SnapShotDisplayRole).toString();
+                if (!text.isEmpty())
+                {
+                    QFontMetrics fm(fontMetric(aIndex, UIVMItemModel::SnapShotFontRole));
+                    return QRect(QPoint(0, 0), fm.size(0, QString("(%1)").arg(text)));
+                }else
+                    return QRect();
+                break;
+            }
+        case UIVMItemModel::SessionStateDisplayRole:
+            {
+                QString text = aIndex.data(UIVMItemModel::SessionStateDisplayRole).toString();
+                QFontMetrics fm(fontMetric(aIndex, UIVMItemModel::SessionStateFontRole));
+                return QRect(QPoint(0, 0), fm.size(0, text));
+                break;
+            }
+        case UIVMItemModel::SessionStateDecorationRole:
+            {
+                QIcon icon = aIndex.data(UIVMItemModel::SessionStateDecorationRole).value<QIcon>();
+                return QRect(QPoint(0, 0), icon.actualSize(QSize(16, 16), iconMode(aOption.state), iconState(aOption.state)));
+                break;
+            }
+    }
+    return QRect();
+}
+
+void UIVMItemPainter::calcLayout(const QModelIndex &aIndex,
+                                 QRect *aOSType, QRect *aVMName, QRect *aShot,
+                                 QRect *aStateIcon, QRect *aState) const
+{
+    const int nameSpaceWidth = fontMetric(aIndex, Qt::FontRole).width(' ');
+    const int stateSpaceWidth = fontMetric(aIndex, UIVMItemModel::SessionStateFontRole).width(' ');
+    /* Really basic layout managment.
+     * First layout as usual */
+    aOSType->moveTo(m_Margin, m_Margin);
+    aVMName->moveTo(m_Margin + aOSType->width() + m_Spacing, m_Margin);
+    aShot->moveTo(aVMName->right() + nameSpaceWidth, aVMName->top());
+    aStateIcon->moveTo(aVMName->left(), aVMName->bottom());
+    aState->moveTo(aStateIcon->right() + stateSpaceWidth, aStateIcon->top());
+    /* Do grouping for the automatic center routine.
+     * First the states group: */
+    QRectList statesLayout;
+    statesLayout << aStateIcon << aState;
+    /* All items in the layout: */
+    QRectList allLayout;
+    allLayout << aOSType << aVMName << aShot << statesLayout;
+    /* Now verticaly center the items based on the reference item */
+    statesLayout.alignVCenterTo(aStateIcon);
+    allLayout.alignVCenterTo(aOSType);
+}
+
Index: trunk/src/VBox/Frontends/VirtualBox/src/UIVMListView.h
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/src/UIVMListView.h	(revision 30022)
+++ trunk/src/VBox/Frontends/VirtualBox/src/UIVMListView.h	(revision 30022)
@@ -0,0 +1,204 @@
+/** @file
+ *
+ * VBox frontends: Qt GUI ("VirtualBox"):
+ * UIVMItem, UIVMItemModel, UIVMListView, UIVMItemPainter class declarations
+ */
+
+/*
+ * Copyright (C) 2006-2010 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 __UIVMListView_h__
+#define __UIVMListView_h__
+
+#include "VBoxGlobal.h"
+#include "QIListView.h"
+
+/* Qt includes */
+#include <QAbstractListModel>
+#include <QDateTime>
+
+class VBoxSelectorWnd;
+
+class UIVMItem
+{
+public:
+
+    UIVMItem(const CMachine &aMachine);
+    virtual ~UIVMItem();
+
+    CMachine machine() const { return m_machine; }
+
+    QString name() const { return m_strName; }
+    QIcon osIcon() const { return m_fAccessible ? vboxGlobal().vmGuestOSTypeIcon(m_strOSTypeId) : QPixmap(":/os_other.png"); }
+    QString id() const { return m_strId; }
+
+    QString sessionStateName() const;
+    QIcon sessionStateIcon() const { return m_fAccessible ? vboxGlobal().toIcon(m_state) : QPixmap(":/state_aborted_16px.png"); }
+
+    QString snapshotName() const { return m_strSnapshotName; }
+    ULONG snapshotCount() const { return m_cSnaphot; }
+
+    QString toolTipText() const;
+
+    bool accessible() const { return m_fAccessible; }
+    const CVirtualBoxErrorInfo &accessError() const { return m_accessError; }
+    KMachineState state() const { return m_state; }
+    KSessionState sessionState() const { return m_sessionState; }
+
+    bool recache();
+
+    bool canSwitchTo() const;
+    bool switchTo();
+
+private:
+
+    /* Private member vars */
+    CMachine m_machine;
+
+    /* Cached machine data (to minimize server requests) */
+    QString m_strId;
+    QString m_strSettingsFile;
+
+    bool m_fAccessible;
+    CVirtualBoxErrorInfo m_accessError;
+
+    QString m_strName;
+    QString m_strSnapshotName;
+    KMachineState m_state;
+    QDateTime m_lastStateChange;
+    KSessionState m_sessionState;
+    QString m_strOSTypeId;
+    ULONG m_cSnaphot;
+
+    ULONG m_pid;
+};
+
+/* Make the pointer of this class public to the QVariant framework */
+Q_DECLARE_METATYPE(UIVMItem *);
+
+class UIVMItemModel: public QAbstractListModel
+{
+    Q_OBJECT;
+
+public:
+    enum { SnapShotDisplayRole = Qt::UserRole,
+           SnapShotFontRole,
+           SessionStateDisplayRole,
+           SessionStateDecorationRole,
+           SessionStateFontRole,
+           UIVMItemPtrRole };
+
+    UIVMItemModel(QObject *aParent = 0)
+        :QAbstractListModel(aParent) {}
+
+    void addItem(UIVMItem *aItem);
+    void removeItem(UIVMItem *aItem);
+    void refreshItem(UIVMItem *aItem);
+
+    void itemChanged(UIVMItem *aItem);
+
+    void clear();
+
+    UIVMItem *itemById(const QString &aId) const;
+    UIVMItem *itemByRow(int aRow) const;
+    QModelIndex indexById(const QString &aId) const;
+
+    int rowById(const QString &aId) const;;
+
+    void sort(Qt::SortOrder aOrder = Qt::AscendingOrder) { sort(0, aOrder); }
+
+    /* The following are necessary model implementations */
+    void sort(int aColumn, Qt::SortOrder aOrder = Qt::AscendingOrder);
+
+    int rowCount(const QModelIndex &aParent = QModelIndex()) const;
+
+    QVariant data(const QModelIndex &aIndex, int aRole) const;
+    QVariant headerData(int aSection, Qt::Orientation aOrientation,
+                        int aRole = Qt::DisplayRole) const;
+
+    bool removeRows(int aRow, int aCount, const QModelIndex &aParent = QModelIndex());
+
+private:
+    static bool UIVMItemNameCompareLessThan(UIVMItem* aItem1, UIVMItem* aItem2);
+    static bool UIVMItemNameCompareGreaterThan(UIVMItem* aItem1, UIVMItem* aItem2);
+
+    /* Private member vars */
+    QList<UIVMItem *> m_VMItemList;
+};
+
+class UIVMListView: public QIListView
+{
+    Q_OBJECT;
+
+public:
+    UIVMListView(QWidget *aParent = 0);
+
+    void selectItemByRow(int row);
+    void selectItemById(const QString &aID);
+    void ensureSomeRowSelected(int aRowHint);
+    UIVMItem * selectedItem() const;
+
+    void ensureCurrentVisible();
+
+signals:
+    void currentChanged();
+    void activated();
+
+protected slots:
+    void selectionChanged(const QItemSelection &aSelected, const QItemSelection &aDeselected);
+    void currentChanged(const QModelIndex &aCurrent, const QModelIndex &aPrevious);
+    void dataChanged(const QModelIndex &aTopLeft, const QModelIndex &aBottomRight);
+
+protected:
+    bool selectCurrent();
+};
+
+class UIVMItemPainter: public QIItemDelegate
+{
+public:
+    UIVMItemPainter(QObject *aParent = 0)
+      : QIItemDelegate(aParent), m_Margin(8), m_Spacing(m_Margin * 3 / 2) {}
+
+    QSize sizeHint(const QStyleOptionViewItem &aOption,
+                   const QModelIndex &aIndex) const;
+
+    void paint(QPainter *aPainter, const QStyleOptionViewItem &aOption,
+               const QModelIndex &aIndex) const;
+
+private:
+    void paintContent(QPainter *pPainter, const QStyleOptionViewItem &option, const QModelIndex &index) const;
+    void blendContent(QPainter *pPainter, const QStyleOptionViewItem &option, const QModelIndex &index) const;
+    inline QFontMetrics fontMetric(const QModelIndex &aIndex, int aRole) const { return QFontMetrics(aIndex.data(aRole).value<QFont>()); }
+    inline QIcon::Mode iconMode(QStyle::State aState) const
+    {
+        if (!(aState & QStyle::State_Enabled))
+            return QIcon::Disabled;
+        if (aState & QStyle::State_Selected)
+            return QIcon::Selected;
+        return QIcon::Normal;
+    }
+    inline QIcon::State iconState(QStyle::State aState) const { return aState & QStyle::State_Open ? QIcon::On : QIcon::Off; }
+
+    QRect rect(const QStyleOptionViewItem &aOption,
+               const QModelIndex &aIndex, int aRole) const;
+
+    void calcLayout(const QModelIndex &aIndex,
+                    QRect *aOSType, QRect *aVMName, QRect *aShot,
+                    QRect *aStateIcon, QRect *aState) const;
+
+    /* Private member vars */
+    int m_Margin;
+    int m_Spacing;
+};
+
+#endif /* __UIVMListView_h__ */
+
Index: trunk/src/VBox/Frontends/VirtualBox/src/VBoxSelectorWnd.cpp
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/src/VBoxSelectorWnd.cpp	(revision 30021)
+++ trunk/src/VBox/Frontends/VirtualBox/src/VBoxSelectorWnd.cpp	(revision 30022)
@@ -22,5 +22,5 @@
 #include "VBoxProblemReporter.h"
 #include "VBoxSelectorWnd.h"
-#include "VBoxVMListView.h"
+#include "UIVMListView.h"
 #include "VBoxToolBar.h"
 
@@ -34,4 +34,5 @@
 #include "VBoxGlobal.h"
 #include "VBoxUtils.h"
+#include "QISplitter.h"
 #include "QITabWidget.h"
 
@@ -221,5 +222,5 @@
     ~VBoxVMDescriptionPage() {}
 
-    void setMachineItem (VBoxVMItem *aItem);
+    void setMachineItem (UIVMItem *aItem);
 
     void updateState();
@@ -235,5 +236,5 @@
 private:
 
-    VBoxVMItem *mItem;
+    UIVMItem *mItem;
 
     VBoxSelectorWnd *mParent;
@@ -303,5 +304,5 @@
  * unnecessary RPC calls.
  */
-void VBoxVMDescriptionPage::setMachineItem (VBoxVMItem *aItem)
+void VBoxVMDescriptionPage::setMachineItem (UIVMItem *aItem)
 {
     mItem = aItem;
@@ -340,5 +341,5 @@
  * Called by the parent from machineStateChanged() and sessionStateChanged()
  * signal handlers. We cannot connect to these signals ourselves because we
- * use the VBoxVMListBoxItem which needs to be properly updated by the parent
+ * use the UIVMListBoxItem which needs to be properly updated by the parent
  * first.
  */
@@ -395,5 +396,7 @@
         *aSelf = this;
 
-    statusBar();
+    statusBar()->setContextMenuPolicy(Qt::CustomContextMenu);
+    connect(statusBar(), SIGNAL(customContextMenuRequested(const QPoint&)),
+            this, SLOT(showViewContextMenu(const QPoint&)));
 
 #if defined (Q_WS_MAC) && (QT_VERSION < 0x040402)
@@ -468,49 +471,53 @@
     mHelpActions.setup (this);
 
+    QISplitter *pSplitter = new QISplitter(this);
+    pSplitter->setHandleType(QISplitter::Native);
     /* Central widget @ horizontal layout */
-    setCentralWidget (new QWidget (this));
-    QHBoxLayout *centralLayout = new QHBoxLayout (centralWidget());
-
-    /* Left vertical box */
-    QVBoxLayout *leftVLayout = new QVBoxLayout();
-    /* Right vertical box */
-    QVBoxLayout *rightVLayout = new QVBoxLayout();
-    centralLayout->addLayout (leftVLayout, 1);
-    centralLayout->addLayout (rightVLayout, 2);
+    setCentralWidget(pSplitter);
 
     /* VM list toolbar */
-    mVMToolBar = new VBoxToolBar (this);
+    mVMToolBar = new VBoxToolBar(this);
+    mVMToolBar->setContextMenuPolicy(Qt::CustomContextMenu);
+#ifndef Q_WS_MAC
+    connect(mVMToolBar, SIGNAL(customContextMenuRequested(const QPoint&)),
+            this, SLOT(showViewContextMenu(const QPoint&)));
+#else /* !Q_WS_MAC */
+    /* A simple connect doesn't work on the Mac, also we want receive right
+     * click notifications on the title bar. So register our own handler. */
+    ::darwinRegisterForUnifiedToolbarContextMenuEvents(this);
+#endif /* Q_WS_MAC */
+
+    /* VM list view */
+    mVMListView = new UIVMListView();
+    mVMModel = new UIVMItemModel(mVMListView);
+    mVMListView->setModel(mVMModel);
+    mVMListView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+
+    /* Make non-possible to activate list elements by single click,
+     * this hack should disable the current possibility to do it if present */
+    if (mVMListView->style()->styleHint (QStyle::SH_ItemView_ActivateItemOnSingleClick, 0, mVMListView))
+        mVMListView->setStyleSheet ("activate-on-singleclick : 0");
+
 #if MAC_LEOPARD_STYLE
     /* Enable unified toolbars on Mac OS X. Available on Qt >= 4.3 */
     addToolBar (mVMToolBar);
     mVMToolBar->setMacToolbar();
-    /* No spacing/margin on the mac */
-    VBoxGlobal::setLayoutMargin (centralLayout, 0);
-    leftVLayout->setSpacing (0);
-    rightVLayout->setSpacing (0);
-    rightVLayout->insertSpacing (0, 10);
+    pSplitter->addWidget (mVMListView);
 #else /* MAC_LEOPARD_STYLE */
-    leftVLayout->addWidget (mVMToolBar);
-    centralLayout->setSpacing (9);
-    VBoxGlobal::setLayoutMargin (centralLayout, 5);
-    leftVLayout->setSpacing (5);
-    rightVLayout->setSpacing (5);
+    QWidget *pLeftWidget = new QWidget(this);
+    QVBoxLayout *pLeftVLayout = new QVBoxLayout(pLeftWidget);
+    pLeftVLayout->setContentsMargins(5, 5, 0, 0);
+    pLeftVLayout->addWidget(mVMToolBar);
+    pLeftVLayout->addWidget(mVMListView);
+    pSplitter->addWidget(pLeftWidget);
 #endif /* MAC_LEOPARD_STYLE */
-
-    /* VM list view */
-    mVMListView = new VBoxVMListView();
-    mVMModel = new VBoxVMModel (mVMListView);
-    mVMListView->setModel (mVMModel);
-
-    /* Make non-possible to activate list elements by single click,
-     * this hack should disable the current possibility to do it if present */
-    if (mVMListView->style()->styleHint (QStyle::SH_ItemView_ActivateItemOnSingleClick, 0, mVMListView))
-        mVMListView->setStyleSheet ("activate-on-singleclick : 0");
-
-    leftVLayout->addWidget (mVMListView);
 
     /* VM tab widget containing details and snapshots tabs */
     mVmTabWidget = new QITabWidget();
-    rightVLayout->addWidget (mVmTabWidget);
+    pSplitter->addWidget (mVmTabWidget);
+
+    /* Set the initial distribution. The right site is bigger. */
+    pSplitter->setStretchFactor(1, 3);
+    pSplitter->setStretchFactor(0, 2);
 
     /* VM details view */
@@ -550,6 +557,10 @@
     mVMToolBar->addAction (mVmDiscardAction);
 
+    /* Configure menubar */
+    menuBar()->setContextMenuPolicy(Qt::CustomContextMenu);
+    connect(menuBar(), SIGNAL(customContextMenuRequested(const QPoint&)),
+            this, SLOT(showViewContextMenu(const QPoint&)));
+
     /* add actions to menubar */
-
     mFileMenu = menuBar()->addMenu (QString::null);
     mFileMenu->addAction (mFileMediaMgrAction);
@@ -605,7 +616,7 @@
     retranslateUi();
 
+    CVirtualBox vbox = vboxGlobal().virtualBox();
     /* Restore the position of the window */
     {
-        CVirtualBox vbox = vboxGlobal().virtualBox();
         QString winPos = vbox.GetExtraData (VBoxDefs::GUI_LastWindowPosition);
 
@@ -653,8 +664,27 @@
     /* restore the position of vm selector */
     {
-        CVirtualBox vbox = vboxGlobal().virtualBox();
         QString prevVMId = vbox.GetExtraData (VBoxDefs::GUI_LastVMSelected);
 
         mVMListView->selectItemById (prevVMId);
+    }
+
+    /* Read the splitter handle position */
+    {
+        QString sliderPos = vbox.GetExtraData(VBoxDefs::GUI_SplitterSizes);
+        QStringList strSizes = sliderPos.split(",");
+        QList<int> sizes;
+        for (int i=0; i <  strSizes.size(); ++i)
+            sizes << strSizes.at(i).toInt();
+        if (!sizes.isEmpty())
+            pSplitter->setSizes(sizes);
+    }
+
+    /* Restore toolbar and statusbar visibility */
+    {
+        QString strToolbar = vbox.GetExtraData(VBoxDefs::GUI_Toolbar);
+        QString strStatusbar = vbox.GetExtraData(VBoxDefs::GUI_Statusbar);
+
+        mVMToolBar->setVisible(strToolbar.isEmpty() || strToolbar == "true");
+        statusBar()->setVisible(strStatusbar.isEmpty() || strStatusbar == "true");
     }
 
@@ -731,15 +761,9 @@
     {
         int y = mNormalGeo.y();
-#if defined (Q_WS_MAC) && !defined (QT_MAC_USE_COCOA)
-        /* The toolbar counts to the content not to the frame. Unfortunately
-         * the toolbar isn't fully initialized when this window will be moved
-         * to the last position after VBox starting. As a workaround just do
-         * remove the toolbar height part when save the last position. */
-        y -= ::darwinWindowToolBarHeight (this);
-#endif /* Q_WS_MAC && !QT_MAC_USE_COCOA */
         QString winPos = QString ("%1,%2,%3,%4")
             .arg (mNormalGeo.x()).arg (y)
             .arg (mNormalGeo.width()).arg (mNormalGeo.height());
 #ifdef Q_WS_MAC
+        ::darwinUnregisterForUnifiedToolbarContextMenuEvents(this);
         if (::darwinIsWindowMaximized(this))
 #else /* Q_WS_MAC */
@@ -751,11 +775,21 @@
     }
 
-    /* Save vm selector position */
-    {
-        VBoxVMItem *item = mVMListView->selectedItem();
+    /* Save VM selector position */
+    {
+        UIVMItem *item = mVMListView->selectedItem();
         QString curVMId = item ?
             QString (item->id()) :
             QString::null;
         vbox.SetExtraData (VBoxDefs::GUI_LastVMSelected, curVMId);
+    }
+
+    /* Save the splitter handle position */
+    {
+        QSplitter *pSplitter = static_cast<QSplitter*>(centralWidget());
+        QList<int> sizes = pSplitter->sizes();
+        QStringList strSizes;
+        for (int i=0; i < sizes.size(); ++i)
+            strSizes << QString::number(sizes.at(i));
+        vbox.SetExtraData(VBoxDefs::GUI_SplitterSizes, strSizes.join(","));
     }
 
@@ -790,5 +824,5 @@
     QString name;
 
-    VBoxVMItem *item = mVMListView->selectedItem();
+    UIVMItem *item = mVMListView->selectedItem();
     if (item)
         name = item->name();
@@ -860,5 +894,5 @@
     }
 
-    VBoxVMItem *item = aUuid.isNull() ? mVMListView->selectedItem() :
+    UIVMItem *item = aUuid.isNull() ? mVMListView->selectedItem() :
                        mVMModel->itemById (aUuid);
 
@@ -904,5 +938,5 @@
 void VBoxSelectorWnd::vmDelete (const QString &aUuid /*= QUuid_null*/)
 {
-    VBoxVMItem *item = aUuid.isNull() ? mVMListView->selectedItem() :
+    UIVMItem *item = aUuid.isNull() ? mVMListView->selectedItem() :
                        mVMModel->itemById (aUuid);
 
@@ -971,5 +1005,5 @@
 {
     QUuid uuid (aUuid);
-    VBoxVMItem *item = uuid.isNull() ? mVMListView->selectedItem() :
+    UIVMItem *item = uuid.isNull() ? mVMListView->selectedItem() :
                        mVMModel->itemById (aUuid);
 
@@ -1047,5 +1081,5 @@
 void VBoxSelectorWnd::vmDiscard (const QString &aUuid /*= QUuid_null*/)
 {
-    VBoxVMItem *item = aUuid.isNull() ? mVMListView->selectedItem() :
+    UIVMItem *item = aUuid.isNull() ? mVMListView->selectedItem() :
                        mVMModel->itemById (aUuid);
 
@@ -1082,5 +1116,5 @@
 void VBoxSelectorWnd::vmPause (bool aPause, const QString &aUuid /*= QUuid_null*/)
 {
-    VBoxVMItem *item = aUuid.isNull() ? mVMListView->selectedItem() :
+    UIVMItem *item = aUuid.isNull() ? mVMListView->selectedItem() :
                        mVMModel->itemById (aUuid);
 
@@ -1114,5 +1148,5 @@
 void VBoxSelectorWnd::vmRefresh (const QString &aUuid /*= QUuid_null*/)
 {
-    VBoxVMItem *item = aUuid.isNull() ? mVMListView->selectedItem() :
+    UIVMItem *item = aUuid.isNull() ? mVMListView->selectedItem() :
                        mVMModel->itemById (aUuid);
 
@@ -1127,5 +1161,5 @@
 void VBoxSelectorWnd::vmShowLogs (const QString &aUuid /*= QUuid_null*/)
 {
-    VBoxVMItem *item = aUuid.isNull() ? mVMListView->selectedItem() :
+    UIVMItem *item = aUuid.isNull() ? mVMListView->selectedItem() :
                        mVMModel->itemById (aUuid);
 
@@ -1142,5 +1176,5 @@
     for (CMachineVector::ConstIterator m = vec.begin();
          m != vec.end(); ++ m)
-        mVMModel->addItem (new VBoxVMItem (*m));
+        mVMModel->addItem (new UIVMItem (*m));
     mVMModel->sort();
 
@@ -1157,5 +1191,5 @@
                                                        bool aDescription)
 {
-    VBoxVMItem *item = mVMModel->itemById (aID);
+    UIVMItem *item = mVMModel->itemById (aID);
     if (item)
     {
@@ -1172,5 +1206,5 @@
     if (index.isValid())
         if (mVMListView->model()->data (index,
-            VBoxVMModel::VBoxVMItemPtrRole).value <VBoxVMItem*>())
+            UIVMItemModel::UIVMItemPtrRole).value <UIVMItem*>())
                 mVMCtxtMenu->exec (mVMListView->mapToGlobal (aPoint));
 }
@@ -1245,4 +1279,26 @@
             break;
         }
+#ifdef Q_WS_MAC
+        case QEvent::ContextMenu:
+        {
+            /* This is the unified context menu event. Lets show the context
+             * menu. */
+            QContextMenuEvent *pCE = static_cast<QContextMenuEvent*>(e);
+            showViewContextMenu(pCE->globalPos());
+            /* Accept it to interrupt the chain. */
+            pCE->accept();
+            return false;
+            break;
+        }
+        case QEvent::ToolBarChange:
+        {
+            CVirtualBox vbox = vboxGlobal().virtualBox();
+            /* We have to invert the isVisible check one time, cause this event
+             * is sent *before* the real toggle is done. Really intuitive
+             * Trolls. */
+            vbox.SetExtraData(VBoxDefs::GUI_Toolbar, !::darwinIsToolbarVisible(mVMToolBar) ? "true" : "false");
+            break;
+        }
+#endif /* Q_WS_MAC */
         default:
             break;
@@ -1434,5 +1490,5 @@
                                                 bool aRefreshDescription)
 {
-    VBoxVMItem *item = mVMListView->selectedItem();
+    UIVMItem *item = mVMListView->selectedItem();
 
     if (item && item->accessible())
@@ -1501,5 +1557,5 @@
 #endif /* QT_MAC_USE_COCOA */
             mVmStartAction->setStatusTip (
-                                          tr ("Start the selected virtual machine"));
+                tr ("Start the selected virtual machine"));
 
             mVmStartAction->setEnabled (!running);
@@ -1703,5 +1759,5 @@
         if (!m.isNull())
         {
-            mVMModel->addItem (new VBoxVMItem (m));
+            mVMModel->addItem (new UIVMItem (m));
             mVMModel->sort();
             /* Make sure the description, ... pages are properly updated.
@@ -1716,5 +1772,5 @@
     else
     {
-        VBoxVMItem *item = mVMModel->itemById (e.id);
+        UIVMItem *item = mVMModel->itemById (e.id);
         if (item)
         {
@@ -1773,5 +1829,5 @@
 }
 
-VBoxTrayIcon::VBoxTrayIcon (VBoxSelectorWnd* aParent, VBoxVMModel* aVMModel)
+VBoxTrayIcon::VBoxTrayIcon (VBoxSelectorWnd* aParent, UIVMItemModel* aVMModel)
 {
     mParent = aParent;
@@ -1876,5 +1932,5 @@
         return;
 
-    VBoxVMItem* pItem = NULL;
+    UIVMItem* pItem = NULL;
     QMenu *pMenu = NULL;
     QVariant vID;
@@ -1918,14 +1974,14 @@
            )
         {
-            mVmStartAction->setText (VBoxVMListView::tr ("S&tart"));
+            mVmStartAction->setText (UIVMListView::tr ("S&tart"));
             mVmStartAction->setStatusTip (
-                  VBoxVMListView::tr ("Start the selected virtual machine"));
+                  UIVMListView::tr ("Start the selected virtual machine"));
             mVmStartAction->setEnabled (!running);
         }
         else
         {
-            mVmStartAction->setText (VBoxVMListView::tr ("S&how"));
+            mVmStartAction->setText (UIVMListView::tr ("S&how"));
             mVmStartAction->setStatusTip (
-                  VBoxVMListView::tr ("Switch to the window of the selected virtual machine"));
+                  UIVMListView::tr ("Switch to the window of the selected virtual machine"));
             mVmStartAction->setEnabled (pItem->canSwitchTo());
         }
@@ -1943,7 +1999,7 @@
            )
         {
-            mVmPauseAction->setText (VBoxVMListView::tr ("R&esume"));
+            mVmPauseAction->setText (UIVMListView::tr ("R&esume"));
             mVmPauseAction->setStatusTip (
-                  VBoxVMListView::tr ("Resume the execution of the virtual machine"));
+                  UIVMListView::tr ("Resume the execution of the virtual machine"));
             mVmPauseAction->blockSignals (true);
             mVmPauseAction->setChecked (true);
@@ -1952,7 +2008,7 @@
         else
         {
-            mVmPauseAction->setText (VBoxVMListView::tr ("&Pause"));
+            mVmPauseAction->setText (UIVMListView::tr ("&Pause"));
             mVmPauseAction->setStatusTip (
-                  VBoxVMListView::tr ("Suspend the execution of the virtual machine"));
+                  UIVMListView::tr ("Suspend the execution of the virtual machine"));
             mVmPauseAction->blockSignals (true);
             mVmPauseAction->setChecked (false);
@@ -1986,7 +2042,7 @@
 
         /* Set the Start button text accordingly. */
-        mVmStartAction->setText (VBoxVMListView::tr ("S&tart"));
+        mVmStartAction->setText (UIVMListView::tr ("S&tart"));
         mVmStartAction->setStatusTip (
-              VBoxVMListView::tr ("Start the selected virtual machine"));
+              UIVMListView::tr ("Start the selected virtual machine"));
         mVmStartAction->setEnabled (false);
 
@@ -2005,5 +2061,5 @@
         return;
 
-    VBoxVMItem* pItem = NULL;
+    UIVMItem* pItem = NULL;
     QVariant vID;
 
@@ -2030,5 +2086,5 @@
     mTrayIconMenu->clear();
 
-    VBoxVMItem* pItem = NULL;
+    UIVMItem* pItem = NULL;
     QMenu* pCurMenu = mTrayIconMenu;
     QMenu* pSubMenu = NULL;
@@ -2080,7 +2136,7 @@
 }
 
-VBoxVMItem* VBoxTrayIcon::GetItem (QObject* aObject)
-{
-    VBoxVMItem* pItem = NULL;
+UIVMItem* VBoxTrayIcon::GetItem (QObject* aObject)
+{
+    UIVMItem* pItem = NULL;
     if (QAction *pAction = qobject_cast<QAction*>(sender()))
     {
@@ -2113,5 +2169,5 @@
 void VBoxTrayIcon::vmSettings()
 {
-    VBoxVMItem* pItem = GetItem (sender());
+    UIVMItem* pItem = GetItem (sender());
     mParent->vmSettings (NULL, NULL, pItem->id());
 }
@@ -2119,5 +2175,5 @@
 void VBoxTrayIcon::vmDelete()
 {
-    VBoxVMItem* pItem = GetItem (sender());
+    UIVMItem* pItem = GetItem (sender());
     mParent->vmDelete (pItem->id());
 }
@@ -2125,5 +2181,5 @@
 void VBoxTrayIcon::vmStart()
 {
-    VBoxVMItem* pItem = GetItem (sender());
+    UIVMItem* pItem = GetItem (sender());
     mParent->vmStart (pItem->id());
 }
@@ -2131,5 +2187,5 @@
 void VBoxTrayIcon::vmDiscard()
 {
-    VBoxVMItem* pItem = GetItem (sender());
+    UIVMItem* pItem = GetItem (sender());
     mParent->vmDiscard (pItem->id());
 }
@@ -2137,5 +2193,5 @@
 void VBoxTrayIcon::vmPause(bool aPause)
 {
-    VBoxVMItem* pItem = GetItem (sender());
+    UIVMItem* pItem = GetItem (sender());
     mParent->vmPause (aPause, pItem->id());
 }
@@ -2143,5 +2199,5 @@
 void VBoxTrayIcon::vmRefresh()
 {
-    VBoxVMItem* pItem = GetItem (sender());
+    UIVMItem* pItem = GetItem (sender());
     mParent->vmRefresh (pItem->id());
 }
@@ -2149,5 +2205,5 @@
 void VBoxTrayIcon::vmShowLogs()
 {
-    VBoxVMItem* pItem = GetItem (sender());
+    UIVMItem* pItem = GetItem (sender());
     mParent->vmShowLogs (pItem->id());
 }
@@ -2162,3 +2218,53 @@
 }
 
+void VBoxSelectorWnd::showViewContextMenu(const QPoint &pos)
+{
+    CVirtualBox vbox = vboxGlobal().virtualBox();
+    QString strToolbar = vbox.GetExtraData(VBoxDefs::GUI_Toolbar);
+    QString strStatusbar = vbox.GetExtraData(VBoxDefs::GUI_Statusbar);
+    bool fToolbar = strToolbar.isEmpty() || strToolbar == "true";
+    bool fStatusbar = strStatusbar.isEmpty() || strStatusbar == "true";
+
+    QList<QAction*> actions;
+    QAction *pShowToolBar = new QAction(tr("Show Toolbar"), 0);
+    pShowToolBar->setCheckable(true);
+    pShowToolBar->setChecked(fToolbar);
+    actions << pShowToolBar;
+    QAction *pShowStatusBar = new QAction(tr("Show Statusbar"), 0);
+    pShowStatusBar->setCheckable(true);
+    pShowStatusBar->setChecked(fStatusbar);
+    actions << pShowStatusBar;
+
+    QPoint gpos = pos;
+    QWidget *pSender = static_cast<QWidget*>(sender());
+    if (pSender)
+        gpos = pSender->mapToGlobal(pos);
+    QAction *pResult = QMenu::exec(actions, gpos);
+    if (pResult == pShowToolBar)
+    {
+        if (pResult->isChecked())
+        {
+            mVMToolBar->show();
+            vbox.SetExtraData(VBoxDefs::GUI_Toolbar, "true");
+        }
+        else
+        {
+            mVMToolBar->hide();
+            vbox.SetExtraData(VBoxDefs::GUI_Toolbar, "false");
+        }
+    }else if (pResult == pShowStatusBar)
+    {
+        if (pResult->isChecked())
+        {
+            statusBar()->show();
+            vbox.SetExtraData(VBoxDefs::GUI_Statusbar, "true");
+        }
+        else
+        {
+            statusBar()->hide();
+            vbox.SetExtraData(VBoxDefs::GUI_Statusbar, "false");
+        }
+    }
+}
+
 #include "VBoxSelectorWnd.moc"
Index: trunk/src/VBox/Frontends/VirtualBox/src/VBoxSelectorWnd.h
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/src/VBoxSelectorWnd.h	(revision 30021)
+++ trunk/src/VBox/Frontends/VirtualBox/src/VBoxSelectorWnd.h	(revision 30022)
@@ -38,9 +38,10 @@
 class VBoxVMDescriptionPage;
 class VBoxVMLogViewer;
-class VBoxVMListView;
-class VBoxVMModel;
-class VBoxVMItem;
+class UIVMListView;
+class UIVMItemModel;
+class UIVMItem;
 class VBoxTrayIcon;
 class VBoxToolBar;
+class UIOSDMenu;
 class QITabWidget;
 
@@ -108,7 +109,7 @@
     bool event (QEvent *aEvent);
     void closeEvent (QCloseEvent *aEvent);
-#if defined (Q_WS_MAC) && (QT_VERSION < 0x040402)
-    bool eventFilter (QObject *aObject, QEvent *aEvent);
-#endif /* defined (Q_WS_MAC) && (QT_VERSION < 0x040402) */
+//#if defined (Q_WS_MAC) && (QT_VERSION < 0x040402)
+//    bool eventFilter (QObject *aObject, QEvent *aEvent);
+//#endif /* defined (Q_WS_MAC) && (QT_VERSION < 0x040402) */
 
     void retranslateUi();
@@ -139,4 +140,6 @@
     void sltDownloaderUserManualEmbed();
 
+    void showViewContextMenu(const QPoint &pos);
+
 private:
 
@@ -151,4 +154,5 @@
     /* VM list context menu */
     QMenu *mVMCtxtMenu;
+//    UIOSDMenu *mVMCtxtMenu;
 
     /* Actions */
@@ -175,6 +179,6 @@
 
     /* The vm list view/model */
-    VBoxVMListView *mVMListView;
-    VBoxVMModel *mVMModel;
+    UIVMListView *mVMListView;
+    UIVMItemModel *mVMModel;
 
     /* The right information widgets */
@@ -199,5 +203,5 @@
 public:
 
-    VBoxTrayIcon (VBoxSelectorWnd* aParent, VBoxVMModel* aVMModel);
+    VBoxTrayIcon (VBoxSelectorWnd* aParent, UIVMItemModel* aVMModel);
     virtual ~VBoxTrayIcon ();
 
@@ -207,5 +211,5 @@
 protected:
 
-    VBoxVMItem* GetItem (QObject* aObject);
+    UIVMItem* GetItem (QObject* aObject);
 
 signals:
@@ -233,5 +237,5 @@
 
     /* The vm list model */
-    VBoxVMModel *mVMModel;
+    UIVMItemModel *mVMModel;
 
     VBoxSelectorWnd* mParent;
@@ -252,2 +256,3 @@
 
 #endif // __VBoxSelectorWnd_h__
+
Index: trunk/src/VBox/Frontends/VirtualBox/src/VBoxVMListView.cpp
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/src/VBoxVMListView.cpp	(revision 30021)
+++ 	(revision )
@@ -1,894 +1,0 @@
-/** @file
- *
- * VBox frontends: Qt GUI ("VirtualBox"):
- * VBoxVMItem, VBoxVMModel, VBoxVMListView, VBoxVMItemPainter class implementation
- */
-
-/*
- * Copyright (C) 2006-2008 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 */
-#include "VBoxVMListView.h"
-#include "VBoxProblemReporter.h"
-#include "VBoxSelectorWnd.h"
-
-/* Qt includes */
-#include <QPainter>
-#include <QFileInfo>
-
-#if defined (Q_WS_MAC)
-# include <ApplicationServices/ApplicationServices.h>
-#endif
-#endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
-
-
-// Helpers
-////////////////////////////////////////////////////////////////////////////////
-
-/// @todo Remove. See @c todo in #switchTo() below.
-#if 0
-
-#if defined (Q_WS_WIN32)
-
-struct EnumWindowsProcData
-{
-    ULONG pid;
-    WId wid;
-};
-
-BOOL CALLBACK EnumWindowsProc (HWND hwnd, LPARAM lParam)
-{
-    EnumWindowsProcData *d = (EnumWindowsProcData *) lParam;
-
-    DWORD pid = 0;
-    GetWindowThreadProcessId (hwnd, &pid);
-
-    if (d->pid == pid)
-    {
-        WINDOWINFO info;
-        if (!GetWindowInfo (hwnd, &info))
-            return TRUE;
-
-#if 0
-        LogFlowFunc (("pid=%d, wid=%08X\n", pid, hwnd));
-        LogFlowFunc (("  parent=%08X\n", GetParent (hwnd)));
-        LogFlowFunc (("  owner=%08X\n", GetWindow (hwnd, GW_OWNER)));
-        TCHAR buf [256];
-        LogFlowFunc (("  rcWindow=%d,%d;%d,%d\n",
-                      info.rcWindow.left, info.rcWindow.top,
-                      info.rcWindow.right, info.rcWindow.bottom));
-        LogFlowFunc (("  dwStyle=%08X\n", info.dwStyle));
-        LogFlowFunc (("  dwExStyle=%08X\n", info.dwExStyle));
-        GetClassName (hwnd, buf, 256);
-        LogFlowFunc (("  class=%ls\n", buf));
-        GetWindowText (hwnd, buf, 256);
-        LogFlowFunc (("  text=%ls\n", buf));
-#endif
-
-        /* we are interested in unowned top-level windows only */
-        if (!(info.dwStyle & (WS_CHILD | WS_POPUP)) &&
-            info.rcWindow.left < info.rcWindow.right &&
-            info.rcWindow.top < info.rcWindow.bottom &&
-            GetParent (hwnd) == NULL &&
-            GetWindow (hwnd, GW_OWNER) == NULL)
-        {
-            d->wid = hwnd;
-            /* if visible, stop the search immediately */
-            if (info.dwStyle & WS_VISIBLE)
-                return FALSE;
-            /* otherwise, give other top-level windows a chance
-             * (the last one wins) */
-        }
-    }
-
-    return TRUE;
-}
-
-#endif
-
-/**
- * Searches for a main window of the given process.
- *
- * @param aPid process ID to search for
- *
- * @return window ID on success or <tt>(WId) ~0</tt> otherwise.
- */
-static WId FindWindowIdFromPid (ULONG aPid)
-{
-#if defined (Q_WS_WIN32)
-
-    EnumWindowsProcData d = { aPid, (WId) ~0 };
-    EnumWindows (EnumWindowsProc, (LPARAM) &d);
-    LogFlowFunc (("SELECTED wid=%08X\n", d.wid));
-    return d.wid;
-
-#elif defined (Q_WS_X11)
-
-    NOREF (aPid);
-    return (WId) ~0;
-
-#elif defined (Q_WS_MAC)
-
-    /** @todo Figure out how to get access to another windows of another process...
-     * Or at least check that it's not a VBoxVRDP process. */
-    NOREF (aPid);
-    return (WId) 0;
-
-#else
-
-    return (WId) ~0;
-
-#endif
-}
-
-#endif
-
-VBoxVMItem::VBoxVMItem (const CMachine &aMachine)
-    : mMachine (aMachine)
-{
-    recache();
-}
-
-VBoxVMItem::~VBoxVMItem()
-{
-}
-
-// public members
-////////////////////////////////////////////////////////////////////////////////
-
-QString VBoxVMItem::sessionStateName() const
-{
-    return mAccessible ? vboxGlobal().toString (mState) :
-           VBoxVMListView::tr ("Inaccessible");
-}
-
-QString VBoxVMItem::toolTipText() const
-{
-    QString dateTime = (mLastStateChange.date() == QDate::currentDate()) ?
-                        mLastStateChange.time().toString (Qt::LocalDate) :
-                        mLastStateChange.toString (Qt::LocalDate);
-
-    QString toolTip;
-
-    if (mAccessible)
-    {
-        toolTip = QString ("<b>%1</b>").arg (mName);
-        if (!mSnapshotName.isNull())
-            toolTip += QString (" (%1)").arg (mSnapshotName);
-        toolTip = QString (VBoxVMListView::tr (
-            "<nobr>%1<br></nobr>"
-            "<nobr>%2 since %3</nobr><br>"
-            "<nobr>Session %4</nobr>",
-            "VM tooltip (name, last state change, session state)"))
-            .arg (toolTip)
-            .arg (vboxGlobal().toString (mState))
-            .arg (dateTime)
-            .arg (vboxGlobal().toString (mSessionState));
-    }
-    else
-    {
-        toolTip = QString (VBoxVMListView::tr (
-            "<nobr><b>%1</b><br></nobr>"
-            "<nobr>Inaccessible since %2</nobr>",
-            "Inaccessible VM tooltip (name, last state change)"))
-            .arg (mSettingsFile)
-            .arg (dateTime);
-    }
-
-    return toolTip;
-}
-
-bool VBoxVMItem::recache()
-{
-    bool needsResort = true;
-
-    mId = mMachine.GetId();
-    mSettingsFile = mMachine.GetSettingsFilePath();
-
-    mAccessible = mMachine.GetAccessible();
-    if (mAccessible)
-    {
-        QString name = mMachine.GetName();
-
-        CSnapshot snp = mMachine.GetCurrentSnapshot();
-        mSnapshotName = snp.isNull() ? QString::null : snp.GetName();
-        needsResort = name != mName;
-        mName = name;
-
-        mState = mMachine.GetState();
-        mLastStateChange.setTime_t (mMachine.GetLastStateChange() / 1000);
-        mSessionState = mMachine.GetSessionState();
-        mOSTypeId = mMachine.GetOSTypeId();
-        mSnapshotCount = mMachine.GetSnapshotCount();
-
-        if (   mState == KMachineState_PoweredOff
-            || mState == KMachineState_Saved
-            || mState == KMachineState_Teleported
-            || mState == KMachineState_Aborted
-           )
-        {
-            mPid = (ULONG) ~0;
-    /// @todo Remove. See @c todo in #switchTo() below.
-#if 0
-            mWinId = (WId) ~0;
-#endif
-        }
-        else
-        {
-            mPid = mMachine.GetSessionPid();
-    /// @todo Remove. See @c todo in #switchTo() below.
-#if 0
-            mWinId = FindWindowIdFromPid (mPid);
-#endif
-        }
-    }
-    else
-    {
-        mAccessError = mMachine.GetAccessError();
-
-        /* this should be in sync with
-         * VBoxProblemReporter::confirmMachineDeletion() */
-        QFileInfo fi (mSettingsFile);
-        QString name = fi.completeSuffix().toLower() == "xml" ?
-                       fi.completeBaseName() : fi.fileName();
-        needsResort = name != mName;
-        mName = name;
-        mState = KMachineState_Null;
-        mSessionState = KSessionState_Null;
-        mLastStateChange = QDateTime::currentDateTime();
-        mOSTypeId = QString::null;
-        mSnapshotCount = 0;
-
-        mPid = (ULONG) ~0;
-    /// @todo Remove. See @c todo in #switchTo() below.
-#if 0
-        mWinId = (WId) ~0;
-#endif
-    }
-
-    return needsResort;
-}
-
-/**
- * Returns @a true if we can activate and bring the VM console window to
- * foreground, and @a false otherwise.
- */
-bool VBoxVMItem::canSwitchTo() const
-{
-    return const_cast <CMachine &> (mMachine).CanShowConsoleWindow();
-
-    /// @todo Remove. See @c todo in #switchTo() below.
-#if 0
-    return mWinId != (WId) ~0;
-#endif
-}
-
-/**
- * Tries to switch to the main window of the VM process.
- *
- * @return true if successfully switched and false otherwise.
- */
-bool VBoxVMItem::switchTo()
-{
-#ifdef Q_WS_MAC
-    ULONG64 id = mMachine.ShowConsoleWindow();
-#else
-    WId id = (WId) mMachine.ShowConsoleWindow();
-#endif
-    AssertWrapperOk (mMachine);
-    if (!mMachine.isOk())
-        return false;
-
-    /* winId = 0 it means the console window has already done everything
-     * necessary to implement the "show window" semantics. */
-    if (id == 0)
-        return true;
-
-#if defined (Q_WS_WIN32) || defined (Q_WS_X11)
-
-    return vboxGlobal().activateWindow (id, true);
-
-#elif defined (Q_WS_MAC)
-    /*
-     * This is just for the case were the other process cannot steal
-     * the focus from us. It will send us a PSN so we can try.
-     */
-    ProcessSerialNumber psn;
-    psn.highLongOfPSN = id >> 32;
-    psn.lowLongOfPSN = (UInt32)id;
-    OSErr rc = ::SetFrontProcess (&psn);
-    if (!rc)
-        Log (("GUI: %#RX64 couldn't do SetFrontProcess on itself, the selector (we) had to do it...\n", id));
-    else
-        Log (("GUI: Failed to bring %#RX64 to front. rc=%#x\n", id, rc));
-    return !rc;
-
-#endif
-
-    return false;
-
-    /// @todo Below is the old method of switching to the console window
-    //  based on the process ID of the console process. It should go away
-    //  after the new (callback-based) method is fully tested.
-#if 0
-
-    if (!canSwitchTo())
-        return false;
-
-#if defined (Q_WS_WIN32)
-
-    HWND hwnd = mWinId;
-
-    /* if there are ownees (modal and modeless dialogs, etc), find the
-     * topmost one */
-    HWND hwndAbove = NULL;
-    do
-    {
-        hwndAbove = GetNextWindow (hwnd, GW_HWNDPREV);
-        HWND hwndOwner;
-        if (hwndAbove != NULL &&
-            ((hwndOwner = GetWindow (hwndAbove, GW_OWNER)) == hwnd ||
-             hwndOwner  == hwndAbove))
-            hwnd = hwndAbove;
-        else
-            break;
-    }
-    while (1);
-
-    /* first, check that the primary window is visible */
-    if (IsIconic (mWinId))
-        ShowWindow (mWinId, SW_RESTORE);
-    else if (!IsWindowVisible (mWinId))
-        ShowWindow (mWinId, SW_SHOW);
-
-#if 0
-    LogFlowFunc (("mWinId=%08X hwnd=%08X\n", mWinId, hwnd));
-#endif
-
-    /* then, activate the topmost in the group */
-    AllowSetForegroundWindow (mPid);
-    SetForegroundWindow (hwnd);
-
-    return true;
-
-#elif defined (Q_WS_X11)
-
-    return false;
-
-#elif defined (Q_WS_MAC)
-
-    ProcessSerialNumber psn;
-    OSStatus rc = ::GetProcessForPID (mPid, &psn);
-    if (!rc)
-    {
-        rc = ::SetFrontProcess (&psn);
-
-        if (!rc)
-        {
-            ShowHideProcess (&psn, true);
-            return true;
-        }
-    }
-    return false;
-
-#else
-
-    return false;
-
-#endif
-
-#endif
-}
-
-/* VBoxVMModel class */
-
-void VBoxVMModel::addItem (VBoxVMItem *aItem)
-{
-    Assert (aItem);
-    int row = mVMItemList.count();
-    emit layoutAboutToBeChanged();
-    beginInsertRows (QModelIndex(), row, row);
-    mVMItemList << aItem;
-    endInsertRows();
-    refreshItem (aItem);
-}
-
-void VBoxVMModel::removeItem (VBoxVMItem *aItem)
-{
-    Assert (aItem);
-    int row = mVMItemList.indexOf (aItem);
-    removeRows (row, 1);
-}
-
-bool VBoxVMModel::removeRows (int aRow, int aCount, const QModelIndex &aParent /* = QModelIndex() */)
-{
-    emit layoutAboutToBeChanged();
-    beginRemoveRows (aParent, aRow, aRow + aCount);
-    mVMItemList.erase (mVMItemList.begin() + aRow, mVMItemList.begin() + aRow + aCount);
-    endRemoveRows();
-    emit layoutChanged();
-    return true;
-}
-
-/**
- *  Refreshes the item corresponding to the given UUID.
- */
-void VBoxVMModel::refreshItem (VBoxVMItem *aItem)
-{
-    Assert (aItem);
-    if (aItem->recache())
-        sort();
-    itemChanged (aItem);
-}
-
-void VBoxVMModel::itemChanged (VBoxVMItem *aItem)
-{
-    Assert (aItem);
-    int row = mVMItemList.indexOf (aItem);
-    /* Emit an layout change signal for the case some dimensions of the item
-     * has changed also. */
-    emit layoutChanged();
-    /* Emit an data changed signal. */
-    emit dataChanged (index (row), index (row));
-}
-
-/**
- *  Clear the item model list. Please note that the items itself are also
- *  deleted.
- */
-void VBoxVMModel::clear()
-{
-    qDeleteAll (mVMItemList);
-}
-
-/**
- *  Returns the list item with the given UUID.
- */
-VBoxVMItem *VBoxVMModel::itemById (const QString &aId) const
-{
-    foreach (VBoxVMItem *item, mVMItemList)
-        if (item->id() == aId)
-            return item;
-    return NULL;
-}
-
-VBoxVMItem *VBoxVMModel::itemByRow (int aRow) const
-{
-    return mVMItemList.at (aRow);
-}
-
-QModelIndex VBoxVMModel::indexById (const QString &aId) const
-{
-    int row = rowById (aId);
-    if (row >= 0)
-        return index (row);
-    else
-        return QModelIndex();
-}
-
-int VBoxVMModel::rowById (const QString &aId) const
-{
-    for (int i=0; i < mVMItemList.count(); ++i)
-    {
-        VBoxVMItem *item = mVMItemList.at (i);
-        if (item->id() == aId)
-            return i;
-    }
-    return -1;
-}
-
-void VBoxVMModel::sort (int /* aColumn */, Qt::SortOrder aOrder /* = Qt::AscendingOrder */)
-{
-    emit layoutAboutToBeChanged();
-    switch (aOrder)
-    {
-        case Qt::AscendingOrder: qSort (mVMItemList.begin(), mVMItemList.end(), VBoxVMItemNameCompareLessThan); break;
-        case Qt::DescendingOrder: qSort (mVMItemList.begin(), mVMItemList.end(), VBoxVMItemNameCompareGreaterThan); break;
-    }
-    emit layoutChanged();
-}
-
-int VBoxVMModel::rowCount (const QModelIndex & /* aParent = QModelIndex() */) const
-{
-    return mVMItemList.count();
-}
-
-QVariant VBoxVMModel::data (const QModelIndex &aIndex, int aRole) const
-{
-    if (!aIndex.isValid())
-        return QVariant();
-
-    if (aIndex.row() >= mVMItemList.size())
-        return QVariant();
-
-    QVariant v;
-    switch (aRole)
-    {
-        case Qt::DisplayRole:
-        {
-            v = mVMItemList.at (aIndex.row())->name();
-            break;
-        }
-        case Qt::DecorationRole:
-        {
-            v = mVMItemList.at (aIndex.row())->osIcon();
-            break;
-        }
-        case Qt::ToolTipRole:
-        {
-            v = mVMItemList.at (aIndex.row())->toolTipText();
-            break;
-        }
-        case Qt::FontRole:
-        {
-            QFont f = qApp->font();
-            f.setPointSize (f.pointSize() + 1);
-            f.setWeight (QFont::Bold);
-            v = f;
-            break;
-        }
-        case Qt::AccessibleTextRole:
-        {
-            VBoxVMItem *item = mVMItemList.at (aIndex.row());
-            v = QString ("%1 (%2)\n%3")
-                         .arg (item->name())
-                         .arg (item->snapshotName())
-                         .arg (item->sessionStateName());
-            break;
-        }
-        case SnapShotDisplayRole:
-        {
-            v = mVMItemList.at (aIndex.row())->snapshotName();
-            break;
-        }
-        case SnapShotFontRole:
-        {
-            QFont f = qApp->font();
-            v = f;
-            break;
-        }
-        case SessionStateDisplayRole:
-        {
-            v = mVMItemList.at (aIndex.row())->sessionStateName();
-            break;
-        }
-        case SessionStateDecorationRole:
-        {
-            v = mVMItemList.at (aIndex.row())->sessionStateIcon();
-            break;
-        }
-        case SessionStateFontRole:
-        {
-            QFont f = qApp->font();
-            f.setPointSize (f.pointSize());
-            if (mVMItemList.at (aIndex.row())->sessionState() != KSessionState_Closed)
-                f.setItalic (true);
-            v = f;
-            break;
-        }
-        case VBoxVMItemPtrRole:
-        {
-            v = qVariantFromValue (mVMItemList.at (aIndex.row()));
-        }
-    }
-    return v;
-}
-
-QVariant VBoxVMModel::headerData (int /*aSection*/, Qt::Orientation /*aOrientation*/,
-                                  int /*aRole = Qt::DisplayRole */) const
-{
-    return QVariant();
-}
-
-bool VBoxVMModel::VBoxVMItemNameCompareLessThan (VBoxVMItem* aItem1, VBoxVMItem* aItem2)
-{
-    Assert (aItem1);
-    Assert (aItem2);
-    return aItem1->name().toLower() < aItem2->name().toLower();
-}
-
-bool VBoxVMModel::VBoxVMItemNameCompareGreaterThan (VBoxVMItem* aItem1, VBoxVMItem* aItem2)
-{
-    Assert (aItem1);
-    Assert (aItem2);
-    return aItem2->name().toLower() < aItem1->name().toLower();
-}
-
-/* VBoxVMListView class */
-
-VBoxVMListView::VBoxVMListView (QWidget *aParent /* = 0 */)
-    :QIListView (aParent)
-{
-    /* Create & set our delegation class */
-    VBoxVMItemPainter *delegate = new VBoxVMItemPainter (this);
-    setItemDelegate (delegate);
-    /* Default icon size */
-    setIconSize (QSize (32, 32));
-    /* Publish the activation of items */
-    connect (this, SIGNAL (activated (const QModelIndex &)),
-             this, SIGNAL (activated()));
-    /* Use the correct policy for the context menu */
-    setContextMenuPolicy (Qt::CustomContextMenu);
-}
-
-void VBoxVMListView::selectItemByRow (int row)
-{
-    setCurrentIndex (model()->index (row, 0));
-}
-
-void VBoxVMListView::selectItemById (const QString &aID)
-{
-    if (VBoxVMModel *m = qobject_cast <VBoxVMModel*> (model()))
-    {
-        QModelIndex i = m->indexById (aID);
-        if (i.isValid())
-            setCurrentIndex (i);
-    }
-}
-
-void VBoxVMListView::ensureSomeRowSelected (int aRowHint)
-{
-    VBoxVMItem *item = selectedItem();
-    if (!item)
-    {
-        aRowHint = qBound (0, aRowHint, model()->rowCount() - 1);
-        selectItemByRow (aRowHint);
-        item = selectedItem ();
-        if (!item)
-            selectItemByRow (0);
-    }
-}
-
-VBoxVMItem * VBoxVMListView::selectedItem() const
-{
-    QModelIndexList indexes = selectedIndexes();
-    if (indexes.isEmpty())
-        return NULL;
-    return model()->data (indexes.first(), VBoxVMModel::VBoxVMItemPtrRole).value <VBoxVMItem *>();
-}
-
-void VBoxVMListView::ensureCurrentVisible()
-{
-    scrollTo (currentIndex(), QAbstractItemView::EnsureVisible);
-}
-
-void VBoxVMListView::selectionChanged (const QItemSelection &aSelected, const QItemSelection &aDeselected)
-{
-    QListView::selectionChanged (aSelected, aDeselected);
-    selectCurrent();
-    ensureCurrentVisible();
-    emit currentChanged();
-}
-
-void VBoxVMListView::currentChanged (const QModelIndex &aCurrent, const QModelIndex &aPrevious)
-{
-    QListView::currentChanged (aCurrent, aPrevious);
-    selectCurrent();
-    ensureCurrentVisible();
-    emit currentChanged();
-}
-
-void VBoxVMListView::dataChanged (const QModelIndex &aTopLeft, const QModelIndex &aBottomRight)
-{
-    QListView::dataChanged (aTopLeft, aBottomRight);
-    selectCurrent();
-//    ensureCurrentVisible();
-    emit currentChanged();
-}
-
-bool VBoxVMListView::selectCurrent()
-{
-    QModelIndexList indexes = selectionModel()->selectedIndexes();
-    if (indexes.isEmpty() ||
-        indexes.first() != currentIndex())
-    {
-        /* Make sure that the current is always selected */
-        selectionModel()->select (currentIndex(), QItemSelectionModel::Current | QItemSelectionModel::ClearAndSelect);
-        return true;
-    }
-    return false;
-}
-
-/* VBoxVMItemPainter class */
-/*
- +----------------------------------------------+
- |       marg                                   |
- |   +----------+   m                           |
- | m |          | m a  name_string___________ m |
- | a |  OSType  | a r                         a |
- | r |  icon    | r g  +--+                   r |
- | g |          | g /  |si|  state_string     g |
- |   +----------+   2  +--+                     |
- |       marg                                   |
- +----------------------------------------------+
-
- si = state icon
-
-*/
-
-/* Little helper class for layout calculation */
-class QRectList: public QList<QRect *>
-{
-public:
-    void alignVCenterTo (QRect* aWhich)
-    {
-        QRect b;
-        foreach (QRect *rect, *this)
-            if(rect != aWhich)
-                b |= *rect;
-        if (b.width() > aWhich->width())
-            aWhich->moveCenter (QPoint (aWhich->center().x(), b.center().y()));
-        else
-        {
-            foreach (QRect *rect, *this)
-                if(rect != aWhich)
-                    rect->moveCenter (QPoint (rect->center().x(), aWhich->center().y()));
-        }
-    }
-};
-
-QSize VBoxVMItemPainter::sizeHint (const QStyleOptionViewItem &aOption,
-                                   const QModelIndex &aIndex) const
-{
-    /* Get the size of every item */
-    QRect osTypeRT = rect (aOption, aIndex, Qt::DecorationRole);
-    QRect vmNameRT = rect (aOption, aIndex, Qt::DisplayRole);
-    QRect shotRT = rect (aOption, aIndex, VBoxVMModel::SnapShotDisplayRole);
-    QRect stateIconRT = rect (aOption, aIndex, VBoxVMModel::SessionStateDecorationRole);
-    QRect stateRT = rect (aOption, aIndex, VBoxVMModel::SessionStateDisplayRole);
-    /* Calculate the position for every item */
-    calcLayout (aIndex, &osTypeRT, &vmNameRT, &shotRT, &stateIconRT, &stateRT);
-    /* Calc the bounding rect */
-    const QRect boundingRect = osTypeRT | vmNameRT | shotRT | stateIconRT | stateRT;
-    /* Return + left/top/right/bottom margin */
-    return (boundingRect.size() + QSize (2 * mMargin, 2 * mMargin));
-}
-
-void VBoxVMItemPainter::paint (QPainter *aPainter, const QStyleOptionViewItem &aOption,
-                               const QModelIndex &aIndex) const
-{
-    QStyleOptionViewItem option (aOption);
-    /* Highlight background if an item is selected in any case.
-     * (Fix for selector in the windows style.) */
-    option.showDecorationSelected = true;
-    // Name and decoration
-    const QString vmName = aIndex.data(Qt::DisplayRole).toString();
-    const QFont nameFont = aIndex.data (Qt::FontRole).value<QFont>();
-    const QPixmap osType = aIndex.data(Qt::DecorationRole).value<QIcon>().pixmap (option.decorationSize, iconMode (option.state), iconState (option.state));
-
-    const QString shot = aIndex.data(VBoxVMModel::SnapShotDisplayRole).toString();
-    const QFont shotFont = aIndex.data (VBoxVMModel::SnapShotFontRole).value<QFont>();
-
-    const QString state = aIndex.data(VBoxVMModel::SessionStateDisplayRole).toString();
-    const QFont stateFont = aIndex.data (VBoxVMModel::SessionStateFontRole).value<QFont>();
-    const QPixmap stateIcon = aIndex.data(VBoxVMModel::SessionStateDecorationRole).value<QIcon>().pixmap (QSize (16, 16), iconMode (option.state), iconState (option.state));
-
-    /* Get the sizes for all items */
-    QRect osTypeRT = rect (option, aIndex, Qt::DecorationRole);
-    QRect vmNameRT = rect (option, aIndex, Qt::DisplayRole);
-    QRect shotRT = rect (option, aIndex, VBoxVMModel::SnapShotDisplayRole);
-    QRect stateIconRT = rect (option, aIndex, VBoxVMModel::SessionStateDecorationRole);
-    QRect stateRT = rect (option, aIndex, VBoxVMModel::SessionStateDisplayRole);
-
-    /* Calculate the positions for all items */
-    calcLayout (aIndex, &osTypeRT, &vmNameRT, &shotRT, &stateIconRT, &stateRT);
-
-    /* Get the appropriate pen for the current state */
-    QPalette pal = option.palette;
-    QPen pen = pal.color (QPalette::Active, QPalette::Text);
-    if (option.state & QStyle::State_Selected &&
-        (option.state & QStyle::State_HasFocus ||
-        QApplication::style()->styleHint (QStyle::SH_ItemView_ChangeHighlightOnFocus, &option) == 0))
-        pen =  pal.color (QPalette::Active, QPalette::HighlightedText);
-    /* Start drawing */
-    drawBackground (aPainter, option, aIndex);
-    aPainter->save();
-    /* Set the current pen */
-    aPainter->setPen (pen);
-    /* Move the painter to the initial position */
-    aPainter->translate (option.rect.x(), option.rect.y());
-    /* os type icon */
-    aPainter->drawPixmap (osTypeRT, osType);
-    /* vm name */
-    aPainter->setFont (nameFont);
-    aPainter->drawText (vmNameRT, vmName);
-    /* current snapshot in braces */
-    if (!shot.isEmpty())
-    {
-        aPainter->setFont (shotFont);
-        aPainter->drawText (shotRT, QString ("(%1)").arg (shot));
-    }
-    /* state icon */
-    aPainter->drawPixmap (stateIconRT, stateIcon);
-    /* textual state */
-    aPainter->setFont (stateFont);
-    aPainter->drawText (stateRT, state);
-    /* For debugging */
-//    QRect boundingRect = osTypeRT | vmNameRT | shotRT | stateIconRT | stateRT;
-//    aPainter->drawRect (boundingRect);
-    aPainter->restore();
-    drawFocus(aPainter, option, option.rect);
-}
-
-QRect VBoxVMItemPainter::rect (const QStyleOptionViewItem &aOption,
-                               const QModelIndex &aIndex, int aRole) const
-{
-    switch (aRole)
-    {
-        case Qt::DisplayRole:
-            {
-                QString text = aIndex.data (Qt::DisplayRole).toString();
-                QFontMetrics fm (fontMetric (aIndex, Qt::FontRole));
-                return QRect (QPoint (0, 0), fm.size (0, text));
-                break;
-            }
-        case Qt::DecorationRole:
-            {
-                QIcon icon = aIndex.data (Qt::DecorationRole).value<QIcon>();
-                return QRect (QPoint (0, 0), icon.actualSize (aOption.decorationSize, iconMode (aOption.state), iconState (aOption.state)));
-                break;
-            }
-        case VBoxVMModel::SnapShotDisplayRole:
-            {
-                QString text = aIndex.data (VBoxVMModel::SnapShotDisplayRole).toString();
-                if (!text.isEmpty())
-                {
-                    QFontMetrics fm (fontMetric (aIndex, VBoxVMModel::SnapShotFontRole));
-                    return QRect (QPoint (0, 0), fm.size (0, QString ("(%1)").arg (text)));
-                }else
-                    return QRect();
-                break;
-            }
-        case VBoxVMModel::SessionStateDisplayRole:
-            {
-                QString text = aIndex.data (VBoxVMModel::SessionStateDisplayRole).toString();
-                QFontMetrics fm (fontMetric (aIndex, VBoxVMModel::SessionStateFontRole));
-                return QRect (QPoint (0, 0), fm.size (0, text));
-                break;
-            }
-        case VBoxVMModel::SessionStateDecorationRole:
-            {
-                QIcon icon = aIndex.data (VBoxVMModel::SessionStateDecorationRole).value<QIcon>();
-                return QRect (QPoint (0, 0), icon.actualSize (QSize (16, 16), iconMode (aOption.state), iconState (aOption.state)));
-                break;
-            }
-    }
-    return QRect();
-}
-
-void VBoxVMItemPainter::calcLayout (const QModelIndex &aIndex,
-                                    QRect *aOSType, QRect *aVMName, QRect *aShot,
-                                    QRect *aStateIcon, QRect *aState) const
-{
-    const int nameSpaceWidth = fontMetric (aIndex, Qt::FontRole).width (' ');
-    const int stateSpaceWidth = fontMetric (aIndex, VBoxVMModel::SessionStateFontRole).width (' ');
-    /* Really basic layout managment.
-     * First layout as usual */
-    aOSType->moveTo (mMargin, mMargin);
-    aVMName->moveTo (mMargin + aOSType->width() + mSpacing, mMargin);
-    aShot->moveTo (aVMName->right() + nameSpaceWidth, aVMName->top());
-    aStateIcon->moveTo (aVMName->left(), aVMName->bottom());
-    aState->moveTo (aStateIcon->right() + stateSpaceWidth, aStateIcon->top());
-    /* Do grouping for the automatic center routine.
-     * First the states group: */
-    QRectList statesLayout;
-    statesLayout << aStateIcon << aState;
-    /* All items in the layout: */
-    QRectList allLayout;
-    allLayout << aOSType << aVMName << aShot << statesLayout;
-    /* Now verticaly center the items based on the reference item */
-    statesLayout.alignVCenterTo (aStateIcon);
-    allLayout.alignVCenterTo (aOSType);
-}
-
Index: trunk/src/VBox/Frontends/VirtualBox/src/VBoxVMListView.h
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/src/VBoxVMListView.h	(revision 30021)
+++ 	(revision )
@@ -1,201 +1,0 @@
-/** @file
- *
- * VBox frontends: Qt GUI ("VirtualBox"):
- * VBoxVMItem, VBoxVMModel, VBoxVMListView, VBoxVMItemPainter class declarations
- */
-
-/*
- * Copyright (C) 2006-2008 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 __VBoxVMListView_h__
-#define __VBoxVMListView_h__
-
-#include "VBoxGlobal.h"
-#include "QIListView.h"
-
-/* Qt includes */
-#include <QAbstractListModel>
-#include <QDateTime>
-
-class VBoxSelectorWnd;
-
-class VBoxVMItem
-{
-public:
-
-    VBoxVMItem (const CMachine &aMachine);
-    virtual ~VBoxVMItem();
-
-    CMachine machine() const { return mMachine; }
-
-    QString name() const { return mName; }
-    QIcon osIcon() const { return mAccessible ? vboxGlobal().vmGuestOSTypeIcon (mOSTypeId) : QPixmap (":/os_other.png"); }
-    QString id() const { return mId; }
-
-    QString sessionStateName() const;
-    QIcon sessionStateIcon() const { return mAccessible ? vboxGlobal().toIcon (mState) : QPixmap (":/state_aborted_16px.png"); }
-
-    QString snapshotName() const { return mSnapshotName; }
-    ULONG snapshotCount() const { return mSnapshotCount; }
-
-    QString toolTipText() const;
-
-    bool accessible() const { return mAccessible; }
-    const CVirtualBoxErrorInfo &accessError() const { return mAccessError; }
-    KMachineState state() const { return mState; }
-    KSessionState sessionState() const { return mSessionState; }
-
-    bool recache();
-
-    bool canSwitchTo() const;
-    bool switchTo();
-
-private:
-
-    /* Private member vars */
-    CMachine mMachine;
-
-    /* Cached machine data (to minimize server requests) */
-    QString mId;
-    QString mSettingsFile;
-
-    bool mAccessible;
-    CVirtualBoxErrorInfo mAccessError;
-
-    QString mName;
-    QString mSnapshotName;
-    KMachineState mState;
-    QDateTime mLastStateChange;
-    KSessionState mSessionState;
-    QString mOSTypeId;
-    ULONG mSnapshotCount;
-
-    ULONG mPid;
-};
-
-/* Make the pointer of this class public to the QVariant framework */
-Q_DECLARE_METATYPE(VBoxVMItem *);
-
-class VBoxVMModel: public QAbstractListModel
-{
-    Q_OBJECT;
-
-public:
-    enum { SnapShotDisplayRole = Qt::UserRole,
-           SnapShotFontRole,
-           SessionStateDisplayRole,
-           SessionStateDecorationRole,
-           SessionStateFontRole,
-           VBoxVMItemPtrRole };
-
-    VBoxVMModel(QObject *aParent = 0)
-        :QAbstractListModel (aParent) {}
-
-    void addItem (VBoxVMItem *aItem);
-    void removeItem (VBoxVMItem *aItem);
-    void refreshItem (VBoxVMItem *aItem);
-
-    void itemChanged (VBoxVMItem *aItem);
-
-    void clear();
-
-    VBoxVMItem *itemById (const QString &aId) const;
-    VBoxVMItem *itemByRow (int aRow) const;
-    QModelIndex indexById (const QString &aId) const;
-
-    int rowById (const QString &aId) const;;
-
-    void sort (Qt::SortOrder aOrder = Qt::AscendingOrder) { sort (0, aOrder); }
-
-    /* The following are necessary model implementations */
-    void sort (int aColumn, Qt::SortOrder aOrder = Qt::AscendingOrder);
-
-    int rowCount (const QModelIndex &aParent = QModelIndex()) const;
-
-    QVariant data (const QModelIndex &aIndex, int aRole) const;
-    QVariant headerData (int aSection, Qt::Orientation aOrientation,
-                         int aRole = Qt::DisplayRole) const;
-
-    bool removeRows (int aRow, int aCount, const QModelIndex &aParent = QModelIndex());
-
-private:
-    static bool VBoxVMItemNameCompareLessThan (VBoxVMItem* aItem1, VBoxVMItem* aItem2);
-    static bool VBoxVMItemNameCompareGreaterThan (VBoxVMItem* aItem1, VBoxVMItem* aItem2);
-
-    /* Private member vars */
-    QList<VBoxVMItem *> mVMItemList;
-};
-
-class VBoxVMListView: public QIListView
-{
-    Q_OBJECT;
-
-public:
-    VBoxVMListView (QWidget *aParent = 0);
-
-    void selectItemByRow (int row);
-    void selectItemById (const QString &aID);
-    void ensureSomeRowSelected (int aRowHint);
-    VBoxVMItem * selectedItem() const;
-
-    void ensureCurrentVisible();
-
-signals:
-    void currentChanged();
-    void activated();
-
-protected slots:
-    void selectionChanged (const QItemSelection &aSelected, const QItemSelection &aDeselected);
-    void currentChanged (const QModelIndex &aCurrent, const QModelIndex &aPrevious);
-    void dataChanged (const QModelIndex &aTopLeft, const QModelIndex &aBottomRight);
-
-protected:
-    bool selectCurrent();
-};
-
-class VBoxVMItemPainter: public QIItemDelegate
-{
-public:
-    VBoxVMItemPainter (QObject *aParent = 0)
-      : QIItemDelegate (aParent), mMargin (8), mSpacing (mMargin * 3 / 2) {}
-
-    QSize sizeHint (const QStyleOptionViewItem &aOption,
-                    const QModelIndex &aIndex) const;
-
-    void paint (QPainter *aPainter, const QStyleOptionViewItem &aOption,
-                const QModelIndex &aIndex) const;
-
-private:
-    inline QFontMetrics fontMetric (const QModelIndex &aIndex, int aRole) const { return QFontMetrics (aIndex.data (aRole).value<QFont>()); }
-    inline QIcon::Mode iconMode (QStyle::State aState) const
-    {
-        if (!(aState & QStyle::State_Enabled))
-            return QIcon::Disabled;
-        if (aState & QStyle::State_Selected)
-            return QIcon::Selected;
-        return QIcon::Normal;
-    }
-    inline QIcon::State iconState (QStyle::State aState) const { return aState & QStyle::State_Open ? QIcon::On : QIcon::Off; }
-
-    QRect rect (const QStyleOptionViewItem &aOption,
-                const QModelIndex &aIndex, int aRole) const;
-
-    void calcLayout (const QModelIndex &aIndex,
-                     QRect *aOSType, QRect *aVMName, QRect *aShot,
-                     QRect *aStateIcon, QRect *aState) const;
-
-    /* Private member vars */
-    int mMargin;
-    int mSpacing;
-};
-
-#endif /* __VBoxVMListView_h__ */
Index: trunk/src/VBox/Frontends/VirtualBox/src/darwin/VBoxUtils-darwin-cocoa.mm
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/src/darwin/VBoxUtils-darwin-cocoa.mm	(revision 30021)
+++ trunk/src/VBox/Frontends/VirtualBox/src/darwin/VBoxUtils-darwin-cocoa.mm	(revision 30022)
@@ -175,4 +175,13 @@
 }
 
+bool darwinIsToolbarVisible(NativeWindowRef pWindow)
+{
+    CocoaAutoreleasePool pool;
+
+    NSToolbar *pToolbar = [pWindow toolbar];
+
+    return [pToolbar isVisible] == YES;
+}
+
 bool darwinIsWindowMaximized(NativeWindowRef aWindow)
 {
@@ -193,2 +202,31 @@
 }
 
+/* Cocoa event handler which checks if the user right clicked at the unified
+   toolbar or the title area. */
+bool darwinUnifiedToolbarEvents(const void *pvCocoaEvent, const void *pvCarbonEvent, void *pvUser)
+{
+    NSEvent *pEvent = (NSEvent*)pvCocoaEvent;
+    NSEventType EvtType = [pEvent type];
+    NSWindow *pWin = ::darwinToNativeWindow((QWidget*)pvUser);
+    /* First check for the right event type and that we are processing events
+       from the window which was registered by the user. */
+    if (   EvtType == NSRightMouseDown
+        && pWin == [pEvent window])
+    {
+        /* Get the mouse position of the event (screen coordinates) */
+        NSPoint point = [NSEvent mouseLocation];
+        /* Get the frame rectangle of the window (screen coordinates) */
+        NSRect winFrame = [pWin frame];
+        /* Calculate the height of the title and the toolbar */
+        int i = NSHeight(winFrame) - NSHeight([[pWin contentView] frame]);
+        /* Based on that height create a rectangle of the unified toolbar + title */
+        winFrame.origin.y += winFrame.size.height - i;
+        winFrame.size.height = i;
+        /* Check if the mouse press event was on the unified toolbar or title */
+        if (NSMouseInRect(point, winFrame, NO))
+            /* Create a Qt context menu event, with flipped screen coordinates */
+            ::darwinCreateContextMenuEvent(pvUser, point.x, NSHeight([[pWin screen] frame]) - point.y);
+    }
+    return false;
+}
+
Index: trunk/src/VBox/Frontends/VirtualBox/src/darwin/VBoxUtils-darwin.cpp
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/src/darwin/VBoxUtils-darwin.cpp	(revision 30021)
+++ trunk/src/VBox/Frontends/VirtualBox/src/darwin/VBoxUtils-darwin.cpp	(revision 30022)
@@ -17,7 +17,9 @@
 
 #include "VBoxUtils-darwin.h"
+#include "VBoxCocoaApplication.h"
 
 #include <iprt/mem.h>
 
+#include <QMainWindow>
 #include <QApplication>
 #include <QWidget>
@@ -25,4 +27,5 @@
 #include <QPainter>
 #include <QPixmap>
+#include <QContextMenuEvent>
 
 #include <Carbon/Carbon.h>
@@ -156,4 +159,14 @@
 #endif /* QT_MAC_USE_COCOA */
 }
+
+bool darwinIsToolbarVisible(QToolBar *pToolBar)
+{
+    bool fResult = false;
+    QWidget *pParent = pToolBar->parentWidget();
+    if (pParent)
+        fResult = ::darwinIsToolbarVisible(::darwinToNativeWindow(pParent));
+    return fResult;
+}
+
 
 bool darwinSetFrontMostProcess()
@@ -287,4 +300,22 @@
     Assert (!qpm.isNull());
     return ::darwinToCGImageRef (&qpm);
+}
+
+void darwinRegisterForUnifiedToolbarContextMenuEvents(QMainWindow *pWindow)
+{
+    ::VBoxCocoaApplication_setCallback(UINT32_MAX, ::darwinUnifiedToolbarEvents, pWindow);
+}
+
+void darwinUnregisterForUnifiedToolbarContextMenuEvents(QMainWindow *pWindow)
+{
+    ::VBoxCocoaApplication_unsetCallback(UINT32_MAX, ::darwinUnifiedToolbarEvents, pWindow);
+}
+
+void darwinCreateContextMenuEvent(void *pvUser, int x, int y)
+{
+    QWidget *pWin = static_cast<QWidget*>(pvUser);
+    QPoint global(x, y);
+    QPoint local = pWin->mapFromGlobal(global);
+    qApp->postEvent(pWin, new QContextMenuEvent(QContextMenuEvent::Mouse, local, global));
 }
 
Index: trunk/src/VBox/Frontends/VirtualBox/src/darwin/VBoxUtils-darwin.h
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/src/darwin/VBoxUtils-darwin.h	(revision 30021)
+++ trunk/src/VBox/Frontends/VirtualBox/src/darwin/VBoxUtils-darwin.h	(revision 30022)
@@ -39,5 +39,5 @@
 # include <ApplicationServices/ApplicationServices.h>
 
-class QWidget;
+class QMainWindow;
 class QToolBar;
 class QPixmap;
@@ -55,4 +55,6 @@
 #include <QRect>
 
+class QWidget;
+
 RT_C_DECLS_BEGIN
 
@@ -85,4 +87,5 @@
 void darwinWindowInvalidateShadowImpl(NativeWindowRef aWindow);
 int  darwinWindowToolBarHeight(NativeWindowRef aWindow);
+bool darwinIsToolbarVisible(NativeWindowRef pWindow);
 bool darwinIsWindowMaximized(NativeWindowRef aWindow);
 
@@ -90,4 +93,7 @@
 bool darwinSetFrontMostProcess();
 uint64_t darwinGetCurrentProcessId();
+
+bool darwinUnifiedToolbarEvents(const void *pvCocoaEvent, const void *pvCarbonEvent, void *pvUser);
+void darwinCreateContextMenuEvent(void *pvWin, int x, int y);
 
 RT_C_DECLS_END
@@ -104,5 +110,4 @@
 
 
-#ifndef __OBJC__
 /********************************************************************************
  *
@@ -146,4 +151,5 @@
 NativeViewRef darwinToNativeView(NativeWindowRef aWindow);
 
+#ifndef __OBJC__
 /********************************************************************************
  *
@@ -167,8 +173,11 @@
 void darwinWindowInvalidateShadow(QWidget *aWidget);
 int  darwinWindowToolBarHeight(QWidget *aWidget);
+bool darwinIsToolbarVisible(QToolBar *pToolBar);
 bool darwinIsWindowMaximized(QWidget *aWidget);
 QString darwinSystemLanguage(void);
 QPixmap darwinCreateDragPixmap(const QPixmap& aPixmap, const QString &aText);
 
+void darwinRegisterForUnifiedToolbarContextMenuEvents(QMainWindow *pWindow);
+void darwinUnregisterForUnifiedToolbarContextMenuEvents(QMainWindow *pWindow);
 
 /********************************************************************************
Index: trunk/src/VBox/Frontends/VirtualBox/src/extensions/QIListView.cpp
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/src/extensions/QIListView.cpp	(revision 30021)
+++ trunk/src/VBox/Frontends/VirtualBox/src/extensions/QIListView.cpp	(revision 30022)
@@ -29,5 +29,5 @@
 
 
-/* VBoxVMListView class */
+/* QIListView class */
 
 QIListView::QIListView (QWidget *aParent /* = 0 */)
@@ -64,5 +64,5 @@
 }
 
-/* VBoxVMItemPainter class */
+/* QIItemDelegate class */
 
 void QIItemDelegate::drawBackground (QPainter *aPainter, const QStyleOptionViewItem &aOption,
Index: trunk/src/VBox/Frontends/VirtualBox/src/extensions/QISplitter.cpp
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/src/extensions/QISplitter.cpp	(revision 30021)
+++ trunk/src/VBox/Frontends/VirtualBox/src/extensions/QISplitter.cpp	(revision 30022)
@@ -7,5 +7,5 @@
 
 /*
- * Copyright (C) 2009 Oracle Corporation
+ * Copyright (C) 2009-2010 Oracle Corporation
  *
  * This file is part of VirtualBox Open Source Edition (OSE), as
@@ -27,14 +27,106 @@
 #include "QISplitter.h"
 
-QISplitter::QISplitter (QWidget *aParent)
-    : QSplitter (aParent)
-    , mPolished (false)
+/* A simple shaded line. */
+class QIShadeSplitterHandle: public QSplitterHandle
+{
+    Q_OBJECT;
+
+public:
+
+    QIShadeSplitterHandle(Qt::Orientation aOrientation, QISplitter *aParent)
+      :QSplitterHandle(aOrientation, aParent)
+    {}
+
+protected:
+
+    void paintEvent(QPaintEvent *aEvent)
+    {
+        QPainter painter(this);
+        QLinearGradient gradient;
+        if (orientation() == Qt::Horizontal)
+        {
+            gradient.setStart(rect().left(), rect().height() / 2);
+            gradient.setFinalStop(rect().right(), rect().height() / 2);
+        }
+        else
+        {
+            gradient.setStart(rect().width() / 2, rect().top());
+            gradient.setFinalStop(rect().width() / 2, rect().bottom());
+        }
+        painter.fillRect(aEvent->rect(), QBrush (gradient));
+    }
+};
+
+#ifdef RT_OS_DARWIN
+/* The Mac OS X version. */
+class QIDarwinSplitterHandle: public QSplitterHandle
+{
+    Q_OBJECT;
+
+public:
+
+    QIDarwinSplitterHandle(Qt::Orientation aOrientation, QISplitter *aParent)
+      :QSplitterHandle(aOrientation, aParent)
+    {}
+
+    QSize sizeHint() const
+    {
+        QSize parent = QSplitterHandle::sizeHint();
+        if (orientation() == Qt::Vertical)
+            return parent + QSize(0, 3);
+        else
+            return QSize(1, parent.height());
+    }
+
+protected:
+
+    void paintEvent(QPaintEvent * /* aEvent */)
+    {
+        QPainter painter(this);
+
+        QColor topColor(145, 145, 145);
+        QColor bottomColor(142, 142, 142);
+        QColor gradientStart(252, 252, 252);
+        QColor gradientStop(223, 223, 223);
+
+        if (orientation() == Qt::Vertical)
+        {
+            painter.setPen(topColor);
+            painter.drawLine(0, 0, width(), 0);
+            painter.setPen(bottomColor);
+            painter.drawLine(0, height() - 1, width(), height() - 1);
+
+            QLinearGradient linearGrad(QPointF(0, 0), QPointF(0, height() -3));
+            linearGrad.setColorAt(0, gradientStart);
+            linearGrad.setColorAt(1, gradientStop);
+            painter.fillRect(QRect(QPoint(0,1), size() - QSize(0, 2)), QBrush(linearGrad));
+        }else
+        {
+            painter.setPen(topColor);
+            painter.drawLine(0, 0, 0, height());
+        }
+    }
+};
+#endif /* RT_OS_DARWIN */
+
+QISplitter::QISplitter(QWidget *aParent /* = 0 */)
+    : QSplitter(aParent)
+    , mPolished(false)
+    , m_type(Shade)
 {
     qApp->installEventFilter (this);
 }
 
-bool QISplitter::eventFilter (QObject *aWatched, QEvent *aEvent)
+QISplitter::QISplitter(Qt::Orientation orientation /* = Qt::Horizontal */, QWidget *pParent /* = 0 */)
+    : QSplitter(orientation, pParent)
+    , mPolished(false)
+    , m_type(Shade)
 {
-    if (aWatched == handle (1))
+    qApp->installEventFilter (this);
+}
+
+bool QISplitter::eventFilter(QObject *aWatched, QEvent *aEvent)
+{
+    if (aWatched == handle(1))
     {
         switch (aEvent->type())
@@ -48,8 +140,8 @@
     }
 
-    return QSplitter::eventFilter (aWatched, aEvent);
+    return QSplitter::eventFilter(aWatched, aEvent);
 }
 
-void QISplitter::showEvent (QShowEvent *aEvent)
+void QISplitter::showEvent(QShowEvent *aEvent)
 {
     if (!mPolished)
@@ -59,32 +151,20 @@
     }
 
-    return QSplitter::showEvent (aEvent);
+    return QSplitter::showEvent(aEvent);
 }
 
 QSplitterHandle* QISplitter::createHandle()
 {
-    return new QISplitterHandle (orientation(), this);
+    if (m_type == Native)
+    {
+#ifdef RT_OS_DARWIN
+        return new QIDarwinSplitterHandle(orientation(), this);
+#else /* RT_OS_DARWIN */
+        return new QSplitterHandle(orientation(), this);
+#endif /* RT_OS_DARWIN */
+    }else
+        return new QIShadeSplitterHandle(orientation(), this);
 }
 
-QISplitterHandle::QISplitterHandle (Qt::Orientation aOrientation, QISplitter *aParent)
-    : QSplitterHandle (aOrientation, aParent)
-{
-}
+#include "QISplitter.moc"
 
-void QISplitterHandle::paintEvent (QPaintEvent *aEvent)
-{
-    QPainter painter (this);
-    QLinearGradient gradient;
-    if (orientation() == Qt::Horizontal)
-    {
-        gradient.setStart (rect().left(), rect().height() / 2);
-        gradient.setFinalStop (rect().right(), rect().height() / 2);
-    }
-    else
-    {
-        gradient.setStart (rect().width() / 2, rect().top());
-        gradient.setFinalStop (rect().width() / 2, rect().bottom());
-    }
-    painter.fillRect (aEvent->rect(), QBrush (gradient));
-}
-
Index: trunk/src/VBox/Frontends/VirtualBox/src/extensions/QISplitter.h
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/src/extensions/QISplitter.h	(revision 30021)
+++ trunk/src/VBox/Frontends/VirtualBox/src/extensions/QISplitter.h	(revision 30022)
@@ -6,5 +6,5 @@
 
 /*
- * Copyright (C) 2009 Oracle Corporation
+ * Copyright (C) 2009-2010 Oracle Corporation
  *
  * This file is part of VirtualBox Open Source Edition (OSE), as
@@ -23,7 +23,4 @@
 #include <QSplitter>
 
-/* Global forwardes */
-class SplitterHandle;
-
 class QISplitter : public QSplitter
 {
@@ -32,10 +29,15 @@
 public:
 
-    QISplitter (QWidget *aParent);
+    enum Type { Native, Shade };
 
+    QISplitter(QWidget *aParent = 0);
+    QISplitter(Qt::Orientation orientation = Qt::Horizontal, QWidget *pParent = 0);
+
+    void setHandleType(Type type) { m_type = type; }
+    Type handleType() const { return m_type; }
 private:
 
-    bool eventFilter (QObject *aWatched, QEvent *aEvent);
-    void showEvent (QShowEvent *aEvent);
+    bool eventFilter(QObject *aWatched, QEvent *aEvent);
+    void showEvent(QShowEvent *aEvent);
 
     QSplitterHandle* createHandle();
@@ -44,17 +46,5 @@
 
     bool mPolished;
-};
-
-class QISplitterHandle : public QSplitterHandle
-{
-    Q_OBJECT;
-
-public:
-
-    QISplitterHandle (Qt::Orientation aOrientation, QISplitter *aParent);
-
-private:
-
-    void paintEvent (QPaintEvent *aEvent);
+    Type m_type;
 };
 
Index: trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxProblemReporter.cpp
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxProblemReporter.cpp	(revision 30021)
+++ trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxProblemReporter.cpp	(revision 30022)
@@ -1069,5 +1069,5 @@
     else
     {
-        /* this should be in sync with VBoxVMListBoxItem::recache() */
+        /* this should be in sync with UIVMListBoxItem::recache() */
         QFileInfo fi (machine.GetSettingsFilePath());
         name = fi.suffix().toLower() == "xml" ?
