Changeset 23493 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Oct 1, 2009 5:16:30 PM (15 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/include/VBoxVMInformationDlg.h
r17669 r23493 6 6 7 7 /* 8 * Copyright (C) 2006-200 8Sun Microsystems, Inc.8 * Copyright (C) 2006-2009 Sun Microsystems, Inc. 9 9 * 10 10 * This file is part of VirtualBox Open Source Edition (OSE), as … … 32 32 class QTimer; 33 33 34 class VBoxVMInformationDlg : public QIWithRetranslateUI2<QIMainDialog>, 35 public Ui::VBoxVMInformationDlg 34 class VBoxVMInformationDlg : public QIWithRetranslateUI2 <QIMainDialog>, public Ui::VBoxVMInformationDlg 36 35 { 37 36 Q_OBJECT; … … 39 38 public: 40 39 41 typedef QMap <QString, QString> DataMapType;42 typedef QMap <QString, QStringList> LinksMapType;43 struct CounterElementType { QString type; DataMapType list;};40 typedef QMap <QString, QString> DataMapType; 41 typedef QMap <QString, QStringList> LinksMapType; 42 struct CounterElementType { QString type; DataMapType list; }; 44 43 typedef QMap <QString, VBoxVMInformationDlg*> InfoDlgMap; 45 44 46 static void createInformationDlg (const CSession &aSession, 47 VBoxConsoleView *aConsole); 48 49 VBoxVMInformationDlg (VBoxConsoleView *aConsole, const CSession &aSession, 50 Qt::WindowFlags aFlags); 51 ~VBoxVMInformationDlg(); 45 static void createInformationDlg (const CSession &aSession, VBoxConsoleView *aConsole); 52 46 53 47 protected: 48 49 VBoxVMInformationDlg (VBoxConsoleView *aConsole, const CSession &aSession, Qt::WindowFlags aFlags); 50 ~VBoxVMInformationDlg(); 54 51 55 52 void retranslateUi(); … … 64 61 void processStatistics(); 65 62 void onPageChanged (int aIndex); 66 void suicide();67 63 68 64 private: … … 72 68 73 69 QString formatValue (const QString &aValueName, const QString &aValue, int aMaxSize); 74 QString format HardDisk (const QString &ctlName, LONG aChannel, LONG aDevice, const QString &aBelongsTo);70 QString formatMedium (const QString &aCtrName, LONG aPort, LONG aDevice, const QString &aBelongsTo); 75 71 QString formatAdapter (ULONG aSlot, const QString &aBelongsTo); 76 72 77 QString composeArticle (const QString &aBelongsTo );73 QString composeArticle (const QString &aBelongsTo, int aSpacesCount = 0); 78 74 79 75 static InfoDlgMap mSelfArray; -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxVMInformationDlg.cpp
r23438 r23493 6 6 7 7 /* 8 * Copyright (C) 2006-200 8Sun Microsystems, Inc.8 * Copyright (C) 2006-2009 Sun Microsystems, Inc. 9 9 * 10 10 * This file is part of VirtualBox Open Source Edition (OSE), as … … 21 21 */ 22 22 23 /* Global Includes */ 24 #include <QTimer> 25 26 /* Local Includes */ 23 27 #include <VBoxVMInformationDlg.h> 24 28 #include <VBoxGlobal.h> 25 29 #include <VBoxConsoleView.h> 26 30 27 /* Qt includes */28 #include <QTimer>29 30 31 VBoxVMInformationDlg::InfoDlgMap VBoxVMInformationDlg::mSelfArray = InfoDlgMap(); 31 32 32 void VBoxVMInformationDlg::createInformationDlg (const CSession &aSession, 33 VBoxConsoleView *aConsole) 33 void VBoxVMInformationDlg::createInformationDlg (const CSession &aSession, VBoxConsoleView *aConsole) 34 34 { 35 35 CMachine machine = aSession.GetMachine(); … … 37 37 { 38 38 /* Creating new information dialog if there is no one existing */ 39 VBoxVMInformationDlg *id = new VBoxVMInformationDlg (aConsole, 40 aSession, Qt::Window); 39 VBoxVMInformationDlg *id = new VBoxVMInformationDlg (aConsole, aSession, Qt::Window); 41 40 id->centerAccording (aConsole); 42 41 connect (vboxGlobal().mainWindow(), SIGNAL (closing()), id, SLOT (close())); … … 52 51 } 53 52 54 55 VBoxVMInformationDlg::VBoxVMInformationDlg (VBoxConsoleView *aConsole, 56 const CSession &aSession, 57 Qt::WindowFlags aFlags) 53 VBoxVMInformationDlg::VBoxVMInformationDlg (VBoxConsoleView *aConsole, const CSession &aSession, Qt::WindowFlags aFlags) 58 54 #ifdef Q_WS_MAC 59 : QIWithRetranslateUI2 <QIMainDialog> (aConsole, aFlags)55 : QIWithRetranslateUI2 <QIMainDialog> (aConsole, aFlags) 60 56 #else /* Q_WS_MAC */ 61 : QIWithRetranslateUI2 <QIMainDialog> (NULL, aFlags)57 : QIWithRetranslateUI2 <QIMainDialog> (0, aFlags) 62 58 #endif /* Q_WS_MAC */ 63 59 , mIsPolished (false) … … 70 66 71 67 #ifdef Q_WS_MAC 72 /* No icon for this window on the mac, cause this would act as proxy icon 73 * which isn't necessary here. */ 68 /* No icon for this window on the mac, cause this would act as proxy icon which isn't necessary here. */ 74 69 setWindowIcon (QIcon()); 75 70 #else … … 90 85 mStatisticText->viewport()->setAutoFillBackground (false); 91 86 92 /* For further tuning can be used setViewportMargins method of 93 * QRichTextEdit extended class: */ 94 #if 0 87 /* Setup margins */ 95 88 mDetailsText->setViewportMargins (5, 5, 5, 5); 96 #endif 97 mStatisticText->setViewportMargins (0, 0, 5, 0); 89 mStatisticText->setViewportMargins (5, 5, 5, 5); 98 90 99 91 /* Setup handlers */ 100 connect (mInfoStack, SIGNAL (currentChanged (int)), 101 this, SLOT (onPageChanged (int))); 102 connect (&vboxGlobal(), SIGNAL (mediumEnumFinished (const VBoxMediaList &)), 103 this, SLOT (updateDetails())); 104 connect (mConsole, SIGNAL (mediaDriveChanged (VBoxDefs::MediaType)), 105 this, SLOT (updateDetails())); 106 connect (mConsole, SIGNAL (sharedFoldersChanged()), 107 this, SLOT (updateDetails())); 108 connect (mStatTimer, SIGNAL (timeout()), 109 this, SLOT (processStatistics())); 110 connect (mConsole, SIGNAL (resizeHintDone()), 111 this, SLOT (processStatistics())); 92 connect (mInfoStack, SIGNAL (currentChanged (int)), this, SLOT (onPageChanged (int))); 93 connect (&vboxGlobal(), SIGNAL (mediumEnumFinished (const VBoxMediaList &)), this, SLOT (updateDetails())); 94 connect (mConsole, SIGNAL (mediaDriveChanged (VBoxDefs::MediaType)), this, SLOT (updateDetails())); 95 connect (mConsole, SIGNAL (sharedFoldersChanged()), this, SLOT (updateDetails())); 96 connect (mStatTimer, SIGNAL (timeout()), this, SLOT (processStatistics())); 97 connect (mConsole, SIGNAL (resizeHintDone()), this, SLOT (processStatistics())); 112 98 113 99 /* Loading language constants */ … … 122 108 123 109 /* Preload dialog attributes for this vm */ 124 QString dlgsize = 125 mSession.GetMachine().GetExtraData (VBoxDefs::GUI_InfoDlgState); 110 QString dlgsize = mSession.GetMachine().GetExtraData (VBoxDefs::GUI_InfoDlgState); 126 111 if (dlgsize.isEmpty()) 127 112 { … … 132 117 else 133 118 { 134 QStringList list = dlgsize.split (',');119 QStringList list = dlgsize.split (','); 135 120 mWidth = list [0].toInt(), mHeight = list [1].toInt(); 136 121 mMax = list [2] == "max"; … … 175 160 mLinksMap.clear(); 176 161 177 /* IDE HD statistics: */ 178 for (int i = 0; i < 2; ++ i) 179 for (int j = 0; j < 2; ++ j) 180 { 181 /* Names */ 182 mNamesMap [QString ("/Devices/ATA%1/Unit%2/*DMA") 183 .arg (i).arg (j)] = tr ("DMA Transfers"); 184 mNamesMap [QString ("/Devices/ATA%1/Unit%2/*PIO") 185 .arg (i).arg (j)] = tr ("PIO Transfers"); 186 mNamesMap [QString ("/Devices/ATA%1/Unit%2/ReadBytes") 187 .arg (i).arg (j)] = tr ("Data Read"); 188 mNamesMap [QString ("/Devices/ATA%1/Unit%2/WrittenBytes") 189 .arg (i).arg (j)] = tr ("Data Written"); 190 191 /* Units */ 192 mUnitsMap [QString ("/Devices/ATA%1/Unit%2/*DMA") 193 .arg (i).arg (j)] = "[B]"; 194 mUnitsMap [QString ("/Devices/ATA%1/Unit%2/*PIO") 195 .arg (i).arg (j)] = "[B]"; 196 mUnitsMap [QString ("/Devices/ATA%1/Unit%2/ReadBytes") 197 .arg (i).arg (j)] = "B"; 198 mUnitsMap [QString ("/Devices/ATA%1/Unit%2/WrittenBytes") 199 .arg (i).arg (j)] = "B"; 200 201 /* Belongs to */ 202 mLinksMap [QString ("IDE%1%2").arg (i).arg (j)] = QStringList() 203 << QString ("/Devices/ATA%1/Unit%2/*DMA").arg (i).arg (j) 204 << QString ("/Devices/ATA%1/Unit%2/*PIO").arg (i).arg (j) 205 << QString ("/Devices/ATA%1/Unit%2/ReadBytes").arg (i).arg (j) 206 << QString ("/Devices/ATA%1/Unit%2/WrittenBytes").arg (i).arg (j); 207 } 208 209 /* SATA HD statistics: */ 210 for (int i = 0; i < 30; ++ i) 211 { 212 /* Names */ 213 mNamesMap [QString ("/Devices/SATA/Port%1/DMA").arg (i)] 214 = tr ("DMA Transfers"); 215 mNamesMap [QString ("/Devices/SATA/Port%1/ReadBytes").arg (i)] 216 = tr ("Data Read"); 217 mNamesMap [QString ("/Devices/SATA/Port%1/WrittenBytes").arg (i)] 218 = tr ("Data Written"); 219 220 /* Units */ 221 mUnitsMap [QString ("/Devices/SATA/Port%1/DMA").arg (i)] = "[B]"; 222 mUnitsMap [QString ("/Devices/SATA/Port%1/ReadBytes").arg (i)] = "B"; 223 mUnitsMap [QString ("/Devices/SATA/Port%1/WrittenBytes").arg (i)] = "B"; 224 225 /* Belongs to */ 226 mLinksMap [QString ("SATA%1").arg (i)] = QStringList() 227 << QString ("/Devices/SATA/Port%1/DMA").arg (i) 228 << QString ("/Devices/SATA/Port%1/ReadBytes").arg (i) 229 << QString ("/Devices/SATA/Port%1/WrittenBytes").arg (i); 230 } 231 232 /* SCSI HD statistics: */ 233 for (int i = 0; i < 16; ++ i) 234 { 235 /* Names */ 236 mNamesMap [QString ("/Devices/SCSI/%1/ReadBytes").arg (i)] 237 = tr ("Data Read"); 238 mNamesMap [QString ("/Devices/SCSI/%1/WrittenBytes").arg (i)] 239 = tr ("Data Written"); 240 241 /* Units */ 242 mUnitsMap [QString ("/Devices/SCSI/%1/ReadBytes").arg (i)] = "B"; 243 mUnitsMap [QString ("/Devices/SCSI/%1/WrittenBytes").arg (i)] = "B"; 244 245 /* Belongs to */ 246 mLinksMap [QString ("SCSI%1").arg (i)] = QStringList() 247 << QString ("/Devices/SCSI/%1/ReadBytes").arg (i) 248 << QString ("/Devices/SCSI/%1/WrittenBytes").arg (i); 249 } 250 251 /* Network Adapters statistics: */ 252 ulong count = vboxGlobal().virtualBox() 253 .GetSystemProperties().GetNetworkAdapterCount(); 162 /* Storage statistics */ 163 CSystemProperties sp = vboxGlobal().virtualBox().GetSystemProperties(); 164 CStorageControllerVector controllers = mSession.GetMachine().GetStorageControllers(); 165 int ideCount = 0, sataCount = 0, scsiCount = 0; 166 foreach (const CStorageController &controller, controllers) 167 { 168 switch (controller.GetBus()) 169 { 170 case KStorageBus_IDE: 171 { 172 for (ULONG i = 0; i < sp.GetMaxPortCountForStorageBus (KStorageBus_IDE); ++ i) 173 { 174 for (ULONG j = 0; j < sp.GetMaxDevicesPerPortForStorageBus (KStorageBus_IDE); ++ j) 175 { 176 /* Names */ 177 mNamesMap [QString ("/Devices/IDE%1/ATA%2/Unit%3/*DMA") 178 .arg (ideCount).arg (i).arg (j)] = tr ("DMA Transfers"); 179 mNamesMap [QString ("/Devices/IDE%1/ATA%2/Unit%3/*PIO") 180 .arg (ideCount).arg (i).arg (j)] = tr ("PIO Transfers"); 181 mNamesMap [QString ("/Devices/IDE%1/ATA%2/Unit%3/ReadBytes") 182 .arg (ideCount).arg (i).arg (j)] = tr ("Data Read"); 183 mNamesMap [QString ("/Devices/IDE%1/ATA%2/Unit%3/WrittenBytes") 184 .arg (ideCount).arg (i).arg (j)] = tr ("Data Written"); 185 186 /* Units */ 187 mUnitsMap [QString ("/Devices/IDE%1/ATA%2/Unit%3/*DMA") 188 .arg (ideCount).arg (i).arg (j)] = "[B]"; 189 mUnitsMap [QString ("/Devices/IDE%1/ATA%2/Unit%3/*PIO") 190 .arg (ideCount).arg (i).arg (j)] = "[B]"; 191 mUnitsMap [QString ("/Devices/IDE%1/ATA%2/Unit%3/ReadBytes") 192 .arg (ideCount).arg (i).arg (j)] = "B"; 193 mUnitsMap [QString ("/Devices/IDE%1/ATA%2/Unit%3/WrittenBytes") 194 .arg (ideCount).arg (i).arg (j)] = "B"; 195 196 /* Belongs to */ 197 mLinksMap [QString ("/Devices/IDE%1/ATA%2/Unit%3").arg (ideCount).arg (i).arg (j)] = QStringList() 198 << QString ("/Devices/IDE%1/ATA%2/Unit%3/*DMA").arg (ideCount).arg (i).arg (j) 199 << QString ("/Devices/IDE%1/ATA%2/Unit%3/*PIO").arg (ideCount).arg (i).arg (j) 200 << QString ("/Devices/IDE%1/ATA%2/Unit%3/ReadBytes").arg (ideCount).arg (i).arg (j) 201 << QString ("/Devices/IDE%1/ATA%2/Unit%3/WrittenBytes").arg (ideCount).arg (i).arg (j); 202 } 203 } 204 ++ ideCount; 205 break; 206 } 207 case KStorageBus_SATA: 208 { 209 for (ULONG i = 0; i < sp.GetMaxPortCountForStorageBus (KStorageBus_SATA); ++ i) 210 { 211 for (ULONG j = 0; j < sp.GetMaxDevicesPerPortForStorageBus (KStorageBus_SATA); ++ j) 212 { 213 /* Names */ 214 mNamesMap [QString ("/Devices/SATA%1/Port%2/DMA").arg (sataCount).arg (i)] 215 = tr ("DMA Transfers"); 216 mNamesMap [QString ("/Devices/SATA%1/Port%2/ReadBytes").arg (sataCount).arg (i)] 217 = tr ("Data Read"); 218 mNamesMap [QString ("/Devices/SATA%1/Port%2/WrittenBytes").arg (sataCount).arg (i)] 219 = tr ("Data Written"); 220 221 /* Units */ 222 mUnitsMap [QString ("/Devices/SATA%1/Port%2/DMA").arg (sataCount).arg (i)] = "[B]"; 223 mUnitsMap [QString ("/Devices/SATA%1/Port%2/ReadBytes").arg (sataCount).arg (i)] = "B"; 224 mUnitsMap [QString ("/Devices/SATA%1/Port%2/WrittenBytes").arg (sataCount).arg (i)] = "B"; 225 226 /* Belongs to */ 227 mLinksMap [QString ("/Devices/SATA%1/Port%2").arg (sataCount).arg (i)] = QStringList() 228 << QString ("/Devices/SATA%1/Port%2/DMA").arg (sataCount).arg (i) 229 << QString ("/Devices/SATA%1/Port%2/ReadBytes").arg (sataCount).arg (i) 230 << QString ("/Devices/SATA%1/Port%2/WrittenBytes").arg (sataCount).arg (i); 231 } 232 } 233 ++ sataCount; 234 break; 235 } 236 case KStorageBus_SCSI: 237 { 238 for (ULONG i = 0; i < sp.GetMaxPortCountForStorageBus (KStorageBus_SCSI); ++ i) 239 { 240 for (ULONG j = 0; j < sp.GetMaxDevicesPerPortForStorageBus (KStorageBus_SCSI); ++ j) 241 { 242 /* Names */ 243 mNamesMap [QString ("/Devices/SCSI%1/%2/ReadBytes").arg (scsiCount).arg (i)] 244 = tr ("Data Read"); 245 mNamesMap [QString ("/Devices/SCSI%1/%2/WrittenBytes").arg (scsiCount).arg (i)] 246 = tr ("Data Written"); 247 248 /* Units */ 249 mUnitsMap [QString ("/Devices/SCSI%1/%2/ReadBytes").arg (scsiCount).arg (i)] = "B"; 250 mUnitsMap [QString ("/Devices/SCSI%1/%2/WrittenBytes").arg (scsiCount).arg (i)] = "B"; 251 252 /* Belongs to */ 253 mLinksMap [QString ("/Devices/SCSI%1/%2").arg (scsiCount).arg (i)] = QStringList() 254 << QString ("/Devices/SCSI%1/%2/ReadBytes").arg (scsiCount).arg (i) 255 << QString ("/Devices/SCSI%1/%2/WrittenBytes").arg (scsiCount).arg (i); 256 } 257 } 258 ++ scsiCount; 259 break; 260 } 261 default: 262 break; 263 } 264 } 265 266 /* Network statistics: */ 267 ulong count = vboxGlobal().virtualBox().GetSystemProperties().GetNetworkAdapterCount(); 254 268 for (ulong i = 0; i < count; ++ i) 255 269 { … … 347 361 { 348 362 /* Details page update */ 349 mDetailsText->setText ( 350 vboxGlobal().detailsReport (mSession.GetMachine(), false /* aWithLinks */)); 363 mDetailsText->setText (vboxGlobal().detailsReport (mSession.GetMachine(), false /* aWithLinks */)); 351 364 } 352 365 … … 357 370 358 371 /* Process selected statistics: */ 359 for (DataMapType::const_iterator it = mNamesMap.begin(); 360 it != mNamesMap.end(); ++ it) 372 for (DataMapType::const_iterator it = mNamesMap.begin(); it != mNamesMap.end(); ++ it) 361 373 { 362 374 dbg.GetStats (it.key(), true, info); … … 373 385 mInfoStack->widget (aIndex)->setFocus(); 374 386 } 375 376 /**377 * Opposing to deleteLater() slot this one makes it immediately.378 */379 void VBoxVMInformationDlg::suicide()380 {381 delete this;382 }383 384 387 385 388 QString VBoxVMInformationDlg::parseStatistics (const QString &aText) … … 393 396 394 397 ULONG64 summa = 0; 395 for (QStringList::Iterator lineIt = wholeList.begin(); 396 lineIt != wholeList.end(); ++ lineIt) 398 for (QStringList::Iterator lineIt = wholeList.begin(); lineIt != wholeList.end(); ++ lineIt) 397 399 { 398 400 QString text = *lineIt; … … 435 437 CMachine m = mSession.GetMachine(); 436 438 437 /* Screen & VT-X Runtime Parameters*/439 /* Runtime Information */ 438 440 { 439 441 CConsole console = mSession.GetConsole(); … … 466 468 valuesList << resolution << virtualization << nested << addVerisonStr << osType; 467 469 int maxLength = 0; 468 foreach ( QStringvalue, valuesList)470 foreach (const QString &value, valuesList) 469 471 maxLength = maxLength < fontMetrics().width (value) ? 470 472 fontMetrics().width (value) : maxLength; … … 479 481 } 480 482 481 /* Hard Disk Statistics */ 482 { 483 QString hdStat; 484 const QString ideCtl = QString("IDE Controller"); 485 const QString sataCtl = QString("SATA"); 486 487 result += hdrRow.arg (":/hd_16px.png").arg (tr ("Hard Disk Statistics")); 488 489 /* IDE Hard Disk (Primary Master) */ 490 if (!m.GetMedium(ideCtl, 0, 0).isNull()) 491 { 492 hdStat += formatHardDisk (ideCtl, 0, 0, "IDE00"); 493 hdStat += paragraph; 494 } 495 496 /* IDE Hard Disk (Primary Slave) */ 497 if (!m.GetMedium(ideCtl, 0, 1).isNull()) 498 { 499 hdStat += formatHardDisk (ideCtl, 0, 1, "IDE01"); 500 hdStat += paragraph; 501 } 502 503 /* IDE Hard Disk (Secondary Slave) */ 504 if (!m.GetMedium(ideCtl, 1, 1).isNull()) 505 { 506 hdStat += formatHardDisk (ideCtl, 1, 1, "IDE11"); 507 hdStat += paragraph; 508 } 509 510 /* SATA Hard Disks */ 511 for (int i = 0; i < 30; ++ i) 512 { 513 if (!m.GetMedium(sataCtl, i, 0).isNull()) 483 /* Storage statistics */ 484 { 485 QString storageStat; 486 487 result += hdrRow.arg (":/attachment_16px.png").arg (tr ("Storage Statistics")); 488 489 CStorageControllerVector controllers = mSession.GetMachine().GetStorageControllers(); 490 int ideCount = 0, sataCount = 0, scsiCount = 0; 491 foreach (const CStorageController &controller, controllers) 492 { 493 QString ctrName = controller.GetName(); 494 KStorageBus busType = controller.GetBus(); 495 CMediumAttachmentVector attachments = mSession.GetMachine().GetMediumAttachmentsOfController (ctrName); 496 if (!attachments.isEmpty() && busType != KStorageBus_Floppy) 514 497 { 515 hdStat += formatHardDisk (sataCtl, i, 0, 516 QString ("SATA%1").arg (i)); 517 hdStat += paragraph; 518 } 519 } 520 521 /* @todo Rework if more than one additional 522 * controller is allowed. 523 */ 524 const QString scsiCtl = QString("SCSI"); 525 526 if (!m.GetStorageControllerByName(scsiCtl).isNull()) 527 { 528 /* SCSI Hard Disks */ 529 for (int i = 0; i < 16; ++ i) 530 { 531 if (!m.GetMedium(scsiCtl, i, 0).isNull()) 498 QString header = "<tr><td></td><td colspan=2><nobr><u>%1</u></nobr></td></tr>"; 499 storageStat += header.arg (ctrName); 500 int scsiIndex = 0; 501 foreach (const CMediumAttachment &attachment, attachments) 532 502 { 533 hdStat += formatHardDisk (scsiCtl, i, 0, 534 QString ("SCSI%1").arg (i)); 535 hdStat += paragraph; 503 LONG attPort = attachment.GetPort(); 504 LONG attDevice = attachment.GetDevice(); 505 switch (busType) 506 { 507 case KStorageBus_IDE: 508 { 509 storageStat += formatMedium (ctrName, attPort, attDevice, 510 QString ("/Devices/IDE%1/ATA%2/Unit%3").arg (ideCount).arg (attPort).arg (attDevice)); 511 break; 512 } 513 case KStorageBus_SATA: 514 { 515 storageStat += formatMedium (ctrName, attPort, attDevice, 516 QString ("/Devices/SATA%1/Port%2").arg (sataCount).arg (attPort)); 517 break; 518 } 519 case KStorageBus_SCSI: 520 { 521 storageStat += formatMedium (ctrName, attPort, attDevice, 522 QString ("/Devices/SCSI%1/%2").arg (scsiCount).arg (scsiIndex)); 523 ++ scsiIndex; 524 break; 525 } 526 default: 527 break; 528 } 529 storageStat += paragraph; 536 530 } 537 531 } 532 533 switch (busType) 534 { 535 case KStorageBus_IDE: 536 { 537 ++ ideCount; 538 break; 539 } 540 case KStorageBus_SATA: 541 { 542 ++ sataCount; 543 break; 544 } 545 case KStorageBus_SCSI: 546 { 547 ++ scsiCount; 548 break; 549 } 550 default: 551 break; 552 } 538 553 } 539 554 540 555 /* If there are no Hard Disks */ 541 if (hdStat.isNull()) 542 { 543 hdStat = composeArticle (tr ("No Hard Disks")); 544 hdStat += paragraph; 545 } 546 547 result += hdStat; 548 549 /* CD/DVD-ROM (Secondary Master) */ 550 result += hdrRow.arg (":/cd_16px.png").arg (tr ("CD/DVD-ROM Statistics")); 551 result += formatHardDisk (ideCtl, 1, 0, "IDE10"); 552 result += paragraph; 556 if (storageStat.isNull()) 557 { 558 storageStat = composeArticle (tr ("No Storage Devices")); 559 storageStat += paragraph; 560 } 561 562 result += storageStat; 553 563 } 554 564 555 565 /* Network Adapters Statistics */ 556 566 { 557 QString naStat; 558 559 result += hdrRow.arg (":/nw_16px.png") 560 .arg (tr ("Network Adapter Statistics")); 567 QString networkStat; 568 569 result += hdrRow.arg (":/nw_16px.png").arg (tr ("Network Statistics")); 561 570 562 571 /* Network Adapters list */ 563 ulong count = vboxGlobal().virtualBox() 564 .GetSystemProperties().GetNetworkAdapterCount(); 572 ulong count = vboxGlobal().virtualBox().GetSystemProperties().GetNetworkAdapterCount(); 565 573 for (ulong slot = 0; slot < count; ++ slot) 566 574 { 567 575 if (m.GetNetworkAdapter (slot).GetEnabled()) 568 576 { 569 n aStat += formatAdapter (slot, QString ("NA%1").arg (slot));570 n aStat += paragraph;577 networkStat += formatAdapter (slot, QString ("NA%1").arg (slot)); 578 networkStat += paragraph; 571 579 } 572 580 } 573 581 574 582 /* If there are no Network Adapters */ 575 if (n aStat.isNull())576 { 577 n aStat = composeArticle (tr ("No Network Adapters"));578 n aStat += paragraph;579 } 580 581 result += n aStat;583 if (networkStat.isNull()) 584 { 585 networkStat = composeArticle (tr ("No Network Adapters")); 586 networkStat += paragraph; 587 } 588 589 result += networkStat; 582 590 } 583 591 … … 606 614 } 607 615 608 QString VBoxVMInformationDlg::formatHardDisk (const QString &ctlName, 609 LONG aChannel, 610 LONG aDevice, 611 const QString &aBelongsTo) 616 QString VBoxVMInformationDlg::formatMedium (const QString &aCtrName, 617 LONG aPort, LONG aDevice, 618 const QString &aBelongsTo) 612 619 { 613 620 if (mSession.isNull()) 614 621 return QString::null; 615 622 616 CStorageController ctl = mSession.GetMachine().GetStorageControllerByName (ctlName); 617 618 CMedium hd = mSession.GetMachine().GetMedium (ctlName, aChannel, aDevice); 619 QString header = "<tr><td></td><td colspan=2><nobr><u>%1</u></nobr></td></tr>"; 620 QString name = vboxGlobal().toString (StorageSlot (ctl.GetBus(), aChannel, aDevice)); 621 QString result = hd.isNull() ? QString::null : header.arg (name); 622 result += composeArticle (aBelongsTo); 623 return result; 623 QString header = "<tr><td></td><td colspan=2><nobr> %1:</nobr></td></tr>"; 624 CStorageController ctr = mSession.GetMachine().GetStorageControllerByName (aCtrName); 625 QString name = vboxGlobal().toString (StorageSlot (ctr.GetBus(), aPort, aDevice)); 626 return header.arg (name) + composeArticle (aBelongsTo, 2); 624 627 } 625 628 … … 632 635 QString header = "<tr><td></td><td colspan=2><nobr><u>%1</u></nobr></td></tr>"; 633 636 QString name = VBoxGlobal::tr ("Adapter %1", "details report (network)").arg (aSlot + 1); 634 QString result = header.arg (name); 635 result += composeArticle (aBelongsTo); 636 return result; 637 } 638 639 QString VBoxVMInformationDlg::composeArticle (const QString &aBelongsTo) 640 { 641 QString body = "<tr><td></td><td width=50%><nobr>%1</nobr></td>" 642 "<td align=right><nobr>%2%3</nobr></td></tr>"; 637 return header.arg (name) + composeArticle (aBelongsTo, 1); 638 } 639 640 QString VBoxVMInformationDlg::composeArticle (const QString &aBelongsTo, int aSpacesCount) 641 { 642 QString body = "<tr><td></td><td width=50%><nobr>%1%2</nobr></td>" 643 "<td align=right><nobr>%3%4</nobr></td></tr>"; 644 QString indent; 645 for (int i = 0; i < aSpacesCount; ++ i) 646 indent += " "; 647 body = body.arg (indent); 648 643 649 QString result; 644 650 645 651 if (mLinksMap.contains (aBelongsTo)) 646 652 { 647 QStringList key List= mLinksMap [aBelongsTo];648 for (QStringList::Iterator it = keyList.begin(); it != keyList.end(); ++ it)653 QStringList keys = mLinksMap [aBelongsTo]; 654 foreach (const QString &key, keys) 649 655 { 650 656 QString line (body); 651 QString key = *it; 652 if (mNamesMap.contains (key) && 653 mValuesMap.contains (key) && 654 mUnitsMap.contains (key)) 657 if (mNamesMap.contains (key) && mValuesMap.contains (key) && mUnitsMap.contains (key)) 655 658 { 656 line = line.arg (mNamesMap [key]) 657 .arg (QString ("%L1") 658 .arg (mValuesMap [key].toULongLong())); 659 line = line.arg (mNamesMap [key]).arg (QString ("%L1").arg (mValuesMap [key].toULongLong())); 659 660 line = mUnitsMap [key].contains (QRegExp ("\\[\\S+\\]")) ? 660 661 line.arg (QString ("<img src=:/tpixel.png width=%1 height=1>")
Note:
See TracChangeset
for help on using the changeset viewer.