VirtualBox

Ignore:
Timestamp:
May 8, 2008 3:44:09 PM (17 years ago)
Author:
vboxsync
Message:

1761: "Create VM session information dialog":

  1. Updating Dialog for SATA devices.
  2. Not present hard disks and adapters removed from statistics.
  3. Updating Dialog for OS Type Name.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/ui/VBoxVMInformationDlg.ui.h

    r8698 r8718  
    4141        /* creating new information dialog if there is no one existing */
    4242        mSelfArray [machine.GetName()] = new VBoxVMInformationDlg (
    43             aConsole,
    44             "VBoxVMInformationDlg", WType_TopLevel | WDestructiveClose);
     43            aConsole, "VBoxVMInformationDlg", WType_TopLevel | WDestructiveClose);
    4544        /* read new machine data for this information dialog */
    4645        mSelfArray [machine.GetName()]->setup (aSession, aConsole);
     
    186185    /* Clear counter names initially. */
    187186    mNamesMap.clear();
    188 
    189     /* HD statistics: */
    190     mNamesMap ["/Devices/ATA0/Unit0/*DMA"] = tr ("DMA Transfers");
    191     mNamesMap ["/Devices/ATA0/Unit0/*PIO"] = tr ("PIO Transfers");
    192     mNamesMap ["/Devices/ATA0/Unit0/ReadBytes"] = tr ("Data Read");
    193     mNamesMap ["/Devices/ATA0/Unit0/WrittenBytes"] = tr ("Data Written");
    194 
    195     mNamesMap ["/Devices/ATA0/Unit1/*DMA"] = tr ("DMA Transfers");
    196     mNamesMap ["/Devices/ATA0/Unit1/*PIO"] = tr ("PIO Transfers");
    197     mNamesMap ["/Devices/ATA0/Unit1/ReadBytes"] = tr ("Data Read");
    198     mNamesMap ["/Devices/ATA0/Unit1/WrittenBytes"] = tr ("Data Written");
    199 
    200     mNamesMap ["/Devices/ATA1/Unit0/*DMA"] = tr ("DMA Transfers");
    201     mNamesMap ["/Devices/ATA1/Unit0/*PIO"] = tr ("PIO Transfers");
    202     mNamesMap ["/Devices/ATA1/Unit0/ReadBytes"] = tr ("Data Read");
    203     mNamesMap ["/Devices/ATA1/Unit0/WrittenBytes"] = tr ("Data Written");
    204 
    205     mNamesMap ["/Devices/ATA1/Unit1/*DMA"] = tr ("DMA Transfers");
    206     mNamesMap ["/Devices/ATA1/Unit1/*PIO"] = tr ("PIO Transfers");
    207     mNamesMap ["/Devices/ATA1/Unit1/ReadBytes"] = tr ("Data Read");
    208     mNamesMap ["/Devices/ATA1/Unit1/WrittenBytes"] = tr ("Data Written");
    209 
    210     for (int i = 0; i < 4; i++)
     187    mUnitsMap.clear();
     188    mLinksMap.clear();
     189
     190    /* IDE HD statistics: */
     191    for (int i = 0; i < 2; ++ i)
     192    for (int j = 0; j < 2; ++ j)
     193    {
     194        /* Names */
     195        mNamesMap [QString ("/Devices/ATA%1/Unit%2/*DMA")
     196                   .arg (i).arg (j)] = tr ("DMA Transfers");
     197        mNamesMap [QString ("/Devices/ATA%1/Unit%2/*PIO")
     198                   .arg (i).arg (j)] = tr ("PIO Transfers");
     199        mNamesMap [QString ("/Devices/ATA%1/Unit%2/ReadBytes")
     200                   .arg (i).arg (j)] = tr ("Data Read");
     201        mNamesMap [QString ("/Devices/ATA%1/Unit%2/WrittenBytes")
     202                   .arg (i).arg (j)] = tr ("Data Written");
     203
     204        /* Units */
     205        mUnitsMap [QString ("/Devices/ATA%1/Unit%2/*DMA")
     206                   .arg (i).arg (j)] = "[B]";
     207        mUnitsMap [QString ("/Devices/ATA%1/Unit%2/*PIO")
     208                   .arg (i).arg (j)] = "[B]";
     209        mUnitsMap [QString ("/Devices/ATA%1/Unit%2/ReadBytes")
     210                   .arg (i).arg (j)] = "B";
     211        mUnitsMap [QString ("/Devices/ATA%1/Unit%2/WrittenBytes")
     212                   .arg (i).arg (j)] = "B";
     213
     214        /* Belongs to */
     215        mLinksMap [QString ("IDE%1%2").arg (i).arg (j)] = QStringList()
     216            << QString ("/Devices/ATA%1/Unit%2/*DMA").arg (i).arg (j)
     217            << QString ("/Devices/ATA%1/Unit%2/*PIO").arg (i).arg (j)
     218            << QString ("/Devices/ATA%1/Unit%2/ReadBytes").arg (i).arg (j)
     219            << QString ("/Devices/ATA%1/Unit%2/WrittenBytes").arg (i).arg (j);
     220    }
     221
     222    /* SATA HD statistics: */
     223    for (int i = 0; i < 30; ++ i)
     224    {
     225        /* Names */
     226        mNamesMap [QString ("/Devices/SATA/Port%1/DMA").arg (i)]
     227            = tr ("DMA Transfers");
     228        mNamesMap [QString ("/Devices/SATA/Port%1/ReadBytes").arg (i)]
     229            = tr ("Data Read");
     230        mNamesMap [QString ("/Devices/SATA/Port%1/WrittenBytes").arg (i)]
     231            = tr ("Data Written");
     232
     233        /* Units */
     234        mUnitsMap [QString ("/Devices/SATA/Port%1/DMA").arg (i)] = "[B]";
     235        mUnitsMap [QString ("/Devices/SATA/Port%1/ReadBytes").arg (i)] = "B";
     236        mUnitsMap [QString ("/Devices/SATA/Port%1/WrittenBytes").arg (i)] = "B";
     237
     238        /* Belongs to */
     239        mLinksMap [QString ("SATA%1").arg (i)] = QStringList()
     240            << QString ("/Devices/SATA/Port%1/DMA").arg (i)
     241            << QString ("/Devices/SATA/Port%1/ReadBytes").arg (i)
     242            << QString ("/Devices/SATA/Port%1/WrittenBytes").arg (i);
     243    }
     244
     245    /* Network Adapters statistics: */
     246    ulong count = vboxGlobal().virtualBox()
     247                  .GetSystemProperties().GetNetworkAdapterCount();
     248    for (ulong i = 0; i < count; ++ i)
    211249    {
    212250        CNetworkAdapter na = machine.GetNetworkAdapter (i);
     
    223261                break;
    224262        }
    225         mNamesMap [QString("/Devices/%1%2/TransmitBytes")
    226                      .arg(name) .arg(i)] = tr ("Data Transmitted");
    227         mNamesMap [QString("/Devices/%1%2/ReceiveBytes")
    228                      .arg(name) .arg(i)] = tr ("Data Received");
     263
     264        /* Names */
     265        mNamesMap [QString ("/Devices/%1%2/TransmitBytes")
     266            .arg (name).arg (i)] = tr ("Data Transmitted");
     267        mNamesMap [QString ("/Devices/%1%2/ReceiveBytes")
     268            .arg (name).arg (i)] = tr ("Data Received");
     269
     270        /* Units */
     271        mUnitsMap [QString ("/Devices/%1%2/TransmitBytes")
     272            .arg (name).arg (i)] = "B";
     273        mUnitsMap [QString ("/Devices/%1%2/ReceiveBytes")
     274            .arg (name).arg (i)] = "B";
     275
     276        /* Belongs to */
     277        mLinksMap [QString ("NA%1").arg (i)] = QStringList()
     278            << QString ("/Devices/%1%2/TransmitBytes").arg (name).arg (i)
     279            << QString ("/Devices/%1%2/ReceiveBytes").arg (name).arg (i);
    229280    }
    230281
     
    466517    QString bdyRow = "<tr><td></td><td><nobr>%1</nobr></td><td colspan=2><nobr>%2</nobr></td></tr>";
    467518    QString paragraph = "<tr><td colspan=4></td></tr>";
    468     QString interline = "<tr><td colspan=4><font size=1>&nbsp;</font></td></tr>";
    469519    QString result;
     520
     521    CMachine m = mSession.GetMachine();
    470522
    471523    /* Screen & VT-X Runtime Parameters */
     
    487539                .arg (RT_HIWORD (addVersion)).arg (RT_LOWORD (addVersion)) :
    488540            tr ("Not Detected", "guest additions");
     541        QString osType = console.GetGuest().GetOSTypeId().isNull() ?
     542            tr ("Not Detected", "guest os type") : console.GetGuest().GetOSTypeId();
    489543
    490544        result += hdrRow.arg ("state_running_16px.png").arg (tr ("Runtime Attributes"));
     
    492546                  bdyRow.arg (VBoxGlobal::tr ("VT-x/AMD-V", "details report")).arg (virt);
    493547        result += bdyRow.arg (tr ("Guest Additions")).arg (addVerisonStr);
     548        result += bdyRow.arg (tr ("Guest OS Type")).arg (osType);
    494549        result += paragraph;
    495550    }
    496551
    497552    /* Hard Disk Statistics. */
    498     QString primaryMaster = QString ("%1 %2")
    499         .arg (vboxGlobal().toString (KStorageBus_IDE, 0))
    500         .arg (vboxGlobal().toString (KStorageBus_IDE, 0, 0));
    501     QString primarySlave = QString ("%1 %2")
    502         .arg (vboxGlobal().toString (KStorageBus_IDE, 0))
    503         .arg (vboxGlobal().toString (KStorageBus_IDE, 0, 1));
    504     QString secondarySlave = QString ("%1 %2")
    505         .arg (vboxGlobal().toString (KStorageBus_IDE, 1))
    506         .arg (vboxGlobal().toString (KStorageBus_IDE, 1, 1));
    507 
    508     result += hdrRow.arg ("hd_16px.png").arg (tr ("IDE Hard Disk Statistics"));
    509     result += formatHardDisk (primaryMaster, KStorageBus_IDE, 0, 0, 0, 1);
    510     result += interline;
    511     result += formatHardDisk (primarySlave, KStorageBus_IDE, 0, 1, 4, 5);
    512     result += interline;
    513     result += formatHardDisk (secondarySlave, KStorageBus_IDE, 1, 1, 12, 13);
    514     result += paragraph;
    515 
    516     /* CD/DVD-ROM Statistics. */
    517     result += hdrRow.arg ("cd_16px.png").arg (tr ("CD/DVD-ROM Statistics"));
    518     result += formatHardDisk (QString::null,
    519                               KStorageBus_IDE, 1, 0, 8, 9);
    520     result += paragraph;
     553    {
     554        QString hdStat;
     555
     556        result += hdrRow.arg ("hd_16px.png").arg (tr ("Hard Disk Statistics"));
     557
     558        /* IDE Hard Disk (Primary Master) */
     559        if (!m.GetHardDisk (KStorageBus_IDE, 0, 0).isNull())
     560        {
     561            hdStat += formatHardDisk (KStorageBus_IDE, 0, 0, "IDE00");
     562            hdStat += paragraph;
     563        }
     564
     565        /* IDE Hard Disk (Primary Slave) */
     566        if (!m.GetHardDisk (KStorageBus_IDE, 0, 1).isNull())
     567        {
     568            hdStat += formatHardDisk (KStorageBus_IDE, 0, 1, "IDE01");
     569            hdStat += paragraph;
     570        }
     571
     572        /* IDE Hard Disk (Secondary Slave) */
     573        if (!m.GetHardDisk (KStorageBus_IDE, 1, 1).isNull())
     574        {
     575            hdStat += formatHardDisk (KStorageBus_IDE, 1, 1, "IDE11");
     576            hdStat += paragraph;
     577        }
     578
     579        /* SATA Hard Disks */
     580        for (int i = 0; i < 30; ++ i)
     581        {
     582            if (!m.GetHardDisk (KStorageBus_SATA, i, 0).isNull())
     583            {
     584                hdStat += formatHardDisk (KStorageBus_SATA, i, 0,
     585                                          QString ("SATA%1").arg (i));
     586                hdStat += paragraph;
     587            }
     588        }
     589
     590        /* If there are no Hard Disks */
     591        if (hdStat.isNull())
     592        {
     593            hdStat = composeArticle (tr ("Hard Disks not attached"));
     594            hdStat += paragraph;
     595        }
     596
     597        result += hdStat;
     598
     599        /* CD/DVD-ROM (Secondary Master) */
     600        result += hdrRow.arg ("cd_16px.png").arg (tr ("CD/DVD-ROM Statistics"));
     601        result += formatHardDisk (KStorageBus_IDE, 1, 0, "IDE10");
     602        result += paragraph;
     603    }
    521604
    522605    /* Network Adapters Statistics. */
    523606    {
     607        QString naStat;
     608
    524609        result += hdrRow.arg ("nw_16px.png")
    525610            .arg (tr ("Network Adapter Statistics"));
     611
     612        /* Network Adapters list */
    526613        ulong count = vboxGlobal().virtualBox()
    527             .GetSystemProperties().GetNetworkAdapterCount();
     614                      .GetSystemProperties().GetNetworkAdapterCount();
    528615        for (ulong slot = 0; slot < count; ++ slot)
    529616        {
    530             result += formatAdapter (
    531                 VBoxGlobal::tr ("Adapter %1", "details report (network)")
    532                 .arg (slot), slot, 16 + slot * 2, 17 + slot * 2);
    533             if (slot < count - 1)
    534                 result += interline;
    535         }
     617            if (m.GetNetworkAdapter (slot).GetEnabled())
     618            {
     619                naStat += formatAdapter (slot, QString ("NA%1").arg (slot));
     620                naStat += paragraph;
     621            }
     622        }
     623
     624        /* If there are no Network Adapters */
     625        if (naStat.isNull())
     626        {
     627            naStat = composeArticle (tr ("Network Adapters not attached"));
     628            naStat += paragraph;
     629        }
     630
     631        result += naStat;
    536632    }
    537633
     
    541637
    542638
    543 QString VBoxVMInformationDlg::formatHardDisk (const QString &aName,
    544                                               KStorageBus aBus, LONG aChannel,
    545                                               LONG aDevice, int aStart, int aFinish)
     639QString VBoxVMInformationDlg::formatHardDisk (KStorageBus aBus,
     640                                              LONG aChannel,
     641                                              LONG aDevice,
     642                                              const QString &aBelongsTo)
    546643{
    547644    if (mSession.isNull())
    548645        return QString::null;
    549646
     647    CHardDisk hd = mSession.GetMachine().GetHardDisk (aBus, aChannel, aDevice);
    550648    QString header = "<tr><td></td><td colspan=3><nobr><u>%1</u></nobr></td></tr>";
    551     CMachine machine = mSession.GetMachine();
    552 
    553     QString result = aName.isNull() ? QString::null : header.arg (aName);
    554     CHardDisk hd = machine.GetHardDisk (aBus, aChannel, aDevice);
    555     if (!hd.isNull() || (aBus == KStorageBus_IDE && aChannel == 1 && aDevice == 0))
    556     {
    557         result += composeArticle (QString::null, aStart, aFinish);
    558         result += composeArticle ("B", aStart + 2, aFinish + 2);
    559     }
    560     else
    561         result += composeArticle (tr ("Not Attached", "hard disk"), -1, -1);
     649    QString name = vboxGlobal().toFullString (aBus, aChannel, aDevice);
     650    QString result = hd.isNull() ? QString::null : header.arg (name);
     651    result += composeArticle (aBelongsTo);
    562652    return result;
    563653}
    564654
    565 QString VBoxVMInformationDlg::formatAdapter (const QString &aName,
    566                                              ULONG aSlot,
    567                                              int aStart, int aFinish)
     655QString VBoxVMInformationDlg::formatAdapter (ULONG aSlot,
     656                                             const QString &aBelongsTo)
    568657
    569658{
     
    572661
    573662    QString header = "<tr><td></td><td colspan=3><nobr><u>%1</u></nobr></td></tr>";
    574     CMachine machine = mSession.GetMachine();
    575 
    576     QString result = header.arg (aName);
    577     CNetworkAdapter na = machine.GetNetworkAdapter (aSlot);
    578     result += na.GetEnabled() ?
    579         composeArticle ("B", aStart, aFinish) :
    580         composeArticle (tr ("Disabled", "network adapter"), -1, -1);
     663    QString name = VBoxGlobal::tr ("Adapter %1", "details report (network)").arg (aSlot);
     664    QString result = header.arg (name);
     665    result += composeArticle (aBelongsTo);
    581666    return result;
    582667}
    583668
    584669
    585 QString VBoxVMInformationDlg::composeArticle (const QString &aUnits,
    586                                               int aStart, int aFinish)
    587 {
    588     QString body = "<tr><td></td><td><nobr>%1</nobr></td><td align=right><nobr>%2%3</nobr></td><td width=100%></td></tr>";
    589 
     670QString VBoxVMInformationDlg::composeArticle (const QString &aBelongsTo)
     671{
     672    QString body = "<tr><td></td><td><nobr>%1</nobr></td><td align=right>"
     673                   "<nobr>%2%3</nobr></td><td width=100%></td></tr>";
    590674    QString result;
    591675
    592     if (aStart == -1 && aFinish == -1)
    593         result += body.arg (aUnits).arg (QString::null).arg (QString::null);
    594     else for (int id = aStart; id <= aFinish; ++ id)
    595     {
    596         QString line = body;
    597         if (mValuesMap.contains (mNamesMap.keys() [id]))
    598         {
    599             ULONG64 value = mValuesMap.values() [id].toULongLong();
    600             line = line.arg (mNamesMap.values() [id])
    601                        .arg (QString ("%L1").arg (value));
    602             line = aUnits.isNull() ?
    603                 line.arg (QString ("<img src=tpixel.png width=%1 height=1>")
    604                           .arg (QApplication::fontMetrics().width (" B"))) :
    605                 line.arg (QString (" %1").arg (aUnits));
    606         }
    607         result += line;
    608     }
     676    if (mLinksMap.contains (aBelongsTo))
     677    {
     678        QStringList keyList = mLinksMap [aBelongsTo];
     679        for (QStringList::Iterator it = keyList.begin(); it != keyList.end(); ++ it)
     680        {
     681            QString line (body);
     682            QString key = *it;
     683            if (mNamesMap.contains (key) &&
     684                mValuesMap.contains (key) &&
     685                mUnitsMap.contains (key))
     686            {
     687                line = line.arg (mNamesMap [key])
     688                           .arg (QString ("%L1")
     689                                 .arg (mValuesMap [key].toULongLong()));
     690                line = mUnitsMap [key].contains (QRegExp ("\\[\\S+\\]")) ?
     691                    line.arg (QString ("<img src=tpixel.png width=%1 height=1>")
     692                              .arg (QApplication::fontMetrics().width (
     693                              QString (" %1").arg (mUnitsMap [key]
     694                              .mid (1, mUnitsMap [key].length() - 2))))) :
     695                    line.arg (QString (" %1").arg (mUnitsMap [key]));
     696                result += line;
     697            }
     698        }
     699    }
     700    else
     701        result = body.arg (aBelongsTo).arg (QString::null).arg (QString::null);
    609702
    610703    return result;
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