VirtualBox

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

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

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