- Timestamp:
- Jan 13, 2017 3:45:43 PM (8 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/runtime/information
- Files:
-
- 2 edited
-
UIInformationDataItem.cpp (modified) (34 diffs)
-
UIInformationDataItem.h (modified) (17 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/runtime/information/UIInformationDataItem.cpp
r65285 r65287 25 25 26 26 /* GUI includes: */ 27 # include "VBoxGlobal.h" 27 28 # include "UIMachine.h" 28 29 # include "UISession.h" 29 # include "UIIconPool.h"30 # include "VBoxGlobal.h"31 30 # include "UIConverter.h" 32 # include "UIMessageCenter.h"33 31 # include "UIInformationItem.h" 34 32 # include "UIInformationModel.h" 35 33 # include "UIInformationDataItem.h" 36 # include "UIGraphicsRotatorButton.h"37 34 38 35 /* COM includes: */ 39 # include "COMEnums.h"40 36 # include "CMedium.h" 41 # include "C Machine.h"37 # include "CSerialPort.h" 42 38 # include "CVRDEServer.h" 43 # include "CSerialPort.h"44 39 # include "CAudioAdapter.h" 45 40 # include "CParallelPort.h" … … 50 45 # include "CUSBDeviceFilter.h" 51 46 # include "CMediumAttachment.h" 47 # include "CSystemProperties.h" 52 48 # include "CUSBDeviceFilters.h" 53 # include "CSystemProperties.h"54 49 # include "CStorageController.h" 55 50 56 /* Other VBox includes: */57 # include <iprt/time.h>58 59 51 #endif /* !VBOX_WITH_PRECOMPILED_HEADERS */ 60 52 … … 64 56 *********************************************************************************************************************************/ 65 57 66 UIInformationDataItem::UIInformationDataItem(InformationElementType type, const CMachine &machine, const CConsole &console, UIInformationModel *pModel)67 : m_ type(type)58 UIInformationDataItem::UIInformationDataItem(InformationElementType enmType, const CMachine &machine, const CConsole &console, UIInformationModel *pModel) 59 : m_enmType(enmType) 68 60 , m_machine(machine) 69 61 , m_console(console) … … 72 64 } 73 65 74 UIInformationDataItem::~UIInformationDataItem() 75 { 76 } 77 78 QVariant UIInformationDataItem::data(const QModelIndex &index, int role) const 79 { 80 RT_NOREF(index); 81 82 /* For particular role: */ 83 switch (role) 84 { 85 case Qt::DisplayRole: 86 { 87 return gpConverter->toString(m_type); 88 } 89 break; 90 91 case Qt::UserRole + 2: 92 { 93 return m_type; 94 } 95 break; 96 97 default: 98 break; 66 QVariant UIInformationDataItem::data(const QModelIndex & /* index */, int role) const 67 { 68 /* For particular role: */ 69 switch (role) 70 { 71 case Qt::DisplayRole: return gpConverter->toString(m_enmType); 72 case Qt::UserRole + 2: return m_enmType; 73 default: break; 99 74 } 100 75 … … 122 97 return QString(":/machine_16px.png"); 123 98 } 124 break;125 99 126 100 case Qt::UserRole + 1: … … 131 105 return QVariant::fromValue(p_text); 132 106 } 133 break; 134 135 default: 136 break; 107 108 default: 109 break; 137 110 } 138 111 … … 160 133 return QString(":/chipset_16px.png"); 161 134 } 162 break;163 135 164 136 case Qt::UserRole + 1: … … 226 198 return QVariant::fromValue(p_text); 227 199 } 228 break; 229 230 default: 231 break; 200 201 default: 202 break; 232 203 } 233 204 … … 255 226 return QString(":/vrdp_16px.png"); 256 227 } 257 break; 258 259 case Qt::UserRole+1: 228 229 case Qt::UserRole + 1: 260 230 { 261 231 UITextTable p_text; … … 291 261 return QVariant::fromValue(p_text); 292 262 } 293 break; 294 295 default: 296 break; 263 264 default: 265 break; 297 266 } 298 267 … … 316 285 switch (role) 317 286 { 318 319 287 case Qt::DecorationRole: 320 288 { 321 289 return QString(":/hd_16px.png"); 322 290 } 323 break; 324 325 case Qt::UserRole+1: 291 292 case Qt::UserRole + 1: 326 293 { 327 294 UITextTable p_text; … … 361 328 return QVariant::fromValue(p_text); 362 329 } 363 break; 364 365 default: 366 break; 330 331 default: 332 break; 367 333 } 368 334 … … 390 356 return QString(":/sound_16px.png"); 391 357 } 392 break;393 358 394 359 case Qt::UserRole + 1: … … 405 370 return QVariant::fromValue(p_text); 406 371 } 407 break; 408 409 default: 410 break; 372 373 default: 374 break; 411 375 } 412 376 … … 434 398 return QString(":/nw_16px.png"); 435 399 } 436 break; 437 438 case Qt::UserRole+1: 400 401 case Qt::UserRole + 1: 439 402 { 440 403 UITextTable p_text; … … 447 410 { 448 411 KNetworkAttachmentType type = adapter.GetAttachmentType(); 449 QString attType = gpConverter->toString (adapter.GetAdapterType())450 .replace (QRegExp ("\\s\\(.+\\)"), " (%1)");412 QString attType = gpConverter->toString(adapter.GetAdapterType()) 413 .replace(QRegExp ("\\s\\(.+\\)"), " (%1)"); 451 414 /* don't use the adapter type string for types that have 452 415 * an additional symbolic network/interface name field, use 453 416 * this name instead */ 454 417 if (type == KNetworkAttachmentType_Bridged) 455 attType = attType.arg (tr("Bridged adapter, %1",456 "details report (network)").arg (adapter.GetBridgedInterface()));418 attType = attType.arg(tr("Bridged adapter, %1", 419 "details report (network)").arg(adapter.GetBridgedInterface())); 457 420 else if (type == KNetworkAttachmentType_Internal) 458 attType = attType.arg (tr("Internal network, '%1'",459 "details report (network)").arg (adapter.GetInternalNetwork()));421 attType = attType.arg(tr("Internal network, '%1'", 422 "details report (network)").arg(adapter.GetInternalNetwork())); 460 423 else if (type == KNetworkAttachmentType_HostOnly) 461 attType = attType.arg (tr("Host-only adapter, '%1'",462 "details report (network)").arg (adapter.GetHostOnlyInterface()));424 attType = attType.arg(tr("Host-only adapter, '%1'", 425 "details report (network)").arg(adapter.GetHostOnlyInterface())); 463 426 else if (type == KNetworkAttachmentType_Generic) 464 attType = attType.arg (tr("Generic, '%1'",465 "details report (network)").arg (adapter.GetGenericDriver()));427 attType = attType.arg(tr("Generic, '%1'", 428 "details report (network)").arg(adapter.GetGenericDriver())); 466 429 else if (type == KNetworkAttachmentType_NATNetwork) 467 attType = attType.arg (tr("NAT network, '%1'",468 "details report (network)").arg (adapter.GetNATNetwork()));430 attType = attType.arg(tr("NAT network, '%1'", 431 "details report (network)").arg(adapter.GetNATNetwork())); 469 432 else 470 attType = attType.arg (gpConverter->toString(type));433 attType = attType.arg(gpConverter->toString(type)); 471 434 472 435 p_text << UITextTableLine(tr("Adapter %1", "details report (network)").arg(adapter.GetSlot() + 1), attType); … … 476 439 return QVariant::fromValue(p_text); 477 440 } 478 break; 479 480 default: 481 break; 441 442 default: 443 break; 482 444 } 483 445 … … 505 467 return QString(":/serial_port_16px.png"); 506 468 } 507 break;508 469 509 470 case Qt::UserRole + 1: … … 514 475 for (ulong slot = 0; slot < count; slot++) 515 476 { 516 CSerialPort port = m_machine.GetSerialPort (slot);477 CSerialPort port = m_machine.GetSerialPort(slot); 517 478 if (port.GetEnabled()) 518 479 { 519 480 KPortMode mode = port.GetHostMode(); 520 QString data = vboxGlobal().toCOMPortName (port.GetIRQ(), port.GetIOBase()) + ", ";481 QString data = vboxGlobal().toCOMPortName(port.GetIRQ(), port.GetIOBase()) + ", "; 521 482 if (mode == KPortMode_HostPipe || 522 483 mode == KPortMode_HostDevice || 523 484 mode == KPortMode_TCP || 524 485 mode == KPortMode_RawFile) 525 data += QString ("%1 (<nobr>%2</nobr>)")526 .arg (gpConverter->toString(mode))527 .arg (QDir::toNativeSeparators(port.GetPath()));486 data += QString("%1 (<nobr>%2</nobr>)") 487 .arg(gpConverter->toString(mode)) 488 .arg(QDir::toNativeSeparators(port.GetPath())); 528 489 else 529 490 data += gpConverter->toString(mode); … … 535 496 return QVariant::fromValue(p_text); 536 497 } 537 break; 538 539 default: 540 break; 498 499 default: 500 break; 541 501 } 542 502 … … 565 525 return QString(":/parallel_port_16px.png"); 566 526 } 567 break;568 527 569 528 case Qt::UserRole + 1: … … 575 534 if (port.GetEnabled()) 576 535 { 577 QString data = vboxGlobal().toLPTPortName (port.GetIRQ(), port.GetIOBase()) +578 QString (" (<nobr>%1</nobr>)")579 .arg (QDir::toNativeSeparators(port.GetPath()));536 QString data = vboxGlobal().toLPTPortName(port.GetIRQ(), port.GetIOBase()) + 537 QString(" (<nobr>%1</nobr>)") 538 .arg(QDir::toNativeSeparators(port.GetPath())); 580 539 p_text << UITextTableLine(tr("Port %1", "details report (parallel ports)").arg(port.GetSlot() + 1), data); 581 540 } … … 584 543 p_text << UITextTableLine(tr("Disabled", "details report (parallel ports)"), QString()); 585 544 } 586 break; 587 588 default: 589 break; 545 546 default: 547 break; 590 548 } 591 549 return QVariant(); … … 612 570 return QString(":/usb_16px.png"); 613 571 } 614 break;615 572 616 573 case Qt::UserRole + 1: … … 634 591 635 592 p_text << UITextTableLine(tr("Device Filters", "details report (USB)"), tr("%1 (%2 active)", "details report (USB)") 636 .arg(coll.size()).arg(active));593 .arg(coll.size()).arg(active)); 637 594 } 638 595 } 639 596 } 640 break; 641 642 default: 643 break; 597 598 default: 599 break; 644 600 } 645 601 … … 668 624 return QString(":/sf_16px.png"); 669 625 } 670 break;671 626 672 627 case Qt::UserRole + 1: … … 680 635 return QVariant::fromValue(p_text); 681 636 } 682 break; 683 684 default: 685 break; 637 638 default: 639 break; 686 640 } 687 641 … … 714 668 return QString(":/state_running_16px.png"); 715 669 } 716 break;717 670 718 671 case Qt::UserRole + 1: … … 833 786 return QVariant::fromValue(p_text); 834 787 } 835 break; 836 837 default: 838 break; 788 789 default: 790 break; 839 791 } 840 792 … … 888 840 } 889 841 890 m_pTimer = new QTimer(this);842 m_pTimer = new QTimer(this); 891 843 892 844 connect(m_pTimer, SIGNAL(timeout()), this, SLOT(sltProcessStatistics())); … … 906 858 return QString(":/nw_16px.png"); 907 859 } 908 break;909 860 910 861 case Qt::UserRole + 1: … … 928 879 return QVariant::fromValue(p_text); 929 880 } 930 break; 931 932 default: 933 break; 881 882 default: 883 break; 934 884 } 935 885 … … 1103 1053 return QString(":/hd_16px.png"); 1104 1054 } 1105 break;1106 1055 1107 1056 case Qt::UserRole + 1: … … 1167 1116 return QVariant::fromValue(p_text); 1168 1117 } 1169 break; 1170 1171 default: 1172 break; 1118 1119 default: 1120 break; 1173 1121 } 1174 1122 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/information/UIInformationDataItem.h
r65285 r65287 24 24 25 25 /* GUI includes: */ 26 #include "UIThreadPool.h"27 26 #include "UIExtraDataDefs.h" 28 #include "UIInformationDataItem.h"29 27 30 28 /* COM includes: */ 31 29 #include "COMEnums.h" 32 #include "CGuest.h"33 30 #include "CMachine.h" 34 31 #include "CConsole.h" 35 #include "CDisplay.h"36 #include "CNetworkAdapter.h"37 #include "CMachineDebugger.h"38 #include "CMediumAttachment.h"39 #include "CSystemProperties.h"40 #include "CStorageController.h"41 32 42 33 /* Forward declarations: */ 43 class CNetworkAdapter;44 class QTextLayout;45 34 class UIInformationModel; 46 35 … … 54 43 public: 55 44 56 /** Constructs information data-item of type @a type. 57 * @param machine Brings the machine reference. 58 * @param console Brings the machine console reference. 59 * @param pModel Brings the information model this item belings to. */ 60 UIInformationDataItem(InformationElementType type, const CMachine &machine, const CConsole &console, UIInformationModel *pModel); 61 62 /** Destructs information data-item. */ 63 ~UIInformationDataItem(); 45 /** Constructs information data-item of type @a enmType. 46 * @param machine Brings the machine reference. 47 * @param console Brings the machine console reference. 48 * @param pModel Brings the information model this item belings to. */ 49 UIInformationDataItem(InformationElementType enmType, const CMachine &machine, const CConsole &console, UIInformationModel *pModel); 64 50 65 51 /** Returns type of information data-item. */ 66 InformationElementType elementType() const { return m_ type; }67 68 /** Returns data for item specified by @a index for the @a role. */69 virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;52 InformationElementType elementType() const { return m_enmType; } 53 54 /** Returns data for item specified by @a index for the @a iRole. */ 55 virtual QVariant data(const QModelIndex &index, int iRole = Qt::DisplayRole) const; 70 56 71 57 protected: 72 58 73 59 /** Holds the type of information data-item. */ 74 InformationElementType m_ type;60 InformationElementType m_enmType; 75 61 76 62 /** Holds the pixmap of information data-item. */ … … 104 90 UIInformationDataGeneral(const CMachine &machine, const CConsole &console, UIInformationModel *pModel); 105 91 106 /** Returns data for item specified by @a index for the @a role. */107 virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;92 /** Returns data for item specified by @a index for the @a iRole. */ 93 virtual QVariant data(const QModelIndex &index, int iRole = Qt::DisplayRole) const; 108 94 }; 109 95 … … 122 108 UIInformationDataSystem(const CMachine &machine, const CConsole &console, UIInformationModel *pModel); 123 109 124 /** Returns data for item specified by @a index for the @a role. */125 virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;110 /** Returns data for item specified by @a index for the @a iRole. */ 111 virtual QVariant data(const QModelIndex &index, int iRole = Qt::DisplayRole) const; 126 112 }; 127 113 … … 140 126 UIInformationDataDisplay(const CMachine &machine, const CConsole &console, UIInformationModel *pModel); 141 127 142 /** Returns data for item specified by @a index for the @a role. */143 virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;128 /** Returns data for item specified by @a index for the @a iRole. */ 129 virtual QVariant data(const QModelIndex &index, int iRole = Qt::DisplayRole) const; 144 130 }; 145 131 … … 158 144 UIInformationDataStorage(const CMachine &machine, const CConsole &console, UIInformationModel *pModel); 159 145 160 /** Returns data for item specified by @a index for the @a role. */161 virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;146 /** Returns data for item specified by @a index for the @a iRole. */ 147 virtual QVariant data(const QModelIndex &index, int iRole = Qt::DisplayRole) const; 162 148 }; 163 149 … … 176 162 UIInformationDataAudio(const CMachine &machine, const CConsole &console, UIInformationModel *pModel); 177 163 178 /** Returns data for item specified by @a index for the @a role. */179 virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;164 /** Returns data for item specified by @a index for the @a iRole. */ 165 virtual QVariant data(const QModelIndex &index, int iRole = Qt::DisplayRole) const; 180 166 }; 181 167 … … 194 180 UIInformationDataNetwork(const CMachine &machine, const CConsole &console, UIInformationModel *pModel); 195 181 196 /** Returns data for item specified by @a index for the @a role. */197 virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;182 /** Returns data for item specified by @a index for the @a iRole. */ 183 virtual QVariant data(const QModelIndex &index, int iRole = Qt::DisplayRole) const; 198 184 }; 199 185 … … 212 198 UIInformationDataSerialPorts(const CMachine &machine, const CConsole &console, UIInformationModel *pModel); 213 199 214 /** Returns data for item specified by @a index for the @a role. */215 virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;200 /** Returns data for item specified by @a index for the @a iRole. */ 201 virtual QVariant data(const QModelIndex &index, int iRole = Qt::DisplayRole) const; 216 202 }; 217 203 … … 231 217 UIInformationDataParallelPorts(const CMachine &machine, const CConsole &console, UIInformationModel *pModel); 232 218 233 /** Returns data for item specified by @a index for the @a role. */234 virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;219 /** Returns data for item specified by @a index for the @a iRole. */ 220 virtual QVariant data(const QModelIndex &index, int iRole = Qt::DisplayRole) const; 235 221 }; 236 222 #endif /* VBOX_WITH_PARALLEL_PORTS */ … … 250 236 UIInformationDataUSB(const CMachine &machine, const CConsole &console, UIInformationModel *pModel); 251 237 252 /** Returns data for item specified by @a index for the @a role. */253 virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;238 /** Returns data for item specified by @a index for the @a iRole. */ 239 virtual QVariant data(const QModelIndex &index, int iRole = Qt::DisplayRole) const; 254 240 }; 255 241 … … 268 254 UIInformationDataSharedFolders(const CMachine &machine, const CConsole &console, UIInformationModel *pModel); 269 255 270 /** Returns data for item specified by @a index for the @a role. */271 virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;256 /** Returns data for item specified by @a index for the @a iRole. */ 257 virtual QVariant data(const QModelIndex &index, int iRole = Qt::DisplayRole) const; 272 258 273 259 protected slots: … … 291 277 UIInformationDataRuntimeAttributes(const CMachine &machine, const CConsole &console, UIInformationModel *pModel); 292 278 293 /** Returns data for item specified by @a index for the @a role. */294 virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;279 /** Returns data for item specified by @a index for the @a iRole. */ 280 virtual QVariant data(const QModelIndex &index, int iRole = Qt::DisplayRole) const; 295 281 }; 296 282 … … 309 295 UIInformationDataNetworkStatistics(const CMachine &machine, const CConsole &console, UIInformationModel *pModel); 310 296 311 /** Returns data for item specified by @a index for the @a role. */312 virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;297 /** Returns data for item specified by @a index for the @a iRole. */ 298 virtual QVariant data(const QModelIndex &index, int iRole = Qt::DisplayRole) const; 313 299 314 300 private slots: … … 323 309 324 310 /** VM statistics counter data map. */ 325 typedef QMap <QString, QString> DataMapType;311 typedef QMap<QString, QString> DataMapType; 326 312 /** VM statistics counter links map. */ 327 typedef QMap <QString, QStringList> LinksMapType;313 typedef QMap<QString, QStringList> LinksMapType; 328 314 /** VM statistics counter struct. */ 329 315 struct CounterElementType { QString type; DataMapType list; }; 330 316 331 317 /** Holds the VM statistics counter names. */ 332 DataMapType m_names;318 DataMapType m_names; 333 319 /** Holds the VM statistics counter values. */ 334 DataMapType m_values;320 DataMapType m_values; 335 321 /** Holds the VM statistics counter units. */ 336 DataMapType m_units;322 DataMapType m_units; 337 323 /** Holds the VM statistics counter links. */ 338 LinksMapType m_links;324 LinksMapType m_links; 339 325 /** Holds the VM statistics update timer instance. */ 340 QTimer *m_pTimer;326 QTimer *m_pTimer; 341 327 }; 342 328 … … 355 341 UIInformationDataStorageStatistics(const CMachine &machine, const CConsole &console, UIInformationModel *pModel); 356 342 357 /** Returns data for item specified by @a index for the @a role. */358 virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;343 /** Returns data for item specified by @a index for the @a iRole. */ 344 virtual QVariant data(const QModelIndex &index, int iRole = Qt::DisplayRole) const; 359 345 360 346 private slots: … … 372 358 373 359 /** VM statistics counter data map. */ 374 typedef QMap <QString, QString> DataMapType;360 typedef QMap<QString, QString> DataMapType; 375 361 /** VM statistics counter links map. */ 376 typedef QMap <QString, QStringList> LinksMapType;362 typedef QMap<QString, QStringList> LinksMapType; 377 363 /** VM statistics counter struct. */ 378 364 struct CounterElementType { QString type; DataMapType list; }; 379 365 380 366 /** Holds the VM statistics counter names. */ 381 DataMapType m_names;367 DataMapType m_names; 382 368 /** Holds the VM statistics counter values. */ 383 DataMapType m_values;369 DataMapType m_values; 384 370 /** Holds the VM statistics counter units. */ 385 DataMapType m_units;371 DataMapType m_units; 386 372 /** Holds the VM statistics counter links. */ 387 LinksMapType m_links;373 LinksMapType m_links; 388 374 /** Holds the VM statistics update timer instance. */ 389 QTimer *m_pTimer;375 QTimer *m_pTimer; 390 376 }; 391 377
Note:
See TracChangeset
for help on using the changeset viewer.

