VirtualBox

Changeset 80419 in vbox


Ignore:
Timestamp:
Aug 26, 2019 7:18:56 AM (5 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9510: Adding a context menu to the chart widget.

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

    r80416 r80419  
    2020#include <QHeaderView>
    2121#include <QLabel>
     22#include <QMenu>
    2223#include <QPainter>
    2324#include <QGridLayout>
     
    8081    virtual QSize sizeHint() const;
    8182    virtual QSize minimumSizeHint() const /* override */;
    82 
    8383
    8484private:
     
    121121    Q_OBJECT;
    122122
     123signals:
     124
     125
     126
    123127public:
    124128
    125     UIChart(QWidget *pParent, const UISubMetric *pSubMetric);
     129    UIChart(QWidget *pParent, UIMetric *pMetric);
    126130    void setFontSize(int iFontSize);
    127131    int  fontSize() const;
     
    148152    virtual void retranslateUi()  /* override */;
    149153
     154private slots:
     155
     156    void sltCreateContextMenu(const QPoint &point);
     157    void sltResetMetric();
     158
    150159private:
    151160
     
    155164    void insertInfoLine(InfoLine enmInfoLine, const QString& strLabel, const QString &strInfo);
    156165
    157     const UISubMetric *m_pSubMetric;
     166    UIMetric *m_pMetric;
    158167    QSize m_size;
    159168    QFont m_font;
     
    170179    QString m_strXAxisLabel;
    171180    QString m_strGAWarning;
     181    QString m_strResetActionLabel;
    172182};
    173183
     
    183193
    184194{
    185     // QPalette pal = palette();
    186     // pal.setColor(QPalette::Background, Qt::yellow);
    187     // setAutoFillBackground(true);
    188     // setPalette(pal);
    189 
    190195    setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    191196
     
    201206
    202207    retranslateUi();
    203 
    204     //QString(":/state_running_16px.png");
    205     //setItem(0, 0, new QTableWidgetItem(, ""));
    206 
     208    /* Add the title row: */
    207209    QTableWidgetItem *pTitleItem = new QTableWidgetItem(UIIconPool::iconSet(":/state_running_16px.png"), m_strTableTitle);
    208210    QFont titleFont(font());
     
    212214    setItem(0, 0, pTitleItem);
    213215
     216    /* Make the API calls and populate the table: */
    214217    runTimeAttributes();
    215218    computeMinimumWidth();
     
    239242QSize UIRuntimeInfoWidget::minimumSizeHint() const
    240243{
    241     printf("mini %d\n", m_iMinimumWidth);
    242244    return QSize(m_iMinimumWidth, m_iMinimumWidth);
    243245}
     
    403405*********************************************************************************************************************************/
    404406
    405 UIChart::UIChart(QWidget *pParent, const UISubMetric *pSubMetric)
     407UIChart::UIChart(QWidget *pParent, UIMetric *pMetric)
    406408    :QIWithRetranslateUI<QWidget>(pParent)
    407     , m_pSubMetric(pSubMetric)
     409    , m_pMetric(pMetric)
    408410    , m_size(QSize(50, 50))
    409     , m_fDrawPieChart(true)
    410     , m_fUseGradientLineColor(true)
    411 {
     411    , m_fDrawPieChart(false)
     412    , m_fUseGradientLineColor(false)
     413{
     414    setContextMenuPolicy(Qt::CustomContextMenu);
     415    connect(this, &UIChart::customContextMenuRequested,
     416            this, &UIChart::sltCreateContextMenu);
     417
     418
    412419    m_dataSeriesColor[0] = QColor(Qt::red);
    413420    m_dataSeriesColor[1] = QColor(Qt::blue);
     
    512519{
    513520    m_strGAWarning = QApplication::translate("UIVMInformationDialog", "No guest additions! This metric requires guest additions to work properly.");
     521    m_strResetActionLabel = QApplication::translate("UIVMInformationDialog", "Reset");
    514522}
    515523
     
    518526    int iFontSize = 24;
    519527
    520     //const QString &strText = m_pSubMetric->name();
     528    //const QString &strText = m_pMetric->name();
    521529    foreach (const QString &strText, m_textList)
    522530    {
     
    591599    }
    592600
    593     if (!m_pSubMetric || iMaximumQueueSize <= 1)
    594         return;
    595 
    596     qulonglong iMaximum = m_pSubMetric->maximum();
     601    if (!m_pMetric || iMaximumQueueSize <= 1)
     602        return;
     603
     604    qulonglong iMaximum = m_pMetric->maximum();
    597605    if (iMaximum == 0)
    598606        return;
     
    610618        }
    611619
    612         const QQueue<qulonglong> *data = m_pSubMetric->data(k);
     620        const QQueue<qulonglong> *data = m_pMetric->data(k);
    613621        if (!m_fUseGradientLineColor)
    614622            painter.setPen(QPen(m_dataSeriesColor[k], 2.5));
     
    632640        QString strValue;
    633641        qulonglong iValue = (iYSubAxisCount + 1 - i) * (iMaximum / (float) (iYSubAxisCount + 1));
    634         if (m_pSubMetric->unit().compare("%", Qt::CaseInsensitive) == 0)
     642        if (m_pMetric->unit().compare("%", Qt::CaseInsensitive) == 0)
    635643            strValue = QString::number(iValue);
    636         else if (m_pSubMetric->unit().compare("kb", Qt::CaseInsensitive) == 0)
     644        else if (m_pMetric->unit().compare("kb", Qt::CaseInsensitive) == 0)
    637645            strValue = uiCommon().formatSize(_1K * (qulonglong)iValue, iDecimalCount);
    638         else if (m_pSubMetric->unit().compare("b", Qt::CaseInsensitive) == 0 ||
    639                  m_pSubMetric->unit().compare("b/s", Qt::CaseInsensitive) == 0)
     646        else if (m_pMetric->unit().compare("b", Qt::CaseInsensitive) == 0 ||
     647                 m_pMetric->unit().compare("b/s", Qt::CaseInsensitive) == 0)
    640648            strValue = uiCommon().formatSize(iValue, iDecimalCount);
     649        else if (m_pMetric->unit().compare("times", Qt::CaseInsensitive) == 0)
     650            strValue = QString::number(iValue);
     651
    641652        painter.drawText(width() - 0.9 * m_iMarginRight, iTextY, strValue);
    642653    }
     
    672683    {
    673684        /* Draw the pie chart for the 0th data series only: */
    674         const QQueue<qulonglong> *data = m_pSubMetric->data(i);
     685        const QQueue<qulonglong> *data = m_pMetric->data(i);
    675686        if (!data || data->isEmpty())
    676687            continue;
     
    709720}
    710721
     722void UIChart::sltCreateContextMenu(const QPoint &point)
     723{
     724    QMenu menu;
     725    QAction *pResetAction = menu.addAction(m_strResetActionLabel);
     726    connect(pResetAction, &QAction::triggered, this, &UIChart::sltResetMetric);
     727    menu.exec(mapToGlobal(point));
     728}
     729
     730void UIChart::sltResetMetric()
     731{
     732    if (m_pMetric)
     733        m_pMetric->reset();
     734}
     735
    711736/*********************************************************************************************************************************
    712 *   UISubMetric implementation.                                                                                     *
     737*   UIMetric implementation.                                                                                     *
    713738*********************************************************************************************************************************/
    714739
    715 UISubMetric::UISubMetric(const QString &strName, const QString &strUnit, int iMaximumQueueSize)
     740UIMetric::UIMetric(const QString &strName, const QString &strUnit, int iMaximumQueueSize)
    716741    : m_strName(strName)
    717742    , m_strUnit(strUnit)
     
    719744    , m_iMaximumQueueSize(iMaximumQueueSize)
    720745    , m_fRequiresGuestAdditions(false)
     746    , m_fIsInitialized(false)
    721747{
    722748    m_iTotal[0] = 0;
     
    724750}
    725751
    726 UISubMetric::UISubMetric()
     752UIMetric::UIMetric()
    727753    : m_iMaximumQueueSize(0)
    728754{
    729755}
    730756
    731 const QString &UISubMetric::name() const
     757const QString &UIMetric::name() const
    732758{
    733759    return m_strName;
    734760}
    735761
    736 void UISubMetric::setMaximum(qulonglong iMaximum)
     762void UIMetric::setMaximum(qulonglong iMaximum)
    737763{
    738764    m_iMaximum = iMaximum;
    739765}
    740766
    741 qulonglong UISubMetric::maximum() const
     767qulonglong UIMetric::maximum() const
    742768{
    743769    return m_iMaximum;
    744770}
    745771
    746 void UISubMetric::setUnit(QString strUnit)
     772void UIMetric::setUnit(QString strUnit)
    747773{
    748774    m_strUnit = strUnit;
    749775
    750776}
    751 const QString &UISubMetric::unit() const
     777const QString &UIMetric::unit() const
    752778{
    753779    return m_strUnit;
    754780}
    755781
    756 void UISubMetric::addData(int iDataSeriesIndex, qulonglong fData)
     782void UIMetric::addData(int iDataSeriesIndex, qulonglong fData)
    757783{
    758784    if (iDataSeriesIndex >= DATA_SERIES_SIZE)
     
    763789}
    764790
    765 const QQueue<qulonglong> *UISubMetric::data(int iDataSeriesIndex) const
     791const QQueue<qulonglong> *UIMetric::data(int iDataSeriesIndex) const
    766792{
    767793    if (iDataSeriesIndex >= DATA_SERIES_SIZE)
     
    770796}
    771797
    772 void UISubMetric::setTotal(int iDataSeriesIndex, qulonglong iTotal)
     798void UIMetric::setTotal(int iDataSeriesIndex, qulonglong iTotal)
    773799{
    774800    if (iDataSeriesIndex >= DATA_SERIES_SIZE)
     
    777803}
    778804
    779 qulonglong UISubMetric::total(int iDataSeriesIndex) const
     805qulonglong UIMetric::total(int iDataSeriesIndex) const
    780806{
    781807    if (iDataSeriesIndex >= DATA_SERIES_SIZE)
     
    784810}
    785811
    786 bool UISubMetric::requiresGuestAdditions() const
     812bool UIMetric::requiresGuestAdditions() const
    787813{
    788814    return m_fRequiresGuestAdditions;
    789815}
    790816
    791 void UISubMetric::setRequiresGuestAdditions(bool fRequiresGAs)
     817void UIMetric::setRequiresGuestAdditions(bool fRequiresGAs)
    792818{
    793819    m_fRequiresGuestAdditions = fRequiresGAs;
    794820}
    795821
    796 const QStringList &UISubMetric::deviceTypeList() const
     822const QStringList &UIMetric::deviceTypeList() const
    797823{
    798824    return m_deviceTypeList;
    799825}
    800826
    801 void UISubMetric::setDeviceTypeList(const QStringList &list)
     827void UIMetric::setDeviceTypeList(const QStringList &list)
    802828{
    803829    m_deviceTypeList = list;
     
    805831}
    806832
    807 const QStringList &UISubMetric::metricDataSubString() const
     833const QStringList &UIMetric::metricDataSubString() const
    808834{
    809835    return m_metricDataSubString;
    810836}
    811837
    812 void UISubMetric::setMetricDataSubString(const QStringList &list)
     838void UIMetric::setQueryPrefix(const QString &strPrefix)
     839{
     840    m_strQueryPrefix = strPrefix;
     841    composeQueryString();
     842
     843}
     844
     845void UIMetric::setMetricDataSubString(const QStringList &list)
    813846{
    814847    m_metricDataSubString = list;
     
    816849}
    817850
    818 const QString &UISubMetric::queryString() const
     851const QString &UIMetric::queryString() const
    819852{
    820853    return m_strQueryString;
    821854}
    822855
    823 void UISubMetric::composeQueryString()
     856bool UIMetric::isInitialized() const
     857{
     858    return m_fIsInitialized;
     859}
     860
     861void UIMetric::setIsInitialized(bool fIsInitialized)
     862{
     863    m_fIsInitialized = fIsInitialized;
     864}
     865
     866void UIMetric::reset()
     867{
     868    m_fIsInitialized = false;
     869    for (int i = 0; i < DATA_SERIES_SIZE; ++i)
     870    {
     871        m_iTotal[i] = 0;
     872        m_data[i].clear();
     873    }
     874    m_iMaximum = 0;
     875}
     876
     877void UIMetric::composeQueryString()
    824878{
    825879    /* Compose of if both m_metricDataSubString and m_deviceTypeList are not empty: */
     
    831885        foreach (const QString &strSubString, m_metricDataSubString)
    832886        {
    833             m_strQueryString += QString("*Devices*%1*%2*|").arg(strDeviceName).arg(strSubString);
     887            m_strQueryString += QString("*%1*%2*%3*|").arg(m_strQueryPrefix).arg(strDeviceName).arg(strSubString);
    834888        }
    835889    }
     
    854908    , m_strNetworkMetricName("Network")
    855909    , m_strDiskIOMetricName("DiskIO")
     910    , m_strVMExitMetricName("VMExits")
    856911    , m_iTimeStep(0)
    857912{
     
    9501005    m_pRuntimeInfoWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);
    9511006
    952     QStringList chartOder;
    953     chartOder << m_strCPUMetricName << m_strRAMMetricName <<
    954         m_strDiskMetricName << m_strNetworkMetricName << m_strDiskIOMetricName;
     1007    QStringList chartOrder;
     1008    chartOrder << m_strCPUMetricName << m_strRAMMetricName <<
     1009        m_strDiskMetricName << m_strNetworkMetricName << m_strDiskIOMetricName << m_strVMExitMetricName;
    9551010    int iRow = 0;
    956     foreach (const QString &strMetricName, chartOder)
     1011    foreach (const QString &strMetricName, chartOrder)
    9571012    {
    9581013        if (!m_subMetrics.contains(strMetricName))
     
    9711026
    9721027    /* Configure charts: */
    973     if (m_charts.contains(m_strNetworkMetricName) && m_charts[m_strNetworkMetricName])
    974     {
    975         m_charts[m_strNetworkMetricName]->setDrawPieChart(false);
    976         m_charts[m_strNetworkMetricName]->setUseGradientLineColor(false);
    977     }
    978     if (m_charts.contains(m_strDiskIOMetricName) && m_charts[m_strDiskIOMetricName])
    979     {
    980         m_charts[m_strDiskIOMetricName]->setDrawPieChart(false);
    981         m_charts[m_strDiskIOMetricName]->setUseGradientLineColor(false);
    982     }
    9831028    if (m_charts.contains(m_strCPUMetricName) && m_charts[m_strCPUMetricName])
    984         m_charts[m_strCPUMetricName]->setUseGradientLineColor(false);
     1029        m_charts[m_strCPUMetricName]->setDrawPieChart(true);
    9851030    if (m_charts.contains(m_strRAMMetricName) && m_charts[m_strRAMMetricName])
    986         m_charts[m_strRAMMetricName]->setUseGradientLineColor(false);
     1031        m_charts[m_strRAMMetricName]->setDrawPieChart(false);
    9871032
    9881033    QWidget *bottomSpacerWidget = new QWidget(this);
     
    10601105    qulonglong uDiskIOTotalRead = 0;
    10611106
     1107   qulonglong uTotalVMExits = 0;
     1108
    10621109    QVector<DebuggerMetricData> xmlData = getTotalCounterFromDegugger(m_strQueryString);
    1063     for (QMap<QString, UISubMetric>::iterator iterator =  m_subMetrics.begin();
     1110    for (QMap<QString, UIMetric>::iterator iterator =  m_subMetrics.begin();
    10641111         iterator != m_subMetrics.end(); ++iterator)
    10651112    {
    1066         UISubMetric &metric = iterator.value();
     1113        UIMetric &metric = iterator.value();
    10671114        const QStringList &deviceTypeList = metric.deviceTypeList();
    10681115        foreach (const QString &strDeviceType, deviceTypeList)
     
    10861133                            uDiskIOTotalRead += data.m_counter;
    10871134                    }
     1135                    else if (metric.name() == m_strVMExitMetricName)
     1136                    {
     1137                        if (data.m_strName.contains("all", Qt::CaseInsensitive))
     1138                            uTotalVMExits += data.m_counter;
     1139                    }
    10881140                }
    10891141            }
     
    10921144    updateNetworkGraphsAndMetric(uNetworkTotalReceive, uNetworkTotalTransmit);
    10931145    updateDiskIOGraphsAndMetric(uDiskIOTotalWritten, uDiskIOTotalRead);
     1146    updateVMExitMetric(uTotalVMExits);
    10941147}
    10951148
     
    11231176                if (strName.contains("RAM", Qt::CaseInsensitive) && strName.contains("Free", Qt::CaseInsensitive))
    11241177                {
    1125                     UISubMetric newMetric(m_strRAMMetricName, metrics[i].GetUnit(), iMaximumQueueSize);
     1178                    UIMetric newMetric(m_strRAMMetricName, metrics[i].GetUnit(), iMaximumQueueSize);
    11261179                    newMetric.setRequiresGuestAdditions(true);
    11271180                    m_subMetrics.insert(m_strRAMMetricName, newMetric);
     
    11311184    }
    11321185
    1133     m_subMetrics.insert(m_strCPUMetricName, UISubMetric(m_strCPUMetricName, "%", iMaximumQueueSize));
     1186    m_subMetrics.insert(m_strCPUMetricName, UIMetric(m_strCPUMetricName, "%", iMaximumQueueSize));
    11341187    {
    11351188
    11361189        /* Network metric: */
    1137         UISubMetric networkMetric(m_strNetworkMetricName, "B", iMaximumQueueSize);
     1190        UIMetric networkMetric(m_strNetworkMetricName, "B", iMaximumQueueSize);
     1191        networkMetric.setQueryPrefix("Devices");
    11381192        QStringList networkDeviceList;
    11391193        networkDeviceList << "E1k" <<"VNet" << "PCNet";
     
    11471201    /* Disk IO metric */
    11481202    {
    1149         UISubMetric diskIOMetric(m_strDiskIOMetricName, "B", iMaximumQueueSize);
     1203        UIMetric diskIOMetric(m_strDiskIOMetricName, "B", iMaximumQueueSize);
     1204        diskIOMetric.setQueryPrefix("Devices");
    11501205        QStringList diskTypeList;
    11511206        diskTypeList << "LSILOGICSCSI" << "BUSLOGIC"
     
    11571212        m_subMetrics.insert(m_strDiskIOMetricName, diskIOMetric);
    11581213    }
    1159     for (QMap<QString, UISubMetric>::const_iterator iterator =  m_subMetrics.begin();
     1214
     1215    /* VM exits metric */
     1216    {
     1217        UIMetric VMExitsMetric(m_strVMExitMetricName, "times", iMaximumQueueSize);
     1218        VMExitsMetric.setQueryPrefix("HM");
     1219        QStringList typeList;
     1220        typeList << "CPU";
     1221        VMExitsMetric.setDeviceTypeList(typeList);
     1222        QStringList subStringList;
     1223        subStringList << "All";
     1224        VMExitsMetric.setMetricDataSubString(subStringList);
     1225        m_subMetrics.insert(m_strVMExitMetricName, VMExitsMetric);
     1226    }
     1227
     1228    for (QMap<QString, UIMetric>::const_iterator iterator =  m_subMetrics.begin();
    11601229         iterator != m_subMetrics.end(); ++iterator)
    11611230    {
     
    11641233        m_strQueryString += iterator.value().queryString();
    11651234    }
    1166 }
     1235
     1236}
     1237
    11671238
    11681239bool UIInformationRuntime::guestAdditionsAvailable(int iMinimumMajorVersion)
     
    11871258void UIInformationRuntime::enableDisableGuestAdditionDependedWidgets(bool fEnable)
    11881259{
    1189     for (QMap<QString, UISubMetric>::const_iterator iterator =  m_subMetrics.begin();
     1260    for (QMap<QString, UIMetric>::const_iterator iterator =  m_subMetrics.begin();
    11901261         iterator != m_subMetrics.end(); ++iterator)
    11911262    {
     
    12071278void UIInformationRuntime::updateCPUGraphsAndMetric(ULONG iExecutingPercentage, ULONG iOtherPercentage)
    12081279{
    1209     UISubMetric &CPUMetric = m_subMetrics[m_strCPUMetricName];
     1280    UIMetric &CPUMetric = m_subMetrics[m_strCPUMetricName];
    12101281    CPUMetric.addData(0, iExecutingPercentage);
    12111282    CPUMetric.addData(1, iOtherPercentage);
     
    12331304void UIInformationRuntime::updateRAMGraphsAndMetric(quint64 iTotalRAM, quint64 iFreeRAM)
    12341305{
    1235     UISubMetric &RAMMetric = m_subMetrics[m_strRAMMetricName];
     1306    UIMetric &RAMMetric = m_subMetrics[m_strRAMMetricName];
    12361307    RAMMetric.setMaximum(iTotalRAM);
    12371308    RAMMetric.addData(0, iTotalRAM - iFreeRAM);
     
    12531324void UIInformationRuntime::updateNetworkGraphsAndMetric(qulonglong iReceiveTotal, qulonglong iTransmitTotal)
    12541325{
    1255     UISubMetric &NetMetric = m_subMetrics[m_strNetworkMetricName];
     1326    UIMetric &NetMetric = m_subMetrics[m_strNetworkMetricName];
    12561327
    12571328    qulonglong iReceiveRate = iReceiveTotal - NetMetric.total(0);
     
    12611332    NetMetric.setTotal(1, iTransmitTotal);
    12621333
    1263     /* Do not set data and maximum if the timer has just started since we need to initialize totals "(t-1)" first: */
    1264     if (m_iTimeStep <= 1)
    1265         return;
     1334    /* Do not set data and maximum if the metric has not been initialized  since we need to initialize totals "(t-1)" first: */
     1335    if (!NetMetric.isInitialized())
     1336    {
     1337        NetMetric.setIsInitialized(true);
     1338        return;
     1339    }
     1340
    12661341    NetMetric.addData(0, iReceiveRate);
    12671342    NetMetric.addData(1, iTransmitRate);
     
    12931368void UIInformationRuntime::updateDiskIOGraphsAndMetric(qulonglong uDiskIOTotalWritten, qulonglong uDiskIOTotalRead)
    12941369{
    1295     UISubMetric &NetMetric = m_subMetrics[m_strDiskIOMetricName];
    1296 
    1297     qulonglong iWriteRate = uDiskIOTotalWritten - NetMetric.total(0);
    1298     qulonglong iReadRate = uDiskIOTotalRead - NetMetric.total(1);
    1299 
    1300     NetMetric.setTotal(0, uDiskIOTotalWritten);
    1301     NetMetric.setTotal(1, uDiskIOTotalRead);
    1302 
    1303     /* Do not set data and maximum if the timer has just started since we need to initialize totals "(t-1)" first: */
    1304     if (m_iTimeStep <= 1)
    1305         return;
    1306     NetMetric.addData(0, iWriteRate);
    1307     NetMetric.addData(1, iReadRate);
    1308     qulonglong iMaximum = qMax(NetMetric.maximum(), qMax(iWriteRate, iReadRate));
    1309     NetMetric.setMaximum(iMaximum);
     1370    UIMetric &diskMetric = m_subMetrics[m_strDiskIOMetricName];
     1371
     1372    qulonglong iWriteRate = uDiskIOTotalWritten - diskMetric.total(0);
     1373    qulonglong iReadRate = uDiskIOTotalRead - diskMetric.total(1);
     1374
     1375    diskMetric.setTotal(0, uDiskIOTotalWritten);
     1376    diskMetric.setTotal(1, uDiskIOTotalRead);
     1377
     1378    /* Do not set data and maximum if the metric has not been initialized  since we need to initialize totals "(t-1)" first: */
     1379    if (!diskMetric.isInitialized())
     1380    {
     1381        diskMetric.setIsInitialized(true);
     1382        return;
     1383    }
     1384    diskMetric.addData(0, iWriteRate);
     1385    diskMetric.addData(1, iReadRate);
     1386    qulonglong iMaximum = qMax(diskMetric.maximum(), qMax(iWriteRate, iReadRate));
     1387    diskMetric.setMaximum(iMaximum);
    13101388
    13111389    if (m_infoLabels.contains(m_strDiskIOMetricName)  && m_infoLabels[m_strDiskIOMetricName])
     
    13321410}
    13331411
     1412void UIInformationRuntime::updateVMExitMetric(qulonglong uTotalVMExits)
     1413{
     1414    UIMetric &VMExitMetric = m_subMetrics[m_strVMExitMetricName];
     1415
     1416    qulonglong iRate = uTotalVMExits - VMExitMetric.total(0);
     1417
     1418    VMExitMetric.setTotal(0, uTotalVMExits);
     1419
     1420    /* Do not set data and maximum if the metric has not been initialized  since we need to initialize totals "(t-1)" first: */
     1421    if (!VMExitMetric.isInitialized())
     1422    {
     1423        VMExitMetric.setIsInitialized(true);
     1424        return;
     1425    }
     1426
     1427    VMExitMetric.addData(0, iRate);
     1428    qulonglong iMaximum = qMax(VMExitMetric.maximum(), iRate);
     1429    VMExitMetric.setMaximum(iMaximum);
     1430}
     1431
    13341432QString UIInformationRuntime::dataColorString(const QString &strChartName, int iDataIndex)
    13351433{
     
    13501448
    13511449    QString strStats = debugger.GetStats(strQuery, false);
     1450
    13521451    QXmlStreamReader xmlReader;
    13531452    xmlReader.addData(strStats);
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/information/UIInformationRuntime.h

    r80411 r80419  
    6161};
    6262
    63 class UISubMetric
     63class UIMetric
    6464{
    6565public:
    6666
    67     UISubMetric(const QString &strName, const QString &strUnit, int iMaximumQueueSize);
    68     UISubMetric();
     67    UIMetric(const QString &strName, const QString &strUnit, int iMaximumQueueSize);
     68    UIMetric();
    6969    const QString &name() const;
    7070
     
    8181    qulonglong total(int iDataSeriesIndex) const;
    8282
    83 
    84 
    8583    bool requiresGuestAdditions() const;
    8684    void setRequiresGuestAdditions(bool fRequiresGAs);
     
    8987    void setDeviceTypeList(const QStringList &list);
    9088
     89    void setQueryPrefix(const QString &strPrefix);
     90
    9191    const QStringList &metricDataSubString() const;
    9292    void setMetricDataSubString(const QStringList &list);
    9393
    9494    const QString &queryString() const;
     95
     96    void setIsInitialized(bool fIsInitialized);
     97    bool isInitialized() const;
     98
     99    void reset();
    95100
    96101private:
     
    103108      * it is ReceiveBytes/TransmitBytes */
    104109    QStringList m_metricDataSubString;
     110    QString m_strQueryPrefix;
    105111
    106112    QString m_strName;
    107113    QString m_strUnit;
    108114    /** This string is used while calling IMachineDebugger::getStats(..). It is composed of
    109       * m_deviceTypeList and m_metricDataSubString. */
     115      * m_strQueryPrefix, m_deviceTypeList, and m_metricDataSubString. */
    110116    QString m_strQueryString;
    111117    qulonglong m_iMaximum;
     
    116122    int m_iMaximumQueueSize;
    117123    bool m_fRequiresGuestAdditions;
    118 
     124    /** Used for metrices whose data is computed as total deltas. That is we receieve only total value and
     125      * compute time step data from total deltas. m_isInitialised is true if the total has been set first time. */
     126    bool m_fIsInitialized;
    119127};
    120128
    121129/** UIInformationRuntime class displays some high level performance metric of the guest system.
    122130  * The values are read in certain periods and cached in the GUI side. Currently we draw some line charts
    123   * and pie charts (where applicable) alongside with some text. */
     131  * and pie charts (where applicable) alongside with some text. Additionally it displays a table including some
     132  * run time attributes. */
    124133class UIInformationRuntime : public QIWithRetranslateUI<QWidget>
    125134{
     
    153162    void updateNetworkGraphsAndMetric(qulonglong iReceiveTotal, qulonglong iTransmitTotal);
    154163    void updateDiskIOGraphsAndMetric(qulonglong uDiskIOTotalWritten, qulonglong uDiskIOTotalRead);
     164    void updateVMExitMetric(qulonglong uTotalVMExits);
    155165
    156166    QString dataColorString(const QString &strChartName, int iDataIndex);
     
    174184    QVector<CUnknown> m_objectList;
    175185
    176     QMap<QString, UISubMetric> m_subMetrics;
     186    QMap<QString, UIMetric> m_subMetrics;
    177187    QMap<QString,UIChart*>  m_charts;
    178188    QMap<QString,QLabel*>  m_infoLabels;
     
    185195        QString m_strNetworkMetricName;
    186196        QString m_strDiskIOMetricName;
     197        QString m_strVMExitMetricName;
    187198    /** @} */
    188199
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