- Timestamp:
- May 13, 2008 12:32:10 PM (17 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox4
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox4/include/VBoxGlobal.h
r8155 r8785 211 211 } 212 212 213 QString toString (KStorageBus t) const 214 { 215 AssertMsg (!storageBuses.value (t).isNull(), ("No text for %d", t)); 216 return storageBuses.value (t); 217 } 218 219 QString toString (KStorageBus t, LONG c) const; 220 QString toString (KStorageBus t, LONG c, LONG d) const; 213 /** 214 * Returns a string representation of the given KStorageBus enum value. 215 * Complementary to #toStorageBusType (const QString &) const. 216 */ 217 QString toString (KStorageBus aBus) const 218 { 219 AssertMsg (!storageBuses.value (aBus).isNull(), ("No text for %d", aBus)); 220 return storageBuses [aBus]; 221 } 222 223 /** 224 * Returns a KStorageBus enum value corresponding to the given string 225 * representation. Complementary to #toString (KStorageBus) const. 226 */ 227 KStorageBus toStorageBusType (const QString &aBus) const 228 { 229 QStringVector::const_iterator it = 230 qFind (storageBuses.begin(), storageBuses.end(), aBus); 231 AssertMsg (it != storageBuses.end(), ("No value for {%s}", aBus.toLatin1().constData())); 232 return KStorageBus (it - storageBuses.begin()); 233 } 234 235 QString toString (KStorageBus aBus, LONG aChannel) const; 236 LONG toStorageChannel (KStorageBus aBus, const QString &aChannel) const; 237 238 QString toString (KStorageBus aBus, LONG aChannel, LONG aDevice) const; 239 LONG toStorageDevice (KStorageBus aBus, LONG aChannel, const QString &aDevice) const; 240 241 QString toFullString (KStorageBus aBus, LONG aChannel, LONG aDevice) const; 221 242 222 243 QString toString (KHardDiskType t) const -
trunk/src/VBox/Frontends/VirtualBox4/src/VBoxGlobal.cpp
r8741 r8785 741 741 , deviceTypes (KDeviceType_COUNT) 742 742 , storageBuses (KStorageBus_COUNT) 743 , storageBusDevices ( 3)743 , storageBusDevices (2) 744 744 , storageBusChannels (3) 745 745 , diskTypes (KHardDiskType_COUNT) … … 970 970 } 971 971 972 QString VBoxGlobal::toString (KStorageBus t, LONG c, LONG d) const 973 { 974 Assert (storageBusDevices.count() == 3); 975 QString dev; 976 977 NOREF(c); 978 switch (t) 972 /** 973 * Returns a string representation of the given channel number on the given 974 * storage bus. Complementary to #toStorageChannel (KStorageBus, const 975 * QString &) const. 976 */ 977 QString VBoxGlobal::toString (KStorageBus aBus, LONG aChannel) const 978 { 979 Assert (storageBusChannels.count() == 3); 980 QString channel; 981 982 switch (aBus) 979 983 { 980 984 case KStorageBus_IDE: 981 985 { 982 if ( d == 0 || d== 1)986 if (aChannel == 0 || aChannel == 1) 983 987 { 984 dev = storageBusDevices [d];988 channel = storageBusChannels [aChannel]; 985 989 break; 986 990 } 991 992 AssertMsgFailedBreak (("Invalid channel %d\n", aChannel)); 993 } 994 case KStorageBus_SATA: 995 { 996 channel = storageBusChannels [2].arg (aChannel); 997 break; 987 998 } 988 999 default: 989 dev = storageBusDevices [2].arg (d); 990 } 991 return dev; 992 } 993 994 QString VBoxGlobal::toString (KStorageBus t, LONG c) const 995 { 996 Assert (storageBusChannels.count() == 3); 997 QString dev; 998 switch (t) 1000 AssertFailedBreak(); 1001 } 1002 1003 return channel; 1004 } 1005 1006 /** 1007 * Returns a channel number on the given storage bus corresponding to the given 1008 * string representation. Complementary to #toString (KStorageBus, LONG) const. 1009 */ 1010 LONG VBoxGlobal::toStorageChannel (KStorageBus aBus, const QString &aChannel) const 1011 { 1012 LONG channel = 0; 1013 1014 switch (aBus) 999 1015 { 1000 1016 case KStorageBus_IDE: 1001 1017 { 1002 if (c == 0 || c == 1) 1018 QStringVector::const_iterator it = 1019 qFind (storageBusChannels.begin(), storageBusChannels.end(), 1020 aChannel); 1021 AssertMsgBreak (it != storageBusChannels.end(), 1022 ("No value for {%s}\n", aChannel.toLatin1().constData())); 1023 channel = (LONG) (it - storageBusChannels.begin()); 1024 break; 1025 } 1026 case KStorageBus_SATA: 1027 { 1028 /// @todo use regexp to properly extract the %1 text 1029 QString tpl = storageBusChannels [2].arg (""); 1030 if (aChannel.startsWith (tpl)) 1003 1031 { 1004 dev = storageBusChannels [c];1032 channel = aChannel.right (aChannel.length() - tpl.length()).toLong(); 1005 1033 break; 1006 1034 } 1035 1036 AssertMsgFailedBreak (("Invalid channel {%s}\n", aChannel.toLatin1().constData())); 1037 break; 1007 1038 } 1008 1039 default: 1009 dev = storageBusChannels [2].arg (c); 1010 } 1011 return dev; 1040 AssertFailedBreak(); 1041 } 1042 1043 return channel; 1044 } 1045 1046 /** 1047 * Returns a string representation of the given device number of the given 1048 * channel on the given storage bus. Complementary to #toStorageDevice 1049 * (KStorageBus, LONG, const QString &) const. 1050 */ 1051 QString VBoxGlobal::toString (KStorageBus aBus, LONG aChannel, LONG aDevice) const 1052 { 1053 NOREF (aChannel); 1054 1055 Assert (storageBusDevices.count() == 2); 1056 QString device; 1057 1058 switch (aBus) 1059 { 1060 case KStorageBus_IDE: 1061 { 1062 if (aDevice == 0 || aDevice == 1) 1063 { 1064 device = storageBusDevices [aDevice]; 1065 break; 1066 } 1067 1068 AssertMsgFailedBreak (("Invalid device %d\n", aDevice)); 1069 } 1070 case KStorageBus_SATA: 1071 { 1072 AssertMsgBreak (aDevice == 0, ("Invalid device %d\n", aDevice)); 1073 /* always zero so far for SATA */ 1074 break; 1075 } 1076 default: 1077 AssertFailedBreak(); 1078 } 1079 1080 return device; 1081 } 1082 1083 /** 1084 * Returns a device number of the given channel on the given storage bus 1085 * corresponding to the given string representation. Complementary to #toString 1086 * (KStorageBus, LONG, LONG) const. 1087 */ 1088 LONG VBoxGlobal::toStorageDevice (KStorageBus aBus, LONG aChannel, 1089 const QString &aDevice) const 1090 { 1091 NOREF (aChannel); 1092 1093 LONG device = 0; 1094 1095 switch (aBus) 1096 { 1097 case KStorageBus_IDE: 1098 { 1099 QStringVector::const_iterator it = 1100 qFind (storageBusDevices.begin(), storageBusDevices.end(), 1101 aDevice); 1102 AssertMsg (it != storageBusDevices.end(), 1103 ("No value for {%s}", aDevice.toLatin1().constData())); 1104 device = (LONG) (it - storageBusDevices.begin()); 1105 break; 1106 } 1107 case KStorageBus_SATA: 1108 { 1109 AssertMsgBreak(aDevice.isEmpty(), ("Invalid device {%s}\n", aDevice.toLatin1().constData())); 1110 /* always zero for SATA so far. */ 1111 break; 1112 } 1113 default: 1114 AssertFailedBreak(); 1115 } 1116 1117 return device; 1118 } 1119 1120 /** 1121 * Returns a full string representation of the given device of the given channel 1122 * on the given storage bus. Complementary to #toStorageParams (KStorageBus, 1123 * LONG, LONG) const. 1124 */ 1125 QString VBoxGlobal::toFullString (KStorageBus aBus, LONG aChannel, 1126 LONG aDevice) const 1127 { 1128 QString device; 1129 1130 switch (aBus) 1131 { 1132 case KStorageBus_IDE: 1133 { 1134 device = QString ("%1 %2 %3") 1135 .arg (vboxGlobal().toString (aBus)) 1136 .arg (vboxGlobal().toString (aBus, aChannel)) 1137 .arg (vboxGlobal().toString (aBus, aChannel, aDevice)); 1138 break; 1139 } 1140 case KStorageBus_SATA: 1141 { 1142 /* we only have one SATA device so far which is always zero */ 1143 device = QString ("%1 %2") 1144 .arg (vboxGlobal().toString (aBus)) 1145 .arg (vboxGlobal().toString (aBus, aChannel)); 1146 break; 1147 } 1148 default: 1149 AssertFailedBreak(); 1150 } 1151 1152 return device; 1012 1153 } 1013 1154 … … 1401 1542 { 1402 1543 QString src = root.GetLocation(); 1544 KStorageBus bus = hda.GetBus(); 1545 LONG channel = hda.GetChannel(); 1546 LONG device = hda.GetDevice(); 1403 1547 hardDisks += QString (sSectionItemTpl) 1404 .arg (QString ("%1 %2") 1405 .arg (toString (hda.GetBus(), hda.GetChannel())) 1406 .arg (toString (hda.GetBus(), hda.GetChannel(), 1407 hda.GetDevice()))) 1548 .arg (toFullString (bus, channel, device)) 1408 1549 .arg (QString ("%1 [<nobr>%2</nobr>]") 1409 1550 .arg (prepareFileNameForHTML (src)) … … 2318 2459 tr ("Secondary", "StorageBusChannel"); 2319 2460 storageBusChannels [2] = 2320 tr (" Channel %1", "StorageBusChannel");2321 2322 Assert (storageBusDevices.count() == 3);2461 tr ("Port %1", "StorageBusChannel"); 2462 2463 Assert (storageBusDevices.count() == 2); 2323 2464 storageBusDevices [0] = tr ("Master", "StorageBusDevice"); 2324 2465 storageBusDevices [1] = tr ("Slave", "StorageBusDevice"); 2325 storageBusDevices [2] = tr ("Device %1", "StorageBusDevice");2326 2466 2327 2467 diskTypes [KHardDiskType_Normal] =
Note:
See TracChangeset
for help on using the changeset viewer.