VirtualBox

Changeset 105058 in vbox


Ignore:
Timestamp:
Jun 27, 2024 12:44:55 PM (9 months ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
163677
Message:

FE/Qt: bugref:10681: UIShortcutConfigurationEditor: Rework sorting a bit to depend on Qt signals/slots; But it will be replaced with sort-filtering model anyway.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/editors/UIShortcutConfigurationEditor.cpp

    r105056 r105058  
    235235signals:
    236236
    237     /** Notifies about shortcuts loaded. */
    238     void sigShortcutsLoaded();
    239237    /** Notifies about data changed. */
    240238    void sigDataChanged();
     
    323321    virtual void setModel(QAbstractItemModel *pModel) RT_OVERRIDE;
    324322
    325 private slots:
    326 
    327     /** Handles shortcuts loaded signal. */
    328     void sltHandleShortcutsLoaded();
     323protected slots:
     324
     325    /** Handles rows being inserted.
     326      * @param  parent  Brings the parent under which new rows being inserted.
     327      * @param  iStart  Brings the starting position (inclusive).
     328      * @param  iStart  Brings the end position (inclusive). */
     329    virtual void rowsInserted(const QModelIndex &parent, int iStart, int iEnd) RT_OVERRIDE;
    329330
    330331private:
     
    374375        m_shortcuts << new UIShortcutTableViewRow(view(), item);
    375376    }
     377
    376378    /* Apply filter: */
    377379    applyFilter();
    378     /* Notify table: */
    379     emit sigShortcutsLoaded();
    380380}
    381381
     
    637637{
    638638    /* Sort whole the list: */
    639     std::stable_sort(m_shortcuts.begin(), m_shortcuts.end(), UIShortcutItemSortingFunctor(iColumn, order));
     639    std::stable_sort(m_filteredShortcuts.begin(), m_filteredShortcuts.end(), UIShortcutItemSortingFunctor(iColumn, order));
    640640    /* Make sure host-combo item is always the first one: */
    641641    UIShortcutConfigurationItem fakeHostComboItem(UIHostCombo::hostComboCacheKey(), QString(), QString(), QString(), QString());
    642642    UIShortcutTableViewRow fakeHostComboTableViewRow(0, fakeHostComboItem);
    643     const int iIndexOfHostComboItem = UIShortcutSearchFunctor<UIShortcutTableViewRow>()(m_shortcuts, fakeHostComboTableViewRow);
     643    const int iIndexOfHostComboItem = UIShortcutSearchFunctor<UIShortcutTableViewRow>()(m_filteredShortcuts, fakeHostComboTableViewRow);
    644644    if (iIndexOfHostComboItem != -1)
    645645    {
    646         UIShortcutTableViewRow *pHostComboItem = m_shortcuts.takeAt(iIndexOfHostComboItem);
    647         m_shortcuts.prepend(pHostComboItem);
    648     }
    649     /* Apply the filter: */
    650     applyFilter();
     646        UIShortcutTableViewRow *pHostComboItem = m_filteredShortcuts.takeAt(iIndexOfHostComboItem);
     647        m_filteredShortcuts.prepend(pHostComboItem);
     648    }
    651649    /* Notify the model: */
    652650    emit dataChanged(index(0, 0), index(rowCount() - 1, columnCount() - 1));
     
    741739        horizontalHeader()->setSectionResizeMode(TableColumnIndex_Description, QHeaderView::Interactive);
    742740        horizontalHeader()->setSectionResizeMode(TableColumnIndex_Sequence, QHeaderView::Stretch);
    743 
    744         /* Connect model: */
    745         UIShortcutConfigurationModel *pHotKeyTableModel = qobject_cast<UIShortcutConfigurationModel*>(model());
    746         if (pHotKeyTableModel)
    747             connect(pHotKeyTableModel, &UIShortcutConfigurationModel::sigShortcutsLoaded,
    748                     this, &UIShortcutConfigurationView::sltHandleShortcutsLoaded);
    749     }
    750 }
    751 
    752 void UIShortcutConfigurationView::sltHandleShortcutsLoaded()
    753 {
    754     /* Resize columns to feat contents: */
     741    }
     742}
     743
     744void UIShortcutConfigurationView::rowsInserted(const QModelIndex &parent, int iStart, int iEnd)
     745{
     746    /* Call to base-class: */
     747    QITableView::rowsInserted(parent, iStart, iEnd);
     748
     749    /* Resize columns to fit contents: */
    755750    resizeColumnsToContents();
    756751
    757     /* Configure sorting: */
     752    /* Reapply sorting: */
    758753    sortByColumn(TableColumnIndex_Description, Qt::AscendingOrder);
     754}
     755
     756void UIShortcutConfigurationView::prepare()
     757{
     758    /* Configure self: */
    759759    setSortingEnabled(true);
    760 }
    761 
    762 void UIShortcutConfigurationView::prepare()
    763 {
    764     /* Configure self: */
    765760    setTabKeyNavigation(false);
    766761    setContextMenuPolicy(Qt::CustomContextMenu);
     
    1004999}
    10051000
     1001
    10061002# include "UIShortcutConfigurationEditor.moc"
Note: See TracChangeset for help on using the changeset viewer.

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