- Timestamp:
- May 20, 2014 3:30:53 PM (11 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/UIVMInfoDialog.cpp
r51305 r51308 37 37 /* COM includes: */ 38 38 #include "COMEnums.h" 39 #include "CMachine.h" 39 40 #include "CConsole.h" 40 41 #include "CSystemProperties.h" … … 51 52 #endif /* !VBOX_WITH_PRECOMPILED_HEADERS */ 52 53 53 UIVMInfoDialog::InfoDlgMap UIVMInfoDialog::mSelfArray = InfoDlgMap(); 54 55 void UIVMInfoDialog::createInformationDlg(UIMachineWindow *pMachineWindow) 56 { 57 CMachine machine = pMachineWindow->machineLogic()->uisession()->session().GetMachine(); 58 if (mSelfArray.find (machine.GetName()) == mSelfArray.end()) 59 { 60 /* Creating new information dialog if there is no one existing */ 61 UIVMInfoDialog *id = new UIVMInfoDialog(pMachineWindow); 62 id->setAttribute (Qt::WA_DeleteOnClose); 63 mSelfArray [machine.GetName()] = id; 64 } 65 66 UIVMInfoDialog *info = mSelfArray [machine.GetName()]; 67 info->show(); 68 info->raise(); 69 info->setWindowState (info->windowState() & ~Qt::WindowMinimized); 70 info->activateWindow(); 71 } 72 73 UIVMInfoDialog::UIVMInfoDialog (UIMachineWindow *pMachineWindow) 54 /* static */ 55 UIVMInfoDialog* UIVMInfoDialog::m_spInstance = 0; 56 57 void UIVMInfoDialog::invoke(UIMachineWindow *pMachineWindow) 58 { 59 /* Make sure dialog instance exists: */ 60 if (!m_spInstance) 61 { 62 /* Create new dialog instance if it doesn't exists yet: */ 63 new UIVMInfoDialog(pMachineWindow); 64 } 65 66 /* Show dialog: */ 67 m_spInstance->show(); 68 /* Raise it: */ 69 m_spInstance->raise(); 70 /* De-miniaturize if necessary: */ 71 m_spInstance->setWindowState(m_spInstance->windowState() & ~Qt::WindowMinimized); 72 /* And activate finally: */ 73 m_spInstance->activateWindow(); 74 } 75 76 UIVMInfoDialog::UIVMInfoDialog(UIMachineWindow *pMachineWindow) 74 77 : QIWithRetranslateUI<QMainWindow>(0) 75 78 , m_pPseudoParentWidget(pMachineWindow) 76 , mIsPolished (false) 77 , mWidth(0), mHeight(0), mMax(false) 78 , mSession (pMachineWindow->session()) 79 , mStatTimer (new QTimer (this)) 80 { 79 , m_fIsPolished(false) 80 , m_iWidth(0), m_iHeight(0), m_fMax(false) 81 , m_session(pMachineWindow->session()) 82 , m_pTimer(new QTimer(this)) 83 { 84 /* Initialize instance early: */ 85 m_spInstance = this; 86 87 /* Delete dialog on close: */ 88 setAttribute(Qt::WA_DeleteOnClose); 89 81 90 /* Apply UI decorations */ 82 Ui::UIVMInfoDialog::setupUi 91 Ui::UIVMInfoDialog::setupUi(this); 83 92 84 93 #ifdef Q_WS_MAC 85 94 /* No icon for this window on the mac, cause this would act as proxy icon which isn't necessary here. */ 86 95 setWindowIcon(QIcon()); 87 #else 96 #else /* !Q_WS_MAC */ 88 97 /* Apply window icons */ 89 98 setWindowIcon(UIIconPool::iconSetFull(":/session_info_32px.png", ":/session_info_16px.png")); 90 #endif 99 #endif /* !Q_WS_MAC */ 91 100 92 101 /* Setup tab icons: */ … … 94 103 mInfoStack->setTabIcon(1, UIIconPool::iconSet(":/session_info_runtime_16px.png")); 95 104 96 /* Setup focus-proxy for pages */97 mPage1->setFocusProxy 98 mPage2->setFocusProxy 99 100 /* Setup browsers */101 mDetailsText->viewport()->setAutoFillBackground 102 mStatisticText->viewport()->setAutoFillBackground 103 104 /* Setup margins */105 mDetailsText->setViewportMargins 106 mStatisticText->setViewportMargins 105 /* Setup focus-proxy for pages: */ 106 mPage1->setFocusProxy(mDetailsText); 107 mPage2->setFocusProxy(mStatisticText); 108 109 /* Setup browsers: */ 110 mDetailsText->viewport()->setAutoFillBackground(false); 111 mStatisticText->viewport()->setAutoFillBackground(false); 112 113 /* Setup margins: */ 114 mDetailsText->setViewportMargins(5, 5, 5, 5); 115 mStatisticText->setViewportMargins(5, 5, 5, 5); 107 116 108 117 /* Configure dialog button-box: */ 109 118 mButtonBox->button(QDialogButtonBox::Close)->setShortcut(Qt::Key_Escape); 110 119 111 /* Setup handlers */ 112 connect (pMachineWindow->uisession(), SIGNAL (sigMediumChange(const CMediumAttachment&)), this, SLOT (updateDetails())); 113 connect (pMachineWindow->uisession(), SIGNAL (sigSharedFolderChange()), this, SLOT (updateDetails())); 114 /* TODO_NEW_CORE: this is ofc not really right in the mm sense. There are 115 * more than one screens. */ 116 connect (pMachineWindow->machineView(), SIGNAL (resizeHintDone()), this, SLOT (processStatistics())); 117 connect (mInfoStack, SIGNAL (currentChanged (int)), this, SLOT (onPageChanged (int))); 118 connect(&vboxGlobal(), SIGNAL(sigMediumEnumerationFinished()), this, SLOT(updateDetails())); 119 connect (mStatTimer, SIGNAL (timeout()), this, SLOT (processStatistics())); 120 121 /* Loading language constants */ 120 /* Setup handlers: */ 121 connect(pMachineWindow->uisession(), SIGNAL(sigMediumChange(const CMediumAttachment&)), this, SLOT(sltUpdateDetails())); 122 connect(pMachineWindow->uisession(), SIGNAL(sigSharedFolderChange()), this, SLOT(sltUpdateDetails())); 123 /* TODO_NEW_CORE: this is ofc not really right in the mm sense. There are more than one screens. */ 124 connect(pMachineWindow->machineView(), SIGNAL(resizeHintDone()), this, SLOT(sltProcessStatistics())); 125 connect(mInfoStack, SIGNAL(currentChanged(int)), this, SLOT(sltHandlePageChanged(int))); 126 connect(&vboxGlobal(), SIGNAL(sigMediumEnumerationFinished()), this, SLOT(sltUpdateDetails())); 127 connect(m_pTimer, SIGNAL(timeout()), this, SLOT(sltProcessStatistics())); 128 129 /* Loading language constants: */ 122 130 retranslateUi(); 123 131 124 /* Details page update */125 updateDetails();126 127 /* Statistics page update */128 processStatistics();129 m StatTimer->start(5000);130 131 /* Preload dialog attributes for this vm*/132 QString dlgsize = mSession.GetMachine().GetExtraData(GUI_InfoDlgState);133 if ( dlgsize.isEmpty())134 { 135 m Width = 400;136 m Height = 450;137 m Max = false;132 /* Details page update: */ 133 sltUpdateDetails(); 134 135 /* Statistics page update: */ 136 sltProcessStatistics(); 137 m_pTimer->start(5000); 138 139 /* Load dialog attributes for this VM: */ 140 QString strSize = m_session.GetMachine().GetExtraData(GUI_InfoDlgState); 141 if (strSize.isEmpty()) 142 { 143 m_iWidth = 400; 144 m_iHeight = 450; 145 m_fMax = false; 138 146 } 139 147 else 140 148 { 141 QStringList list = dlgsize.split(',');142 m Width = list [0].toInt(), mHeight = list[1].toInt();143 m Max = list[2] == "max";144 } 145 146 /* Make statistics page the default one */147 mInfoStack->setCurrentIndex 149 QStringList list = strSize.split(','); 150 m_iWidth = list[0].toInt(), m_iHeight = list[1].toInt(); 151 m_fMax = list[2] == "max"; 152 } 153 154 /* Make statistics page the default one: */ 155 mInfoStack->setCurrentIndex(1); 148 156 } 149 157 150 158 UIVMInfoDialog::~UIVMInfoDialog() 151 159 { 152 /* Save dialog attributes for this vm*/153 QString dlgsize("%1,%2,%3");154 m Session.GetMachine().SetExtraData(GUI_InfoDlgState,155 dlgsize.arg(mWidth).arg(mHeight).arg(isMaximized() ? "max" : "normal"));156 157 if (!mSession.isNull() && !mSession.GetMachine().isNull())158 mSelfArray.remove (mSession.GetMachine().GetName());160 /* Save dialog attributes for this VM: */ 161 QString strSize("%1,%2,%3"); 162 m_session.GetMachine().SetExtraData(GUI_InfoDlgState, 163 strSize.arg(m_iWidth).arg(m_iHeight).arg(isMaximized() ? "max" : "normal")); 164 165 /* Deinitialize instance finally: */ 166 m_spInstance = 0; 159 167 } 160 168 161 169 void UIVMInfoDialog::retranslateUi() 162 170 { 163 /* Translate uic generated strings */164 Ui::UIVMInfoDialog::retranslateUi 165 166 updateDetails();167 168 AssertReturnVoid (!mSession.isNull());169 CMachine machine = m Session.GetMachine();170 AssertReturnVoid 171 172 /* Setup a dialog caption */173 setWindowTitle (tr ("%1 - Session Information").arg(machine.GetName()));174 175 /* Clear counter names initially */176 m NamesMap.clear();177 m UnitsMap.clear();178 m LinksMap.clear();179 180 /* Storage statistics */171 /* Translate uic generated strings: */ 172 Ui::UIVMInfoDialog::retranslateUi(this); 173 174 sltUpdateDetails(); 175 176 AssertReturnVoid(!m_session.isNull()); 177 CMachine machine = m_session.GetMachine(); 178 AssertReturnVoid(!machine.isNull()); 179 180 /* Setup a dialog caption: */ 181 setWindowTitle(tr("%1 - Session Information").arg(machine.GetName())); 182 183 /* Clear counter names initially: */ 184 m_names.clear(); 185 m_units.clear(); 186 m_links.clear(); 187 188 /* Storage statistics: */ 181 189 CSystemProperties sp = vboxGlobal().virtualBox().GetSystemProperties(); 182 CStorageControllerVector controllers = m Session.GetMachine().GetStorageControllers();183 int i deCount = 0, sataCount = 0, scsiCount = 0;190 CStorageControllerVector controllers = m_session.GetMachine().GetStorageControllers(); 191 int iIDECount = 0, iSATACount = 0, iSCSICount = 0; 184 192 foreach (const CStorageController &controller, controllers) 185 193 { … … 188 196 case KStorageBus_IDE: 189 197 { 190 for (ULONG i = 0; i < sp.GetMaxPortCountForStorageBus (KStorageBus_IDE); ++i)198 for (ULONG i = 0; i < sp.GetMaxPortCountForStorageBus(KStorageBus_IDE); ++i) 191 199 { 192 for (ULONG j = 0; j < sp.GetMaxDevicesPerPortForStorageBus (KStorageBus_IDE); ++j)200 for (ULONG j = 0; j < sp.GetMaxDevicesPerPortForStorageBus(KStorageBus_IDE); ++j) 193 201 { 194 /* Names */195 m NamesMap [QString("/Devices/IDE%1/ATA%2/Unit%3/*DMA")196 .arg (ideCount).arg (i).arg (j)] = tr("DMA Transfers");197 m NamesMap [QString("/Devices/IDE%1/ATA%2/Unit%3/*PIO")198 .arg (ideCount).arg (i).arg (j)] = tr("PIO Transfers");199 m NamesMap [QString("/Devices/IDE%1/ATA%2/Unit%3/ReadBytes")200 .arg (ideCount).arg (i).arg (j)] = tr("Data Read");201 m NamesMap [QString("/Devices/IDE%1/ATA%2/Unit%3/WrittenBytes")202 .arg (ideCount).arg (i).arg (j)] = tr("Data Written");203 204 /* Units */205 m UnitsMap [QString("/Devices/IDE%1/ATA%2/Unit%3/*DMA")206 .arg (ideCount).arg (i).arg(j)] = "[B]";207 m UnitsMap [QString("/Devices/IDE%1/ATA%2/Unit%3/*PIO")208 .arg (ideCount).arg (i).arg(j)] = "[B]";209 m UnitsMap [QString("/Devices/IDE%1/ATA%2/Unit%3/ReadBytes")210 .arg (ideCount).arg (i).arg(j)] = "B";211 m UnitsMap [QString("/Devices/IDE%1/ATA%2/Unit%3/WrittenBytes")212 .arg (ideCount).arg (i).arg(j)] = "B";202 /* Names: */ 203 m_names[QString("/Devices/IDE%1/ATA%2/Unit%3/*DMA") 204 .arg(iIDECount).arg(i).arg(j)] = tr("DMA Transfers"); 205 m_names[QString("/Devices/IDE%1/ATA%2/Unit%3/*PIO") 206 .arg(iIDECount).arg(i).arg(j)] = tr("PIO Transfers"); 207 m_names[QString("/Devices/IDE%1/ATA%2/Unit%3/ReadBytes") 208 .arg(iIDECount).arg(i).arg(j)] = tr("Data Read"); 209 m_names[QString("/Devices/IDE%1/ATA%2/Unit%3/WrittenBytes") 210 .arg(iIDECount).arg(i).arg(j)] = tr("Data Written"); 211 212 /* Units: */ 213 m_units[QString("/Devices/IDE%1/ATA%2/Unit%3/*DMA") 214 .arg(iIDECount).arg(i).arg(j)] = "[B]"; 215 m_units[QString("/Devices/IDE%1/ATA%2/Unit%3/*PIO") 216 .arg(iIDECount).arg(i).arg(j)] = "[B]"; 217 m_units[QString("/Devices/IDE%1/ATA%2/Unit%3/ReadBytes") 218 .arg(iIDECount).arg(i).arg(j)] = "B"; 219 m_units[QString("/Devices/IDE%1/ATA%2/Unit%3/WrittenBytes") 220 .arg(iIDECount).arg(i).arg(j)] = "B"; 213 221 214 222 /* Belongs to */ 215 m LinksMap [QString ("/Devices/IDE%1/ATA%2/Unit%3").arg (ideCount).arg (i).arg(j)] = QStringList()216 << QString ("/Devices/IDE%1/ATA%2/Unit%3/*DMA").arg (ideCount).arg (i).arg(j)217 << QString ("/Devices/IDE%1/ATA%2/Unit%3/*PIO").arg (ideCount).arg (i).arg(j)218 << QString ("/Devices/IDE%1/ATA%2/Unit%3/ReadBytes").arg (ideCount).arg (i).arg(j)219 << QString ("/Devices/IDE%1/ATA%2/Unit%3/WrittenBytes").arg (ideCount).arg (i).arg(j);223 m_links[QString("/Devices/IDE%1/ATA%2/Unit%3").arg(iIDECount).arg(i).arg(j)] = QStringList() 224 << QString("/Devices/IDE%1/ATA%2/Unit%3/*DMA").arg(iIDECount).arg(i).arg(j) 225 << QString("/Devices/IDE%1/ATA%2/Unit%3/*PIO").arg(iIDECount).arg(i).arg(j) 226 << QString("/Devices/IDE%1/ATA%2/Unit%3/ReadBytes").arg(iIDECount).arg(i).arg(j) 227 << QString("/Devices/IDE%1/ATA%2/Unit%3/WrittenBytes").arg(iIDECount).arg(i).arg(j); 220 228 } 221 229 } 222 ++ ideCount;230 ++iIDECount; 223 231 break; 224 232 } 225 233 case KStorageBus_SATA: 226 234 { 227 for (ULONG i = 0; i < sp.GetMaxPortCountForStorageBus (KStorageBus_SATA); ++i)235 for (ULONG i = 0; i < sp.GetMaxPortCountForStorageBus(KStorageBus_SATA); ++i) 228 236 { 229 for (ULONG j = 0; j < sp.GetMaxDevicesPerPortForStorageBus (KStorageBus_SATA); ++j)237 for (ULONG j = 0; j < sp.GetMaxDevicesPerPortForStorageBus(KStorageBus_SATA); ++j) 230 238 { 231 /* Names */232 m NamesMap [QString ("/Devices/SATA%1/Port%2/DMA").arg (sataCount).arg(i)]233 = tr 234 m NamesMap [QString ("/Devices/SATA%1/Port%2/ReadBytes").arg (sataCount).arg(i)]235 = tr 236 m NamesMap [QString ("/Devices/SATA%1/Port%2/WrittenBytes").arg (sataCount).arg(i)]237 = tr 238 239 /* Units */240 m UnitsMap [QString ("/Devices/SATA%1/Port%2/DMA").arg (sataCount).arg(i)] = "[B]";241 m UnitsMap [QString ("/Devices/SATA%1/Port%2/ReadBytes").arg (sataCount).arg(i)] = "B";242 m UnitsMap [QString ("/Devices/SATA%1/Port%2/WrittenBytes").arg (sataCount).arg(i)] = "B";243 244 /* Belongs to */245 m LinksMap [QString ("/Devices/SATA%1/Port%2").arg (sataCount).arg(i)] = QStringList()246 << QString ("/Devices/SATA%1/Port%2/DMA").arg (sataCount).arg(i)247 << QString ("/Devices/SATA%1/Port%2/ReadBytes").arg (sataCount).arg(i)248 << QString ("/Devices/SATA%1/Port%2/WrittenBytes").arg (sataCount).arg(i);239 /* Names: */ 240 m_names[QString("/Devices/SATA%1/Port%2/DMA").arg(iSATACount).arg(i)] 241 = tr("DMA Transfers"); 242 m_names[QString("/Devices/SATA%1/Port%2/ReadBytes").arg(iSATACount).arg(i)] 243 = tr("Data Read"); 244 m_names[QString("/Devices/SATA%1/Port%2/WrittenBytes").arg(iSATACount).arg(i)] 245 = tr("Data Written"); 246 247 /* Units: */ 248 m_units[QString("/Devices/SATA%1/Port%2/DMA").arg(iSATACount).arg(i)] = "[B]"; 249 m_units[QString("/Devices/SATA%1/Port%2/ReadBytes").arg(iSATACount).arg(i)] = "B"; 250 m_units[QString("/Devices/SATA%1/Port%2/WrittenBytes").arg(iSATACount).arg(i)] = "B"; 251 252 /* Belongs to: */ 253 m_links[QString("/Devices/SATA%1/Port%2").arg(iSATACount).arg(i)] = QStringList() 254 << QString("/Devices/SATA%1/Port%2/DMA").arg(iSATACount).arg(i) 255 << QString("/Devices/SATA%1/Port%2/ReadBytes").arg(iSATACount).arg(i) 256 << QString("/Devices/SATA%1/Port%2/WrittenBytes").arg(iSATACount).arg(i); 249 257 } 250 258 } 251 ++ sataCount;259 ++iSATACount; 252 260 break; 253 261 } 254 262 case KStorageBus_SCSI: 255 263 { 256 for (ULONG i = 0; i < sp.GetMaxPortCountForStorageBus (KStorageBus_SCSI); ++i)264 for (ULONG i = 0; i < sp.GetMaxPortCountForStorageBus(KStorageBus_SCSI); ++i) 257 265 { 258 for (ULONG j = 0; j < sp.GetMaxDevicesPerPortForStorageBus (KStorageBus_SCSI); ++j)266 for (ULONG j = 0; j < sp.GetMaxDevicesPerPortForStorageBus(KStorageBus_SCSI); ++j) 259 267 { 260 /* Names */261 m NamesMap [QString ("/Devices/SCSI%1/%2/ReadBytes").arg (scsiCount).arg(i)]262 = tr 263 m NamesMap [QString ("/Devices/SCSI%1/%2/WrittenBytes").arg (scsiCount).arg(i)]264 = tr 265 266 /* Units */267 m UnitsMap [QString ("/Devices/SCSI%1/%2/ReadBytes").arg (scsiCount).arg(i)] = "B";268 m UnitsMap [QString ("/Devices/SCSI%1/%2/WrittenBytes").arg (scsiCount).arg(i)] = "B";269 270 /* Belongs to */271 m LinksMap [QString ("/Devices/SCSI%1/%2").arg (scsiCount).arg(i)] = QStringList()272 << QString ("/Devices/SCSI%1/%2/ReadBytes").arg (scsiCount).arg(i)273 << QString ("/Devices/SCSI%1/%2/WrittenBytes").arg (scsiCount).arg(i);268 /* Names: */ 269 m_names[QString("/Devices/SCSI%1/%2/ReadBytes").arg(iSCSICount).arg(i)] 270 = tr("Data Read"); 271 m_names[QString("/Devices/SCSI%1/%2/WrittenBytes").arg(iSCSICount).arg(i)] 272 = tr("Data Written"); 273 274 /* Units: */ 275 m_units[QString("/Devices/SCSI%1/%2/ReadBytes").arg(iSCSICount).arg(i)] = "B"; 276 m_units[QString("/Devices/SCSI%1/%2/WrittenBytes").arg(iSCSICount).arg(i)] = "B"; 277 278 /* Belongs to: */ 279 m_links[QString("/Devices/SCSI%1/%2").arg(iSCSICount).arg(i)] = QStringList() 280 << QString("/Devices/SCSI%1/%2/ReadBytes").arg(iSCSICount).arg(i) 281 << QString("/Devices/SCSI%1/%2/WrittenBytes").arg(iSCSICount).arg(i); 274 282 } 275 283 } 276 ++ scsiCount;284 ++iSCSICount; 277 285 break; 278 286 } … … 284 292 /* Network statistics: */ 285 293 ulong count = vboxGlobal().virtualBox().GetSystemProperties().GetMaxNetworkAdapters(KChipsetType_PIIX3); 286 for (ulong i = 0; i < count; ++ 287 { 288 CNetworkAdapter na = machine.GetNetworkAdapter 294 for (ulong i = 0; i < count; ++i) 295 { 296 CNetworkAdapter na = machine.GetNetworkAdapter(i); 289 297 KNetworkAdapterType ty = na.GetAdapterType(); 290 298 const char *name; … … 305 313 } 306 314 307 /* Names */ 308 mNamesMap [QString ("/Devices/%1%2/TransmitBytes") 309 .arg (name).arg (i)] = tr ("Data Transmitted"); 310 mNamesMap [QString ("/Devices/%1%2/ReceiveBytes") 311 .arg (name).arg (i)] = tr ("Data Received"); 312 313 /* Units */ 314 mUnitsMap [QString ("/Devices/%1%2/TransmitBytes") 315 .arg (name).arg (i)] = "B"; 316 mUnitsMap [QString ("/Devices/%1%2/ReceiveBytes") 317 .arg (name).arg (i)] = "B"; 318 319 /* Belongs to */ 320 mLinksMap [QString ("NA%1").arg (i)] = QStringList() 321 << QString ("/Devices/%1%2/TransmitBytes").arg (name).arg (i) 322 << QString ("/Devices/%1%2/ReceiveBytes").arg (name).arg (i); 323 } 324 325 /* Statistics page update. */ 315 /* Names: */ 316 m_names[QString("/Devices/%1%2/TransmitBytes").arg(name).arg(i)] = tr("Data Transmitted"); 317 m_names[QString("/Devices/%1%2/ReceiveBytes").arg(name).arg(i)] = tr("Data Received"); 318 319 /* Units: */ 320 m_units[QString("/Devices/%1%2/TransmitBytes").arg(name).arg(i)] = "B"; 321 m_units[QString("/Devices/%1%2/ReceiveBytes").arg(name).arg(i)] = "B"; 322 323 /* Belongs to: */ 324 m_links[QString("NA%1").arg(i)] = QStringList() 325 << QString("/Devices/%1%2/TransmitBytes").arg(name).arg(i) 326 << QString("/Devices/%1%2/ReceiveBytes").arg(name).arg(i); 327 } 328 329 /* Statistics page update: */ 326 330 refreshStatistics(); 327 331 } 328 332 329 bool UIVMInfoDialog::event (QEvent *aEvent) 330 { 331 bool result = QMainWindow::event (aEvent); 332 switch (aEvent->type()) 333 { 333 bool UIVMInfoDialog::event(QEvent *pEvent) 334 { 335 /* Pre-process through base-class: */ 336 bool fResult = QMainWindow::event(pEvent); 337 338 /* Process required events: */ 339 switch (pEvent->type()) 340 { 341 /* Window state-change event: */ 334 342 case QEvent::WindowStateChange: 335 343 { 336 if (m IsPolished)337 m Max = isMaximized();338 else if (m Max == isMaximized())339 m IsPolished = true;344 if (m_fIsPolished) 345 m_fMax = isMaximized(); 346 else if (m_fMax == isMaximized()) 347 m_fIsPolished = true; 340 348 break; 341 349 } … … 343 351 break; 344 352 } 345 return result; 346 } 347 348 void UIVMInfoDialog::resizeEvent (QResizeEvent *aEvent) 349 { 350 QMainWindow::resizeEvent (aEvent); 351 352 /* Store dialog size for this vm */ 353 if (mIsPolished && !isMaximized()) 354 { 355 mWidth = width(); 356 mHeight = height(); 357 } 358 } 359 360 void UIVMInfoDialog::showEvent (QShowEvent *aEvent) 353 354 /* Return result: */ 355 return fResult; 356 } 357 358 void UIVMInfoDialog::resizeEvent(QResizeEvent *pEvent) 359 { 360 /* Pre-process through base-class: */ 361 QMainWindow::resizeEvent(pEvent); 362 363 /* Store dialog size for this VM: */ 364 if (m_fIsPolished && !isMaximized()) 365 { 366 m_iWidth = width(); 367 m_iHeight = height(); 368 } 369 } 370 371 void UIVMInfoDialog::showEvent(QShowEvent *pEvent) 361 372 { 362 373 /* One may think that QWidget::polish() is the right place to do things … … 365 376 * size hint is not properly calculated. Since this is sometimes necessary, 366 377 * we provide our own "polish" implementation */ 367 if (!m IsPolished)378 if (!m_fIsPolished) 368 379 { 369 380 /* Load window size, adjust position and load window state finally: */ 370 resize (mWidth, mHeight);381 resize(m_iWidth, m_iHeight); 371 382 vboxGlobal().centerWidget(this, m_pPseudoParentWidget, false); 372 if (m Max)373 QTimer::singleShot (0, this, SLOT(showMaximized()));383 if (m_fMax) 384 QTimer::singleShot(0, this, SLOT(showMaximized())); 374 385 else 375 mIsPolished = true; 376 } 377 378 QMainWindow::showEvent (aEvent); 379 } 380 381 382 void UIVMInfoDialog::updateDetails() 383 { 384 /* Details page update */ 385 mDetailsText->setText (vboxGlobal().detailsReport (mSession.GetMachine(), false /* aWithLinks */)); 386 } 387 388 void UIVMInfoDialog::processStatistics() 389 { 390 CMachineDebugger dbg = mSession.GetConsole().GetDebugger(); 391 QString info; 392 393 /* Process selected statistics: */ 394 for (DataMapType::const_iterator it = mNamesMap.begin(); it != mNamesMap.end(); ++ it) 395 { 396 info = dbg.GetStats(it.key(), true); 397 mValuesMap[it.key()] = parseStatistics(info); 398 } 399 400 /* Statistics page update */ 386 m_fIsPolished = true; 387 } 388 389 /* Post-process through base-class: */ 390 QMainWindow::showEvent(pEvent); 391 } 392 393 void UIVMInfoDialog::sltUpdateDetails() 394 { 395 /* Details page update: */ 396 mDetailsText->setText(vboxGlobal().detailsReport(m_session.GetMachine(), false /* with links */)); 397 } 398 399 void UIVMInfoDialog::sltProcessStatistics() 400 { 401 /* Get machine debugger: */ 402 CMachineDebugger dbg = m_session.GetConsole().GetDebugger(); 403 QString strInfo; 404 405 /* Process selected VM statistics: */ 406 for (DataMapType::const_iterator it = m_names.begin(); it != m_names.end(); ++it) 407 { 408 strInfo = dbg.GetStats(it.key(), true); 409 m_values[it.key()] = parseStatistics(strInfo); 410 } 411 412 /* Update VM statistics page: */ 401 413 refreshStatistics(); 402 414 } 403 415 404 void UIVMInfoDialog::onPageChanged (int aIndex) 405 { 406 /* Focusing the browser on shown page */ 407 mInfoStack->widget (aIndex)->setFocus(); 408 } 409 410 QString UIVMInfoDialog::parseStatistics (const QString &aText) 411 { 412 /* Filters the statistic counters body */ 413 QRegExp query ("^.+<Statistics>\n(.+)\n</Statistics>.*$"); 414 if (query.indexIn (aText) == -1) 415 return QString::null; 416 417 QStringList wholeList = query.cap (1).split ("\n"); 418 419 ULONG64 summa = 0; 420 for (QStringList::Iterator lineIt = wholeList.begin(); lineIt != wholeList.end(); ++ lineIt) 421 { 422 QString text = *lineIt; 423 text.remove (1, 1); 424 text.remove (text.length() - 2, 2); 425 426 /* Parse incoming counter and fill the counter-element values. */ 416 void UIVMInfoDialog::sltHandlePageChanged(int iIndex) 417 { 418 /* Focus the browser on shown page: */ 419 mInfoStack->widget(iIndex)->setFocus(); 420 } 421 422 QString UIVMInfoDialog::parseStatistics(const QString &strText) 423 { 424 /* Filters VM statistics counters body: */ 425 QRegExp query("^.+<Statistics>\n(.+)\n</Statistics>.*$"); 426 if (query.indexIn(strText) == -1) 427 return QString(); 428 429 /* Split whole VM statistics text to lines: */ 430 const QStringList text = query.cap(1).split("\n"); 431 432 /* Iterate through all VM statistics: */ 433 ULONG64 uSumm = 0; 434 for (QStringList::const_iterator lineIt = text.begin(); lineIt != text.end(); ++lineIt) 435 { 436 /* Get current line: */ 437 QString strLine = *lineIt; 438 strLine.remove(1, 1); 439 strLine.remove(strLine.length() -2, 2); 440 441 /* Parse incoming counter and fill the counter-element values: */ 427 442 CounterElementType counter; 428 counter.type = text.section(" ", 0, 0);429 text = text.section(" ", 1);430 QStringList list = text.split("\" ");431 for (QStringList::Iterator it = list.begin(); it != list.end(); ++ 443 counter.type = strLine.section(" ", 0, 0); 444 strLine = strLine.section(" ", 1); 445 QStringList list = strLine.split("\" "); 446 for (QStringList::Iterator it = list.begin(); it != list.end(); ++it) 432 447 { 433 448 QString pair = *it; 434 QRegExp regExp 435 regExp.indexIn 436 counter.list.insert (regExp.cap (1), regExp.cap(2));449 QRegExp regExp("^(.+)=\"([^\"]*)\"?$"); 450 regExp.indexIn(pair); 451 counter.list.insert(regExp.cap(1), regExp.cap(2)); 437 452 } 438 453 439 454 /* Fill the output with the necessary counter's value. 440 455 * Currently we are using "c" field of simple counter only. */ 441 QString result = counter.list.contains ("c") ? counter.list["c"] : "0";442 summa+= result.toULongLong();443 } 444 445 return QString::number (summa);456 QString result = counter.list.contains("c") ? counter.list["c"] : "0"; 457 uSumm += result.toULongLong(); 458 } 459 460 return QString::number(uSumm); 446 461 } 447 462 448 463 void UIVMInfoDialog::refreshStatistics() 449 464 { 450 if (mSession.isNull()) 465 /* Skip for inactive session: */ 466 if (m_session.isNull()) 451 467 return; 452 468 453 QString table = "<table width=100% cellspacing=1 cellpadding=0>%1</table>"; 454 QString hdrRow = "<tr><td width=22><img src='%1'></td>" 455 "<td colspan=2><nobr><b>%2</b></nobr></td></tr>"; 456 QString paragraph = "<tr><td colspan=3></td></tr>"; 457 QString result; 458 459 CMachine m = mSession.GetMachine(); 460 461 /* Runtime Information */ 462 { 463 CConsole console = mSession.GetConsole(); 464 465 ULONG width = 0; 466 ULONG height = 0; 467 ULONG bpp = 0; 469 /* Prepare templates: */ 470 QString strTable = "<table width=100% cellspacing=1 cellpadding=0>%1</table>"; 471 QString strHeader = "<tr><td width=22><img src='%1'></td>" 472 "<td colspan=2><nobr><b>%2</b></nobr></td></tr>"; 473 QString strParagraph = "<tr><td colspan=3></td></tr>"; 474 QString strResult; 475 476 /* Get current machine: */ 477 CMachine m = m_session.GetMachine(); 478 479 /* Runtime Information: */ 480 { 481 /* Get current console: */ 482 CConsole console = m_session.GetConsole(); 483 484 /* Determine resolution: */ 485 ULONG uWidth = 0; 486 ULONG uHeight = 0; 487 ULONG uBpp = 0; 468 488 LONG xOrigin = 0; 469 489 LONG yOrigin = 0; 470 console.GetDisplay().GetScreenResolution(0, width, height, bpp, xOrigin, yOrigin); 471 QString resolution = QString ("%1x%2") 472 .arg (width) 473 .arg (height); 474 if (bpp) 475 resolution += QString ("x%1").arg (bpp); 476 resolution += QString (" @%1,%2") 477 .arg (xOrigin) 478 .arg (yOrigin); 479 /* this page is refreshed every 5 seconds, round */ 490 console.GetDisplay().GetScreenResolution(0, uWidth, uHeight, uBpp, xOrigin, yOrigin); 491 QString strResolution = QString("%1x%2").arg(uWidth).arg(uHeight); 492 if (uBpp) 493 strResolution += QString("x%1").arg(uBpp); 494 strResolution += QString(" @%1,%2").arg(xOrigin).arg(yOrigin); 495 496 /* Calculate uptime: */ 480 497 uint32_t uUpSecs = (RTTimeProgramSecTS() / 5) * 5; 481 498 char szUptime[32]; … … 488 505 RTStrPrintf(szUptime, sizeof(szUptime), "%dd %02d:%02d:%02d", 489 506 uUpDays, uUpHours, uUpMins, uUpSecs); 490 QString uptime = QString(szUptime); 491 492 QString clipboardMode = gpConverter->toString(m.GetClipboardMode()); 493 QString dragAndDropMode = gpConverter->toString(m.GetDragAndDropMode()); 494 507 QString strUptime = QString(szUptime); 508 509 /* Determine clipboard mode: */ 510 QString strClipboardMode = gpConverter->toString(m.GetClipboardMode()); 511 /* Determine Drag&Drop mode: */ 512 QString strDragAndDropMode = gpConverter->toString(m.GetDragAndDropMode()); 513 514 /* Deterine virtualization attributes: */ 495 515 CMachineDebugger debugger = console.GetDebugger(); 496 QString virtualization = debugger.GetHWVirtExEnabled() ? 497 VBoxGlobal::tr ("Enabled", "details report (VT-x/AMD-V)") : 498 VBoxGlobal::tr ("Disabled", "details report (VT-x/AMD-V)"); 499 QString nested = debugger.GetHWVirtExNestedPagingEnabled() ? 500 VBoxGlobal::tr ("Enabled", "details report (Nested Paging)") : 501 VBoxGlobal::tr ("Disabled", "details report (Nested Paging)"); 502 QString unrestricted = debugger.GetHWVirtExUXEnabled() ? 503 VBoxGlobal::tr ("Enabled", "details report (Unrestricted Execution)") : 504 VBoxGlobal::tr ("Disabled", "details report (Unrestricted Execution)"); 505 516 QString strVirtualization = debugger.GetHWVirtExEnabled() ? 517 VBoxGlobal::tr("Enabled", "details report (VT-x/AMD-V)") : 518 VBoxGlobal::tr("Disabled", "details report (VT-x/AMD-V)"); 519 QString strNestedPaging = debugger.GetHWVirtExNestedPagingEnabled() ? 520 VBoxGlobal::tr("Enabled", "details report (Nested Paging)") : 521 VBoxGlobal::tr("Disabled", "details report (Nested Paging)"); 522 QString strUnrestrictedExecution = debugger.GetHWVirtExUXEnabled() ? 523 VBoxGlobal::tr("Enabled", "details report (Unrestricted Execution)") : 524 VBoxGlobal::tr("Disabled", "details report (Unrestricted Execution)"); 525 526 /* Guest information: */ 506 527 CGuest guest = console.GetGuest(); 507 QString addVersionStr= guest.GetAdditionsVersion();508 if ( addVersionStr.isEmpty())509 addVersionStr= tr("Not Detected", "guest additions");528 QString strGAVersion = guest.GetAdditionsVersion(); 529 if (strGAVersion.isEmpty()) 530 strGAVersion = tr("Not Detected", "guest additions"); 510 531 else 511 532 { 512 ULONG revision = guest.GetAdditionsRevision();513 if ( revision != 0)514 addVersionStr += QString(" r%1").arg(revision);515 } 516 QString osType = guest.GetOSTypeId();517 if ( osType.isEmpty())518 osType = tr("Not Detected", "guest os type");533 ULONG uRevision = guest.GetAdditionsRevision(); 534 if (uRevision != 0) 535 strGAVersion += QString(" r%1").arg(uRevision); 536 } 537 QString strOSType = guest.GetOSTypeId(); 538 if (strOSType.isEmpty()) 539 strOSType = tr("Not Detected", "guest os type"); 519 540 else 520 osType = vboxGlobal().vmGuestOSTypeDescription (osType); 521 522 int vrdePort = console.GetVRDEServerInfo().GetPort(); 523 QString vrdeInfo = (vrdePort == 0 || vrdePort == -1)? 524 tr ("Not Available", "details report (VRDE server port)") : 525 QString ("%1").arg (vrdePort); 526 527 /* Searching for longest string */ 528 QStringList valuesList; 529 valuesList << resolution << uptime << virtualization << nested << unrestricted << addVersionStr << osType << vrdeInfo; 530 int maxLength = 0; 531 foreach (const QString &value, valuesList) 532 maxLength = maxLength < fontMetrics().width (value) ? 533 fontMetrics().width (value) : maxLength; 534 535 result += hdrRow.arg (":/state_running_16px.png").arg (tr ("Runtime Attributes")); 536 result += formatValue (tr ("Screen Resolution"), resolution, maxLength); 537 result += formatValue (tr ("VM Uptime"), uptime, maxLength); 538 result += formatValue (tr ("Clipboard Mode"), clipboardMode, maxLength); 539 result += formatValue (tr ("Drag'n'Drop Mode"), dragAndDropMode, maxLength); 540 result += formatValue (VBoxGlobal::tr ("VT-x/AMD-V", "details report"), virtualization, maxLength); 541 result += formatValue (VBoxGlobal::tr ("Nested Paging", "details report"), nested, maxLength); 542 result += formatValue (VBoxGlobal::tr ("Unrestricted Execution", "details report"), unrestricted, maxLength); 543 result += formatValue (tr ("Guest Additions"), addVersionStr, maxLength); 544 result += formatValue (tr ("Guest OS Type"), osType, maxLength); 545 result += formatValue (VBoxGlobal::tr ("Remote Desktop Server Port", "details report (VRDE Server)"), vrdeInfo, maxLength); 546 result += paragraph; 547 } 548 549 /* Storage statistics */ 550 { 551 QString storageStat; 552 553 result += hdrRow.arg (":/hd_16px.png").arg (tr ("Storage Statistics")); 554 555 CStorageControllerVector controllers = mSession.GetMachine().GetStorageControllers(); 556 int ideCount = 0, sataCount = 0, scsiCount = 0; 541 strOSType = vboxGlobal().vmGuestOSTypeDescription(strOSType); 542 543 /* VRDE information: */ 544 int iVRDEPort = console.GetVRDEServerInfo().GetPort(); 545 QString strVRDEInfo = (iVRDEPort == 0 || iVRDEPort == -1)? 546 tr("Not Available", "details report (VRDE server port)") : 547 QString("%1").arg(iVRDEPort); 548 549 /* Searching for longest string: */ 550 QStringList values; 551 values << strResolution << strUptime 552 << strVirtualization << strNestedPaging << strUnrestrictedExecution 553 << strGAVersion << strOSType << strVRDEInfo; 554 int iMaxLength = 0; 555 foreach (const QString &strValue, values) 556 iMaxLength = iMaxLength < fontMetrics().width(strValue) 557 ? fontMetrics().width(strValue) : iMaxLength; 558 559 /* Summary: */ 560 strResult += strHeader.arg(":/state_running_16px.png").arg(tr("Runtime Attributes")); 561 strResult += formatValue(tr("Screen Resolution"), strResolution, iMaxLength); 562 strResult += formatValue(tr("VM Uptime"), strUptime, iMaxLength); 563 strResult += formatValue(tr("Clipboard Mode"), strClipboardMode, iMaxLength); 564 strResult += formatValue(tr("Drag'n'Drop Mode"), strDragAndDropMode, iMaxLength); 565 strResult += formatValue(VBoxGlobal::tr("VT-x/AMD-V", "details report"), strVirtualization, iMaxLength); 566 strResult += formatValue(VBoxGlobal::tr("Nested Paging", "details report"), strNestedPaging, iMaxLength); 567 strResult += formatValue(VBoxGlobal::tr("Unrestricted Execution", "details report"), strUnrestrictedExecution, iMaxLength); 568 strResult += formatValue(tr("Guest Additions"), strGAVersion, iMaxLength); 569 strResult += formatValue(tr("Guest OS Type"), strOSType, iMaxLength); 570 strResult += formatValue(VBoxGlobal::tr("Remote Desktop Server Port", "details report (VRDE Server)"), strVRDEInfo, iMaxLength); 571 strResult += strParagraph; 572 } 573 574 /* Storage statistics: */ 575 { 576 /* Prepare storage-statistics: */ 577 QString strStorageStat; 578 579 /* Append result with storage-statistics header: */ 580 strResult += strHeader.arg(":/hd_16px.png").arg(tr("Storage Statistics")); 581 582 /* Enumerate storage-controllers: */ 583 CStorageControllerVector controllers = m.GetStorageControllers(); 584 int iIDECount = 0, iSATACount = 0, iSCSICount = 0; 557 585 foreach (const CStorageController &controller, controllers) 558 586 { 559 QString ctrName = controller.GetName(); 587 /* Get controller attributes: */ 588 QString strName = controller.GetName(); 560 589 KStorageBus busType = controller.GetBus(); 561 CMediumAttachmentVector attachments = mSession.GetMachine().GetMediumAttachmentsOfController (ctrName); 590 CMediumAttachmentVector attachments = m.GetMediumAttachmentsOfController(strName); 591 /* Skip empty and floppy attachments: */ 562 592 if (!attachments.isEmpty() && busType != KStorageBus_Floppy) 563 593 { 564 QString header = "<tr><td></td><td colspan=2><nobr>%1</nobr></td></tr>"; 594 /* Prepare storage templates: */ 595 QString strHeaderStorage = "<tr><td></td><td colspan=2><nobr>%1</nobr></td></tr>"; 596 /* Prepare full controller name: */ 565 597 QString strControllerName = QApplication::translate("UIMachineSettingsStorage", "Controller: %1"); 566 storageStat += header.arg(strControllerName.arg(controller.GetName())); 567 int scsiIndex = 0; 598 /* Append storage-statistics with controller name: */ 599 strStorageStat += strHeaderStorage.arg(strControllerName.arg(controller.GetName())); 600 int iSCSIIndex = 0; 601 /* Enumerate storage-attachments: */ 568 602 foreach (const CMediumAttachment &attachment, attachments) 569 603 { 570 LONG attPort = attachment.GetPort();571 LONG attDevice = attachment.GetDevice();604 const LONG iPort = attachment.GetPort(); 605 const LONG iDevice = attachment.GetDevice(); 572 606 switch (busType) 573 607 { 574 608 case KStorageBus_IDE: 575 609 { 576 storageStat += formatMedium (ctrName, attPort, attDevice, 577 QString ("/Devices/IDE%1/ATA%2/Unit%3").arg (ideCount).arg (attPort).arg (attDevice)); 610 /* Append storage-statistics with IDE controller statistics: */ 611 strStorageStat += formatStorageElement(strName, iPort, iDevice, 612 QString("/Devices/IDE%1/ATA%2/Unit%3") 613 .arg(iIDECount).arg(iPort).arg(iDevice)); 578 614 break; 579 615 } 580 616 case KStorageBus_SATA: 581 617 { 582 storageStat += formatMedium (ctrName, attPort, attDevice, 583 QString ("/Devices/SATA%1/Port%2").arg (sataCount).arg (attPort)); 618 /* Append storage-statistics with SATA controller statistics: */ 619 strStorageStat += formatStorageElement(strName, iPort, iDevice, 620 QString("/Devices/SATA%1/Port%2") 621 .arg(iSATACount).arg(iPort)); 584 622 break; 585 623 } 586 624 case KStorageBus_SCSI: 587 625 { 588 storageStat += formatMedium (ctrName, attPort, attDevice, 589 QString ("/Devices/SCSI%1/%2").arg (scsiCount).arg (scsiIndex)); 590 ++ scsiIndex; 626 /* Append storage-statistics with SCSI controller statistics: */ 627 strStorageStat += formatStorageElement(strName, iPort, iDevice, 628 QString("/Devices/SCSI%1/%2") 629 .arg(iSCSICount).arg(iSCSIIndex)); 630 ++iSCSIIndex; 591 631 break; 592 632 } … … 594 634 break; 595 635 } 596 st orageStat += paragraph;636 strStorageStat += strParagraph; 597 637 } 598 638 } 599 639 /* Increment controller counters: */ 600 640 switch (busType) 601 641 { 602 case KStorageBus_IDE: 603 { 604 ++ ideCount; 605 break; 606 } 607 case KStorageBus_SATA: 608 { 609 ++ sataCount; 610 break; 611 } 612 case KStorageBus_SCSI: 613 { 614 ++ scsiCount; 615 break; 616 } 617 default: 618 break; 642 case KStorageBus_IDE: ++iIDECount; break; 643 case KStorageBus_SATA: ++iSATACount; break; 644 case KStorageBus_SCSI: ++iSCSICount; break; 645 default: break; 619 646 } 620 647 } 621 648 622 /* If there are no Hard Disks */ 623 if (storageStat.isNull()) 624 { 625 storageStat = composeArticle (tr ("No Storage Devices")); 626 storageStat += paragraph; 627 } 628 629 result += storageStat; 630 } 631 632 /* Network Adapters Statistics */ 633 { 634 QString networkStat; 635 636 result += hdrRow.arg (":/nw_16px.png").arg (tr ("Network Statistics")); 637 638 /* Network Adapters list */ 639 ulong count = vboxGlobal().virtualBox().GetSystemProperties().GetMaxNetworkAdapters(KChipsetType_PIIX3); 640 for (ulong slot = 0; slot < count; ++ slot) 641 { 642 if (m.GetNetworkAdapter (slot).GetEnabled()) 649 /* If there are no storage devices: */ 650 if (strStorageStat.isNull()) 651 { 652 strStorageStat = composeArticle(tr("No Storage Devices")); 653 strStorageStat += strParagraph; 654 } 655 656 /* Append result with storage-statistics: */ 657 strResult += strStorageStat; 658 } 659 660 /* Network statistics: */ 661 { 662 /* Prepare netork-statistics: */ 663 QString strNetworkStat; 664 665 /* Append result with network-statistics header: */ 666 strResult += strHeader.arg(":/nw_16px.png").arg(tr("Network Statistics")); 667 668 /* Enumerate network-adapters: */ 669 ulong uCount = vboxGlobal().virtualBox().GetSystemProperties().GetMaxNetworkAdapters(m.GetChipsetType()); 670 for (ulong uSlot = 0; uSlot < uCount; ++uSlot) 671 { 672 /* Skip disabled adapters: */ 673 if (m.GetNetworkAdapter(uSlot).GetEnabled()) 643 674 { 644 networkStat += formatAdapter (slot, QString ("NA%1").arg (slot)); 645 networkStat += paragraph; 675 /* Append network-statistics with adapter-statistics: */ 676 strNetworkStat += formatNetworkElement(uSlot, QString("NA%1").arg(uSlot)); 677 strNetworkStat += strParagraph; 646 678 } 647 679 } 648 680 649 /* If there are no Network Adapters */ 650 if (networkStat.isNull()) 651 { 652 networkStat = composeArticle (tr ("No Network Adapters")); 653 networkStat += paragraph; 654 } 655 656 result += networkStat; 657 } 658 659 /* Show full composed page & save/restore scroll-bar position */ 660 int vv = mStatisticText->verticalScrollBar()->value(); 661 mStatisticText->setText (table.arg (result)); 662 mStatisticText->verticalScrollBar()->setValue (vv); 663 } 664 665 /** 666 * Allows left-aligned values formatting in right column. 667 * 668 * aValueName - the name of value in the left column. 669 * aValue - left-aligned value itself in the right column. 670 * aMaxSize - maximum width (in pixels) of value in right column. 671 */ 672 QString UIVMInfoDialog::formatValue (const QString &aValueName, 673 const QString &aValue, int aMaxSize) 674 { 681 /* If there are no network adapters: */ 682 if (strNetworkStat.isNull()) 683 { 684 strNetworkStat = composeArticle(tr("No Network Adapters")); 685 strNetworkStat += strParagraph; 686 } 687 688 /* Append result with network-statistics: */ 689 strResult += strNetworkStat; 690 } 691 692 /* Show full composed page & save/restore scroll-bar position: */ 693 int iScrollBarValue = mStatisticText->verticalScrollBar()->value(); 694 mStatisticText->setText(strTable.arg(strResult)); 695 mStatisticText->verticalScrollBar()->setValue(iScrollBarValue); 696 } 697 698 QString UIVMInfoDialog::formatValue(const QString &strValueName, 699 const QString &strValue, 700 int iMaxSize) 701 { 702 if (m_session.isNull()) 703 return QString(); 704 675 705 QString strMargin; 676 int size = aMaxSize - fontMetrics().width(aValue);706 int size = iMaxSize - fontMetrics().width(strValue); 677 707 for (int i = 0; i < size; ++i) 678 708 strMargin += QString("<img width=1 height=1 src=:/tpixel.png>"); … … 684 714 "</tr>"; 685 715 686 return bdyRow.arg (aValueName).arg (aValue).arg (strMargin); 687 } 688 689 QString UIVMInfoDialog::formatMedium (const QString &aCtrName, 690 LONG aPort, LONG aDevice, 691 const QString &aBelongsTo) 692 { 693 if (mSession.isNull()) 694 return QString::null; 695 696 QString header = "<tr><td></td><td colspan=2><nobr> %1:</nobr></td></tr>"; 697 CStorageController ctr = mSession.GetMachine().GetStorageControllerByName (aCtrName); 698 QString name = gpConverter->toString (StorageSlot (ctr.GetBus(), aPort, aDevice)); 699 return header.arg (name) + composeArticle (aBelongsTo, 2); 700 } 701 702 QString UIVMInfoDialog::formatAdapter (ULONG aSlot, 703 const QString &aBelongsTo) 704 { 705 if (mSession.isNull()) 706 return QString::null; 707 708 QString header = "<tr><td></td><td colspan=2><nobr>%1</nobr></td></tr>"; 709 QString name = VBoxGlobal::tr ("Adapter %1", "details report (network)").arg (aSlot + 1); 710 return header.arg (name) + composeArticle (aBelongsTo, 1); 711 } 712 713 QString UIVMInfoDialog::composeArticle (const QString &aBelongsTo, int aSpacesCount) 714 { 715 QString body = "<tr><td></td><td width=50%><nobr>%1%2</nobr></td>" 716 "<td align=right><nobr>%3%4</nobr></td></tr>"; 717 QString indent; 718 for (int i = 0; i < aSpacesCount; ++ i) 719 indent += " "; 720 body = body.arg (indent); 721 722 QString result; 723 724 if (mLinksMap.contains (aBelongsTo)) 725 { 726 QStringList keys = mLinksMap [aBelongsTo]; 716 return bdyRow.arg(strValueName).arg(strValue).arg(strMargin); 717 } 718 719 QString UIVMInfoDialog::formatStorageElement(const QString &strControllerName, 720 LONG iPort, LONG iDevice, 721 const QString &strBelongsTo) 722 { 723 if (m_session.isNull()) 724 return QString(); 725 726 QString strHeader = "<tr><td></td><td colspan=2><nobr> %1:</nobr></td></tr>"; 727 CStorageController ctr = m_session.GetMachine().GetStorageControllerByName(strControllerName); 728 QString strName = gpConverter->toString(StorageSlot(ctr.GetBus(), iPort, iDevice)); 729 730 return strHeader.arg(strName) + composeArticle(strBelongsTo, 2); 731 } 732 733 QString UIVMInfoDialog::formatNetworkElement(ULONG uSlot, 734 const QString &strBelongsTo) 735 { 736 if (m_session.isNull()) 737 return QString(); 738 739 QString strHeader = "<tr><td></td><td colspan=2><nobr>%1</nobr></td></tr>"; 740 QString strName = VBoxGlobal::tr("Adapter %1", "details report (network)").arg(uSlot + 1); 741 742 return strHeader.arg(strName) + composeArticle(strBelongsTo, 1); 743 } 744 745 QString UIVMInfoDialog::composeArticle(const QString &strBelongsTo, int iSpacesCount /* = 0 */) 746 { 747 QFontMetrics fm = QApplication::fontMetrics(); 748 749 QString strBody = "<tr><td></td><td width=50%><nobr>%1%2</nobr></td>" 750 "<td align=right><nobr>%3%4</nobr></td></tr>"; 751 QString strIndent; 752 for (int i = 0; i < iSpacesCount; ++i) 753 strIndent += " "; 754 strBody = strBody.arg(strIndent); 755 756 QString strResult; 757 758 if (m_links.contains(strBelongsTo)) 759 { 760 QStringList keys = m_links[strBelongsTo]; 727 761 foreach (const QString &key, keys) 728 762 { 729 QString line (body);730 if (m NamesMap.contains (key) && mValuesMap.contains (key) && mUnitsMap.contains(key))763 QString line(strBody); 764 if (m_names.contains(key) && m_values.contains(key) && m_units.contains(key)) 731 765 { 732 line = line.arg (mNamesMap [key]).arg (QString ("%L1").arg (mValuesMap [key].toULongLong())); 733 line = mUnitsMap [key].contains (QRegExp ("\\[\\S+\\]")) ? 734 line.arg (QString ("<img src=:/tpixel.png width=%1 height=1>") 735 .arg (QApplication::fontMetrics().width ( 736 QString (" %1").arg (mUnitsMap [key] 737 .mid (1, mUnitsMap [key].length() - 2))))) : 738 line.arg (QString (" %1").arg (mUnitsMap [key])); 739 result += line; 766 line = line.arg(m_names[key]).arg(QString("%L1").arg(m_values[key].toULongLong())); 767 line = m_units[key].contains(QRegExp("\\[\\S+\\]")) ? 768 line.arg(QString("<img src=:/tpixel.png width=%1 height=1>") 769 .arg(fm.width(QString(" %1").arg(m_units[key].mid(1, m_units[key].length() - 2))))) : 770 line.arg(QString (" %1").arg(m_units[key])); 771 strResult += line; 740 772 } 741 773 } 742 774 } 743 775 else 744 result = body.arg (aBelongsTo).arg (QString::null).arg (QString::null); 745 746 return result; 747 } 776 strResult = strBody.arg(strBelongsTo).arg(QString()).arg(QString()); 777 778 return strResult; 779 } 780 -
trunk/src/VBox/Frontends/VirtualBox/src/UIVMInfoDialog.h
r51305 r51308 40 40 public: 41 41 42 /** Instance pointer map. */43 typedef QMap <QString, UIVMInfoDialog*> InfoDlgMap;44 45 42 /** VM statistics counter data map. */ 46 43 typedef QMap <QString, QString> DataMapType; … … 50 47 struct CounterElementType { QString type; DataMapType list; }; 51 48 52 /** Factory function to create information-dialog for passed @a pMachineWindow. */ 53 static void createInformationDlg(UIMachineWindow *pMachineWindow); 49 /** Shows (and creates if necessary) 50 * information-dialog for passed @a pMachineWindow. */ 51 static void invoke(UIMachineWindow *pMachineWindow); 54 52 55 53 protected: … … 64 62 65 63 /** Common event-handler. */ 66 virtual bool event (QEvent *aEvent);64 virtual bool event(QEvent *pEvent); 67 65 /** Resize event-handler. */ 68 virtual void resizeEvent (QResizeEvent *aEvent);66 virtual void resizeEvent(QResizeEvent *pEvent); 69 67 /** Show event-handler. */ 70 virtual void showEvent (QShowEvent *aEvent);68 virtual void showEvent(QShowEvent *pEvent); 71 69 72 70 private slots: 73 71 74 72 /** Slot to update general VM details. */ 75 void updateDetails();73 void sltUpdateDetails(); 76 74 /** Slot to update runtime VM statistics. */ 77 void processStatistics();75 void sltProcessStatistics(); 78 76 /** Slot to handle tab-widget page change. */ 79 void onPageChanged (int aIndex);77 void sltHandlePageChanged(int iIndex); 80 78 81 79 private: 82 80 83 81 /** Helper to parse passed VM statistics @a aText. */ 84 QString parseStatistics (const QString &aText);82 QString parseStatistics(const QString &strText); 85 83 /** Helper to re-acquire whole VM statistics. */ 86 84 void refreshStatistics(); 87 85 88 86 /** Helper to format common VM statistics value. */ 89 QString formatValue (const QString &aValueName, const QString &aValue, int aMaxSize);90 /** Helper to format VM storage- mediumstatistics value. */91 QString format Medium (const QString &aCtrName, LONG aPort, LONG aDevice, const QString &aBelongsTo);92 /** Helper to format VM network- adapterstatistics value. */93 QString format Adapter (ULONG aSlot, const QString &aBelongsTo);87 QString formatValue(const QString &strValueName, const QString &strValue, int iMaxSize); 88 /** Helper to format VM storage-statistics value. */ 89 QString formatStorageElement(const QString &strCtrName, LONG iPort, LONG iDevice, const QString &strBelongsTo); 90 /** Helper to format VM network-statistics value. */ 91 QString formatNetworkElement(ULONG uSlot, const QString &strBelongsTo); 94 92 95 93 /** Helper to compose user-oriented article. */ 96 QString composeArticle (const QString &aBelongsTo, int aSpacesCount = 0);94 QString composeArticle(const QString &strBelongsTo, int iSpacesCount = 0); 97 95 98 96 /** @name General variables. 99 97 * @{ */ 100 /** Dialog instance array. */101 static InfoDlgMap mSelfArray;98 /** Dialog instance pointer. */ 99 static UIVMInfoDialog *m_spInstance; 102 100 /** Widget to center dialog according. */ 103 QWidget *m_pPseudoParentWidget;101 QWidget *m_pPseudoParentWidget; 104 102 /** Whether dialog was polished. */ 105 bool mIsPolished;103 bool m_fIsPolished; 106 104 /** @} */ 107 105 … … 109 107 * @{ */ 110 108 /** Current dialog width. */ 111 int m Width;109 int m_iWidth; 112 110 /** Current dialog height. */ 113 int m Height;111 int m_iHeight; 114 112 /** Whether dialog maximized. */ 115 bool m Max;113 bool m_fMax; 116 114 /** @} */ 117 115 … … 119 117 * @{ */ 120 118 /** Session to acquire VM details/statistics from. */ 121 CSession m Session;119 CSession m_session; 122 120 /** VM statistics update timer. */ 123 QTimer *m StatTimer;121 QTimer *m_pTimer; 124 122 /** VM statistics counter names. */ 125 DataMapType m NamesMap;123 DataMapType m_names; 126 124 /** VM statistics counter values. */ 127 DataMapType m ValuesMap;125 DataMapType m_values; 128 126 /** VM statistics counter units. */ 129 DataMapType m UnitsMap;127 DataMapType m_units; 130 128 /** VM statistics counter links. */ 131 LinksMapType m LinksMap;129 LinksMapType m_links; 132 130 /** @} */ 133 131 }; -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp
r51304 r51308 1383 1383 return; 1384 1384 1385 UIVMInfoDialog::createInformationDlg(mainMachineWindow()); 1385 /* Invoke VM information dialog: */ 1386 UIVMInfoDialog::invoke(mainMachineWindow()); 1386 1387 } 1387 1388
Note:
See TracChangeset
for help on using the changeset viewer.