Changeset 23438 in vbox for trunk/src/VBox
- Timestamp:
- Sep 30, 2009 12:37:23 PM (15 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/include/VBoxGlobal.h
r23390 r23438 413 413 LONG toStorageDevice (KStorageBus aBus, LONG aChannel, const QString &aDevice) const; 414 414 415 QString to FullString (StorageSlot aSlot) const;415 QString toString (StorageSlot aSlot) const; 416 416 StorageSlot toStorageSlot (const QString &aSlot) const; 417 417 … … 924 924 QLongStringHash mStorageBusChannels; 925 925 QLongStringHash mStorageBusDevices; 926 QULongStringHash mSlotTemplates; 926 927 927 928 QULongStringHash mDiskTypes; -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxGlobal.cpp
r23389 r23438 1155 1155 /** 1156 1156 * Returns a full string representation of the given device of the given channel on the given storage bus. 1157 * This method does not uses any separate string tags related to bus, channel, device, it has own 1158 * separately translated string tags allowing to translate a full slot name into human readable format 1159 * to be consistent with i18n. 1157 1160 * Complementary to #toStorageSlot (const QString &) const. 1158 1161 */ 1159 QString VBoxGlobal::toFullString (StorageSlot aSlot) const 1160 { 1161 QString device (vboxGlobal().toString (aSlot.bus) + ' '); 1162 1162 QString VBoxGlobal::toString (StorageSlot aSlot) const 1163 { 1164 int maxPort = virtualBox().GetSystemProperties().GetMaxPortCountForStorageBus (aSlot.bus); 1165 int maxDevice = virtualBox().GetSystemProperties().GetMaxDevicesPerPortForStorageBus (aSlot.bus); 1166 if (aSlot.port < 0 || aSlot.port > maxPort) 1167 AssertMsgFailed (("Invalid port %d\n", aSlot.port)); 1168 if (aSlot.device < 0 || aSlot.device > maxDevice) 1169 AssertMsgFailed (("Invalid device %d\n", aSlot.device)); 1170 1171 QString result; 1163 1172 switch (aSlot.bus) 1164 1173 { 1165 1174 case KStorageBus_IDE: 1166 1175 { 1167 device += vboxGlobal().toString (aSlot.bus, aSlot.port) + ' ' + 1168 vboxGlobal().toString (aSlot.bus, aSlot.port, aSlot.device); 1176 result = mSlotTemplates [aSlot.port * maxDevice + aSlot.device]; 1169 1177 break; 1170 1178 } 1171 1179 case KStorageBus_SATA: 1180 { 1181 result = mSlotTemplates [4].arg (aSlot.port); 1182 break; 1183 } 1172 1184 case KStorageBus_SCSI: 1173 1185 { 1174 device += vboxGlobal().toString (aSlot.bus,aSlot.port);1186 result = mSlotTemplates [5].arg (aSlot.port); 1175 1187 break; 1176 1188 } 1177 1189 case KStorageBus_Floppy: 1178 1190 { 1179 device += vboxGlobal().toString (aSlot.bus, aSlot.port,aSlot.device);1191 result = mSlotTemplates [6].arg (aSlot.device); 1180 1192 break; 1181 1193 } … … 1186 1198 } 1187 1199 } 1188 1189 return device; 1200 return result; 1190 1201 } 1191 1202 … … 1196 1207 StorageSlot VBoxGlobal::toStorageSlot (const QString &aSlot) const 1197 1208 { 1209 int index = -1; 1210 QRegExp regExp; 1211 for (int i = 0; i < mSlotTemplates.size(); ++ i) 1212 { 1213 regExp = QRegExp (mSlotTemplates [i].arg ("(\\d+)")); 1214 if (regExp.indexIn (aSlot) != -1) 1215 { 1216 index = i; 1217 break; 1218 } 1219 } 1220 1198 1221 StorageSlot result; 1199 1200 result.bus = toStorageBusType (aSlot.section (' ', 0, 0)); 1201 QString other (aSlot.section (' ', 1)); 1202 1203 switch (result.bus) 1204 { 1205 case KStorageBus_IDE: 1206 { 1207 result.port = toStorageChannel (result.bus, other.section (' ', 0, 0)); 1208 result.device = toStorageDevice (result.bus, result.port, other.section (' ', 1)); 1222 switch (index) 1223 { 1224 case 0: 1225 case 1: 1226 case 2: 1227 case 3: 1228 { 1229 result.bus = KStorageBus_IDE; 1230 int maxPort = virtualBox().GetSystemProperties().GetMaxPortCountForStorageBus (result.bus); 1231 result.port = index / maxPort; 1232 result.device = index % maxPort; 1209 1233 break; 1210 1234 } 1211 case KStorageBus_SATA: 1212 case KStorageBus_SCSI: 1213 { 1214 result.port = toStorageChannel (result.bus, other); 1215 result.device = toStorageDevice (result.bus, result.port, QString::null); 1235 case 4: 1236 { 1237 result.bus = KStorageBus_SATA; 1238 int maxPort = virtualBox().GetSystemProperties().GetMaxPortCountForStorageBus (result.bus); 1239 result.port = regExp.cap (1).toInt(); 1240 if (result.port < 0 || result.port > maxPort) 1241 AssertMsgFailed (("Invalid port %d\n", result.port)); 1216 1242 break; 1217 1243 } 1218 case KStorageBus_Floppy: 1219 { 1220 result.port = toStorageChannel (result.bus, QString::null); 1221 result.device = toStorageDevice (result.bus, result.port, other); 1244 case 5: 1245 { 1246 result.bus = KStorageBus_SCSI; 1247 int maxPort = virtualBox().GetSystemProperties().GetMaxPortCountForStorageBus (result.bus); 1248 result.port = regExp.cap (1).toInt(); 1249 if (result.port < 0 || result.port > maxPort) 1250 AssertMsgFailed (("Invalid port %d\n", result.port)); 1222 1251 break; 1223 1252 } 1253 case 6: 1254 { 1255 result.bus = KStorageBus_Floppy; 1256 int maxDevice = virtualBox().GetSystemProperties().GetMaxDevicesPerPortForStorageBus (result.bus); 1257 result.device = regExp.cap (1).toInt(); 1258 if (result.device < 0 || result.device > maxDevice) 1259 AssertMsgFailed (("Invalid device %d\n", result.device)); 1260 break; 1261 } 1224 1262 default: 1225 {1226 AssertMsgFailed (("Invalid bus type %d\n", result.bus));1227 1263 break; 1228 } 1229 } 1230 1264 } 1231 1265 return result; 1232 1266 } … … 1704 1738 LONG device = ma.GetDevice(); 1705 1739 item += QString (sSectionItemTpl2) 1706 .arg (to FullString (StorageSlot (bus, port, device)))1740 .arg (toString (StorageSlot (bus, port, device))) 1707 1741 .arg (details (medium, false)); 1708 1742 ++ rows; … … 2629 2663 mStorageBuses [KStorageBus_Floppy] = tr ("Floppy", "StorageBus"); 2630 2664 2631 mStorageBusChannels [0] = tr ("Primary", "StorageBusChannel"); 2632 mStorageBusChannels [1] = tr ("Secondary", "StorageBusChannel"); 2633 mStorageBusChannels [2] = tr ("Port %1", "StorageBusChannel"); 2634 2635 mStorageBusDevices [0] = tr ("Master", "StorageBusDevice"); 2636 mStorageBusDevices [1] = tr ("Slave", "StorageBusDevice"); 2637 mStorageBusDevices [2] = tr ("Device %1", "StorageBusDevice"); 2665 mStorageBusChannels [0] = tr ("Primary", "StorageBusChannel"); 2666 mStorageBusChannels [1] = tr ("Secondary", "StorageBusChannel"); 2667 mStorageBusChannels [2] = tr ("Port %1", "StorageBusChannel"); 2668 2669 mStorageBusDevices [0] = tr ("Master", "StorageBusDevice"); 2670 mStorageBusDevices [1] = tr ("Slave", "StorageBusDevice"); 2671 mStorageBusDevices [2] = tr ("Device %1", "StorageBusDevice"); 2672 2673 mSlotTemplates [0] = tr ("IDE Primary Master", "New Storage UI : Slot Name"); 2674 mSlotTemplates [1] = tr ("IDE Primary Slave", "New Storage UI : Slot Name"); 2675 mSlotTemplates [2] = tr ("IDE Secondary Master", "New Storage UI : Slot Name"); 2676 mSlotTemplates [3] = tr ("IDE Secondary Slave", "New Storage UI : Slot Name"); 2677 mSlotTemplates [4] = tr ("SATA Port %1", "New Storage UI : Slot Name"); 2678 mSlotTemplates [5] = tr ("SCSI Port %1", "New Storage UI : Slot Name"); 2679 mSlotTemplates [6] = tr ("Floppy Device %1", "New Storage UI : Slot Name"); 2638 2680 2639 2681 mDiskTypes [KMediumType_Normal] = tr ("Normal", "DiskType"); -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxProblemReporter.cpp
r23368 r23438 1161 1161 "to the slot <i>%2</i> of the machine <b>%3</b>.") 1162 1162 .arg (aLocation) 1163 .arg (vboxGlobal().to FullString (StorageSlot (aBus, aChannel, aDevice)))1163 .arg (vboxGlobal().toString (StorageSlot (aBus, aChannel, aDevice))) 1164 1164 .arg (CMachine (aMachine).GetName()), 1165 1165 formatErrorInfo (aMachine)); … … 1174 1174 "from the slot <i>%2</i> of the machine <b>%3</b>.") 1175 1175 .arg (aLocation) 1176 .arg (vboxGlobal().to FullString (StorageSlot (aBus, aChannel, aDevice)))1176 .arg (vboxGlobal().toString (StorageSlot (aBus, aChannel, aDevice))) 1177 1177 .arg (CMachine (aMachine).GetName()), 1178 1178 formatErrorInfo (aMachine)); -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxVMInformationDlg.cpp
r23249 r23438 618 618 CMedium hd = mSession.GetMachine().GetMedium (ctlName, aChannel, aDevice); 619 619 QString header = "<tr><td></td><td colspan=2><nobr><u>%1</u></nobr></td></tr>"; 620 QString name = vboxGlobal().to FullString (StorageSlot (ctl.GetBus(), aChannel, aDevice));620 QString name = vboxGlobal().toString (StorageSlot (ctl.GetBus(), aChannel, aDevice)); 621 621 QString result = hd.isNull() ? QString::null : header.arg (name); 622 622 result += composeArticle (aBelongsTo); -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxVMSettingsHD.cpp
r23429 r23438 1729 1729 KDeviceType attDevice = mStorageModel->data (attIndex, StorageModel::R_AttDevice).value <KDeviceType>(); 1730 1730 QString key (mStorageModel->data (attIndex, StorageModel::R_AttMediumId).toString()); 1731 QString value (QString ("%1 (%2)").arg (ctrName, vboxGlobal().to FullString (attSlot)));1731 QString value (QString ("%1 (%2)").arg (ctrName, vboxGlobal().toString (attSlot))); 1732 1732 /* Check for emptiness */ 1733 1733 if (vboxGlobal().findMedium (key).isNull() && attDevice == KDeviceType_HardDisk) … … 1968 1968 SlotsList slotsList (mStorageModel->data (index, StorageModel::R_AttSlots).value <SlotsList>()); 1969 1969 for (int i = 0; i < slotsList.size(); ++ i) 1970 mCbSlot->insertItem (mCbSlot->count(), vboxGlobal().to FullString (slotsList [i]));1970 mCbSlot->insertItem (mCbSlot->count(), vboxGlobal().toString (slotsList [i])); 1971 1971 StorageSlot slt = mStorageModel->data (index, StorageModel::R_AttSlot).value <StorageSlot>(); 1972 int attSlotPos = mCbSlot->findText (vboxGlobal().to FullString (slt));1972 int attSlotPos = mCbSlot->findText (vboxGlobal().toString (slt)); 1973 1973 mCbSlot->setCurrentIndex (attSlotPos == -1 ? 0 : attSlotPos); 1974 1974
Note:
See TracChangeset
for help on using the changeset viewer.