- Timestamp:
- Mar 23, 2020 10:35:27 AM (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
r83345 r83365 59 59 // VMResouceMonitorColumn_RAMUsedPercentage, 60 60 VMResouceMonitorColumn_NetworkDownUpRate, 61 //VMResouceMonitorColumn_NetworkDownUpTotal,62 //VMResouceMonitorColumn_DiskIOWriteReadRate,63 //VMResouceMonitorColumn_DiskIOWriteReadTotal,61 VMResouceMonitorColumn_NetworkDownUpTotal, 62 VMResouceMonitorColumn_DiskIOWriteReadRate, 63 VMResouceMonitorColumn_DiskIOWriteReadTotal, 64 64 VMResouceMonitorColumn_Max 65 65 }; … … 104 104 105 105 UIResourceMonitorProxyModel(QObject *parent = 0); 106 void dataUpdate(); 106 107 107 108 protected: … … 120 121 { 121 122 Q_OBJECT; 123 124 signals: 125 126 void sigDataUpdate(); 122 127 123 128 public: … … 208 213 } 209 214 215 void UIResourceMonitorProxyModel::dataUpdate() 216 { 217 if (sourceModel()) 218 emit dataChanged(index(0,0), index(sourceModel()->rowCount(), sourceModel()->columnCount())); 219 } 220 210 221 211 222 /********************************************************************************************************************************* … … 241 252 QVariant UIResourceMonitorModel::data(const QModelIndex &index, int role) const 242 253 { 254 int iDecimalCount = 2; 243 255 if (!index.isValid() || role != Qt::DisplayRole || index.row() >= rowCount()) 244 256 return QVariant(); … … 255 267 break; 256 268 case VMResouceMonitorColumn_NetworkDownUpRate: 257 return QString("%1/%2").arg(m_itemList[index.row()].m_uNetworkDownRate).arg(m_itemList[index.row()].m_uNetworkUpRate); 269 return QString("%1/%2").arg(uiCommon().formatSize(m_itemList[index.row()].m_uNetworkDownRate, iDecimalCount)). 270 arg(uiCommon().formatSize(m_itemList[index.row()].m_uNetworkUpRate, iDecimalCount)); 271 break; 272 case VMResouceMonitorColumn_NetworkDownUpTotal: 273 return QString("%1/%2").arg(uiCommon().formatSize(m_itemList[index.row()].m_uNetworkDownTotal, iDecimalCount)). 274 arg(uiCommon().formatSize(m_itemList[index.row()].m_uNetworkUpTotal, iDecimalCount)); 275 break; 276 case VMResouceMonitorColumn_DiskIOWriteReadRate: 277 return QString("%1/%2").arg(uiCommon().formatSize(m_itemList[index.row()].m_uDiskWriteRate, iDecimalCount)). 278 arg(uiCommon().formatSize(m_itemList[index.row()].m_uDiskReadRate, iDecimalCount)); 279 break; 280 case VMResouceMonitorColumn_DiskIOWriteReadTotal: 281 return QString("%1/%2").arg(uiCommon().formatSize(m_itemList[index.row()].m_uDiskWriteTotal, iDecimalCount)). 282 arg(uiCommon().formatSize(m_itemList[index.row()].m_uDiskReadTotal, iDecimalCount)); 258 283 break; 259 284 default: … … 273 298 break; 274 299 case VMResouceMonitorColumn_CPUGuestLoad: 275 return tr("CPU Load 300 return tr("CPU Load\n(Guest)"); 276 301 break; 277 302 case VMResouceMonitorColumn_CPUVMMLoad: 278 return tr("CPU Load 303 return tr("CPU Load\n(VMM)"); 279 304 break; 280 305 // case VMResouceMonitorColumn_RAMUsedAndTotal: … … 285 310 // break; 286 311 case VMResouceMonitorColumn_NetworkDownUpRate: 287 return tr("Network Up/Down Rate"); 312 return tr("Network Up/Down\nRate"); 313 break; 314 case VMResouceMonitorColumn_NetworkDownUpTotal: 315 return tr("Network Up/Down\nTotal"); 316 break; 317 case VMResouceMonitorColumn_DiskIOWriteReadRate: 318 return tr("Disk Write/Read\nRate"); 319 break; 320 case VMResouceMonitorColumn_DiskIOWriteReadTotal: 321 return tr("Disk Write/Read\nTotal"); 288 322 break; 289 323 … … 312 346 void UIResourceMonitorModel::sltMachineStateChanged(const QUuid &uId, const KMachineState state) 313 347 { 348 emit layoutAboutToBeChanged(); 314 349 int iIndex = m_itemList.indexOf(UIResourceMonitorItem(uId)); 315 350 /* Remove the machine in case machine is no longer working. */ 316 351 if (iIndex != -1 && state != KMachineState_Running) 317 {318 352 m_itemList.remove(iIndex); 319 emit layoutChanged();320 }321 353 322 354 /* Insert the machine if it is working. */ … … 325 357 CMachine comMachine = uiCommon().virtualBox().FindMachine(uId.toString()); 326 358 m_itemList << UIResourceMonitorItem(uId, comMachine.GetName()); 327 emit layoutChanged();328 }359 } 360 emit layoutChanged(); 329 361 } 330 362 … … 341 373 m_itemList[i].m_uCPUGuestLoad = aPctExecuting; 342 374 m_itemList[i].m_uCPUVMMLoad = aPctVMM; 375 UIMonitorCommon::getNetworkLoad(m_itemList[i].m_comDebugger, 376 m_itemList[i].m_uNetworkDownRate, m_itemList[i].m_uNetworkUpRate); 377 m_itemList[i].m_uNetworkDownTotal += m_itemList[i].m_uNetworkDownRate; 378 m_itemList[i].m_uNetworkUpTotal += m_itemList[i].m_uNetworkUpRate; 379 380 UIMonitorCommon::getDiskLoad(m_itemList[i].m_comDebugger, 381 m_itemList[i].m_uDiskWriteRate, m_itemList[i].m_uDiskReadRate); 382 m_itemList[i].m_uDiskWriteTotal += m_itemList[i].m_uDiskWriteRate; 383 m_itemList[i].m_uDiskReadTotal += m_itemList[i].m_uDiskReadRate; 343 384 } 344 385 } 345 emit layoutChanged();386 //emit layoutChanged(); 346 387 /* dataChanged signal result in view update when there is a proxy model in between. */ 347 388 //emit dataChanged(index(0,0), index(rowCount(), columnCount())); 389 emit sigDataUpdate(); 348 390 } 349 391 … … 437 479 m_pTableWidget->verticalHeader()->setDefaultSectionSize(m_pTableWidget->verticalHeader()->minimumSectionSize()); 438 480 m_pTableWidget->setAlternatingRowColors(true); 481 m_pTableWidget->setSortingEnabled(true); 482 m_pTableWidget->sortByColumn(0, Qt::AscendingOrder); 483 connect(m_pModel, &UIResourceMonitorModel::sigDataUpdate, this, &UIResourceMonitorWidget::sltHandleDataUpdate); 439 484 } 440 485 } … … 470 515 } 471 516 517 void UIResourceMonitorWidget::sltHandleDataUpdate() 518 { 519 if (m_pProxyModel) 520 m_pProxyModel->dataUpdate(); 521 } 522 472 523 473 524 /********************************************************************************************************************************* -
trunk/src/VBox/Frontends/VirtualBox/src/monitor/resource/UIResourceMonitor.h
r83334 r83365 72 72 private slots: 73 73 74 void sltHandleDataUpdate(); 74 75 75 76 private:
Note:
See TracChangeset
for help on using the changeset viewer.