VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/ui/VBoxVMInformationDlg.ui.h@ 10621

Last change on this file since 10621 was 9364, checked in by vboxsync, 17 years ago

FE/Qt: Fixed: Guest OS Type was shown as an ID in the session information dialog instead of a human readable string.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Revision Author Id
File size: 23.8 KB
Line 
1/**
2 *
3 * VBox frontends: Qt GUI ("VirtualBox"):
4 * "VirtualBox Information Dialog" dialog UI include (Qt Designer)
5 */
6
7/*
8 * Copyright (C) 2006 Sun Microsystems, Inc.
9 *
10 * This file is part of VirtualBox Open Source Edition (OSE), as
11 * available from http://www.virtualbox.org. This file is free software;
12 * you can redistribute it and/or modify it under the terms of the GNU
13 * General Public License (GPL) as published by the Free Software
14 * Foundation, in version 2 as it comes in the "COPYING" file of the
15 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
16 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
17 *
18 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
19 * Clara, CA 95054 USA or visit http://www.sun.com if you need
20 * additional information or have any questions.
21 */
22
23/****************************************************************************
24** ui.h extension file, included from the uic-generated form implementation.
25**
26** If you wish to add, delete or rename functions or slots use
27** Qt Designer which will update this file, preserving your code. Create an
28** init() function in place of a constructor, and a destroy() function in
29** place of a destructor.
30*****************************************************************************/
31
32
33VBoxVMInformationDlg::InfoDlgMap VBoxVMInformationDlg::mSelfArray = InfoDlgMap();
34
35void VBoxVMInformationDlg::createInformationDlg (const CSession &aSession,
36 VBoxConsoleView *aConsole)
37{
38 CMachine machine = aSession.GetMachine();
39 if (mSelfArray.find (machine.GetName()) == mSelfArray.end())
40 {
41 /* creating new information dialog if there is no one existing */
42 mSelfArray [machine.GetName()] = new VBoxVMInformationDlg (
43 aConsole, "VBoxVMInformationDlg", WType_TopLevel | WDestructiveClose);
44 /* read new machine data for this information dialog */
45 mSelfArray [machine.GetName()]->setup (aSession, aConsole);
46 }
47
48 VBoxVMInformationDlg *info = mSelfArray [machine.GetName()];
49 info->show();
50 info->raise();
51 info->setWindowState (info->windowState() & ~WindowMinimized);
52 info->setActiveWindow();
53}
54
55
56void VBoxVMInformationDlg::init()
57{
58 /* dialog initially is not polished */
59 mIsPolished = false;
60
61 /* search the default button */
62 mDefaultButton = searchDefaultButton();
63 qApp->installEventFilter (this);
64
65 /* setup a dialog icon */
66 setIcon (QPixmap::fromMimeSource ("description_16px.png"));
67
68 /* statusbar initially disabled */
69 statusBar()->setHidden (true);
70
71 /* setup size grip */
72 mSizeGrip = new QSizeGrip (centralWidget(), "mSizeGrip");
73 mSizeGrip->resize (mSizeGrip->sizeHint());
74 mSizeGrip->stackUnder (mCloseButton);
75
76 /* logs list creation */
77 mInfoStack = new QTabWidget (mInfoFrame, "mInfoStack");
78 mInfoStack->setMargin (10);
79 QVBoxLayout *infoFrameLayout = new QVBoxLayout (mInfoFrame);
80 infoFrameLayout->addWidget (mInfoStack);
81
82 /* details view creation */
83 mDetailsText = new QTextBrowser();
84 mDetailsText->setFrameShape (QFrame::NoFrame);
85 mDetailsText->setPaper (backgroundBrush());
86 mInfoStack->addTab (mDetailsText,
87 VBoxGlobal::iconSet ("settings_16px.png"),
88 QString::null);
89
90 /* statistic view creation */
91 mStatisticText = new QTextBrowser();
92 mStatisticText->setFrameShape (QFrame::NoFrame);
93 mStatisticText->setPaper (backgroundBrush());
94 mInfoStack->addTab (mStatisticText,
95 VBoxGlobal::iconSet ("state_running_16px.png"),
96 QString::null);
97
98 /* full list of statistics counters to get total info */
99 // mDefStatText = new QTextBrowser();
100 // mDefStatText->setFrameShape (QFrame::NoFrame);
101 // mDefStatText->setPaper (backgroundBrush());
102 // mInfoStack->addTab (mDefStatText,
103 // VBoxGlobal::iconSet ("show_logs_16px.png"),
104 // QString::null);
105
106 /* show statistics page and make it focused */
107 connect (mInfoStack, SIGNAL (currentChanged (QWidget*)),
108 this, SLOT (onPageChanged (QWidget*)));
109 mInfoStack->showPage (mStatisticText);
110}
111
112
113void VBoxVMInformationDlg::destroy()
114{
115 /* save dialog attributes for this vm */
116 QString dlgsize ("%1,%2,%3");
117 mSession.GetMachine().SetExtraData (VBoxDefs::GUI_InfoDlgState,
118 dlgsize.arg (mWidth).arg (mHeight).arg (isMaximized() ? "max" : "normal"));
119
120 if (!mSession.isNull() && !mSession.GetMachine().isNull())
121 mSelfArray.erase (mSession.GetMachine().GetName());
122}
123
124
125void VBoxVMInformationDlg::setup (const CSession &aSession,
126 VBoxConsoleView *aConsole)
127{
128 /* store related machine pointers */
129 mSession = aSession;
130 mConsole = aConsole;
131
132 /* loading language constants */
133 languageChangeImp();
134
135 /* details page update */
136 updateDetails();
137
138 /* statistics page update */
139 processStatistics();
140 mStatTimer.start (5000);
141
142 /* setup handlers */
143 connect (&vboxGlobal(), SIGNAL (mediaEnumFinished (const VBoxMediaList &)),
144 this, SLOT (updateDetails()));
145 connect (mConsole, SIGNAL (mediaChanged (VBoxDefs::DiskType)),
146 this, SLOT (updateDetails()));
147 connect (mConsole, SIGNAL (sharedFoldersChanged()),
148 this, SLOT (updateDetails()));
149
150 connect (&mStatTimer, SIGNAL (timeout()), this, SLOT (processStatistics()));
151 connect (mConsole, SIGNAL (resizeHintDone()), this, SLOT (processStatistics()));
152
153 /* preload dialog attributes for this vm */
154 QString dlgsize = mSession.GetMachine().GetExtraData (VBoxDefs::GUI_InfoDlgState);
155 if (dlgsize.isNull())
156 {
157 mWidth = 400;
158 mHeight = 450;
159 mMax = false;
160 }
161 else
162 {
163 QStringList list = QStringList::split (',', dlgsize);
164 mWidth = list [0].toInt(), mHeight = list [1].toInt();
165 mMax = list [2] == "max";
166 }
167}
168
169
170void VBoxVMInformationDlg::languageChangeImp()
171{
172 AssertReturnVoid (!mSession.isNull());
173
174 CMachine machine = mSession.GetMachine();
175 AssertReturnVoid (!machine.isNull());
176
177 /* Setup a dialog caption. */
178 setCaption (tr ("%1 - Session Information").arg (machine.GetName()));
179
180 /* Setup a tabwidget page names. */
181 mInfoStack->changeTab (mDetailsText, tr ("&Details"));
182 mInfoStack->changeTab (mStatisticText, tr ("&Runtime"));
183 // mInfoStack->changeTab (mDefStatText, tr ("De&fault Stat"));
184
185 /* Clear counter names initially. */
186 mNamesMap.clear();
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)
249 {
250 CNetworkAdapter na = machine.GetNetworkAdapter (i);
251 KNetworkAdapterType ty = na.GetAdapterType();
252 const char *name;
253
254 switch (ty)
255 {
256 case KNetworkAdapterType_I82540EM:
257 case KNetworkAdapterType_I82543GC:
258 name = "E1k";
259 break;
260 default:
261 name = "PCNet";
262 break;
263 }
264
265 /* Names */
266 mNamesMap [QString ("/Devices/%1%2/TransmitBytes")
267 .arg (name).arg (i)] = tr ("Data Transmitted");
268 mNamesMap [QString ("/Devices/%1%2/ReceiveBytes")
269 .arg (name).arg (i)] = tr ("Data Received");
270
271 /* Units */
272 mUnitsMap [QString ("/Devices/%1%2/TransmitBytes")
273 .arg (name).arg (i)] = "B";
274 mUnitsMap [QString ("/Devices/%1%2/ReceiveBytes")
275 .arg (name).arg (i)] = "B";
276
277 /* Belongs to */
278 mLinksMap [QString ("NA%1").arg (i)] = QStringList()
279 << QString ("/Devices/%1%2/TransmitBytes").arg (name).arg (i)
280 << QString ("/Devices/%1%2/ReceiveBytes").arg (name).arg (i);
281 }
282
283 /* Statistics page update. */
284 refreshStatistics();
285}
286
287
288QPushButton* VBoxVMInformationDlg::searchDefaultButton()
289{
290 /* this mechanism is used for searching the default dialog button
291 * and similar the same mechanism in Qt::QDialog inner source */
292 QPushButton *button = 0;
293 QObjectList *list = queryList ("QPushButton");
294 QObjectListIt it (*list);
295 while ((button = (QPushButton*)it.current()) && !button->isDefault())
296 ++ it;
297 return button;
298}
299
300
301bool VBoxVMInformationDlg::eventFilter (QObject *aObject, QEvent *aEvent)
302{
303 switch (aEvent->type())
304 {
305 /* auto-default button focus-in processor used to move the "default"
306 * button property into the currently focused button */
307 case QEvent::FocusIn:
308 {
309 if (aObject->inherits ("QPushButton") &&
310 aObject->parent() == centralWidget())
311 {
312 ((QPushButton*)aObject)->setDefault (aObject != mDefaultButton);
313 if (mDefaultButton)
314 mDefaultButton->setDefault (aObject == mDefaultButton);
315 }
316 break;
317 }
318 /* auto-default button focus-out processor used to remove the "default"
319 * button property from the previously focused button */
320 case QEvent::FocusOut:
321 {
322 if (aObject->inherits ("QPushButton") &&
323 aObject->parent() == centralWidget())
324 {
325 if (mDefaultButton)
326 mDefaultButton->setDefault (aObject != mDefaultButton);
327 ((QPushButton*)aObject)->setDefault (aObject == mDefaultButton);
328 }
329 break;
330 }
331 default:
332 break;
333 }
334 return QMainWindow::eventFilter (aObject, aEvent);
335}
336
337
338bool VBoxVMInformationDlg::event (QEvent *aEvent)
339{
340 bool result = QMainWindow::event (aEvent);
341 switch (aEvent->type())
342 {
343 case QEvent::LanguageChange:
344 {
345 if (!mSession.isNull())
346 languageChangeImp();
347 break;
348 }
349 case QEvent::WindowStateChange:
350 {
351 if (mIsPolished)
352 mMax = isMaximized();
353 else if (mMax == isMaximized())
354 mIsPolished = true;
355 break;
356 }
357 default:
358 break;
359 }
360 return result;
361}
362
363
364void VBoxVMInformationDlg::keyPressEvent (QKeyEvent *aEvent)
365{
366 if (aEvent->state() == 0 ||
367 (aEvent->state() & Keypad && aEvent->key() == Key_Enter))
368 {
369 switch (aEvent->key())
370 {
371 /* processing the return keypress for the auto-default button */
372 case Key_Enter:
373 case Key_Return:
374 {
375 QPushButton *currentDefault = searchDefaultButton();
376 if (currentDefault)
377 currentDefault->animateClick();
378 break;
379 }
380 /* processing the escape keypress as the close dialog action */
381 case Key_Escape:
382 {
383 close();
384 break;
385 }
386 }
387 }
388 else
389 aEvent->ignore();
390}
391
392
393void VBoxVMInformationDlg::showEvent (QShowEvent *aEvent)
394{
395 QMainWindow::showEvent (aEvent);
396
397 /* one may think that QWidget::polish() is the right place to do things
398 * below, but apparently, by the time when QWidget::polish() is called,
399 * the widget style & layout are not fully done, at least the minimum
400 * size hint is not properly calculated. Since this is sometimes necessary,
401 * we provide our own "polish" implementation. */
402
403 if (mIsPolished)
404 return;
405
406 /* load window size and state */
407 resize (mWidth, mHeight);
408 if (mMax)
409 QTimer::singleShot (0, this, SLOT (showMaximized()));
410 else
411 mIsPolished = true;
412
413 VBoxGlobal::centerWidget (this, parentWidget());
414}
415
416
417void VBoxVMInformationDlg::resizeEvent (QResizeEvent*)
418{
419 /* adjust the size-grip location for the current resize event */
420 mSizeGrip->move (centralWidget()->rect().bottomRight() -
421 QPoint (mSizeGrip->rect().width() - 1,
422 mSizeGrip->rect().height() - 1));
423
424 /* store dialog size for this vm */
425 if (mIsPolished && !isMaximized())
426 {
427 mWidth = width();
428 mHeight = height();
429 }
430}
431
432
433void VBoxVMInformationDlg::updateDetails()
434{
435 /* details page update */
436 mDetailsText->setText (
437 vboxGlobal().detailsReport (mSession.GetMachine(), false /* isNewVM */,
438 false /* withLinks */, false /* refresh */));
439}
440
441
442void VBoxVMInformationDlg::onPageChanged (QWidget *aPage)
443{
444 /* focusing the browser on shown page */
445 aPage->setFocus();
446}
447
448
449void VBoxVMInformationDlg::processStatistics()
450{
451 CMachineDebugger dbg = mSession.GetConsole().GetDebugger();
452 QString info;
453
454 /* Look for all statistics for filtering purposes. */
455 // dbg.GetStats ("*", false, info);
456 // mDefStatText->setText (info);
457
458 /* Process selected statistics: */
459 for (DataMapType::const_iterator it = mNamesMap.begin();
460 it != mNamesMap.end(); ++ it)
461 {
462 dbg.GetStats (it.key(), true, info);
463 mValuesMap [it.key()] = parseStatistics (info);
464 }
465
466 /* Statistics page update. */
467 refreshStatistics();
468}
469
470
471QString VBoxVMInformationDlg::parseStatistics (const QString &aText)
472{
473 /* Filters the statistic counters body. */
474 QRegExp query ("^.+<Statistics>\n(.+)\n</Statistics>.*$");
475 if (query.search (aText) == -1)
476 return QString::null;
477
478 QStringList wholeList = QStringList::split ("\n", query.cap (1));
479
480 ULONG64 summa = 0;
481 for (QStringList::Iterator lineIt = wholeList.begin();
482 lineIt != wholeList.end(); ++ lineIt)
483 {
484 QString text = *lineIt;
485 text.remove (1, 1);
486 text.remove (text.length() - 2, 2);
487
488 /* Parse incoming counter and fill the counter-element values. */
489 CounterElementType counter;
490 counter.type = text.section (" ", 0, 0);
491 text = text.section (" ", 1);
492 QStringList list = QStringList::split ("\" ", text);
493 for (QStringList::Iterator it = list.begin(); it != list.end(); ++ it)
494 {
495 QString pair = *it;
496 QRegExp regExp ("^(.+)=\"([^\"]*)\"?$");
497 regExp.search (pair);
498 counter.list.insert (regExp.cap (1), regExp.cap (2));
499 }
500
501 /* Fill the output with the necessary counter's value.
502 * Currently we are using "c" field of simple counter only. */
503 QString result = counter.list.contains ("c") ? counter.list ["c"] : "0";
504 summa += result.toULongLong();
505 }
506
507 return QString::number (summa);
508}
509
510
511void VBoxVMInformationDlg::refreshStatistics()
512{
513 if (mSession.isNull())
514 return;
515
516 QString table = "<p><table border=0 cellspacing=0 cellpadding=0 width=100%>%1</table></p>";
517 QString hdrRow = "<tr><td align=left><img src='%1'></td><td colspan=3><b>%2</b></td></tr>";
518 QString bdyRow = "<tr><td></td><td><nobr>%1</nobr></td><td colspan=2><nobr>%2</nobr></td></tr>";
519 QString paragraph = "<tr><td colspan=4></td></tr>";
520 QString result;
521
522 CMachine m = mSession.GetMachine();
523
524 /* Screen & VT-X Runtime Parameters */
525 {
526 CConsole console = mSession.GetConsole();
527 ULONG bpp = console.GetDisplay().GetBitsPerPixel();
528 QString resolution = QString ("%1x%2")
529 .arg (console.GetDisplay().GetWidth())
530 .arg (console.GetDisplay().GetHeight());
531 if (bpp)
532 resolution += QString ("x%1").arg (bpp);
533 QString virt = console.GetDebugger().GetHWVirtExEnabled() ?
534 VBoxGlobal::tr ("Enabled", "details report (VT-x/AMD-V)") :
535 VBoxGlobal::tr ("Disabled", "details report (VT-x/AMD-V)");
536 QString addInfo = console.GetGuest().GetAdditionsVersion();
537 uint addVersion = addInfo.toUInt();
538 QString addVerisonStr = !addInfo.isNull() ?
539 tr ("Version %1.%2", "guest additions")
540 .arg (RT_HIWORD (addVersion)).arg (RT_LOWORD (addVersion)) :
541 tr ("Not Detected", "guest additions");
542 QString osType = console.GetGuest().GetOSTypeId();
543 if (osType.isNull())
544 osType = tr ("Not Detected", "guest os type");
545 else
546 osType = vboxGlobal().vmGuestOSTypeDescription (osType);
547
548 result += hdrRow.arg ("state_running_16px.png").arg (tr ("Runtime Attributes"));
549 result += bdyRow.arg (tr ("Screen Resolution")).arg (resolution) +
550 bdyRow.arg (VBoxGlobal::tr ("VT-x/AMD-V", "details report")).arg (virt);
551 result += bdyRow.arg (tr ("Guest Additions")).arg (addVerisonStr);
552 result += bdyRow.arg (tr ("Guest OS Type")).arg (osType);
553 result += paragraph;
554 }
555
556 /* Hard Disk Statistics. */
557 {
558 QString hdStat;
559
560 result += hdrRow.arg ("hd_16px.png").arg (tr ("Hard Disk Statistics"));
561
562 /* IDE Hard Disk (Primary Master) */
563 if (!m.GetHardDisk (KStorageBus_IDE, 0, 0).isNull())
564 {
565 hdStat += formatHardDisk (KStorageBus_IDE, 0, 0, "IDE00");
566 hdStat += paragraph;
567 }
568
569 /* IDE Hard Disk (Primary Slave) */
570 if (!m.GetHardDisk (KStorageBus_IDE, 0, 1).isNull())
571 {
572 hdStat += formatHardDisk (KStorageBus_IDE, 0, 1, "IDE01");
573 hdStat += paragraph;
574 }
575
576 /* IDE Hard Disk (Secondary Slave) */
577 if (!m.GetHardDisk (KStorageBus_IDE, 1, 1).isNull())
578 {
579 hdStat += formatHardDisk (KStorageBus_IDE, 1, 1, "IDE11");
580 hdStat += paragraph;
581 }
582
583 /* SATA Hard Disks */
584 for (int i = 0; i < 30; ++ i)
585 {
586 if (!m.GetHardDisk (KStorageBus_SATA, i, 0).isNull())
587 {
588 hdStat += formatHardDisk (KStorageBus_SATA, i, 0,
589 QString ("SATA%1").arg (i));
590 hdStat += paragraph;
591 }
592 }
593
594 /* If there are no Hard Disks */
595 if (hdStat.isNull())
596 {
597 hdStat = composeArticle (tr ("No Hard Disks"));
598 hdStat += paragraph;
599 }
600
601 result += hdStat;
602
603 /* CD/DVD-ROM (Secondary Master) */
604 result += hdrRow.arg ("cd_16px.png").arg (tr ("CD/DVD-ROM Statistics"));
605 result += formatHardDisk (KStorageBus_IDE, 1, 0, "IDE10");
606 result += paragraph;
607 }
608
609 /* Network Adapters Statistics. */
610 {
611 QString naStat;
612
613 result += hdrRow.arg ("nw_16px.png")
614 .arg (tr ("Network Adapter Statistics"));
615
616 /* Network Adapters list */
617 ulong count = vboxGlobal().virtualBox()
618 .GetSystemProperties().GetNetworkAdapterCount();
619 for (ulong slot = 0; slot < count; ++ slot)
620 {
621 if (m.GetNetworkAdapter (slot).GetEnabled())
622 {
623 naStat += formatAdapter (slot, QString ("NA%1").arg (slot));
624 naStat += paragraph;
625 }
626 }
627
628 /* If there are no Network Adapters */
629 if (naStat.isNull())
630 {
631 naStat = composeArticle (tr ("No Network Adapters"));
632 naStat += paragraph;
633 }
634
635 result += naStat;
636 }
637
638 /* Show full composed page. */
639 mStatisticText->setText (table.arg (result));
640}
641
642
643QString VBoxVMInformationDlg::formatHardDisk (KStorageBus aBus,
644 LONG aChannel,
645 LONG aDevice,
646 const QString &aBelongsTo)
647{
648 if (mSession.isNull())
649 return QString::null;
650
651 CHardDisk hd = mSession.GetMachine().GetHardDisk (aBus, aChannel, aDevice);
652 QString header = "<tr><td></td><td colspan=3><nobr><u>%1</u></nobr></td></tr>";
653 QString name = vboxGlobal().toFullString (aBus, aChannel, aDevice);
654 QString result = hd.isNull() ? QString::null : header.arg (name);
655 result += composeArticle (aBelongsTo);
656 return result;
657}
658
659QString VBoxVMInformationDlg::formatAdapter (ULONG aSlot,
660 const QString &aBelongsTo)
661
662{
663 if (mSession.isNull())
664 return QString::null;
665
666 QString header = "<tr><td></td><td colspan=3><nobr><u>%1</u></nobr></td></tr>";
667 QString name = VBoxGlobal::tr ("Adapter %1", "details report (network)").arg (aSlot);
668 QString result = header.arg (name);
669 result += composeArticle (aBelongsTo);
670 return result;
671}
672
673
674QString VBoxVMInformationDlg::composeArticle (const QString &aBelongsTo)
675{
676 QString body = "<tr><td></td><td><nobr>%1</nobr></td><td align=right>"
677 "<nobr>%2%3</nobr></td><td width=100%></td></tr>";
678 QString result;
679
680 if (mLinksMap.contains (aBelongsTo))
681 {
682 QStringList keyList = mLinksMap [aBelongsTo];
683 for (QStringList::Iterator it = keyList.begin(); it != keyList.end(); ++ it)
684 {
685 QString line (body);
686 QString key = *it;
687 if (mNamesMap.contains (key) &&
688 mValuesMap.contains (key) &&
689 mUnitsMap.contains (key))
690 {
691 line = line.arg (mNamesMap [key])
692 .arg (QString ("%L1")
693 .arg (mValuesMap [key].toULongLong()));
694 line = mUnitsMap [key].contains (QRegExp ("\\[\\S+\\]")) ?
695 line.arg (QString ("<img src=tpixel.png width=%1 height=1>")
696 .arg (QApplication::fontMetrics().width (
697 QString (" %1").arg (mUnitsMap [key]
698 .mid (1, mUnitsMap [key].length() - 2))))) :
699 line.arg (QString (" %1").arg (mUnitsMap [key]));
700 result += line;
701 }
702 }
703 }
704 else
705 result = body.arg (aBelongsTo).arg (QString::null).arg (QString::null);
706
707 return result;
708}
709
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette