Changeset 85891 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Aug 26, 2020 4:56:11 PM (4 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/runtime/information
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/runtime/information/UIInformationRuntime.cpp
r82968 r85891 17 17 18 18 /* Qt includes: */ 19 #include <QAction> 19 20 #include <QApplication> 21 #include <QClipboard> 20 22 #include <QHeaderView> 23 #include <QMenu> 21 24 #include <QVBoxLayout> 22 25 #include <QTableWidget> … … 70 73 void updateClipboardMode(KClipboardMode enmMode = KClipboardMode_Max); 71 74 void updateDnDMode(KDnDMode enmMode = KDnDMode_Max); 75 QString tableData(); 72 76 73 77 protected: … … 143 147 , m_pTimer(0) 144 148 { 149 setContextMenuPolicy(Qt::CustomContextMenu); 145 150 setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); 146 151 setAlternatingRowColors(true); … … 411 416 } 412 417 418 QString UIRuntimeInfoWidget::tableData() 419 { 420 QStringList stringData; 421 for (int i = 0; i < rowCount(); ++i) 422 { 423 /* Skip the first column as it is used for icon: */ 424 for (int j = 1; j < columnCount(); ++j) 425 { 426 QTableWidgetItem *pItem = item(i, j); 427 if (!pItem || pItem->text().isEmpty()) 428 continue; 429 stringData << pItem->text(); 430 if (j == 1) 431 stringData << ": "; 432 } 433 stringData << "\n"; 434 } 435 return stringData.join(QString()); 436 } 437 438 413 439 void UIRuntimeInfoWidget::updateInfoRow(InfoRow enmLine, const QString &strColumn0, const QString &strColumn1) 414 440 { … … 464 490 , m_pMainLayout(0) 465 491 , m_pRuntimeInfoWidget(0) 492 , m_pCopyWholeTableAction(0) 466 493 { 467 494 if (!m_console.isNull()) … … 479 506 void UIInformationRuntime::retranslateUi() 480 507 { 508 if (m_pCopyWholeTableAction) 509 m_pCopyWholeTableAction->setText(QApplication::translate("UIVMInformationDialog", "Copy All")); 481 510 } 482 511 … … 489 518 490 519 m_pRuntimeInfoWidget = new UIRuntimeInfoWidget(0, m_machine, m_console); 520 AssertReturnVoid(m_pRuntimeInfoWidget); 521 connect(m_pRuntimeInfoWidget, &UIRuntimeInfoWidget::customContextMenuRequested, 522 this, &UIInformationRuntime::sltHandleTableContextMenuRequest); 491 523 m_pMainLayout->addWidget(m_pRuntimeInfoWidget); 492 524 m_pRuntimeInfoWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding); 525 526 m_pCopyWholeTableAction = new QAction(this); 527 connect(m_pCopyWholeTableAction, &QAction::triggered, this, &UIInformationRuntime::sltHandleCopyWholeTable); 493 528 } 494 529 … … 525 560 } 526 561 562 void UIInformationRuntime::sltHandleTableContextMenuRequest(const QPoint &position) 563 { 564 if (!m_pCopyWholeTableAction) 565 return; 566 567 QMenu menu(this); 568 menu.addAction(m_pCopyWholeTableAction); 569 menu.exec(mapToGlobal(position)); 570 } 571 572 void UIInformationRuntime::sltHandleCopyWholeTable() 573 { 574 QClipboard *pClipboard = QApplication::clipboard(); 575 if (!pClipboard) 576 return; 577 if (!m_pRuntimeInfoWidget) 578 return; 579 580 pClipboard->setText(m_pRuntimeInfoWidget->tableData(), QClipboard::Clipboard); 581 } 582 527 583 #include "UIInformationRuntime.moc" -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/information/UIInformationRuntime.h
r82968 r85891 35 35 36 36 /* Forward declarations: */ 37 class QAction; 37 38 class QVBoxLayout; 38 39 class UISession; … … 66 67 void sltDnDModeChange(KDnDMode enmMode); 67 68 /** @} */ 69 void sltHandleTableContextMenuRequest(const QPoint &position); 70 void sltHandleCopyWholeTable(); 68 71 69 72 private: … … 78 81 QVBoxLayout *m_pMainLayout; 79 82 UIRuntimeInfoWidget *m_pRuntimeInfoWidget; 83 QAction *m_pCopyWholeTableAction; 80 84 }; 81 85
Note:
See TracChangeset
for help on using the changeset viewer.