Index: /trunk/src/VBox/Frontends/VirtualBox4/Makefile.kmk
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox4/Makefile.kmk	(revision 9213)
+++ /trunk/src/VBox/Frontends/VirtualBox4/Makefile.kmk	(revision 9214)
@@ -291,4 +291,7 @@
 VirtualBox_QT_UISRCS4 += ui/VBoxVMLogViewer.ui
 
+VirtualBox_QT_UISRCS3 := $(filter-out ui/VBoxDiskImageManagerDlg.ui,$(VirtualBox_QT_UISRCS3))
+VirtualBox_QT_UISRCS4 += ui/VBoxDiskImageManagerDlg.ui
+
 VirtualBox_QT_UISRCS3 := $(filter-out ui/VBoxVMSettingsGeneral.ui,$(VirtualBox_QT_UISRCS3))
 VirtualBox_QT_UISRCS4 += ui/VBoxVMSettingsGeneral.ui
@@ -434,4 +437,5 @@
 	include/QIAbstractDialog.h \
 	include/QIListView.h \
+	include/QITreeWidget.h \
 	include/VBoxGlobalSettings.h \
 	include/VBoxUtils.h \
@@ -457,4 +461,5 @@
 	include/VBoxSnapshotsWgt.h \
 	include/VBoxVMLogViewer.h \
+	include/VBoxDiskImageManagerDlg.h \
 	include/VBoxVMSettingsUtils.h \
 	include/VBoxVMSettingsGeneral.h \
@@ -514,4 +519,5 @@
 	src/QIDialogButtonBox.cpp \
 	src/QIListView.cpp \
+	src/QITreeWidget.cpp \
 	src/QILineEdit.cpp \
 	src/VBoxDefs.cpp \
@@ -540,4 +546,5 @@
 	src/VBoxSnapshotsWgt.cpp \
 	src/VBoxVMLogViewer.cpp \
+	src/VBoxDiskImageManagerDlg.cpp \
 	src/VBoxVMSettingsGeneral.cpp \
 	src/VBoxVMSettingsCD.cpp \
Index: /trunk/src/VBox/Frontends/VirtualBox4/include/QITreeWidget.h
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox4/include/QITreeWidget.h	(revision 9214)
+++ /trunk/src/VBox/Frontends/VirtualBox4/include/QITreeWidget.h	(revision 9214)
@@ -0,0 +1,53 @@
+/** @file
+ *
+ * VBox frontends: Qt GUI ("VirtualBox"):
+ * VirtualBox Qt extensions: QITreeWidget class implementation
+ */
+
+/*
+ * Copyright (C) 2008 Sun Microsystems, Inc.
+ *
+ * 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.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
+ * Clara, CA 95054 USA or visit http://www.sun.com if you need
+ * additional information or have any questions.
+ */
+
+#ifndef __QITreeWidget_h__
+#define __QITreeWidget_h__
+
+/* Qt includes */
+#include <QTreeWidget>
+
+class QITreeWidget: public QTreeWidget
+{
+    Q_OBJECT;
+
+public:
+
+    QITreeWidget (QWidget *aParent = 0);
+
+    void setSupportedDropActions (Qt::DropActions aAction);
+
+signals:
+
+    void itemRightClicked (const QPoint &aPos, QTreeWidgetItem *aItem, int aColumn);
+
+protected:
+
+    void mousePressEvent (QMouseEvent *aEvent);
+    virtual Qt::DropActions supportedDropActions () const;
+
+    /* Protected member vars */
+    Qt::DropActions mSupportedDropActions;
+};
+
+#endif /* __QITreeWidget_h__ */
+
Index: /trunk/src/VBox/Frontends/VirtualBox4/include/VBoxDefs.h
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox4/include/VBoxDefs.h	(revision 9213)
+++ /trunk/src/VBox/Frontends/VirtualBox4/include/VBoxDefs.h	(revision 9214)
@@ -151,4 +151,5 @@
 #endif
         ChangeGUILanguageEventType,
+        AddVDMUrlsEventType
     };
 
Index: /trunk/src/VBox/Frontends/VirtualBox4/include/VBoxDiskImageManagerDlg.h
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox4/include/VBoxDiskImageManagerDlg.h	(revision 9214)
+++ /trunk/src/VBox/Frontends/VirtualBox4/include/VBoxDiskImageManagerDlg.h	(revision 9214)
@@ -0,0 +1,201 @@
+/** @file
+ *
+ * VBox frontends: Qt4 GUI ("VirtualBox"):
+ * VBoxDiskImageManagerDlg class declaration
+ */
+
+/*
+ * Copyright (C) 2006-2008 Sun Microsystems, Inc.
+ *
+ * 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.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
+ * Clara, CA 95054 USA or visit http://www.sun.com if you need
+ * additional information or have any questions.
+ */
+
+#ifndef __VBoxDiskImageManagerDlg_h__
+#define __VBoxDiskImageManagerDlg_h__
+
+#include "VBoxDiskImageManagerDlg.gen.h"
+#include "QIWithRetranslateUI.h"
+#include "COMDefs.h"
+#include "VBoxDefs.h"
+#include "VBoxMediaComboBox.h"
+
+/* Qt includes */
+#include <QPointer>
+
+class DiskImageItem;
+class VBoxToolBar;
+class InfoPaneLabel;
+
+class VBoxDiskImageManagerDlg : public QIWithRetranslateUI2<QMainWindow>,
+                                public Ui::VBoxDiskImageManagerDlg
+{
+    Q_OBJECT;
+
+    enum TabIndex { HDTab = 0,
+                    CDTab,
+                    FDTab };
+
+public:
+
+    enum ResultCode { Rejected, 
+                      Accepted };
+
+    VBoxDiskImageManagerDlg (QWidget *aParent = NULL, Qt::WindowFlags aFlags = Qt::Dialog);
+
+    void setup (int aType, bool aDoSelect, const QUuid *aTargetVMId = NULL, bool aRefresh = true, CMachine aMachine = NULL, const QUuid & aHdId = QUuid(), const QUuid & aCdId = QUuid(), const QUuid & aFdId = QUuid());
+
+    static void showModeless (bool aRefresh = true);
+    int exec();
+    int result() const;
+
+    QUuid selectedUuid() const;
+    QString selectedPath() const;
+
+    static QString composeHdToolTip (CHardDisk &aHd, VBoxMedia::Status aStatus, DiskImageItem *aItem = NULL);
+    static QString composeCdToolTip (CDVDImage &aCd, VBoxMedia::Status aStatus, DiskImageItem *aItem = NULL);
+    static QString composeFdToolTip (CFloppyImage &aFd, VBoxMedia::Status aStatus, DiskImageItem *aItem = NULL);
+
+public slots:
+
+    void refreshAll();
+    virtual void setVisible (bool aVisible);
+
+protected:
+
+    void retranslateUi();
+    virtual void closeEvent (QCloseEvent *aEvent);
+    virtual void keyPressEvent (QKeyEvent *aEvent);
+    virtual bool eventFilter (QObject *aObject, QEvent *aEvent);
+    /* @todo: Currently not used (Ported from Qt3): */
+    virtual void machineStateChanged (const VBoxMachineStateChangeEvent &aEvent);
+
+private slots:
+
+    void mediaAdded (const VBoxMedia &aMedia);
+    void mediaUpdated (const VBoxMedia &aMedia);
+    void mediaRemoved (VBoxDefs::DiskType aType, const QUuid &aId);
+
+    void mediaEnumStarted();
+    void mediaEnumerated (const VBoxMedia &aMedia, int aIndex);
+    void mediaEnumFinished (const VBoxMediaList &aList);
+
+    void newImage();
+    void addImage();
+    void removeImage();
+    void releaseImage();
+
+    void releaseDisk (const QUuid &aMachineId, const QUuid &aItemId, VBoxDefs::DiskType aDiskType);
+
+    void processCurrentChanged (int index = -1);
+    void processCurrentChanged (QTreeWidgetItem *aItem, QTreeWidgetItem *aPrevItem = NULL);
+    void processDoubleClick (QTreeWidgetItem *aItem, int aColumn);
+    void processRightClick (const QPoint &aPos, QTreeWidgetItem *aItem, int aColumn);
+
+    void accept();
+    void reject();
+    void done (int aRescode);
+
+    void setResult (int aRescode);
+
+private:
+
+    QTreeWidget* treeWidget (VBoxDefs::DiskType aType) const;
+    VBoxDefs::DiskType currentTreeWidgetType() const;
+    QTreeWidget* currentTreeWidget() const;
+
+    QTreeWidgetItem *selectedItem (const QTreeWidget *aTree) const;
+    DiskImageItem *toDiskImageItem (QTreeWidgetItem *aItem) const;
+
+    void setCurrentItem (QTreeWidget *aTree, QTreeWidgetItem *aItem);
+
+    void addImageToList (const QString &aSource, VBoxDefs::DiskType aDiskType);
+    DiskImageItem* createImageNode (QTreeWidget *aTree, DiskImageItem *aRoot, const VBoxMedia &aMedia) const;
+
+    DiskImageItem* createHdItem (QTreeWidget *aTree, const VBoxMedia &aMedia) const;
+    DiskImageItem* createCdItem (QTreeWidget *aTree, const VBoxMedia &aMedia) const;
+    DiskImageItem* createFdItem (QTreeWidget *aTree, const VBoxMedia &aMedia) const;
+
+    void updateHdItem (DiskImageItem *aItem, const VBoxMedia &aMedia) const;
+    void updateCdItem (DiskImageItem *aItem, const VBoxMedia &aMedia) const;
+    void updateFdItem (DiskImageItem *aItem, const VBoxMedia &aMedia) const;
+
+    DiskImageItem* searchItem (QTreeWidget *aTree, const QUuid &aId) const;
+    DiskImageItem* searchItem (QTreeWidget *aTree, VBoxMedia::Status aStatus) const;
+
+    bool checkImage (DiskImageItem *aItem);
+
+    bool checkDndUrls (const QList<QUrl> &aUrls) const;
+    void addDndUrls (const QList<QUrl> &aUrls);
+
+    void clearInfoPanes();
+    void prepareToRefresh (int aTotal = 0);
+    void createInfoString (InfoPaneLabel *&aInfo, QWidget* aRoot, int aRow, int aCol, int aRowSpan = 1, int aColSpan = 1) const;
+
+    void makeWarningMark (DiskImageItem *aItem, VBoxMedia::Status aStatus, VBoxDefs::DiskType aType) const;
+    
+    static QString DVDImageUsage (const QUuid &aId, QString &aSnapshotUsage);
+    static QString FloppyImageUsage (const QUuid &aId, QString &aSnapshotUsage);
+    static void DVDImageSnapshotUsage (const QUuid &aId, const CSnapshot &aSnapshot, QString &aUsage);
+    static void FloppyImageSnapshotUsage (const QUuid &aId, const CSnapshot &aSnapshot, QString &aUsage);
+
+    /* Private member vars */
+    /* Window status */
+    bool mDoSelect;
+    int mRescode;
+    static VBoxDiskImageManagerDlg *mModelessDialog;
+    QPointer<QEventLoop> mEventLoop;
+
+    /* Type if we are in the select modus */
+    int mType;
+
+    /* Icon definitions */
+    QIcon mIconInaccessible;
+    QIcon mIconErroneous;
+    QIcon mIconHD;
+    QIcon mIconCD;
+    QIcon mIconFD;
+
+    /* Menu & Toolbar */
+    QMenu       *mActionsContextMenu;
+    QMenu       *mActionsMenu;
+    VBoxToolBar *mActionsToolBar;
+    QAction     *mNewAction;
+    QAction     *mAddAction;
+    QAction     *mEditAction;
+    QAction     *mRemoveAction;
+    QAction     *mReleaseAction;
+    QAction     *mRefreshAction;
+
+    /* The grid entries in the various information panels */
+    InfoPaneLabel *mHdsPane1;
+    InfoPaneLabel *mHdsPane2;
+    InfoPaneLabel *mHdsPane3;
+    InfoPaneLabel *mHdsPane4;
+    InfoPaneLabel *mHdsPane5;
+    InfoPaneLabel *mHdsPane6;
+    InfoPaneLabel *mHdsPane7;
+    InfoPaneLabel *mCdsPane1;
+    InfoPaneLabel *mCdsPane2;
+    InfoPaneLabel *mFdsPane1;
+    InfoPaneLabel *mFdsPane2;
+
+    /* Machine */
+    CMachine mMachine;
+    QUuid mTargetVMId;
+    QUuid mHdSelectedId;
+    QUuid mCdSelectedId;
+    QUuid mFdSelectedId;
+};
+
+#endif /* __VBoxDiskImageManagerDlg_h__ */
+
Index: /trunk/src/VBox/Frontends/VirtualBox4/src/QITreeWidget.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox4/src/QITreeWidget.cpp	(revision 9214)
+++ /trunk/src/VBox/Frontends/VirtualBox4/src/QITreeWidget.cpp	(revision 9214)
@@ -0,0 +1,52 @@
+/** @file
+ *
+ * VBox frontends: Qt GUI ("VirtualBox"):
+ * VirtualBox Qt extensions: QITreeWidget class implementation
+ */
+
+/*
+ * Copyright (C) 2008 Sun Microsystems, Inc.
+ *
+ * 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.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
+ * Clara, CA 95054 USA or visit http://www.sun.com if you need
+ * additional information or have any questions.
+ */
+
+#include "QITreeWidget.h"
+
+/* Qt includes */
+#include <QMouseEvent>
+
+QITreeWidget::QITreeWidget (QWidget *aParent)
+    : QTreeWidget (aParent) 
+{
+}
+
+void QITreeWidget::setSupportedDropActions (Qt::DropActions aAction)
+{
+    mSupportedDropActions = aAction;
+}
+
+void QITreeWidget::mousePressEvent (QMouseEvent *aEvent)
+{
+    if (aEvent->button() == Qt::RightButton)
+    {
+        emit itemRightClicked (aEvent->globalPos(), itemAt (aEvent->pos()), columnAt (aEvent->pos().x()));
+        aEvent->accept();
+    }else
+        QTreeWidget::mousePressEvent (aEvent);
+}
+
+Qt::DropActions QITreeWidget::supportedDropActions () const
+{
+    return mSupportedDropActions;
+}
+
Index: /trunk/src/VBox/Frontends/VirtualBox4/src/VBoxConsoleWnd.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox4/src/VBoxConsoleWnd.cpp	(revision 9213)
+++ /trunk/src/VBox/Frontends/VirtualBox4/src/VBoxConsoleWnd.cpp	(revision 9214)
@@ -31,4 +31,5 @@
 #include "VBoxDownloaderWgt.h"
 #include "VBoxGlobal.h"
+#include "VBoxProblemReporter.h"
 
 #include "QIStateIndicator.h"
@@ -2528,5 +2529,5 @@
     if (!console) return;
 
-    VBoxDiskImageManagerDlg dlg (this, "VBoxDiskImageManagerDlg", Qt::WType_Dialog | Qt::WShowModal);
+    VBoxDiskImageManagerDlg dlg (this);
     QUuid id = csession.GetMachine().GetId();
     dlg.setup (VBoxDefs::FD, true, &id);
@@ -2535,5 +2536,5 @@
     {
         CFloppyDrive drv = csession.GetMachine().GetFloppyDrive();
-        drv.MountImage (dlg.getSelectedUuid());
+        drv.MountImage (dlg.selectedUuid());
         AssertWrapperOk (drv);
         if (drv.isOk())
@@ -2572,5 +2573,5 @@
     if (!console) return;
 
-    VBoxDiskImageManagerDlg dlg (this, "VBoxDiskImageManagerDlg", Qt::WType_Dialog | Qt::WShowModal);
+    VBoxDiskImageManagerDlg dlg (this);
     QUuid id = csession.GetMachine().GetId();
     dlg.setup (VBoxDefs::CD, true, &id);
@@ -2579,5 +2580,5 @@
     {
         CDVDDrive drv = csession.GetMachine().GetDVDDrive();
-        drv.MountImage (dlg.getSelectedUuid());
+        drv.MountImage (dlg.selectedUuid());
         AssertWrapperOk (drv);
         if (drv.isOk())
Index: /trunk/src/VBox/Frontends/VirtualBox4/src/VBoxDiskImageManagerDlg.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox4/src/VBoxDiskImageManagerDlg.cpp	(revision 9214)
+++ /trunk/src/VBox/Frontends/VirtualBox4/src/VBoxDiskImageManagerDlg.cpp	(revision 9214)
@@ -0,0 +1,2215 @@
+/** @file
+ *
+ * VBox frontends: Qt4 GUI ("VirtualBox"):
+ * VBoxDiskImageManagerDlg class implementation
+ */
+
+/*
+ * Copyright (C) 2006-2008 Sun Microsystems, Inc.
+ *
+ * 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.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
+ * Clara, CA 95054 USA or visit http://www.sun.com if you need
+ * additional information or have any questions.
+ */
+
+#include "VBoxDiskImageManagerDlg.h"
+#include "VBoxToolBar.h"
+#include "QIRichLabel.h"
+#include "VBoxNewHDWzd.h"
+#include "VBoxProblemReporter.h"
+
+/* Qt includes */
+#include <QLabel>
+#include <QDir>
+#include <QFileInfo>
+#include <QHeaderView>
+#include <QMenuBar>
+#include <QPushButton>
+#include <QUrl>
+
+class AddVDMUrlsEvent: public QEvent
+{
+public:
+
+    AddVDMUrlsEvent (const QList<QUrl> &aUrls)
+        : QEvent (static_cast<QEvent::Type> (VBoxDefs::AddVDMUrlsEventType))
+        , mUrls (aUrls) 
+    {}
+
+    const QList<QUrl> &urls() const { return mUrls; }
+
+private:
+
+    const QList<QUrl> mUrls;
+};
+
+class DiskImageItem : public QTreeWidgetItem
+{
+public:
+
+    enum { TypeId = QTreeWidgetItem::UserType + 1 };
+
+    DiskImageItem (DiskImageItem *aParent) :
+        QTreeWidgetItem (aParent, TypeId), mStatus (VBoxMedia::Unknown) {}
+
+    DiskImageItem (QTreeWidget *aParent) :
+        QTreeWidgetItem (aParent, TypeId), mStatus (VBoxMedia::Unknown) {}
+
+    void setMedia (const VBoxMedia &aMedia) { mMedia = aMedia; }
+    const VBoxMedia &getMedia() const { return mMedia; }
+
+    void setPath (const QString &aPath) { mPath = aPath; }
+    const QString &getPath() const { return mPath; }
+
+    void setUsage (const QString &aUsage) { mUsage = aUsage; }
+    const QString &getUsage() const { return mUsage; }
+
+    void setSnapshotUsage (const QString &aSnapshotUsage) { mSnapshotUsage = aSnapshotUsage; }
+    const QString &getSnapshotUsage() const { return mSnapshotUsage; }
+
+    QString getTotalUsage() const
+    {
+        /* should correlate with VBoxDiskImageManagerDlg::compose[Cd/Fd]Tooltip */
+        return mSnapshotUsage.isNull() ? mUsage :
+            QString ("%1 (%2)").arg (mUsage, mSnapshotUsage);
+    }
+
+    void setSnapshotName (const QString &aSnapshotName) { mSnapshotName = aSnapshotName; }
+    const QString &getSnapshotName() const { return mSnapshotName; }
+
+    void setDiskType (const QString &aDiskType) { mDiskType = aDiskType; }
+    const QString &getDiskType() const { return mDiskType; }
+
+    void setStorageType (const QString &aStorageType) { mStorageType = aStorageType; }
+    const QString &getStorageType() const { return mStorageType; }
+
+    void setVirtualSize (const QString &aVirtualSize) { mVirtualSize = aVirtualSize; }
+    const QString &getVirtualSize() const { return mVirtualSize; }
+
+    void setActualSize (const QString &aActualSize) { mActualSize = aActualSize; }
+    const QString &getActualSize() const { return mActualSize; }
+
+    void setUuid (const QUuid &aUuid) { mUuid = aUuid; }
+    const QUuid &getUuid() const { return mUuid; }
+
+    void setMachineId (const QUuid &aMachineId) { mMachineId = aMachineId; }
+    const QUuid &getMachineId() const { return mMachineId; }
+
+    void setStatus (VBoxMedia::Status aStatus) { mStatus = aStatus; }
+    VBoxMedia::Status getStatus() const { return mStatus; }
+
+    void setToolTip (const QString& aToolTip) 
+    { 
+        mToolTip = aToolTip; 
+        for (int i=0; i < treeWidget()->columnCount(); ++i)
+            QTreeWidgetItem::setToolTip (i, mToolTip);
+    }
+    const QString &getToolTip() const { return mToolTip; }
+
+    QString getInformation (const QString &aInfo, bool aCompact = true,
+                            const QString &aElipsis = "middle")
+    {
+        QString compactString = QString ("<compact elipsis=\"%1\">").arg (aElipsis);
+        QString info = QString ("<nobr>%1%2%3</nobr>")
+                       .arg (aCompact ? compactString : "")
+                       .arg (aInfo.isEmpty() ?
+                             QApplication::translate ("VBoxDiskImageManagerDlg", "--", "no info") :
+                             aInfo)
+                       .arg (aCompact ? "</compact>" : "");
+        return info;
+    }
+
+    bool operator< (const QTreeWidgetItem &aOther) const 
+    {
+        int column = treeWidget()->sortColumn();
+        ULONG64 thisValue = vboxGlobal().parseSize (       text (column));
+        ULONG64 thatValue = vboxGlobal().parseSize (aOther.text (column));
+        if (thisValue && thatValue)
+            return thisValue < thatValue;
+        else
+            return QTreeWidgetItem::operator< (aOther);
+    }
+
+//    void paintCell (QPainter *aPainter, const QColorGroup &aColorGroup,
+//                    int aColumn, int aWidth, int aSlign)
+//    {
+//        QColorGroup cGroup (aColorGroup);
+//        if (mStatus == VBoxMedia::Unknown)
+//            cGroup.setColor (QColorGroup::Text, cGroup.mid());
+//        Q3ListViewItem::paintCell (aPainter, cGroup, aColumn, aWidth, aSlign);
+//    }
+
+protected:
+
+    VBoxMedia mMedia;
+
+    QString mName;
+    QString mPath;
+    QString mUsage;
+    QString mSnapshotUsage;
+    QString mSnapshotName;
+    QString mDiskType;
+    QString mStorageType;
+    QString mVirtualSize;
+    QString mActualSize;
+
+    QUuid mUuid;
+    QUuid mMachineId;
+
+    QString mToolTip;
+
+    VBoxMedia::Status mStatus;
+};
+
+class DiskImageItemIterator : public QTreeWidgetItemIterator
+{
+public:
+
+    DiskImageItemIterator (QTreeWidget* aTree)
+        : QTreeWidgetItemIterator (aTree) {}
+
+    DiskImageItem* operator*()
+    {
+        QTreeWidgetItem *item = QTreeWidgetItemIterator::operator*();
+        return item && item->type() == DiskImageItem::TypeId ?
+            static_cast<DiskImageItem*> (item) : NULL;
+    }
+
+    DiskImageItemIterator& operator++()
+    {
+        return (DiskImageItemIterator&) QTreeWidgetItemIterator::operator++();
+    }
+};
+
+class InfoPaneLabel : public QIRichLabel
+{
+public:
+
+    InfoPaneLabel (QWidget *aParent, QLabel *aLabel = 0)
+        : QIRichLabel (aParent), mLabel (aLabel) {}
+
+    QLabel* label() { return mLabel; }
+
+private:
+
+    QLabel *mLabel;
+};
+
+VBoxDiskImageManagerDlg *VBoxDiskImageManagerDlg::mModelessDialog = NULL;
+
+VBoxDiskImageManagerDlg::VBoxDiskImageManagerDlg (QWidget *aParent /* = NULL */,  Qt::WindowFlags aFlags /* = 0 */)
+    : QIWithRetranslateUI2<QMainWindow> (aParent, aFlags)
+    , mRescode (Rejected)
+    , mType (VBoxDefs::InvalidType)
+{
+    /* Apply UI decorations */
+    Ui::VBoxDiskImageManagerDlg::setupUi (this);
+
+//    defaultButton = searchDefaultButton();
+
+    mType = VBoxDefs::InvalidType;
+
+    mIconInaccessible = style()->standardIcon (QStyle::SP_MessageBoxWarning);
+    mIconErroneous = style()->standardIcon (QStyle::SP_MessageBoxCritical);
+    mIconHD = VBoxGlobal::iconSet (":/hd_16px.png", ":/hd_disabled_16px.png");
+    mIconCD = VBoxGlobal::iconSet (":/cd_16px.png", ":/cd_disabled_16px.png");
+    mIconFD = VBoxGlobal::iconSet (":/fd_16px.png", ":/fd_disabled_16px.png");
+
+    /* Setup tab widget icons */
+    twImages->setTabIcon (HDTab, mIconHD);
+    twImages->setTabIcon (CDTab, mIconCD);
+    twImages->setTabIcon (FDTab, mIconFD);
+
+    connect (twImages, SIGNAL (currentChanged (int)),
+             this, SLOT (processCurrentChanged (int)));
+
+    /* Setup the tree view widgets */
+    mHdsTree->header()->setResizeMode (0, QHeaderView::Stretch);
+    mHdsTree->header()->setResizeMode (1, QHeaderView::ResizeToContents);
+    mHdsTree->header()->setResizeMode (2, QHeaderView::ResizeToContents);
+    mHdsTree->setSortingEnabled(true);
+    mHdsTree->setSupportedDropActions (Qt::LinkAction);
+    mHdsTree->installEventFilter (this);
+    connect (mHdsTree, SIGNAL (currentItemChanged (QTreeWidgetItem *, QTreeWidgetItem *)),
+             this, SLOT (processCurrentChanged (QTreeWidgetItem *, QTreeWidgetItem *)));
+    connect (mHdsTree, SIGNAL (itemDoubleClicked (QTreeWidgetItem *, int)),
+             this, SLOT (processDoubleClick (QTreeWidgetItem *, int)));
+    connect (mHdsTree, SIGNAL (itemRightClicked (const QPoint &, QTreeWidgetItem *, int)),
+             this, SLOT (processRightClick (const QPoint &, QTreeWidgetItem *, int)));
+
+    mCdsTree->header()->setResizeMode (0, QHeaderView::Stretch);
+    mCdsTree->header()->setResizeMode (1, QHeaderView::ResizeToContents);
+    mCdsTree->setSortingEnabled(true);
+    mCdsTree->setSupportedDropActions (Qt::LinkAction);
+    mCdsTree->installEventFilter (this);
+    connect (mCdsTree, SIGNAL (currentItemChanged (QTreeWidgetItem *, QTreeWidgetItem *)),
+             this, SLOT (processCurrentChanged (QTreeWidgetItem *, QTreeWidgetItem *)));
+    connect (mCdsTree, SIGNAL (itemDoubleClicked (QTreeWidgetItem *, int)),
+             this, SLOT (processDoubleClick (QTreeWidgetItem *, int)));
+    connect (mCdsTree, SIGNAL (itemRightClicked (const QPoint &, QTreeWidgetItem *, int)),
+             this, SLOT (processRightClick (const QPoint &, QTreeWidgetItem *, int)));
+
+    mFdsTree->header()->setResizeMode (0, QHeaderView::Stretch);
+    mFdsTree->header()->setResizeMode (1, QHeaderView::ResizeToContents);
+    mFdsTree->setSortingEnabled(true);
+    mFdsTree->setSupportedDropActions (Qt::LinkAction);
+    mFdsTree->installEventFilter (this);
+    connect (mFdsTree, SIGNAL (currentItemChanged (QTreeWidgetItem *, QTreeWidgetItem *)),
+             this, SLOT (processCurrentChanged (QTreeWidgetItem *, QTreeWidgetItem *)));
+    connect (mFdsTree, SIGNAL (itemDoubleClicked (QTreeWidgetItem *, int)),
+             this, SLOT (processDoubleClick (QTreeWidgetItem *, int)));
+    connect (mFdsTree, SIGNAL (itemRightClicked (const QPoint &, QTreeWidgetItem *, int)),
+             this, SLOT (processRightClick (const QPoint &, QTreeWidgetItem *, int)));
+
+    /* Context menu composing */
+    mActionsContextMenu = new QMenu (this);
+
+    mNewAction = new QAction (this);
+    mAddAction = new QAction (this);
+    // mEditAction = new QAction (this);
+    mRemoveAction = new QAction (this);
+    mReleaseAction = new QAction (this);
+    mRefreshAction = new QAction (this);
+
+    connect (mNewAction, SIGNAL (activated()),
+             this, SLOT (newImage()));
+    connect (mAddAction, SIGNAL (activated()),
+             this, SLOT (addImage()));
+    // connect (mEditAction, SIGNAL (activated()),
+    //          this, SLOT (editImage()));
+    connect (mRemoveAction, SIGNAL (activated()),
+             this, SLOT (removeImage()));
+    connect (mReleaseAction, SIGNAL (activated()),
+             this, SLOT (releaseImage()));
+    connect (mRefreshAction, SIGNAL (activated()),
+             this, SLOT (refreshAll()));
+
+    mNewAction->setIcon (VBoxGlobal::iconSetEx (
+        ":/vdm_new_22px.png", ":/vdm_new_16px.png",
+        ":/vdm_new_disabled_22px.png", ":/vdm_new_disabled_16px.png"));
+    mAddAction->setIcon (VBoxGlobal::iconSetEx (
+        ":/vdm_add_22px.png", ":/vdm_add_16px.png",
+        ":/vdm_add_disabled_22px.png", ":/vdm_add_disabled_16px.png"));
+    // mEditAction->setIcon (VBoxGlobal::iconSet (":/guesttools_16px.png", ":/guesttools_disabled_16px.png"));
+    mRemoveAction->setIcon (VBoxGlobal::iconSetEx (
+        ":/vdm_remove_22px.png", ":/vdm_remove_16px.png",
+        ":/vdm_remove_disabled_22px.png", ":/vdm_remove_disabled_16px.png"));
+    mReleaseAction->setIcon (VBoxGlobal::iconSetEx (
+        ":/vdm_release_22px.png", ":/vdm_release_16px.png",
+        ":/vdm_release_disabled_22px.png", ":/vdm_release_disabled_16px.png"));
+    mRefreshAction->setIcon (VBoxGlobal::iconSetEx (
+        ":/refresh_22px.png", ":/refresh_16px.png",
+        ":/refresh_disabled_22px.png", ":/refresh_disabled_16px.png"));
+
+//    mActionsMenu->addAction (mEditAction);
+    mActionsContextMenu->addAction (mRemoveAction);
+    mActionsContextMenu->addAction (mReleaseAction);
+
+    /* Toolbar composing */
+    mActionsToolBar = new VBoxToolBar (this);
+    mActionsToolBar->setIconSize (QSize (32, 32));
+    mActionsToolBar->setToolButtonStyle (Qt::ToolButtonTextUnderIcon);
+    mActionsToolBar->setSizePolicy (QSizePolicy::Fixed, QSizePolicy::Preferred);
+
+    /* Really messy what the uic produce here: a vbox layout in an hbox layout */
+    QHBoxLayout *centralLayout = qobject_cast<QHBoxLayout*> (centralWidget()->layout());
+    Assert (VALID_PTR (centralLayout));
+    QVBoxLayout *mainLayout = static_cast<QVBoxLayout*> (centralLayout->itemAt(0));
+    Assert (VALID_PTR (mainLayout));
+#if MAC_LEOPARD_STYLE
+    /* Enable unified toolbars on Mac OS X. Available on Qt >= 4.3 */
+    setUnifiedTitleAndToolBarOnMac (true);
+    addToolBar (mActionsToolBar);
+    /* No spacing/margin on the mac */
+    VBoxGlobal::setLayoutMargin (centralLayout, 0);
+    VBoxGlobal::setLayoutMargin (mainLayout, 0);
+#else /* MAC_LEOPARD_STYLE */
+    /* Add the toolbar */
+    mainLayout->insertWidget (0, mActionsToolBar);
+    /* Set spacing/margin like in the selector window */
+    centralLayout->setSpacing (0);
+    VBoxGlobal::setLayoutMargin (centralLayout, 0);
+    mainLayout->setSpacing (9);
+    VBoxGlobal::setLayoutMargin (mainLayout, 5);
+#endif /* MAC_LEOPARD_STYLE */
+
+    mActionsToolBar->addAction (mNewAction);
+    mActionsToolBar->addAction (mAddAction);
+    mActionsToolBar->addSeparator();
+//    mActionsToolBar->addAction (mEditAction);
+    mActionsToolBar->addAction (mRemoveAction);
+    mActionsToolBar->addAction (mReleaseAction);
+    mActionsToolBar->addSeparator();
+    mActionsToolBar->addAction (mRefreshAction);
+
+    /* Menu bar */
+    mActionsMenu = menuBar()->addMenu (QString::null);
+    mActionsMenu->addAction (mNewAction);
+    mActionsMenu->addAction (mAddAction);
+    mActionsMenu->addSeparator();
+//    mActionsMenu->addAction (mEditAction);
+    mActionsMenu->addAction (mRemoveAction);
+    mActionsMenu->addAction (mReleaseAction);
+    mActionsMenu->addSeparator();
+    mActionsMenu->addAction (mRefreshAction);
+
+//    qApp->installEventFilter (this);
+
+    /* Setup information pane layouts */
+    QGridLayout *hdsContainerLayout = new QGridLayout (mHdsContainer);
+    VBoxGlobal::setLayoutMargin (hdsContainerLayout, 5);
+    hdsContainerLayout->setSpacing (0);
+    QGridLayout *cdsContainerLayout = new QGridLayout (mCdsContainer);
+    VBoxGlobal::setLayoutMargin (cdsContainerLayout, 5);
+    cdsContainerLayout->setSpacing (0);
+    QGridLayout *fdsContainerLayout = new QGridLayout (mFdsContainer);
+    VBoxGlobal::setLayoutMargin (fdsContainerLayout, 5);
+    fdsContainerLayout->setSpacing (0);
+    /* Create info-pane for hd list-view */
+    createInfoString (mHdsPane1, mHdsContainer, 0, 0, 1, 3);
+    createInfoString (mHdsPane2, mHdsContainer, 1, 0);
+    createInfoString (mHdsPane3, mHdsContainer, 1, 2);
+    createInfoString (mHdsPane4, mHdsContainer, 2, 0);
+    createInfoString (mHdsPane5, mHdsContainer, 2, 2);
+    /* Create info-pane for cd list-view */
+    createInfoString (mCdsPane1, mCdsContainer, 0, 0);
+    createInfoString (mCdsPane2, mCdsContainer, 1, 0);
+    /* Create info-pane for fd list-view */
+    createInfoString (mFdsPane1, mFdsContainer, 0, 0);
+    createInfoString (mFdsPane2, mFdsContainer, 1, 0);
+
+    /* enumeration progressbar creation */
+//    mProgressText = new QLabel (centralWidget());
+//    mProgressText->setHidden (true);
+#warning port me
+//    buttonLayout->insertWidget (2, mProgressText);
+//    mProgressBar = new Q3ProgressBar (centralWidget());
+//    mProgressBar->setHidden (true);
+//    mProgressBar->setFrameShadow (Q3Frame::Sunken);
+//    mProgressBar->setFrameShape  (Q3Frame::Panel);
+//    mProgressBar->setPercentageVisible (false);
+//    mProgressBar->setMaximumWidth (100);
+#warning port me
+//    buttonLayout->insertWidget (3, mProgressBar);
+
+    /* Connects for the button box */
+    connect (mButtonBox, SIGNAL (accepted()),
+             this, SLOT (accept()));
+    connect (mButtonBox, SIGNAL (rejected()),
+             this, SLOT (reject()));
+    connect (mButtonBox, SIGNAL (helpRequested()),
+             &vboxProblem(), SLOT (showHelpHelpDialog()));
+
+
+    /* Applying language settings */
+    retranslateUi();
+}
+
+
+void VBoxDiskImageManagerDlg::setup (int aType, bool aDoSelect,
+                                     const QUuid *aTargetVMId /* = NULL */,
+                                     bool aRefresh /* = true */,
+                                     CMachine aMachine /* = NULL */,
+                                     const QUuid &aHdId,
+                                     const QUuid &aCdId,
+                                     const QUuid &aFdId)
+{
+    mMachine = aMachine;
+    mHdSelectedId = aHdId;
+    mCdSelectedId = aCdId;
+    mFdSelectedId = aFdId;
+
+    mType = aType;
+    twImages->setTabEnabled (HDTab, mType & VBoxDefs::HD);
+    twImages->setTabEnabled (CDTab, mType & VBoxDefs::CD);
+    twImages->setTabEnabled (FDTab, mType & VBoxDefs::FD);
+
+    mDoSelect = aDoSelect;
+    if (aTargetVMId)
+        mTargetVMId = *aTargetVMId;
+
+    if (mDoSelect)
+        mButtonBox->button (QDialogButtonBox::Ok)->setText (tr ("&Select"));
+    else
+        mButtonBox->button (QDialogButtonBox::Cancel)->setVisible (false);
+
+    /* Listen to "media enumeration started" signals */
+    connect (&vboxGlobal(), SIGNAL (mediaEnumStarted()),
+             this, SLOT (mediaEnumStarted()));
+    /* Listen to "media enumeration" signals */
+    connect (&vboxGlobal(), SIGNAL (mediaEnumerated (const VBoxMedia &, int)),
+             this, SLOT (mediaEnumerated (const VBoxMedia &, int)));
+    /* Listen to "media enumeration finished" signals */
+    connect (&vboxGlobal(), SIGNAL (mediaEnumFinished (const VBoxMediaList &)),
+             this, SLOT (mediaEnumFinished (const VBoxMediaList &)));
+
+    /* Listen to "media add" signals */
+    connect (&vboxGlobal(), SIGNAL (mediaAdded (const VBoxMedia &)),
+             this, SLOT (mediaAdded (const VBoxMedia &)));
+    /* Listen to "media update" signals */
+    connect (&vboxGlobal(), SIGNAL (mediaUpdated (const VBoxMedia &)),
+             this, SLOT (mediaUpdated (const VBoxMedia &)));
+    /* Listen to "media remove" signals */
+    connect (&vboxGlobal(), SIGNAL (mediaRemoved (VBoxDefs::DiskType, const QUuid &)),
+             this, SLOT (mediaRemoved (VBoxDefs::DiskType, const QUuid &)));
+
+    if (aRefresh && !vboxGlobal().isMediaEnumerationStarted())
+        vboxGlobal().startEnumeratingMedia();
+    else
+    {
+        /* Insert already enumerated media */
+        const VBoxMediaList &list = vboxGlobal().currentMediaList();
+        prepareToRefresh (list.size());
+        VBoxMediaList::const_iterator it;
+        int index = 0;
+        for (it = list.begin(); it != list.end(); ++ it)
+        {
+            mediaAdded (*it);
+//            if ((*it).status != VBoxMedia::Unknown)
+//                mProgressBar->setProgress (++ index);
+        }
+
+        /* Emulate the finished signal to reuse the code */
+        if (!vboxGlobal().isMediaEnumerationStarted())
+            mediaEnumFinished (list);
+    }
+
+    /* For a newly opened dialog, select the first item */
+    if (!mHdsTree->selectedItems().isEmpty())
+        if (QTreeWidgetItem *item = mHdsTree->topLevelItem (0))
+            setCurrentItem (mHdsTree, item);
+    if (!mCdsTree->selectedItems().isEmpty())
+        if (QTreeWidgetItem *item = mCdsTree->topLevelItem (0))
+            setCurrentItem (mCdsTree, item);
+    if (!mFdsTree->selectedItems().isEmpty())
+        if (QTreeWidgetItem *item = mFdsTree->topLevelItem (0))
+            setCurrentItem (mFdsTree, item);
+}
+
+void VBoxDiskImageManagerDlg::showModeless (bool aRefresh /* = true */)
+{
+    if (!mModelessDialog)
+    {
+        mModelessDialog =
+            new VBoxDiskImageManagerDlg (NULL, Qt::Window);
+        mModelessDialog->setAttribute (Qt::WA_DeleteOnClose);
+        mModelessDialog->setup (VBoxDefs::HD | VBoxDefs::CD | VBoxDefs::FD,
+                                false, NULL, aRefresh);
+
+        /* listen to events that may change the media status and refresh
+         * the contents of the modeless dialog */
+        /// @todo refreshAll() may be slow, so it may be better to analyze
+        //  event details and update only what is changed */
+        connect (&vboxGlobal(), SIGNAL (machineDataChanged (const VBoxMachineDataChangeEvent &)),
+                 mModelessDialog, SLOT (refreshAll()));
+        connect (&vboxGlobal(), SIGNAL (machineRegistered (const VBoxMachineRegisteredEvent &)),
+                 mModelessDialog, SLOT (refreshAll()));
+        connect (&vboxGlobal(), SIGNAL (snapshotChanged (const VBoxSnapshotEvent &)),
+                 mModelessDialog, SLOT (refreshAll()));
+    }
+
+    mModelessDialog->show();
+    mModelessDialog->setWindowState (mModelessDialog->windowState() &
+                                     ~Qt::WindowMinimized);
+    mModelessDialog->activateWindow();
+}
+
+int VBoxDiskImageManagerDlg::exec()
+{
+    AssertMsg (!mEventLoop, ("exec is called recursively"));
+
+    /* Reset the result code */
+    setResult (Rejected);
+    bool deleteOnClose = testAttribute(Qt::WA_DeleteOnClose);
+    setAttribute(Qt::WA_DeleteOnClose, false);
+    /* Create a local event loop */
+    mEventLoop = new QEventLoop();
+    /* Show the window */
+    show();
+    /* A guard to ourself for the case we destroy ourself. */
+    QPointer<VBoxDiskImageManagerDlg> guard = this;
+    /* Start the event loop. This blocks. */
+    mEventLoop->exec();
+    /* Delete the event loop */
+    delete mEventLoop;
+    /* Are we valid anymore? */
+    if (guard.isNull())
+        return Rejected;
+     int res = result();
+     if (deleteOnClose)
+         delete this;
+    /* Return the final result */
+    return res;
+}
+
+QUuid VBoxDiskImageManagerDlg::selectedUuid() const
+{
+    QTreeWidget *tree = currentTreeWidget();
+    QUuid uuid;
+
+    DiskImageItem *item = toDiskImageItem (selectedItem (tree));
+    if (item)
+        uuid = item->getUuid();
+
+    return uuid;
+}
+
+QString VBoxDiskImageManagerDlg::selectedPath() const
+{
+    QTreeWidget *tree = currentTreeWidget();
+    QString path;
+
+    DiskImageItem *item = toDiskImageItem (selectedItem (tree));
+    if (item)
+        path = item->getPath().trimmed();
+
+    return path;
+}
+
+QString VBoxDiskImageManagerDlg::composeHdToolTip (CHardDisk &aHd,
+                                                   VBoxMedia::Status aStatus,
+                                                   DiskImageItem *aItem)
+{
+    CVirtualBox vbox = vboxGlobal().virtualBox();
+    QUuid machineId = aItem ? aItem->getMachineId() : aHd.GetMachineId();
+
+    QString src = aItem ? aItem->getPath() : aHd.GetLocation();
+    QString location = aItem || aHd.GetStorageType() == KHardDiskStorageType_ISCSIHardDisk ? src :
+        QDir::convertSeparators (QFileInfo (src).absoluteFilePath());
+
+    QString storageType = aItem ? aItem->getStorageType() :
+        vboxGlobal().toString (aHd.GetStorageType());
+    QString hardDiskType = aItem ? aItem->getDiskType() :
+        vboxGlobal().hardDiskTypeString (aHd);
+
+    QString usage;
+    if (aItem)
+        usage = aItem->getUsage();
+    else if (!machineId.isNull())
+        usage = vbox.GetMachine (machineId).GetName();
+
+    QUuid snapshotId = aItem ? aItem->getUuid() : aHd.GetSnapshotId();
+    QString snapshotName;
+    if (aItem)
+        snapshotName = aItem->getSnapshotName();
+    else if (!machineId.isNull() && !snapshotId.isNull())
+    {
+        CSnapshot snapshot = vbox.GetMachine (machineId).
+                                  GetSnapshot (aHd.GetSnapshotId());
+        if (!snapshot.isNull())
+            snapshotName = snapshot.GetName();
+    }
+
+    /* Compose tool-tip information */
+    QString tip;
+    switch (aStatus)
+    {
+        case VBoxMedia::Unknown:
+        {
+            tip = tr ("<nobr><b>%1</b></nobr><br>"
+                      "Checking accessibility...", "HDD")
+                      .arg (location);
+            break;
+        }
+        case VBoxMedia::Ok:
+        {
+            tip = tr ("<nobr><b>%1</b></nobr><br>"
+                      "<nobr>Disk type:&nbsp;&nbsp;%2</nobr><br>"
+                      "<nobr>Storage type:&nbsp;&nbsp;%3</nobr>")
+                      .arg (location)
+                      .arg (hardDiskType)
+                      .arg (storageType);
+
+            if (!usage.isNull())
+                tip += tr ("<br><nobr>Attached to:&nbsp;&nbsp;%1</nobr>", "HDD")
+                           .arg (usage);
+            if (!snapshotName.isNull())
+                tip += tr ("<br><nobr>Snapshot:&nbsp;&nbsp;%5</nobr>", "HDD")
+                           .arg (snapshotName);
+            break;
+        }
+        case VBoxMedia::Error:
+        {
+            /// @todo (r=dmik) paass a complete VBoxMedia instance here
+            //  to get the result of blabla.GetAccessible() call form CUnknown
+            tip = tr ("<nobr><b>%1</b></nobr><br>"
+                      "Error checking media accessibility", "HDD")
+                      .arg (location);
+            break;
+        }
+        case VBoxMedia::Inaccessible:
+        {
+            tip = tr ("<nobr><b>%1</b></nobr><br>%2", "HDD")
+                      .arg (location)
+                      .arg (VBoxGlobal::highlight (aHd.GetLastAccessError(),
+                                                   true /* aToolTip */));
+            break;
+        }
+        default:
+            AssertFailed();
+    }
+    return tip;
+}
+
+QString VBoxDiskImageManagerDlg::composeCdToolTip (CDVDImage &aCd,
+                                                   VBoxMedia::Status aStatus,
+                                                   DiskImageItem *aItem)
+{
+    QString location = aItem ? aItem->getPath() :
+        QDir::convertSeparators (QFileInfo (aCd.GetFilePath()).absoluteFilePath());
+    QUuid uuid = aItem ? aItem->getUuid() : aCd.GetId();
+    QString usage;
+    if (aItem)
+        usage = aItem->getTotalUsage();
+    else
+    {
+        QString snapshotUsage;
+        usage = DVDImageUsage (uuid, snapshotUsage);
+        /* Should correlate with DiskImageItem::getTotalUsage() */
+        if (!snapshotUsage.isNull())
+            usage = QString ("%1 (%2)").arg (usage, snapshotUsage);
+    }
+
+    /* Compose tool-tip information */
+    QString tip;
+    switch (aStatus)
+    {
+        case VBoxMedia::Unknown:
+        {
+            tip = tr ("<nobr><b>%1</b></nobr><br>"
+                      "Checking accessibility...", "CD/DVD/Floppy")
+                      .arg (location);
+            break;
+        }
+        case VBoxMedia::Ok:
+        {
+            tip = tr ("<nobr><b>%1</b></nobr>", "CD/DVD/Floppy")
+                      .arg (location);
+
+            if (!usage.isNull())
+                tip += tr ("<br><nobr>Attached to:&nbsp;&nbsp;%1</nobr>",
+                           "CD/DVD/Floppy")
+                           .arg (usage);
+            break;
+        }
+        case VBoxMedia::Error:
+        {
+            /// @todo (r=dmik) paass a complete VBoxMedia instance here
+            //  to get the result of blabla.GetAccessible() call form CUnknown
+            tip = tr ("<nobr><b>%1</b></nobr><br>"
+                      "Error checking media accessibility", "CD/DVD/Floppy")
+                      .arg (location);
+            break;
+        }
+        case VBoxMedia::Inaccessible:
+        {
+            /// @todo (r=dmik) correct this when GetLastAccessError() is
+            //  implemented for IDVDImage
+            tip = tr ("<nobr><b>%1</b></nobr><br>%2")
+                      .arg (location)
+                      .arg (tr ("The image file is not accessible",
+                                "CD/DVD/Floppy"));
+            break;
+        }
+        default:
+            AssertFailed();
+    }
+    return tip;
+}
+
+QString VBoxDiskImageManagerDlg::composeFdToolTip (CFloppyImage &aFd,
+                                                   VBoxMedia::Status aStatus,
+                                                   DiskImageItem *aItem)
+{
+    QString location = aItem ? aItem->getPath() :
+        QDir::convertSeparators (QFileInfo (aFd.GetFilePath()).absoluteFilePath());
+    QUuid uuid = aItem ? aItem->getUuid() : aFd.GetId();
+    QString usage;
+    if (aItem)
+        usage = aItem->getTotalUsage();
+    else
+    {
+        QString snapshotUsage;
+        usage = FloppyImageUsage (uuid, snapshotUsage);
+        /* Should correlate with DiskImageItem::getTotalUsage() */
+        if (!snapshotUsage.isNull())
+            usage = QString ("%1 (%2)").arg (usage, snapshotUsage);
+    }
+
+    /* Compose tool-tip information */
+    QString tip;
+    switch (aStatus)
+    {
+        case VBoxMedia::Unknown:
+        {
+            tip = tr ("<nobr><b>%1</b></nobr><br>"
+                      "Checking accessibility...", "CD/DVD/Floppy")
+                      .arg (location);
+            break;
+        }
+        case VBoxMedia::Ok:
+        {
+            tip = tr ("<nobr><b>%1</b></nobr>", "CD/DVD/Floppy")
+                      .arg (location);
+
+            if (!usage.isNull())
+                tip += tr ("<br><nobr>Attached to:&nbsp;&nbsp;%1</nobr>",
+                           "CD/DVD/Floppy")
+                           .arg (usage);
+            break;
+        }
+        case VBoxMedia::Error:
+        {
+            /// @todo (r=dmik) paass a complete VBoxMedia instance here
+            //  to get the result of blabla.GetAccessible() call form CUnknown
+            tip = tr ("<nobr><b>%1</b></nobr><br>"
+                      "Error checking media accessibility", "CD/DVD/Floppy")
+                      .arg (location);
+            break;
+        }
+        case VBoxMedia::Inaccessible:
+        {
+            /// @todo (r=dmik) correct this when GetLastAccessError() is
+            //  implemented for IDVDImage
+            tip = tr ("<nobr><b>%1</b></nobr><br>%2")
+                      .arg (location)
+                      .arg (tr ("The image file is not accessible",
+                                "CD/DVD/Floppy"));
+            break;
+        }
+        default:
+            AssertFailed();
+    }
+    return tip;
+}
+
+void VBoxDiskImageManagerDlg::refreshAll()
+{
+    /* Start enumerating media */
+    vboxGlobal().startEnumeratingMedia();
+}
+
+void VBoxDiskImageManagerDlg::setVisible (bool aVisible)
+{
+    QMainWindow::setVisible (aVisible);
+    /* Exit from the event loop if there is any and we are changing our state
+     * from visible to invisible. */
+    if(mEventLoop && !aVisible)
+        mEventLoop->exit();
+}
+
+void VBoxDiskImageManagerDlg::retranslateUi()
+{
+    /* Translate uic generated strings */
+    Ui::VBoxDiskImageManagerDlg::retranslateUi (this);
+
+    mActionsMenu->setTitle (tr ("&Actions"));
+
+    mNewAction->setText (tr ("&New"));
+    mAddAction->setText (tr ("&Add"));
+    // mEditAction->setText (tr ("&Edit"));
+    mRemoveAction->setText (tr ("R&emove"));
+    mReleaseAction->setText (tr ("Re&lease"));
+    mRefreshAction->setText (tr ("Re&fresh"));
+
+    mNewAction->setShortcut (tr ("Ctrl+N"));
+    mAddAction->setShortcut (tr ("Ctrl+A"));
+    // mEditAction->setShortcut (tr ("Ctrl+E"));
+    mRemoveAction->setShortcut (tr ("Ctrl+D"));
+    mReleaseAction->setShortcut (tr ("Ctrl+L"));
+    mRefreshAction->setShortcut (tr ("Ctrl+R"));
+
+    mNewAction->setStatusTip (tr ("Create a new virtual hard disk"));
+    mAddAction->setStatusTip (tr ("Add (register) an existing image file"));
+    // mEditAction->setStatusTip (tr ("Edit the properties of the selected item"));
+    mRemoveAction->setStatusTip (tr ("Remove (unregister) the selected media"));
+    mReleaseAction->setStatusTip (tr ("Release the selected media by detaching it from the machine"));
+    mRefreshAction->setStatusTip (tr ("Refresh the media list"));
+
+    mHdsPane1->label()->setText (QString ("<nobr>%1:</nobr>").arg (tr ("Location")));
+    mHdsPane2->label()->setText (QString ("<nobr>%1:</nobr>").arg (tr ("Disk Type")));
+    mHdsPane3->label()->setText (QString ("<nobr>&nbsp;&nbsp;%1:</nobr>").arg (tr ("Storage Type")));
+    mHdsPane4->label()->setText (QString ("<nobr>%1:</nobr>").arg (tr ("Attached to")));
+    mHdsPane5->label()->setText (QString ("<nobr>&nbsp;&nbsp;%1:</nobr>").arg (tr ("Snapshot")));
+    mCdsPane1->label()->setText (QString ("<nobr>%1:</nobr>").arg (tr ("Location")));
+    mCdsPane2->label()->setText (QString ("<nobr>%1:</nobr>").arg (tr ("Attached to")));
+    mFdsPane1->label()->setText (QString ("<nobr>%1:</nobr>").arg (tr ("Location")));
+    mFdsPane2->label()->setText (QString ("<nobr>%1:</nobr>").arg (tr ("Attached to")));
+
+//    mProgressText->setText (tr ("Checking accessibility"));
+//
+    if (mHdsTree->model()->rowCount() || mCdsTree->model()->rowCount() || mFdsTree->model()->rowCount())
+        refreshAll();
+}
+
+void VBoxDiskImageManagerDlg::closeEvent (QCloseEvent *aEvent)
+{
+    mModelessDialog = NULL;
+    aEvent->accept();
+}
+
+void VBoxDiskImageManagerDlg::keyPressEvent (QKeyEvent *aEvent)
+{
+    if (aEvent->modifiers() == Qt::NoModifier ||
+        (aEvent->modifiers() != Qt::NoModifier && aEvent->key() == Qt::Key_Enter))
+    {
+        switch (aEvent->key())
+        {
+            case Qt::Key_Enter:
+            case Qt::Key_Return:
+                {
+                    accept();
+                    break;
+                }
+            case Qt::Key_Escape:
+                {
+                    reject();
+                    break;
+                }
+        }
+    }
+    else
+        aEvent->ignore();
+}
+
+bool VBoxDiskImageManagerDlg::eventFilter (QObject *aObject, QEvent *aEvent)
+{
+    switch (aEvent->type())
+    {
+        case QEvent::DragEnter:
+            {
+                QDragEnterEvent *deEvent = static_cast<QDragEnterEvent*> (aEvent);
+                if (deEvent->mimeData()->hasUrls())
+                {
+                    if (checkDndUrls (deEvent->mimeData()->urls()))
+                    {
+                        deEvent->setDropAction (Qt::LinkAction);
+                        deEvent->acceptProposedAction();
+                    }
+                }
+                return true;
+                break;
+            }
+        case QEvent::Drop:
+            {
+                QDropEvent *dEvent = static_cast<QDropEvent*> (aEvent);
+                if (dEvent->mimeData()->hasUrls())
+                {
+                    AddVDMUrlsEvent *event = new AddVDMUrlsEvent (dEvent->mimeData()->urls());
+                    QApplication::postEvent (currentTreeWidget(), event);
+                    dEvent->acceptProposedAction();
+                }
+                return true;
+                break;
+            }
+        case VBoxDefs::AddVDMUrlsEventType:
+        {
+            if (aObject == currentTreeWidget())
+            {
+                AddVDMUrlsEvent *addEvent = static_cast<AddVDMUrlsEvent*> (aEvent);
+                addDndUrls (addEvent->urls());
+                return true;
+            }
+            break;
+        }
+        default:
+            break;
+    }
+    return QMainWindow::eventFilter (aObject, aEvent);
+}
+
+/* @todo: Currently not used (Ported from Qt3): */
+void VBoxDiskImageManagerDlg::machineStateChanged (const VBoxMachineStateChangeEvent &aEvent)
+{
+    /// @todo (r=dmik) IVirtualBoxCallback::OnMachineStateChange
+    //  must also expose the old state! In this case we won't need to cache
+    //  the state value in every class in GUI that uses this signal.
+
+    switch (aEvent.state)
+    {
+        case KMachineState_PoweredOff:
+        case KMachineState_Aborted:
+        case KMachineState_Saved:
+        case KMachineState_Starting:
+        case KMachineState_Restoring:
+        {
+            refreshAll();
+            break;
+        }
+        default:
+            break;
+    }
+}
+
+void VBoxDiskImageManagerDlg::mediaAdded (const VBoxMedia &aMedia)
+{
+    /* Ignore non-interesting aMedia */
+    if (!(mType & aMedia.type))
+        return;
+
+    DiskImageItem *item = NULL;
+    switch (aMedia.type)
+    {
+        case VBoxDefs::HD:
+            item = createHdItem (mHdsTree, aMedia);
+            if (item->getUuid() == mHdSelectedId)
+            {
+                setCurrentItem (mHdsTree, item);
+                mHdSelectedId = QUuid();
+            }
+            break;
+        case VBoxDefs::CD:
+            item = createCdItem (mCdsTree, aMedia);
+            if (item->getUuid() == mCdSelectedId)
+            {
+                setCurrentItem (mCdsTree, item);
+                mCdSelectedId = QUuid();
+            }
+            break;
+        case VBoxDefs::FD:
+            item = createFdItem (mFdsTree, aMedia);
+            if (item->getUuid() == mFdSelectedId)
+            {
+                setCurrentItem (mFdsTree, item);
+                mFdSelectedId = QUuid();
+            }
+            break;
+        default:
+            AssertMsgFailed (("Invalid aMedia type\n"));
+    }
+
+    if (!item)
+        return;
+
+    if (!vboxGlobal().isMediaEnumerationStarted())
+        setCurrentItem (treeWidget (aMedia.type), item);
+    if (item == currentTreeWidget()->currentItem())
+        processCurrentChanged (item);
+}
+
+void VBoxDiskImageManagerDlg::mediaUpdated (const VBoxMedia &aMedia)
+{
+    /* Ignore non-interesting aMedia */
+    if (!(mType & aMedia.type))
+        return;
+
+    DiskImageItem *item = NULL;
+    switch (aMedia.type)
+    {
+        case VBoxDefs::HD:
+        {
+            CHardDisk hd = aMedia.disk;
+            item = searchItem (mHdsTree, hd.GetId());
+            updateHdItem (item, aMedia);
+            break;
+        }
+        case VBoxDefs::CD:
+        {
+            CDVDImage cd = aMedia.disk;
+            item = searchItem (mCdsTree, cd.GetId());
+            updateCdItem (item, aMedia);
+            break;
+        }
+        case VBoxDefs::FD:
+        {
+            CFloppyImage fd = aMedia.disk;
+            item = searchItem (mFdsTree, fd.GetId());
+            updateFdItem (item, aMedia);
+            break;
+        }
+        default:
+            AssertMsgFailed (("Invalid aMedia type\n"));
+    }
+
+    if (!item)
+        return;
+
+    /* Note: current items on invisible tabs are not updated because
+     * it is always done in processCurrentChanged() when the user switches
+     * to an invisible tab */
+    if (item == currentTreeWidget()->currentItem())
+        processCurrentChanged (item);
+}
+
+void VBoxDiskImageManagerDlg::mediaRemoved (VBoxDefs::DiskType aType,
+                                            const QUuid &aId)
+{
+    QTreeWidget *tree = treeWidget (aType);
+    DiskImageItem *item = searchItem (tree, aId);
+    delete item;
+    setCurrentItem (tree, tree->currentItem());
+    /* Search the list for inaccessible media */
+    if (!searchItem (tree, VBoxMedia::Inaccessible) &&
+        !searchItem (tree, VBoxMedia::Error))
+    {
+        int index = aType == VBoxDefs::HD ? HDTab :
+                    aType == VBoxDefs::CD ? CDTab :
+                    aType == VBoxDefs::FD ? FDTab : -1;
+        const QIcon &set = aType == VBoxDefs::HD ? mIconHD :
+                           aType == VBoxDefs::CD ? mIconCD :
+                           aType == VBoxDefs::FD ? mIconFD : QIcon();
+        Assert (index != -1 && !set.isNull()); /* atype should be the correct one */
+        twImages->setTabIcon (index, set);
+    }
+}
+
+void VBoxDiskImageManagerDlg::mediaEnumStarted()
+{
+    /* Load default tab icons */
+    twImages->setTabIcon (HDTab, mIconHD);
+    twImages->setTabIcon (CDTab, mIconCD);
+    twImages->setTabIcon (FDTab, mIconFD);
+
+    /* Load current media list */
+    const VBoxMediaList &list = vboxGlobal().currentMediaList();
+    prepareToRefresh (list.size());
+    VBoxMediaList::const_iterator it;
+    for (it = list.begin(); it != list.end(); ++ it)
+        mediaAdded (*it);
+
+    /* Select the first item if the previous saved item is not found or no
+     * current item at all */
+    if (!mHdsTree->currentItem() || !mHdSelectedId.isNull())
+        if (QTreeWidgetItem *item = mHdsTree->topLevelItem (0))
+            setCurrentItem (mHdsTree, item);
+    if (!mCdsTree->currentItem() || !mCdSelectedId.isNull())
+        if (QTreeWidgetItem *item = mCdsTree->topLevelItem (0))
+            setCurrentItem (mCdsTree, item);
+    if (!mFdsTree->currentItem() || !mFdSelectedId.isNull())
+        if (QTreeWidgetItem *item = mFdsTree->topLevelItem (0))
+            setCurrentItem (mFdsTree, item);
+
+    processCurrentChanged();
+}
+
+void VBoxDiskImageManagerDlg::mediaEnumerated (const VBoxMedia &aMedia,
+                                               int aIndex)
+{
+    mediaUpdated (aMedia);
+    Assert (aMedia.status != VBoxMedia::Unknown);
+//    if (aMedia.status != VBoxMedia::Unknown)
+//        mProgressBar->setProgress (aIndex + 1);
+}
+
+void VBoxDiskImageManagerDlg::mediaEnumFinished (const VBoxMediaList &/* aList */)
+{
+//    mProgressBar->setHidden (true);
+//    mProgressText->setHidden (true);
+
+    mRefreshAction->setEnabled (true);
+    unsetCursor();
+
+    processCurrentChanged();
+}
+
+void VBoxDiskImageManagerDlg::newImage()
+{
+    AssertReturnVoid (currentTreeWidgetType() == VBoxDefs::HD);
+
+    VBoxNewHDWzd dlg (this);
+
+    if (dlg.exec() == QDialog::Accepted)
+    {
+        CHardDisk hd = dlg.hardDisk();
+        VBoxMedia::Status status =
+            hd.GetAccessible() ? VBoxMedia::Ok :
+            hd.isOk() ? VBoxMedia::Inaccessible :
+            VBoxMedia::Error;
+        vboxGlobal().addMedia (VBoxMedia (CUnknown (hd), VBoxDefs::HD, status));
+    }
+}
+
+void VBoxDiskImageManagerDlg::addImage()
+{
+    QTreeWidget *tree = currentTreeWidget();
+    DiskImageItem *item = toDiskImageItem (tree->currentItem());
+
+    CVirtualBox vbox = vboxGlobal().virtualBox();
+
+    QString title;
+    QString filter;
+    VBoxDefs::DiskType type = currentTreeWidgetType();
+
+    QString dir;
+    if (item && item->getStatus() == VBoxMedia::Ok)
+        dir = QFileInfo (item->getPath().trimmed()).absolutePath ();
+
+    if (dir.isEmpty())
+        if (type == VBoxDefs::HD)
+            dir = vbox.GetSystemProperties().GetDefaultVDIFolder();
+
+    if (dir.isEmpty() || !QFileInfo (dir).exists())
+        dir = vbox.GetHomeFolder();
+
+    switch (type)
+    {
+        case VBoxDefs::HD:
+            {
+                filter = tr ("All hard disk images (*.vdi *.vmdk);;"
+                             "Virtual Disk images (*.vdi);;"
+                             "VMDK images (*.vmdk);;"
+                             "All files (*)");
+                title = tr ("Select a hard disk image file");
+                break;
+            }
+        case VBoxDefs::CD:
+            {
+                filter = tr ("CD/DVD-ROM images (*.iso);;"
+                             "All files (*)");
+                title = tr ("Select a CD/DVD-ROM disk image file");
+                break;
+            }
+        case VBoxDefs::FD:
+            {
+                filter = tr ("Floppy images (*.img);;"
+                             "All files (*)");
+                title = tr ("Select a floppy disk image file");
+                break;
+            }
+        default:
+            AssertMsgFailed (("Selected tree should be equal to one item in VBoxDefs::DiskType.\n"));
+            break;
+    }
+
+    QString src = VBoxGlobal::getOpenFileName (dir, filter, this, title);
+    src =  QDir::convertSeparators (src);
+
+    addImageToList (src, type);
+    if (!vbox.isOk())
+        vboxProblem().cannotRegisterMedia (this, vbox, type, src);
+}
+
+void VBoxDiskImageManagerDlg::removeImage()
+{
+    QTreeWidget *tree = currentTreeWidget();
+    DiskImageItem *item = toDiskImageItem (tree->currentItem());
+    AssertMsg (item, ("Current item must not be null\n"));
+
+    CVirtualBox vbox = vboxGlobal().virtualBox();
+
+    QUuid uuid = item->getUuid();
+    AssertMsg (!uuid.isNull(), ("Current item must have uuid\n"));
+
+    QString src = item->getPath().trimmed();
+    VBoxDefs::DiskType type = currentTreeWidgetType();
+
+    switch (type)
+    {
+        case VBoxDefs::HD:
+            {
+                bool deleteImage = false;
+
+                /// @todo When creation of VMDK is implemented, we should
+                /// enable image deletion for  them as well (use
+                /// GetStorageType() to define the correct cast).
+                CHardDisk disk = item->getMedia().disk;
+                if (disk.GetStorageType() == KHardDiskStorageType_VirtualDiskImage &&
+                    disk.GetParent().isNull() && /* must not be differencing (see below) */
+                    item->getStatus() == VBoxMedia::Ok)
+                {
+                    int rc = vboxProblem().confirmHardDiskImageDeletion (this, src);
+                    if (rc == QIMessageBox::Cancel)
+                        return;
+                    deleteImage = rc == QIMessageBox::Yes;
+                }
+                else
+                {
+                    /// @todo note that differencing images are always automatically
+                    /// deleted when unregistered, but the following message box
+                    /// doesn't mention it. I keep it as is for now because
+                    /// implementing the portability feature will most likely change
+                    /// this behavior (we'll update the message afterwards).
+                    if (!vboxProblem().confirmHardDiskUnregister (this, src))
+                        return;
+                }
+
+                CHardDisk hd = vbox.UnregisterHardDisk (uuid);
+                if (!vbox.isOk())
+                    vboxProblem().cannotUnregisterMedia (this, vbox, type, src);
+                else if (deleteImage)
+                {
+                    /// @todo When creation of VMDK is implemented, we should
+                    /// enable image deletion for  them as well (use
+                    /// GetStorageType() to define the correct cast).
+                    CVirtualDiskImage vdi = CUnknown (hd);
+                    if (vdi.isOk())
+                        vdi.DeleteImage();
+                    if (!vdi.isOk())
+                        vboxProblem().cannotDeleteHardDiskImage (this, vdi);
+                }
+                break;
+            }
+        case VBoxDefs::CD:
+            vbox.UnregisterDVDImage (uuid);
+            break;
+        case VBoxDefs::FD:
+            vbox.UnregisterFloppyImage (uuid);
+            break;
+        default:
+            AssertMsgFailed (("Selected tree should be equal to one item in VBoxDefs::DiskType.\n"));
+            break;
+    }
+
+    if (vbox.isOk())
+        vboxGlobal().removeMedia (type, uuid);
+    else
+        vboxProblem().cannotUnregisterMedia (this, vbox, type, src);
+}
+
+void VBoxDiskImageManagerDlg::releaseImage()
+{
+    QTreeWidget *tree = currentTreeWidget();
+    DiskImageItem *item = toDiskImageItem (tree->currentItem());
+    AssertMsg (item, ("Current item must not be null\n"));
+
+    CVirtualBox vbox = vboxGlobal().virtualBox();
+
+    QUuid itemId = item->getUuid();
+    AssertMsg (!itemId.isNull(), ("Current item must have uuid\n"));
+
+    switch (currentTreeWidgetType())
+    {
+        /* If it is a hard disk sub-item: */
+        case VBoxDefs::HD:
+            {
+                CHardDisk hd = item->getMedia().disk;
+                QUuid machineId = hd.GetMachineId();
+                if (vboxProblem().confirmReleaseImage (this,
+                                                       vbox.GetMachine (machineId).GetName()))
+                {
+                    releaseDisk (machineId, itemId, VBoxDefs::HD);
+                    VBoxMedia media (item->getMedia());
+                    media.status = hd.GetAccessible() ? VBoxMedia::Ok :
+                        hd.isOk() ? VBoxMedia::Inaccessible :
+                        VBoxMedia::Error;
+                    vboxGlobal().updateMedia (media);
+                }
+                break;
+            }
+        /* If it is a cd/dvd sub-item: */
+        case VBoxDefs::CD:
+            {
+                QString usage = item->getTotalUsage();
+                if (vboxProblem().confirmReleaseImage (this, usage))
+                {
+                    QStringList permMachines =
+                        vbox.GetDVDImageUsage (itemId,
+                                               KResourceUsage_Permanent).split (' ', QString::SkipEmptyParts);
+                    for (QStringList::Iterator it = permMachines.begin();
+                         it != permMachines.end(); ++it)
+                        releaseDisk (QUuid (*it), itemId, VBoxDefs::CD);
+
+                    CDVDImage cd = vbox.GetDVDImage (itemId);
+                    VBoxMedia media (item->getMedia());
+                    media.status = cd.GetAccessible() ? VBoxMedia::Ok :
+                        cd.isOk() ? VBoxMedia::Inaccessible :
+                        VBoxMedia::Error;
+                    vboxGlobal().updateMedia (media);
+                }
+            }
+        /* If it is a floppy sub-item: */
+        case VBoxDefs::FD:
+            {
+                QString usage = item->getTotalUsage();
+                if (vboxProblem().confirmReleaseImage (this, usage))
+                {
+                    QStringList permMachines =
+                        vbox.GetFloppyImageUsage (itemId,
+                                                  KResourceUsage_Permanent).split (' ', QString::SkipEmptyParts);
+                    for (QStringList::Iterator it = permMachines.begin();
+                         it != permMachines.end(); ++it)
+                        releaseDisk (QUuid (*it), itemId, VBoxDefs::FD);
+
+                    CFloppyImage fd = vbox.GetFloppyImage (itemId);
+                    VBoxMedia media (item->getMedia());
+                    media.status = fd.GetAccessible() ? VBoxMedia::Ok :
+                        fd.isOk() ? VBoxMedia::Inaccessible :
+                        VBoxMedia::Error;
+                    vboxGlobal().updateMedia (media);
+                }
+            }
+        default:
+            AssertMsgFailed (("Selected tree should be equal to one item in VBoxDefs::DiskType.\n"));
+            break;
+    }
+}
+
+void VBoxDiskImageManagerDlg::releaseDisk (const QUuid &aMachineId,
+                                           const QUuid &aItemId,
+                                           VBoxDefs::DiskType aDiskType)
+{
+    CSession session;
+    CMachine machine;
+    /* Is this media image mapped to this VM: */
+    if (!mMachine.isNull() && mMachine.GetId() == aMachineId)
+        machine = mMachine;
+    /* Or some other: */
+    else
+    {
+        session = vboxGlobal().openSession (aMachineId);
+        if (session.isNull()) return;
+        machine = session.GetMachine();
+    }
+    /* Perform disk releasing: */
+    switch (aDiskType)
+    {
+        case VBoxDefs::HD:
+        {
+            /* Releasing hd: */
+            CHardDiskAttachmentEnumerator en =
+                machine.GetHardDiskAttachments().Enumerate();
+            while (en.HasMore())
+            {
+                CHardDiskAttachment hda = en.GetNext();
+                if (hda.GetHardDisk().GetId() == aItemId)
+                {
+                    machine.DetachHardDisk (hda.GetBus(),
+                                            hda.GetChannel(),
+                                            hda.GetDevice());
+                    if (!machine.isOk())
+                        vboxProblem().cannotDetachHardDisk (this,
+                            machine, hda.GetBus(), hda.GetChannel(), hda.GetDevice());
+                    break;
+                }
+            }
+            break;
+        }
+        case VBoxDefs::CD:
+        {
+            /* Releasing cd: */
+            machine.GetDVDDrive().Unmount();
+            break;
+        }
+        case VBoxDefs::FD:
+        {
+            /* Releasing fd: */
+            machine.GetFloppyDrive().Unmount();
+            break;
+        }
+        default:
+            AssertMsgFailed (("Incorrect disk type."));
+    }
+    /* Save all setting changes: */
+    machine.SaveSettings();
+    if (!machine.isOk())
+        vboxProblem().cannotSaveMachineSettings (machine);
+    /* If local session was opened - close this session: */
+    if (!session.isNull())
+        session.Close();
+}
+
+void VBoxDiskImageManagerDlg::accept() 
+{ 
+    done (Accepted); 
+}
+
+void VBoxDiskImageManagerDlg::reject() 
+{ 
+    done (Rejected); 
+}
+
+void VBoxDiskImageManagerDlg::done (int aResult)
+{
+    /* Set the final result */
+    setResult (aResult);
+    /* Hide this window */
+    hide();
+    /* And close the window */
+    close();
+}
+
+int VBoxDiskImageManagerDlg::result() const 
+{ 
+    return mRescode; 
+}
+
+void VBoxDiskImageManagerDlg::setResult (int aRescode) 
+{ 
+    mRescode = aRescode; 
+}
+
+QTreeWidget* VBoxDiskImageManagerDlg::treeWidget (VBoxDefs::DiskType aType) const
+{
+    QTreeWidget* tree = NULL;
+    switch (aType)
+    {
+        case VBoxDefs::HD:
+            tree = mHdsTree;
+            break;
+        case VBoxDefs::CD:
+            tree = mCdsTree;
+            break;
+        case VBoxDefs::FD:
+            tree = mFdsTree;
+            break;
+        default:
+            AssertMsgFailed (("Disk type %d unknown!\n", aType));
+            break;
+    }
+    return tree;
+}
+
+VBoxDefs::DiskType VBoxDiskImageManagerDlg::currentTreeWidgetType() const
+{
+    VBoxDefs::DiskType type = VBoxDefs::InvalidType;
+    switch (twImages->currentIndex ())
+    {
+        case HDTab: 
+            type = VBoxDefs::HD;
+            break;
+        case CDTab: 
+            type = VBoxDefs::CD;
+            break;
+        case FDTab: 
+            type = VBoxDefs::FD;
+            break;
+        default:
+            AssertMsgFailed (("Page type %d unknown!\n", twImages->currentIndex ()));
+            break;
+    }
+    return type;
+}
+
+QTreeWidget* VBoxDiskImageManagerDlg::currentTreeWidget() const
+{
+    return treeWidget (currentTreeWidgetType());
+}
+
+
+QTreeWidgetItem *VBoxDiskImageManagerDlg::selectedItem (const QTreeWidget *aTree) const
+{
+    /* Return the current selected item. The user can select one item at the
+     * time only, so return the first element always. */
+    QList<QTreeWidgetItem *> selItems = aTree->selectedItems();
+    if (!selItems.isEmpty())
+        return selItems.first();
+    else
+        return NULL;
+}
+
+
+DiskImageItem *VBoxDiskImageManagerDlg::toDiskImageItem (QTreeWidgetItem *aItem) const
+{
+    /* Convert the QTreeWidgetItem to a DiskImageItem if it is valid. */
+    DiskImageItem *item = NULL;
+    if (aItem &&
+        aItem->type() == DiskImageItem::TypeId)
+        item = static_cast <DiskImageItem *> (aItem);
+
+    return item;
+}
+
+void VBoxDiskImageManagerDlg::setCurrentItem (QTreeWidget *aTree,
+                                              QTreeWidgetItem *aItem)
+{
+    if (aTree && aItem)
+    {
+        aItem->setSelected (true);
+        aTree->setCurrentItem (aItem);
+        aTree->scrollToItem (aItem, QAbstractItemView::EnsureVisible);
+    }
+}
+
+void VBoxDiskImageManagerDlg::processCurrentChanged (int /* index = -1 */)
+{
+    QTreeWidget *tree = currentTreeWidget();
+    tree->setFocus();
+
+    /* Tab stop setup */
+    setTabOrder (mHdsTree, mHdsPane1);
+    setTabOrder (mHdsPane1, mHdsPane2);
+    setTabOrder (mHdsPane2, mHdsPane3);
+    setTabOrder (mHdsPane3, mHdsPane4);
+    setTabOrder (mHdsPane4, mHdsPane5);
+
+    setTabOrder (mCdsTree, mCdsPane1);
+    setTabOrder (mCdsPane1, mCdsPane2);
+
+    setTabOrder (mFdsTree, mFdsPane1);
+    setTabOrder (mFdsPane1, mFdsPane2);
+
+    processCurrentChanged (tree->currentItem());
+}
+
+void VBoxDiskImageManagerDlg::processCurrentChanged (QTreeWidgetItem *aItem, QTreeWidgetItem *aPrevItem /* = NULL */)
+{
+    DiskImageItem *item = toDiskImageItem (aItem);
+
+    if (!item)
+    {
+        DiskImageItem *itemOld = toDiskImageItem (aPrevItem);
+        /* We have to make sure that one item is selected always. If the new
+         * item is 0, set the old item again. */
+        setCurrentItem (currentTreeWidget(), itemOld);
+        return;
+    }
+
+    /* Ensures current item visible every time we are switching page */
+    item->treeWidget()->scrollToItem (item, QAbstractItemView::EnsureVisible);
+
+    bool notInEnum      = !vboxGlobal().isMediaEnumerationStarted();
+    bool modifyEnabled  = notInEnum &&
+                          item &&  item->getUsage().isNull() &&
+                          (item->childCount() == 0) && !item->getPath().isNull();
+    bool releaseEnabled = item && !item->getUsage().isNull() &&
+                          item->getSnapshotUsage().isNull() &&
+                          checkImage (item) &&
+                          !item->parent() && (item->childCount() == 0) &&
+                          item->getSnapshotName().isNull();
+    bool newEnabled     = notInEnum &&
+                          currentTreeWidget() == mHdsTree ? true : false;
+    bool addEnabled     = notInEnum;
+
+    // mEditAction->setEnabled (modifyEnabled);
+    mRemoveAction->setEnabled (modifyEnabled);
+    mReleaseAction->setEnabled (releaseEnabled);
+    mNewAction->setEnabled (newEnabled);
+    mAddAction->setEnabled (addEnabled);
+
+    if (mDoSelect)
+    {
+        bool selectEnabled = item && !item->parent() &&
+                             (!newEnabled ||
+                                (item->getUsage().isNull() ||
+                                 item->getMachineId() == mTargetVMId));
+
+        mButtonBox->button (QDialogButtonBox::Ok)->setEnabled (selectEnabled);
+    }
+
+    if (item)
+    {
+        if (item->treeWidget() == mHdsTree)
+        {
+            mHdsPane1->setText (item->getInformation (item->getPath(), true, "end"));
+            mHdsPane2->setText (item->getInformation (item->getDiskType(), false));
+            mHdsPane3->setText (item->getInformation (item->getStorageType(), false));
+            mHdsPane4->setText (item->getInformation (item->getUsage()));
+            mHdsPane5->setText (item->getInformation (item->getSnapshotName()));
+        }
+        else if (item->treeWidget() == mCdsTree)
+        {
+            mCdsPane1->setText (item->getInformation (item->getPath(), true, "end"));
+            mCdsPane2->setText (item->getInformation (item->getTotalUsage()));
+        }
+        else if (item->treeWidget() == mFdsTree)
+        {
+            mFdsPane1->setText (item->getInformation (item->getPath(), true, "end"));
+            mFdsPane2->setText (item->getInformation (item->getTotalUsage()));
+        }
+    }
+    else
+        clearInfoPanes();
+}
+
+void VBoxDiskImageManagerDlg::processDoubleClick (QTreeWidgetItem * /* aItem */, int /* aColumn */)
+{
+    QTreeWidget *tree = currentTreeWidget();
+
+    if (mDoSelect && selectedItem (tree) && mButtonBox->button (QDialogButtonBox::Ok)->isEnabled())
+        accept();
+}
+
+void VBoxDiskImageManagerDlg::processRightClick (const QPoint &aPos, QTreeWidgetItem *aItem, int /* aColumn */)
+{
+    if (aItem)
+    {
+        /* Make sure the item is selected and current */
+        setCurrentItem (currentTreeWidget(), aItem);
+        mActionsContextMenu->exec (aPos);
+    }
+}
+
+void VBoxDiskImageManagerDlg::addImageToList (const QString &aSource,
+                                              VBoxDefs::DiskType aDiskType)
+{
+    if (aSource.isEmpty())
+        return;
+
+    CVirtualBox vbox = vboxGlobal().virtualBox();
+
+    QUuid uuid;
+    VBoxMedia media;
+    switch (aDiskType)
+    {
+        case VBoxDefs::HD:
+        {
+            CHardDisk hd = vbox.OpenHardDisk (aSource);
+            if (vbox.isOk())
+            {
+                vbox.RegisterHardDisk (hd);
+                if (vbox.isOk())
+                {
+                    VBoxMedia::Status status =
+                        hd.GetAccessible() ? VBoxMedia::Ok :
+                        hd.isOk() ? VBoxMedia::Inaccessible :
+                        VBoxMedia::Error;
+                    media = VBoxMedia (CUnknown (hd), VBoxDefs::HD, status);
+                }
+            }
+            break;
+        }
+        case VBoxDefs::CD:
+        {
+            CDVDImage cd = vbox.OpenDVDImage (aSource, uuid);
+            if (vbox.isOk())
+            {
+                vbox.RegisterDVDImage (cd);
+                if (vbox.isOk())
+                {
+                    VBoxMedia::Status status =
+                        cd.GetAccessible() ? VBoxMedia::Ok :
+                        cd.isOk() ? VBoxMedia::Inaccessible :
+                        VBoxMedia::Error;
+                    media = VBoxMedia (CUnknown (cd), VBoxDefs::CD, status);
+                }
+            }
+            break;
+        }
+        case VBoxDefs::FD:
+        {
+            CFloppyImage fd = vbox.OpenFloppyImage (aSource, uuid);
+            if (vbox.isOk())
+            {
+                vbox.RegisterFloppyImage (fd);
+                if (vbox.isOk())
+                {
+                    VBoxMedia::Status status =
+                        fd.GetAccessible() ? VBoxMedia::Ok :
+                        fd.isOk() ? VBoxMedia::Inaccessible :
+                        VBoxMedia::Error;
+                    media = VBoxMedia (CUnknown (fd), VBoxDefs::FD, status);
+                }
+            }
+            break;
+        }
+        default:
+            AssertMsgFailed (("Invalid aDiskType type\n"));
+    }
+    if (media.type != VBoxDefs::InvalidType)
+        vboxGlobal().addMedia (media);
+}
+
+DiskImageItem* VBoxDiskImageManagerDlg::createImageNode (QTreeWidget *aTree,
+                                                         DiskImageItem *aRoot,
+                                                         const VBoxMedia &aMedia) const
+{
+    Assert (!(aTree == NULL && aRoot == NULL));
+
+    DiskImageItem *item = NULL;
+
+    if (aRoot)
+        item = new DiskImageItem (aRoot);
+    else if (aTree)
+        item = new DiskImageItem (aTree);
+
+    item->setMedia (aMedia);
+
+    return item;
+}
+
+DiskImageItem* VBoxDiskImageManagerDlg::createHdItem (QTreeWidget *aTree,
+                                                      const VBoxMedia &aMedia) const
+{
+    CHardDisk hd = aMedia.disk;
+    QUuid rootId = hd.GetParent().isNull() ? QUuid() : hd.GetParent().GetId();
+    DiskImageItem *root = searchItem (aTree, rootId);
+    DiskImageItem *item = createImageNode (aTree, root, aMedia);
+    updateHdItem (item, aMedia);
+    return item;
+}
+
+DiskImageItem* VBoxDiskImageManagerDlg::createCdItem (QTreeWidget *aTree,
+                                                      const VBoxMedia &aMedia) const
+{
+    DiskImageItem *item = createImageNode (aTree, 0, aMedia);
+    updateCdItem (item, aMedia);
+    return item;
+}
+
+DiskImageItem* VBoxDiskImageManagerDlg::createFdItem (QTreeWidget *aTree,
+                                                      const VBoxMedia &aMedia) const
+{
+    DiskImageItem *item = createImageNode (aTree, 0, aMedia);
+    updateFdItem (item, aMedia);
+    return item;
+}
+
+void VBoxDiskImageManagerDlg::updateHdItem (DiskImageItem *aItem,
+                                            const VBoxMedia &aMedia) const
+{
+    if (!aItem)
+        return;
+
+    CHardDisk hd = aMedia.disk;
+    VBoxMedia::Status status = aMedia.status;
+
+    QUuid uuid = hd.GetId();
+    QString src = hd.GetLocation();
+    QUuid machineId = hd.GetMachineId();
+    QString usage;
+    if (!machineId.isNull())
+        usage = vboxGlobal().virtualBox().GetMachine (machineId).GetName();
+    QString storageType = vboxGlobal().toString (hd.GetStorageType());
+    QString hardDiskType = vboxGlobal().hardDiskTypeString (hd);
+    QString virtualSize = status == VBoxMedia::Ok ?
+        vboxGlobal().formatSize ((ULONG64)hd.GetSize() * _1M) : QString ("--");
+    QString actualSize = status == VBoxMedia::Ok ?
+        vboxGlobal().formatSize (hd.GetActualSize()) : QString ("--");
+    QString snapshotName;
+    if (!machineId.isNull() && !hd.GetSnapshotId().isNull())
+    {
+        CSnapshot snapshot = vboxGlobal().virtualBox().GetMachine (machineId).
+                                  GetSnapshot (hd.GetSnapshotId());
+        if (!snapshot.isNull())
+            snapshotName = QString ("%1").arg (snapshot.GetName());
+    }
+    QFileInfo fi (src);
+
+    aItem->setText (0, fi.fileName());
+    aItem->setText (1, virtualSize);
+    aItem->setTextAlignment (1, Qt::AlignRight);
+    aItem->setText (2, actualSize);
+    aItem->setTextAlignment (2, Qt::AlignRight);
+    aItem->setPath (hd.GetStorageType() == KHardDiskStorageType_ISCSIHardDisk ? src :
+                    QDir::convertSeparators (fi.absoluteFilePath()));
+    aItem->setUsage (usage);
+    aItem->setSnapshotName (snapshotName);
+    aItem->setDiskType (hardDiskType);
+    aItem->setStorageType (storageType);
+    aItem->setVirtualSize (virtualSize);
+    aItem->setActualSize (actualSize);
+    aItem->setUuid (uuid);
+    aItem->setMachineId (machineId);
+    aItem->setToolTip (composeHdToolTip (hd, status, aItem));
+    aItem->setStatus (status);
+
+    makeWarningMark (aItem, aMedia.status, VBoxDefs::HD);
+}
+
+void VBoxDiskImageManagerDlg::updateCdItem (DiskImageItem *aItem,
+                                            const VBoxMedia &aMedia) const
+{
+    if (!aItem)
+        return;
+
+    CDVDImage cd = aMedia.disk;
+    VBoxMedia::Status status = aMedia.status;
+
+    QUuid uuid = cd.GetId();
+    QString src = cd.GetFilePath();
+    QString snapshotUsage;
+    QString usage = DVDImageUsage (uuid, snapshotUsage);
+    QString size = status == VBoxMedia::Ok ?
+        vboxGlobal().formatSize (cd.GetSize()) : QString ("--");
+    QFileInfo fi (src);
+
+    aItem->setText (0, fi.fileName());
+    aItem->setText (1, size);
+    aItem->setTextAlignment (1, Qt::AlignRight);
+    aItem->setPath (QDir::convertSeparators (fi.absoluteFilePath ()));
+    aItem->setUsage (usage);
+    aItem->setSnapshotUsage (snapshotUsage);
+    aItem->setActualSize (size);
+    aItem->setUuid (uuid);
+    aItem->setToolTip (composeCdToolTip (cd, status, aItem));
+    aItem->setStatus (status);
+
+    makeWarningMark (aItem, aMedia.status, VBoxDefs::CD);
+}
+
+void VBoxDiskImageManagerDlg::updateFdItem (DiskImageItem *aItem,
+                                            const VBoxMedia &aMedia) const
+{
+    if (!aItem)
+        return;
+
+    CFloppyImage fd = aMedia.disk;
+    VBoxMedia::Status status = aMedia.status;
+
+    QUuid uuid = fd.GetId();
+    QString src = fd.GetFilePath();
+    QString snapshotUsage;
+    QString usage = FloppyImageUsage (uuid, snapshotUsage);
+    QString size = status == VBoxMedia::Ok ?
+        vboxGlobal().formatSize (fd.GetSize()) : QString ("--");
+    QFileInfo fi (src);
+
+    aItem->setText (0, fi.fileName());
+    aItem->setText (1, size);
+    aItem->setTextAlignment (1, Qt::AlignRight);
+    aItem->setPath (QDir::convertSeparators (fi.absoluteFilePath ()));
+    aItem->setUsage (usage);
+    aItem->setSnapshotUsage (snapshotUsage);
+    aItem->setActualSize (size);
+    aItem->setUuid (uuid);
+    aItem->setToolTip (composeFdToolTip (fd, status, aItem));
+    aItem->setStatus (status);
+
+    makeWarningMark (aItem, aMedia.status, VBoxDefs::FD);
+}
+
+DiskImageItem* VBoxDiskImageManagerDlg::searchItem (QTreeWidget *aTree,
+                                                    const QUuid &aId) const
+{
+    if (aId.isNull()) 
+        return NULL;
+
+    DiskImageItemIterator iterator (aTree);
+    while (*iterator)
+    {
+        if ((*iterator)->getUuid() == aId)
+            return *iterator;
+        ++iterator;
+    }
+    return NULL;
+}
+
+DiskImageItem* VBoxDiskImageManagerDlg::searchItem (QTreeWidget *aTree,
+                                                    VBoxMedia::Status aStatus) const
+{
+    DiskImageItemIterator iterator (aTree);
+    while (*iterator)
+    {
+        if ((*iterator)->getStatus() == aStatus)
+            return *iterator;
+        ++iterator;
+    }
+    return NULL;
+}
+
+bool VBoxDiskImageManagerDlg::checkImage (DiskImageItem *aItem)
+{
+    QUuid itemId = aItem ? aItem->getUuid() : QUuid();
+    if (itemId.isNull()) 
+        return false;
+
+    CVirtualBox vbox = vboxGlobal().virtualBox();
+
+    switch (currentTreeWidgetType())
+    {
+        case VBoxDefs::HD:
+            {
+                CHardDisk hd = aItem->getMedia().disk;
+                QUuid machineId = hd.GetMachineId();
+                if (machineId.isNull() ||
+                    (vbox.GetMachine (machineId).GetState() != KMachineState_PoweredOff &&
+                     vbox.GetMachine (machineId).GetState() != KMachineState_Aborted))
+                    return false;
+                break;
+            }
+        case VBoxDefs::CD:
+            {
+                /* Check if there is temporary usage: */
+                QStringList tempMachines =
+                    vbox.GetDVDImageUsage (itemId,
+                                           KResourceUsage_Temporary).split (' ', QString::SkipEmptyParts);
+                if (!tempMachines.isEmpty())
+                    return false;
+                /* Only permanently mounted .iso could be released */
+                QStringList permMachines =
+                    vbox.GetDVDImageUsage (itemId,
+                                           KResourceUsage_Permanent).split (' ', QString::SkipEmptyParts);
+                for (QStringList::Iterator it = permMachines.begin();
+                     it != permMachines.end(); ++it)
+                    if (vbox.GetMachine(QUuid (*it)).GetState() != KMachineState_PoweredOff &&
+                        vbox.GetMachine(QUuid (*it)).GetState() != KMachineState_Aborted)
+                        return false;
+                break;
+            }
+        case VBoxDefs::FD:
+            {
+                /* Check if there is temporary usage: */
+                QStringList tempMachines =
+                    vbox.GetFloppyImageUsage (itemId,
+                                              KResourceUsage_Temporary).split (' ', QString::SkipEmptyParts);
+                if (!tempMachines.isEmpty())
+                    return false;
+                /* Only permanently mounted floppies could be released */
+                QStringList permMachines =
+                    vbox.GetFloppyImageUsage (itemId,
+                                              KResourceUsage_Permanent).split (' ', QString::SkipEmptyParts);
+                for (QStringList::Iterator it = permMachines.begin();
+                     it != permMachines.end(); ++it)
+                    if (vbox.GetMachine(QUuid (*it)).GetState() != KMachineState_PoweredOff &&
+                        vbox.GetMachine(QUuid (*it)).GetState() != KMachineState_Aborted)
+                        return false;
+                break;
+            }
+        default:
+            {
+                return false;
+                break;
+            }
+    }
+    return true;
+}
+
+bool VBoxDiskImageManagerDlg::checkDndUrls (const QList<QUrl> &aUrls) const
+{
+    bool err = false;
+    /* Check that all file extensions fit to the current
+     * selected tree view and the files are valid. */
+    foreach (QUrl u, aUrls)
+    {
+        QFileInfo fi (u.toLocalFile());
+        /* Check dropped media type */
+        /// @todo On OS/2 and windows (and mac?) extension checks should be case
+        /// insensitive, as OPPOSED to linux and the rest where case matters.
+        QString suffix = fi.suffix().toLower();
+        switch (currentTreeWidgetType())
+        {
+            case VBoxDefs::HD: 
+                err |= (!(suffix == "vdi" || suffix == "vmdk")); 
+                break;
+            case VBoxDefs::CD: 
+                err |= (suffix != "iso"); 
+                break;
+            case VBoxDefs::FD: 
+                err |= (suffix != "img"); 
+                break;
+            default:
+                AssertMsgFailed (("Selected tree should be equal to one item in VBoxDefs::DiskType.\n"));
+                break;
+        }
+    }
+    return !err;
+}
+
+void VBoxDiskImageManagerDlg::addDndUrls (const QList<QUrl> &aUrls)
+{
+    CVirtualBox vbox = vboxGlobal().virtualBox();
+    foreach (QUrl u, aUrls)
+    {
+        QString file = u.toLocalFile();
+        VBoxDefs::DiskType type = currentTreeWidgetType();
+        addImageToList (file, type);
+        if (!vbox.isOk())
+            vboxProblem().cannotRegisterMedia (this, vbox, type, file);
+    }
+}
+
+void VBoxDiskImageManagerDlg::clearInfoPanes()
+{
+    mHdsPane1->clear();
+    mHdsPane2->clear(); mHdsPane3->clear();
+    mHdsPane4->clear(); mHdsPane5->clear();
+    mCdsPane1->clear(); mCdsPane2->clear();
+    mFdsPane1->clear(); mFdsPane2->clear();
+}
+
+void VBoxDiskImageManagerDlg::prepareToRefresh (int aTotal)
+{
+    /* Info panel clearing */
+    clearInfoPanes();
+
+    /* Prepare progressbar */
+//    if (mProgressBar)
+//    {
+//        mProgressBar->setProgress (0, aTotal);
+//        mProgressBar->setHidden (false);
+//        mProgressText->setHidden (false);
+//    }
+
+    mRefreshAction->setEnabled (false);
+    setCursor (QCursor (Qt::BusyCursor));
+
+    /* Store the current list selections */
+    DiskImageItem *di;
+
+    di = toDiskImageItem (mHdsTree->currentItem());
+    if (mHdSelectedId.isNull())
+        mHdSelectedId = di ? di->getUuid() : QUuid();
+
+    di = toDiskImageItem (mCdsTree->currentItem());
+    if (mCdSelectedId.isNull())
+        mCdSelectedId = di ? di->getUuid() : QUuid();
+
+    di = toDiskImageItem (mFdsTree->currentItem());
+    if (mFdSelectedId.isNull())
+        mFdSelectedId = di ? di->getUuid() : QUuid();
+
+    /* Finally, clear all lists */
+    mHdsTree->clear();
+    mCdsTree->clear();
+    mFdsTree->clear();
+}
+
+void VBoxDiskImageManagerDlg::createInfoString (InfoPaneLabel *&aInfo,
+                                                QWidget *aRoot,
+                                                int aRow, int aCol,
+                                                int aRowSpan /* = 1 */, int aColSpan /* = 1 */) const
+{
+    /* Create the label & the info pane itself */
+    QLabel *nameLabel = new QLabel (aRoot);
+    aInfo = new InfoPaneLabel (aRoot, nameLabel);
+
+    /* Setup focus policy <strong> default for info pane */
+    aInfo->setFocusPolicy (Qt::StrongFocus);
+
+    /* Prevent the name columns from being expanded */
+    nameLabel->setSizePolicy (QSizePolicy::Fixed, QSizePolicy::Fixed);
+
+    QGridLayout *rootLayout = qobject_cast<QGridLayout*> (aRoot->layout());
+    Assert (VALID_PTR (rootLayout));
+
+    /* Add the two widgets */
+    rootLayout->addWidget (nameLabel, aRow, aCol, 1, 1);
+    rootLayout->addWidget (aInfo, aRow, aCol + 1, aRowSpan, aColSpan);
+}
+
+void VBoxDiskImageManagerDlg::makeWarningMark (DiskImageItem *aItem,
+                                               VBoxMedia::Status aStatus,
+                                               VBoxDefs::DiskType aType) const
+{
+    const QIcon &icon = aStatus == VBoxMedia::Inaccessible ? mIconInaccessible :
+                        aStatus == VBoxMedia::Error ? mIconErroneous : QIcon();
+
+    if (!icon.isNull())
+    {
+        aItem->setIcon (0, icon);
+        treeWidget (aType);
+        int index = aType == VBoxDefs::HD ? HDTab :
+                    aType == VBoxDefs::CD ? CDTab :
+                    aType == VBoxDefs::FD ? FDTab : -1;
+        Assert (index != -1); /* aType should be correct */
+        twImages->setTabIcon (index, icon);
+        aItem->treeWidget()->scrollToItem (aItem, QAbstractItemView::EnsureVisible);
+    }
+}
+
+QString VBoxDiskImageManagerDlg::DVDImageUsage (const QUuid &aId, QString &aSnapshotUsage)
+{
+    CVirtualBox vbox = vboxGlobal().virtualBox();
+
+    QStringList permMachines =
+        vbox.GetDVDImageUsage (aId, KResourceUsage_Permanent).split (' ', QString::SkipEmptyParts);
+    QStringList tempMachines =
+        vbox.GetDVDImageUsage (aId, KResourceUsage_Temporary).split (' ', QString::SkipEmptyParts);
+
+    QString usage;
+
+    for (QStringList::Iterator it = permMachines.begin();
+         it != permMachines.end();
+         ++it)
+    {
+        if (!usage.isEmpty())
+            usage += ", ";
+        CMachine machine = vbox.GetMachine (QUuid (*it));
+        usage += machine.GetName();
+
+        DVDImageSnapshotUsage (aId, machine.GetSnapshot (QUuid()),
+                               aSnapshotUsage);
+    }
+
+    for (QStringList::Iterator it = tempMachines.begin();
+         it != tempMachines.end();
+         ++it)
+    {
+        /* Skip IDs that are in the permanent list */
+        if (!permMachines.contains (*it))
+        {
+            if (!usage.isEmpty())
+                usage += ", [";
+            else
+                usage += "[";
+            CMachine machine = vbox.GetMachine (QUuid (*it));
+            usage += machine.GetName() + "]";
+
+            DVDImageSnapshotUsage (aId, machine.GetSnapshot (QUuid()),
+                                   aSnapshotUsage);
+        }
+    }
+
+    return usage;
+}
+
+QString VBoxDiskImageManagerDlg::FloppyImageUsage (const QUuid &aId, QString &aSnapshotUsage)
+{
+    CVirtualBox vbox = vboxGlobal().virtualBox();
+
+    QStringList permMachines =
+        vbox.GetFloppyImageUsage (aId, KResourceUsage_Permanent).split (' ', QString::SkipEmptyParts);
+    QStringList tempMachines =
+        vbox.GetFloppyImageUsage (aId, KResourceUsage_Temporary).split (' ', QString::SkipEmptyParts);
+
+    QString usage;
+
+    for (QStringList::Iterator it = permMachines.begin();
+         it != permMachines.end();
+         ++it)
+    {
+        if (!usage.isEmpty())
+            usage += ", ";
+        CMachine machine = vbox.GetMachine (QUuid (*it));
+        usage += machine.GetName();
+
+        FloppyImageSnapshotUsage (aId, machine.GetSnapshot (QUuid()),
+                                  aSnapshotUsage);
+    }
+
+    for (QStringList::Iterator it = tempMachines.begin();
+         it != tempMachines.end();
+         ++it)
+    {
+        /* Skip IDs that are in the permanent list */
+        if (!permMachines.contains (*it))
+        {
+            if (!usage.isEmpty())
+                usage += ", [";
+            else
+                usage += "[";
+            CMachine machine = vbox.GetMachine (QUuid (*it));
+            usage += machine.GetName() + "]";
+
+            FloppyImageSnapshotUsage (aId, machine.GetSnapshot (QUuid()),
+                                      aSnapshotUsage);
+        }
+    }
+
+    return usage;
+}
+
+void VBoxDiskImageManagerDlg::DVDImageSnapshotUsage (const QUuid &aId, const CSnapshot &aSnapshot, QString &aUsage)
+{
+    if (aSnapshot.isNull())
+        return;
+
+    if (!aSnapshot.GetMachine().GetDVDDrive().GetImage().isNull() &&
+        aSnapshot.GetMachine().GetDVDDrive().GetImage().GetId() == aId)
+    {
+        if (!aUsage.isEmpty())
+            aUsage += ", ";
+        aUsage += aSnapshot.GetName();
+    }
+
+    CSnapshotEnumerator en = aSnapshot.GetChildren().Enumerate();
+    while (en.HasMore())
+        DVDImageSnapshotUsage (aId, en.GetNext(), aUsage);
+}
+
+void VBoxDiskImageManagerDlg::FloppyImageSnapshotUsage (const QUuid &aId, const CSnapshot &aSnapshot, QString &aUsage)
+{
+    if (aSnapshot.isNull())
+        return;
+
+    if (!aSnapshot.GetMachine().GetFloppyDrive().GetImage().isNull() &&
+        aSnapshot.GetMachine().GetFloppyDrive().GetImage().GetId() == aId)
+    {
+        if (!aUsage.isEmpty())
+            aUsage += ", ";
+        aUsage += aSnapshot.GetName();
+    }
+
+    CSnapshotEnumerator en = aSnapshot.GetChildren().Enumerate();
+    while (en.HasMore())
+        FloppyImageSnapshotUsage (aId, en.GetNext(), aUsage);
+}
+
Index: /trunk/src/VBox/Frontends/VirtualBox4/src/VBoxMediaComboBox.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox4/src/VBoxMediaComboBox.cpp	(revision 9213)
+++ /trunk/src/VBox/Frontends/VirtualBox4/src/VBoxMediaComboBox.cpp	(revision 9214)
@@ -32,4 +32,5 @@
 //Added by qt3to4:
 #include <QPixmap>
+#include <QMessageBox>
 
 VBoxMediaComboBox::VBoxMediaComboBox (QWidget *aParent, int aType /* = -1 */,
Index: /trunk/src/VBox/Frontends/VirtualBox4/src/VBoxNewVMWzd.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox4/src/VBoxNewVMWzd.cpp	(revision 9213)
+++ /trunk/src/VBox/Frontends/VirtualBox4/src/VBoxNewVMWzd.cpp	(revision 9214)
@@ -195,8 +195,8 @@
 void VBoxNewVMWzd::showVDIManager()
 {
-    VBoxDiskImageManagerDlg dlg (this, "VBoxDiskImageManagerDlg", Qt::WType_Dialog | Qt::WShowModal);
+    VBoxDiskImageManagerDlg dlg (this);
     dlg.setup (VBoxDefs::HD, true);
     QUuid newId = dlg.exec() == VBoxDiskImageManagerDlg::Accepted ?
-        dlg.getSelectedUuid() : mMediaCombo->getId();
+        dlg.selectedUuid() : mMediaCombo->getId();
 
     if (uuidHD != newId)
Index: /trunk/src/VBox/Frontends/VirtualBox4/src/VBoxVMFirstRunWzd.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox4/src/VBoxVMFirstRunWzd.cpp	(revision 9213)
+++ /trunk/src/VBox/Frontends/VirtualBox4/src/VBoxVMFirstRunWzd.cpp	(revision 9214)
@@ -241,6 +241,5 @@
 void VBoxVMFirstRunWzd::openVdm()
 {
-    VBoxDiskImageManagerDlg vdm (this, "VBoxDiskImageManagerDlg",
-                                 Qt::WType_Dialog | Qt::WShowModal);
+    VBoxDiskImageManagerDlg vdm (this);
     QUuid machineId = mMachine.GetId();
     VBoxDefs::DiskType type = mRbCdType->isChecked() ? VBoxDefs::CD :
@@ -249,5 +248,5 @@
     if (vdm.exec() == VBoxDiskImageManagerDlg::Accepted)
     {
-        mCbImage->setCurrentItem (vdm.getSelectedUuid());
+        mCbImage->setCurrentItem (vdm.selectedUuid());
 
         /* Revalidate updated page */
Index: /trunk/src/VBox/Frontends/VirtualBox4/ui/VBoxDiskImageManagerDlg.ui
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox4/ui/VBoxDiskImageManagerDlg.ui	(revision 9213)
+++ /trunk/src/VBox/Frontends/VirtualBox4/ui/VBoxDiskImageManagerDlg.ui	(revision 9214)
@@ -1,641 +1,221 @@
-<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
-<class>VBoxDiskImageManagerDlg</class>
-<comment>
-:mode=html:tabSize=4:indentSize=4:noTabs=true:
-:folding=explicit:collapseFolds=1:
+<ui version="4.0" >
+ <comment>
+ VBox frontends: Qt4 GUI ("VirtualBox"):
 
-     Copyright (C) 2006-2007 Sun Microsystems, Inc.
-    
-     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.
-    
-     Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
-     Clara, CA 95054 USA or visit http://www.sun.com if you need
-     additional information or have any questions.
-</comment>
-<widget class="QMainWindow">
-    <property name="name">
-        <cstring>VBoxDiskImageManagerDlg</cstring>
-    </property>
-    <property name="geometry">
-        <rect>
-            <x>0</x>
-            <y>0</y>
-            <width>620</width>
-            <height>460</height>
-        </rect>
-    </property>
-    <property name="minimumSize">
-        <size>
-            <width>289</width>
-            <height>178</height>
-        </size>
-    </property>
-    <property name="caption">
-        <string>Virtual Disk Manager</string>
-    </property>
-    <vbox>
-        <property name="name">
-            <cstring>unnamed</cstring>
+ Copyright (C) 2008 Sun Microsystems, Inc.
+
+ 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.
+
+ Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
+ Clara, CA 95054 USA or visit http://www.sun.com if you need
+ additional information or have any questions.
+ </comment>
+ <class>VBoxDiskImageManagerDlg</class>
+ <widget class="QMainWindow" name="VBoxDiskImageManagerDlg" >
+  <property name="geometry" >
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>620</width>
+    <height>460</height>
+   </rect>
+  </property>
+  <property name="minimumSize" >
+   <size>
+    <width>283</width>
+    <height>190</height>
+   </size>
+  </property>
+  <property name="windowTitle" >
+   <string>Virtual Disk Manager</string>
+  </property>
+  <property name="windowIcon" >
+   <iconset resource="../VirtualBox.qrc" >:/diskim_16px.png</iconset>
+  </property>
+  <widget class="QWidget" name="centralwidget" >
+   <layout class="QHBoxLayout" >
+    <item>
+     <layout class="QVBoxLayout" >
+      <item>
+       <widget class="QTabWidget" name="twImages" >
+        <property name="sizePolicy" >
+         <sizepolicy vsizetype="Expanding" hsizetype="Preferred" >
+          <horstretch>0</horstretch>
+          <verstretch>0</verstretch>
+         </sizepolicy>
         </property>
-        <property name="margin">
-            <number>3</number>
+        <property name="currentIndex" >
+         <number>0</number>
         </property>
-        <property name="spacing">
-            <number>5</number>
+        <widget class="QWidget" name="tbHardDisk" >
+         <attribute name="title" >
+          <string>&amp;Hard Disks</string>
+         </attribute>
+         <layout class="QVBoxLayout" >
+          <item>
+           <widget class="QITreeWidget" name="mHdsTree" >
+            <property name="acceptDrops" >
+             <bool>true</bool>
+            </property>
+            <property name="horizontalScrollBarPolicy" >
+             <enum>Qt::ScrollBarAlwaysOff</enum>
+            </property>
+            <property name="alternatingRowColors" >
+             <bool>true</bool>
+            </property>
+            <property name="allColumnsShowFocus" >
+             <bool>true</bool>
+            </property>
+            <column>
+             <property name="text" >
+              <string>Name</string>
+             </property>
+            </column>
+            <column>
+             <property name="text" >
+              <string>Virtual Size</string>
+             </property>
+            </column>
+            <column>
+             <property name="text" >
+              <string>Actual Size</string>
+             </property>
+            </column>
+           </widget>
+          </item>
+          <item>
+           <widget class="QFrame" name="mHdsContainer" >
+            <property name="frameShape" >
+             <enum>QFrame::Box</enum>
+            </property>
+            <property name="frameShadow" >
+             <enum>QFrame::Sunken</enum>
+            </property>
+           </widget>
+          </item>
+         </layout>
+        </widget>
+        <widget class="QWidget" name="tbCD" >
+         <attribute name="title" >
+          <string>&amp;CD/DVD Images</string>
+         </attribute>
+         <layout class="QVBoxLayout" >
+          <item>
+           <widget class="QITreeWidget" name="mCdsTree" >
+            <property name="acceptDrops" >
+             <bool>true</bool>
+            </property>
+            <property name="horizontalScrollBarPolicy" >
+             <enum>Qt::ScrollBarAlwaysOff</enum>
+            </property>
+            <property name="alternatingRowColors" >
+             <bool>true</bool>
+            </property>
+            <property name="allColumnsShowFocus" >
+             <bool>true</bool>
+            </property>
+            <column>
+             <property name="text" >
+              <string>Name</string>
+             </property>
+            </column>
+            <column>
+             <property name="text" >
+              <string>Size</string>
+             </property>
+            </column>
+           </widget>
+          </item>
+          <item>
+           <widget class="QFrame" name="mCdsContainer" >
+            <property name="frameShape" >
+             <enum>QFrame::Box</enum>
+            </property>
+            <property name="frameShadow" >
+             <enum>QFrame::Sunken</enum>
+            </property>
+           </widget>
+          </item>
+         </layout>
+        </widget>
+        <widget class="QWidget" name="tbFloppy" >
+         <attribute name="title" >
+          <string>&amp;Floppy Images</string>
+         </attribute>
+         <layout class="QVBoxLayout" >
+          <item>
+           <widget class="QITreeWidget" name="mFdsTree" >
+            <property name="acceptDrops" >
+             <bool>true</bool>
+            </property>
+            <property name="horizontalScrollBarPolicy" >
+             <enum>Qt::ScrollBarAlwaysOff</enum>
+            </property>
+            <property name="alternatingRowColors" >
+             <bool>true</bool>
+            </property>
+            <property name="allColumnsShowFocus" >
+             <bool>true</bool>
+            </property>
+            <column>
+             <property name="text" >
+              <string>Name</string>
+             </property>
+            </column>
+            <column>
+             <property name="text" >
+              <string>Size</string>
+             </property>
+            </column>
+           </widget>
+          </item>
+          <item>
+           <widget class="QFrame" name="mFdsContainer" >
+            <property name="frameShape" >
+             <enum>QFrame::Box</enum>
+            </property>
+            <property name="frameShadow" >
+             <enum>QFrame::Sunken</enum>
+            </property>
+           </widget>
+          </item>
+         </layout>
+        </widget>
+       </widget>
+      </item>
+      <item>
+       <widget class="QIDialogButtonBox" name="mButtonBox" >
+        <property name="standardButtons" >
+         <set>QDialogButtonBox::Cancel|QDialogButtonBox::Help|QDialogButtonBox::NoButton|QDialogButtonBox::Ok</set>
         </property>
-        <widget class="QLayoutWidget">
-            <property name="name">
-                <cstring>layout2</cstring>
-            </property>
-            <vbox>
-                <property name="name">
-                    <cstring>unnamed</cstring>
-                </property>
-                <property name="margin">
-                    <number>7</number>
-                </property>
-                <widget class="QTabWidget">
-                    <property name="name">
-                        <cstring>twImages</cstring>
-                    </property>
-                    <property name="sizePolicy">
-                        <sizepolicy>
-                            <hsizetype>5</hsizetype>
-                            <vsizetype>7</vsizetype>
-                            <horstretch>0</horstretch>
-                            <verstretch>0</verstretch>
-                        </sizepolicy>
-                    </property>
-                    <widget class="QWidget">
-                        <property name="name">
-                            <cstring>tab</cstring>
-                        </property>
-                        <attribute name="title">
-                            <string>&amp;Hard Disks</string>
-                        </attribute>
-                        <vbox>
-                            <property name="name">
-                                <cstring>unnamed</cstring>
-                            </property>
-                            <widget class="QListView">
-                                <column>
-                                    <property name="text">
-                                        <string>Name</string>
-                                    </property>
-                                    <property name="clickable">
-                                        <bool>true</bool>
-                                    </property>
-                                    <property name="resizable">
-                                        <bool>true</bool>
-                                    </property>
-                                </column>
-                                <column>
-                                    <property name="text">
-                                        <string>Virtual Size</string>
-                                    </property>
-                                    <property name="clickable">
-                                        <bool>true</bool>
-                                    </property>
-                                    <property name="resizable">
-                                        <bool>true</bool>
-                                    </property>
-                                </column>
-                                <column>
-                                    <property name="text">
-                                        <string>Actual Size</string>
-                                    </property>
-                                    <property name="clickable">
-                                        <bool>true</bool>
-                                    </property>
-                                    <property name="resizable">
-                                        <bool>true</bool>
-                                    </property>
-                                </column>
-                                <property name="name">
-                                    <cstring>hdsView</cstring>
-                                </property>
-                                <property name="acceptDrops">
-                                    <bool>true</bool>
-                                </property>
-                                <property name="hScrollBarMode">
-                                    <enum>AlwaysOff</enum>
-                                </property>
-                                <property name="dragAutoScroll">
-                                    <bool>false</bool>
-                                </property>
-                                <property name="allColumnsShowFocus">
-                                    <bool>true</bool>
-                                </property>
-                                <property name="rootIsDecorated">
-                                    <bool>true</bool>
-                                </property>
-                                <property name="resizeMode">
-                                    <enum>AllColumns</enum>
-                                </property>
-                                <property name="whatsThis" stdset="0">
-                                    <string></string>
-                                </property>
-                            </widget>
-                            <widget class="QFrame">
-                                <property name="name">
-                                    <cstring>hdsContainer</cstring>
-                                </property>
-                                <property name="frameShape">
-                                    <enum>Box</enum>
-                                </property>
-                                <property name="frameShadow">
-                                    <enum>Sunken</enum>
-                                </property>
-                            </widget>
-                        </vbox>
-                    </widget>
-                    <widget class="QWidget">
-                        <property name="name">
-                            <cstring>tab</cstring>
-                        </property>
-                        <attribute name="title">
-                            <string>&amp;CD/DVD Images</string>
-                        </attribute>
-                        <vbox>
-                            <property name="name">
-                                <cstring>unnamed</cstring>
-                            </property>
-                            <widget class="QListView">
-                                <column>
-                                    <property name="text">
-                                        <string>Name</string>
-                                    </property>
-                                    <property name="clickable">
-                                        <bool>true</bool>
-                                    </property>
-                                    <property name="resizable">
-                                        <bool>true</bool>
-                                    </property>
-                                </column>
-                                <column>
-                                    <property name="text">
-                                        <string>Size</string>
-                                    </property>
-                                    <property name="clickable">
-                                        <bool>true</bool>
-                                    </property>
-                                    <property name="resizable">
-                                        <bool>true</bool>
-                                    </property>
-                                </column>
-                                <property name="name">
-                                    <cstring>cdsView</cstring>
-                                </property>
-                                <property name="acceptDrops">
-                                    <bool>true</bool>
-                                </property>
-                                <property name="hScrollBarMode">
-                                    <enum>AlwaysOff</enum>
-                                </property>
-                                <property name="dragAutoScroll">
-                                    <bool>false</bool>
-                                </property>
-                                <property name="allColumnsShowFocus">
-                                    <bool>true</bool>
-                                </property>
-                                <property name="rootIsDecorated">
-                                    <bool>true</bool>
-                                </property>
-                                <property name="resizeMode">
-                                    <enum>AllColumns</enum>
-                                </property>
-                                <property name="whatsThis" stdset="0">
-                                    <string></string>
-                                </property>
-                            </widget>
-                            <widget class="QFrame">
-                                <property name="name">
-                                    <cstring>cdsContainer</cstring>
-                                </property>
-                                <property name="frameShape">
-                                    <enum>Box</enum>
-                                </property>
-                                <property name="frameShadow">
-                                    <enum>Sunken</enum>
-                                </property>
-                            </widget>
-                        </vbox>
-                    </widget>
-                    <widget class="QWidget">
-                        <property name="name">
-                            <cstring>TabPage</cstring>
-                        </property>
-                        <attribute name="title">
-                            <string>&amp;Floppy Images</string>
-                        </attribute>
-                        <vbox>
-                            <property name="name">
-                                <cstring>unnamed</cstring>
-                            </property>
-                            <widget class="QListView">
-                                <column>
-                                    <property name="text">
-                                        <string>Name</string>
-                                    </property>
-                                    <property name="clickable">
-                                        <bool>true</bool>
-                                    </property>
-                                    <property name="resizable">
-                                        <bool>true</bool>
-                                    </property>
-                                </column>
-                                <column>
-                                    <property name="text">
-                                        <string>Size</string>
-                                    </property>
-                                    <property name="clickable">
-                                        <bool>true</bool>
-                                    </property>
-                                    <property name="resizable">
-                                        <bool>true</bool>
-                                    </property>
-                                </column>
-                                <property name="name">
-                                    <cstring>fdsView</cstring>
-                                </property>
-                                <property name="acceptDrops">
-                                    <bool>true</bool>
-                                </property>
-                                <property name="hScrollBarMode">
-                                    <enum>AlwaysOff</enum>
-                                </property>
-                                <property name="dragAutoScroll">
-                                    <bool>false</bool>
-                                </property>
-                                <property name="allColumnsShowFocus">
-                                    <bool>true</bool>
-                                </property>
-                                <property name="rootIsDecorated">
-                                    <bool>true</bool>
-                                </property>
-                                <property name="resizeMode">
-                                    <enum>AllColumns</enum>
-                                </property>
-                                <property name="whatsThis" stdset="0">
-                                    <string></string>
-                                </property>
-                            </widget>
-                            <widget class="QFrame">
-                                <property name="name">
-                                    <cstring>fdsContainer</cstring>
-                                </property>
-                                <property name="frameShape">
-                                    <enum>Box</enum>
-                                </property>
-                                <property name="frameShadow">
-                                    <enum>Sunken</enum>
-                                </property>
-                            </widget>
-                        </vbox>
-                    </widget>
-                </widget>
-                <widget class="QLayoutWidget">
-                    <property name="name">
-                        <cstring>buttonLayout</cstring>
-                    </property>
-                    <hbox>
-                        <property name="name">
-                            <cstring>unnamed</cstring>
-                        </property>
-                        <widget class="QPushButton">
-                            <property name="name">
-                                <cstring>buttonHelp</cstring>
-                            </property>
-                            <property name="text">
-                                <string>Help</string>
-                            </property>
-                            <property name="accel">
-                                <string>F1</string>
-                            </property>
-                            <property name="autoDefault">
-                                <bool>true</bool>
-                            </property>
-                            <property name="whatsThis" stdset="0">
-                                <string>Invoke dialog's help</string>
-                            </property>
-                        </widget>
-                        <spacer>
-                            <property name="name">
-                                <cstring>Spacer1</cstring>
-                            </property>
-                            <property name="orientation">
-                                <enum>Horizontal</enum>
-                            </property>
-                            <property name="sizeType">
-                                <enum>Expanding</enum>
-                            </property>
-                            <property name="sizeHint">
-                                <size>
-                                    <width>214</width>
-                                    <height>16</height>
-                                </size>
-                            </property>
-                        </spacer>
-                        <spacer>
-                            <property name="name">
-                                <cstring>Spacer2</cstring>
-                            </property>
-                            <property name="orientation">
-                                <enum>Horizontal</enum>
-                            </property>
-                            <property name="sizeType">
-                                <enum>Expanding</enum>
-                            </property>
-                            <property name="sizeHint">
-                                <size>
-                                    <width>214</width>
-                                    <height>16</height>
-                                </size>
-                            </property>
-                        </spacer>
-                        <widget class="QPushButton">
-                            <property name="name">
-                                <cstring>buttonOk</cstring>
-                            </property>
-                            <property name="text">
-                                <string>&amp;OK</string>
-                            </property>
-                            <property name="autoDefault">
-                                <bool>true</bool>
-                            </property>
-                            <property name="default">
-                                <bool>true</bool>
-                            </property>
-                            <property name="whatsThis" stdset="0">
-                                <string>Accept dialog</string>
-                            </property>
-                        </widget>
-                        <widget class="QPushButton">
-                            <property name="name">
-                                <cstring>buttonCancel</cstring>
-                            </property>
-                            <property name="text">
-                                <string>Cancel</string>
-                            </property>
-                            <property name="autoDefault">
-                                <bool>true</bool>
-                            </property>
-                            <property name="whatsThis" stdset="0">
-                                <string>Cancel dialog</string>
-                            </property>
-                        </widget>
-                    </hbox>
-                </widget>
-            </vbox>
-        </widget>
-    </vbox>
-</widget>
-<toolbars>
-</toolbars>
-<connections>
-    <connection>
-        <sender>buttonOk</sender>
-        <signal>clicked()</signal>
-        <receiver>VBoxDiskImageManagerDlg</receiver>
-        <slot>accept()</slot>
-    </connection>
-    <connection>
-        <sender>buttonCancel</sender>
-        <signal>clicked()</signal>
-        <receiver>VBoxDiskImageManagerDlg</receiver>
-        <slot>reject()</slot>
-    </connection>
-    <connection>
-        <sender>hdsView</sender>
-        <signal>currentChanged(QListViewItem*)</signal>
-        <receiver>VBoxDiskImageManagerDlg</receiver>
-        <slot>processCurrentChanged(QListViewItem*)</slot>
-    </connection>
-    <connection>
-        <sender>cdsView</sender>
-        <signal>currentChanged(QListViewItem*)</signal>
-        <receiver>VBoxDiskImageManagerDlg</receiver>
-        <slot>processCurrentChanged(QListViewItem*)</slot>
-    </connection>
-    <connection>
-        <sender>fdsView</sender>
-        <signal>currentChanged(QListViewItem*)</signal>
-        <receiver>VBoxDiskImageManagerDlg</receiver>
-        <slot>processCurrentChanged(QListViewItem*)</slot>
-    </connection>
-    <connection>
-        <sender>hdsView</sender>
-        <signal>pressed(QListViewItem*)</signal>
-        <receiver>VBoxDiskImageManagerDlg</receiver>
-        <slot>processPressed(QListViewItem*)</slot>
-    </connection>
-    <connection>
-        <sender>cdsView</sender>
-        <signal>pressed(QListViewItem*)</signal>
-        <receiver>VBoxDiskImageManagerDlg</receiver>
-        <slot>processPressed(QListViewItem*)</slot>
-    </connection>
-    <connection>
-        <sender>fdsView</sender>
-        <signal>pressed(QListViewItem*)</signal>
-        <receiver>VBoxDiskImageManagerDlg</receiver>
-        <slot>processPressed(QListViewItem*)</slot>
-    </connection>
-    <connection>
-        <sender>hdsView</sender>
-        <signal>doubleClicked(QListViewItem*)</signal>
-        <receiver>VBoxDiskImageManagerDlg</receiver>
-        <slot>processDoubleClick(QListViewItem*)</slot>
-    </connection>
-    <connection>
-        <sender>cdsView</sender>
-        <signal>doubleClicked(QListViewItem*)</signal>
-        <receiver>VBoxDiskImageManagerDlg</receiver>
-        <slot>processDoubleClick(QListViewItem*)</slot>
-    </connection>
-    <connection>
-        <sender>fdsView</sender>
-        <signal>doubleClicked(QListViewItem*)</signal>
-        <receiver>VBoxDiskImageManagerDlg</receiver>
-        <slot>processDoubleClick(QListViewItem*)</slot>
-    </connection>
-    <connection>
-        <sender>hdsView</sender>
-        <signal>contextMenuRequested(QListViewItem*,const QPoint&amp;,int)</signal>
-        <receiver>VBoxDiskImageManagerDlg</receiver>
-        <slot>invokePopup(QListViewItem*,const QPoint&amp;,int)</slot>
-    </connection>
-    <connection>
-        <sender>cdsView</sender>
-        <signal>contextMenuRequested(QListViewItem*,const QPoint&amp;,int)</signal>
-        <receiver>VBoxDiskImageManagerDlg</receiver>
-        <slot>invokePopup(QListViewItem*,const QPoint&amp;,int)</slot>
-    </connection>
-    <connection>
-        <sender>fdsView</sender>
-        <signal>contextMenuRequested(QListViewItem*,const QPoint&amp;,int)</signal>
-        <receiver>VBoxDiskImageManagerDlg</receiver>
-        <slot>invokePopup(QListViewItem*,const QPoint&amp;,int)</slot>
-    </connection>
-    <connection>
-        <sender>twImages</sender>
-        <signal>currentChanged(QWidget*)</signal>
-        <receiver>VBoxDiskImageManagerDlg</receiver>
-        <slot>processCurrentChanged()</slot>
-    </connection>
-    <connection>
-        <sender>buttonHelp</sender>
-        <signal>clicked()</signal>
-        <receiver>&amp;vboxProblem()</receiver>
-        <slot>showHelpHelpDialog()</slot>
-    </connection>
-</connections>
-<includes>
-    <include location="global" impldecl="in implementation">qapplication.h</include>
-    <include location="global" impldecl="in implementation">qprogressdialog.h</include>
-    <include location="global" impldecl="in implementation">qobjectlist.h</include>
-    <include location="global" impldecl="in implementation">qdragobject.h</include>
-    <include location="global" impldecl="in implementation">qaction.h</include>
-    <include location="global" impldecl="in implementation">qpopupmenu.h</include>
-    <include location="global" impldecl="in implementation">qeventloop.h</include>
-    <include location="global" impldecl="in implementation">qstatusbar.h</include>
-    <include location="global" impldecl="in implementation">qsizegrip.h</include>
-    <include location="global" impldecl="in implementation">qlocale.h</include>
-    <include location="global" impldecl="in implementation">qregexp.h</include>
-    <include location="global" impldecl="in implementation">qpainter.h</include>
-    <include location="global" impldecl="in implementation">qprogressbar.h</include>
-    <include location="global" impldecl="in declaration">qvaluelist.h</include>
-    <include location="local" impldecl="in declaration">COMDefs.h</include>
-    <include location="local" impldecl="in declaration">VBoxGlobal.h</include>
-    <include location="local" impldecl="in declaration">VBoxProblemReporter.h</include>
-    <include location="local" impldecl="in implementation">VBoxDefs.h</include>
-    <include location="local" impldecl="in implementation">VBoxNewHDWzd.h</include>
-    <include location="local" impldecl="in implementation">VBoxToolBar.h</include>
-    <include location="local" impldecl="in implementation">QIRichLabel.h</include>
-</includes>
-<forwards>
-    <forward>class DiskImageItem</forward>
-    <forward>class VBoxToolBar</forward>
-    <forward>class QSizeGrip</forward>
-    <forward>class InfoPaneLabel</forward>
-    <forward>class QProgressBar</forward>
-</forwards>
-<variables>
-    <variable access="public">enum ResultCode { Rejected, Accepted };</variable>
-    <variable access="private">bool polished;</variable>
-    <variable access="private">CVirtualBox vbox;</variable>
-    <variable access="private">int type;</variable>
-    <variable access="private">bool doSelect;</variable>
-    <variable access="private">QUuid targetVMId;</variable>
-    <variable access="private">QPixmap pxInaccessible;</variable>
-    <variable access="private">QPixmap pxErroneous;</variable>
-    <variable access="private">QIconSet pxHD;</variable>
-    <variable access="private">QIconSet pxCD;</variable>
-    <variable access="private">QIconSet pxFD;</variable>
-    <variable access="private">CMachine cmachine;</variable>
-    <variable access="private">QPopupMenu *itemMenu;</variable>
-    <variable access="private">VBoxToolBar *toolBar;</variable>
-    <variable access="private">int mRescode;</variable>
-    <variable access="private">bool mInLoop;</variable>
-    <variable access="private">QAction *imNewAction;</variable>
-    <variable access="private">QAction *imAddAction;</variable>
-    <variable access="private">QAction *imEditAction;</variable>
-    <variable access="private">QAction *imRemoveAction;</variable>
-    <variable access="private">QAction *imReleaseAction;</variable>
-    <variable access="private">QAction *imRefreshAction;</variable>
-    <variable access="private">InfoPaneLabel *hdsPane1;</variable>
-    <variable access="private">InfoPaneLabel *hdsPane2;</variable>
-    <variable access="private">InfoPaneLabel *hdsPane3;</variable>
-    <variable access="private">InfoPaneLabel *hdsPane4;</variable>
-    <variable access="private">InfoPaneLabel *hdsPane5;</variable>
-    <variable access="private">InfoPaneLabel *hdsPane6;</variable>
-    <variable access="private">InfoPaneLabel *hdsPane7;</variable>
-    <variable access="private">InfoPaneLabel *cdsPane1;</variable>
-    <variable access="private">InfoPaneLabel *cdsPane2;</variable>
-    <variable access="private">InfoPaneLabel *fdsPane1;</variable>
-    <variable access="private">InfoPaneLabel *fdsPane2;</variable>
-    <variable>QSizeGrip *sizeGrip;</variable>
-    <variable>QPushButton *defaultButton;</variable>
-    <variable access="private">static VBoxDiskImageManagerDlg *mModelessDialog;</variable>
-    <variable access="private">QProgressBar *mProgressBar;</variable>
-    <variable access="private">QLabel *mProgressText;</variable>
-    <variable access="private">QUuid hdSelectedId;</variable>
-    <variable access="private">QUuid cdSelectedId;</variable>
-    <variable access="private">QUuid fdSelectedId;</variable>
-</variables>
-<slots>
-    <slot access="protected">mediaEnumStarted()</slot>
-    <slot access="protected">mediaEnumerated( const VBoxMedia &amp;, int )</slot>
-    <slot access="protected">mediaEnumFinished( const VBoxMediaList &amp; )</slot>
-    <slot access="protected">mediaAdded( const VBoxMedia &amp; )</slot>
-    <slot access="protected">mediaUpdated( const VBoxMedia &amp; )</slot>
-    <slot access="protected">mediaRemoved( VBoxDefs::DiskType, const QUuid &amp; )</slot>
-    <slot access="protected">machineStateChanged( const VBoxMachineStateChangeEvent &amp; )</slot>
-    <slot>refreshAll()</slot>
-    <slot access="protected">processCurrentChanged( QListViewItem * item )</slot>
-    <slot access="protected">processPressed( QListViewItem * item )</slot>
-    <slot access="protected">newImage()</slot>
-    <slot access="protected">addImage()</slot>
-    <slot access="protected">removeImage()</slot>
-    <slot access="protected">processDoubleClick( QListViewItem * item )</slot>
-    <slot access="protected">releaseImage()</slot>
-    <slot access="protected">invokePopup( QListViewItem * item, const QPoint &amp; pos, int col )</slot>
-    <slot access="protected">processCurrentChanged()</slot>
-    <slot access="protected">accept()</slot>
-    <slot access="protected">reject()</slot>
-    <slot access="protected">mouseOnItem( QListViewItem *item )</slot>
-</slots>
-<functions>
-    <function access="private">init()</function>
-    <function access="private" returnType="int">result()</function>
-    <function access="private">setResult( int )</function>
-    <function returnType="int">exec()</function>
-    <function access="private">done( int )</function>
-    <function access="private" returnType="DiskImageItem*">searchItem( QListView*, const QUuid &amp; )</function>
-    <function access="private" returnType="DiskImageItem*">searchItem( QListView*, VBoxMedia::Status )</function>
-    <function specifier="static" access="private" returnType="QString">getDVDImageUsage( const QUuid &amp; aId, QString &amp; aSnapshotUsage )</function>
-    <function specifier="static" access="private" returnType="QString">getFloppyImageUsage( const QUuid &amp; aId, QString &amp; aSnapshotUsage )</function>
-    <function specifier="static" access="private">getDVDImageSnapshotUsage( const QUuid &amp; aImageId, const CSnapshot &amp; aSnapshot, QString &amp; aUsage )</function>
-    <function specifier="static" access="private">getFloppyImageSnapshotUsage( const QUuid &amp; aImageId, const CSnapshot &amp; aSnapshot, QString &amp; aUsage )</function>
-    <function access="private" returnType="bool">checkImage( DiskImageItem* item )</function>
-    <function access="private">releaseDisk( QUuid machineId, QUuid itemId, VBoxDefs::DiskType diskType )</function>
-    <function returnType="QUuid">getSelectedUuid()</function>
-    <function returnType="QString">getSelectedPath()</function>
-    <function>setup( int aType, bool aDoSelect, const QUuid *aTargetVMId = NULL, bool aRefresh = true, CMachine machine = NULL, const QUuid &amp; aHdId = QUuid(), const QUuid &amp; aCdId = QUuid(), const QUuid &amp; aFdId = QUuid() )</function>
-    <function access="private" returnType="QListView*">getCurrentListView()</function>
-    <function access="private" returnType="QListView*">getListView( VBoxDefs::DiskType )</function>
-    <function returnType="bool">eventFilter( QObject *, QEvent * )</function>
-    <function access="private">addDroppedImages( QStringList* )</function>
-    <function access="private">addImageToList( const QString &amp; aSource, VBoxDefs::DiskType aDiskType )</function>
-    <function access="private" returnType="DiskImageItem*">createImageNode( QListView *aList, DiskImageItem *aRoot, const VBoxMedia &amp; )</function>
-    <function access="private">updateHdItem( DiskImageItem*, const VBoxMedia &amp; )</function>
-    <function access="private">updateCdItem( DiskImageItem*, const VBoxMedia &amp; )</function>
-    <function access="private">updateFdItem( DiskImageItem*, const VBoxMedia &amp; )</function>
-    <function access="private" returnType="DiskImageItem*">createHdItem( QListView*, const VBoxMedia &amp; )</function>
-    <function access="private" returnType="DiskImageItem*">createCdItem( QListView*, const VBoxMedia &amp; )</function>
-    <function access="private" returnType="DiskImageItem*">createFdItem( QListView*, const VBoxMedia &amp; )</function>
-    <function access="protected" returnType="bool">event( QEvent* )</function>
-    <function access="protected">showEvent( QShowEvent * )</function>
-    <function access="protected">resizeEvent( QResizeEvent* )</function>
-    <function access="protected">keyPressEvent( QKeyEvent* )</function>
-    <function access="protected">closeEvent( QCloseEvent* )</function>
-    <function access="protected">createInfoString( InfoPaneLabel *&amp;, QWidget*, int, int )</function>
-    <function access="protected" returnType="QPushButton*">searchDefaultButton()</function>
-    <function access="protected">setCurrentItem( QListView*, QListViewItem* )</function>
-    <function specifier="static"> showModeless( bool aRefresh = true )</function>
-    <function specifier="static" returnType="QString">composeHdToolTip( CHardDisk &amp;, VBoxMedia::Status = VBoxMedia::Ok, DiskImageItem *aItem = NULL )</function>
-    <function specifier="static" returnType="QString">composeCdToolTip( CDVDImage &amp;, VBoxMedia::Status = VBoxMedia::Ok, DiskImageItem *aItem = NULL )</function>
-    <function specifier="static" returnType="QString">composeFdToolTip( CFloppyImage &amp;, VBoxMedia::Status = VBoxMedia::Ok, DiskImageItem *aItem = NULL )</function>
-    <function access="protected">clearInfoPanes()</function>
-    <function access="protected">prepareToRefresh( int aTotal = 0 )</function>
-    <function access="protected">makeWarningMark( DiskImageItem*, VBoxMedia::Status, VBoxDefs::DiskType )</function>
-    <function access="pritave">languageChangeImp()</function>
-</functions>
-<layoutdefaults spacing="10" margin="10"/>
-</UI>
+       </widget>
+      </item>
+     </layout>
+    </item>
+   </layout>
+  </widget>
+  <widget class="QStatusBar" name="statusBar" />
+ </widget>
+ <customwidgets>
+  <customwidget>
+   <class>QIDialogButtonBox</class>
+   <extends>QDialogButtonBox</extends>
+   <header>QIDialogButtonBox.h</header>
+  </customwidget>
+  <customwidget>
+   <class>QITreeWidget</class>
+   <extends>QTreeWidget</extends>
+   <header>QITreeWidget.h</header>
+  </customwidget>
+ </customwidgets>
+ <resources>
+  <include location="../VirtualBox.qrc" />
+ </resources>
+ <connections/>
+</ui>
Index: unk/src/VBox/Frontends/VirtualBox4/ui/VBoxDiskImageManagerDlg.ui.h
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox4/ui/VBoxDiskImageManagerDlg.ui.h	(revision 9213)
+++ 	(revision )
@@ -1,2286 +1,0 @@
-//Added by qt3to4:
-#include <QResizeEvent>
-#include <QLabel>
-#include <QPixmap>
-#include <QCloseEvent>
-#include <Q3GridLayout>
-#include <QShowEvent>
-#include <q3mimefactory.h>
-#include <QDragEnterEvent>
-#include <QKeyEvent>
-#include <QEvent>
-#include <Q3VBoxLayout>
-#include <Q3Frame>
-#include <QDropEvent>
-#include <QCustomEvent>
-#include <Q3PopupMenu>
-#include <QMenuBar>
-#include <QMenuItem>
-#include <QDir>
-#include <QToolTip>
-/**
- *
- * VBox frontends: Qt GUI ("VirtualBox"):
- * "Virtual Disk Manager" dialog UI include (Qt Designer)
- */
-
-/*
- * Copyright (C) 2006-2007 Sun Microsystems, Inc.
- *
- * 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.
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
- * Clara, CA 95054 USA or visit http://www.sun.com if you need
- * additional information or have any questions.
- */
-
-/****************************************************************************
-** ui.h extension file, included from the uic-generated form implementation.
-**
-** If you wish to add, delete or rename functions or slots use
-** Qt Designer which will update this file, preserving your code. Create an
-** init() function in place of a constructor, and a destroy() function in
-** place of a destructor.
-*****************************************************************************/
-
-
-class DiskImageItem : public Q3ListViewItem
-{
-public:
-
-    enum { TypeId = 1001 };
-
-    DiskImageItem (DiskImageItem *parent) :
-        Q3ListViewItem (parent), mStatus (VBoxMedia::Unknown) {}
-
-    DiskImageItem (Q3ListView *parent) :
-        Q3ListViewItem (parent), mStatus (VBoxMedia::Unknown) {}
-
-    void setMedia (const VBoxMedia &aMedia) { mMedia = aMedia; }
-    const VBoxMedia &getMedia() const { return mMedia; }
-
-    void setPath (const QString &aPath) { mPath = aPath; }
-    const QString &getPath() const { return mPath; }
-
-    void setUsage (const QString &aUsage) { mUsage = aUsage; }
-    const QString &getUsage() const { return mUsage; }
-
-    void setSnapshotUsage (const QString &aSnapshotUsage) { mSnapshotUsage = aSnapshotUsage; }
-    const QString &getSnapshotUsage() const { return mSnapshotUsage; }
-
-    QString getTotalUsage() const
-    {
-        /* should correlate with VBoxDiskImageManagerDlg::compose[Cd/Fd]Tooltip */
-        return mSnapshotUsage.isNull() ? mUsage :
-            QString ("%1 (%2)").arg (mUsage, mSnapshotUsage);
-    }
-
-    void setSnapshotName (const QString &aSnapshotName) { mSnapshotName = aSnapshotName; }
-    const QString &getSnapshotName() const { return mSnapshotName; }
-
-    void setDiskType (const QString &aDiskType) { mDiskType = aDiskType; }
-    const QString &getDiskType() const { return mDiskType; }
-
-    void setStorageType (const QString &aStorageType) { mStorageType = aStorageType; }
-    const QString &getStorageType() const { return mStorageType; }
-
-    void setVirtualSize (const QString &aVirtualSize) { mVirtualSize = aVirtualSize; }
-    const QString &getVirtualSize() const { return mVirtualSize; }
-
-    void setActualSize (const QString &aActualSize) { mActualSize = aActualSize; }
-    const QString &getActualSize() const { return mActualSize; }
-
-    void setUuid (const QUuid &aUuid) { mUuid = aUuid; }
-    const QUuid &getUuid() const { return mUuid; }
-
-    void setMachineId (const QUuid &aMachineId) { mMachineId = aMachineId; }
-    const QUuid &getMachineId() const { return mMachineId; }
-
-    void setStatus (VBoxMedia::Status aStatus) { mStatus = aStatus; }
-    VBoxMedia::Status getStatus() const { return mStatus; }
-
-    void setToolTip (QString aToolTip) { mToolTip = aToolTip; }
-    const QString &getToolTip() const { return mToolTip; }
-
-    QString getInformation (const QString &aInfo, bool aCompact = true,
-                            const QString &aElipsis = "middle")
-    {
-        QString compactString = QString ("<compact elipsis=\"%1\">").arg (aElipsis);
-        QString info = QString ("<nobr>%1%2%3</nobr>")
-                       .arg (aCompact ? compactString : "")
-                       .arg (aInfo.isEmpty() ?
-                             VBoxDiskImageManagerDlg::tr ("--", "no info") :
-                             aInfo)
-                       .arg (aCompact ? "</compact>" : "");
-        return info;
-    }
-
-    int rtti() const { return TypeId; }
-
-    int compare (Q3ListViewItem *aItem, int aColumn, bool aAscending) const
-    {
-        ULONG64 thisValue = vboxGlobal().parseSize (       text (aColumn));
-        ULONG64 thatValue = vboxGlobal().parseSize (aItem->text (aColumn));
-        if (thisValue && thatValue)
-        {
-            if (thisValue == thatValue)
-                return 0;
-            else
-                return thisValue > thatValue ? 1 : -1;
-        }
-        else
-            return Q3ListViewItem::compare (aItem, aColumn, aAscending);
-    }
-
-    DiskImageItem* nextSibling() const
-    {
-        return (Q3ListViewItem::nextSibling() &&
-                Q3ListViewItem::nextSibling()->rtti() == DiskImageItem::TypeId) ?
-                static_cast<DiskImageItem*> (Q3ListViewItem::nextSibling()) : 0;
-    }
-
-    void paintCell (QPainter *aPainter, const QColorGroup &aColorGroup,
-                    int aColumn, int aWidth, int aSlign)
-    {
-        QColorGroup cGroup (aColorGroup);
-        if (mStatus == VBoxMedia::Unknown)
-            cGroup.setColor (QColorGroup::Text, cGroup.mid());
-        Q3ListViewItem::paintCell (aPainter, cGroup, aColumn, aWidth, aSlign);
-    }
-
-protected:
-
-    VBoxMedia mMedia;
-
-    QString mName;
-    QString mPath;
-    QString mUsage;
-    QString mSnapshotUsage;
-    QString mSnapshotName;
-    QString mDiskType;
-    QString mStorageType;
-    QString mVirtualSize;
-    QString mActualSize;
-
-    QUuid mUuid;
-    QUuid mMachineId;
-
-    QString mToolTip;
-
-    VBoxMedia::Status mStatus;
-};
-
-
-class DiskImageItemIterator : public Q3ListViewItemIterator
-{
-public:
-
-    DiskImageItemIterator (Q3ListView* aList)
-        : Q3ListViewItemIterator (aList) {}
-
-    DiskImageItem* operator*()
-    {
-        Q3ListViewItem *item = Q3ListViewItemIterator::operator*();
-        return item && item->rtti() == DiskImageItem::TypeId ?
-            static_cast<DiskImageItem*> (item) : 0;
-    }
-
-    DiskImageItemIterator& operator++()
-    {
-        return (DiskImageItemIterator&) Q3ListViewItemIterator::operator++();
-    }
-};
-
-
-class InfoPaneLabel : public QIRichLabel
-{
-public:
-
-    InfoPaneLabel (QWidget *aParent, QLabel *aLabel = 0)
-        : QIRichLabel (aParent, "infoLabel"), mLabel (aLabel) {}
-
-    QLabel* label() { return mLabel; }
-
-private:
-
-    QLabel *mLabel;
-};
-
-
-VBoxDiskImageManagerDlg *VBoxDiskImageManagerDlg::mModelessDialog = 0;
-
-
-void VBoxDiskImageManagerDlg::showModeless (bool aRefresh /* = true */)
-{
-    if (!mModelessDialog)
-    {
-        mModelessDialog =
-            new VBoxDiskImageManagerDlg (NULL,
-                                         "VBoxDiskImageManagerDlg",
-                                         Qt::WType_TopLevel | Qt::WDestructiveClose);
-        mModelessDialog->setup (VBoxDefs::HD | VBoxDefs::CD | VBoxDefs::FD,
-                                false, NULL, aRefresh);
-
-        /* listen to events that may change the media status and refresh
-         * the contents of the modeless dialog */
-        /// @todo refreshAll() may be slow, so it may be better to analyze
-        //  event details and update only what is changed */
-        connect (&vboxGlobal(), SIGNAL (machineDataChanged (const VBoxMachineDataChangeEvent &)),
-                 mModelessDialog, SLOT (refreshAll()));
-        connect (&vboxGlobal(), SIGNAL (machineRegistered (const VBoxMachineRegisteredEvent &)),
-                 mModelessDialog, SLOT (refreshAll()));
-        connect (&vboxGlobal(), SIGNAL (snapshotChanged (const VBoxSnapshotEvent &)),
-                 mModelessDialog, SLOT (refreshAll()));
-    }
-
-    mModelessDialog->show();
-    mModelessDialog->setWindowState (mModelessDialog->windowState() &
-                                     ~Qt::WindowMinimized);
-    mModelessDialog->setActiveWindow();
-}
-
-
-void VBoxDiskImageManagerDlg::init()
-{
-    polished = false;
-
-    mInLoop = false;
-
-    defaultButton = searchDefaultButton();
-
-    vbox = vboxGlobal().virtualBox();
-    Assert (!vbox.isNull());
-
-    setIcon (QPixmap (":/diskim_16px.png"));
-
-    type = VBoxDefs::InvalidType;
-
-    QImage img =
-        QMessageBox::standardIcon (QMessageBox::Warning).convertToImage();
-    img = img.smoothScale (16, 16);
-    pxInaccessible.convertFromImage (img);
-    Assert (!pxInaccessible.isNull());
-
-    img =
-        QMessageBox::standardIcon (QMessageBox::Critical).convertToImage();
-    img = img.smoothScale (16, 16);
-    pxErroneous.convertFromImage (img);
-    Assert (!pxErroneous.isNull());
-
-    pxHD = VBoxGlobal::iconSet (":/hd_16px.png", ":/hd_disabled_16px.png");
-    pxCD = VBoxGlobal::iconSet (":/cd_16px.png", ":/cd_disabled_16px.png");
-    pxFD = VBoxGlobal::iconSet (":/fd_16px.png", ":/fd_disabled_16px.png");
-
-    /* setup tab widget icons */
-    twImages->setTabIconSet (twImages->page (0), pxHD);
-    twImages->setTabIconSet (twImages->page (1), pxCD);
-    twImages->setTabIconSet (twImages->page (2), pxFD);
-
-    /* setup image list views */
-    hdsView->setColumnAlignment (1, Qt::AlignRight);
-    hdsView->setColumnAlignment (2, Qt::AlignRight);
-    hdsView->header()->setStretchEnabled (false);
-    hdsView->header()->setStretchEnabled (true, 0);
-
-    fdsView->setColumnAlignment (1, Qt::AlignRight);
-    fdsView->header()->setStretchEnabled (false);
-    fdsView->header()->setStretchEnabled (true, 0);
-
-    cdsView->setColumnAlignment (1, Qt::AlignRight);
-    cdsView->header()->setStretchEnabled (false);
-    cdsView->header()->setStretchEnabled (true, 0);
-
-
-    /* setup list-view's item tooltip */
-    hdsView->setShowToolTips (false);
-    cdsView->setShowToolTips (false);
-    fdsView->setShowToolTips (false);
-    connect (hdsView, SIGNAL (onItem (Q3ListViewItem*)),
-             this, SLOT (mouseOnItem(Q3ListViewItem*)));
-    connect (cdsView, SIGNAL (onItem (Q3ListViewItem*)),
-             this, SLOT (mouseOnItem(Q3ListViewItem*)));
-    connect (fdsView, SIGNAL (onItem (Q3ListViewItem*)),
-             this, SLOT (mouseOnItem(Q3ListViewItem*)));
-
-
-    /* status-bar currently disabled */
-    /// @todo we must enable it and disable our size grip hack!
-    /// (at least, to have action help text showh)
-    statusBar()->setHidden (true);
-
-
-    /* context menu composing */
-    itemMenu = new Q3PopupMenu (this, "itemMenu");
-
-    imNewAction = new QAction (this, "imNewAction");
-    imAddAction = new QAction (this, "imAddAction");
-    // imEditAction = new QAction (this, "imEditAction");
-    imRemoveAction = new QAction (this, "imRemoveAction");
-    imReleaseAction = new QAction (this, "imReleaseAction");
-    imRefreshAction = new QAction (this, "imRefreshAction");
-
-    connect (imNewAction, SIGNAL (activated()),
-             this, SLOT (newImage()));
-    connect (imAddAction, SIGNAL (activated()),
-             this, SLOT (addImage()));
-    // connect (imEditAction, SIGNAL (activated()),
-    //          this, SLOT (editImage()));
-    connect (imRemoveAction, SIGNAL (activated()),
-             this, SLOT (removeImage()));
-    connect (imReleaseAction, SIGNAL (activated()),
-             this, SLOT (releaseImage()));
-    connect (imRefreshAction, SIGNAL (activated()),
-             this, SLOT (refreshAll()));
-
-    imNewAction->setIconSet (VBoxGlobal::iconSetEx (
-        ":/vdm_new_22px.png", ":/vdm_new_16px.png",
-        ":/vdm_new_disabled_22px.png", ":/vdm_new_disabled_16px.png"));
-    imAddAction->setIconSet (VBoxGlobal::iconSetEx (
-        ":/vdm_add_22px.png", ":/vdm_add_16px.png",
-        ":/vdm_add_disabled_22px.png", ":/vdm_add_disabled_16px.png"));
-    // imEditAction->setIconSet (VBoxGlobal::iconSet (":/guesttools_16px.png", ":/guesttools_disabled_16px.png"));
-    imRemoveAction->setIconSet (VBoxGlobal::iconSetEx (
-        ":/vdm_remove_22px.png", ":/vdm_remove_16px.png",
-        ":/vdm_remove_disabled_22px.png", ":/vdm_remove_disabled_16px.png"));
-    imReleaseAction->setIconSet (VBoxGlobal::iconSetEx (
-        ":/vdm_release_22px.png", ":/vdm_release_16px.png",
-        ":/vdm_release_disabled_22px.png", ":/vdm_release_disabled_16px.png"));
-    imRefreshAction->setIconSet (VBoxGlobal::iconSetEx (
-        ":/refresh_22px.png", ":/refresh_16px.png",
-        ":/refresh_disabled_22px.png", ":/refresh_disabled_16px.png"));
-
-    // imEditAction->addTo (itemMenu);
-    imRemoveAction->addTo (itemMenu);
-    imReleaseAction->addTo (itemMenu);
-
-
-    /* toolbar composing */
-#warning port me
-//    toolBar = new VBoxToolBar (this, centralWidget());
-    toolBar->setSizePolicy (QSizePolicy::Fixed, QSizePolicy::Minimum);
-    ((Q3VBoxLayout*)centralWidget()->layout())->insertWidget(0, toolBar);
-
-    toolBar->setUsesTextLabel (true);
-    toolBar->setUsesBigPixmaps (true);
-
-    imNewAction->addTo (toolBar);
-    imAddAction->addTo (toolBar);
-    toolBar->addSeparator();
-    // imEditAction->addTo (toolBar);
-    imRemoveAction->addTo (toolBar);
-    imReleaseAction->addTo (toolBar);
-    toolBar->addSeparator();
-    imRefreshAction->addTo (toolBar);
-#ifdef Q_WS_MAC
-    toolBar->setMacStyle();
-#endif
-
-
-    /* menu bar */
-    Q3PopupMenu *actionMenu = new Q3PopupMenu (this, "actionMenu");
-    imNewAction->addTo    (actionMenu);
-    imAddAction->addTo    (actionMenu);
-    actionMenu->insertSeparator();
-    // imEditAction->addTo (toolBar);
-    imRemoveAction->addTo (actionMenu);
-    imReleaseAction->addTo (actionMenu);
-    actionMenu->insertSeparator();
-    imRefreshAction->addTo (actionMenu);
-    menuBar()->insertItem (QString::null, actionMenu, 1);
-
-
-    /* setup size grip */
-    sizeGrip = new QSizeGrip (centralWidget(), "sizeGrip");
-    sizeGrip->resize (sizeGrip->sizeHint());
-    sizeGrip->stackUnder(buttonOk);
-
-    /* setup information pane */
-    QApplication::setGlobalMouseTracking (true);
-    qApp->installEventFilter (this);
-    /* setup information pane layouts */
-    Q3GridLayout *hdsContainerLayout = new Q3GridLayout (hdsContainer, 4, 4);
-    hdsContainerLayout->setMargin (10);
-    Q3GridLayout *cdsContainerLayout = new Q3GridLayout (cdsContainer, 2, 4);
-    cdsContainerLayout->setMargin (10);
-    Q3GridLayout *fdsContainerLayout = new Q3GridLayout (fdsContainer, 2, 4);
-    fdsContainerLayout->setMargin (10);
-    /* create info-pane for hd list-view */
-    createInfoString (hdsPane1, hdsContainer, 0, -1);
-    createInfoString (hdsPane2, hdsContainer, 1, 0);
-    createInfoString (hdsPane3, hdsContainer, 1, 1);
-    createInfoString (hdsPane4, hdsContainer, 2, 0);
-    createInfoString (hdsPane5, hdsContainer, 2, 1);
-    /* create info-pane for cd list-view */
-    createInfoString (cdsPane1, cdsContainer, 0, -1);
-    createInfoString (cdsPane2, cdsContainer, 1, -1);
-    /* create info-pane for fd list-view */
-    createInfoString (fdsPane1, fdsContainer, 0, -1);
-    createInfoString (fdsPane2, fdsContainer, 1, -1);
-
-
-    /* enumeration progressbar creation */
-    mProgressText = new QLabel (centralWidget());
-    mProgressText->setHidden (true);
-#warning port me
-//    buttonLayout->insertWidget (2, mProgressText);
-    mProgressBar = new Q3ProgressBar (centralWidget());
-    mProgressBar->setHidden (true);
-    mProgressBar->setFrameShadow (Q3Frame::Sunken);
-    mProgressBar->setFrameShape  (Q3Frame::Panel);
-    mProgressBar->setPercentageVisible (false);
-    mProgressBar->setMaximumWidth (100);
-#warning port me
-//    buttonLayout->insertWidget (3, mProgressBar);
-
-
-    /* applying language settings */
-    languageChangeImp();
-}
-
-
-void VBoxDiskImageManagerDlg::languageChangeImp()
-{
-    imNewAction->setMenuText (tr ("&New..."));
-    imAddAction->setMenuText (tr ("&Add..."));
-    // imEditAction->setMenuText (tr ("&Edit..."));
-    imRemoveAction->setMenuText (tr ("R&emove"));
-    imReleaseAction->setMenuText (tr ("Re&lease"));
-    imRefreshAction->setMenuText (tr ("Re&fresh"));
-
-    imNewAction->setText (tr ("New"));
-    imAddAction->setText (tr ("Add"));
-    // imEditAction->setText (tr ("Edit"));
-    imRemoveAction->setText (tr ("Remove"));
-    imReleaseAction->setText (tr ("Release"));
-    imRefreshAction->setText (tr ("Refresh"));
-
-    imNewAction->setAccel (tr ("Ctrl+N"));
-    imAddAction->setAccel (tr ("Ctrl+A"));
-    // imEditAction->setAccel (tr ("Ctrl+E"));
-    imRemoveAction->setAccel (tr ("Ctrl+D"));
-    imReleaseAction->setAccel (tr ("Ctrl+L"));
-    imRefreshAction->setAccel (tr ("Ctrl+R"));
-
-    imNewAction->setStatusTip (tr ("Create a new virtual hard disk"));
-    imAddAction->setStatusTip (tr ("Add (register) an existing image file"));
-    // imEditAction->setStatusTip (tr ("Edit the properties of the selected item"));
-    imRemoveAction->setStatusTip (tr ("Remove (unregister) the selected media"));
-    imReleaseAction->setStatusTip (tr ("Release the selected media by detaching it from the machine"));
-    imRefreshAction->setStatusTip (tr ("Refresh the media list"));
-
-    if (menuBar()->findItem(1))
-        menuBar()->findItem(1)->setText (tr ("&Actions"));
-
-    hdsPane1->label()->setText (QString ("<nobr>%1:</nobr>").arg (tr ("Location")));
-    hdsPane2->label()->setText (QString ("<nobr>%1:</nobr>").arg (tr ("Disk Type")));
-    hdsPane3->label()->setText (QString ("<nobr>&nbsp;&nbsp;%1:</nobr>").arg (tr ("Storage Type")));
-    hdsPane4->label()->setText (QString ("<nobr>%1:</nobr>").arg (tr ("Attached to")));
-    hdsPane5->label()->setText (QString ("<nobr>&nbsp;&nbsp;%1:</nobr>").arg (tr ("Snapshot")));
-    cdsPane1->label()->setText (QString ("<nobr>%1:</nobr>").arg (tr ("Location")));
-    cdsPane2->label()->setText (QString ("<nobr>%1:</nobr>").arg (tr ("Attached to")));
-    fdsPane1->label()->setText (QString ("<nobr>%1:</nobr>").arg (tr ("Location")));
-    fdsPane2->label()->setText (QString ("<nobr>%1:</nobr>").arg (tr ("Attached to")));
-
-    mProgressText->setText (tr ("Checking accessibility"));
-
-    if (hdsView->childCount() || cdsView->childCount() || fdsView->childCount())
-        refreshAll();
-}
-
-
-void VBoxDiskImageManagerDlg::createInfoString (InfoPaneLabel *&aInfo,
-                                                QWidget *aRoot,
-                                                int aRow, int aColumn)
-{
-    QLabel *nameLabel = new QLabel (aRoot);
-    aInfo = new InfoPaneLabel (aRoot, nameLabel);
-
-    /* Setup focus policy <strong> default for info pane */
-    aInfo->setFocusPolicy (Qt::StrongFocus);
-
-    /* prevent the name columns from being expanded */
-    nameLabel->setSizePolicy (QSizePolicy::Fixed, QSizePolicy::Fixed);
-
-    if (aColumn == -1)
-    {
-        ((Q3GridLayout *) aRoot->layout())->addWidget (nameLabel, aRow, 0);
-        ((Q3GridLayout *) aRoot->layout())->
-            addMultiCellWidget (aInfo, aRow, aRow,
-                                1, ((Q3GridLayout *) aRoot->layout())->numCols() - 1);
-    }
-    else
-    {
-        ((Q3GridLayout *) aRoot->layout())->addWidget (nameLabel, aRow, aColumn * 2);
-        ((Q3GridLayout *) aRoot->layout())->addWidget (aInfo, aRow, aColumn * 2 + 1);
-    }
-}
-
-
-void VBoxDiskImageManagerDlg::showEvent (QShowEvent *e)
-{
-    Q3MainWindow::showEvent (e);
-
-    /* one may think that QWidget::polish() is the right place to do things
-     * below, but apparently, by the time when QWidget::polish() is called,
-     * the widget style & layout are not fully done, at least the minimum
-     * size hint is not properly calculated. Since this is sometimes necessary,
-     * we provide our own "polish" implementation. */
-
-    if (polished)
-        return;
-
-    polished = true;
-
-    VBoxGlobal::centerWidget (this, parentWidget());
-}
-
-
-void VBoxDiskImageManagerDlg::mouseOnItem (Q3ListViewItem *aItem)
-{
-    Q3ListView *currentList = getCurrentListView();
-    QString tip;
-    switch (aItem->rtti())
-    {
-        case DiskImageItem::TypeId:
-            tip = static_cast<DiskImageItem*> (aItem)->getToolTip();
-            break;
-        default:
-            Assert (0);
-    }
-    QToolTip::add (currentList->viewport(), currentList->itemRect (aItem), tip);
-}
-
-
-void VBoxDiskImageManagerDlg::resizeEvent (QResizeEvent*)
-{
-    sizeGrip->move (centralWidget()->rect().bottomRight() -
-                    QPoint(sizeGrip->rect().width() - 1, sizeGrip->rect().height() - 1));
-}
-
-
-void VBoxDiskImageManagerDlg::closeEvent (QCloseEvent *aEvent)
-{
-    mModelessDialog = 0;
-    aEvent->accept();
-}
-
-
-void VBoxDiskImageManagerDlg::keyPressEvent (QKeyEvent *aEvent)
-{
-    if ( aEvent->state() == 0 ||
-         (aEvent->state() & Qt::KeypadModifier && aEvent->key() == Qt::Key_Enter) )
-    {
-        switch ( aEvent->key() )
-        {
-            case Qt::Key_Enter:
-            case Qt::Key_Return:
-            {
-                QPushButton *currentDefault = searchDefaultButton();
-                if (currentDefault)
-                    currentDefault->animateClick();
-                break;
-            }
-            case Qt::Key_Escape:
-            {
-                reject();
-                break;
-            }
-        }
-    }
-    else
-        aEvent->ignore();
-}
-
-
-QPushButton* VBoxDiskImageManagerDlg::searchDefaultButton()
-{
-    QPushButton *defButton = 0;
-    QObjectList list = queryList ("QPushButton");
-    QListIterator<QObject*> it (list);
-    foreach(QObject *o, list)
-    {
-        defButton = qobject_cast<QPushButton*> (o);
-        if(defButton->isDefault())
-            break;
-    }
-    return defButton;
-}
-
-
-int  VBoxDiskImageManagerDlg::result() { return mRescode; }
-void VBoxDiskImageManagerDlg::setResult (int aRescode) { mRescode = aRescode; }
-void VBoxDiskImageManagerDlg::accept() { done( Accepted ); }
-void VBoxDiskImageManagerDlg::reject() { done( Rejected ); }
-
-int  VBoxDiskImageManagerDlg::exec()
-{
-    setResult (0);
-
-    if (mInLoop) return result();
-    show();
-    mInLoop = true;
-#warning port me
-//    qApp->eventLoop()->enterLoop();
-    mInLoop = false;
-
-    return result();
-}
-
-void VBoxDiskImageManagerDlg::done (int aResult)
-{
-    setResult (aResult);
-
-    if (mInLoop)
-    {
-        hide();
-#warning port me
-//        qApp->eventLoop()->exitLoop();
-    }
-    else
-    {
-        close();
-    }
-}
-
-
-Q3ListView* VBoxDiskImageManagerDlg::getCurrentListView()
-{
-    Q3ListView *clv = static_cast<Q3ListView*>(twImages->currentPage()->
-        queryList("QListView").first());
-    Assert(clv);
-    return clv;
-}
-
-Q3ListView* VBoxDiskImageManagerDlg::getListView (VBoxDefs::DiskType aType)
-{
-    switch (aType)
-    {
-        case VBoxDefs::HD:
-            return hdsView;
-        case VBoxDefs::CD:
-            return cdsView;
-        case VBoxDefs::FD:
-            return fdsView;
-        default:
-            return 0;
-    }
-}
-
-
-bool VBoxDiskImageManagerDlg::eventFilter (QObject *aObject, QEvent *aEvent)
-{
-    Q3ListView *currentList = getCurrentListView();
-
-    switch (aEvent->type())
-    {
-        case QEvent::DragEnter:
-        {
-            if (aObject == currentList)
-            {
-                QDragEnterEvent *dragEnterEvent =
-                    static_cast<QDragEnterEvent*>(aEvent);
-                dragEnterEvent->acceptAction();
-                return true;
-            }
-            break;
-        }
-        case QEvent::Drop:
-        {
-            if (aObject == currentList)
-            {
-                QDropEvent *dropEvent =
-                    static_cast<QDropEvent*>(aEvent);
-                QStringList *droppedList = new QStringList();
-                Q3UriDrag::decodeLocalFiles (dropEvent, *droppedList);
-                QCustomEvent *updateEvent = new QCustomEvent (1001);
-                updateEvent->setData (droppedList);
-                QApplication::postEvent (currentList, updateEvent);
-                dropEvent->acceptAction();
-                return true;
-            }
-            break;
-        }
-        case 1001: /* QCustomEvent 1001 - DnD Update Event */
-        {
-            if (aObject == currentList)
-            {
-                QCustomEvent *updateEvent =
-                    static_cast<QCustomEvent*>(aEvent);
-                addDroppedImages ((QStringList*) updateEvent->data());
-                return true;
-            }
-            break;
-        }
-        case QEvent::FocusIn:
-        {
-            if (aObject->inherits ("QPushButton") && aObject->parent() == centralWidget())
-            {
-                ((QPushButton*)aObject)->setDefault (aObject != defaultButton);
-                if (defaultButton)
-                    defaultButton->setDefault (aObject == defaultButton);
-            }
-            break;
-        }
-        case QEvent::FocusOut:
-        {
-            if (aObject->inherits ("QPushButton") && aObject->parent() == centralWidget())
-            {
-                if (defaultButton)
-                    defaultButton->setDefault (aObject != defaultButton);
-                ((QPushButton*)aObject)->setDefault (aObject == defaultButton);
-            }
-            break;
-        }
-        default:
-            break;
-    }
-    return Q3MainWindow::eventFilter (aObject, aEvent);
-}
-
-
-bool VBoxDiskImageManagerDlg::event (QEvent *aEvent)
-{
-    bool result = Q3MainWindow::event (aEvent);
-    switch (aEvent->type())
-    {
-        case QEvent::LanguageChange:
-        {
-            languageChangeImp();
-            break;
-        }
-        default:
-            break;
-    }
-    return result;
-}
-
-
-void VBoxDiskImageManagerDlg::addDroppedImages (QStringList *aDroppedList)
-{
-    Q3ListView *currentList = getCurrentListView();
-
-    for (QStringList::Iterator it = (*aDroppedList).begin();
-         it != (*aDroppedList).end(); ++it)
-    {
-        QString src = *it;
-        /* Check dropped media type */
-        /// @todo On OS/2 and windows (and mac?) extension checks should be case
-        /// insensitive, as OPPOSED to linux and the rest where case matters.
-        VBoxDefs::DiskType type = VBoxDefs::InvalidType;
-        if      (src.endsWith (".iso", false))
-        {
-            if (currentList == cdsView) type = VBoxDefs::CD;
-        }
-        else if (src.endsWith (".img", false))
-        {
-            if (currentList == fdsView) type = VBoxDefs::FD;
-        }
-        else if (src.endsWith (".vdi", false) ||
-                 src.endsWith (".vmdk", false))
-        {
-            if (currentList == hdsView) type = VBoxDefs::HD;
-        }
-        /* If media type has been determined - attach this device */
-        if (type)
-        {
-            addImageToList (*it, type);
-            if (!vbox.isOk())
-                vboxProblem().cannotRegisterMedia (this, vbox, type, src);
-        }
-    }
-    delete aDroppedList;
-}
-
-
-void VBoxDiskImageManagerDlg::addImageToList (const QString &aSource,
-                                              VBoxDefs::DiskType aDiskType)
-{
-    if (aSource.isEmpty())
-        return;
-
-    QUuid uuid;
-    VBoxMedia media;
-    switch (aDiskType)
-    {
-        case VBoxDefs::HD:
-        {
-            CHardDisk hd = vbox.OpenHardDisk (aSource);
-            if (vbox.isOk())
-            {
-                vbox.RegisterHardDisk (hd);
-                if (vbox.isOk())
-                {
-                    VBoxMedia::Status status =
-                        hd.GetAccessible() ? VBoxMedia::Ok :
-                        hd.isOk() ? VBoxMedia::Inaccessible :
-                        VBoxMedia::Error;
-                    media = VBoxMedia (CUnknown (hd), VBoxDefs::HD, status);
-                }
-            }
-            break;
-        }
-        case VBoxDefs::CD:
-        {
-            CDVDImage cd = vbox.OpenDVDImage (aSource, uuid);
-            if (vbox.isOk())
-            {
-                vbox.RegisterDVDImage (cd);
-                if (vbox.isOk())
-                {
-                    VBoxMedia::Status status =
-                        cd.GetAccessible() ? VBoxMedia::Ok :
-                        cd.isOk() ? VBoxMedia::Inaccessible :
-                        VBoxMedia::Error;
-                    media = VBoxMedia (CUnknown (cd), VBoxDefs::CD, status);
-                }
-            }
-            break;
-        }
-        case VBoxDefs::FD:
-        {
-            CFloppyImage fd = vbox.OpenFloppyImage (aSource, uuid);
-            if (vbox.isOk())
-            {
-                vbox.RegisterFloppyImage (fd);
-                if (vbox.isOk())
-                {
-                    VBoxMedia::Status status =
-                        fd.GetAccessible() ? VBoxMedia::Ok :
-                        fd.isOk() ? VBoxMedia::Inaccessible :
-                        VBoxMedia::Error;
-                    media = VBoxMedia (CUnknown (fd), VBoxDefs::FD, status);
-                }
-            }
-            break;
-        }
-        default:
-            AssertMsgFailed (("Invalid aDiskType type\n"));
-    }
-    if (media.type != VBoxDefs::InvalidType)
-        vboxGlobal().addMedia (media);
-}
-
-
-DiskImageItem* VBoxDiskImageManagerDlg::createImageNode (Q3ListView *aList,
-                                                         DiskImageItem *aRoot,
-                                                         const VBoxMedia &aMedia)
-{
-    DiskImageItem *item = 0;
-
-    if (aRoot)
-        item = new DiskImageItem (aRoot);
-    else if (aList)
-        item = new DiskImageItem (aList);
-    else
-        Assert (0);
-
-    item->setMedia (aMedia);
-
-    return item;
-}
-
-
-void VBoxDiskImageManagerDlg::invokePopup (Q3ListViewItem *aItem, const QPoint & aPos, int)
-{
-    if (aItem)
-        itemMenu->popup(aPos);
-}
-
-
-QString VBoxDiskImageManagerDlg::getDVDImageUsage (const QUuid &aId,
-                                                   QString &aSnapshotUsage)
-{
-    CVirtualBox vbox = vboxGlobal().virtualBox();
-
-    QStringList permMachines =
-        QStringList::split (' ', vbox.GetDVDImageUsage (aId, KResourceUsage_Permanent));
-    QStringList tempMachines =
-        QStringList::split (' ', vbox.GetDVDImageUsage (aId, KResourceUsage_Temporary));
-
-    QString usage;
-
-    for (QStringList::Iterator it = permMachines.begin();
-         it != permMachines.end();
-         ++it)
-    {
-        if (!usage.isEmpty())
-            usage += ", ";
-        CMachine machine = vbox.GetMachine (QUuid (*it));
-        usage += machine.GetName();
-
-        getDVDImageSnapshotUsage (aId, machine.GetSnapshot (QUuid()),
-                                  aSnapshotUsage);
-    }
-
-    for (QStringList::Iterator it = tempMachines.begin();
-         it != tempMachines.end();
-         ++it)
-    {
-        /* skip IDs that are in the permanent list */
-        if (!permMachines.contains (*it))
-        {
-            if (!usage.isEmpty())
-                usage += ", [";
-            else
-                usage += "[";
-            CMachine machine = vbox.GetMachine (QUuid (*it));
-            usage += machine.GetName() + "]";
-
-            getDVDImageSnapshotUsage (aId, machine.GetSnapshot (QUuid()),
-                                      aSnapshotUsage);
-        }
-    }
-
-    return usage;
-}
-
-QString VBoxDiskImageManagerDlg::getFloppyImageUsage (const QUuid &aId,
-                                                      QString &aSnapshotUsage)
-{
-    CVirtualBox vbox = vboxGlobal().virtualBox();
-
-    QStringList permMachines =
-        QStringList::split (' ', vbox.GetFloppyImageUsage (aId, KResourceUsage_Permanent));
-    QStringList tempMachines =
-        QStringList::split (' ', vbox.GetFloppyImageUsage (aId, KResourceUsage_Temporary));
-
-    QString usage;
-
-    for (QStringList::Iterator it = permMachines.begin();
-         it != permMachines.end();
-         ++it)
-    {
-        if (!usage.isEmpty())
-            usage += ", ";
-        CMachine machine = vbox.GetMachine (QUuid (*it));
-        usage += machine.GetName();
-
-        getFloppyImageSnapshotUsage (aId, machine.GetSnapshot (QUuid()),
-                                     aSnapshotUsage);
-    }
-
-    for (QStringList::Iterator it = tempMachines.begin();
-         it != tempMachines.end();
-         ++it)
-    {
-        /* skip IDs that are in the permanent list */
-        if (!permMachines.contains (*it))
-        {
-            if (!usage.isEmpty())
-                usage += ", [";
-            else
-                usage += "[";
-            CMachine machine = vbox.GetMachine (QUuid (*it));
-            usage += machine.GetName() + "]";
-
-            getFloppyImageSnapshotUsage (aId, machine.GetSnapshot (QUuid()),
-                                         aSnapshotUsage);
-        }
-    }
-
-    return usage;
-}
-
-
-void VBoxDiskImageManagerDlg::getDVDImageSnapshotUsage (const QUuid &aImageId,
-                                                        const CSnapshot &aSnapshot,
-                                                        QString &aUsage)
-{
-    if (aSnapshot.isNull())
-        return;
-
-    if (!aSnapshot.GetMachine().GetDVDDrive().GetImage().isNull() &&
-        aSnapshot.GetMachine().GetDVDDrive().GetImage().GetId() == aImageId)
-    {
-        if (!aUsage.isEmpty())
-            aUsage += ", ";
-        aUsage += aSnapshot.GetName();
-    }
-
-    CSnapshotEnumerator en = aSnapshot.GetChildren().Enumerate();
-    while (en.HasMore())
-        getDVDImageSnapshotUsage (aImageId, en.GetNext(), aUsage);
-}
-
-void VBoxDiskImageManagerDlg::getFloppyImageSnapshotUsage (const QUuid &aImageId,
-                                                           const CSnapshot &aSnapshot,
-                                                           QString &aUsage)
-{
-    if (aSnapshot.isNull())
-        return;
-
-    if (!aSnapshot.GetMachine().GetFloppyDrive().GetImage().isNull() &&
-        aSnapshot.GetMachine().GetFloppyDrive().GetImage().GetId() == aImageId)
-    {
-        if (!aUsage.isEmpty())
-            aUsage += ", ";
-        aUsage += aSnapshot.GetName();
-    }
-
-    CSnapshotEnumerator en = aSnapshot.GetChildren().Enumerate();
-    while (en.HasMore())
-        getFloppyImageSnapshotUsage (aImageId, en.GetNext(), aUsage);
-}
-
-
-QString VBoxDiskImageManagerDlg::composeHdToolTip (CHardDisk &aHd,
-                                                   VBoxMedia::Status aStatus,
-                                                   DiskImageItem *aItem)
-{
-    CVirtualBox vbox = vboxGlobal().virtualBox();
-    QUuid machineId = aItem ? aItem->getMachineId() : aHd.GetMachineId();
-
-    QString src = aItem ? aItem->getPath() : aHd.GetLocation();
-    QString location = aItem || aHd.GetStorageType() == KHardDiskStorageType_ISCSIHardDisk ? src :
-        QDir::convertSeparators (QFileInfo (src).absFilePath());
-
-    QString storageType = aItem ? aItem->getStorageType() :
-        vboxGlobal().toString (aHd.GetStorageType());
-    QString hardDiskType = aItem ? aItem->getDiskType() :
-        vboxGlobal().hardDiskTypeString (aHd);
-
-    QString usage;
-    if (aItem)
-        usage = aItem->getUsage();
-    else if (!machineId.isNull())
-        usage = vbox.GetMachine (machineId).GetName();
-
-    QUuid snapshotId = aItem ? aItem->getUuid() : aHd.GetSnapshotId();
-    QString snapshotName;
-    if (aItem)
-        snapshotName = aItem->getSnapshotName();
-    else if (!machineId.isNull() && !snapshotId.isNull())
-    {
-        CSnapshot snapshot = vbox.GetMachine (machineId).
-                                  GetSnapshot (aHd.GetSnapshotId());
-        if (!snapshot.isNull())
-            snapshotName = snapshot.GetName();
-    }
-
-    /* compose tool-tip information */
-    QString tip;
-    switch (aStatus)
-    {
-        case VBoxMedia::Unknown:
-        {
-            tip = tr ("<nobr><b>%1</b></nobr><br>"
-                      "Checking accessibility...", "HDD")
-                      .arg (location);
-            break;
-        }
-        case VBoxMedia::Ok:
-        {
-            tip = tr ("<nobr><b>%1</b></nobr><br>"
-                      "<nobr>Disk type:&nbsp;&nbsp;%2</nobr><br>"
-                      "<nobr>Storage type:&nbsp;&nbsp;%3</nobr>")
-                      .arg (location)
-                      .arg (hardDiskType)
-                      .arg (storageType);
-
-            if (!usage.isNull())
-                tip += tr ("<br><nobr>Attached to:&nbsp;&nbsp;%1</nobr>", "HDD")
-                           .arg (usage);
-            if (!snapshotName.isNull())
-                tip += tr ("<br><nobr>Snapshot:&nbsp;&nbsp;%5</nobr>", "HDD")
-                           .arg (snapshotName);
-            break;
-        }
-        case VBoxMedia::Error:
-        {
-            /// @todo (r=dmik) paass a complete VBoxMedia instance here
-            //  to get the result of blabla.GetAccessible() call form CUnknown
-            tip = tr ("<nobr><b>%1</b></nobr><br>"
-                      "Error checking media accessibility", "HDD")
-                      .arg (location);
-            break;
-        }
-        case VBoxMedia::Inaccessible:
-        {
-            tip = tr ("<nobr><b>%1</b></nobr><br>%2", "HDD")
-                      .arg (location)
-                      .arg (VBoxGlobal::highlight (aHd.GetLastAccessError(),
-                                                   true /* aToolTip */));
-            break;
-        }
-        default:
-            AssertFailed();
-    }
-    return tip;
-}
-
-QString VBoxDiskImageManagerDlg::composeCdToolTip (CDVDImage &aCd,
-                                                   VBoxMedia::Status aStatus,
-                                                   DiskImageItem *aItem)
-{
-    QString location = aItem ? aItem->getPath() :
-        QDir::convertSeparators (QFileInfo (aCd.GetFilePath()).absFilePath());
-    QUuid uuid = aItem ? aItem->getUuid() : aCd.GetId();
-    QString usage;
-    if (aItem)
-        usage = aItem->getTotalUsage();
-    else
-    {
-        QString snapshotUsage;
-        usage = getDVDImageUsage (uuid, snapshotUsage);
-        /* should correlate with DiskImageItem::getTotalUsage() */
-        if (!snapshotUsage.isNull())
-            usage = QString ("%1 (%2)").arg (usage, snapshotUsage);
-    }
-
-    /* compose tool-tip information */
-    QString tip;
-    switch (aStatus)
-    {
-        case VBoxMedia::Unknown:
-        {
-            tip = tr ("<nobr><b>%1</b></nobr><br>"
-                      "Checking accessibility...", "CD/DVD/Floppy")
-                      .arg (location);
-            break;
-        }
-        case VBoxMedia::Ok:
-        {
-            tip = tr ("<nobr><b>%1</b></nobr>", "CD/DVD/Floppy")
-                      .arg (location);
-
-            if (!usage.isNull())
-                tip += tr ("<br><nobr>Attached to:&nbsp;&nbsp;%1</nobr>",
-                           "CD/DVD/Floppy")
-                           .arg (usage);
-            break;
-        }
-        case VBoxMedia::Error:
-        {
-            /// @todo (r=dmik) paass a complete VBoxMedia instance here
-            //  to get the result of blabla.GetAccessible() call form CUnknown
-            tip = tr ("<nobr><b>%1</b></nobr><br>"
-                      "Error checking media accessibility", "CD/DVD/Floppy")
-                      .arg (location);
-            break;
-        }
-        case VBoxMedia::Inaccessible:
-        {
-            /// @todo (r=dmik) correct this when GetLastAccessError() is
-            //  implemented for IDVDImage
-            tip = tr ("<nobr><b>%1</b></nobr><br>%2")
-                      .arg (location)
-                      .arg (tr ("The image file is not accessible",
-                                "CD/DVD/Floppy"));
-            break;
-        }
-        default:
-            AssertFailed();
-    }
-    return tip;
-}
-
-QString VBoxDiskImageManagerDlg::composeFdToolTip (CFloppyImage &aFd,
-                                                   VBoxMedia::Status aStatus,
-                                                   DiskImageItem *aItem)
-{
-    QString location = aItem ? aItem->getPath() :
-        QDir::convertSeparators (QFileInfo (aFd.GetFilePath()).absFilePath());
-    QUuid uuid = aItem ? aItem->getUuid() : aFd.GetId();
-    QString usage;
-    if (aItem)
-        usage = aItem->getTotalUsage();
-    else
-    {
-        QString snapshotUsage;
-        usage = getFloppyImageUsage (uuid, snapshotUsage);
-        /* should correlate with DiskImageItem::getTotalUsage() */
-        if (!snapshotUsage.isNull())
-            usage = QString ("%1 (%2)").arg (usage, snapshotUsage);
-    }
-
-    /* compose tool-tip information */
-    QString tip;
-    switch (aStatus)
-    {
-        case VBoxMedia::Unknown:
-        {
-            tip = tr ("<nobr><b>%1</b></nobr><br>"
-                      "Checking accessibility...", "CD/DVD/Floppy")
-                      .arg (location);
-            break;
-        }
-        case VBoxMedia::Ok:
-        {
-            tip = tr ("<nobr><b>%1</b></nobr>", "CD/DVD/Floppy")
-                      .arg (location);
-
-            if (!usage.isNull())
-                tip += tr ("<br><nobr>Attached to:&nbsp;&nbsp;%1</nobr>",
-                           "CD/DVD/Floppy")
-                           .arg (usage);
-            break;
-        }
-        case VBoxMedia::Error:
-        {
-            /// @todo (r=dmik) paass a complete VBoxMedia instance here
-            //  to get the result of blabla.GetAccessible() call form CUnknown
-            tip = tr ("<nobr><b>%1</b></nobr><br>"
-                      "Error checking media accessibility", "CD/DVD/Floppy")
-                      .arg (location);
-            break;
-        }
-        case VBoxMedia::Inaccessible:
-        {
-            /// @todo (r=dmik) correct this when GetLastAccessError() is
-            //  implemented for IDVDImage
-            tip = tr ("<nobr><b>%1</b></nobr><br>%2")
-                      .arg (location)
-                      .arg (tr ("The image file is not accessible",
-                                "CD/DVD/Floppy"));
-            break;
-        }
-        default:
-            AssertFailed();
-    }
-    return tip;
-}
-
-
-void VBoxDiskImageManagerDlg::updateHdItem (DiskImageItem   *aItem,
-                                            const VBoxMedia &aMedia)
-{
-    if (!aItem)
-        return;
-
-    CHardDisk hd = aMedia.disk;
-    VBoxMedia::Status status = aMedia.status;
-
-    QUuid uuid = hd.GetId();
-    QString src = hd.GetLocation();
-    QUuid machineId = hd.GetMachineId();
-    QString usage;
-    if (!machineId.isNull())
-        usage = vbox.GetMachine (machineId).GetName();
-    QString storageType = vboxGlobal().toString (hd.GetStorageType());
-    QString hardDiskType = vboxGlobal().hardDiskTypeString (hd);
-    QString virtualSize = status == VBoxMedia::Ok ?
-        vboxGlobal().formatSize ((ULONG64)hd.GetSize() * _1M) : QString ("--");
-    QString actualSize = status == VBoxMedia::Ok ?
-        vboxGlobal().formatSize (hd.GetActualSize()) : QString ("--");
-    QString snapshotName;
-    if (!machineId.isNull() && !hd.GetSnapshotId().isNull())
-    {
-        CSnapshot snapshot = vbox.GetMachine (machineId).
-                                  GetSnapshot (hd.GetSnapshotId());
-        if (!snapshot.isNull())
-            snapshotName = QString ("%1").arg (snapshot.GetName());
-    }
-    QFileInfo fi (src);
-
-    aItem->setText (0, fi.fileName());
-    aItem->setText (1, virtualSize);
-    aItem->setText (2, actualSize);
-    aItem->setPath (hd.GetStorageType() == KHardDiskStorageType_ISCSIHardDisk ? src :
-                    QDir::convertSeparators (fi.absFilePath()));
-    aItem->setUsage (usage);
-    aItem->setSnapshotName (snapshotName);
-    aItem->setDiskType (hardDiskType);
-    aItem->setStorageType (storageType);
-    aItem->setVirtualSize (virtualSize);
-    aItem->setActualSize (actualSize);
-    aItem->setUuid (uuid);
-    aItem->setMachineId (machineId);
-    aItem->setToolTip (composeHdToolTip (hd, status, aItem));
-    aItem->setStatus (status);
-
-    makeWarningMark (aItem, aMedia.status, VBoxDefs::HD);
-}
-
-void VBoxDiskImageManagerDlg::updateCdItem (DiskImageItem   *aItem,
-                                            const VBoxMedia &aMedia)
-{
-    if (!aItem)
-        return;
-
-    CDVDImage cd = aMedia.disk;
-    VBoxMedia::Status status = aMedia.status;
-
-    QUuid uuid = cd.GetId();
-    QString src = cd.GetFilePath();
-    QString snapshotUsage;
-    QString usage = getDVDImageUsage (uuid, snapshotUsage);
-    QString size = status == VBoxMedia::Ok ?
-        vboxGlobal().formatSize (cd.GetSize()) : QString ("--");
-    QFileInfo fi (src);
-
-    aItem->setText (0, fi.fileName());
-    aItem->setText (1, size);
-    aItem->setPath (QDir::convertSeparators (fi.absFilePath ()));
-    aItem->setUsage (usage);
-    aItem->setSnapshotUsage (snapshotUsage);
-    aItem->setActualSize (size);
-    aItem->setUuid (uuid);
-    aItem->setToolTip (composeCdToolTip (cd, status, aItem));
-    aItem->setStatus (status);
-
-    makeWarningMark (aItem, aMedia.status, VBoxDefs::CD);
-}
-
-void VBoxDiskImageManagerDlg::updateFdItem (DiskImageItem   *aItem,
-                                            const VBoxMedia &aMedia)
-{
-    if (!aItem)
-        return;
-
-    CFloppyImage fd = aMedia.disk;
-    VBoxMedia::Status status = aMedia.status;
-
-    QUuid uuid = fd.GetId();
-    QString src = fd.GetFilePath();
-    QString snapshotUsage;
-    QString usage = getFloppyImageUsage (uuid, snapshotUsage);
-    QString size = status == VBoxMedia::Ok ?
-        vboxGlobal().formatSize (fd.GetSize()) : QString ("--");
-    QFileInfo fi (src);
-
-    aItem->setText (0, fi.fileName());
-    aItem->setText (1, size);
-    aItem->setPath (QDir::convertSeparators (fi.absFilePath ()));
-    aItem->setUsage (usage);
-    aItem->setSnapshotUsage (snapshotUsage);
-    aItem->setActualSize (size);
-    aItem->setUuid (uuid);
-    aItem->setToolTip (composeFdToolTip (fd, status, aItem));
-    aItem->setStatus (status);
-
-    makeWarningMark (aItem, aMedia.status, VBoxDefs::FD);
-}
-
-
-DiskImageItem* VBoxDiskImageManagerDlg::createHdItem (Q3ListView *aList,
-                                                      const VBoxMedia &aMedia)
-{
-    CHardDisk hd = aMedia.disk;
-    QUuid rootId = hd.GetParent().isNull() ? QUuid() : hd.GetParent().GetId();
-    DiskImageItem *root = searchItem (aList, rootId);
-    DiskImageItem *item = createImageNode (aList, root, aMedia);
-    updateHdItem (item, aMedia);
-    return item;
-}
-
-DiskImageItem* VBoxDiskImageManagerDlg::createCdItem (Q3ListView *aList,
-                                                      const VBoxMedia &aMedia)
-{
-    DiskImageItem *item = createImageNode (aList, 0, aMedia);
-    updateCdItem (item, aMedia);
-    return item;
-}
-
-DiskImageItem* VBoxDiskImageManagerDlg::createFdItem (Q3ListView *aList,
-                                                      const VBoxMedia &aMedia)
-{
-    DiskImageItem *item = createImageNode (aList, 0, aMedia);
-    updateFdItem (item, aMedia);
-    return item;
-}
-
-
-void VBoxDiskImageManagerDlg::makeWarningMark (DiskImageItem *aItem,
-                                               VBoxMedia::Status aStatus,
-                                               VBoxDefs::DiskType aType)
-{
-    const QPixmap &pm = aStatus == VBoxMedia::Inaccessible ? pxInaccessible :
-                        aStatus == VBoxMedia::Error ? pxErroneous : QPixmap();
-
-    if (!pm.isNull())
-    {
-        aItem->setPixmap (0, pm);
-        QIcon iconSet (pm);
-        QWidget *wt = aType == VBoxDefs::HD ? twImages->page (0) :
-                      aType == VBoxDefs::CD ? twImages->page (1) :
-                      aType == VBoxDefs::FD ? twImages->page (2) : 0;
-        Assert (wt); /* aType should be correct */
-        twImages->changeTab (wt, iconSet, twImages->tabLabel (wt));
-        aItem->listView()->ensureItemVisible (aItem);
-    }
-}
-
-
-DiskImageItem* VBoxDiskImageManagerDlg::searchItem (Q3ListView *aList,
-                                                    const QUuid &aId)
-{
-    if (aId.isNull()) return 0;
-    DiskImageItemIterator iterator (aList);
-    while (*iterator)
-    {
-        if ((*iterator)->getUuid() == aId)
-            return *iterator;
-        ++iterator;
-    }
-    return 0;
-}
-
-
-DiskImageItem* VBoxDiskImageManagerDlg::searchItem (Q3ListView *aList,
-                                                    VBoxMedia::Status aStatus)
-{
-    DiskImageItemIterator iterator (aList);
-    while (*iterator)
-    {
-        if ((*iterator)->getStatus() == aStatus)
-            return *iterator;
-        ++iterator;
-    }
-    return 0;
-}
-
-
-void VBoxDiskImageManagerDlg::setup (int aType, bool aDoSelect,
-                                     const QUuid *aTargetVMId /* = NULL */,
-                                     bool aRefresh /* = true */,
-                                     CMachine machine /* = NULL */,
-                                     const QUuid &aHdId,
-                                     const QUuid &aCdId,
-                                     const QUuid &aFdId)
-{
-    cmachine = machine;
-    hdSelectedId = aHdId;
-    cdSelectedId = aCdId;
-    fdSelectedId = aFdId;
-
-    type = aType;
-    twImages->setTabEnabled (twImages->page(0), type & VBoxDefs::HD);
-    twImages->setTabEnabled (twImages->page(1), type & VBoxDefs::CD);
-    twImages->setTabEnabled (twImages->page(2), type & VBoxDefs::FD);
-
-    doSelect = aDoSelect;
-    if (aTargetVMId)
-        targetVMId = *aTargetVMId;
-
-    if (doSelect)
-        buttonOk->setText (tr ("&Select"));
-    else
-        buttonCancel->setShown (false);
-
-    /* listen to "media enumeration started" signals */
-    connect (&vboxGlobal(), SIGNAL (mediaEnumStarted()),
-             this, SLOT (mediaEnumStarted()));
-    /* listen to "media enumeration" signals */
-    connect (&vboxGlobal(), SIGNAL (mediaEnumerated (const VBoxMedia &, int)),
-             this, SLOT (mediaEnumerated (const VBoxMedia &, int)));
-    /* listen to "media enumeration finished" signals */
-    connect (&vboxGlobal(), SIGNAL (mediaEnumFinished (const VBoxMediaList &)),
-             this, SLOT (mediaEnumFinished (const VBoxMediaList &)));
-
-    /* listen to "media add" signals */
-    connect (&vboxGlobal(), SIGNAL (mediaAdded (const VBoxMedia &)),
-             this, SLOT (mediaAdded (const VBoxMedia &)));
-    /* listen to "media update" signals */
-    connect (&vboxGlobal(), SIGNAL (mediaUpdated (const VBoxMedia &)),
-             this, SLOT (mediaUpdated (const VBoxMedia &)));
-    /* listen to "media remove" signals */
-    connect (&vboxGlobal(), SIGNAL (mediaRemoved (VBoxDefs::DiskType, const QUuid &)),
-             this, SLOT (mediaRemoved (VBoxDefs::DiskType, const QUuid &)));
-
-    if (aRefresh && !vboxGlobal().isMediaEnumerationStarted())
-    {
-        vboxGlobal().startEnumeratingMedia();
-    }
-    else
-    {
-        /* insert already enumerated media */
-        const VBoxMediaList &list = vboxGlobal().currentMediaList();
-        prepareToRefresh (list.size());
-        VBoxMediaList::const_iterator it;
-        int index = 0;
-        for (it = list.begin(); it != list.end(); ++ it)
-        {
-            mediaAdded (*it);
-            if ((*it).status != VBoxMedia::Unknown)
-                mProgressBar->setProgress (++ index);
-        }
-
-        /* emulate the finished signal to reuse the code */
-        if (!vboxGlobal().isMediaEnumerationStarted())
-            mediaEnumFinished (list);
-    }
-
-    /* for a newly opened dialog, select the first item */
-    if (!hdsView->selectedItem())
-        setCurrentItem (hdsView, hdsView->firstChild());
-    if (!cdsView->selectedItem())
-        setCurrentItem (cdsView, cdsView->firstChild());
-    if (!fdsView->selectedItem())
-        setCurrentItem (fdsView, fdsView->firstChild());
-}
-
-
-void VBoxDiskImageManagerDlg::mediaEnumStarted()
-{
-    /* load default tab icons */
-    twImages->changeTab (twImages->page (0), pxHD,
-                         twImages->tabLabel (twImages->page (0)));
-    twImages->changeTab (twImages->page (1), pxCD,
-                         twImages->tabLabel (twImages->page (1)));
-    twImages->changeTab (twImages->page (2), pxFD,
-                         twImages->tabLabel (twImages->page (2)));
-
-    /* load current media list */
-    const VBoxMediaList &list = vboxGlobal().currentMediaList();
-    prepareToRefresh (list.size());
-    VBoxMediaList::const_iterator it;
-    for (it = list.begin(); it != list.end(); ++ it)
-        mediaAdded (*it);
-
-    /* select the first item if the previous saved item is not found
-     * or no current item at all */
-    if (!hdsView->currentItem() || !hdSelectedId.isNull())
-        setCurrentItem (hdsView, hdsView->firstChild());
-    if (!cdsView->currentItem() || !cdSelectedId.isNull())
-        setCurrentItem (cdsView, cdsView->firstChild());
-    if (!fdsView->currentItem() || !fdSelectedId.isNull())
-        setCurrentItem (fdsView, fdsView->firstChild());
-
-    processCurrentChanged();
-}
-
-void VBoxDiskImageManagerDlg::mediaEnumerated (const VBoxMedia &aMedia,
-                                               int aIndex)
-{
-    mediaUpdated (aMedia);
-    Assert (aMedia.status != VBoxMedia::Unknown);
-    if (aMedia.status != VBoxMedia::Unknown)
-        mProgressBar->setProgress (aIndex + 1);
-}
-
-void VBoxDiskImageManagerDlg::mediaEnumFinished (const VBoxMediaList &/* aList */)
-{
-    mProgressBar->setHidden (true);
-    mProgressText->setHidden (true);
-
-    imRefreshAction->setEnabled (true);
-    unsetCursor();
-
-    /* adjust columns (it is strange to repeat but it works) */
-
-    hdsView->adjustColumn (1);
-    hdsView->adjustColumn (2);
-    hdsView->adjustColumn (1);
-
-    cdsView->adjustColumn (1);
-    cdsView->adjustColumn (2);
-    cdsView->adjustColumn (1);
-
-    fdsView->adjustColumn (1);
-    fdsView->adjustColumn (2);
-    fdsView->adjustColumn (1);
-
-    processCurrentChanged();
-}
-
-
-void VBoxDiskImageManagerDlg::mediaAdded (const VBoxMedia &aMedia)
-{
-    /* ignore non-interesting aMedia */
-    if (!(type & aMedia.type))
-        return;
-
-    DiskImageItem *item = 0;
-    switch (aMedia.type)
-    {
-        case VBoxDefs::HD:
-            item = createHdItem (hdsView, aMedia);
-            if (item->getUuid() == hdSelectedId)
-            {
-                setCurrentItem (hdsView, item);
-                hdSelectedId = QUuid();
-            }
-            break;
-        case VBoxDefs::CD:
-            item = createCdItem (cdsView, aMedia);
-            if (item->getUuid() == cdSelectedId)
-            {
-                setCurrentItem (cdsView, item);
-                cdSelectedId = QUuid();
-            }
-            break;
-        case VBoxDefs::FD:
-            item = createFdItem (fdsView, aMedia);
-            if (item->getUuid() == fdSelectedId)
-            {
-                setCurrentItem (fdsView, item);
-                fdSelectedId = QUuid();
-            }
-            break;
-        default:
-            AssertMsgFailed (("Invalid aMedia type\n"));
-    }
-
-    if (!item)
-        return;
-
-    if (!vboxGlobal().isMediaEnumerationStarted())
-        setCurrentItem (getListView (aMedia.type), item);
-    if (item == getCurrentListView()->currentItem())
-        processCurrentChanged (item);
-}
-
-void VBoxDiskImageManagerDlg::mediaUpdated (const VBoxMedia &aMedia)
-{
-    /* ignore non-interesting aMedia */
-    if (!(type & aMedia.type))
-        return;
-
-    DiskImageItem *item = 0;
-    switch (aMedia.type)
-    {
-        case VBoxDefs::HD:
-        {
-            CHardDisk hd = aMedia.disk;
-            item = searchItem (hdsView, hd.GetId());
-            updateHdItem (item, aMedia);
-            break;
-        }
-        case VBoxDefs::CD:
-        {
-            CDVDImage cd = aMedia.disk;
-            item = searchItem (cdsView, cd.GetId());
-            updateCdItem (item, aMedia);
-            break;
-        }
-        case VBoxDefs::FD:
-        {
-            CFloppyImage fd = aMedia.disk;
-            item = searchItem (fdsView, fd.GetId());
-            updateFdItem (item, aMedia);
-            break;
-        }
-        default:
-            AssertMsgFailed (("Invalid aMedia type\n"));
-    }
-
-    if (!item)
-        return;
-
-    /* note: current items on invisible tabs are not updated because
-     * it is always done in processCurrentChanged() when the user switches
-     * to an invisible tab */
-    if (item == getCurrentListView()->currentItem())
-        processCurrentChanged (item);
-}
-
-void VBoxDiskImageManagerDlg::mediaRemoved (VBoxDefs::DiskType aType,
-                                            const QUuid &aId)
-{
-    Q3ListView *listView = getListView (aType);
-    DiskImageItem *item = searchItem (listView, aId);
-    delete item;
-    setCurrentItem (listView, listView->currentItem());
-    /* search the list for inaccessible media */
-    if (!searchItem (listView, VBoxMedia::Inaccessible) &&
-        !searchItem (listView, VBoxMedia::Error))
-    {
-        QWidget *wt = aType == VBoxDefs::HD ? twImages->page (0) :
-                      aType == VBoxDefs::CD ? twImages->page (1) :
-                      aType == VBoxDefs::FD ? twImages->page (2) : 0;
-        const QIcon &set = aType == VBoxDefs::HD ? pxHD :
-                              aType == VBoxDefs::CD ? pxCD :
-                              aType == VBoxDefs::FD ? pxFD : QIcon();
-        Assert (wt && !set.isNull()); /* atype should be the correct one */
-        twImages->changeTab (wt, set, twImages->tabLabel (wt));
-    }
-}
-
-
-void VBoxDiskImageManagerDlg::machineStateChanged (const VBoxMachineStateChangeEvent &e)
-{
-    /// @todo (r=dmik) IVirtualBoxCallback::OnMachineStateChange
-    //  must also expose the old state! In this case we won't need to cache
-    //  the state value in every class in GUI that uses this signal.
-
-    switch (e.state)
-    {
-        case KMachineState_PoweredOff:
-        case KMachineState_Aborted:
-        case KMachineState_Saved:
-        case KMachineState_Starting:
-        case KMachineState_Restoring:
-        {
-            refreshAll();
-            break;
-        }
-        default:
-            break;
-    }
-}
-
-
-void VBoxDiskImageManagerDlg::clearInfoPanes()
-{
-    hdsPane1->clear();
-    hdsPane2->clear(), hdsPane3->clear();
-    hdsPane4->clear(), hdsPane5->clear();
-    cdsPane1->clear(), cdsPane2->clear();
-    fdsPane1->clear(), fdsPane2->clear();
-}
-
-
-void VBoxDiskImageManagerDlg::prepareToRefresh (int aTotal)
-{
-    /* info panel clearing */
-    clearInfoPanes();
-
-    /* prepare progressbar */
-    if (mProgressBar)
-    {
-        mProgressBar->setProgress (0, aTotal);
-        mProgressBar->setHidden (false);
-        mProgressText->setHidden (false);
-    }
-
-    imRefreshAction->setEnabled (false);
-    setCursor (QCursor (Qt::BusyCursor));
-
-    /* store the current list selections */
-
-    Q3ListViewItem *item;
-    DiskImageItem *di;
-
-    item = hdsView->currentItem();
-    di = (item && item->rtti() == DiskImageItem::TypeId) ?
-        static_cast <DiskImageItem *> (item) : 0;
-    if (hdSelectedId.isNull())
-        hdSelectedId = di ? di->getUuid() : QUuid();
-
-    item = cdsView->currentItem();
-    di = (item && item->rtti() == DiskImageItem::TypeId) ?
-        static_cast <DiskImageItem *> (item) : 0;
-    if (cdSelectedId.isNull())
-        cdSelectedId = di ? di->getUuid() : QUuid();
-
-    item = fdsView->currentItem();
-    di = (item && item->rtti() == DiskImageItem::TypeId) ?
-        static_cast <DiskImageItem *> (item) : 0;
-    if (fdSelectedId.isNull())
-        fdSelectedId = di ? di->getUuid() : QUuid();
-
-    /* finally, clear all lists */
-    hdsView->clear();
-    cdsView->clear();
-    fdsView->clear();
-}
-
-
-void VBoxDiskImageManagerDlg::refreshAll()
-{
-    /* start enumerating media */
-    vboxGlobal().startEnumeratingMedia();
-}
-
-
-bool VBoxDiskImageManagerDlg::checkImage (DiskImageItem* aItem)
-{
-    QUuid itemId = aItem ? aItem->getUuid() : QUuid();
-    if (itemId.isNull()) return false;
-
-    Q3ListView* parentList = aItem->listView();
-    if (parentList == hdsView)
-    {
-        CHardDisk hd = aItem->getMedia().disk;
-        QUuid machineId = hd.GetMachineId();
-        if (machineId.isNull() ||
-            (vbox.GetMachine (machineId).GetState() != KMachineState_PoweredOff &&
-             vbox.GetMachine (machineId).GetState() != KMachineState_Aborted))
-            return false;
-    }
-    else if (parentList == cdsView)
-    {
-        /* check if there is temporary usage: */
-        QStringList tempMachines =
-            QStringList::split (' ', vbox.GetDVDImageUsage (itemId,
-                                                            KResourceUsage_Temporary));
-        if (!tempMachines.isEmpty())
-            return false;
-        /* only permamently mounted .iso could be released */
-        QStringList permMachines =
-            QStringList::split (' ', vbox.GetDVDImageUsage (itemId,
-                                                            KResourceUsage_Permanent));
-        for (QStringList::Iterator it = permMachines.begin();
-             it != permMachines.end(); ++it)
-            if (vbox.GetMachine(QUuid (*it)).GetState() != KMachineState_PoweredOff &&
-                vbox.GetMachine(QUuid (*it)).GetState() != KMachineState_Aborted)
-                return false;
-    }
-    else if (parentList == fdsView)
-    {
-        /* check if there is temporary usage: */
-        QStringList tempMachines =
-            QStringList::split (' ', vbox.GetFloppyImageUsage (itemId,
-                                                               KResourceUsage_Temporary));
-        if (!tempMachines.isEmpty())
-            return false;
-        /* only permamently mounted floppies could be released */
-        QStringList permMachines =
-            QStringList::split (' ', vbox.GetFloppyImageUsage (itemId,
-                                                               KResourceUsage_Permanent));
-        for (QStringList::Iterator it = permMachines.begin();
-             it != permMachines.end(); ++it)
-            if (vbox.GetMachine(QUuid (*it)).GetState() != KMachineState_PoweredOff &&
-                vbox.GetMachine(QUuid (*it)).GetState() != KMachineState_Aborted)
-                return false;
-    }
-    else
-    {
-        return false;
-    }
-    return true;
-}
-
-
-void VBoxDiskImageManagerDlg::setCurrentItem (Q3ListView *aListView,
-                                              Q3ListViewItem *aItem)
-{
-    if (!aItem)
-        return;
-
-    aListView->setCurrentItem (aItem);
-    aListView->setSelected (aListView->currentItem(), true);
-    aListView->ensureItemVisible (aListView->currentItem());
-}
-
-
-void VBoxDiskImageManagerDlg::processCurrentChanged()
-{
-    Q3ListView *currentList = getCurrentListView();
-    currentList->setFocus();
-
-    /* tab stop setup */
-    setTabOrder (hdsView, hdsPane1);
-    setTabOrder (hdsPane1, hdsPane2);
-    setTabOrder (hdsPane2, hdsPane3);
-    setTabOrder (hdsPane3, hdsPane4);
-    setTabOrder (hdsPane4, hdsPane5);
-    setTabOrder (hdsPane5, buttonHelp);
-
-    setTabOrder (cdsView, cdsPane1);
-    setTabOrder (cdsPane1, cdsPane2);
-    setTabOrder (cdsPane2, buttonHelp);
-
-    setTabOrder (fdsView, fdsPane1);
-    setTabOrder (fdsPane1, fdsPane2);
-    setTabOrder (fdsPane2, buttonHelp);
-
-    setTabOrder (buttonHelp, buttonOk);
-    setTabOrder (buttonOk, twImages);
-
-    processCurrentChanged (currentList->currentItem());
-}
-
-void VBoxDiskImageManagerDlg::processCurrentChanged (Q3ListViewItem *aItem)
-{
-    DiskImageItem *item = aItem && aItem->rtti() == DiskImageItem::TypeId ?
-        static_cast<DiskImageItem*> (aItem) : 0;
-
-    /* Ensures current item visible every time we are switching page */
-    item->listView()->ensureItemVisible (item);
-
-    bool notInEnum      = !vboxGlobal().isMediaEnumerationStarted();
-    bool modifyEnabled  = notInEnum &&
-                          item &&  item->getUsage().isNull() &&
-                          !item->firstChild() && !item->getPath().isNull();
-    bool releaseEnabled = item && !item->getUsage().isNull() &&
-                          item->getSnapshotUsage().isNull() &&
-                          checkImage (item) &&
-                          !item->parent() && !item->firstChild() &&
-                          item->getSnapshotName().isNull();
-    bool newEnabled     = notInEnum &&
-                          getCurrentListView() == hdsView ? true : false;
-    bool addEnabled     = notInEnum;
-
-    // imEditAction->setEnabled (modifyEnabled);
-    imRemoveAction->setEnabled (modifyEnabled);
-    imReleaseAction->setEnabled (releaseEnabled);
-    imNewAction->setEnabled (newEnabled);
-    imAddAction->setEnabled (addEnabled);
-
-    // itemMenu->setItemVisible (itemMenu->idAt(0), modifyEnabled);
-    itemMenu->setItemEnabled (itemMenu->idAt(0), modifyEnabled);
-    itemMenu->setItemEnabled (itemMenu->idAt(1), releaseEnabled);
-
-    if (doSelect)
-    {
-        bool selectEnabled = item && !item->parent() &&
-                             (!newEnabled ||
-                                (item->getUsage().isNull() ||
-                                 item->getMachineId() == targetVMId));
-
-        buttonOk->setEnabled (selectEnabled);
-    }
-
-    if (item)
-    {
-        if (item->listView() == hdsView)
-        {
-            hdsPane1->setText (item->getInformation (item->getPath(), true, "end"));
-            hdsPane2->setText (item->getInformation (item->getDiskType(), false));
-            hdsPane3->setText (item->getInformation (item->getStorageType(), false));
-            hdsPane4->setText (item->getInformation (item->getUsage()));
-            hdsPane5->setText (item->getInformation (item->getSnapshotName()));
-        }
-        else if (item->listView() == cdsView)
-        {
-            cdsPane1->setText (item->getInformation (item->getPath(), true, "end"));
-            cdsPane2->setText (item->getInformation (item->getTotalUsage()));
-        }
-        else if (item->listView() == fdsView)
-        {
-            fdsPane1->setText (item->getInformation (item->getPath(), true, "end"));
-            fdsPane2->setText (item->getInformation (item->getTotalUsage()));
-        }
-    }
-    else
-        clearInfoPanes();
-}
-
-
-void VBoxDiskImageManagerDlg::processPressed (Q3ListViewItem * aItem)
-{
-    if (!aItem)
-    {
-        Q3ListView *currentList = getCurrentListView();
-        currentList->setSelected (currentList->currentItem(), true);
-    }
-}
-
-
-void VBoxDiskImageManagerDlg::newImage()
-{
-    AssertReturnVoid (getCurrentListView() == hdsView);
-
-    VBoxNewHDWzd dlg (this);
-
-    if (dlg.exec() == QDialog::Accepted)
-    {
-        CHardDisk hd = dlg.hardDisk();
-        VBoxMedia::Status status =
-            hd.GetAccessible() ? VBoxMedia::Ok :
-            hd.isOk() ? VBoxMedia::Inaccessible :
-            VBoxMedia::Error;
-        vboxGlobal().addMedia (VBoxMedia (CUnknown (hd), VBoxDefs::HD, status));
-    }
-}
-
-
-void VBoxDiskImageManagerDlg::addImage()
-{
-    Q3ListView *currentList = getCurrentListView();
-    DiskImageItem *item =
-        currentList->currentItem() &&
-        currentList->currentItem()->rtti() == DiskImageItem::TypeId ?
-        static_cast <DiskImageItem*> (currentList->currentItem()) : 0;
-
-    QString dir;
-    if (item && item->getStatus() == VBoxMedia::Ok)
-        dir = QFileInfo (item->getPath().stripWhiteSpace()).dirPath (true);
-
-    if (dir.isEmpty())
-        if (currentList == hdsView)
-            dir = vbox.GetSystemProperties().GetDefaultVDIFolder();
-
-    if (dir.isEmpty() || !QFileInfo (dir).exists())
-        dir = vbox.GetHomeFolder();
-
-    QString title;
-    QString filter;
-    VBoxDefs::DiskType type = VBoxDefs::InvalidType;
-
-    if (currentList == hdsView)
-    {
-        filter = tr ("All hard disk images (*.vdi; *.vmdk);;"
-                     "Virtual Disk images (*.vdi);;"
-                     "VMDK images (*.vmdk);;"
-                     "All files (*)");
-        title = tr ("Select a hard disk image file");
-        type = VBoxDefs::HD;
-    }
-    else if (currentList == cdsView)
-    {
-        filter = tr ("CD/DVD-ROM images (*.iso);;"
-                     "All files (*)");
-        title = tr ("Select a CD/DVD-ROM disk image file");
-        type = VBoxDefs::CD;
-    }
-    else if (currentList == fdsView)
-    {
-        filter = tr ("Floppy images (*.img);;"
-                     "All files (*)");
-        title = tr ("Select a floppy disk image file");
-        type = VBoxDefs::FD;
-    }
-    else
-    {
-        AssertMsgFailed (("Root list should be equal to hdsView, cdsView or fdsView"));
-    }
-
-    QString src = VBoxGlobal::getOpenFileName (dir, filter, this, title);
-    src =  QDir::convertSeparators (src);
-
-    addImageToList (src, type);
-    if (!vbox.isOk())
-        vboxProblem().cannotRegisterMedia (this, vbox, type, src);
-}
-
-
-void VBoxDiskImageManagerDlg::removeImage()
-{
-    Q3ListView *currentList = getCurrentListView();
-    DiskImageItem *item =
-        currentList->currentItem() &&
-        currentList->currentItem()->rtti() == DiskImageItem::TypeId ?
-        static_cast<DiskImageItem*> (currentList->currentItem()) : 0;
-    AssertMsg (item, ("Current item must not be null"));
-
-    QUuid uuid = item->getUuid();
-    AssertMsg (!uuid.isNull(), ("Current item must have uuid"));
-
-    QString src = item->getPath().stripWhiteSpace();
-    VBoxDefs::DiskType type = VBoxDefs::InvalidType;
-
-    if (currentList == hdsView)
-    {
-        type = VBoxDefs::HD;
-        bool deleteImage = false;
-
-        /// @todo When creation of VMDK is implemented, we should
-        /// enable image deletion for  them as well (use
-        /// GetStorageType() to define the correct cast).
-        CHardDisk disk = item->getMedia().disk;
-        if (disk.GetStorageType() == KHardDiskStorageType_VirtualDiskImage &&
-            disk.GetParent().isNull() && /* must not be differencing (see below) */
-            item->getStatus() == VBoxMedia::Ok)
-        {
-            int rc = vboxProblem().confirmHardDiskImageDeletion (this, src);
-            if (rc == QIMessageBox::Cancel)
-                return;
-            deleteImage = rc == QIMessageBox::Yes;
-        }
-        else
-        {
-            /// @todo note that differencing images are always automatically
-            /// deleted when unregistered, but the following message box
-            /// doesn't mention it. I keep it as is for now because
-            /// implementing the portability feature will most likely change
-            /// this behavior (we'll update the message afterwards).
-            if (!vboxProblem().confirmHardDiskUnregister (this, src))
-                return;
-        }
-
-        CHardDisk hd = vbox.UnregisterHardDisk (uuid);
-        if (!vbox.isOk())
-            vboxProblem().cannotUnregisterMedia (this, vbox, type, src);
-        else if (deleteImage)
-        {
-            /// @todo When creation of VMDK is implemented, we should
-            /// enable image deletion for  them as well (use
-            /// GetStorageType() to define the correct cast).
-            CVirtualDiskImage vdi = CUnknown (hd);
-            if (vdi.isOk())
-                vdi.DeleteImage();
-            if (!vdi.isOk())
-                vboxProblem().cannotDeleteHardDiskImage (this, vdi);
-        }
-    }
-    else if (currentList == cdsView)
-    {
-        type = VBoxDefs::CD;
-        vbox.UnregisterDVDImage (uuid);
-    }
-    else if (currentList == fdsView)
-    {
-        type = VBoxDefs::FD;
-        vbox.UnregisterFloppyImage (uuid);
-    }
-
-    if (vbox.isOk())
-        vboxGlobal().removeMedia (type, uuid);
-    else
-        vboxProblem().cannotUnregisterMedia (this, vbox, type, src);
-}
-
-
-void VBoxDiskImageManagerDlg::releaseImage()
-{
-    Q3ListView *currentList = getCurrentListView();
-    DiskImageItem *item =
-        currentList->currentItem() &&
-        currentList->currentItem()->rtti() == DiskImageItem::TypeId ?
-        static_cast<DiskImageItem*> (currentList->currentItem()) : 0;
-    AssertMsg (item, ("Current item must not be null"));
-
-    QUuid itemId = item->getUuid();
-    AssertMsg (!itemId.isNull(), ("Current item must have uuid"));
-
-    /* if it is a hard disk sub-item: */
-    if (currentList == hdsView)
-    {
-        CHardDisk hd = item->getMedia().disk;
-        QUuid machineId = hd.GetMachineId();
-        if (vboxProblem().confirmReleaseImage (this,
-            vbox.GetMachine (machineId).GetName()))
-        {
-            releaseDisk (machineId, itemId, VBoxDefs::HD);
-            VBoxMedia media (item->getMedia());
-            media.status = hd.GetAccessible() ? VBoxMedia::Ok :
-                           hd.isOk() ? VBoxMedia::Inaccessible :
-                           VBoxMedia::Error;
-            vboxGlobal().updateMedia (media);
-        }
-    }
-    /* if it is a cd/dvd sub-item: */
-    else if (currentList == cdsView)
-    {
-        QString usage = item->getTotalUsage();
-        if (vboxProblem().confirmReleaseImage (this, usage))
-        {
-            QStringList permMachines =
-                QStringList::split (' ', vbox.GetDVDImageUsage (itemId,
-                                                                KResourceUsage_Permanent));
-            for (QStringList::Iterator it = permMachines.begin();
-                 it != permMachines.end(); ++it)
-                releaseDisk (QUuid (*it), itemId, VBoxDefs::CD);
-
-            CDVDImage cd = vbox.GetDVDImage (itemId);
-            VBoxMedia media (item->getMedia());
-            media.status = cd.GetAccessible() ? VBoxMedia::Ok :
-                           cd.isOk() ? VBoxMedia::Inaccessible :
-                           VBoxMedia::Error;
-            vboxGlobal().updateMedia (media);
-        }
-    }
-    /* if it is a floppy sub-item: */
-    else if (currentList == fdsView)
-    {
-        QString usage = item->getTotalUsage();
-        if (vboxProblem().confirmReleaseImage (this, usage))
-        {
-            QStringList permMachines =
-                QStringList::split (' ', vbox.GetFloppyImageUsage (itemId,
-                                                                   KResourceUsage_Permanent));
-            for (QStringList::Iterator it = permMachines.begin();
-                 it != permMachines.end(); ++it)
-                releaseDisk (QUuid (*it), itemId, VBoxDefs::FD);
-
-            CFloppyImage fd = vbox.GetFloppyImage (itemId);
-            VBoxMedia media (item->getMedia());
-            media.status = fd.GetAccessible() ? VBoxMedia::Ok :
-                           fd.isOk() ? VBoxMedia::Inaccessible :
-                           VBoxMedia::Error;
-            vboxGlobal().updateMedia (media);
-        }
-    }
-}
-
-
-void VBoxDiskImageManagerDlg::releaseDisk (QUuid aMachineId,
-                                           QUuid aItemId,
-                                           VBoxDefs::DiskType aDiskType)
-{
-    CSession session;
-    CMachine machine;
-    /* is this media image mapped to this VM: */
-    if (!cmachine.isNull() && cmachine.GetId() == aMachineId)
-    {
-        machine = cmachine;
-    }
-    /* or some other: */
-    else
-    {
-        session = vboxGlobal().openSession (aMachineId);
-        if (session.isNull()) return;
-        machine = session.GetMachine();
-    }
-    /* perform disk releasing: */
-    switch (aDiskType)
-    {
-        case VBoxDefs::HD:
-        {
-            /* releasing hd: */
-            CHardDiskAttachmentEnumerator en =
-                machine.GetHardDiskAttachments().Enumerate();
-            while (en.HasMore())
-            {
-                CHardDiskAttachment hda = en.GetNext();
-                if (hda.GetHardDisk().GetId() == aItemId)
-                {
-                    machine.DetachHardDisk (hda.GetBus(),
-                                            hda.GetChannel(),
-                                            hda.GetDevice());
-                    if (!machine.isOk())
-                        vboxProblem().cannotDetachHardDisk (this,
-                            machine, hda.GetBus(), hda.GetChannel(), hda.GetDevice());
-                    break;
-                }
-            }
-            break;
-        }
-        case VBoxDefs::CD:
-        {
-            /* releasing cd: */
-            machine.GetDVDDrive().Unmount();
-            break;
-        }
-        case VBoxDefs::FD:
-        {
-            /* releasing fd: */
-            machine.GetFloppyDrive().Unmount();
-            break;
-        }
-        default:
-            AssertMsgFailed (("Incorrect disk type."));
-    }
-    /* save all setting changes: */
-    machine.SaveSettings();
-    if (!machine.isOk())
-        vboxProblem().cannotSaveMachineSettings (machine);
-    /* if local session was opened - close this session: */
-    if (!session.isNull())
-        session.Close();
-}
-
-
-QUuid VBoxDiskImageManagerDlg::getSelectedUuid()
-{
-    Q3ListView *currentList = getCurrentListView();
-    QUuid uuid;
-
-    if (currentList->selectedItem() &&
-        currentList->selectedItem()->rtti() == DiskImageItem::TypeId)
-        uuid = static_cast <DiskImageItem *> (
-            currentList->selectedItem())->getUuid();
-
-    return uuid;
-}
-
-
-QString VBoxDiskImageManagerDlg::getSelectedPath()
-{
-    Q3ListView *currentList = getCurrentListView();
-    QString path;
-
-    if (currentList->selectedItem() &&
-        currentList->selectedItem()->rtti() == DiskImageItem::TypeId )
-        path = static_cast<DiskImageItem*> (currentList->selectedItem())
-               ->getPath().stripWhiteSpace();
-
-    return path;
-}
-
-
-void VBoxDiskImageManagerDlg::processDoubleClick (Q3ListViewItem*)
-{
-    Q3ListView *currentList = getCurrentListView();
-
-    if (doSelect && currentList->selectedItem() && buttonOk->isEnabled())
-        accept();
-}
