VirtualBox

Changeset 101315 in vbox


Ignore:
Timestamp:
Sep 29, 2023 10:39:08 AM (12 months ago)
Author:
vboxsync
Message:

FE/Qt: bugref:10523. Removing guest OS type related getters from UICommon.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UICommon.cpp

    r101278 r101315  
    814814    m_pThreadPoolCloud = 0;
    815815
    816     /* Ensure CGuestOSType objects are no longer used: */
    817     m_guestOSFamilyIDs.clear();
    818     m_guestOSTypes.clear();
    819 
    820816    /* Starting COM cleanup: */
    821817    m_comCleanupProtectionToken.lockForWrite();
     
    11271123
    11281124#endif /* VBOX_GUI_WITH_PIDFILE */
    1129 
    1130 QString UICommon::vmGuestOSFamilyDescription(const QString &strFamilyId) const
    1131 {
    1132     AssertMsg(m_guestOSFamilyDescriptions.contains(strFamilyId),
    1133               ("Family ID incorrect: '%s'.", strFamilyId.toLatin1().constData()));
    1134     return m_guestOSFamilyDescriptions.value(strFamilyId);
    1135 }
    1136 
    1137 QList<CGuestOSType> UICommon::vmGuestOSTypeList(const QString &strFamilyId) const
    1138 {
    1139     AssertMsg(m_guestOSFamilyIDs.contains(strFamilyId),
    1140               ("Family ID incorrect: '%s'.", strFamilyId.toLatin1().constData()));
    1141     return m_guestOSFamilyIDs.contains(strFamilyId) ?
    1142            m_guestOSTypes[m_guestOSFamilyIDs.indexOf(strFamilyId)] : QList<CGuestOSType>();
    1143 }
    1144 
    1145 CGuestOSType UICommon::vmGuestOSType(const QString &strTypeId,
    1146                                      const QString &strFamilyId /* = QString() */) const
    1147 {
    1148     QList<CGuestOSType> list;
    1149     if (m_guestOSFamilyIDs.contains(strFamilyId))
    1150     {
    1151         list = m_guestOSTypes.at(m_guestOSFamilyIDs.indexOf(strFamilyId));
    1152     }
    1153     else
    1154     {
    1155         for (int i = 0; i < m_guestOSFamilyIDs.size(); ++i)
    1156             list += m_guestOSTypes.at(i);
    1157     }
    1158     for (int j = 0; j < list.size(); ++j)
    1159         if (!list.at(j).GetId().compare(strTypeId))
    1160             return list.at(j);
    1161     return CGuestOSType();
    1162 }
    1163 
    1164 QString UICommon::vmGuestOSTypeDescription(const QString &strTypeId) const
    1165 {
    1166     for (int i = 0; i < m_guestOSFamilyIDs.size(); ++i)
    1167     {
    1168         QList<CGuestOSType> list(m_guestOSTypes[i]);
    1169         for (int j = 0; j < list.size(); ++j)
    1170             if (!list.at(j).GetId().compare(strTypeId))
    1171                 return list.at(j).GetDescription();
    1172     }
    1173     return QString();
    1174 }
    1175 
    1176 /* static */
    1177 bool UICommon::isDOSType(const QString &strOSTypeId)
    1178 {
    1179     if (   strOSTypeId.left(3) == "dos"
    1180         || strOSTypeId.left(3) == "win"
    1181         || strOSTypeId.left(3) == "os2")
    1182         return true;
    1183 
    1184     return false;
    1185 }
    11861125
    11871126/* static */
     
    30072946    m_strHomeFolder = virtualBox().GetHomeFolder();
    30082947
    3009     /* Re-initialize guest OS Type list: */
    3010     m_guestOSFamilyIDs.clear();
    3011     m_guestOSTypes.clear();
    3012     const CGuestOSTypeVector guestOSTypes = m_comVBox.GetGuestOSTypes();
    3013     const int cGuestOSTypeCount = guestOSTypes.size();
    3014     AssertMsg(cGuestOSTypeCount > 0, ("Number of OS types must not be zero"));
    3015     if (cGuestOSTypeCount > 0)
    3016     {
    3017         /* Here we ASSUME the 'Other' types are always the first,
    3018          * so we remember them and will append them to the list when finished.
    3019          * We do a two pass, first adding the specific types, then the two 'Other' types. */
    3020         for (int j = 0; j < 2; ++j)
    3021         {
    3022             int cMax = j == 0 ? cGuestOSTypeCount : RT_MIN(2, cGuestOSTypeCount);
    3023             for (int i = j == 0 ? 2 : 0; i < cMax; ++i)
    3024             {
    3025                 const CGuestOSType os = guestOSTypes.at(i);
    3026                 const QString strFamilyID = os.GetFamilyId();
    3027                 const QString strFamilyDescription = os.GetFamilyDescription();
    3028                 if (!m_guestOSFamilyIDs.contains(strFamilyID))
    3029                 {
    3030                     m_guestOSFamilyIDs << strFamilyID;
    3031                     m_guestOSFamilyDescriptions[strFamilyID] = strFamilyDescription;
    3032                     m_guestOSTypes << QList<CGuestOSType>();
    3033                 }
    3034                 m_guestOSTypes[m_guestOSFamilyIDs.indexOf(strFamilyID)].append(os);
    3035             }
    3036         }
    3037     }
     2948    /* Re-initialize guest OS Type database: */
    30382949    if (m_pGuestOSTypeManager)
    3039         m_pGuestOSTypeManager->reCacheGuestOSTypes(guestOSTypes);
     2950        m_pGuestOSTypeManager->reCacheGuestOSTypes(m_comVBox.GetGuestOSTypes());
    30402951    /* Mark wrappers valid: */
    30412952    m_fWrappersValid = true;
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UICommon.h

    r101265 r101315  
    317317    /** @name COM: Guest OS Type stuff.
    318318     * @{ */
    319         /** Returns the list of family IDs. */
    320         QList<QString> vmGuestOSFamilyIDs() const { return m_guestOSFamilyIDs; }
    321 
    322         /** Returns a family description with passed @a strFamilyId. */
    323         QString vmGuestOSFamilyDescription(const QString &strFamilyId) const;
    324         /** Returns a list of all guest OS types with passed @a strFamilyId. */
    325         QList<CGuestOSType> vmGuestOSTypeList(const QString &strFamilyId) const;
    326 
    327         /** Returns the guest OS type for passed @a strTypeId.
    328           * It is being serached through the list of family with passed @a strFamilyId if specified. */
    329         CGuestOSType vmGuestOSType(const QString &strTypeId, const QString &strFamilyId = QString()) const;
    330         /** Returns a type description with passed @a strTypeId. */
    331         QString vmGuestOSTypeDescription(const QString &strTypeId) const;
    332 
    333         /** Returns whether guest type with passed @a strOSTypeId is one of DOS types. */
    334         static bool isDOSType(const QString &strOSTypeId);
     319        const UIGuestOSTypeManager *guestOSTypeManager() const { return m_pGuestOSTypeManager; }
     320        UIGuestOSTypeManager &guestOSTypeManager2() const { return *m_pGuestOSTypeManager; }
    335321    /** @} */
    336322
     
    529515        bool isExtentionPackInstalled() const;
    530516    /** @} */
    531 
    532     const UIGuestOSTypeManager *guestOSTypeManager() const { return m_pGuestOSTypeManager; }
    533517
    534518public slots:
     
    749733        bool  m_fVBoxSVCAvailable;
    750734
    751         /** Holds the guest OS family IDs. */
    752         QList<QString>               m_guestOSFamilyIDs;
    753         /** Holds the guest OS family descriptions. */
    754         QMap<QString, QString>       m_guestOSFamilyDescriptions;
    755         /** Holds the guest OS types for each family ID. */
    756         QList<QList<CGuestOSType> >  m_guestOSTypes;
    757735        UIGuestOSTypeManager *m_pGuestOSTypeManager;
    758736    /** @} */
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIDetailsGenerator.cpp

    r101074 r101315  
    3737#include "UIDetailsGenerator.h"
    3838#include "UIErrorString.h"
     39#include "UIGuestOSType.h"
    3940#include "UIMedium.h"
    4041#include "UITranslator.h"
     
    118119        const QString strAnchorType = QString("os_type");
    119120        const QString strOsTypeId = comMachine.GetOSTypeId();
     121        const UIGuestOSTypeManager *pManager = uiCommon().guestOSTypeManager();
     122        QString strOsTypeDescription;
     123        if (pManager)
     124            strOsTypeDescription = pManager->getDescription(strOsTypeId);
    120125        table << UITextTableLine(QApplication::translate("UIDetails", "Operating System", "details (general)"),
    121126                                 QString("<a href=#%1,%2>%3</a>")
    122127                                     .arg(strAnchorType,
    123128                                          strOsTypeId,
    124                                           uiCommon().vmGuestOSTypeDescription(strOsTypeId)));
     129                                          strOsTypeDescription));
    125130    }
    126131
     
    14091414    {
    14101415        /* Select slashes depending on the OS type: */
    1411         if (UICommon::isDOSType(comGuest.GetOSTypeId()))
     1416        if (UIGuestOSTypeManager::isDOSType(comGuest.GetOSTypeId()))
    14121417            strInfo += e_strTableRow2.arg(QString("<b>\\\\vboxsvr\\%1</b>").arg(it.key()), it.value());
    14131418        else
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIGuestOSType.cpp

    r101295 r101315  
    2929#include "UIGuestOSType.h"
    3030
     31/* COM includes: */
     32#include "CGuestOSType.h"
    3133
    3234/*********************************************************************************************************************************
     
    6062        LONG64                  getRecommendedHDD() const;
    6163        KGraphicsControllerType getRecommendedGraphicsController() const;
     64        KStorageControllerType  getRecommendedDVDStorageController() const;
    6265    /** @} */
    6366
     
    192195}
    193196
     197KStorageControllerType UIGuestOSTypeManager::getRecommendedDVDStorageController(const QString &strTypeId) const
     198{
     199    AssertReturn(m_guestOSTypes, KStorageControllerType_Null);
     200    return m_guestOSTypes->value(m_typeIdIndexMap.value(strTypeId, -1)).getRecommendedDVDStorageController();
     201}
     202
    194203ULONG UIGuestOSTypeManager::getRecommendedRAM(const QString &strTypeId) const
    195204{
     
    238247    AssertReturn(m_guestOSTypes, false);
    239248    return m_guestOSTypes->value(m_typeIdIndexMap.value(strTypeId, -1)).getRecommendedFloppy();
     249}
     250
     251bool UIGuestOSTypeManager::isLinux(const QString &strTypeId) const
     252{
     253    QString strFamilyId = getFamilyId(strTypeId);
     254    if (strFamilyId.contains("linux", Qt::CaseInsensitive))
     255        return true;
     256    return false;
     257}
     258
     259bool UIGuestOSTypeManager::isWindows(const QString &strTypeId) const
     260{
     261    QString strFamilyId = getFamilyId(strTypeId);
     262    if (strFamilyId.contains("windows", Qt::CaseInsensitive))
     263        return true;
     264    return false;
     265}
     266
     267/* static */
     268bool UIGuestOSTypeManager::isDOSType(const QString &strOSTypeId)
     269{
     270    if (   strOSTypeId.left(3) == "dos"
     271        || strOSTypeId.left(3) == "win"
     272        || strOSTypeId.left(3) == "os2")
     273        return true;
     274
     275    return false;
    240276}
    241277
     
    348384    return KGraphicsControllerType_Null;
    349385}
     386
     387KStorageControllerType UIGuestOSType::getRecommendedDVDStorageController() const
     388{
     389    if (m_comGuestOSType.isOk())
     390        return m_comGuestOSType.GetRecommendedDVDStorageController();
     391    return KStorageControllerType_Null;
     392}
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIGuestOSType.h

    r101295 r101315  
    4242
    4343class UIGuestOSType;
    44 class UIFoo;
    4544
    4645/** A wrapper and manager class for Guest OS types (IGuestOSType). Logically we structure os types into families
     
    7372    UIGuestOSTypeInfo              getTypeListForVariant(const QString &strVariant) const;
    7473
     74    static bool isDOSType(const QString &strOSTypeId);
     75
    7576    /** @name Getters for UIGuestOSType properties. They utilize a map for faster access to UIGuestOSType instance with @p strTypeId
    7677      * @{ */
     
    8687        KStorageBus             getRecommendedDVDStorageBus(const QString &strTypeId) const;
    8788        bool                    getRecommendedFloppy(const QString &strTypeId) const;
     89        KStorageControllerType  getRecommendedDVDStorageController(const QString &strTypeId) const;
     90        bool                    isLinux(const QString &strTypeId) const;
     91        bool                    isWindows(const QString &strTypeId) const;
    8892    /** @} */
    8993
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp

    r101155 r101315  
    4040#include "UIFrameBuffer.h"
    4141#include "UIIconPool.h"
     42#include "UIGuestOSType.h"
    4243#include "UIMachine.h"
    4344#include "UIMachineLogic.h"
     
    840841    /* Get recommended controller bus & type: */
    841842    CVirtualBox comVBox = uiCommon().virtualBox();
    842     const CGuestOSType comOsType = comVBox.GetGuestOSType(osTypeId());
     843
    843844    if (!comVBox.isOk())
    844845    {
     
    846847        return false;
    847848    }
    848     const KStorageBus enmRecommendedDvdBus = comOsType.GetRecommendedDVDStorageBus();
    849     if (!comOsType.isOk())
    850     {
    851         UINotificationMessage::cannotAcquireGuestOSTypeParameter(comOsType);
    852         return false;
    853     }
    854     const KStorageControllerType enmRecommendedDvdType = comOsType.GetRecommendedDVDStorageController();
    855     if (!comOsType.isOk())
    856     {
    857         UINotificationMessage::cannotAcquireGuestOSTypeParameter(comOsType);
    858         return false;
    859     }
     849
     850    const UIGuestOSTypeManager *pManager = uiCommon().guestOSTypeManager();
     851    AssertReturn(pManager, false);
     852
     853    const KStorageBus enmRecommendedDvdBus = pManager->getRecommendedDVDStorageBus(osTypeId());
     854    const KStorageControllerType enmRecommendedDvdType = pManager->getRecommendedDVDStorageController(osTypeId());
    860855
    861856    /* Search for an attachment of required bus & type: */
     
    13101305
    13111306    /* Auto GA update is currently for Windows and Linux guests only */
    1312     const CGuestOSType osType = uiCommon().vmGuestOSType(uimachine()->osTypeId());
    1313     if (!osType.isOk())
    1314         return false;
    1315 
    1316     const QString strGuestFamily = osType.GetFamilyId();
    1317     bool fIsWindowOrLinux = strGuestFamily.contains("windows", Qt::CaseInsensitive) || strGuestFamily.contains("linux", Qt::CaseInsensitive);
     1307    const UIGuestOSTypeManager *pManager = uiCommon().guestOSTypeManager();
     1308    AssertReturn(pManager, false);
     1309
     1310    bool fIsWindowOrLinux = pManager->isLinux(uimachine()->osTypeId()) || pManager->isWindows(uimachine()->osTypeId());
    13181311
    13191312    if (!fIsWindowOrLinux)
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/information/UIInformationRuntime.cpp

    r98874 r101315  
    4141#include "UIIconPool.h"
    4242#include "UIInformationRuntime.h"
     43#include "UIGuestOSType.h"
    4344#include "UIMachine.h"
    4445
     
    350351        strOSType = m_strOSNotDetected;
    351352    else
    352         strOSType = uiCommon().vmGuestOSTypeDescription(strOSType);
     353    {
     354        const UIGuestOSTypeManager *pManager = uiCommon().guestOSTypeManager();
     355        if (pManager)
     356            strOSType = pManager->getDescription(strOSType);
     357    }
    353358   updateInfoRow(InfoRow_GuestOSType, QString("%1").arg(m_strGuestOSTypeLabel), strOSType);
    354359}
  • trunk/src/VBox/Frontends/VirtualBox/src/snapshots/UISnapshotDetailsWidget.cpp

    r101074 r101315  
    5454#include "UIDesktopWidgetWatchdog.h"
    5555#include "UIIconPool.h"
     56#include "UIGuestOSType.h"
    5657#include "UISnapshotDetailsWidget.h"
    5758#include "UIMessageCenter.h"
     
    12961297            /* Operating System: */
    12971298            ++iRowCount;
    1298             strItem += QString(sSectionItemTpl2).arg(QApplication::translate("UIDetails", "Operating System", "details (general)"),
    1299                                                      empReport(uiCommon().vmGuestOSTypeDescription(comMachine.GetOSTypeId()),
    1300                                                                uiCommon().vmGuestOSTypeDescription(comMachineOld.GetOSTypeId())));
     1299            const UIGuestOSTypeManager *pManager = uiCommon().guestOSTypeManager();
     1300            if (pManager)
     1301                strItem += QString(sSectionItemTpl2).arg(QApplication::translate("UIDetails", "Operating System", "details (general)"),
     1302                                                         empReport(pManager->getDescription(comMachine.GetOSTypeId()),
     1303                                                                   pManager->getDescription(comMachineOld.GetOSTypeId())));
    13011304
    13021305            /* Location of the settings file: */
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIApplianceEditorWidget.cpp

    r101035 r101315  
    4141#include "QITreeView.h"
    4242#include "UICommon.h"
     43#include "UIGuestOSType.h"
    4344#include "UIGuestOSTypeSelectionButton.h"
    4445#include "UIApplianceEditorWidget.h"
     
    537538                        value = strTmp; break;
    538539                    }
    539                     case KVirtualSystemDescriptionType_OS:               value = uiCommon().vmGuestOSTypeDescription(m_strConfigValue); break;
     540                    case KVirtualSystemDescriptionType_OS:
     541                    {
     542                        const UIGuestOSTypeManager *pManager = uiCommon().guestOSTypeManager();
     543                        if (pManager)
     544                            value = pManager->getDescription(m_strConfigValue);
     545                        break;
     546                    }
    540547                    case KVirtualSystemDescriptionType_Memory:           value = m_strConfigValue + " " + UICommon::tr("MB", "size suffix MBytes=1024 KBytes"); break;
    541548                    case KVirtualSystemDescriptionType_SoundCard:        value = gpConverter->toString(static_cast<KAudioControllerType>(m_strConfigValue.toInt())); break;
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMNameOSTypePage.cpp

    r101272 r101315  
    550550    else if (!pWizard->detectedOSTypeId().isEmpty())
    551551    {
    552         QString strType = uiCommon().vmGuestOSTypeDescription(pWizard->detectedOSTypeId());
     552        const UIGuestOSTypeManager *pManager = uiCommon().guestOSTypeManager();
     553        QString strType;
     554        if (pManager)
     555            strType = pManager->getDescription(pWizard->detectedOSTypeId());
    553556        if (!pWizard->isUnattendedInstallSupported())
    554557            strMessage = UIWizardNewVM::tr("Detected OS type: %1. %2")
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