VirtualBox

Changeset 64264 in vbox


Ignore:
Timestamp:
Oct 13, 2016 4:44:52 PM (8 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:6899: Accessibility support (step 92): Preferences: Input page: Move UIShortcutCacheItem onto QITableViewRow rails.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsInput.cpp

    r64263 r64264  
    5353
    5454
    55 /** Global settings / Input page / Cache / Shortcut cache item. */
    56 struct UIShortcutCacheItem
    57 {
     55/** Global settings / Input page / Shortcut table row. */
     56class UIShortcutCacheRow : public QITableViewRow
     57{
     58    Q_OBJECT;
     59
     60public:
     61
    5862    /** Constructs table row on the basis of passed arguments.
     63      * @param  pParent             Brings the row this cell belongs too.
    5964      * @param  strKey              Brings the unique key inentifying held sequence.
    6065      * @param  strDescription      Brings the deescription for the held sequence.
    6166      * @param  strCurrentSequence  Brings the current held sequence.
    6267      * @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)
    6875        , m_strDescription(strDescription)
    6976        , m_strCurrentSequence(strCurrentSequence)
     
    7279
    7380    /** 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())
    7684        , m_strDescription(other.description())
    7785        , m_strCurrentSequence(other.currentSequence())
     
    8088
    8189    /** Copies a table row from @a other one. */
    82     UIShortcutCacheItem &operator=(const UIShortcutCacheItem &other)
     90    UIShortcutCacheRow &operator=(const UIShortcutCacheRow &other)
    8391    {
    8492        /* Reassign variables: */
     93        setTable(other.table());
    8594        m_strKey = other.key();
    8695        m_strDescription = other.description();
     
    93102
    94103    /** Returns whether this row equals to @a other. */
    95     bool operator==(const UIShortcutCacheItem &other) const
     104    bool operator==(const UIShortcutCacheRow &other) const
    96105    {
    97106        /* Compare by the key only: */
     
    110119    /** Defines @a strCurrentSequence. */
    111120    void setCurrentSequence(const QString &strCurrentSequence) { m_strCurrentSequence = strCurrentSequence; }
     121
     122protected:
     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    }
    112136
    113137private:
     
    125149
    126150/** Global settings / Input page / Cache / Shortcut cache. */
    127 typedef QList<UIShortcutCacheItem> UIShortcutCache;
     151typedef QList<UIShortcutCacheRow> UIShortcutCache;
    128152
    129153
     
    174198    /** Returns whether the @a item1 is more/less than the @a item2.
    175199      * @note  Order depends on the one set through constructor, stored in m_order. */
    176     bool operator()(const UIShortcutCacheItem &item1, const UIShortcutCacheItem &item2)
     200    bool operator()(const UIShortcutCacheRow &item1, const UIShortcutCacheRow &item2)
    177201    {
    178202        switch (m_iColumn)
     
    288312{
    289313    /* Load shortcuts: */
    290     foreach (const UIShortcutCacheItem &item, shortcuts)
     314    foreach (const UIShortcutCacheRow &item, shortcuts)
    291315    {
    292316        /* Filter out unnecessary shortcuts: */
     
    306330{
    307331    /* Save model items: */
    308     foreach (const UIShortcutCacheItem &item, m_shortcuts)
     332    foreach (const UIShortcutCacheRow &item, m_shortcuts)
    309333    {
    310334        /* Search for corresponding cache item index: */
     
    322346    /* Enumerate all the sequences: */
    323347    QMap<QString, QString> usedSequences;
    324     foreach (const UIShortcutCacheItem &item, m_shortcuts)
     348    foreach (const UIShortcutCacheRow &item, m_shortcuts)
    325349        if (!item.currentSequence().isEmpty())
    326350            usedSequences.insertMulti(item.currentSequence(), item.key());
     
    511535                    int iIndex = index.row();
    512536                    /* Set sequence to shortcut: */
    513                     UIShortcutCacheItem &filteredShortcut = m_filteredShortcuts[iIndex];
     537                    UIShortcutCacheRow &filteredShortcut = m_filteredShortcuts[iIndex];
    514538                    int iShortcutIndex = m_shortcuts.indexOf(filteredShortcut);
    515539                    if (iShortcutIndex != -1)
     
    539563    qStableSort(m_shortcuts.begin(), m_shortcuts.end(), UIShortcutCacheItemFunctor(iColumn, order));
    540564    /* Make sure host-combo item is always the first one: */
    541     UIShortcutCacheItem fakeHostComboItem(UIHostCombo::hostComboCacheKey(), QString(), QString(), QString());
     565    UIShortcutCacheRow fakeHostComboItem(0, UIHostCombo::hostComboCacheKey(), QString(), QString(), QString());
    542566    int iIndexOfHostComboItem = m_shortcuts.indexOf(fakeHostComboItem);
    543567    if (iIndexOfHostComboItem != -1)
    544568    {
    545         UIShortcutCacheItem hostComboItem = m_shortcuts.takeAt(iIndexOfHostComboItem);
     569        UIShortcutCacheRow hostComboItem = m_shortcuts.takeAt(iIndexOfHostComboItem);
    546570        m_shortcuts.prepend(hostComboItem);
    547571    }
     
    571595    {
    572596        /* Check if the description matches the filter: */
    573         foreach (const UIShortcutCacheItem &item, m_shortcuts)
     597        foreach (const UIShortcutCacheRow &item, m_shortcuts)
    574598        {
    575599            /* If neither description nor sequence matches the filter, skip item: */
     
    747771
    748772    /* Load host-combo shortcut to cache: */
    749     m_pCache->shortcuts() << UIShortcutCacheItem(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());
    750774    /* Load all other shortcuts to cache: */
    751775    const QMap<QString, UIShortcut>& shortcuts = gShortcutPool->shortcuts();
     
    754778    {
    755779        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));
    759786    }
    760787    /* Load other things to cache: */
     
    796823
    797824    /* Save host-combo shortcut from cache: */
    798     UIShortcutCacheItem fakeHostComboItem(UIHostCombo::hostComboCacheKey(), QString(), QString(), QString());
     825    UIShortcutCacheRow fakeHostComboItem(0, UIHostCombo::hostComboCacheKey(), QString(), QString(), QString());
    799826    int iIndexOfHostComboItem = m_pCache->shortcuts().indexOf(fakeHostComboItem);
    800827    if (iIndexOfHostComboItem != -1)
     
    802829    /* Iterate over cached shortcuts: */
    803830    QMap<QString, QString> sequences;
    804     foreach (const UIShortcutCacheItem &item, m_pCache->shortcuts())
     831    foreach (const UIShortcutCacheRow &item, m_pCache->shortcuts())
    805832        sequences.insert(item.key(), item.currentSequence());
    806833    /* Save shortcut sequences from cache: */
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette