Changeset 80409 in vbox for trunk/src/VBox
- Timestamp:
- Aug 23, 2019 10:43:22 PM (5 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/runtime/information
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/runtime/information/UIInformationRuntime.cpp
r80407 r80409 587 587 strValue = QString::number(iValue); 588 588 else if (m_pSubMetric->unit().compare("kb", Qt::CaseInsensitive) == 0) 589 strValue = uiCommon().formatSize(_1K * (qu int64)iValue, iDecimalCount);589 strValue = uiCommon().formatSize(_1K * (qulonglong)iValue, iDecimalCount); 590 590 else if (m_pSubMetric->unit().compare("b", Qt::CaseInsensitive) == 0 || 591 591 m_pSubMetric->unit().compare("b/s", Qt::CaseInsensitive) == 0) … … 804 804 , m_strRAMMetricName("RAM Usage") 805 805 , m_strDiskMetricName("Disk Usage") 806 , m_strNetMetricName("Net") 807 , m_strNetDebuggerMetricName("NetDebugger") 808 806 , m_strNetworkMetricName("NetDebugger") 807 , m_iTimeStep(0) 809 808 { 810 809 if (!m_console.isNull()) … … 844 843 m_strRAMInfoLabelUsed = QApplication::translate("UIVMInformationDialog", "Used"); 845 844 iMaximum = qMax(iMaximum, m_strRAMInfoLabelUsed.length()); 846 m_strNetInfoLabelTitle = QApplication::translate("UIVMInformationDialog", "Network"); 847 iMaximum = qMax(iMaximum, m_strNetInfoLabelTitle.length()); 848 m_strNetInfoLabelReceived = QApplication::translate("UIVMInformationDialog", "Receive Rate"); 849 iMaximum = qMax(iMaximum, m_strNetInfoLabelReceived.length()); 850 m_strNetInfoLabelTransmitted = QApplication::translate("UIVMInformationDialog", "Transmit Rate"); 851 iMaximum = qMax(iMaximum, m_strNetInfoLabelTransmitted.length()); 852 m_strNetInfoLabelMaximum = QApplication::translate("UIVMInformationDialog", "Maximum"); 853 iMaximum = qMax(iMaximum, m_strNetInfoLabelMaximum.length()); 845 m_strNetworkInfoLabelTitle = QApplication::translate("UIVMInformationDialog", "Network"); 846 iMaximum = qMax(iMaximum, m_strNetworkInfoLabelTitle.length()); 847 m_strNetworkInfoLabelReceived = QApplication::translate("UIVMInformationDialog", "Receive Rate"); 848 iMaximum = qMax(iMaximum, m_strNetworkInfoLabelReceived.length()); 849 m_strNetworkInfoLabelTransmitted = QApplication::translate("UIVMInformationDialog", "Transmit Rate"); 850 iMaximum = qMax(iMaximum, m_strNetworkInfoLabelTransmitted.length()); 851 m_strNetworkInfoLabelReceivedTotal = QApplication::translate("UIVMInformationDialog", "Total Received"); 852 iMaximum = qMax(iMaximum, m_strNetworkInfoLabelReceivedTotal.length()); 853 m_strNetworkInfoLabelTransmittedTotal = QApplication::translate("UIVMInformationDialog", "Total Transmitted"); 854 iMaximum = qMax(iMaximum, m_strNetworkInfoLabelReceivedTotal.length()); 855 854 856 855 857 /* Compute the maximum label string length and set it as a fixed width to labels to prevent always changing widths: */ 856 /* Add m_iDecimalCount plus 3 characters for the number and 2for unit string: */857 iMaximum += (iDecimalCount + 5);858 /* Add m_iDecimalCount plus 3 characters for the number and 3 for unit string: */ 859 iMaximum += (iDecimalCount + 7); 858 860 if (!m_infoLabels.isEmpty()) 859 861 { … … 862 864 { 863 865 QFontMetrics labelFontMetric(pLabel->font()); 864 int iWidth = iMaximum * labelFontMetric.width(' x');866 int iWidth = iMaximum * labelFontMetric.width('X'); 865 867 foreach (QLabel *pInfoLabel, m_infoLabels) 866 868 pInfoLabel->setFixedWidth(iWidth); … … 890 892 891 893 QStringList chartOder; 892 chartOder << m_strCPUMetricName << m_strRAMMetricName << m_strDiskMetricName << m_strNet MetricName << m_strNetDebuggerMetricName;894 chartOder << m_strCPUMetricName << m_strRAMMetricName << m_strDiskMetricName << m_strNetworkMetricName; 893 895 int iRow = 0; 894 896 foreach (const QString &strMetricName, chartOder) … … 909 911 910 912 /* Configure charts: */ 911 if (m_charts.contains(m_strNetMetricName) && m_charts[m_strNetMetricName]) 912 { 913 m_charts[m_strNetMetricName]->setDrawPieChart(false); 914 m_charts[m_strNetMetricName]->setUseGradientLineColor(false); 915 } 916 if (m_charts.contains(m_strNetDebuggerMetricName) && m_charts[m_strNetDebuggerMetricName]) 917 { 918 m_charts[m_strNetDebuggerMetricName]->setDrawPieChart(false); 919 m_charts[m_strNetDebuggerMetricName]->setUseGradientLineColor(false); 913 if (m_charts.contains(m_strNetworkMetricName) && m_charts[m_strNetworkMetricName]) 914 { 915 m_charts[m_strNetworkMetricName]->setDrawPieChart(false); 916 m_charts[m_strNetworkMetricName]->setUseGradientLineColor(false); 920 917 } 921 918 … … 941 938 if (m_performanceMonitor.isNull()) 942 939 return; 940 ++m_iTimeStep; 943 941 QVector<QString> allNames;// = new ArrayList<IUnknown>(); 944 942 QVector<CUnknown> allObjects;// = new ArrayList<IUnknown>(); … … 961 959 aReturnDataIndices, 962 960 aReturnDataLengths); 963 quint64 iTotalRAM = 0; 964 quint64 iFreeRAM = 0; 965 ULONG iReceiveRate = 0; 966 ULONG iTransmitRate = 0; 961 qulonglong iTotalRAM = 0; 962 qulonglong iFreeRAM = 0; 967 963 968 964 for (int i = 0; i < aReturnNames.size(); ++i) … … 979 975 iFreeRAM = (quint64)fData; 980 976 } 981 else if (aReturnNames[i].contains("Net/Rate", Qt::CaseInsensitive) && !aReturnNames[i].contains(":"))982 {983 if (aReturnNames[i].contains("Rx", Qt::CaseInsensitive))984 iReceiveRate = fData;985 if (aReturnNames[i].contains("Tx", Qt::CaseInsensitive))986 iTransmitRate = fData;987 }988 977 } 989 978 if (m_subMetrics.contains(m_strRAMMetricName)) 990 979 updateRAMGraphsAndMetric(iTotalRAM, iFreeRAM); 991 if (m_subMetrics.contains(m_strNetMetricName))992 updateNetworkGraphsAndMetric(iReceiveRate, iTransmitRate);993 980 994 981 /* Update the CPU load chart with values we get from IMachineDebugger::getCPULoad(..): */ … … 1017 1004 if (data.m_strName.contains(strDeviceType, Qt::CaseInsensitive)) 1018 1005 { 1019 if (metric.name() == m_strNet DebuggerMetricName)1006 if (metric.name() == m_strNetworkMetricName) 1020 1007 { 1021 1008 if (data.m_strName.contains("receive", Qt::CaseInsensitive)) … … 1050 1037 return; 1051 1038 1052 // m_nameList << "Guest/RAM/Usage*";1053 1039 m_nameList << "Guest/RAM/Usage*"; 1054 m_nameList << "Net/Rate*";1055 1056 1057 1040 m_objectList = QVector<CUnknown>(m_nameList.size(), CUnknown()); 1058 1041 m_performanceMonitor.SetupMetrics(m_nameList, m_objectList, iPeriod, iMetricSetupCount); … … 1070 1053 m_subMetrics.insert(m_strRAMMetricName, newMetric); 1071 1054 } 1072 else if (strName.contains("Net", Qt::CaseInsensitive))1073 {1074 UISubMetric newMetric(m_strNetMetricName, metrics[i].GetUnit(), iMaximumQueueSize);1075 newMetric.setRequiresGuestAdditions(true);1076 m_subMetrics.insert(m_strNetMetricName, newMetric);1077 }1078 1055 } 1079 1056 } … … 1082 1059 m_subMetrics.insert(m_strCPUMetricName, UISubMetric(m_strCPUMetricName, "%", iMaximumQueueSize)); 1083 1060 1084 UISubMetric networkMetric(m_strNet DebuggerMetricName, "B", iMaximumQueueSize);1061 UISubMetric networkMetric(m_strNetworkMetricName, "B", iMaximumQueueSize); 1085 1062 QStringList networkDeviceList; 1086 1063 networkDeviceList << "E1k" <<"VNet" << "PCNet"; … … 1089 1066 networkMetricDataSubStringList << "ReceiveBytes" << "TransmitBytes"; 1090 1067 networkMetric.setMetricDataSubString(networkMetricDataSubStringList); 1091 m_subMetrics.insert(m_strNet DebuggerMetricName, networkMetric);1068 m_subMetrics.insert(m_strNetworkMetricName, networkMetric); 1092 1069 1093 1070 for (QMap<QString, UISubMetric>::const_iterator iterator = m_subMetrics.begin(); … … 1185 1162 } 1186 1163 1187 void UIInformationRuntime::updateNetworkGraphsAndMetric(qulonglong iReceiveRate, qulonglong iTransmitRate)1188 {1189 UISubMetric &NetMetric = m_subMetrics[m_strNetMetricName];1190 1191 NetMetric.addData(0, iReceiveRate);1192 NetMetric.addData(1, iTransmitRate);1193 1194 qulonglong iMaximum = qMax(NetMetric.maximum(), qMax(iReceiveRate, iTransmitRate));1195 NetMetric.setMaximum(iMaximum);1196 1197 if (m_infoLabels.contains(m_strNetMetricName) && m_infoLabels[m_strNetMetricName])1198 {1199 QString strInfo;1200 QString strReceiveColor;1201 if (m_infoLabels[m_strNetMetricName]->isEnabled())1202 strInfo = QString("<b>%1</b></b><br/><font color=\"%2\">%3: %4</font><br/><font color=\"%5\">%6: %7</font><br/>%8: %9")1203 .arg(m_strNetInfoLabelTitle)1204 .arg(dataColorString(m_strNetMetricName, 0))1205 .arg(m_strNetInfoLabelReceived).arg(uiCommon().formatSize((quint64)iReceiveRate, iDecimalCount))1206 .arg(dataColorString(m_strNetMetricName, 1))1207 .arg(m_strNetInfoLabelTransmitted).arg(uiCommon().formatSize((quint64)iTransmitRate, iDecimalCount))1208 .arg(m_strNetInfoLabelMaximum).arg(uiCommon().formatSize((quint64)iMaximum, iDecimalCount));1209 else1210 strInfo = QString("<b>%1</b><br/>%2: %3<br/>%4: %5<br/>%6: %7").arg(m_strNetInfoLabelTitle).arg(m_strNetInfoLabelReceived).arg("---").arg(m_strNetInfoLabelTransmitted).arg("---");1211 m_infoLabels[m_strNetMetricName]->setText(strInfo);1212 }1213 if (m_charts.contains(m_strNetMetricName))1214 m_charts[m_strNetMetricName]->update();1215 }1216 1217 1164 void UIInformationRuntime::updateNetworkDebuggerGraphsAndMetric(qulonglong iReceiveTotal, qulonglong iTransmitTotal) 1218 1165 { 1219 UISubMetric &NetMetric = m_subMetrics[m_strNet DebuggerMetricName];1166 UISubMetric &NetMetric = m_subMetrics[m_strNetworkMetricName]; 1220 1167 1221 1168 qulonglong iReceiveRate = iReceiveTotal - NetMetric.total(0); … … 1225 1172 NetMetric.setTotal(1, iTransmitTotal); 1226 1173 1174 /* Do not set data and maximum if the timer has just started since we need to initialize totals "(t-1)" first: */ 1175 if (m_iTimeStep <= 1) 1176 return; 1227 1177 NetMetric.addData(0, iReceiveRate); 1228 1178 NetMetric.addData(1, iTransmitRate); 1229 1179 qulonglong iMaximum = qMax(NetMetric.maximum(), qMax(iReceiveRate, iTransmitRate)); 1230 1180 NetMetric.setMaximum(iMaximum); 1181 1182 if (m_infoLabels.contains(m_strNetworkMetricName) && m_infoLabels[m_strNetworkMetricName]) 1183 { 1184 QString strInfo; 1185 QString strReceiveColor; 1186 if (m_infoLabels[m_strNetworkMetricName]->isEnabled()) 1187 strInfo = QString("<b>%1</b></b><br/><font color=\"%2\">%3: %4<br/>%5 %6</font><br/><font color=\"%7\">%8: %9<br/>%10 %11</font>") 1188 .arg(m_strNetworkInfoLabelTitle) 1189 .arg(dataColorString(m_strNetworkMetricName, 0)).arg(m_strNetworkInfoLabelReceived).arg(uiCommon().formatSize((quint64)iReceiveRate, iDecimalCount)) 1190 .arg(m_strNetworkInfoLabelReceivedTotal).arg(uiCommon().formatSize((quint64)iReceiveTotal, iDecimalCount)) 1191 .arg(dataColorString(m_strNetworkMetricName, 1)).arg(m_strNetworkInfoLabelTransmitted).arg(uiCommon().formatSize((quint64)iTransmitRate, iDecimalCount)) 1192 .arg(m_strNetworkInfoLabelTransmittedTotal).arg(uiCommon().formatSize((quint64)iTransmitTotal, iDecimalCount)); 1193 1194 else 1195 strInfo = QString("<b>%1</b><br/>%2: %3<br/>%4: %5"). 1196 arg(m_strNetworkInfoLabelTitle) 1197 .arg(m_strNetworkInfoLabelReceived).arg("---") 1198 .arg(m_strNetworkInfoLabelTransmitted).arg("---"); 1199 m_infoLabels[m_strNetworkMetricName]->setText(strInfo); 1200 } 1201 if (m_charts.contains(m_strNetworkMetricName)) 1202 m_charts[m_strNetworkMetricName]->update(); 1231 1203 1232 1204 } -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/information/UIInformationRuntime.h
r80406 r80409 151 151 void updateCPUGraphsAndMetric(ULONG iLoadPercentage, ULONG iOtherPercentage); 152 152 void updateRAMGraphsAndMetric(quint64 iTotalRAM, quint64 iFreeRAM); 153 void updateNetworkGraphsAndMetric(qulonglong iReceiveRate, qulonglong iTransmitRate);154 153 void updateNetworkDebuggerGraphsAndMetric(qulonglong iReceiveTotal, qulonglong iTransmitTotal); 155 154 … … 183 182 QString m_strRAMMetricName; 184 183 QString m_strDiskMetricName; 185 QString m_strNetMetricName; 186 QString m_strNetDebuggerMetricName; 184 QString m_strNetworkMetricName; 187 185 /** @} */ 188 186 … … 199 197 QString m_strRAMInfoLabelUsed; 200 198 /** Net traffic info label strings. */ 201 QString m_strNetInfoLabelTitle; 202 QString m_strNetInfoLabelReceived; 203 QString m_strNetInfoLabelTransmitted; 204 QString m_strNetInfoLabelMaximum; 199 QString m_strNetworkInfoLabelTitle; 200 QString m_strNetworkInfoLabelReceived; 201 QString m_strNetworkInfoLabelTransmitted; 202 QString m_strNetworkInfoLabelReceivedTotal; 203 QString m_strNetworkInfoLabelTransmittedTotal; 205 204 /** @} */ 206 205 /** The following string is used while querrying CMachineDebugger. */ 207 206 QString m_strQueryString; 207 qulonglong m_iTimeStep; 208 208 }; 209 209
Note:
See TracChangeset
for help on using the changeset viewer.