Index: /trunk/src/VBox/Frontends/VirtualBox/src/monitor/resource/UIResourceMonitor.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/monitor/resource/UIResourceMonitor.cpp	(revision 83474)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/monitor/resource/UIResourceMonitor.cpp	(revision 83475)
@@ -60,4 +60,33 @@
     bool    m_fEnabled;
 };
+
+
+/*********************************************************************************************************************************
+*   Class UIVMResouceMonitorTableView definition.                                                                           *
+*********************************************************************************************************************************/
+
+class UIVMResouceMonitorTableView : public QTableView
+{
+    Q_OBJECT;
+
+public:
+
+    UIVMResouceMonitorTableView(QWidget *pParent = 0);
+
+protected:
+
+    virtual void resizeEvent(QResizeEvent *pEvent) /* override */;
+
+private slots:
+
+    void sltHeaderResized(int iIndex, int iOldSize, int iNewSize);
+
+private:
+
+    void resizeHeader();
+    QSet<int> m_userResizedColums;
+
+};
+
 /*********************************************************************************************************************************
 *   Class UIVMResouceMonitorItem definition.                                                                           *
@@ -70,5 +99,5 @@
     UIResourceMonitorItem();
     bool operator==(const UIResourceMonitorItem& other) const;
-    bool isWithGuestAdditions();
+    bool isWithGuestAdditions() const;
 
     QUuid    m_VMuid;
@@ -96,5 +125,5 @@
 
     CMachineDebugger m_comDebugger;
-    CGuest           m_comGuest;
+    mutable CGuest           m_comGuest;
 private:
 
@@ -208,4 +237,42 @@
     virtual void drawFocus ( QPainter * /*painter*/, const QStyleOptionViewItem & /*option*/, const QRect & /*rect*/ ) const {}
 };
+
+/*********************************************************************************************************************************
+*   Class UIVMResouceMonitorTableView implementation.                                                                           *
+*********************************************************************************************************************************/
+
+UIVMResouceMonitorTableView::UIVMResouceMonitorTableView(QWidget *pParent /* = 0 */)
+    :QTableView(pParent)
+{
+    QHeaderView* pHeader = horizontalHeader();
+    if (pHeader)
+    {
+        connect(pHeader, &QHeaderView::sectionResized, this, &UIVMResouceMonitorTableView::sltHeaderResized);
+        //pHeader->setResizeMode(QHeaderView::ResizeToContents);
+    }
+}
+
+void UIVMResouceMonitorTableView::resizeEvent(QResizeEvent *pEvent)
+{
+    //resizeHeader();
+    QTableView::resizeEvent(pEvent);
+}
+
+void UIVMResouceMonitorTableView::resizeHeader()
+{
+    QHeaderView* pHeader = horizontalHeader();
+    if (!pHeader)
+        return;
+    int iSectionCount = pHeader->count();
+    if (iSectionCount <= 0)
+        return;
+    pHeader->setDefaultSectionSize(width() / iSectionCount);
+}
+
+void UIVMResouceMonitorTableView::sltHeaderResized(int iIndex, int iOldSize, int iNewSize)
+{
+    printf("section resize %d %d %d\n", iIndex, iOldSize, iNewSize);
+}
+
 
 /*********************************************************************************************************************************
@@ -291,5 +358,5 @@
 }
 
-bool UIResourceMonitorItem::isWithGuestAdditions()
+bool UIResourceMonitorItem::isWithGuestAdditions() const
 {
     if (m_comGuest.isNull())
@@ -386,5 +453,4 @@
     if (!index.isValid() || role != Qt::DisplayRole || index.row() >= rowCount())
         return QVariant();
-    UIResourceMonitorItem* pItem = static_cast<UIResourceMonitorItem*>(index.internalPointer());
 
     switch (index.column())
@@ -400,5 +466,5 @@
             break;
         case VMResouceMonitorColumn_RAMUsedAndTotal:
-            if (pItem && pItem->isWithGuestAdditions())
+            if (m_itemList[index.row()].isWithGuestAdditions())
                 return QString("%1/%2").arg(uiCommon().formatSize(_1K * m_itemList[index.row()].m_uUsedRAM, iDecimalCount)).
                     arg(uiCommon().formatSize(_1K * m_itemList[index.row()].m_uTotalRAM, iDecimalCount));
@@ -407,5 +473,5 @@
             break;
         case VMResouceMonitorColumn_RAMUsedPercentage:
-            if (pItem && pItem->isWithGuestAdditions())
+            if (m_itemList[index.row()].isWithGuestAdditions())
                 return QString("%1%").arg(QString::number(m_itemList[index.row()].m_fRAMUsagePercentage, 'f', 2));
             else
@@ -671,4 +737,5 @@
     , m_pModel(0)
     , m_pColumnSelectionMenu(0)
+    , m_fIsCurrentTool(true)
 {
     /* Prepare: */
@@ -684,4 +751,14 @@
 {
     return NULL;
+}
+
+bool UIResourceMonitorWidget::isCurrentTool() const
+{
+    return m_fIsCurrentTool;
+}
+
+void UIResourceMonitorWidget::setIsCurrentTool(bool fIsCurrentTool)
+{
+    m_fIsCurrentTool = fIsCurrentTool;
 }
 
@@ -753,5 +830,5 @@
     m_pProxyModel = new UIResourceMonitorProxyModel(this);
 
-    m_pTableView = new QTableView();
+    m_pTableView = new UIVMResouceMonitorTableView();
     if (m_pTableView && m_pModel && m_pProxyModel)
     {
@@ -768,5 +845,5 @@
         m_pTableView->setShowGrid(false);
         m_pTableView->horizontalHeader()->setHighlightSections(false);
-        m_pTableView->horizontalHeader()->setSectionResizeMode(QHeaderView::Interactive);
+        //m_pTableView->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
         //m_pTableView->horizontalHeader()->setStretchLastSection(true);
 
Index: /trunk/src/VBox/Frontends/VirtualBox/src/monitor/resource/UIResourceMonitor.h
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/monitor/resource/UIResourceMonitor.h	(revision 83474)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/monitor/resource/UIResourceMonitor.h	(revision 83475)
@@ -39,4 +39,5 @@
 class UIResourceMonitorProxyModel;
 class UIResourceMonitorModel;
+class UIVMResouceMonitorTableView;
 
 /** QWidget extension to display a Linux top like utility that sort running vm wrt. resource allocations. */
@@ -53,6 +54,8 @@
                                bool fShowToolbar = true, QWidget *pParent = 0);
     ~UIResourceMonitorWidget();
+    QMenu *menu() const;
 
-    QMenu *menu() const;
+    bool isCurrentTool() const;
+    void setIsCurrentTool(bool fIsCurrentTool);
 
 #ifdef VBOX_WS_MAC
@@ -103,5 +106,5 @@
       * @{ */
         UIToolBar *m_pToolBar;
-        QTableView *m_pTableView;
+        UIVMResouceMonitorTableView *m_pTableView;
         UIResourceMonitorProxyModel *m_pProxyModel;
         UIResourceMonitorModel      *m_pModel;
@@ -110,5 +113,7 @@
         QMap<int, bool>              m_columnVisible;
     /** @} */
-    QFrame* m_pColumnSelectionMenu;
+    QFrame *m_pColumnSelectionMenu;
+    /** Indicates if this widget's host tool is current tool. */
+    bool    m_fIsCurrentTool;
 };
 
