Changeset 102653 in vbox
- Timestamp:
- Dec 20, 2023 2:35:23 PM (11 months ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/activity/vmactivity
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/activity/vmactivity/UIVMActivityMonitor.cpp
r102644 r102653 743 743 for (int i = 0; i < iXSubAxisCount + 2; ++i) 744 744 { 745 int iTimeIndex = iTotalSeconds - i * iTotalSeconds / (float)(iXSubAxisCount + 1); 746 QString strAxisText; 747 if (m_pMetric && m_pMetric->hasDataLabels()) 748 { 749 int iDataIndex = iTimeIndex - (m_iMaximumQueueSize - maxDataSize()); 750 const QQueue<QString> *labels = m_pMetric->labels(); 751 if (iDataIndex < labels->size()) 752 { 753 strAxisText = UIVMActivityMonitorCloud::formatCloudTimeStamp(labels->at(iDataIndex)); 754 755 } 756 } 757 else 758 strAxisText = QString::number(iTimeIndex); 759 #if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) 760 int iTextWidth = fontMetrics.horizontalAdvance(strAxisText); 761 #else 762 int iTextWidth = fontMetrics.width(strAxisText); 763 #endif 745 764 int iTextX = m_lineChartRect.left() + i * m_lineChartRect.width() / (float) (iXSubAxisCount + 1); 746 QString strCurrentSec = QString::number(iTotalSeconds - i * iTotalSeconds / (float)(iXSubAxisCount + 1));747 #if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0)748 int iTextWidth = fontMetrics.horizontalAdvance(strCurrentSec);749 #else750 int iTextWidth = fontMetrics.width(strCurrentSec);751 #endif752 765 if (i == 0) 753 766 { 754 str CurrentSec+= " " + m_strXAxisLabel;755 painter.drawText(iTextX, m_lineChartRect.bottom() + iFontHeight, str CurrentSec);767 strAxisText += " " + m_strXAxisLabel; 768 painter.drawText(iTextX, m_lineChartRect.bottom() + iFontHeight, strAxisText); 756 769 } 757 770 else 758 painter.drawText(iTextX - 0.5 * iTextWidth, m_lineChartRect.bottom() + iFontHeight, str CurrentSec);771 painter.drawText(iTextX - 0.5 * iTextWidth, m_lineChartRect.bottom() + iFontHeight, strAxisText); 759 772 } 760 773 } … … 1034 1047 addData(iDataSeriesIndex, iData); 1035 1048 1036 m_labels[iDataSeriesIndex].enqueue(strLabel); 1037 if (m_data[iDataSeriesIndex].size() > m_iMaximumQueueSize) 1038 m_labels[iDataSeriesIndex].dequeue(); 1049 if (iDataSeriesIndex == 0) 1050 { 1051 m_labels.enqueue(strLabel); 1052 if (m_labels.size() > m_iMaximumQueueSize) 1053 m_labels.dequeue(); 1054 } 1039 1055 } 1040 1056 … … 1044 1060 return 0; 1045 1061 return &m_data[iDataSeriesIndex]; 1062 } 1063 1064 const QQueue<QString> *UIMetric::labels() const 1065 { 1066 return &m_labels; 1067 } 1068 1069 bool UIMetric::hasDataLabels() const 1070 { 1071 return !m_labels.isEmpty(); 1046 1072 } 1047 1073 … … 2053 2079 UIMetric &networkMetric = m_metrics[m_strNetworkMetricName]; 2054 2080 networkMetric.addData(0, uReceiveRate, strLabel); 2055 networkMetric.addData(1, uTransmitRate , strLabel);2081 networkMetric.addData(1, uTransmitRate); 2056 2082 2057 2083 if (m_infoLabels.contains(m_strNetworkMetricName) && m_infoLabels[m_strNetworkMetricName]) … … 2072 2098 2073 2099 diskMetric.addData(0, uWriteRate, strLabel); 2074 diskMetric.addData(1, uReadRate , strLabel);2100 diskMetric.addData(1, uReadRate); 2075 2101 2076 2102 if (m_infoLabels.contains(m_strDiskIOMetricName) && m_infoLabels[m_strDiskIOMetricName]) … … 2235 2261 } 2236 2262 2237 2263 /* static */ 2264 QString UIVMActivityMonitorCloud::formatCloudTimeStamp(const QString &strInput) 2265 { 2266 QDateTime dateTime = QDateTime::fromString(strInput, Qt::RFC2822Date); 2267 2268 if (!dateTime.isValid()) 2269 return QString(); 2270 2271 return dateTime.time().toString("HH:mm"); 2272 } 2238 2273 2239 2274 #include "UIVMActivityMonitor.moc" -
trunk/src/VBox/Frontends/VirtualBox/src/activity/vmactivity/UIVMActivityMonitor.h
r102644 r102653 88 88 void addData(int iDataSeriesIndex, quint64 fData); 89 89 void addData(int iDataSeriesIndex, quint64 fData, const QString &strLabel); 90 90 91 const QQueue<quint64> *data(int iDataSeriesIndex) const; 92 const QQueue<QString> *labels() const; 93 bool hasDataLabels() const; 91 94 92 95 /** # of the data point of the data series with index iDataSeriesIndex. */ … … 118 121 quint64 m_iMaximum; 119 122 QQueue<quint64> m_data[DATA_SERIES_SIZE]; 120 QQueue<QString> m_labels[DATA_SERIES_SIZE]; 123 /** We assume m_data[0] and m_data[1] have a common label array. */ 124 QQueue<QString> m_labels; 121 125 /** The total data (the counter value we get from IMachineDebugger API). For the metrics 122 126 * we get from IMachineDebugger m_data values are computed as deltas of total values t - (t-1) */ … … 315 319 virtual QUuid machineId() const RT_OVERRIDE; 316 320 virtual QString machineName() const RT_OVERRIDE; 321 /** Accoring to OCI docs returned time stamp is in RFC3339 format. */ 322 static QString formatCloudTimeStamp(const QString &strInput); 317 323 318 324 private slots: … … 348 354 void cacheNetworkTransmit(const QString &strTimeStamp, int iValue); 349 355 350 351 356 bool findMetric(KMetricType enmMetricType, UIMetric &metric, int &iDataSeriesIndex) const; 352 357 void prepareMetrics(); 358 353 359 CCloudMachine m_comMachine; 354 360 UIProgressTaskReadCloudMachineMetricList *m_ReadListProgressTask;
Note:
See TracChangeset
for help on using the changeset viewer.