VirtualBox

Changeset 36919 in vbox


Ignore:
Timestamp:
May 3, 2011 6:58:25 AM (14 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
71501
Message:

FE/Qt: 4989: UISettingsCache template integrated into System page.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/settings/machine
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsSystem.cpp

    r36918 r36919  
    170170    UISettingsPageMachine::fetchData(data);
    171171
    172     /* Fill internal variables with corresponding values: */
     172    /* Prepare system data: */
     173    UIDataSettingsMachineSystem systemData;
     174
    173175    /* Load boot-items of current VM: */
    174176    QList<KDeviceType> usedBootItems;
     
    182184            data.m_type = type;
    183185            data.m_fEnabled = true;
    184             m_cache.m_bootItems << data;
     186            systemData.m_bootItems << data;
    185187        }
    186188    }
     
    194196            data.m_type = type;
    195197            data.m_fEnabled = false;
    196             m_cache.m_bootItems << data;
     198            systemData.m_bootItems << data;
    197199        }
    198200    }
    199     m_cache.m_fPFHwVirtExSupported = vboxGlobal().virtualBox().GetHost().GetProcessorFeature(KProcessorFeature_HWVirtEx);
    200     m_cache.m_fPFPAESupported = vboxGlobal().virtualBox().GetHost().GetProcessorFeature(KProcessorFeature_PAE);
    201     m_cache.m_fIoApicEnabled = m_machine.GetBIOSSettings().GetIOAPICEnabled();
    202     m_cache.m_fEFIEnabled = m_machine.GetFirmwareType() >= KFirmwareType_EFI && m_machine.GetFirmwareType() <= KFirmwareType_EFIDUAL;
    203     m_cache.m_fUTCEnabled = m_machine.GetRTCUseUTC();
    204     m_cache.m_fUseAbsHID = m_machine.GetPointingHidType() == KPointingHidType_USBTablet;
    205     m_cache.m_fPAEEnabled = m_machine.GetCPUProperty(KCPUPropertyType_PAE);
    206     m_cache.m_fHwVirtExEnabled = m_machine.GetHWVirtExProperty(KHWVirtExPropertyType_Enabled);
    207     m_cache.m_fNestedPagingEnabled = m_machine.GetHWVirtExProperty(KHWVirtExPropertyType_NestedPaging);
    208     m_cache.m_iRAMSize = m_machine.GetMemorySize();
    209     m_cache.m_cCPUCount = m_cache.m_fPFHwVirtExSupported ? m_machine.GetCPUCount() : 1;
    210     m_cache.m_chipsetType = m_machine.GetChipsetType();
     201    /* Gather other system data: */
     202    systemData.m_fPFHwVirtExSupported = vboxGlobal().virtualBox().GetHost().GetProcessorFeature(KProcessorFeature_HWVirtEx);
     203    systemData.m_fPFPAESupported = vboxGlobal().virtualBox().GetHost().GetProcessorFeature(KProcessorFeature_PAE);
     204    systemData.m_fIoApicEnabled = m_machine.GetBIOSSettings().GetIOAPICEnabled();
     205    systemData.m_fEFIEnabled = m_machine.GetFirmwareType() >= KFirmwareType_EFI && m_machine.GetFirmwareType() <= KFirmwareType_EFIDUAL;
     206    systemData.m_fUTCEnabled = m_machine.GetRTCUseUTC();
     207    systemData.m_fUseAbsHID = m_machine.GetPointingHidType() == KPointingHidType_USBTablet;
     208    systemData.m_fPAEEnabled = m_machine.GetCPUProperty(KCPUPropertyType_PAE);
     209    systemData.m_fHwVirtExEnabled = m_machine.GetHWVirtExProperty(KHWVirtExPropertyType_Enabled);
     210    systemData.m_fNestedPagingEnabled = m_machine.GetHWVirtExProperty(KHWVirtExPropertyType_NestedPaging);
     211    systemData.m_iRAMSize = m_machine.GetMemorySize();
     212    systemData.m_cCPUCount = systemData.m_fPFHwVirtExSupported ? m_machine.GetCPUCount() : 1;
     213    systemData.m_chipsetType = m_machine.GetChipsetType();
     214
     215    /* Cache system data: */
     216    m_cache.cacheInitialData(systemData);
    211217
    212218    /* Upload machine to data: */
     
    218224void UIMachineSettingsSystem::getFromCache()
    219225{
    220     /* Remove any old data in the boot view. */
     226    /* Get system data from cache: */
     227    const UIDataSettingsMachineSystem &systemData = m_cache.base();
     228
     229    /* Remove any old data in the boot view: */
    221230    QAbstractItemView *iv = qobject_cast <QAbstractItemView*> (mTwBootOrder);
    222231    iv->model()->removeRows(0, iv->model()->rowCount());
    223232    /* Apply internal variables data to QWidget(s): */
    224     for (int i = 0; i < m_cache.m_bootItems.size(); ++i)
    225     {
    226         UIBootItemData data = m_cache.m_bootItems[i];
     233    for (int i = 0; i < systemData.m_bootItems.size(); ++i)
     234    {
     235        UIBootItemData data = systemData.m_bootItems[i];
    227236        QListWidgetItem *pItem = new UIBootTableItem(data.m_type);
    228237        pItem->setCheckState(data.m_fEnabled ? Qt::Checked : Qt::Unchecked);
    229238        mTwBootOrder->addItem(pItem);
    230239    }
    231     mCbApic->setChecked(m_cache.m_fIoApicEnabled);
    232     mCbEFI->setChecked(m_cache.m_fEFIEnabled);
    233     mCbTCUseUTC->setChecked(m_cache.m_fUTCEnabled);
    234     mCbUseAbsHID->setChecked(m_cache.m_fUseAbsHID);
    235     mSlCPU->setEnabled(m_cache.m_fPFHwVirtExSupported);
    236     mLeCPU->setEnabled(m_cache.m_fPFHwVirtExSupported);
    237     mCbPae->setEnabled(m_cache.m_fPFPAESupported);
    238     mCbPae->setChecked(m_cache.m_fPAEEnabled);
    239     mCbVirt->setEnabled(m_cache.m_fPFHwVirtExSupported);
    240     mCbVirt->setChecked(m_cache.m_fHwVirtExEnabled);
    241     mCbNestedPaging->setEnabled(m_cache.m_fPFHwVirtExSupported && m_cache.m_fHwVirtExEnabled);
    242     mCbNestedPaging->setChecked(m_cache.m_fNestedPagingEnabled);
    243     mSlMemory->setValue(m_cache.m_iRAMSize);
    244     mSlCPU->setValue(m_cache.m_cCPUCount);
    245     int iChipsetPositionPos = mCbChipset->findData(m_cache.m_chipsetType);
     240    /* Load other system data to page: */
     241    mCbApic->setChecked(systemData.m_fIoApicEnabled);
     242    mCbEFI->setChecked(systemData.m_fEFIEnabled);
     243    mCbTCUseUTC->setChecked(systemData.m_fUTCEnabled);
     244    mCbUseAbsHID->setChecked(systemData.m_fUseAbsHID);
     245    mSlCPU->setEnabled(systemData.m_fPFHwVirtExSupported);
     246    mLeCPU->setEnabled(systemData.m_fPFHwVirtExSupported);
     247    mCbPae->setEnabled(systemData.m_fPFPAESupported);
     248    mCbPae->setChecked(systemData.m_fPAEEnabled);
     249    mCbVirt->setEnabled(systemData.m_fPFHwVirtExSupported);
     250    mCbVirt->setChecked(systemData.m_fHwVirtExEnabled);
     251    mCbNestedPaging->setEnabled(systemData.m_fPFHwVirtExSupported && systemData.m_fHwVirtExEnabled);
     252    mCbNestedPaging->setChecked(systemData.m_fNestedPagingEnabled);
     253    mSlMemory->setValue(systemData.m_iRAMSize);
     254    mSlCPU->setValue(systemData.m_cCPUCount);
     255    int iChipsetPositionPos = mCbChipset->findData(systemData.m_chipsetType);
    246256    mCbChipset->setCurrentIndex(iChipsetPositionPos == -1 ? 0 : iChipsetPositionPos);
    247     if (!m_cache.m_fPFHwVirtExSupported)
     257    if (!systemData.m_fPFHwVirtExSupported)
    248258        mTwSystem->removeTab(2);
    249259
     
    256266void UIMachineSettingsSystem::putToCache()
    257267{
    258     /* Gather internal variables data from QWidget(s): */
    259     m_cache.m_bootItems.clear();
     268    /* Prepare system data: */
     269    UIDataSettingsMachineSystem systemData = m_cache.base();
     270
     271    /* Gather system data: */
     272    systemData.m_bootItems.clear();
    260273    for (int i = 0; i < mTwBootOrder->count(); ++i)
    261274    {
     
    264277        data.m_type = static_cast<UIBootTableItem*>(pItem)->type();
    265278        data.m_fEnabled = pItem->checkState() == Qt::Checked;
    266         m_cache.m_bootItems << data;
    267     }
    268     m_cache.m_fIoApicEnabled = mCbApic->isChecked() || mSlCPU->value() > 1 ||
    269                                (KChipsetType)mCbChipset->itemData(mCbChipset->currentIndex()).toInt() == KChipsetType_ICH9;
    270     m_cache.m_fEFIEnabled = mCbEFI->isChecked();
    271     m_cache.m_fUTCEnabled = mCbTCUseUTC->isChecked();
    272     m_cache.m_fUseAbsHID = mCbUseAbsHID->isChecked();
    273     m_cache.m_fPAEEnabled = mCbPae->isChecked();
    274     m_cache.m_fHwVirtExEnabled = mCbVirt->checkState() == Qt::Checked || mSlCPU->value() > 1;
    275     m_cache.m_fNestedPagingEnabled = mCbNestedPaging->isChecked();
    276     m_cache.m_iRAMSize = mSlMemory->value();
    277     m_cache.m_cCPUCount = mSlCPU->value();
    278     m_cache.m_chipsetType = (KChipsetType)mCbChipset->itemData(mCbChipset->currentIndex()).toInt();
     279        systemData.m_bootItems << data;
     280    }
     281    systemData.m_fIoApicEnabled = mCbApic->isChecked() || mSlCPU->value() > 1 ||
     282                                  (KChipsetType)mCbChipset->itemData(mCbChipset->currentIndex()).toInt() == KChipsetType_ICH9;
     283    systemData.m_fEFIEnabled = mCbEFI->isChecked();
     284    systemData.m_fUTCEnabled = mCbTCUseUTC->isChecked();
     285    systemData.m_fUseAbsHID = mCbUseAbsHID->isChecked();
     286    systemData.m_fPAEEnabled = mCbPae->isChecked();
     287    systemData.m_fHwVirtExEnabled = mCbVirt->checkState() == Qt::Checked || mSlCPU->value() > 1;
     288    systemData.m_fNestedPagingEnabled = mCbNestedPaging->isChecked();
     289    systemData.m_iRAMSize = mSlMemory->value();
     290    systemData.m_cCPUCount = mSlCPU->value();
     291    systemData.m_chipsetType = (KChipsetType)mCbChipset->itemData(mCbChipset->currentIndex()).toInt();
     292
     293    /* Cache system data: */
     294    m_cache.cacheCurrentData(systemData);
    279295}
    280296
     
    286302    UISettingsPageMachine::fetchData(data);
    287303
    288     if (isMachineOffline())
    289     {
    290         /* Motherboard tab: */
    291         m_machine.SetMemorySize(m_cache.m_iRAMSize);
    292         int iBootIndex = 0;
    293         /* Save boot-items of current VM: */
    294         for (int i = 0; i < m_cache.m_bootItems.size(); ++i)
     304    /* Check if system data was changed: */
     305    if (m_cache.wasChanged())
     306    {
     307        /* Get system data from cache: */
     308        const UIDataSettingsMachineSystem &systemData = m_cache.data();
     309
     310        /* Store system data: */
     311        if (isMachineOffline())
    295312        {
    296             if (m_cache.m_bootItems[i].m_fEnabled)
    297                 m_machine.SetBootOrder(++iBootIndex, m_cache.m_bootItems[i].m_type);
     313            /* Motherboard tab: */
     314            m_machine.SetMemorySize(systemData.m_iRAMSize);
     315            int iBootIndex = 0;
     316            /* Save boot-items of current VM: */
     317            for (int i = 0; i < systemData.m_bootItems.size(); ++i)
     318            {
     319                if (systemData.m_bootItems[i].m_fEnabled)
     320                    m_machine.SetBootOrder(++iBootIndex, systemData.m_bootItems[i].m_type);
     321            }
     322            /* Save other unique boot-items: */
     323            for (int i = 0; i < systemData.m_bootItems.size(); ++i)
     324            {
     325                if (!systemData.m_bootItems[i].m_fEnabled)
     326                    m_machine.SetBootOrder(++iBootIndex, KDeviceType_Null);
     327            }
     328            m_machine.SetChipsetType(systemData.m_chipsetType);
     329            m_machine.GetBIOSSettings().SetIOAPICEnabled(systemData.m_fIoApicEnabled);
     330            m_machine.SetFirmwareType(systemData.m_fEFIEnabled ? KFirmwareType_EFI : KFirmwareType_BIOS);
     331            m_machine.SetRTCUseUTC(systemData.m_fUTCEnabled);
     332            m_machine.SetPointingHidType(systemData.m_fUseAbsHID ? KPointingHidType_USBTablet : KPointingHidType_PS2Mouse);
     333            /* Processor tab: */
     334            m_machine.SetCPUCount(systemData.m_cCPUCount);
     335            m_machine.SetCPUProperty(KCPUPropertyType_PAE, systemData.m_fPAEEnabled);
     336            /* Acceleration tab: */
     337            m_machine.SetHWVirtExProperty(KHWVirtExPropertyType_Enabled, systemData.m_fHwVirtExEnabled);
     338            m_machine.SetHWVirtExProperty(KHWVirtExPropertyType_NestedPaging, systemData.m_fNestedPagingEnabled);
    298339        }
    299         /* Save other unique boot-items: */
    300         for (int i = 0; i < m_cache.m_bootItems.size(); ++i)
    301         {
    302             if (!m_cache.m_bootItems[i].m_fEnabled)
    303                 m_machine.SetBootOrder(++iBootIndex, KDeviceType_Null);
    304         }
    305         m_machine.SetChipsetType(m_cache.m_chipsetType);
    306         m_machine.GetBIOSSettings().SetIOAPICEnabled(m_cache.m_fIoApicEnabled);
    307         m_machine.SetFirmwareType(m_cache.m_fEFIEnabled ? KFirmwareType_EFI : KFirmwareType_BIOS);
    308         m_machine.SetRTCUseUTC(m_cache.m_fUTCEnabled);
    309         m_machine.SetPointingHidType(m_cache.m_fUseAbsHID ? KPointingHidType_USBTablet : KPointingHidType_PS2Mouse);
    310         /* Processor tab: */
    311         m_machine.SetCPUCount(m_cache.m_cCPUCount);
    312         m_machine.SetCPUProperty(KCPUPropertyType_PAE, m_cache.m_fPAEEnabled);
    313         /* Acceleration tab: */
    314         m_machine.SetHWVirtExProperty(KHWVirtExPropertyType_Enabled, m_cache.m_fHwVirtExEnabled);
    315         m_machine.SetHWVirtExProperty(KHWVirtExPropertyType_NestedPaging, m_cache.m_fNestedPagingEnabled);
    316340    }
    317341
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsSystem.h

    r36357 r36919  
    2727struct UIBootItemData
    2828{
     29    /* Default constructor: */
     30    UIBootItemData() : m_type(KDeviceType_Null), m_fEnabled(false) {}
     31    /* Operator==: */
     32    bool operator==(const UIBootItemData &other) const
     33    {
     34        return (m_type == other.m_type) &&
     35               (m_fEnabled == other.m_fEnabled);
     36    }
     37    /* Variables: */
    2938    KDeviceType m_type;
    3039    bool m_fEnabled;
    3140};
    3241
    33 /* Machine settings / System page / Cache: */
    34 struct UISettingsCacheMachineSystem
     42/* Machine settings / System page / Data: */
     43struct UIDataSettingsMachineSystem
    3544{
     45    /* Default constructor: */
     46    UIDataSettingsMachineSystem()
     47        : m_bootItems(QList<UIBootItemData>())
     48        , m_chipsetType(KChipsetType_Null)
     49        , m_fPFHwVirtExSupported(false)
     50        , m_fPFPAESupported(false)
     51        , m_fIoApicEnabled(false)
     52        , m_fEFIEnabled(false)
     53        , m_fUTCEnabled(false)
     54        , m_fUseAbsHID(false)
     55        , m_fPAEEnabled(false)
     56        , m_fHwVirtExEnabled(false)
     57        , m_fNestedPagingEnabled(false)
     58        , m_iRAMSize(-1)
     59        , m_cCPUCount(-1) {}
     60    /* Functions: */
     61    bool equal(const UIDataSettingsMachineSystem &other) const
     62    {
     63        return (m_bootItems == other.m_bootItems) &&
     64               (m_chipsetType == other.m_chipsetType) &&
     65               (m_fPFHwVirtExSupported == other.m_fPFHwVirtExSupported) &&
     66               (m_fPFPAESupported == other.m_fPFPAESupported) &&
     67               (m_fIoApicEnabled == other.m_fIoApicEnabled) &&
     68               (m_fEFIEnabled == other.m_fEFIEnabled) &&
     69               (m_fUTCEnabled == other.m_fUTCEnabled) &&
     70               (m_fUseAbsHID == other.m_fUseAbsHID) &&
     71               (m_fPAEEnabled == other.m_fPAEEnabled) &&
     72               (m_fHwVirtExEnabled == other.m_fHwVirtExEnabled) &&
     73               (m_fNestedPagingEnabled == other.m_fNestedPagingEnabled) &&
     74               (m_iRAMSize == other.m_iRAMSize) &&
     75               (m_cCPUCount == other.m_cCPUCount);
     76    }
     77    /* Operators: */
     78    bool operator==(const UIDataSettingsMachineSystem &other) const { return equal(other); }
     79    bool operator!=(const UIDataSettingsMachineSystem &other) const { return !equal(other); }
     80    /* Variables: */
    3681    QList<UIBootItemData> m_bootItems;
    3782    KChipsetType m_chipsetType;
     
    4893    int m_cCPUCount;
    4994};
     95typedef UISettingsCache<UIDataSettingsMachineSystem> UICacheSettingsMachineSystem;
    5096
    5197/* Machine settings / System page: */
     
    117163
    118164    /* Cache: */
    119     UISettingsCacheMachineSystem m_cache;
     165    UICacheSettingsMachineSystem m_cache;
    120166};
    121167
Note: See TracChangeset for help on using the changeset viewer.

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