Index: /trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumManager.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumManager.cpp	(revision 50342)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumManager.cpp	(revision 50343)
@@ -146,15 +146,15 @@
 
 
-/** Functor allowing to check if passed UIMediumItem is suitable by ID. */
+/** Functor allowing to check if passed UIMediumItem is suitable by @a strID. */
 class CheckIfSuitableByID : public CheckIfSuitableBy
 {
 public:
-    /** Constructor. */
+    /** Constructor accepting @a strID to compare with. */
     CheckIfSuitableByID(const QString &strID) : m_strID(strID) {}
 
 private:
-    /** Determines whether passed UIMediumItem is suitable by ID. */
+    /** Determines whether passed UIMediumItem is suitable by @a strID. */
     bool isItSuitable(UIMediumItem *pItem) const { return pItem->id() == m_strID; }
-    /** Holds the ID to compare to. */
+    /** Holds the @a strID to compare to. */
     QString m_strID;
 };
@@ -164,5 +164,5 @@
 {
 public:
-    /** Constructor. */
+    /** Constructor accepting @a state to compare with. */
     CheckIfSuitableByState(KMediumState state) : m_state(state) {}
 
@@ -175,5 +175,6 @@
 
 
-/* Medium manager progress-bar: */
+/** Medium manager progress-bar.
+  * Reflects medium-enumeration progress, stays hidden otherwise. */
 class UIEnumerationProgressBar : public QWidget
 {
@@ -182,5 +183,5 @@
 public:
 
-    /* Constructor: */
+    /** Constructor on the basis of passed @a pParent. */
     UIEnumerationProgressBar(QWidget *pParent)
         : QWidget(pParent)
@@ -190,15 +191,17 @@
     }
 
-    /* API: Text stuff: */
-    void setText(const QString &strText) { mText->setText(strText); }
-
-    /* API: Value stuff: */
+    /** Defines progress-bar label-text. */
+    void setText(const QString &strText) { m_pLabel->setText(strText); }
+
+    /** Returns progress-bar current-value. */
     int value() const { return m_pProgressBar->value(); }
+    /** Defines progress-bar current-value. */
     void setValue(int iValue) { m_pProgressBar->setValue(iValue); }
+    /** Defines progress-bar maximum-value. */
     void setMaximum(int iValue) { m_pProgressBar->setMaximum(iValue); }
 
 private:
 
-    /* Helper: Prepare stuff: */
+    /** Prepares progress-bar content. */
     void prepare()
     {
@@ -209,5 +212,5 @@
             pLayout->setContentsMargins(0, 0, 0, 0);
             /* Create label: */
-            mText = new QLabel;
+            m_pLabel = new QLabel;
             /* Create progress-bar: */
             m_pProgressBar = new QProgressBar;
@@ -217,11 +220,12 @@
             }
             /* Add widgets into layout: */
-            pLayout->addWidget(mText);
+            pLayout->addWidget(m_pLabel);
             pLayout->addWidget(m_pProgressBar);
         }
     }
 
-    /* Widgets: */
-    QLabel *mText;
+    /** Progress-bar label. */
+    QLabel *m_pLabel;
+    /** Progress-bar itself. */
     QProgressBar *m_pProgressBar;
 };
@@ -313,5 +317,5 @@
     updateTabIcons(pMediumItem, ItemAction_Removed);
 
-    /* We need to silently delete item without selecting
+    /* We need to silently delete medium-item without selecting
      * the new one because of complex selection mechanism
      * which could provoke a segfault choosing the new
@@ -322,5 +326,5 @@
     pTree->blockSignals(false);
 
-    /* Set new current-item: */
+    /* Make sure current medium-item is selected: */
     setCurrentItem(pTree, pTree->currentItem());
 }
@@ -388,6 +392,8 @@
 void UIMediumManager::sltCopyMedium()
 {
-    /* Get current-item: */
+    /* Get current medium-item: */
     UIMediumItem *pMediumItem = currentMediumItem();
+    AssertMsgReturnVoid(pMediumItem, ("Current item must not be null"));
+    AssertReturnVoid(!pMediumItem->id().isNull());
 
     /* Show Clone VD wizard: */
@@ -403,6 +409,8 @@
 void UIMediumManager::sltModifyMedium()
 {
-    /* Get current-item: */
+    /* Get current medium-item: */
     UIMediumItem *pMediumItem = currentMediumItem();
+    AssertMsgReturnVoid(pMediumItem, ("Current item must not be null"));
+    AssertReturnVoid(!pMediumItem->id().isNull());
 
     /* Show Modify VD dialog: */
@@ -410,8 +418,8 @@
     if (pDialog->exec() == QDialog::Accepted)
     {
-        /* Safe spot because if dialog is deleted inside ::exec() =>
-         * returned result will be QDialog::Rejected. */
+        /* Update medium-item: */
         pMediumItem->refreshAll();
-        m_pTypePane->setText(pMediumItem->hardDiskType());
+        /* Update HD information-panes: */
+        updateInformationPanesHD();
     }
 
@@ -426,4 +434,5 @@
     UIMediumItem *pMediumItem = currentMediumItem();
     AssertMsgReturnVoid(pMediumItem, ("Current item must not be null"));
+    AssertReturnVoid(!pMediumItem->id().isNull());
 
     /* Remember ID/type as they may get lost after the closure/deletion: */
@@ -561,12 +570,13 @@
 void UIMediumManager::sltHandleCurrentTabChanged()
 {
-    /* Get current-tree: */
+    /* Get current tree-widget: */
     QTreeWidget *pTree = currentTreeWidget();
 
-    /* If other tree was focused previously, moving focus to new tree: */
+    /* If another tree-widget was focused before,
+     * move focus to current tree-widget: */
     if (qobject_cast<QTreeWidget*>(focusWidget()))
         pTree->setFocus();
 
-    /* Update current tree-item: */
+    /* Make sure current medium-item is selected: */
     sltHandleCurrentItemChanged(pTree->currentItem());
 }
@@ -575,20 +585,21 @@
                                                   QTreeWidgetItem *pPrevItem /* = 0 */)
 {
-    /* Get medium-item: */
+    /* Get current medium-item: */
     UIMediumItem *pMediumItem = toMediumItem(pItem);
 
-    /* We have to make sure some item is always selected: */
+    /* We have to make sure some medium-item is always selected: */
     if (!pMediumItem && pPrevItem)
     {
-        /* If the new item is 0, set the old item again. */
+        /* If new medium-item is 0, choose the old one again. */
         UIMediumItem *pPrevMediumItem = toMediumItem(pPrevItem);
         setCurrentItem(currentTreeWidget(), pPrevMediumItem);
     }
 
+    /* If item is set: */
     if (pMediumItem)
     {
         /* Set the file for the proxy icon: */
         setFileForProxyIcon(pMediumItem->location());
-        /* Ensures current item visible every time we are switching page: */
+        /* Make sure current medium-item visible: */
         pMediumItem->treeWidget()->scrollToItem(pMediumItem, QAbstractItemView::EnsureVisible);
     }
@@ -603,5 +614,5 @@
 void UIMediumManager::sltHandleDoubleClick()
 {
-    /* Call for modify-action if hard-disk double-clicked: */
+    /* Call for modify-action if hard-drive medium-item double-clicked: */
     if (currentMediumType() == UIMediumType_HardDisk)
         sltModifyMedium();
@@ -610,5 +621,5 @@
 void UIMediumManager::sltHandleContextMenuCall(const QPoint &position)
 {
-    /* Get surrent widget/item: */
+    /* Get corresponding widget/item: */
     QTreeWidget *pTree = currentTreeWidget();
     QTreeWidgetItem *pItem = pTree->itemAt(position);
@@ -617,5 +628,5 @@
         /* Make sure the item is selected and current: */
         setCurrentItem(pTree, pItem);
-        /* Show context menu: */
+        /* Show item context menu: */
         m_pContextMenu->exec(pTree->viewport()->mapToGlobal(position));
     }
@@ -870,5 +881,5 @@
     /* Tab-widget created in .ui file. */
     {
-        /* Setup tab-widget: */
+        /* Configure tab-widget: */
         mTabWidget->setFocusPolicy(Qt::TabFocus);
         mTabWidget->setTabIcon(HDTab, m_iconHD);
@@ -896,5 +907,5 @@
     /* HD tree-widget created in .ui file. */
     {
-        /* Setup HD tree-widget: */
+        /* Configure HD tree-widget: */
         mTwHD->setColumnCount(3);
         mTwHD->sortItems(0, Qt::AscendingOrder);
@@ -921,5 +932,5 @@
     /* CD tree-widget created in .ui file. */
     {
-        /* Setup CD tree-widget: */
+        /* Configure CD tree-widget: */
         mTwCD->setColumnCount(2);
         mTwCD->sortItems(0, Qt::AscendingOrder);
@@ -945,5 +956,5 @@
     /* FD tree-widget created in .ui file. */
     {
-        /* Setup FD tree-widget: */
+        /* Configure FD tree-widget: */
         mTwFD->setColumnCount(2);
         mTwFD->sortItems(0, Qt::AscendingOrder);
@@ -992,7 +1003,6 @@
     m_pProgressBar = new UIEnumerationProgressBar(this);
     {
-        /* Hidden by default: */
+        /* Configure progress-bar: */
         m_pProgressBar->hide();
-        /* Integrate to the button-box: */
         mButtonBox->addExtraWidget(m_pProgressBar);
     }
@@ -1023,9 +1033,9 @@
     mTwFD->clear();
 
-    /* Populate all medium-items: */
+    /* Create medium-items: */
     foreach (const QString &strMediumID, vboxGlobal().mediumIDs())
         sltHandleMediumCreated(strMediumID);
 
-    /* Select first-item as current medium-item if nothing selected: */
+    /* Select first medium-item as current one if nothing selected: */
     if (!mediumItem(UIMediumType_HardDisk))
         if (QTreeWidgetItem *pItem = mTwHD->topLevelItem(0))
@@ -1041,17 +1051,17 @@
 void UIMediumManager::updateActions()
 {
-    /* Get current-item: */
-    UIMediumItem *pCurrentItem = currentMediumItem();
+    /* Get current medium-item: */
+    UIMediumItem *pMediumItem = currentMediumItem();
 
     /* Calculate actions accessibility: */
     bool fNotInEnumeration = !vboxGlobal().isMediumEnumerationInProgress();
     bool fActionEnabledCopy = currentMediumType() == UIMediumType_HardDisk &&
-                              fNotInEnumeration && pCurrentItem && checkMediumFor(pCurrentItem, Action_Copy);
+                              fNotInEnumeration && pMediumItem && checkMediumFor(pMediumItem, Action_Copy);
     bool fActionEnabledModify = currentMediumType() == UIMediumType_HardDisk &&
-                                fNotInEnumeration && pCurrentItem && checkMediumFor(pCurrentItem, Action_Modify);
-    bool fActionEnabledRemove = fNotInEnumeration && pCurrentItem && checkMediumFor(pCurrentItem, Action_Remove);
-    bool fActionEnabledRelease = fNotInEnumeration && pCurrentItem && checkMediumFor(pCurrentItem, Action_Release);
-
-    /* Update actions: */
+                                fNotInEnumeration && pMediumItem && checkMediumFor(pMediumItem, Action_Modify);
+    bool fActionEnabledRemove = fNotInEnumeration && pMediumItem && checkMediumFor(pMediumItem, Action_Remove);
+    bool fActionEnabledRelease = fNotInEnumeration && pMediumItem && checkMediumFor(pMediumItem, Action_Release);
+
+    /* Apply actions accessibility: */
     m_pActionCopy->setEnabled(fActionEnabledCopy);
     m_pActionModify->setEnabled(fActionEnabledModify);
@@ -1167,5 +1177,5 @@
 void UIMediumManager::updateInformationPanesHD()
 {
-    /* Get current HD item: */
+    /* Get current hard-drive medium-item: */
     UIMediumItem *pCurrentItem = mediumItem(UIMediumType_HardDisk);
 
@@ -1669,5 +1679,5 @@
     AssertReturn(!medium.medium().isNull(), 0);
 
-    /* Search for medium-item: */
+    /* Search for existing medium-item: */
     UIMediumItem *pMediumItem = searchItem(pTree, CheckIfSuitableByID(medium.id()));
 
@@ -1683,5 +1693,5 @@
             if (!pParentMediumItem)
             {
-                /* Make sure such corresponding parent medium is already cached! */
+                /* Make sure corresponding parent medium is already cached! */
                 UIMedium parentMedium = vboxGlobal().medium(medium.parentID());
                 if (parentMedium.isNull())
@@ -1706,5 +1716,5 @@
     }
 
-    /* Return medium-item: */
+    /* Return created medium-item: */
     return pMediumItem;
 }
