Changeset 85594 in vbox
- Timestamp:
- Aug 3, 2020 10:48:32 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/monitor/resource/UIResourceMonitor.cpp
r85592 r85594 303 303 const QMap<int, int> dataLengths() const; 304 304 QUuid itemUid(int iIndex); 305 int itemIndex(const QUuid &uid); 305 306 306 307 private slots: … … 320 321 321 322 QVector<UIResourceMonitorItem> m_itemList; 322 /* Used to find machines by uid. key is the machine uid and int is the index to m_itemList */323 QMap<QUuid, int> m_itemMap;324 323 QMap<int, QString> m_columnTitles; 325 324 QTimer *m_pTimer; … … 956 955 } 957 956 957 int UIResourceMonitorModel::itemIndex(const QUuid &uid) 958 { 959 for (int i = 0; i < m_itemList.size(); ++i) 960 { 961 if (m_itemList[i].m_VMuid == uid) 962 return i; 963 } 964 return -1; 965 } 966 958 967 QVariant UIResourceMonitorModel::data(const QModelIndex &index, int role) const 959 968 { … … 990 999 void UIResourceMonitorModel::sltMachineStateChanged(const QUuid &uId, const KMachineState state) 991 1000 { 992 int iIndex = m_itemMap.value(uId, -1);1001 int iIndex = itemIndex(uId); 993 1002 /* Remove the machine in case machine is no longer working. */ 994 1003 if (iIndex != -1 && state != KMachineState_Running) … … 1198 1207 if (comMachine.isNull()) 1199 1208 continue; 1200 int iIndex = m_itemMap.value(comMachine.GetId(), -1);1209 int iIndex = itemIndex(comMachine.GetId()); 1201 1210 if (iIndex == -1 || iIndex >= m_itemList.size()) 1202 1211 continue; … … 1253 1262 void UIResourceMonitorModel::addItem(const QUuid& uMachineId, const QString& strMachineName) 1254 1263 { 1255 int iIndex = m_itemList.size();1256 1264 m_itemList.append(UIResourceMonitorItem(uMachineId, strMachineName)); 1257 m_itemMap[uMachineId] = iIndex;1258 1265 } 1259 1266 1260 1267 void UIResourceMonitorModel::removeItem(const QUuid& uMachineId) 1261 1268 { 1262 int iIndex = m_itemMap.value(uMachineId, -1);1269 int iIndex = itemIndex(uMachineId); 1263 1270 if (iIndex == -1) 1264 1271 return; 1265 1272 m_itemList.remove(iIndex); 1266 m_itemMap.remove(uMachineId);1267 1273 } 1268 1274
Note:
See TracChangeset
for help on using the changeset viewer.