Changeset 58360 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Oct 21, 2015 2:18:26 PM (9 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/globals
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp
r58346 r58360 632 632 { 633 633 QList<CGuestOSType> result; 634 for (int i = 0; i < m FamilyIDs.size(); ++i)635 result << m Types[i][0];634 for (int i = 0; i < m_guestOSFamilyIDs.size(); ++i) 635 result << m_guestOSTypes[i][0]; 636 636 return result; 637 637 } … … 643 643 QList<CGuestOSType> VBoxGlobal::vmGuestOSTypeList(const QString &aFamilyId) const 644 644 { 645 AssertMsg(m FamilyIDs.contains(aFamilyId), ("Family ID incorrect: '%s'.", aFamilyId.toLatin1().constData()));646 return m FamilyIDs.contains(aFamilyId) ?647 m Types[mFamilyIDs.indexOf(aFamilyId)] : QList<CGuestOSType>();645 AssertMsg(m_guestOSFamilyIDs.contains(aFamilyId), ("Family ID incorrect: '%s'.", aFamilyId.toLatin1().constData())); 646 return m_guestOSFamilyIDs.contains(aFamilyId) ? 647 m_guestOSTypes[m_guestOSFamilyIDs.indexOf(aFamilyId)] : QList<CGuestOSType>(); 648 648 } 649 649 … … 693 693 { 694 694 QList <CGuestOSType> list; 695 if (m FamilyIDs.contains (aFamilyId))696 { 697 list = m Types [mFamilyIDs.indexOf (aFamilyId)];695 if (m_guestOSFamilyIDs.contains (aFamilyId)) 696 { 697 list = m_guestOSTypes [m_guestOSFamilyIDs.indexOf (aFamilyId)]; 698 698 } 699 699 else 700 700 { 701 for (int i = 0; i < m FamilyIDs.size(); ++ i)702 list += m Types [i];701 for (int i = 0; i < m_guestOSFamilyIDs.size(); ++ i) 702 list += m_guestOSTypes [i]; 703 703 } 704 704 for (int j = 0; j < list.size(); ++ j) … … 714 714 QString VBoxGlobal::vmGuestOSTypeDescription (const QString &aTypeId) const 715 715 { 716 for (int i = 0; i < m FamilyIDs.size(); ++ i)717 { 718 QList <CGuestOSType> list (m Types [i]);716 for (int i = 0; i < m_guestOSFamilyIDs.size(); ++ i) 717 { 718 QList <CGuestOSType> list (m_guestOSTypes [i]); 719 719 for ( int j = 0; j < list.size(); ++ j) 720 720 if (!list [j].GetId().compare (aTypeId)) … … 4007 4007 return; 4008 4008 } 4009 /* Fetch corresponding objects/values: */ 4010 m_vbox = virtualBoxClient().GetVirtualBox(); 4011 m_host = virtualBox().GetHost(); 4012 m_strHomeFolder = virtualBox().GetHomeFolder(); 4013 /* Mark wrappers valid: */ 4014 m_fWrappersValid = true; 4009 /* Init wrappers: */ 4010 comWrappersReinit(); 4015 4011 4016 4012 /* Watch for the VBoxSVC availability changes: */ … … 4041 4037 connect(gEDataManager, SIGNAL(sigLanguageChange(QString)), 4042 4038 this, SLOT(sltGUILanguageChange(QString))); 4043 4044 /* Initialize guest OS Type list. */4045 CGuestOSTypeVector coll = m_vbox.GetGuestOSTypes();4046 int osTypeCount = coll.size();4047 AssertMsg(osTypeCount > 0, ("Number of OS types must not be zero"));4048 if (osTypeCount > 0)4049 {4050 /* Here we ASSUME the 'Other' types are always the first, so we4051 * remember it and will append it to the list when finished.4052 * We do a two pass, first adding the specific types, then the two4053 * 'Other' types. */4054 for (int j = 0; j < 2; j++)4055 {4056 int cMax = j == 0 ? coll.size() : RT_MIN(2, coll.size());4057 for (int i = j == 0 ? 2 : 0; i < cMax; ++i)4058 {4059 CGuestOSType os = coll[i];4060 QString familyId(os.GetFamilyId());4061 if (!mFamilyIDs.contains(familyId))4062 {4063 mFamilyIDs << familyId;4064 mTypes << QList<CGuestOSType>();4065 }4066 mTypes[mFamilyIDs.indexOf(familyId)].append(os);4067 }4068 }4069 }4070 4039 4071 4040 qApp->installEventFilter (this); … … 4419 4388 4420 4389 /* ensure CGuestOSType objects are no longer used */ 4421 m FamilyIDs.clear();4422 m Types.clear();4390 m_guestOSFamilyIDs.clear(); 4391 m_guestOSTypes.clear(); 4423 4392 4424 4393 /* Starting COM cleanup: */ … … 4474 4443 if (!m_fWrappersValid) 4475 4444 { 4476 /* Re-fetch corresponding objects/values: */ 4477 m_vbox = virtualBoxClient().GetVirtualBox(); 4478 m_host = virtualBox().GetHost(); 4479 m_strHomeFolder = virtualBox().GetHomeFolder(); 4480 /* Mark wrappers valid: */ 4481 m_fWrappersValid = true; 4445 /* Re-init wrappers: */ 4446 comWrappersReinit(); 4482 4447 4483 4448 /* If that is Selector UI: */ … … 4493 4458 /* Notify listeners about the VBoxSVC availability change: */ 4494 4459 emit sigVBoxSVCAvailabilityChange(); 4460 } 4461 4462 void VBoxGlobal::comWrappersReinit() 4463 { 4464 /* Re-fetch corresponding objects/values: */ 4465 m_vbox = virtualBoxClient().GetVirtualBox(); 4466 m_host = virtualBox().GetHost(); 4467 m_strHomeFolder = virtualBox().GetHomeFolder(); 4468 4469 /* Re-initialize guest OS Type list: */ 4470 m_guestOSFamilyIDs.clear(); 4471 m_guestOSTypes.clear(); 4472 const CGuestOSTypeVector guestOSTypes = m_vbox.GetGuestOSTypes(); 4473 const int cGuestOSTypeCount = guestOSTypes.size(); 4474 AssertMsg(cGuestOSTypeCount > 0, ("Number of OS types must not be zero")); 4475 if (cGuestOSTypeCount > 0) 4476 { 4477 /* Here we ASSUME the 'Other' types are always the first, 4478 * so we remember them and will append them to the list when finished. 4479 * We do a two pass, first adding the specific types, then the two 'Other' types. */ 4480 for (int j = 0; j < 2; ++j) 4481 { 4482 int cMax = j == 0 ? cGuestOSTypeCount : RT_MIN(2, cGuestOSTypeCount); 4483 for (int i = j == 0 ? 2 : 0; i < cMax; ++i) 4484 { 4485 const CGuestOSType os = guestOSTypes.at(i); 4486 const QString strFamilyID = os.GetFamilyId(); 4487 if (!m_guestOSFamilyIDs.contains(strFamilyID)) 4488 { 4489 m_guestOSFamilyIDs << strFamilyID; 4490 m_guestOSTypes << QList<CGuestOSType>(); 4491 } 4492 m_guestOSTypes[m_guestOSFamilyIDs.indexOf(strFamilyID)].append(os); 4493 } 4494 } 4495 } 4496 4497 /* Mark wrappers valid: */ 4498 m_fWrappersValid = true; 4495 4499 } 4496 4500 -
trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.h
r58346 r58360 515 515 ~VBoxGlobal(); 516 516 517 /** Re-initializes COM wrappers and containers. */ 518 void comWrappersReinit(); 519 517 520 #ifdef VBOX_WITH_DEBUGGER_GUI 518 521 void initDebuggerVar(int *piDbgCfgVar, const char *pszEnvVar, const char *pszExtraDataName, bool fDefault = false); … … 539 542 /** Holds the symbolic VirtualBox home-folder representation. */ 540 543 QString m_strHomeFolder; 544 /** Holds the guest OS family IDs. */ 545 QList<QString> m_guestOSFamilyIDs; 546 /** Holds the guest OS types for each family ID. */ 547 QList<QList<CGuestOSType> > m_guestOSTypes; 541 548 542 549 /** Holds whether acquired COM wrappers are currently valid. */ … … 628 635 int m3DAvailable; 629 636 630 QList <QString> mFamilyIDs;631 QList <QList <CGuestOSType> > mTypes;632 633 637 QString mDiskTypes_Differencing; 634 638
Note:
See TracChangeset
for help on using the changeset viewer.