VirtualBox

Changeset 79981 in vbox


Ignore:
Timestamp:
Jul 25, 2019 2:59:57 PM (5 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:7720: VM settings / System page: Move excessively distributed boot order loading/saving logic to UIBootOrderEditor files where it belongs; This logic is now represented by UIBootDataTools namespace.

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

Legend:

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

    r79976 r79981  
    771771            m_pLayoutBootOrder->setSpacing(qApp->style()->pixelMetric(QStyle::PM_LayoutHorizontalSpacing) / 3);
    772772#endif
    773 
    774             /* Boot-order tree-widget created in the .ui file. */
    775             AssertPtrReturnVoid(m_pBootOrderEditor);
    776             {
    777                 /* Populate possible boot items list.
    778                  * Currently, it seems, we are supporting only 4 possible boot device types:
    779                  * 1. Floppy, 2. DVD-ROM, 3. Hard Disk, 4. Network.
    780                  * But maximum boot devices count supported by machine
    781                  * should be retrieved through the ISystemProperties getter.
    782                  * Moreover, possible boot device types are not listed in some separate Main vector,
    783                  * so we should get them (randomely?) from the list of all device types.
    784                  * Until there will be separate Main getter for list of supported boot device types,
    785                  * this list will be hard-coded here... */
    786                 const CSystemProperties properties = uiCommon().virtualBox().GetSystemProperties();
    787                 const int iPossibleBootListSize = qMin((ULONG)4, properties.GetMaxBootPosition());
    788                 for (int iBootPosition = 1; iBootPosition <= iPossibleBootListSize; ++iBootPosition)
    789                 {
    790                     switch (iBootPosition)
    791                     {
    792                         case 1: m_possibleBootItems << KDeviceType_Floppy; break;
    793                         case 2: m_possibleBootItems << KDeviceType_DVD; break;
    794                         case 3: m_possibleBootItems << KDeviceType_HardDisk; break;
    795                         case 4: m_possibleBootItems << KDeviceType_Network; break;
    796                         default: break;
    797                     }
    798                 }
    799             }
    800773        }
    801774
     
    1026999}
    10271000
    1028 UIBootItemDataList UIMachineSettingsSystem::loadBootItems(const CMachine &comMachine)
    1029 {
    1030     /* Prepare boot items: */
    1031     UIBootItemDataList bootItems;
    1032 
    1033     /* Gather boot-items of current VM: */
    1034     QList<KDeviceType> usedBootItems;
    1035     for (int i = 1; i <= m_possibleBootItems.size(); ++i)
    1036     {
    1037         const KDeviceType enmType = comMachine.GetBootOrder(i);
    1038         if (enmType != KDeviceType_Null)
    1039         {
    1040             usedBootItems << enmType;
    1041             UIBootItemData data;
    1042             data.m_enmType = enmType;
    1043             data.m_fEnabled = true;
    1044             bootItems << data;
    1045         }
    1046     }
    1047     /* Gather other unique boot-items: */
    1048     for (int i = 0; i < m_possibleBootItems.size(); ++i)
    1049     {
    1050         const KDeviceType enmType = m_possibleBootItems[i];
    1051         if (!usedBootItems.contains(enmType))
    1052         {
    1053             UIBootItemData data;
    1054             data.m_enmType = enmType;
    1055             data.m_fEnabled = false;
    1056             bootItems << data;
    1057         }
    1058     }
    1059 
    1060     /* Return boot items: */
    1061     return bootItems;
    1062 }
    1063 
    1064 void UIMachineSettingsSystem::saveBootItems(const UIBootItemDataList &bootItems, CMachine &comMachine)
    1065 {
    1066     bool fSuccess = true;
    1067     int iBootIndex = 0;
    1068     for (int i = 0; fSuccess && i < bootItems.size(); ++i)
    1069     {
    1070         if (bootItems.at(i).m_fEnabled)
    1071         {
    1072             comMachine.SetBootOrder(++iBootIndex, bootItems.at(i).m_enmType);
    1073             fSuccess = comMachine.isOk();
    1074         }
    1075     }
    1076     for (int i = 0; fSuccess && i < bootItems.size(); ++i)
    1077     {
    1078         if (!bootItems.at(i).m_fEnabled)
    1079         {
    1080             comMachine.SetBootOrder(++iBootIndex, KDeviceType_Null);
    1081             fSuccess = comMachine.isOk();
    1082         }
    1083     }
    1084 }
    1085 
    10861001bool UIMachineSettingsSystem::saveSystemData()
    10871002{
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsSystem.h

    r79976 r79981  
    143143    void retranslateComboParavirtProvider();
    144144
    145     /** Loads boot item list for passed @a comMachine. */
    146     UIBootItemDataList loadBootItems(const CMachine &comMachine);
    147     /** Saves @a bootItems list to passed @a comMachine. */
    148     void saveBootItems(const UIBootItemDataList &bootItems, CMachine &comMachine);
    149 
    150145    /** Saves existing system data from the cache. */
    151146    bool saveSystemData();
     
    156151    /** Saves existing 'Acceleration' data from the cache. */
    157152    bool saveAccelerationData();
    158 
    159     /** Holds the list of all possible boot items. */
    160     QList<KDeviceType>  m_possibleBootItems;
    161153
    162154    /** Holds the minimum guest CPU count. */
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIBootOrderEditor.cpp

    r79979 r79981  
    2323/* GUI includes: */
    2424#include "UIBootOrderEditor.h"
     25#include "UICommon.h"
    2526#include "UIConverter.h"
    2627#include "UIIconPool.h"
    2728#include "UIToolBar.h"
     29
     30/* COM includes: */
     31#include "COMEnums.h"
     32#include "CMachine.h"
     33#include "CSystemProperties.h"
    2834
    2935
     
    283289
    284290/*********************************************************************************************************************************
     291*   Class UIBootDataTools implementation.                                                                                        *
     292*********************************************************************************************************************************/
     293
     294UIBootItemDataList UIBootDataTools::loadBootItems(const CMachine &comMachine)
     295{
     296    /* Gather a list of all possible boot items.
     297     * Currently, it seems, we are supporting only 4 possible boot device types:
     298     * 1. Floppy, 2. DVD-ROM, 3. Hard Disk, 4. Network.
     299     * But maximum boot devices count supported by machine should be retrieved
     300     * through the ISystemProperties getter.  Moreover, possible boot device
     301     * types are not listed in some separate Main vector, so we should get them
     302     * (randomely?) from the list of all device types.  Until there will be a
     303     * separate Main getter for list of supported boot device types, this list
     304     * will be hard-coded here... */
     305    QVector<KDeviceType> possibleBootItems = QVector<KDeviceType>() << KDeviceType_Floppy
     306                                                                    << KDeviceType_DVD
     307                                                                    << KDeviceType_HardDisk
     308                                                                    << KDeviceType_Network;
     309    const CSystemProperties comProperties = uiCommon().virtualBox().GetSystemProperties();
     310    const int iPossibleBootListSize = qMin((ULONG)4, comProperties.GetMaxBootPosition());
     311    possibleBootItems.resize(iPossibleBootListSize);
     312
     313    /* Prepare boot items: */
     314    UIBootItemDataList bootItems;
     315
     316    /* Gather boot-items of current VM: */
     317    QList<KDeviceType> usedBootItems;
     318    for (int i = 1; i <= possibleBootItems.size(); ++i)
     319    {
     320        const KDeviceType enmType = comMachine.GetBootOrder(i);
     321        if (enmType != KDeviceType_Null)
     322        {
     323            usedBootItems << enmType;
     324            UIBootItemData data;
     325            data.m_enmType = enmType;
     326            data.m_fEnabled = true;
     327            bootItems << data;
     328        }
     329    }
     330    /* Gather other unique boot-items: */
     331    for (int i = 0; i < possibleBootItems.size(); ++i)
     332    {
     333        const KDeviceType enmType = possibleBootItems.at(i);
     334        if (!usedBootItems.contains(enmType))
     335        {
     336            UIBootItemData data;
     337            data.m_enmType = enmType;
     338            data.m_fEnabled = false;
     339            bootItems << data;
     340        }
     341    }
     342
     343    /* Return boot items: */
     344    return bootItems;
     345}
     346
     347void UIBootDataTools::saveBootItems(const UIBootItemDataList &bootItems, CMachine &comMachine)
     348{
     349    bool fSuccess = true;
     350    int iBootIndex = 0;
     351    for (int i = 0; fSuccess && i < bootItems.size(); ++i)
     352    {
     353        if (bootItems.at(i).m_fEnabled)
     354        {
     355            comMachine.SetBootOrder(++iBootIndex, bootItems.at(i).m_enmType);
     356            fSuccess = comMachine.isOk();
     357        }
     358    }
     359    for (int i = 0; fSuccess && i < bootItems.size(); ++i)
     360    {
     361        if (!bootItems.at(i).m_fEnabled)
     362        {
     363            comMachine.SetBootOrder(++iBootIndex, KDeviceType_Null);
     364            fSuccess = comMachine.isOk();
     365        }
     366    }
     367}
     368
     369
     370/*********************************************************************************************************************************
    285371*   Class UIBootOrderEditor implementation.                                                                                      *
    286372*********************************************************************************************************************************/
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIBootOrderEditor.h

    r79979 r79981  
    3636class UIToolBar;
    3737class UIBootListWidget;
     38class CMachine;
    3839
    3940
     
    6263};
    6364typedef QList<UIBootItemData> UIBootItemDataList;
     65
     66
     67/** Boot data tools namespace. */
     68namespace UIBootDataTools
     69{
     70    /** Loads boot item list for passed @a comMachine. */
     71    SHARED_LIBRARY_STUFF UIBootItemDataList loadBootItems(const CMachine &comMachine);
     72    /** Saves @a bootItems list to passed @a comMachine. */
     73    SHARED_LIBRARY_STUFF void saveBootItems(const UIBootItemDataList &bootItems, CMachine &comMachine);
     74}
     75using namespace UIBootDataTools;
    6476
    6577
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