Changeset 105060 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Jun 27, 2024 1:07:56 PM (8 months ago)
- svn:sync-xref-src-repo-rev:
- 163679
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/settings/editors/UIShortcutConfigurationEditor.cpp
r105059 r105060 207 207 UIShortcutConfigurationModel(UIShortcutConfigurationEditor *pParent, UIType enmType); 208 208 /** Destructs model. */ 209 virtual ~UIShortcutConfigurationModel() RT_OVERRIDE ;209 virtual ~UIShortcutConfigurationModel() RT_OVERRIDE RT_FINAL; 210 210 211 211 /** Loads a @a list of shortcuts to the model. */ … … 217 217 bool isAllShortcutsUnique(); 218 218 219 protected: 219 /** Returns the item flags for the given @a index. */ 220 virtual Qt::ItemFlags flags(const QModelIndex &index) const RT_OVERRIDE RT_FINAL; 220 221 221 222 /** Returns the number of rows under the given @a parent. */ 222 virtual int rowCount(const QModelIndex &parent = QModelIndex()) const RT_OVERRIDE ;223 virtual int rowCount(const QModelIndex &parent = QModelIndex()) const RT_OVERRIDE RT_FINAL; 223 224 /** Returns the number of columns under the given @a parent. */ 224 virtual int columnCount(const QModelIndex &parent = QModelIndex()) const RT_OVERRIDE; 225 226 /** Returns the item flags for the given @a index. */ 227 virtual Qt::ItemFlags flags(const QModelIndex &index) const RT_OVERRIDE; 225 virtual int columnCount(const QModelIndex &parent = QModelIndex()) const RT_OVERRIDE RT_FINAL; 226 228 227 /** Returns the data for the given @a iRole and @a iSection in the header with the specified @a enmOrientation. */ 229 virtual QVariant headerData(int iSection, Qt::Orientation enmOrientation, int iRole = Qt::DisplayRole) const RT_OVERRIDE; 228 virtual QVariant headerData(int iSection, Qt::Orientation enmOrientation, int iRole) const RT_OVERRIDE RT_FINAL; 229 230 /** Sets the @a iRole data for the item at @a index to @a value. */ 231 virtual bool setData(const QModelIndex &index, const QVariant &value, int iRole) RT_OVERRIDE RT_FINAL; 230 232 /** Returns the data stored under the given @a iRole for the item referred to by the @a index. */ 231 virtual QVariant data(const QModelIndex &index, int iRole = Qt::DisplayRole) const RT_OVERRIDE; 232 /** Sets the @a iRole data for the item at @a index to @a value. */ 233 virtual bool setData(const QModelIndex &index, const QVariant &value, int iRole = Qt::EditRole) RT_OVERRIDE; 233 virtual QVariant data(const QModelIndex &index, int iRole = Qt::DisplayRole) const RT_OVERRIDE RT_FINAL; 234 234 235 235 private: … … 418 418 } 419 419 420 int UIShortcutConfigurationModel::rowCount(const QModelIndex& /* parent = QModelIndex() */) const421 {422 return m_shortcuts.size();423 }424 425 int UIShortcutConfigurationModel::columnCount(const QModelIndex& /* parent = QModelIndex() */) const426 {427 return TableColumnIndex_Max;428 }429 430 420 Qt::ItemFlags UIShortcutConfigurationModel::flags(const QModelIndex &index) const 431 421 { 432 /* No flags for invalid index: */422 /* Check index validness: */ 433 423 if (!index.isValid()) 434 424 return Qt::NoItemFlags; … … 438 428 case TableColumnIndex_Description: return Qt::ItemIsEnabled | Qt::ItemIsSelectable; 439 429 case TableColumnIndex_Sequence: return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable; 440 default: break; 441 } 442 /* No flags by default: */ 443 return Qt::NoItemFlags; 430 default: return Qt::NoItemFlags; 431 } 432 } 433 434 int UIShortcutConfigurationModel::rowCount(const QModelIndex& /* parent = QModelIndex() */) const 435 { 436 return m_shortcuts.size(); 437 } 438 439 int UIShortcutConfigurationModel::columnCount(const QModelIndex& /* parent = QModelIndex() */) const 440 { 441 return TableColumnIndex_Max; 444 442 } 445 443 … … 473 471 } 474 472 475 QVariant UIShortcutConfigurationModel::data(const QModelIndex &index, int iRole /* = Qt::DisplayRole */) const 473 bool UIShortcutConfigurationModel::setData(const QModelIndex &index, const QVariant &value, int iRole) 474 { 475 /* Nothing to set for invalid index: */ 476 if (!index.isValid()) 477 return false; 478 /* Switch for different roles: */ 479 switch (iRole) 480 { 481 case Qt::EditRole: 482 { 483 /* Switch for different columns: */ 484 switch (index.column()) 485 { 486 case TableColumnIndex_Sequence: 487 { 488 /* Get index: */ 489 const int iIndex = index.row(); 490 /* Set sequence to shortcut: */ 491 UIShortcutTableViewRow *pFilteredShortcut = m_shortcuts.at(iIndex); 492 const int iShortcutIndex = UIShortcutSearchFunctor<UIShortcutTableViewRow>()(m_shortcuts, pFilteredShortcut); 493 if (iShortcutIndex != -1) 494 { 495 pFilteredShortcut->setCurrentSequence( pFilteredShortcut->key() == UIHostCombo::hostComboCacheKey() 496 ? value.value<UIHostComboWrapper>().toString() 497 : value.value<UIHotKey>().sequence()); 498 emit sigDataChanged(); 499 return true; 500 } 501 break; 502 } 503 default: 504 break; 505 } 506 break; 507 } 508 default: 509 break; 510 } 511 /* Nothing to set by default: */ 512 return false; 513 } 514 515 QVariant UIShortcutConfigurationModel::data(const QModelIndex &index, int iRole) const 476 516 { 477 517 /* No data for invalid index: */ … … 578 618 } 579 619 580 bool UIShortcutConfigurationModel::setData(const QModelIndex &index, const QVariant &value, int iRole /* = Qt::EditRole */)581 {582 /* Nothing to set for invalid index: */583 if (!index.isValid())584 return false;585 /* Switch for different roles: */586 switch (iRole)587 {588 case Qt::EditRole:589 {590 /* Switch for different columns: */591 switch (index.column())592 {593 case TableColumnIndex_Sequence:594 {595 /* Get index: */596 const int iIndex = index.row();597 /* Set sequence to shortcut: */598 UIShortcutTableViewRow *pFilteredShortcut = m_shortcuts.at(iIndex);599 const int iShortcutIndex = UIShortcutSearchFunctor<UIShortcutTableViewRow>()(m_shortcuts, pFilteredShortcut);600 if (iShortcutIndex != -1)601 {602 pFilteredShortcut->setCurrentSequence( pFilteredShortcut->key() == UIHostCombo::hostComboCacheKey()603 ? value.value<UIHostComboWrapper>().toString()604 : value.value<UIHotKey>().sequence());605 emit sigDataChanged();606 return true;607 }608 break;609 }610 default:611 break;612 }613 break;614 }615 default:616 break;617 }618 /* Nothing to set by default: */619 return false;620 }621 622 620 QITableView *UIShortcutConfigurationModel::view() const 623 621 { -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIFormEditorWidget.cpp
r104999 r105060 530 530 UIFormEditorModel(UIFormEditorWidget *pParent); 531 531 /** Destructs Port Forwarding model. */ 532 virtual ~UIFormEditorModel() RT_OVERRIDE ;532 virtual ~UIFormEditorModel() RT_OVERRIDE RT_FINAL; 533 533 534 534 /** Clears form. */ … … 537 537 void setFormValues(const CFormValueVector &values); 538 538 539 /** Returns the index of the item in the model specified by the given @a iRow, @a iColumn and @a parentIdx. */540 virtual QModelIndex index(int iRow, int iColumn, const QModelIndex &parentIdx = QModelIndex()) const RT_OVERRIDE;541 542 /** Returns flags for item with certain @a index. */543 virtual Qt::ItemFlags flags(const QModelIndex &index) const RT_OVERRIDE;544 545 /** Returns row count of certain @a parent. */546 virtual int rowCount(const QModelIndex &parent = QModelIndex()) const RT_OVERRIDE;547 /** Returns column count of certain @a parent. */548 virtual int columnCount(const QModelIndex &parent = QModelIndex()) const RT_OVERRIDE;549 550 /** Returns header data for @a iSection, @a enmOrientation and @a iRole specified. */551 virtual QVariant headerData(int iSection, Qt::Orientation enmOrientation, int iRole) const RT_OVERRIDE;552 553 /** Defines the @a iRole data for item with @a index as @a value. */554 virtual bool setData(const QModelIndex &index, const QVariant &value, int iRole = Qt::EditRole) RT_OVERRIDE;555 /** Returns the @a iRole data for item with @a index. */556 virtual QVariant data(const QModelIndex &index, int iRole) const RT_OVERRIDE;557 558 539 /** Creates actual TextData editor for specified @a index. */ 559 540 void createTextDataEditor(const QModelIndex &index); 541 542 /** Returns the index of the item in the model specified by the given @a iRow, @a iColumn and @a parentIdx. */ 543 virtual QModelIndex index(int iRow, int iColumn, const QModelIndex &parentIdx = QModelIndex()) const RT_OVERRIDE RT_FINAL; 544 545 /** Returns flags for item with certain @a index. */ 546 virtual Qt::ItemFlags flags(const QModelIndex &index) const RT_OVERRIDE RT_FINAL; 547 548 /** Returns row count of certain @a parent. */ 549 virtual int rowCount(const QModelIndex &parent = QModelIndex()) const RT_OVERRIDE RT_FINAL; 550 /** Returns column count of certain @a parent. */ 551 virtual int columnCount(const QModelIndex &parent = QModelIndex()) const RT_OVERRIDE RT_FINAL; 552 553 /** Returns header data for @a iSection, @a enmOrientation and @a iRole specified. */ 554 virtual QVariant headerData(int iSection, Qt::Orientation enmOrientation, int iRole) const RT_OVERRIDE RT_FINAL; 555 556 /** Defines the @a iRole data for item with @a index as @a value. */ 557 virtual bool setData(const QModelIndex &index, const QVariant &value, int iRole = Qt::EditRole) RT_OVERRIDE RT_FINAL; 558 /** Returns the @a iRole data for item with @a index. */ 559 virtual QVariant data(const QModelIndex &index, int iRole) const RT_OVERRIDE RT_FINAL; 560 560 561 561 private: … … 1194 1194 m_dataList << new UIFormEditorRow(view(), m_pFormEditorWidget, comValue); 1195 1195 endInsertRows(); 1196 } 1197 1198 void UIFormEditorModel::createTextDataEditor(const QModelIndex &index) 1199 { 1200 /* Create dialog on-the-fly: */ 1201 QPointer<QIDialog> pDialog = new QIDialog(view()); 1202 if (pDialog) 1203 { 1204 /* We will need that pointer: */ 1205 QTextEdit *pEditor = 0; 1206 /* Create layout: */ 1207 QVBoxLayout *pLayout = new QVBoxLayout(pDialog); 1208 if (pLayout) 1209 { 1210 /* Create text-editor: */ 1211 pEditor = new QTextEdit; 1212 if (pEditor) 1213 { 1214 const TextData td = data(index, Qt::EditRole).value<TextData>(); 1215 pEditor->setPlainText(td.text()); 1216 pLayout->addWidget(pEditor); 1217 } 1218 /* Create button-box: */ 1219 QIDialogButtonBox *pBox = new QIDialogButtonBox; 1220 if (pBox) 1221 { 1222 pBox->setStandardButtons(QDialogButtonBox::Cancel | QDialogButtonBox::Ok); 1223 connect(pBox, &QIDialogButtonBox::accepted, pDialog.data(), &QIDialog::accept); 1224 connect(pBox, &QIDialogButtonBox::rejected, pDialog.data(), &QIDialog::reject); 1225 pLayout->addWidget(pBox); 1226 } 1227 } 1228 /* Execute the dialog: */ 1229 if (pDialog->execute() == QDialog::Accepted) 1230 { 1231 const TextData td = TextData(pEditor->toPlainText(), index); 1232 setData(index, QVariant::fromValue(td)); 1233 } 1234 /* Cleanup: */ 1235 delete pDialog; 1236 } 1196 1237 } 1197 1238 … … 1451 1492 } 1452 1493 1453 void UIFormEditorModel::createTextDataEditor(const QModelIndex &index)1454 {1455 /* Create dialog on-the-fly: */1456 QPointer<QIDialog> pDialog = new QIDialog(view());1457 if (pDialog)1458 {1459 /* We will need that pointer: */1460 QTextEdit *pEditor = 0;1461 /* Create layout: */1462 QVBoxLayout *pLayout = new QVBoxLayout(pDialog);1463 if (pLayout)1464 {1465 /* Create text-editor: */1466 pEditor = new QTextEdit;1467 if (pEditor)1468 {1469 const TextData td = data(index, Qt::EditRole).value<TextData>();1470 pEditor->setPlainText(td.text());1471 pLayout->addWidget(pEditor);1472 }1473 /* Create button-box: */1474 QIDialogButtonBox *pBox = new QIDialogButtonBox;1475 if (pBox)1476 {1477 pBox->setStandardButtons(QDialogButtonBox::Cancel | QDialogButtonBox::Ok);1478 connect(pBox, &QIDialogButtonBox::accepted, pDialog.data(), &QIDialog::accept);1479 connect(pBox, &QIDialogButtonBox::rejected, pDialog.data(), &QIDialog::reject);1480 pLayout->addWidget(pBox);1481 }1482 }1483 /* Execute the dialog: */1484 if (pDialog->execute() == QDialog::Accepted)1485 {1486 const TextData td = TextData(pEditor->toPlainText(), index);1487 setData(index, QVariant::fromValue(td));1488 }1489 /* Cleanup: */1490 delete pDialog;1491 }1492 }1493 1494 1494 void UIFormEditorModel::prepare() 1495 1495 { -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIPortForwardingTable.cpp
r105052 r105060 445 445 UIPortForwardingModel(UIPortForwardingTable *pParent, const UIPortForwardingDataList &rules = UIPortForwardingDataList()); 446 446 /** Destructs Port Forwarding model. */ 447 virtual ~UIPortForwardingModel() ;447 virtual ~UIPortForwardingModel() RT_OVERRIDE RT_FINAL; 448 448 449 449 /** Returns the list of port forwarding rules. */ … … 474 474 475 475 /** Defines the @a iRole data for item with @a index as @a value. */ 476 virtual bool setData(const QModelIndex &index, const QVariant &value, int iRole = Qt::EditRole) RT_OVERRIDE RT_FINAL;476 virtual bool setData(const QModelIndex &index, const QVariant &value, int iRole) RT_OVERRIDE RT_FINAL; 477 477 /** Returns the @a iRole data for item with @a index. */ 478 478 virtual QVariant data(const QModelIndex &index, int iRole) const RT_OVERRIDE RT_FINAL; … … 697 697 } 698 698 699 bool UIPortForwardingModel::setData(const QModelIndex &index, const QVariant &value, int iRole /* = Qt::EditRole */)699 bool UIPortForwardingModel::setData(const QModelIndex &index, const QVariant &value, int iRole) 700 700 { 701 701 /* Check index validness: */
Note:
See TracChangeset
for help on using the changeset viewer.