Changeset 105033 in vbox
- Timestamp:
- Jun 26, 2024 5:05:04 PM (9 months ago)
- svn:sync-xref-src-repo-rev:
- 163651
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/settings/editors
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/settings/editors/UIShortcutConfigurationEditor.cpp
r105032 r105033 181 181 182 182 /** Shortcut configuration editor row list. */ 183 typedef QList<UIShortcutTableViewRow > UIShortcutTableViewContent;183 typedef QList<UIShortcutTableViewRow*> UIShortcutTableViewContent; 184 184 185 185 … … 197 197 {} 198 198 199 /** Returns whether the @a item1 is more/less than the @a item2.199 /** Returns whether the @a pItem1 is more/less than the @a pItem2. 200 200 * @note Order depends on the one set through constructor, stored in m_enmOrder. */ 201 bool operator()( const UIShortcutTableViewRow &item1, const UIShortcutTableViewRow &item2)201 bool operator()(UIShortcutTableViewRow *pItem1, UIShortcutTableViewRow *pItem2) 202 202 { 203 203 switch (m_iColumn) … … 205 205 case TableColumnIndex_Description: 206 206 return m_enmOrder == Qt::AscendingOrder 207 ? item1.description() < item2.description()208 : item1.description() > item2.description();207 ? pItem1->description() < pItem2->description() 208 : pItem1->description() > pItem2->description(); 209 209 case TableColumnIndex_Sequence: 210 210 return m_enmOrder == Qt::AscendingOrder 211 ? item1.currentSequence() < item2.currentSequence()212 : item1.currentSequence() > item2.currentSequence();211 ? pItem1->currentSequence() < pItem2->currentSequence() 212 : pItem1->currentSequence() > pItem2->currentSequence(); 213 213 default: 214 214 break; 215 215 } 216 216 return m_enmOrder == Qt::AscendingOrder 217 ? item1.key() < item2.key()218 : item1.key() > item2.key();217 ? pItem1->key() < pItem2->key() 218 : pItem1->key() > pItem2->key(); 219 219 } 220 220 … … 245 245 * @param enmType Brings the action-pool type this model is related to. */ 246 246 UIShortcutConfigurationModel(UIShortcutConfigurationEditor *pParent, UIType enmType); 247 /** Destructs model. */ 248 virtual ~UIShortcutConfigurationModel() RT_OVERRIDE; 247 249 248 250 /** Loads a @a list of shortcuts to the model. */ … … 347 349 } 348 350 351 UIShortcutConfigurationModel::~UIShortcutConfigurationModel() 352 { 353 /* Delete the cached data: */ 354 qDeleteAll(m_shortcuts); 355 m_shortcuts.clear(); 356 m_filteredShortcuts.clear(); 357 } 358 349 359 void UIShortcutConfigurationModel::load(const UIShortcutConfigurationList &list) 350 360 { … … 357 367 continue; 358 368 /* Add suitable item to the model as a new shortcut: */ 359 m_shortcuts << UIShortcutTableViewRow(view(), item);369 m_shortcuts << new UIShortcutTableViewRow(view(), item); 360 370 } 361 371 /* Apply filter: */ … … 368 378 { 369 379 /* Save cached model shortcuts: */ 370 foreach (const UIShortcutTableViewRow &row, m_shortcuts) 371 { 372 const UIShortcutConfigurationItem &item = row; 373 380 foreach (UIShortcutTableViewRow *pRow, m_shortcuts) 381 { 374 382 /* Search for corresponding item position: */ 375 const int iShortcutItemPosition = UIShortcutSearchFunctor<UIShortcutConfigurationItem>()(list, item);383 const int iShortcutItemPosition = UIShortcutSearchFunctor<UIShortcutConfigurationItem>()(list, pRow); 376 384 /* Make sure position is valid: */ 377 385 if (iShortcutItemPosition == -1) 378 386 continue; 379 387 /* Save cached model shortcut to a list: */ 380 list[iShortcutItemPosition] = item;388 list[iShortcutItemPosition] = *pRow; 381 389 } 382 390 } … … 386 394 /* Enumerate all the sequences: */ 387 395 QMultiMap<QString, QString> usedSequences; 388 foreach ( const UIShortcutTableViewRow &item, m_shortcuts)389 { 390 QString strKey = item.currentSequence();396 foreach (UIShortcutTableViewRow *pRow, m_shortcuts) 397 { 398 QString strKey = pRow->currentSequence(); 391 399 if (!strKey.isEmpty()) 392 400 { 393 const QString strScope = item.scope();401 const QString strScope = pRow->scope(); 394 402 strKey = strScope.isNull() ? strKey : QString("%1: %2").arg(strScope, strKey); 395 usedSequences.insert(strKey, item.key());403 usedSequences.insert(strKey, pRow->key()); 396 404 } 397 405 } … … 495 503 { 496 504 /* Return shortcut scope and description: */ 497 const QString strScope = m_filteredShortcuts [iIndex].scope();498 const QString strDescription = m_filteredShortcuts [iIndex].description();505 const QString strScope = m_filteredShortcuts.at(iIndex)->scope(); 506 const QString strDescription = m_filteredShortcuts.at(iIndex)->description(); 499 507 return strScope.isNull() ? strDescription : QString("%1: %2").arg(strScope, strDescription); 500 508 } … … 502 510 { 503 511 /* If that is host-combo cell: */ 504 if (m_filteredShortcuts [iIndex].key() == UIHostCombo::hostComboCacheKey())512 if (m_filteredShortcuts.at(iIndex)->key() == UIHostCombo::hostComboCacheKey()) 505 513 /* We should return host-combo: */ 506 return UIHostCombo::toReadableString(m_filteredShortcuts [iIndex].currentSequence());514 return UIHostCombo::toReadableString(m_filteredShortcuts.at(iIndex)->currentSequence()); 507 515 /* In other cases we should return hot-combo: */ 508 QString strHotCombo = m_filteredShortcuts [iIndex].currentSequence();516 QString strHotCombo = m_filteredShortcuts.at(iIndex)->currentSequence(); 509 517 /* But if that is machine table and hot-combo is not empty: */ 510 518 if (m_enmType == UIType_RuntimeUI && !strHotCombo.isEmpty()) … … 525 533 { 526 534 case TableColumnIndex_Sequence: 527 return m_filteredShortcuts [iIndex].key() == UIHostCombo::hostComboCacheKey()528 ? QVariant::fromValue(UIHostComboWrapper(m_filteredShortcuts [iIndex].currentSequence()))535 return m_filteredShortcuts.at(iIndex)->key() == UIHostCombo::hostComboCacheKey() 536 ? QVariant::fromValue(UIHostComboWrapper(m_filteredShortcuts.at(iIndex)->currentSequence())) 529 537 : QVariant::fromValue(UIHotKey( m_enmType == UIType_RuntimeUI 530 538 ? UIHotKeyType_Simple 531 539 : UIHotKeyType_WithModifiers, 532 m_filteredShortcuts [iIndex].currentSequence(),533 m_filteredShortcuts [iIndex].defaultSequence()));540 m_filteredShortcuts.at(iIndex)->currentSequence(), 541 m_filteredShortcuts.at(iIndex)->defaultSequence())); 534 542 default: 535 543 break; … … 547 555 case TableColumnIndex_Sequence: 548 556 { 549 if ( m_filteredShortcuts [iIndex].key() != UIHostCombo::hostComboCacheKey()550 && m_filteredShortcuts [iIndex].currentSequence() != m_filteredShortcuts[iIndex].defaultSequence())557 if ( m_filteredShortcuts.at(iIndex)->key() != UIHostCombo::hostComboCacheKey() 558 && m_filteredShortcuts.at(iIndex)->currentSequence() != m_filteredShortcuts.at(iIndex)->defaultSequence()) 551 559 font.setBold(true); 552 560 break; … … 564 572 case TableColumnIndex_Sequence: 565 573 { 566 if (m_duplicatedSequences.contains(m_filteredShortcuts [iIndex].key()))574 if (m_duplicatedSequences.contains(m_filteredShortcuts.at(iIndex)->key())) 567 575 return QBrush(Qt::red); 568 576 break; … … 597 605 const int iIndex = index.row(); 598 606 /* Set sequence to shortcut: */ 599 UIShortcutTableViewRow &filteredShortcut = m_filteredShortcuts[iIndex];600 const int iShortcutIndex = UIShortcutSearchFunctor<UIShortcutTableViewRow>()(m_shortcuts, filteredShortcut);607 UIShortcutTableViewRow *pFilteredShortcut = m_filteredShortcuts.at(iIndex); 608 const int iShortcutIndex = UIShortcutSearchFunctor<UIShortcutTableViewRow>()(m_shortcuts, pFilteredShortcut); 601 609 if (iShortcutIndex != -1) 602 610 { 603 filteredShortcut.setCurrentSequence( filteredShortcut.key() == UIHostCombo::hostComboCacheKey() 604 ? value.value<UIHostComboWrapper>().toString() 605 : value.value<UIHotKey>().sequence()); 606 m_shortcuts[iShortcutIndex] = filteredShortcut; 611 pFilteredShortcut->setCurrentSequence( pFilteredShortcut->key() == UIHostCombo::hostComboCacheKey() 612 ? value.value<UIHostComboWrapper>().toString() 613 : value.value<UIHotKey>().sequence()); 607 614 emit sigDataChanged(); 608 615 return true; … … 632 639 if (iIndexOfHostComboItem != -1) 633 640 { 634 UIShortcutTableViewRow hostComboItem = m_shortcuts.takeAt(iIndexOfHostComboItem);635 m_shortcuts.prepend( hostComboItem);641 UIShortcutTableViewRow *pHostComboItem = m_shortcuts.takeAt(iIndexOfHostComboItem); 642 m_shortcuts.prepend(pHostComboItem); 636 643 } 637 644 /* Apply the filter: */ … … 652 659 void UIShortcutConfigurationModel::applyFilter() 653 660 { 654 /* Erase items first if necessary: */661 /* Erase rows first if necessary: */ 655 662 if (!m_filteredShortcuts.isEmpty()) 656 663 { … … 663 670 if (m_strFilter.isEmpty()) 664 671 { 665 /* Just add all the items: */672 /* Just add all the rows: */ 666 673 m_filteredShortcuts = m_shortcuts; 667 674 } … … 669 676 { 670 677 /* Check if the description matches the filter: */ 671 foreach ( const UIShortcutTableViewRow &item, m_shortcuts)672 { 673 /* If neither scope nor description or sequence matches the filter, skip item: */674 if ( ! item.scope().contains(m_strFilter, Qt::CaseInsensitive)675 && ! item.description().contains(m_strFilter, Qt::CaseInsensitive)676 && ! item.currentSequence().contains(m_strFilter, Qt::CaseInsensitive))678 foreach (UIShortcutTableViewRow *pRow, m_shortcuts) 679 { 680 /* If neither scope nor description or sequence matches the filter, skip the pRow: */ 681 if ( !pRow->scope().contains(m_strFilter, Qt::CaseInsensitive) 682 && !pRow->description().contains(m_strFilter, Qt::CaseInsensitive) 683 && !pRow->currentSequence().contains(m_strFilter, Qt::CaseInsensitive)) 677 684 continue; 678 /* Add that item: */679 m_filteredShortcuts << item;680 } 681 } 682 683 /* Add items finally if necessary: */685 /* Add that pRow: */ 686 m_filteredShortcuts << pRow; 687 } 688 } 689 690 /* Add rows finally if necessary: */ 684 691 if (!m_filteredShortcuts.isEmpty()) 685 692 { -
trunk/src/VBox/Frontends/VirtualBox/src/settings/editors/UIShortcutConfigurationEditor.h
r105032 r105033 58 58 const BaseClass &iteratedShortcut = shortcuts.at(i); 59 59 if (iteratedShortcut.key() == shortcut.key()) 60 return i; 61 } 62 return -1; 63 } 64 65 /** Returns the position of the 1st occurrence of the 66 * @a shortcut in the @a shortcuts list, or -1 otherwise. */ 67 int operator()(const QList<BaseClass*> &shortcuts, const BaseClass &shortcut) 68 { 69 for (int i = 0; i < shortcuts.size(); ++i) 70 { 71 const BaseClass *pIteratedShortcut = shortcuts.at(i); 72 if (pIteratedShortcut->key() == shortcut.key()) 73 return i; 74 } 75 return -1; 76 } 77 78 /** Returns the position of the 1st occurrence of the 79 * @a shortcut in the @a shortcuts list, or -1 otherwise. */ 80 int operator()(const QList<BaseClass> &shortcuts, const BaseClass *pShortcut) 81 { 82 for (int i = 0; i < shortcuts.size(); ++i) 83 { 84 const BaseClass &iteratedShortcut = shortcuts.at(i); 85 if (iteratedShortcut.key() == pShortcut->key()) 86 return i; 87 } 88 return -1; 89 } 90 91 /** Returns the position of the 1st occurrence of the 92 * @a shortcut in the @a shortcuts list, or -1 otherwise. */ 93 int operator()(const QList<BaseClass*> &shortcuts, const BaseClass *pShortcut) 94 { 95 for (int i = 0; i < shortcuts.size(); ++i) 96 { 97 const BaseClass *pIteratedShortcut = shortcuts.at(i); 98 if (pIteratedShortcut->key() == pShortcut->key()) 60 99 return i; 61 100 }
Note:
See TracChangeset
for help on using the changeset viewer.