VirtualBox

Changeset 103164 in vbox


Ignore:
Timestamp:
Feb 1, 2024 4:14:28 PM (10 months ago)
Author:
vboxsync
Message:

FE/Qt: bugref:10501. Moving some cloud machine related functions to the common code area.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/activity
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/activity/UIMonitorCommon.cpp

    r103131 r103164  
    3838
    3939/* COM includes: */
     40#include "CForm.h"
     41#include "CFormValue.h"
     42#include "CRangedIntegerFormValue.h"
    4043#include "CMachineDebugger.h"
    4144#include "CPerformanceCollector.h"
    42 
     45#include <VBox/com/VirtualBox.h>
    4346
    4447
     
    309312    painter.drawPath(UIMonitorCommon::doughnutSlice(chartRect, innerRect, 90, fAngle));
    310313}
     314
     315/* static */
     316quint64 UIMonitorCommon::determineTotalRAMAmount(CCloudMachine &comCloudMachine)
     317{
     318    quint64 iTotalRAM = 0;
     319    CForm comForm = comCloudMachine.GetDetailsForm();
     320    /* Ignore cloud machine errors: */
     321    if (comCloudMachine.isOk())
     322    {
     323        /* Common anchor for all fields: */
     324        const QString strAnchorType = "cloud";
     325
     326        /* For each form value: */
     327        const QVector<CFormValue> values = comForm.GetValues();
     328        foreach (const CFormValue &comIteratedValue, values)
     329        {
     330            /* Ignore invisible values: */
     331            if (!comIteratedValue.GetVisible())
     332                continue;
     333
     334            /* Acquire label: */
     335            const QString strLabel = comIteratedValue.GetLabel();
     336            if (strLabel != "RAM")
     337                continue;
     338
     339            AssertReturn((comIteratedValue.GetType() == KFormValueType_RangedInteger), 0);
     340
     341            CRangedIntegerFormValue comValue(comIteratedValue);
     342            iTotalRAM = comValue.GetInteger();
     343            QString strRAMUnit = comValue.GetSuffix();
     344            if (strRAMUnit.compare("gb", Qt::CaseInsensitive) == 0)
     345                iTotalRAM *= _1G / _1K;
     346            else if (strRAMUnit.compare("mb", Qt::CaseInsensitive) == 0)
     347                iTotalRAM *= _1M / _1K;
     348            if (!comValue.isOk())
     349                iTotalRAM = 0;
     350        }
     351    }
     352    return iTotalRAM;
     353}
  • trunk/src/VBox/Frontends/VirtualBox/src/activity/UIMonitorCommon.h

    r103131 r103164  
    131131                                      const QRectF &chartRect, const QRectF &innerRect, int iOverlayAlpha, const QColor &color);
    132132
     133        static quint64 determineTotalRAMAmount(CCloudMachine &comCloudMachine);
     134
    133135private:
    134136
  • trunk/src/VBox/Frontends/VirtualBox/src/activity/vmactivity/UIVMActivityMonitor.cpp

    r103133 r103164  
    5050/* COM includes: */
    5151#include "CConsole.h"
    52 #include "CForm.h"
    53 #include "CFormValue.h"
    5452#include "CGuest.h"
    5553#include "CPerformanceCollector.h"
    5654#include "CPerformanceMetric.h"
    57 #include "CRangedIntegerFormValue.h"
    5855#include <iprt/string.h>
    59 #include <VBox/com/VirtualBox.h>
    6056
    6157/* External includes: */
     
    18141810
    18151811    setMachine(machine);
    1816     determineTotalRAMAmount();
     1812    m_iTotalRAM = UIMonitorCommon::determineTotalRAMAmount(m_comMachine);
    18171813
    18181814    m_pMachineStateUpdateTimer = new QTimer(this);
     
    18331829    /* Start the timer: */
    18341830    start();
    1835 }
    1836 
    1837 void UIVMActivityMonitorCloud::determineTotalRAMAmount()
    1838 {
    1839     CForm comForm = m_comMachine.GetDetailsForm();
    1840     /* Ignore cloud machine errors: */
    1841     if (m_comMachine.isOk())
    1842     {
    1843         /* Common anchor for all fields: */
    1844         const QString strAnchorType = "cloud";
    1845 
    1846         /* For each form value: */
    1847         const QVector<CFormValue> values = comForm.GetValues();
    1848         foreach (const CFormValue &comIteratedValue, values)
    1849         {
    1850             /* Ignore invisible values: */
    1851             if (!comIteratedValue.GetVisible())
    1852                 continue;
    1853 
    1854             /* Acquire label: */
    1855             const QString strLabel = comIteratedValue.GetLabel();
    1856             if (strLabel != "RAM")
    1857                 continue;
    1858 
    1859             AssertReturnVoid((comIteratedValue.GetType() == KFormValueType_RangedInteger));
    1860 
    1861             CRangedIntegerFormValue comValue(comIteratedValue);
    1862             m_iTotalRAM = comValue.GetInteger();
    1863             QString strRAMUnit = comValue.GetSuffix();
    1864             if (strRAMUnit.compare("gb", Qt::CaseInsensitive) == 0)
    1865                 m_iTotalRAM *= _1G / _1K;
    1866             else if (strRAMUnit.compare("mb", Qt::CaseInsensitive) == 0)
    1867                 m_iTotalRAM *= _1M / _1K;
    1868             if (!comValue.isOk())
    1869                 m_iTotalRAM = 0;
    1870         }
    1871     }
    18721831}
    18731832
  • trunk/src/VBox/Frontends/VirtualBox/src/activity/vmactivity/UIVMActivityMonitor.h

    r102903 r103164  
    353353    bool findMetric(KMetricType enmMetricType, UIMetric &metric, int &iDataSeriesIndex) const;
    354354    void prepareMetrics();
    355     void determineTotalRAMAmount();
    356355
    357356    CCloudMachine m_comMachine;
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