VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox4/ui/VBoxVMInformationDlg.ui.h@ 7220

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

Compile VirtualBox with qt4 on linux.

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