VirtualBox

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

最後變更 在這個檔案從8778是 8718,由 vboxsync 提交於 17 年 前

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.
  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Date Revision Author Id
檔案大小: 27.9 KB
 
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.alldomusa.eu.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 name = "E1k";
258 break;
259 default:
260 name = "PCNet";
261 break;
262 }
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);
280 }
281
282 /* Statistics page update. */
283 refreshStatistics();
284}
285
286
287QPushButton* VBoxVMInformationDlg::searchDefaultButton()
288{
289 /* this mechanism is used for searching the default dialog button
290 * and similar the same mechanism in Qt::QDialog inner source */
291 QPushButton *button = 0;
292 QObjectList *list = queryList ("QPushButton");
293 QObjectListIt it (*list);
294 while ((button = (QPushButton*)it.current()) && !button->isDefault())
295 ++ it;
296 return button;
297}
298
299
300bool VBoxVMInformationDlg::eventFilter (QObject *aObject, QEvent *aEvent)
301{
302 switch (aEvent->type())
303 {
304 /* auto-default button focus-in processor used to move the "default"
305 * button property into the currently focused button */
306 case QEvent::FocusIn:
307 {
308 if (aObject->inherits ("QPushButton") &&
309 aObject->parent() == centralWidget())
310 {
311 ((QPushButton*)aObject)->setDefault (aObject != mDefaultButton);
312 if (mDefaultButton)
313 mDefaultButton->setDefault (aObject == mDefaultButton);
314 }
315 break;
316 }
317 /* auto-default button focus-out processor used to remove the "default"
318 * button property from the previously focused button */
319 case QEvent::FocusOut:
320 {
321 if (aObject->inherits ("QPushButton") &&
322 aObject->parent() == centralWidget())
323 {
324 if (mDefaultButton)
325 mDefaultButton->setDefault (aObject != mDefaultButton);
326 ((QPushButton*)aObject)->setDefault (aObject == mDefaultButton);
327 }
328 break;
329 }
330 default:
331 break;
332 }
333 return QMainWindow::eventFilter (aObject, aEvent);
334}
335
336
337bool VBoxVMInformationDlg::event (QEvent *aEvent)
338{
339 bool result = QMainWindow::event (aEvent);
340 switch (aEvent->type())
341 {
342 case QEvent::LanguageChange:
343 {
344 if (!mSession.isNull())
345 languageChangeImp();
346 break;
347 }
348 case QEvent::WindowStateChange:
349 {
350 if (mIsPolished)
351 mMax = isMaximized();
352 else if (mMax == isMaximized())
353 mIsPolished = true;
354 break;
355 }
356 default:
357 break;
358 }
359 return result;
360}
361
362
363void VBoxVMInformationDlg::keyPressEvent (QKeyEvent *aEvent)
364{
365 if (aEvent->state() == 0 ||
366 (aEvent->state() & Keypad && aEvent->key() == Key_Enter))
367 {
368 switch (aEvent->key())
369 {
370 /* processing the return keypress for the auto-default button */
371 case Key_Enter:
372 case Key_Return:
373 {
374 QPushButton *currentDefault = searchDefaultButton();
375 if (currentDefault)
376 currentDefault->animateClick();
377 break;
378 }
379 /* processing the escape keypress as the close dialog action */
380 case Key_Escape:
381 {
382 close();
383 break;
384 }
385 }
386 }
387 else
388 aEvent->ignore();
389}
390
391
392void VBoxVMInformationDlg::showEvent (QShowEvent *aEvent)
393{
394 QMainWindow::showEvent (aEvent);
395
396 /* one may think that QWidget::polish() is the right place to do things
397 * below, but apparently, by the time when QWidget::polish() is called,
398 * the widget style & layout are not fully done, at least the minimum
399 * size hint is not properly calculated. Since this is sometimes necessary,
400 * we provide our own "polish" implementation. */
401
402 if (mIsPolished)
403 return;
404
405 /* load window size and state */
406 resize (mWidth, mHeight);
407 if (mMax)
408 QTimer::singleShot (0, this, SLOT (showMaximized()));
409 else
410 mIsPolished = true;
411
412 VBoxGlobal::centerWidget (this, parentWidget());
413}
414
415
416void VBoxVMInformationDlg::resizeEvent (QResizeEvent*)
417{
418 /* adjust the size-grip location for the current resize event */
419 mSizeGrip->move (centralWidget()->rect().bottomRight() -
420 QPoint (mSizeGrip->rect().width() - 1,
421 mSizeGrip->rect().height() - 1));
422
423 /* store dialog size for this vm */
424 if (mIsPolished && !isMaximized())
425 {
426 mWidth = width();
427 mHeight = height();
428 }
429}
430
431
432void VBoxVMInformationDlg::updateDetails()
433{
434 /* details page update */
435 mDetailsText->setText (
436 vboxGlobal().detailsReport (mSession.GetMachine(), false /* isNewVM */,
437 false /* withLinks */, false /* refresh */));
438}
439
440
441void VBoxVMInformationDlg::onPageChanged (QWidget *aPage)
442{
443 /* focusing the browser on shown page */
444 aPage->setFocus();
445}
446
447
448void VBoxVMInformationDlg::processStatistics()
449{
450 CMachineDebugger dbg = mSession.GetConsole().GetDebugger();
451 QString info;
452
453 /* Look for all statistics for filtering purposes. */
454 // dbg.GetStats ("*", false, info);
455 // mDefStatText->setText (info);
456
457 /* Process selected statistics: */
458 for (DataMapType::const_iterator it = mNamesMap.begin();
459 it != mNamesMap.end(); ++ it)
460 {
461 dbg.GetStats (it.key(), true, info);
462 mValuesMap [it.key()] = parseStatistics (info);
463 }
464
465 /* Statistics page update. */
466 refreshStatistics();
467}
468
469
470QString VBoxVMInformationDlg::parseStatistics (const QString &aText)
471{
472 /* Filters the statistic counters body. */
473 QRegExp query ("^.+<Statistics>\n(.+)\n</Statistics>.*$");
474 if (query.search (aText) == -1)
475 return QString::null;
476
477 QStringList wholeList = QStringList::split ("\n", query.cap (1));
478
479 ULONG64 summa = 0;
480 for (QStringList::Iterator lineIt = wholeList.begin();
481 lineIt != wholeList.end(); ++ lineIt)
482 {
483 QString text = *lineIt;
484 text.remove (1, 1);
485 text.remove (text.length() - 2, 2);
486
487 /* Parse incoming counter and fill the counter-element values. */
488 CounterElementType counter;
489 counter.type = text.section (" ", 0, 0);
490 text = text.section (" ", 1);
491 QStringList list = QStringList::split ("\" ", text);
492 for (QStringList::Iterator it = list.begin(); it != list.end(); ++ it)
493 {
494 QString pair = *it;
495 QRegExp regExp ("^(.+)=\"([^\"]*)\"?$");
496 regExp.search (pair);
497 counter.list.insert (regExp.cap (1), regExp.cap (2));
498 }
499
500 /* Fill the output with the necessary counter's value.
501 * Currently we are using "c" field of simple counter only. */
502 QString result = counter.list.contains ("c") ? counter.list ["c"] : "0";
503 summa += result.toULongLong();
504 }
505
506 return QString::number (summa);
507}
508
509
510void VBoxVMInformationDlg::refreshStatistics()
511{
512 if (mSession.isNull())
513 return;
514
515 QString table = "<p><table border=0 cellspacing=0 cellpadding=0 width=100%>%1</table></p>";
516 QString hdrRow = "<tr><td align=left><img src='%1'></td><td colspan=3><b>%2</b></td></tr>";
517 QString bdyRow = "<tr><td></td><td><nobr>%1</nobr></td><td colspan=2><nobr>%2</nobr></td></tr>";
518 QString paragraph = "<tr><td colspan=4></td></tr>";
519 QString result;
520
521 CMachine m = mSession.GetMachine();
522
523 /* Screen & VT-X Runtime Parameters */
524 {
525 CConsole console = mSession.GetConsole();
526 ULONG bpp = console.GetDisplay().GetBitsPerPixel();
527 QString resolution = QString ("%1x%2")
528 .arg (console.GetDisplay().GetWidth())
529 .arg (console.GetDisplay().GetHeight());
530 if (bpp)
531 resolution += QString ("x%1").arg (bpp);
532 QString virt = console.GetDebugger().GetHWVirtExEnabled() ?
533 VBoxGlobal::tr ("Enabled", "details report (VT-x/AMD-V)") :
534 VBoxGlobal::tr ("Disabled", "details report (VT-x/AMD-V)");
535 QString addInfo = console.GetGuest().GetAdditionsVersion();
536 uint addVersion = addInfo.toUInt();
537 QString addVerisonStr = !addInfo.isNull() ?
538 tr ("Version %1.%2", "guest additions")
539 .arg (RT_HIWORD (addVersion)).arg (RT_LOWORD (addVersion)) :
540 tr ("Not Detected", "guest additions");
541 QString osType = console.GetGuest().GetOSTypeId().isNull() ?
542 tr ("Not Detected", "guest os type") : console.GetGuest().GetOSTypeId();
543
544 result += hdrRow.arg ("state_running_16px.png").arg (tr ("Runtime Attributes"));
545 result += bdyRow.arg (tr ("Screen Resolution")).arg (resolution) +
546 bdyRow.arg (VBoxGlobal::tr ("VT-x/AMD-V", "details report")).arg (virt);
547 result += bdyRow.arg (tr ("Guest Additions")).arg (addVerisonStr);
548 result += bdyRow.arg (tr ("Guest OS Type")).arg (osType);
549 result += paragraph;
550 }
551
552 /* Hard Disk Statistics. */
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 }
604
605 /* Network Adapters Statistics. */
606 {
607 QString naStat;
608
609 result += hdrRow.arg ("nw_16px.png")
610 .arg (tr ("Network Adapter Statistics"));
611
612 /* Network Adapters list */
613 ulong count = vboxGlobal().virtualBox()
614 .GetSystemProperties().GetNetworkAdapterCount();
615 for (ulong slot = 0; slot < count; ++ slot)
616 {
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;
632 }
633
634 /* Show full composed page. */
635 mStatisticText->setText (table.arg (result));
636}
637
638
639QString VBoxVMInformationDlg::formatHardDisk (KStorageBus aBus,
640 LONG aChannel,
641 LONG aDevice,
642 const QString &aBelongsTo)
643{
644 if (mSession.isNull())
645 return QString::null;
646
647 CHardDisk hd = mSession.GetMachine().GetHardDisk (aBus, aChannel, aDevice);
648 QString header = "<tr><td></td><td colspan=3><nobr><u>%1</u></nobr></td></tr>";
649 QString name = vboxGlobal().toFullString (aBus, aChannel, aDevice);
650 QString result = hd.isNull() ? QString::null : header.arg (name);
651 result += composeArticle (aBelongsTo);
652 return result;
653}
654
655QString VBoxVMInformationDlg::formatAdapter (ULONG aSlot,
656 const QString &aBelongsTo)
657
658{
659 if (mSession.isNull())
660 return QString::null;
661
662 QString header = "<tr><td></td><td colspan=3><nobr><u>%1</u></nobr></td></tr>";
663 QString name = VBoxGlobal::tr ("Adapter %1", "details report (network)").arg (aSlot);
664 QString result = header.arg (name);
665 result += composeArticle (aBelongsTo);
666 return result;
667}
668
669
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>";
674 QString result;
675
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);
702
703 return result;
704}
705
706
707/* Old code for two columns support */
708#if 0
709void VBoxVMInformationDlg::refreshStatistics()
710{
711 QString table = "<p><table border=0 cellspacing=0 cellpadding=0 width=100%>%1</table></p>";
712 QString hdrRow = "<tr><td align=left><img src='%1'></td><td colspan=4><b>%2</b></td></tr>";
713 QString subRow = "<tr><td></td><td colspan=2><nobr><u>%1</u></nobr></td>"
714 "<td colspan=2><nobr><u>%2</u></nobr></td></tr>";
715 QString bdyRow = "<tr><td></td><td><nobr>%1</nobr></td><td width=50%><nobr>%2</nobr></td>"
716 "<td><nobr>%3</nobr></td><td width=50%><nobr>%4</nobr></td></tr>";
717 QString paragraph = "<tr><td colspan=5></td></tr>";
718 QString interline = "<tr><td colspan=5><font size=1>&nbsp;</font></td></tr>";
719 QString result;
720
721 /* Screen & VT-X Runtime Parameters */
722 if (!mSession.isNull())
723 {
724 CConsole console = mSession.GetConsole();
725 ULONG bpp = console.GetDisplay().GetBitsPerPixel();
726 QString resolution = QString ("%1x%2")
727 .arg (console.GetDisplay().GetWidth())
728 .arg (console.GetDisplay().GetHeight());
729 if (bpp)
730 resolution += QString ("x%1").arg (bpp);
731 QString virt = console.GetDebugger().GetHWVirtExEnabled() ?
732 tr ("Enabled") : tr ("Disabled");
733
734 result += hdrRow.arg ("state_running_16px.png").arg (tr ("Runtime Attributes"));
735 result += bdyRow.arg (tr ("Screen Resolution")) .arg (resolution)
736 .arg (tr ("Hardware Virtualization")).arg (virt);
737 result += paragraph;
738 }
739
740 /* Hard Disk Statistics. */
741 result += hdrRow.arg ("hd_16px.png").arg (tr ("Hard Disks Statistics"));
742
743 result += subRow.arg (tr ("Primary Master")).arg (tr ("Primary Slave"));
744 result += composeArticle (QString::null, 0, 1, 4, 5);
745 result += composeArticle ("B", 2, 3, 6, 7);
746 result += interline;
747
748 result += subRow.arg (tr ("Secondary Master")).arg (tr ("Secondary Slave"));
749 result += composeArticle (QString::null, 8, 9, 12, 13);
750 result += composeArticle ("B", 10, 11, 14, 15);
751 result += paragraph;
752
753 /* Network Adapters Statistics. Counters are currently missed. */
754 result += hdrRow.arg ("nw_16px.png").arg (tr ("Network Adapter Statistics"));
755 result += subRow.arg (tr ("Adapter 1")).arg (tr ("Adapter 2"));
756 result += composeArticle ("B", 16, 17, 18, 19);
757
758 /* Show full composed page. */
759 mStatisticText->setText (table.arg (result));
760}
761
762
763QString VBoxVMInformationDlg::composeArticle (const QString &aUnits,
764 int aStart1, int aFinish1,
765 int aStart2, int aFinish2)
766{
767 QString bdyRow = "<tr><td></td><td><nobr>%1</nobr></td><td width=50%><nobr>%2</nobr></td>"
768 "<td><nobr>%3</nobr></td><td width=50%><nobr>%4</nobr></td></tr>";
769
770 QString result;
771
772 int id1 = aStart1, id2 = aStart2;
773 while (id1 <= aFinish1 || id2 <= aFinish2)
774 {
775 QString line = bdyRow;
776 /* Processing first column */
777 if (id1 > aFinish1)
778 {
779 line = line.arg (QString::null).arg (QString::null)
780 .arg (QString::null).arg (QString::null);
781 }
782 else if (mValuesMap.contains (mNamesMap.keys() [id1]))
783 {
784 line = line.arg (mNamesMap.values() [id1]);
785 ULONG64 value = mValuesMap.values() [id1].toULongLong();
786 line = aUnits.isNull() ?
787 line.arg (QString ("%L1").arg (value)) :
788 line.arg (QString ("%L1 %2").arg (value).arg (aUnits));
789 }
790 /* Processing second column */
791 if (id2 > aFinish2)
792 {
793 line = line.arg (QString::null).arg (QString::null)
794 .arg (QString::null).arg (QString::null);
795 }
796 else if (mValuesMap.contains (mNamesMap.keys() [id2]))
797 {
798 line = line.arg (mNamesMap.values() [id2]);
799 ULONG64 value = mValuesMap.values() [id2].toULongLong();
800 line = aUnits.isNull() ?
801 line.arg (QString ("%L1").arg (value)) :
802 line.arg (QString ("%L1 %2").arg (value).arg (aUnits));
803 }
804 result += line;
805 ++ id1; ++ id2;
806 }
807
808 return result;
809}
810#endif
811
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

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