VirtualBox

Changeset 102653 in vbox


Ignore:
Timestamp:
Dec 20, 2023 2:35:23 PM (11 months ago)
Author:
vboxsync
Message:

FE/Qt: bugref:10501. Formatiing datetime we get from OCI and using them in the chart X axis. This still needs some polishing.

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  
    743743    for (int i = 0; i < iXSubAxisCount + 2; ++i)
    744744    {
     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
    745764        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 #else
    750         int iTextWidth = fontMetrics.width(strCurrentSec);
    751 #endif
    752765        if (i == 0)
    753766        {
    754             strCurrentSec += " " + m_strXAxisLabel;
    755             painter.drawText(iTextX, m_lineChartRect.bottom() + iFontHeight, strCurrentSec);
     767            strAxisText += " " + m_strXAxisLabel;
     768            painter.drawText(iTextX, m_lineChartRect.bottom() + iFontHeight, strAxisText);
    756769        }
    757770        else
    758             painter.drawText(iTextX - 0.5 * iTextWidth, m_lineChartRect.bottom() + iFontHeight, strCurrentSec);
     771            painter.drawText(iTextX - 0.5 * iTextWidth, m_lineChartRect.bottom() + iFontHeight, strAxisText);
    759772    }
    760773}
     
    10341047    addData(iDataSeriesIndex, iData);
    10351048
    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    }
    10391055}
    10401056
     
    10441060        return 0;
    10451061    return &m_data[iDataSeriesIndex];
     1062}
     1063
     1064const QQueue<QString> *UIMetric::labels() const
     1065{
     1066    return &m_labels;
     1067}
     1068
     1069bool UIMetric::hasDataLabels() const
     1070{
     1071    return !m_labels.isEmpty();
    10461072}
    10471073
     
    20532079    UIMetric &networkMetric = m_metrics[m_strNetworkMetricName];
    20542080    networkMetric.addData(0, uReceiveRate, strLabel);
    2055     networkMetric.addData(1, uTransmitRate, strLabel);
     2081    networkMetric.addData(1, uTransmitRate);
    20562082
    20572083    if (m_infoLabels.contains(m_strNetworkMetricName)  && m_infoLabels[m_strNetworkMetricName])
     
    20722098
    20732099    diskMetric.addData(0, uWriteRate, strLabel);
    2074     diskMetric.addData(1, uReadRate, strLabel);
     2100    diskMetric.addData(1, uReadRate);
    20752101
    20762102    if (m_infoLabels.contains(m_strDiskIOMetricName)  && m_infoLabels[m_strDiskIOMetricName])
     
    22352261}
    22362262
    2237 
     2263/* static */
     2264QString 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}
    22382273
    22392274#include "UIVMActivityMonitor.moc"
  • trunk/src/VBox/Frontends/VirtualBox/src/activity/vmactivity/UIVMActivityMonitor.h

    r102644 r102653  
    8888    void addData(int iDataSeriesIndex, quint64 fData);
    8989    void addData(int iDataSeriesIndex, quint64 fData, const QString &strLabel);
     90
    9091    const QQueue<quint64> *data(int iDataSeriesIndex) const;
     92    const QQueue<QString> *labels() const;
     93    bool hasDataLabels() const;
    9194
    9295    /** # of the data point of the data series with index iDataSeriesIndex. */
     
    118121    quint64 m_iMaximum;
    119122    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;
    121125    /** The total data (the counter value we get from IMachineDebugger API). For the metrics
    122126      * we get from IMachineDebugger m_data values are computed as deltas of total values t - (t-1) */
     
    315319    virtual QUuid machineId() const RT_OVERRIDE;
    316320    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);
    317323
    318324private slots:
     
    348354    void cacheNetworkTransmit(const QString &strTimeStamp, int iValue);
    349355
    350 
    351356    bool findMetric(KMetricType enmMetricType, UIMetric &metric, int &iDataSeriesIndex) const;
    352357    void prepareMetrics();
     358
    353359    CCloudMachine m_comMachine;
    354360    UIProgressTaskReadCloudMachineMetricList *m_ReadListProgressTask;
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette