Changeset 80343 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Aug 19, 2019 2:11:04 PM (6 years ago)
- svn:sync-xref-src-repo-rev:
- 132804
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/runtime/information
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/runtime/information/UIInformationConfiguration.cpp
r80342 r80343 22 22 #include <QHeaderView> 23 23 #include <QTableWidget> 24 #include <QTextDocument> 24 25 #include <QVBoxLayout> 25 26 26 27 /* GUI includes: */ 28 #include "UIDetailsGenerator.h" 27 29 #include "UICommon.h" 28 30 #include "UIExtraDataManager.h" … … 37 39 const unsigned iColumCount = 3; 38 40 39 class UIInformationTableRow40 {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 UIInformationConfiguration::TableRow row() const;50 51 private:52 53 QList<QTableWidgetItem*> m_items;54 UIInformationConfiguration::TableRow m_enmRow;55 };56 57 UIInformationTableRow::UIInformationTableRow(UIInformationConfiguration::TableRow enmRow)58 : m_enmRow(enmRow)59 {60 m_items.reserve(iColumCount);61 }62 63 UIInformationTableRow::~UIInformationTableRow()64 {65 for (int i = 0; i < m_items.size(); ++i)66 delete m_items[i];67 m_items.clear();68 }69 70 UIInformationConfiguration::TableRow UIInformationTableRow::row() const71 {72 return m_enmRow;73 }74 75 QTableWidgetItem *UIInformationTableRow::addItem(unsigned iColumn, const QIcon &icon, const QString &strText)76 {77 if (iColumn >= iColumCount)78 return 0;79 /* Deallocate first if we have something on the column already: */80 if (m_items.size() > (int)iColumn && m_items[iColumn])81 delete m_items[iColumn];82 QTableWidgetItem *pItem = new QTableWidgetItem(icon, strText);83 m_items.insert(iColumn, pItem);84 return pItem;85 }86 87 QTableWidgetItem *UIInformationTableRow::addItem(unsigned iColumn, const QString &strText)88 {89 if (iColumn >= iColumCount)90 return 0;91 /* Deallocate first if we have something on the column already: */92 if (m_items.size() > (int)iColumn && m_items[iColumn])93 delete m_items[iColumn];94 QTableWidgetItem *pItem = new QTableWidgetItem(strText);95 m_items.insert(iColumn, pItem);96 return pItem;97 }98 99 41 UIInformationConfiguration::UIInformationConfiguration(QWidget *pParent, const CMachine &machine, const CConsole &console) 100 42 : QIWithRetranslateUI<QWidget>(pParent) … … 117 59 UIInformationConfiguration::~UIInformationConfiguration() 118 60 { 119 qDeleteAll(m_ rows);120 m_ rows.clear();61 qDeleteAll(m_tableItems); 62 m_tableItems.clear(); 121 63 } 122 64 … … 247 189 { 248 190 /* Configure the table by hiding the headers etc.: */ 249 m_pTableWidget->setRowCount( TableRow_Max);191 m_pTableWidget->setRowCount(20); 250 192 m_pTableWidget->setColumnCount(3); 251 193 m_pTableWidget->verticalHeader()->hide(); … … 253 195 //m_pTableWidget->setShowGrid(false); 254 196 m_pMainLayout->addWidget(m_pTableWidget); 255 m_pTableWidget->hide();256 197 } 257 198 } … … 269 210 int iMaxColumn1Length = 0; 270 211 271 /* General Section: */ 272 insertTitleRow(TableRow_General_Title, m_strGeneralTitle, UIIconPool::iconSet(":/machine_16px.png")); 273 QString strMachineName = m_machine.isNull() ? m_strError : m_machine.GetName(); 274 insertInfoRow(TableRow_General_Name, m_strGeneralName, strMachineName, fontMetrics, iMaxColumn1Length); 275 QString strOSTypeName; 276 if (!m_console.isNull()) 277 { 278 CGuest comGuest = m_console.GetGuest(); 279 if (!comGuest.isNull()) 280 strOSTypeName = uiCommon().vmGuestOSTypeDescription(comGuest.GetOSTypeId()); 281 } 282 if (strOSTypeName.isEmpty()) 283 strOSTypeName = m_strError; 284 insertInfoRow(TableRow_General_OSType, m_strGeneralOSType, strOSTypeName, fontMetrics, iMaxColumn1Length); 285 insertTitleRow(TableRow_System_Title, m_strSystemTitle, UIIconPool::iconSet(":/chipset_16px.png")); 286 212 213 214 insertTitleRow(0, m_strGeneralTitle, UIIconPool::iconSet(":/machine_16px.png")); 215 216 UITextTable generalTextTable = UIDetailsGenerator::generateMachineInformationGeneral(m_machine, 217 UIExtraDataMetaDefs::DetailsElementOptionTypeGeneral_Default); 218 219 int iTableRow = 1; 220 QTextDocument textDocument; 221 foreach (const UITextTableLine &line, generalTextTable) 222 { 223 textDocument.setHtml(line.string2()); 224 insertInfoRow(iTableRow, line.string1(), textDocument.toRawText(), fontMetrics, iMaxColumn1Length); 225 ++iTableRow; 226 } 287 227 288 228 m_pTableWidget->resizeColumnToContents(0); 289 //m_pTableWidget->resizeColumnToContents(1);290 229 m_pTableWidget->setColumnWidth(1, 1.5 * iMaxColumn1Length); 291 230 m_pTableWidget->resizeColumnToContents(2); … … 293 232 } 294 233 295 void UIInformationConfiguration::insertTitleRow(TableRow enmRow, const QString &strTitle, const QIcon &icon) 296 { 297 UIInformationTableRow *pRow = new UIInformationTableRow(enmRow); 298 m_rows.insert(enmRow, pRow); 299 m_pTableWidget->setItem(enmRow, 0, pRow->addItem(0, icon, "")); 300 QTableWidgetItem *pItem = pRow->addItem(1, strTitle); 301 QFont font = pItem->font(); 234 void UIInformationConfiguration::insertTitleRow(int iRow, const QString &strTitle, const QIcon &icon) 235 { 236 QTableWidgetItem *pIconItem = new QTableWidgetItem(icon, ""); 237 m_pTableWidget->setItem(iRow, 0, pIconItem); 238 QTableWidgetItem *pTitleItem = new QTableWidgetItem(strTitle); 239 QFont font = pTitleItem->font(); 302 240 font.setBold(true); 303 pItem->setFont(font); 304 m_pTableWidget->setItem(enmRow, 1, pItem); 305 } 306 307 void UIInformationConfiguration::insertInfoRow(TableRow enmRow, const QString &strColumn1, const QString &strColumn2, 241 pTitleItem->setFont(font); 242 m_pTableWidget->setItem(iRow, 1, pTitleItem); 243 m_tableItems << pIconItem; 244 m_tableItems << pTitleItem; 245 } 246 247 void UIInformationConfiguration::insertInfoRow(int iRow, const QString strText1, const QString &strText2, 308 248 QFontMetrics &fontMetrics, int &iMaxColumn1Length) 309 249 { 310 UIInformationTableRow *pRow = new UIInformationTableRow(enmRow); 311 m_rows.insert(enmRow, pRow); 312 m_pTableWidget->setItem(enmRow, 1, pRow->addItem(1, strColumn1)); 313 m_pTableWidget->setItem(enmRow, 2, pRow->addItem(1, strColumn2)); 314 iMaxColumn1Length = qMax(iMaxColumn1Length, fontMetrics.width(strColumn1)); 315 } 250 iMaxColumn1Length = qMax(iMaxColumn1Length, fontMetrics.width(strText1)); 251 QTableWidgetItem *pCol1 = new QTableWidgetItem(strText1); 252 QTableWidgetItem *pCol2 = new QTableWidgetItem(strText2); 253 m_tableItems << pCol1; 254 m_tableItems << pCol2; 255 m_pTableWidget->setItem(iRow, 1, pCol1); 256 m_pTableWidget->setItem(iRow, 2, pCol2); 257 } -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/information/UIInformationConfiguration.h
r80341 r80343 41 41 class QTableWidget; 42 42 class QTableWidgetItem; 43 class UI InformationTableRow;43 class UITextTableLine; 44 44 45 45 /** QWidget extension … … 50 50 51 51 public: 52 53 enum TableRow54 {55 TableRow_General_Title = 0,56 TableRow_General_Name,57 TableRow_General_OSType,58 TableRow_System_Title,59 TableRow_Max60 };61 52 62 53 /** Constructs information-tab passing @a pParent to the QWidget base-class constructor. … … 77 68 78 69 void updateTable(); 79 void insertTitleRow( TableRow enmRow, const QString &strTitle, const QIcon &icon);80 void insertInfoRow( TableRow enmRow, const QString &strColumn1, const QString &strColumn2,70 void insertTitleRow(int iRow, const QString &strTitle, const QIcon &icon); 71 void insertInfoRow(int iRow, const QString strText1, const QString &strText2, 81 72 QFontMetrics &fontMetrics, int &iMaxColumn1Length); 82 73 … … 92 83 UIInformationView *m_pView; 93 84 QTableWidget *m_pTableWidget; 94 QMap<TableRow, UIInformationTableRow*> m_rows;95 85 //QMap<TableRow, UIInformationTableRow*> m_rows; 86 QList<QTableWidgetItem*> m_tableItems; 96 87 /** @name Cached translated string. 97 88 * @{ */
Note:
See TracChangeset
for help on using the changeset viewer.