VirtualBox

Changeset 23438 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Sep 30, 2009 12:37:23 PM (15 years ago)
Author:
vboxsync
Message:

FE/Qt4: New Storage UI: Better storage-slots serialization/de-serialization procedures feating human readable format for i18n.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/include/VBoxGlobal.h

    r23390 r23438  
    413413    LONG toStorageDevice (KStorageBus aBus, LONG aChannel, const QString &aDevice) const;
    414414
    415     QString toFullString (StorageSlot aSlot) const;
     415    QString toString (StorageSlot aSlot) const;
    416416    StorageSlot toStorageSlot (const QString &aSlot) const;
    417417
     
    924924    QLongStringHash mStorageBusChannels;
    925925    QLongStringHash mStorageBusDevices;
     926    QULongStringHash mSlotTemplates;
    926927
    927928    QULongStringHash mDiskTypes;
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxGlobal.cpp

    r23389 r23438  
    11551155/**
    11561156 * 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.
    11571160 * Complementary to #toStorageSlot (const QString &) const.
    11581161 */
    1159 QString VBoxGlobal::toFullString (StorageSlot aSlot) const
    1160 {
    1161     QString device (vboxGlobal().toString (aSlot.bus) + ' ');
    1162 
     1162QString 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;
    11631172    switch (aSlot.bus)
    11641173    {
    11651174        case KStorageBus_IDE:
    11661175        {
    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];
    11691177            break;
    11701178        }
    11711179        case KStorageBus_SATA:
     1180        {
     1181            result = mSlotTemplates [4].arg (aSlot.port);
     1182            break;
     1183        }
    11721184        case KStorageBus_SCSI:
    11731185        {
    1174             device += vboxGlobal().toString (aSlot.bus, aSlot.port);
     1186            result = mSlotTemplates [5].arg (aSlot.port);
    11751187            break;
    11761188        }
    11771189        case KStorageBus_Floppy:
    11781190        {
    1179             device += vboxGlobal().toString (aSlot.bus, aSlot.port, aSlot.device);
     1191            result = mSlotTemplates [6].arg (aSlot.device);
    11801192            break;
    11811193        }
     
    11861198        }
    11871199    }
    1188 
    1189     return device;
     1200    return result;
    11901201}
    11911202
     
    11961207StorageSlot VBoxGlobal::toStorageSlot (const QString &aSlot) const
    11971208{
     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
    11981221    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;
    12091233            break;
    12101234        }
    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));
    12161242            break;
    12171243        }
    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));
    12221251            break;
    12231252        }
     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        }
    12241262        default:
    1225         {
    1226             AssertMsgFailed (("Invalid bus type %d\n", result.bus));
    12271263            break;
    1228         }
    1229     }
    1230 
     1264    }
    12311265    return result;
    12321266}
     
    17041738                LONG device = ma.GetDevice();
    17051739                item += QString (sSectionItemTpl2)
    1706                         .arg (toFullString (StorageSlot (bus, port, device)))
     1740                        .arg (toString (StorageSlot (bus, port, device)))
    17071741                        .arg (details (medium, false));
    17081742                ++ rows;
     
    26292663    mStorageBuses [KStorageBus_Floppy] =    tr ("Floppy", "StorageBus");
    26302664
    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");
    26382680
    26392681    mDiskTypes [KMediumType_Normal] =           tr ("Normal", "DiskType");
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxProblemReporter.cpp

    r23368 r23438  
    11611161            "to the slot <i>%2</i> of the machine <b>%3</b>.")
    11621162            .arg (aLocation)
    1163             .arg (vboxGlobal().toFullString (StorageSlot (aBus, aChannel, aDevice)))
     1163            .arg (vboxGlobal().toString (StorageSlot (aBus, aChannel, aDevice)))
    11641164            .arg (CMachine (aMachine).GetName()),
    11651165        formatErrorInfo (aMachine));
     
    11741174            "from the slot <i>%2</i> of the machine <b>%3</b>.")
    11751175            .arg (aLocation)
    1176             .arg (vboxGlobal().toFullString (StorageSlot (aBus, aChannel, aDevice)))
     1176            .arg (vboxGlobal().toString (StorageSlot (aBus, aChannel, aDevice)))
    11771177            .arg (CMachine (aMachine).GetName()),
    11781178         formatErrorInfo (aMachine));
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxVMInformationDlg.cpp

    r23249 r23438  
    618618    CMedium hd = mSession.GetMachine().GetMedium (ctlName, aChannel, aDevice);
    619619    QString header = "<tr><td></td><td colspan=2><nobr><u>%1</u></nobr></td></tr>";
    620     QString name = vboxGlobal().toFullString (StorageSlot (ctl.GetBus(), aChannel, aDevice));
     620    QString name = vboxGlobal().toString (StorageSlot (ctl.GetBus(), aChannel, aDevice));
    621621    QString result = hd.isNull() ? QString::null : header.arg (name);
    622622    result += composeArticle (aBelongsTo);
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxVMSettingsHD.cpp

    r23429 r23438  
    17291729            KDeviceType attDevice = mStorageModel->data (attIndex, StorageModel::R_AttDevice).value <KDeviceType>();
    17301730            QString key (mStorageModel->data (attIndex, StorageModel::R_AttMediumId).toString());
    1731             QString value (QString ("%1 (%2)").arg (ctrName, vboxGlobal().toFullString (attSlot)));
     1731            QString value (QString ("%1 (%2)").arg (ctrName, vboxGlobal().toString (attSlot)));
    17321732            /* Check for emptiness */
    17331733            if (vboxGlobal().findMedium (key).isNull() && attDevice == KDeviceType_HardDisk)
     
    19681968                SlotsList slotsList (mStorageModel->data (index, StorageModel::R_AttSlots).value <SlotsList>());
    19691969                for (int i = 0; i < slotsList.size(); ++ i)
    1970                     mCbSlot->insertItem (mCbSlot->count(), vboxGlobal().toFullString (slotsList [i]));
     1970                    mCbSlot->insertItem (mCbSlot->count(), vboxGlobal().toString (slotsList [i]));
    19711971                StorageSlot slt = mStorageModel->data (index, StorageModel::R_AttSlot).value <StorageSlot>();
    1972                 int attSlotPos = mCbSlot->findText (vboxGlobal().toFullString (slt));
     1972                int attSlotPos = mCbSlot->findText (vboxGlobal().toString (slt));
    19731973                mCbSlot->setCurrentIndex (attSlotPos == -1 ? 0 : attSlotPos);
    19741974
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