VirtualBox

Ignore:
Timestamp:
Dec 11, 2008 3:15:25 PM (16 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
40729
Message:

FE/Qt: Don't generate KEnum_COUNT values for COM enums as they might easy get wrong values (next integer after the last enum member which is not necessarily the largest) and screw the GUI.

Location:
trunk/src/VBox/Frontends/VirtualBox4/include
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox4/include/COMWrappers.xsl

    r14514 r15304  
    134134      <xsl:text>,&#x0A;</xsl:text>
    135135    </xsl:for-each>
    136     <xsl:text>    </xsl:text>
    137     <xsl:value-of select="concat('K',@name,'_COUNT')"/>
    138136    <xsl:text>&#x0A;};&#x0A;&#x0A;</xsl:text>
    139137  </xsl:for-each>
  • trunk/src/VBox/Frontends/VirtualBox4/include/VBoxGlobal.h

    r14977 r15304  
    496496public:
    497497
     498    typedef QHash <ulong, QString> QULongStringHash;
     499    typedef QHash <long, QString> QLongStringHash;
     500
    498501    static VBoxGlobal &instance();
    499502
    500503    bool isValid() { return mValid; }
    501504
    502     QString versionString() { return verString; }
     505    QString versionString() { return mVerString; }
    503506
    504507    CVirtualBox virtualBox() const { return mVBox; }
     
    545548    QPixmap toIcon (KMachineState s) const
    546549    {
    547         QPixmap *pm = mStateIcons.value (s);
     550        QPixmap *pm = mVMStateIcons.value (s);
    548551        AssertMsg (pm, ("Icon for VM state %d must be defined", s));
    549552        return pm ? *pm : QPixmap();
     
    553556    {
    554557        static const QColor none;
    555         AssertMsg (vm_state_color.value (s), ("No color for %d", s));
    556         return vm_state_color.value (s) ? *vm_state_color.value(s) : none;
     558        AssertMsg (mVMStateColors.value (s), ("No color for %d", s));
     559        return mVMStateColors.value (s) ? *mVMStateColors.value (s) : none;
    557560    }
    558561
    559562    QString toString (KMachineState s) const
    560563    {
    561         AssertMsg (!machineStates.value (s).isNull(), ("No text for %d", s));
    562         return machineStates.value (s);
     564        AssertMsg (!mMachineStates.value (s).isNull(), ("No text for %d", s));
     565        return mMachineStates.value (s);
    563566    }
    564567
    565568    QString toString (KSessionState s) const
    566569    {
    567         AssertMsg (!sessionStates.value (s).isNull(), ("No text for %d", s));
    568         return sessionStates.value (s);
     570        AssertMsg (!mSessionStates.value (s).isNull(), ("No text for %d", s));
     571        return mSessionStates.value (s);
    569572    }
    570573
     
    575578    QString toString (KStorageBus aBus) const
    576579    {
    577         AssertMsg (!storageBuses.value (aBus).isNull(), ("No text for %d", aBus));
    578         return storageBuses [aBus];
     580        AssertMsg (!mStorageBuses.value (aBus).isNull(), ("No text for %d", aBus));
     581        return mStorageBuses [aBus];
    579582    }
    580583
     
    585588    KStorageBus toStorageBusType (const QString &aBus) const
    586589    {
    587         QStringVector::const_iterator it =
    588             qFind (storageBuses.begin(), storageBuses.end(), aBus);
    589         AssertMsg (it != storageBuses.end(), ("No value for {%s}", aBus.toLatin1().constData()));
    590         return KStorageBus (it - storageBuses.begin());
     590        QULongStringHash::const_iterator it =
     591            qFind (mStorageBuses.begin(), mStorageBuses.end(), aBus);
     592        AssertMsg (it != mStorageBuses.end(), ("No value for {%s}",
     593                                               aBus.toLatin1().constData()));
     594        return KStorageBus (it.key());
    591595    }
    592596
     
    601605    QString toString (KHardDiskType t) const
    602606    {
    603         AssertMsg (!diskTypes.value (t).isNull(), ("No text for %d", t));
    604         return diskTypes.value (t);
     607        AssertMsg (!mDiskTypes.value (t).isNull(), ("No text for %d", t));
     608        return mDiskTypes.value (t);
    605609    }
    606610
     
    614618        {
    615619            Assert (aHD.GetType() == KHardDiskType_Normal);
    616             return diskTypes_Differencing;
     620            return mDiskTypes_Differencing;
    617621        }
    618622        return toString (aHD.GetType());
     
    621625    QString toString (KVRDPAuthType t) const
    622626    {
    623         AssertMsg (!vrdpAuthTypes.value (t).isNull(), ("No text for %d", t));
    624         return vrdpAuthTypes.value (t);
     627        AssertMsg (!mVRDPAuthTypes.value (t).isNull(), ("No text for %d", t));
     628        return mVRDPAuthTypes.value (t);
    625629    }
    626630
    627631    QString toString (KPortMode t) const
    628632    {
    629         AssertMsg (!portModeTypes.value (t).isNull(), ("No text for %d", t));
    630         return portModeTypes.value (t);
     633        AssertMsg (!mPortModeTypes.value (t).isNull(), ("No text for %d", t));
     634        return mPortModeTypes.value (t);
    631635    }
    632636
    633637    QString toString (KUSBDeviceFilterAction t) const
    634638    {
    635         AssertMsg (!usbFilterActionTypes.value (t).isNull(), ("No text for %d", t));
    636         return usbFilterActionTypes.value (t);
     639        AssertMsg (!mUSBFilterActionTypes.value (t).isNull(), ("No text for %d", t));
     640        return mUSBFilterActionTypes.value (t);
    637641    }
    638642
    639643    QString toString (KClipboardMode t) const
    640644    {
    641         AssertMsg (!clipboardTypes.value (t).isNull(), ("No text for %d", t));
    642         return clipboardTypes.value (t);
     645        AssertMsg (!mClipboardTypes.value (t).isNull(), ("No text for %d", t));
     646        return mClipboardTypes.value (t);
    643647    }
    644648
    645649    KClipboardMode toClipboardModeType (const QString &s) const
    646650    {
    647         QStringVector::const_iterator it =
    648             qFind (clipboardTypes.begin(), clipboardTypes.end(), s);
    649         AssertMsg (it != clipboardTypes.end(), ("No value for {%s}", s.toLatin1().constData()));
    650         return KClipboardMode (it - clipboardTypes.begin());
     651        QULongStringHash::const_iterator it =
     652            qFind (mClipboardTypes.begin(), mClipboardTypes.end(), s);
     653        AssertMsg (it != mClipboardTypes.end(), ("No value for {%s}",
     654                                                 s.toLatin1().constData()));
     655        return KClipboardMode (it.key());
    651656    }
    652657
    653658    QString toString (KIDEControllerType t) const
    654659    {
    655         AssertMsg (!ideControllerTypes.value (t).isNull(), ("No text for %d", t));
    656         return ideControllerTypes.value (t);
     660        AssertMsg (!mIDEControllerTypes.value (t).isNull(), ("No text for %d", t));
     661        return mIDEControllerTypes.value (t);
    657662    }
    658663
    659664    KIDEControllerType toIDEControllerType (const QString &s) const
    660665    {
    661         QStringVector::const_iterator it =
    662             qFind (ideControllerTypes.begin(), ideControllerTypes.end(), s);
    663         AssertMsg (it != ideControllerTypes.end(), ("No value for {%s}", s.toLatin1().constData()));
    664         return KIDEControllerType (it - ideControllerTypes.begin());
     666        QULongStringHash::const_iterator it =
     667            qFind (mIDEControllerTypes.begin(), mIDEControllerTypes.end(), s);
     668        AssertMsg (it != mIDEControllerTypes.end(), ("No value for {%s}",
     669                                                     s.toLatin1().constData()));
     670        return KIDEControllerType (it.key());
    665671    }
    666672
    667673    KVRDPAuthType toVRDPAuthType (const QString &s) const
    668674    {
    669         QStringVector::const_iterator it =
    670             qFind (vrdpAuthTypes.begin(), vrdpAuthTypes.end(), s);
    671         AssertMsg (it != vrdpAuthTypes.end(), ("No value for {%s}", s.toLatin1().constData()));
    672         return KVRDPAuthType (it - vrdpAuthTypes.begin());
     675        QULongStringHash::const_iterator it =
     676            qFind (mVRDPAuthTypes.begin(), mVRDPAuthTypes.end(), s);
     677        AssertMsg (it != mVRDPAuthTypes.end(), ("No value for {%s}",
     678                                                s.toLatin1().constData()));
     679        return KVRDPAuthType (it.key());
    673680    }
    674681
    675682    KPortMode toPortMode (const QString &s) const
    676683    {
    677         QStringVector::const_iterator it =
    678             qFind (portModeTypes.begin(), portModeTypes.end(), s);
    679         AssertMsg (it != portModeTypes.end(), ("No value for {%s}", s.toLatin1().constData()));
    680         return KPortMode (it - portModeTypes.begin());
     684        QULongStringHash::const_iterator it =
     685            qFind (mPortModeTypes.begin(), mPortModeTypes.end(), s);
     686        AssertMsg (it != mPortModeTypes.end(), ("No value for {%s}",
     687                                                s.toLatin1().constData()));
     688        return KPortMode (it.key());
    681689    }
    682690
    683691    KUSBDeviceFilterAction toUSBDevFilterAction (const QString &s) const
    684692    {
    685         QStringVector::const_iterator it =
    686             qFind (usbFilterActionTypes.begin(), usbFilterActionTypes.end(), s);
    687         AssertMsg (it != usbFilterActionTypes.end(), ("No value for {%s}", s.toLatin1().constData()));
    688         return KUSBDeviceFilterAction (it - usbFilterActionTypes.begin());
     693        QULongStringHash::const_iterator it =
     694            qFind (mUSBFilterActionTypes.begin(), mUSBFilterActionTypes.end(), s);
     695        AssertMsg (it != mUSBFilterActionTypes.end(), ("No value for {%s}",
     696                                                       s.toLatin1().constData()));
     697        return KUSBDeviceFilterAction (it.key());
    689698    }
    690699
    691700    QString toString (KDeviceType t) const
    692701    {
    693         AssertMsg (!deviceTypes.value (t).isNull(), ("No text for %d", t));
    694         return deviceTypes.value (t);
     702        AssertMsg (!mDeviceTypes.value (t).isNull(), ("No text for %d", t));
     703        return mDeviceTypes.value (t);
    695704    }
    696705
    697706    KDeviceType toDeviceType (const QString &s) const
    698707    {
    699         QStringVector::const_iterator it =
    700             qFind (deviceTypes.begin(), deviceTypes.end(), s);
    701         AssertMsg (it != deviceTypes.end(), ("No value for {%s}", s.toLatin1().constData()));
    702         return KDeviceType (it - deviceTypes.begin());
     708        QULongStringHash::const_iterator it =
     709            qFind (mDeviceTypes.begin(), mDeviceTypes.end(), s);
     710        AssertMsg (it != mDeviceTypes.end(), ("No value for {%s}",
     711                                              s.toLatin1().constData()));
     712        return KDeviceType (it.key());
    703713    }
    704714
     
    707717    QString toString (KAudioDriverType t) const
    708718    {
    709         AssertMsg (!audioDriverTypes.value (t).isNull(), ("No text for %d", t));
    710         return audioDriverTypes.value (t);
     719        AssertMsg (!mAudioDriverTypes.value (t).isNull(), ("No text for %d", t));
     720        return mAudioDriverTypes.value (t);
    711721    }
    712722
    713723    KAudioDriverType toAudioDriverType (const QString &s) const
    714724    {
    715         QStringVector::const_iterator it =
    716             qFind (audioDriverTypes.begin(), audioDriverTypes.end(), s);
    717         AssertMsg (it != audioDriverTypes.end(), ("No value for {%s}", s.toLatin1().constData()));
    718         return KAudioDriverType (it - audioDriverTypes.begin());
     725        QULongStringHash::const_iterator it =
     726            qFind (mAudioDriverTypes.begin(), mAudioDriverTypes.end(), s);
     727        AssertMsg (it != mAudioDriverTypes.end(), ("No value for {%s}",
     728                                                   s.toLatin1().constData()));
     729        return KAudioDriverType (it.key());
    719730    }
    720731
    721732    QString toString (KAudioControllerType t) const
    722733    {
    723         AssertMsg (!audioControllerTypes.value (t).isNull(), ("No text for %d", t));
    724         return audioControllerTypes.value (t);
     734        AssertMsg (!mAudioControllerTypes.value (t).isNull(), ("No text for %d", t));
     735        return mAudioControllerTypes.value (t);
    725736    }
    726737
    727738    KAudioControllerType toAudioControllerType (const QString &s) const
    728739    {
    729         QStringVector::const_iterator it =
    730             qFind (audioControllerTypes.begin(), audioControllerTypes.end(), s);
    731         AssertMsg (it != audioControllerTypes.end(), ("No value for {%s}", s.toLatin1().constData()));
    732         return KAudioControllerType (it - audioControllerTypes.begin());
     740        QULongStringHash::const_iterator it =
     741            qFind (mAudioControllerTypes.begin(), mAudioControllerTypes.end(), s);
     742        AssertMsg (it != mAudioControllerTypes.end(), ("No value for {%s}",
     743                                                       s.toLatin1().constData()));
     744        return KAudioControllerType (it.key());
    733745    }
    734746
    735747    QString toString (KNetworkAdapterType t) const
    736748    {
    737         AssertMsg (!networkAdapterTypes.value (t).isNull(), ("No text for %d", t));
    738         return networkAdapterTypes.value (t);
     749        AssertMsg (!mNetworkAdapterTypes.value (t).isNull(), ("No text for %d", t));
     750        return mNetworkAdapterTypes.value (t);
    739751    }
    740752
    741753    KNetworkAdapterType toNetworkAdapterType (const QString &s) const
    742754    {
    743         QStringVector::const_iterator it =
    744             qFind (networkAdapterTypes.begin(), networkAdapterTypes.end(), s);
    745         AssertMsg (it != networkAdapterTypes.end(), ("No value for {%s}", s.toLatin1().constData()));
    746         return KNetworkAdapterType (it - networkAdapterTypes.begin());
     755        QULongStringHash::const_iterator it =
     756            qFind (mNetworkAdapterTypes.begin(), mNetworkAdapterTypes.end(), s);
     757        AssertMsg (it != mNetworkAdapterTypes.end(), ("No value for {%s}",
     758                                                      s.toLatin1().constData()));
     759        return KNetworkAdapterType (it.key());
    747760    }
    748761
    749762    QString toString (KNetworkAttachmentType t) const
    750763    {
    751         AssertMsg (!networkAttachmentTypes.value (t).isNull(), ("No text for %d", t));
    752         return networkAttachmentTypes.value (t);
     764        AssertMsg (!mNetworkAttachmentTypes.value (t).isNull(), ("No text for %d", t));
     765        return mNetworkAttachmentTypes.value (t);
    753766    }
    754767
    755768    KNetworkAttachmentType toNetworkAttachmentType (const QString &s) const
    756769    {
    757         QStringVector::const_iterator it =
    758             qFind (networkAttachmentTypes.begin(), networkAttachmentTypes.end(), s);
    759         AssertMsg (it != networkAttachmentTypes.end(), ("No value for {%s}", s.toLatin1().constData()));
    760         return KNetworkAttachmentType (it - networkAttachmentTypes.begin());
     770        QULongStringHash::const_iterator it =
     771            qFind (mNetworkAttachmentTypes.begin(), mNetworkAttachmentTypes.end(), s);
     772        AssertMsg (it != mNetworkAttachmentTypes.end(), ("No value for {%s}",
     773                                                         s.toLatin1().constData()));
     774        return KNetworkAttachmentType (it.key());
    761775    }
    762776
    763777    QString toString (KUSBDeviceState aState) const
    764778    {
    765         AssertMsg (!USBDeviceStates.value (aState).isNull(), ("No text for %d", aState));
    766         return USBDeviceStates.value (aState);
     779        AssertMsg (!mUSBDeviceStates.value (aState).isNull(), ("No text for %d", aState));
     780        return mUSBDeviceStates.value (aState);
    767781    }
    768782
     
    10631077    CVirtualBoxCallback callback;
    10641078
    1065     typedef QVector <QString> QStringVector;
    1066 
    1067     QString verString;
     1079    QString mVerString;
    10681080
    10691081    QList <QString> mFamilyIDs;
    10701082    QList <QList <CGuestOSType> > mTypes;
    10711083    QHash <QString, QPixmap *> mOsTypeIcons;
    1072     QVector <QColor *> vm_state_color;
    1073 
    1074     QHash <long int, QPixmap *> mStateIcons;
     1084
     1085    QHash <ulong, QPixmap *> mVMStateIcons;
     1086    QHash <ulong, QColor *> mVMStateColors;
     1087
    10751088    QPixmap mOfflineSnapshotIcon, mOnlineSnapshotIcon;
    10761089
    1077     QStringVector machineStates;
    1078     QStringVector sessionStates;
    1079     QStringVector deviceTypes;
    1080 
    1081     QStringVector storageBuses;
    1082     QStringVector storageBusDevices;
    1083     QStringVector storageBusChannels;
    1084 
    1085     QStringVector diskTypes;
    1086     QString diskTypes_Differencing;
    1087 
    1088     QStringVector vrdpAuthTypes;
    1089     QStringVector portModeTypes;
    1090     QStringVector usbFilterActionTypes;
    1091     QStringVector audioDriverTypes;
    1092     QStringVector audioControllerTypes;
    1093     QStringVector networkAdapterTypes;
    1094     QStringVector networkAttachmentTypes;
    1095     QStringVector clipboardTypes;
    1096     QStringVector ideControllerTypes;
    1097     QStringVector USBDeviceStates;
     1090    QULongStringHash mMachineStates;
     1091    QULongStringHash mSessionStates;
     1092    QULongStringHash mDeviceTypes;
     1093
     1094    QULongStringHash mStorageBuses;
     1095    QLongStringHash mStorageBusChannels;
     1096    QLongStringHash mStorageBusDevices;
     1097
     1098    QULongStringHash mDiskTypes;
     1099    QString mDiskTypes_Differencing;
     1100
     1101    QULongStringHash mVRDPAuthTypes;
     1102    QULongStringHash mPortModeTypes;
     1103    QULongStringHash mUSBFilterActionTypes;
     1104    QULongStringHash mAudioDriverTypes;
     1105    QULongStringHash mAudioControllerTypes;
     1106    QULongStringHash mNetworkAdapterTypes;
     1107    QULongStringHash mNetworkAttachmentTypes;
     1108    QULongStringHash mClipboardTypes;
     1109    QULongStringHash mIDEControllerTypes;
     1110    QULongStringHash mUSBDeviceStates;
    10981111
    10991112    QString mUserDefinedPortName;
     
    11011114    QPixmap mWarningIcon, mErrorIcon;
    11021115
    1103     mutable bool detailReportTemplatesReady;
     1116    mutable bool mDetailReportTemplatesReady;
    11041117
    11051118    friend VBoxGlobal &vboxGlobal();
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