Changeset 95233 in vbox
- Timestamp:
- Jun 8, 2022 3:46:27 PM (3 years ago)
- svn:sync-xref-src-repo-rev:
- 151762
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIDetailsGenerator.cpp
r93996 r95233 19 19 #include <QApplication> 20 20 #include <QDir> 21 #include <QRegularExpression> 21 22 22 23 /* GUI includes: */ -
trunk/src/VBox/Frontends/VirtualBox/src/settings/editors/UIBootOrderEditor.cpp
r95227 r95233 18 18 /* Qt includes: */ 19 19 #include <QGridLayout> 20 #include <QHeaderView> 20 21 #include <QLabel> 21 22 #include <QRegularExpression> … … 28 29 #include "UIIconPool.h" 29 30 #include "QIToolBar.h" 31 #include "QITreeWidget.h" 30 32 31 33 /* COM includes: */ … … 35 37 36 38 37 /** QListWidgetItem extension for our UIBootListWidget. */ 38 class UIBootListWidgetItem : public QListWidgetItem 39 { 39 /** QITreeWidgetItem extension for our UIBootListWidget. */ 40 class UIBootListWidgetItem : public QITreeWidgetItem 41 { 42 Q_OBJECT; 43 40 44 public: 41 45 … … 44 48 45 49 /** Returns the item type. */ 46 KDeviceType type() const;50 KDeviceType deviceType() const; 47 51 48 52 /** Performs item translation. */ … … 56 60 57 61 58 /** Q ListWidget subclass used as system settings boot-table. */59 class UIBootListWidget : public QIWithRetranslateUI<Q ListWidget>62 /** QITreeWidget subclass used as system settings boot-table. */ 63 class UIBootListWidget : public QIWithRetranslateUI<QITreeWidget> 60 64 { 61 65 Q_OBJECT; … … 63 67 signals: 64 68 65 /** Notifies listeners about current table row changed. 66 * @note Same as base-class currentRowChanged but in wider cases. */ 67 void sigRowChanged(int iRow); 69 /** Notifies listeners about current table row changed. */ 70 void sigRowChanged(); 68 71 69 72 public: … … 117 120 : m_enmType(enmType) 118 121 { 119 setCheckState( Qt::Unchecked);122 setCheckState(0, Qt::Unchecked); 120 123 switch(enmType) 121 124 { 122 case KDeviceType_Floppy: setIcon( UIIconPool::iconSet(":/fd_16px.png")); break;123 case KDeviceType_DVD: setIcon( UIIconPool::iconSet(":/cd_16px.png")); break;124 case KDeviceType_HardDisk: setIcon( UIIconPool::iconSet(":/hd_16px.png")); break;125 case KDeviceType_Network: setIcon( UIIconPool::iconSet(":/nw_16px.png")); break;125 case KDeviceType_Floppy: setIcon(0, UIIconPool::iconSet(":/fd_16px.png")); break; 126 case KDeviceType_DVD: setIcon(0, UIIconPool::iconSet(":/cd_16px.png")); break; 127 case KDeviceType_HardDisk: setIcon(0, UIIconPool::iconSet(":/hd_16px.png")); break; 128 case KDeviceType_Network: setIcon(0, UIIconPool::iconSet(":/nw_16px.png")); break; 126 129 default: break; /* Shut up, MSC! */ 127 130 } … … 129 132 } 130 133 131 KDeviceType UIBootListWidgetItem:: type() const134 KDeviceType UIBootListWidgetItem::deviceType() const 132 135 { 133 136 return m_enmType; … … 136 139 void UIBootListWidgetItem::retranslateUi() 137 140 { 138 setText( gpConverter->toString(m_enmType));141 setText(0, gpConverter->toString(m_enmType)); 139 142 } 140 143 … … 145 148 146 149 UIBootListWidget::UIBootListWidget(QWidget *pParent /* = 0 */) 147 : QIWithRetranslateUI<Q ListWidget>(pParent)150 : QIWithRetranslateUI<QITreeWidget>(pParent) 148 151 { 149 152 prepare(); … … 159 162 { 160 163 UIBootListWidgetItem *pItem = new UIBootListWidgetItem(data.m_enmType); 161 pItem->setCheckState(data.m_fEnabled ? Qt::Checked : Qt::Unchecked); 162 addItem(pItem); 163 } 164 pItem->setCheckState(0, data.m_fEnabled ? Qt::Checked : Qt::Unchecked); 165 addTopLevelItem(pItem); 166 } 167 168 /* Make sure at least one is chosen: */ 169 if (topLevelItemCount()) 170 setCurrentItem(topLevelItem(0)); 164 171 165 172 /* Adjust table size after change: */ … … 173 180 174 181 /* Enumerate all the items we have: */ 175 for (int i = 0; i < count(); ++i)176 { 177 Q ListWidgetItem *pItem = item(i);182 for (int i = 0; i < topLevelItemCount(); ++i) 183 { 184 QTreeWidgetItem *pItem = topLevelItem(i); 178 185 UIBootItemData bootData; 179 bootData.m_enmType = static_cast<UIBootListWidgetItem*>(pItem)-> type();180 bootData.m_fEnabled = pItem->checkState( ) == Qt::Checked;186 bootData.m_enmType = static_cast<UIBootListWidgetItem*>(pItem)->deviceType(); 187 bootData.m_fEnabled = pItem->checkState(0) == Qt::Checked; 181 188 bootItems << bootData; 182 189 } … … 200 207 void UIBootListWidget::retranslateUi() 201 208 { 202 for (int i = 0; i < count(); ++i)203 static_cast<UIBootListWidgetItem*>( item(i))->retranslateUi();209 for (int i = 0; i < topLevelItemCount(); ++i) 210 static_cast<UIBootListWidgetItem*>(topLevelItem(i))->retranslateUi(); 204 211 205 212 adjustSizeToFitContent(); … … 209 216 { 210 217 /* Call to base-class: */ 211 Q ListWidget::dropEvent(pEvent);218 QITreeWidget::dropEvent(pEvent); 212 219 /* Separately notify listeners: */ 213 emit sigRowChanged( currentRow());220 emit sigRowChanged(); 214 221 } 215 222 … … 248 255 } 249 256 } 250 return Q ListWidget::moveCursor(cursorAction, fModifiers);257 return QITreeWidget::moveCursor(cursorAction, fModifiers); 251 258 } 252 259 253 260 void UIBootListWidget::prepare() 254 261 { 262 header()->hide(); 263 setRootIsDecorated(false); 255 264 setDragDropMode(QAbstractItemView::InternalMove); 256 265 setSelectionMode(QAbstractItemView::SingleSelection); 257 266 setDropIndicatorShown(true); 258 setUniformItemSizes(true); 259 connect(this, &UIBootListWidget::currentRowChanged, 267 connect(this, &UIBootListWidget::currentItemChanged, 260 268 this, &UIBootListWidget::sigRowChanged); 261 269 } … … 266 274 const int iW = iH; 267 275 setFixedSize(sizeHintForColumn(0) + iW, 268 sizeHintForRow(0) * count() + iH);269 } 270 271 QModelIndex UIBootListWidget::moveItemTo(const QModelIndex &index, int row)276 sizeHintForRow(0) * topLevelItemCount() + iH); 277 } 278 279 QModelIndex UIBootListWidget::moveItemTo(const QModelIndex &index, int iRow) 272 280 { 273 281 /* Check validity: */ … … 276 284 277 285 /* Check sanity: */ 278 if ( row < 0 || row > model()->rowCount())286 if (iRow < 0 || iRow > model()->rowCount()) 279 287 return QModelIndex(); 280 288 281 289 QPersistentModelIndex oldIndex(index); 282 290 UIBootListWidgetItem *pItem = static_cast<UIBootListWidgetItem*>(itemFromIndex(oldIndex)); 283 insertItem(row, new UIBootListWidgetItem(*pItem)); 284 QPersistentModelIndex newIndex = model()->index(row, 0); 285 delete takeItem(oldIndex.row()); 286 setCurrentRow(newIndex.row()); 291 insertTopLevelItem(iRow, new UIBootListWidgetItem(pItem->deviceType())); 292 topLevelItem(iRow)->setCheckState(0, pItem->checkState(0)); 293 QPersistentModelIndex newIndex = model()->index(iRow, 0); 294 delete takeTopLevelItem(oldIndex.row()); 295 setCurrentItem(topLevelItem(newIndex.row())); 287 296 return QModelIndex(newIndex); 288 297 } … … 573 582 { 574 583 /* Update move up/down actions: */ 575 if (m_pTable && m_pMoveUp) 576 m_pMoveUp->setEnabled(m_pTable->hasFocus() && m_pTable->currentRow() > 0); 577 if (m_pTable && m_pMoveDown) 578 m_pMoveDown->setEnabled(m_pTable->hasFocus() && m_pTable->currentRow() < m_pTable->count() - 1); 584 QTreeWidgetItem *pCurrentTopLevelItem = m_pTable->currentItem(); 585 const int iCurrentTopLevelItem = m_pTable->indexOfTopLevelItem(pCurrentTopLevelItem); 586 if (m_pTable && m_pMoveUp && iCurrentTopLevelItem != -1) 587 m_pMoveUp->setEnabled(m_pTable->hasFocus() && iCurrentTopLevelItem > 0); 588 if (m_pTable && m_pMoveDown && iCurrentTopLevelItem != -1) 589 m_pMoveDown->setEnabled(m_pTable->hasFocus() && iCurrentTopLevelItem < m_pTable->topLevelItemCount() - 1); 579 590 } 580 591 -
trunk/src/VBox/Frontends/VirtualBox/src/settings/editors/UIBootOrderEditor.h
r95163 r95233 21 21 # pragma once 22 22 #endif 23 24 /* Qt includes: */25 #include <QListWidget>26 23 27 24 /* GUI includes: */
Note:
See TracChangeset
for help on using the changeset viewer.