Changeset 83475 in vbox
- Timestamp:
- Mar 30, 2020 11:10:50 AM (5 years ago)
- svn:sync-xref-src-repo-rev:
- 136714
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/monitor/resource
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/monitor/resource/UIResourceMonitor.cpp ¶
r83469 r83475 60 60 bool m_fEnabled; 61 61 }; 62 63 64 /********************************************************************************************************************************* 65 * Class UIVMResouceMonitorTableView definition. * 66 *********************************************************************************************************************************/ 67 68 class UIVMResouceMonitorTableView : public QTableView 69 { 70 Q_OBJECT; 71 72 public: 73 74 UIVMResouceMonitorTableView(QWidget *pParent = 0); 75 76 protected: 77 78 virtual void resizeEvent(QResizeEvent *pEvent) /* override */; 79 80 private slots: 81 82 void sltHeaderResized(int iIndex, int iOldSize, int iNewSize); 83 84 private: 85 86 void resizeHeader(); 87 QSet<int> m_userResizedColums; 88 89 }; 90 62 91 /********************************************************************************************************************************* 63 92 * Class UIVMResouceMonitorItem definition. * … … 70 99 UIResourceMonitorItem(); 71 100 bool operator==(const UIResourceMonitorItem& other) const; 72 bool isWithGuestAdditions() ;101 bool isWithGuestAdditions() const; 73 102 74 103 QUuid m_VMuid; … … 96 125 97 126 CMachineDebugger m_comDebugger; 98 CGuest m_comGuest;127 mutable CGuest m_comGuest; 99 128 private: 100 129 … … 208 237 virtual void drawFocus ( QPainter * /*painter*/, const QStyleOptionViewItem & /*option*/, const QRect & /*rect*/ ) const {} 209 238 }; 239 240 /********************************************************************************************************************************* 241 * Class UIVMResouceMonitorTableView implementation. * 242 *********************************************************************************************************************************/ 243 244 UIVMResouceMonitorTableView::UIVMResouceMonitorTableView(QWidget *pParent /* = 0 */) 245 :QTableView(pParent) 246 { 247 QHeaderView* pHeader = horizontalHeader(); 248 if (pHeader) 249 { 250 connect(pHeader, &QHeaderView::sectionResized, this, &UIVMResouceMonitorTableView::sltHeaderResized); 251 //pHeader->setResizeMode(QHeaderView::ResizeToContents); 252 } 253 } 254 255 void UIVMResouceMonitorTableView::resizeEvent(QResizeEvent *pEvent) 256 { 257 //resizeHeader(); 258 QTableView::resizeEvent(pEvent); 259 } 260 261 void UIVMResouceMonitorTableView::resizeHeader() 262 { 263 QHeaderView* pHeader = horizontalHeader(); 264 if (!pHeader) 265 return; 266 int iSectionCount = pHeader->count(); 267 if (iSectionCount <= 0) 268 return; 269 pHeader->setDefaultSectionSize(width() / iSectionCount); 270 } 271 272 void UIVMResouceMonitorTableView::sltHeaderResized(int iIndex, int iOldSize, int iNewSize) 273 { 274 printf("section resize %d %d %d\n", iIndex, iOldSize, iNewSize); 275 } 276 210 277 211 278 /********************************************************************************************************************************* … … 291 358 } 292 359 293 bool UIResourceMonitorItem::isWithGuestAdditions() 360 bool UIResourceMonitorItem::isWithGuestAdditions() const 294 361 { 295 362 if (m_comGuest.isNull()) … … 386 453 if (!index.isValid() || role != Qt::DisplayRole || index.row() >= rowCount()) 387 454 return QVariant(); 388 UIResourceMonitorItem* pItem = static_cast<UIResourceMonitorItem*>(index.internalPointer());389 455 390 456 switch (index.column()) … … 400 466 break; 401 467 case VMResouceMonitorColumn_RAMUsedAndTotal: 402 if ( pItem && pItem->isWithGuestAdditions())468 if (m_itemList[index.row()].isWithGuestAdditions()) 403 469 return QString("%1/%2").arg(uiCommon().formatSize(_1K * m_itemList[index.row()].m_uUsedRAM, iDecimalCount)). 404 470 arg(uiCommon().formatSize(_1K * m_itemList[index.row()].m_uTotalRAM, iDecimalCount)); … … 407 473 break; 408 474 case VMResouceMonitorColumn_RAMUsedPercentage: 409 if ( pItem && pItem->isWithGuestAdditions())475 if (m_itemList[index.row()].isWithGuestAdditions()) 410 476 return QString("%1%").arg(QString::number(m_itemList[index.row()].m_fRAMUsagePercentage, 'f', 2)); 411 477 else … … 671 737 , m_pModel(0) 672 738 , m_pColumnSelectionMenu(0) 739 , m_fIsCurrentTool(true) 673 740 { 674 741 /* Prepare: */ … … 684 751 { 685 752 return NULL; 753 } 754 755 bool UIResourceMonitorWidget::isCurrentTool() const 756 { 757 return m_fIsCurrentTool; 758 } 759 760 void UIResourceMonitorWidget::setIsCurrentTool(bool fIsCurrentTool) 761 { 762 m_fIsCurrentTool = fIsCurrentTool; 686 763 } 687 764 … … 753 830 m_pProxyModel = new UIResourceMonitorProxyModel(this); 754 831 755 m_pTableView = new QTableView();832 m_pTableView = new UIVMResouceMonitorTableView(); 756 833 if (m_pTableView && m_pModel && m_pProxyModel) 757 834 { … … 768 845 m_pTableView->setShowGrid(false); 769 846 m_pTableView->horizontalHeader()->setHighlightSections(false); 770 m_pTableView->horizontalHeader()->setSectionResizeMode(QHeaderView::Interactive);847 //m_pTableView->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents); 771 848 //m_pTableView->horizontalHeader()->setStretchLastSection(true); 772 849 -
trunk/src/VBox/Frontends/VirtualBox/src/monitor/resource/UIResourceMonitor.h ¶
r83469 r83475 39 39 class UIResourceMonitorProxyModel; 40 40 class UIResourceMonitorModel; 41 class UIVMResouceMonitorTableView; 41 42 42 43 /** QWidget extension to display a Linux top like utility that sort running vm wrt. resource allocations. */ … … 53 54 bool fShowToolbar = true, QWidget *pParent = 0); 54 55 ~UIResourceMonitorWidget(); 56 QMenu *menu() const; 55 57 56 QMenu *menu() const; 58 bool isCurrentTool() const; 59 void setIsCurrentTool(bool fIsCurrentTool); 57 60 58 61 #ifdef VBOX_WS_MAC … … 103 106 * @{ */ 104 107 UIToolBar *m_pToolBar; 105 QTableView *m_pTableView;108 UIVMResouceMonitorTableView *m_pTableView; 106 109 UIResourceMonitorProxyModel *m_pProxyModel; 107 110 UIResourceMonitorModel *m_pModel; … … 110 113 QMap<int, bool> m_columnVisible; 111 114 /** @} */ 112 QFrame* m_pColumnSelectionMenu; 115 QFrame *m_pColumnSelectionMenu; 116 /** Indicates if this widget's host tool is current tool. */ 117 bool m_fIsCurrentTool; 113 118 }; 114 119
Note:
See TracChangeset
for help on using the changeset viewer.