Changeset 80341 in vbox
- Timestamp:
- Aug 19, 2019 11:11:27 AM (6 years ago)
- svn:sync-xref-src-repo-rev:
- 132802
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/runtime/information
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/runtime/information/UIInformationConfiguration.cpp
r77594 r80341 16 16 */ 17 17 18 /* COM includes: */ 19 18 20 /* Qt includes: */ 21 #include <QApplication> 22 #include <QHeaderView> 23 #include <QTableWidget> 19 24 #include <QVBoxLayout> 20 #include <QApplication>21 25 22 26 /* GUI includes: */ 27 #include "UICommon.h" 28 #include "UIExtraDataManager.h" 29 #include "UIIconPool.h" 23 30 #include "UIInformationConfiguration.h" 24 31 #include "UIInformationDataItem.h" 25 32 #include "UIInformationItem.h" 26 33 #include "UIInformationView.h" 27 #include "UIExtraDataManager.h"28 34 #include "UIInformationModel.h" 29 35 30 36 37 const unsigned iColumCount = 3; 38 39 class UIInformationTableRow 40 { 41 public: 42 43 UIInformationTableRow(UIInformationConfiguration::TableRow row); 44 ~UIInformationTableRow(); 45 46 QTableWidgetItem *addItem(unsigned iColumn, const QIcon &icon, const QString &strText); 47 QTableWidgetItem *addItem(unsigned iColumn, const QString &strText); 48 49 private: 50 51 QList<QTableWidgetItem*> m_items; 52 UIInformationConfiguration::TableRow m_enmRow; 53 }; 54 55 UIInformationTableRow::UIInformationTableRow(UIInformationConfiguration::TableRow enmRow) 56 : m_enmRow(enmRow) 57 { 58 m_items.reserve(iColumCount); 59 } 60 61 UIInformationTableRow::~UIInformationTableRow() 62 { 63 for (int i = 0; i < m_items.size(); ++i) 64 delete m_items[i]; 65 m_items.clear(); 66 } 67 68 69 QTableWidgetItem *UIInformationTableRow::addItem(unsigned iColumn, const QIcon &icon, const QString &strText) 70 { 71 if (iColumn >= iColumCount) 72 return 0; 73 /* Deallocate first if we have something on the column already: */ 74 if (m_items.size() > (int)iColumn && m_items[iColumn]) 75 delete m_items[iColumn]; 76 QTableWidgetItem *pItem = new QTableWidgetItem(icon, strText); 77 m_items.insert(iColumn, pItem); 78 return pItem; 79 } 80 81 QTableWidgetItem *UIInformationTableRow::addItem(unsigned iColumn, const QString &strText) 82 { 83 if (iColumn >= iColumCount) 84 return 0; 85 /* Deallocate first if we have something on the column already: */ 86 if (m_items.size() > (int)iColumn && m_items[iColumn]) 87 delete m_items[iColumn]; 88 QTableWidgetItem *pItem = new QTableWidgetItem(strText); 89 m_items.insert(iColumn, pItem); 90 return pItem; 91 } 92 31 93 UIInformationConfiguration::UIInformationConfiguration(QWidget *pParent, const CMachine &machine, const CConsole &console) 32 : Q Widget(pParent)94 : QIWithRetranslateUI<QWidget>(pParent) 33 95 , m_machine(machine) 34 96 , m_console(console) … … 36 98 , m_pModel(0) 37 99 , m_pView(0) 38 { 39 /* Prepare layout: */ 40 prepareLayout(); 41 100 , m_pTableWidget(0) 101 { 42 102 /* Prepare model: */ 43 103 prepareModel(); 44 104 45 105 /* Prepare view: */ 46 prepareView(); 47 } 48 49 void UIInformationConfiguration::prepareLayout() 50 { 51 /* Create layout: */ 52 m_pMainLayout = new QVBoxLayout(this); 53 AssertPtrReturnVoid(m_pMainLayout); 54 { 55 /* Configure layout: */ 56 m_pMainLayout->setSpacing(0); 57 } 106 prepareObjects(); 107 retranslateUi(); 108 createTableItems(); 109 } 110 111 UIInformationConfiguration::~UIInformationConfiguration() 112 { 113 qDeleteAll(m_rows); 114 m_rows.clear(); 115 } 116 117 void UIInformationConfiguration::retranslateUi() 118 { 119 m_strGeneralTitle = QApplication::translate("UIVMInformationDialog", "General"); 120 m_strGeneralName = QApplication::translate("UIVMInformationDialog", "Name"); 121 m_strGeneralOSType = QApplication::translate("UIVMInformationDialog", "Operating System"); 122 m_strSystemTitle = QApplication::translate("UIVMInformationDialog", "System"); 123 m_strError = QApplication::translate("UIVMInformationDialog", "Not Detected"); 58 124 } 59 125 … … 138 204 } 139 205 140 void UIInformationConfiguration::prepareView() 141 { 206 void UIInformationConfiguration::prepareObjects() 207 { 208 /* Create layout: */ 209 m_pMainLayout = new QVBoxLayout(this); 210 if (!m_pMainLayout) 211 return; 212 m_pMainLayout->setSpacing(0); 213 214 142 215 /* Create information-view: */ 143 216 m_pView = new UIInformationView; … … 162 235 m_pMainLayout->addWidget(m_pView); 163 236 } 164 } 237 238 m_pTableWidget = new QTableWidget; 239 240 if (m_pTableWidget) 241 { 242 /* Configure the table by hiding the headers etc.: */ 243 m_pTableWidget->setRowCount(TableRow_Max); 244 m_pTableWidget->setColumnCount(3); 245 m_pTableWidget->verticalHeader()->hide(); 246 m_pTableWidget->horizontalHeader()->hide(); 247 //m_pTableWidget->setShowGrid(false); 248 m_pMainLayout->addWidget(m_pTableWidget); 249 m_pTableWidget->hide(); 250 } 251 } 252 253 void UIInformationConfiguration::updateTable() 254 { 255 } 256 257 void UIInformationConfiguration::createTableItems() 258 { 259 if (!m_pTableWidget) 260 return; 261 QFontMetrics fontMetrics(m_pTableWidget->font()); 262 263 int iMaxColumn1Length = 0; 264 265 /* General Section: */ 266 insertTitleRow(TableRow_General_Title, m_strGeneralTitle, UIIconPool::iconSet(":/machine_16px.png")); 267 QString strMachineName = m_machine.isNull() ? m_strError : m_machine.GetName(); 268 insertInfoRow(TableRow_General_Name, m_strGeneralName, strMachineName, fontMetrics, iMaxColumn1Length); 269 QString strOSTypeName; 270 if (!m_console.isNull()) 271 { 272 CGuest comGuest = m_console.GetGuest(); 273 if (!comGuest.isNull()) 274 strOSTypeName = uiCommon().vmGuestOSTypeDescription(comGuest.GetOSTypeId()); 275 } 276 if (strOSTypeName.isEmpty()) 277 strOSTypeName = m_strError; 278 insertInfoRow(TableRow_General_OSType, m_strGeneralOSType, strOSTypeName, fontMetrics, iMaxColumn1Length); 279 insertTitleRow(TableRow_System_Title, m_strSystemTitle, UIIconPool::iconSet(":/chipset_16px.png")); 280 281 282 m_pTableWidget->resizeColumnToContents(0); 283 //m_pTableWidget->resizeColumnToContents(1); 284 m_pTableWidget->setColumnWidth(1, 1.5 * iMaxColumn1Length); 285 m_pTableWidget->resizeColumnToContents(2); 286 287 } 288 289 void UIInformationConfiguration::insertTitleRow(TableRow enmRow, const QString &strTitle, const QIcon &icon) 290 { 291 UIInformationTableRow *pRow = new UIInformationTableRow(enmRow); 292 m_rows.insert(enmRow, pRow); 293 m_pTableWidget->setItem(enmRow, 0, pRow->addItem(0, icon, "")); 294 QTableWidgetItem *pItem = pRow->addItem(1, strTitle); 295 QFont font = pItem->font(); 296 font.setBold(true); 297 pItem->setFont(font); 298 m_pTableWidget->setItem(enmRow, 1, pItem); 299 } 300 301 void UIInformationConfiguration::insertInfoRow(TableRow enmRow, const QString &strColumn1, const QString &strColumn2, 302 QFontMetrics &fontMetrics, int &iMaxColumn1Length) 303 { 304 UIInformationTableRow *pRow = new UIInformationTableRow(enmRow); 305 m_rows.insert(enmRow, pRow); 306 m_pTableWidget->setItem(enmRow, 1, pRow->addItem(1, strColumn1)); 307 m_pTableWidget->setItem(enmRow, 2, pRow->addItem(1, strColumn2)); 308 iMaxColumn1Length = qMax(iMaxColumn1Length, fontMetrics.width(strColumn1)); 309 } -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/information/UIInformationConfiguration.h
r76581 r80341 27 27 /* COM includes: */ 28 28 #include "COMEnums.h" 29 #include "CGuest.h" 30 29 31 #include "CMachine.h" 30 32 #include "CConsole.h" 33 34 /* GUI includes: */ 35 #include "QIWithRetranslateUI.h" 31 36 32 37 /* Forward declarations: */ … … 34 39 class UIInformationView; 35 40 class UIInformationModel; 36 41 class QTableWidget; 42 class QTableWidgetItem; 43 class UIInformationTableRow; 37 44 38 45 /** QWidget extension 39 46 * providing GUI with configuration-information tab in session-information window. */ 40 class UIInformationConfiguration : public Q Widget47 class UIInformationConfiguration : public QIWithRetranslateUI<QWidget> 41 48 { 42 49 Q_OBJECT; … … 44 51 public: 45 52 53 enum TableRow 54 { 55 TableRow_General_Title = 0, 56 TableRow_General_Name, 57 TableRow_General_OSType, 58 TableRow_System_Title, 59 TableRow_Max 60 }; 61 46 62 /** Constructs information-tab passing @a pParent to the QWidget base-class constructor. 47 63 * @param machine is machine reference. 48 64 * @param console is machine console reference. */ 49 65 UIInformationConfiguration(QWidget *pParent, const CMachine &machine, const CConsole &console); 66 ~UIInformationConfiguration(); 67 68 protected: 69 70 void retranslateUi() /* override */; 50 71 51 72 private: 52 53 /** Prepares layout. */54 void prepareLayout();55 56 73 /** Prepares model. */ 57 74 void prepareModel(); 75 void prepareObjects(); 76 void createTableItems(); 58 77 59 /** Prepares view. */ 60 void prepareView(); 78 void updateTable(); 79 void insertTitleRow(TableRow enmRow, const QString &strTitle, const QIcon &icon); 80 void insertInfoRow(TableRow enmRow, const QString &strColumn1, const QString &strColumn2, 81 QFontMetrics &fontMetrics, int &iMaxColumn1Length); 61 82 62 83 /** Holds the machine instance. */ … … 70 91 /** Holds the instance of view we create. */ 71 92 UIInformationView *m_pView; 93 QTableWidget *m_pTableWidget; 94 QMap<TableRow, UIInformationTableRow*> m_rows; 95 96 /** @name Cached translated string. 97 * @{ */ 98 QString m_strError; 99 100 /** General section. */ 101 QString m_strGeneralTitle; 102 QString m_strGeneralName; 103 QString m_strGeneralOSType; 104 /** System section. */ 105 QString m_strSystemTitle; 106 107 /** @} */ 108 72 109 }; 73 110 74 111 #endif /* !FEQT_INCLUDED_SRC_runtime_information_UIInformationConfiguration_h */ 75 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/information/UIPerformanceMonitor.h
r80330 r80341 139 139 /** @} */ 140 140 141 /** @name These metric names are used for map keys to identify metrics.141 /** @name Cached translated string. 142 142 * @{ */ 143 143 /** CPU info label strings. */ -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/information/UIVMInformationDialog.cpp
r80162 r80341 271 271 272 272 /* Set Runtime Information tab as default: */ 273 m_pTabWidget->setCurrentIndex( 1);273 m_pTabWidget->setCurrentIndex(0); 274 274 275 275 /* Assign tab-widget page change handler: */
Note:
See TracChangeset
for help on using the changeset viewer.