- Timestamp:
- Mar 27, 2020 12:57:00 PM (5 years ago)
- 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
r83452 r83466 70 70 UIResourceMonitorItem(); 71 71 bool operator==(const UIResourceMonitorItem& other) const; 72 bool isWithGuestAdditions(); 73 72 74 QUuid m_VMuid; 73 75 QString m_strVMName; … … 94 96 95 97 CMachineDebugger m_comDebugger; 96 98 CGuest m_comGuest; 97 99 private: 98 100 … … 130 132 UIResourceMonitorProxyModel(QObject *parent = 0); 131 133 void dataUpdate(); 132 void setColumn Shown(const QVector<bool>& columnShown);134 void setColumnVisible(const QMap<int, bool>& columnVisible); 133 135 134 136 protected: … … 139 141 private: 140 142 141 Q Vector<bool> m_columnShown;143 QMap<int, bool> m_columnVisible; 142 144 143 145 }; … … 234 236 CConsole comConsole = comSession.GetConsole(); 235 237 if (!comConsole.isNull()) 238 { 239 m_comGuest = comConsole.GetGuest(); 236 240 m_comDebugger = comConsole.GetDebugger(); 241 } 237 242 } 238 243 } … … 285 290 } 286 291 292 bool UIResourceMonitorItem::isWithGuestAdditions() 293 { 294 if (m_comGuest.isNull()) 295 return false; 296 return m_comGuest.GetAdditionsStatus(m_comGuest.GetAdditionsRunLevel()); 297 } 298 287 299 288 300 /********************************************************************************************************************************* … … 323 335 { 324 336 Q_UNUSED(sourceParent); 325 if (iSourceColumn >= m_columnShown.size()) 326 return true; 327 return m_columnShown[iSourceColumn]; 328 } 329 330 void UIResourceMonitorProxyModel::setColumnShown(const QVector<bool>& columnShown) 337 return m_columnVisible.value(iSourceColumn, true); 338 } 339 340 void UIResourceMonitorProxyModel::setColumnVisible(const QMap<int, bool>& columnVisible) 331 341 { 332 342 emit layoutAboutToBeChanged(); 333 m_column Shown = columnShown;343 m_columnVisible = columnVisible; 334 344 invalidateFilter(); 335 345 emit layoutChanged(); … … 720 730 connect(m_pModel, &UIResourceMonitorModel::sigDataUpdate, this, &UIResourceMonitorWidget::sltHandleDataUpdate); 721 731 722 m_pProxyModel->setColumn Shown(m_columnShown);732 m_pProxyModel->setColumnVisible(m_columnVisible); 723 733 } 724 734 } … … 743 753 pLayout->addWidget(pCheckBox); 744 754 pCheckBox->setData(i); 745 if (i < m_columnShown.size()) 746 pCheckBox->setChecked(m_columnShown[i]); 755 pCheckBox->setChecked(columnVisible(i)); 747 756 if (i == (int)VMResouceMonitorColumn_Name) 748 757 pCheckBox->setEnabled(false); … … 789 798 { 790 799 QStringList hiddenColumnList = gEDataManager->VMResourceMonitorHiddenColumnList(); 791 m_columnShown.resize(VMResouceMonitorColumn_Max); 792 for (int i = 0; i < m_columnShown.size(); ++i) 793 m_columnShown[i] = true; 800 for (int i = (int)VMResouceMonitorColumn_Name; i < (int)VMResouceMonitorColumn_Max; ++i) 801 m_columnVisible[i] = true; 794 802 foreach(const QString& strColumn, hiddenColumnList) 795 { 796 VMResouceMonitorColumn enmColumn = gpConverter->fromInternalString<VMResouceMonitorColumn>(strColumn); 797 if ((int)enmColumn < m_columnShown.size()) 798 m_columnShown[(int)enmColumn] = false; 799 } 803 setColumnVisible((int)gpConverter->fromInternalString<VMResouceMonitorColumn>(strColumn), false); 800 804 } 801 805 … … 803 807 { 804 808 QStringList hiddenColumnList; 805 for (int i = 0; i < m_column Shown.size(); ++i)806 { 807 if (! m_columnShown[i])809 for (int i = 0; i < m_columnVisible.size(); ++i) 810 { 811 if (!columnVisible(i)) 808 812 hiddenColumnList << gpConverter->toInternalString((VMResouceMonitorColumn) i); 809 813 } … … 844 848 if (!pSender) 845 849 return; 846 int iColumnId = pSender->data().toInt(); 847 if (iColumnId >= m_columnShown.size()) 848 return; 849 setColumnShown(iColumnId, fChecked); 850 setColumnVisible(pSender->data().toInt(), fChecked); 850 851 } 851 852 … … 856 857 } 857 858 858 void UIResourceMonitorWidget::setColumn Shown(int iColumnId, bool fShown)859 { 860 if ( iColumnId >= m_columnShown.size())859 void UIResourceMonitorWidget::setColumnVisible(int iColumnId, bool fVisible) 860 { 861 if (m_columnVisible.contains(iColumnId) && m_columnVisible[iColumnId] == fVisible) 861 862 return; 862 if (m_columnShown[iColumnId] == fShown) 863 return; 864 m_columnShown[iColumnId] = fShown; 863 m_columnVisible[iColumnId] = fVisible; 865 864 if (m_pProxyModel) 866 m_pProxyModel->setColumnShown(m_columnShown); 865 m_pProxyModel->setColumnVisible(m_columnVisible); 866 } 867 868 bool UIResourceMonitorWidget::columnVisible(int iColumnId) const 869 { 870 return m_columnVisible.value(iColumnId, true); 867 871 } 868 872 -
trunk/src/VBox/Frontends/VirtualBox/src/monitor/resource/UIResourceMonitor.h
r83452 r83466 78 78 private: 79 79 80 void setColumnShown(int iColumnId, bool fShown); 80 void setColumnVisible(int iColumnId, bool fVisible); 81 bool columnVisible(int iColumnId) const; 82 81 83 /** @name Prepare/cleanup cascade. 82 84 * @{ */ … … 104 106 UIResourceMonitorModel *m_pModel; 105 107 QVector<QString> m_columnCaptions; 106 QVector<bool> m_columnShown; 108 /* The key is the column id (VMResouceMonitorColumn) and value is true if the column is visible. */ 109 QMap<int, bool> m_columnVisible; 107 110 /** @} */ 108 111 QFrame* m_pColumnSelectionMenu;
Note:
See TracChangeset
for help on using the changeset viewer.