Changeset 64264 in vbox
- Timestamp:
- Oct 13, 2016 4:44:52 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsInput.cpp
r64263 r64264 53 53 54 54 55 /** Global settings / Input page / Cache / Shortcut cache item. */ 56 struct UIShortcutCacheItem 57 { 55 /** Global settings / Input page / Shortcut table row. */ 56 class UIShortcutCacheRow : public QITableViewRow 57 { 58 Q_OBJECT; 59 60 public: 61 58 62 /** Constructs table row on the basis of passed arguments. 63 * @param pParent Brings the row this cell belongs too. 59 64 * @param strKey Brings the unique key inentifying held sequence. 60 65 * @param strDescription Brings the deescription for the held sequence. 61 66 * @param strCurrentSequence Brings the current held sequence. 62 67 * @param strDefaultSequence Brings the default held sequence. */ 63 UIShortcutCacheItem(const QString &strKey, 64 const QString &strDescription, 65 const QString &strCurrentSequence, 66 const QString &strDefaultSequence) 67 : m_strKey(strKey) 68 UIShortcutCacheRow(QITableView *pParent, 69 const QString &strKey, 70 const QString &strDescription, 71 const QString &strCurrentSequence, 72 const QString &strDefaultSequence) 73 : QITableViewRow(pParent) 74 , m_strKey(strKey) 68 75 , m_strDescription(strDescription) 69 76 , m_strCurrentSequence(strCurrentSequence) … … 72 79 73 80 /** Constructs table row on the basis of @a other one. */ 74 UIShortcutCacheItem(const UIShortcutCacheItem &other) 75 : m_strKey(other.key()) 81 UIShortcutCacheRow(const UIShortcutCacheRow &other) 82 : QITableViewRow(other.table()) 83 , m_strKey(other.key()) 76 84 , m_strDescription(other.description()) 77 85 , m_strCurrentSequence(other.currentSequence()) … … 80 88 81 89 /** Copies a table row from @a other one. */ 82 UIShortcutCache Item &operator=(const UIShortcutCacheItem&other)90 UIShortcutCacheRow &operator=(const UIShortcutCacheRow &other) 83 91 { 84 92 /* Reassign variables: */ 93 setTable(other.table()); 85 94 m_strKey = other.key(); 86 95 m_strDescription = other.description(); … … 93 102 94 103 /** Returns whether this row equals to @a other. */ 95 bool operator==(const UIShortcutCache Item&other) const104 bool operator==(const UIShortcutCacheRow &other) const 96 105 { 97 106 /* Compare by the key only: */ … … 110 119 /** Defines @a strCurrentSequence. */ 111 120 void setCurrentSequence(const QString &strCurrentSequence) { m_strCurrentSequence = strCurrentSequence; } 121 122 protected: 123 124 /** Returns the number of children. */ 125 virtual int childCount() const /* override */ 126 { 127 return 0; 128 } 129 130 /** Returns the child item with @a iIndex. */ 131 virtual QITableViewCell *childItem(int iIndex) const /* override */ 132 { 133 Q_UNUSED(iIndex); 134 return 0; 135 } 112 136 113 137 private: … … 125 149 126 150 /** Global settings / Input page / Cache / Shortcut cache. */ 127 typedef QList<UIShortcutCache Item> UIShortcutCache;151 typedef QList<UIShortcutCacheRow> UIShortcutCache; 128 152 129 153 … … 174 198 /** Returns whether the @a item1 is more/less than the @a item2. 175 199 * @note Order depends on the one set through constructor, stored in m_order. */ 176 bool operator()(const UIShortcutCache Item &item1, const UIShortcutCacheItem&item2)200 bool operator()(const UIShortcutCacheRow &item1, const UIShortcutCacheRow &item2) 177 201 { 178 202 switch (m_iColumn) … … 288 312 { 289 313 /* Load shortcuts: */ 290 foreach (const UIShortcutCache Item&item, shortcuts)314 foreach (const UIShortcutCacheRow &item, shortcuts) 291 315 { 292 316 /* Filter out unnecessary shortcuts: */ … … 306 330 { 307 331 /* Save model items: */ 308 foreach (const UIShortcutCache Item&item, m_shortcuts)332 foreach (const UIShortcutCacheRow &item, m_shortcuts) 309 333 { 310 334 /* Search for corresponding cache item index: */ … … 322 346 /* Enumerate all the sequences: */ 323 347 QMap<QString, QString> usedSequences; 324 foreach (const UIShortcutCache Item&item, m_shortcuts)348 foreach (const UIShortcutCacheRow &item, m_shortcuts) 325 349 if (!item.currentSequence().isEmpty()) 326 350 usedSequences.insertMulti(item.currentSequence(), item.key()); … … 511 535 int iIndex = index.row(); 512 536 /* Set sequence to shortcut: */ 513 UIShortcutCache Item&filteredShortcut = m_filteredShortcuts[iIndex];537 UIShortcutCacheRow &filteredShortcut = m_filteredShortcuts[iIndex]; 514 538 int iShortcutIndex = m_shortcuts.indexOf(filteredShortcut); 515 539 if (iShortcutIndex != -1) … … 539 563 qStableSort(m_shortcuts.begin(), m_shortcuts.end(), UIShortcutCacheItemFunctor(iColumn, order)); 540 564 /* Make sure host-combo item is always the first one: */ 541 UIShortcutCache Item fakeHostComboItem(UIHostCombo::hostComboCacheKey(), QString(), QString(), QString());565 UIShortcutCacheRow fakeHostComboItem(0, UIHostCombo::hostComboCacheKey(), QString(), QString(), QString()); 542 566 int iIndexOfHostComboItem = m_shortcuts.indexOf(fakeHostComboItem); 543 567 if (iIndexOfHostComboItem != -1) 544 568 { 545 UIShortcutCache ItemhostComboItem = m_shortcuts.takeAt(iIndexOfHostComboItem);569 UIShortcutCacheRow hostComboItem = m_shortcuts.takeAt(iIndexOfHostComboItem); 546 570 m_shortcuts.prepend(hostComboItem); 547 571 } … … 571 595 { 572 596 /* Check if the description matches the filter: */ 573 foreach (const UIShortcutCache Item&item, m_shortcuts)597 foreach (const UIShortcutCacheRow &item, m_shortcuts) 574 598 { 575 599 /* If neither description nor sequence matches the filter, skip item: */ … … 747 771 748 772 /* Load host-combo shortcut to cache: */ 749 m_pCache->shortcuts() << UIShortcutCache Item(UIHostCombo::hostComboCacheKey(), tr("Host Key Combination"), m_settings.hostCombo(), QString());773 m_pCache->shortcuts() << UIShortcutCacheRow(m_pMachineTable, UIHostCombo::hostComboCacheKey(), tr("Host Key Combination"), m_settings.hostCombo(), QString()); 750 774 /* Load all other shortcuts to cache: */ 751 775 const QMap<QString, UIShortcut>& shortcuts = gShortcutPool->shortcuts(); … … 754 778 { 755 779 const UIShortcut &shortcut = shortcuts[strShortcutKey]; 756 m_pCache->shortcuts() << UIShortcutCacheItem(strShortcutKey, VBoxGlobal::removeAccelMark(shortcut.description()), 757 shortcut.sequence().toString(QKeySequence::NativeText), 758 shortcut.defaultSequence().toString(QKeySequence::NativeText)); 780 QITableView *pParent = strShortcutKey.startsWith(GUI_Input_MachineShortcuts) ? m_pMachineTable : 781 strShortcutKey.startsWith(GUI_Input_SelectorShortcuts) ? m_pSelectorTable : 0; 782 AssertPtr(pParent); 783 m_pCache->shortcuts() << UIShortcutCacheRow(pParent, strShortcutKey, VBoxGlobal::removeAccelMark(shortcut.description()), 784 shortcut.sequence().toString(QKeySequence::NativeText), 785 shortcut.defaultSequence().toString(QKeySequence::NativeText)); 759 786 } 760 787 /* Load other things to cache: */ … … 796 823 797 824 /* Save host-combo shortcut from cache: */ 798 UIShortcutCache Item fakeHostComboItem(UIHostCombo::hostComboCacheKey(), QString(), QString(), QString());825 UIShortcutCacheRow fakeHostComboItem(0, UIHostCombo::hostComboCacheKey(), QString(), QString(), QString()); 799 826 int iIndexOfHostComboItem = m_pCache->shortcuts().indexOf(fakeHostComboItem); 800 827 if (iIndexOfHostComboItem != -1) … … 802 829 /* Iterate over cached shortcuts: */ 803 830 QMap<QString, QString> sequences; 804 foreach (const UIShortcutCache Item&item, m_pCache->shortcuts())831 foreach (const UIShortcutCacheRow &item, m_pCache->shortcuts()) 805 832 sequences.insert(item.key(), item.currentSequence()); 806 833 /* Save shortcut sequences from cache: */
Note:
See TracChangeset
for help on using the changeset viewer.

