VirtualBox

Changeset 55134 in vbox for trunk/src/VBox/Frontends


Ignore:
Timestamp:
Apr 8, 2015 1:34:11 PM (10 years ago)
Author:
vboxsync
Message:

FE/Qt: QIStyledItemDelegate: Allow to watch for the embedded editor Enter/return key presses.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/extensions/QIStyledItemDelegate.h

    r53295 r55134  
    2828    Q_OBJECT;
    2929
     30signals:
     31
     32    /** Notifies listeners about
     33      * created editor's Enter/Return key triggering. */
     34    void sigEditorEnterKeyTriggered();
     35
    3036public:
    3137
    3238    /** Constructor. */
    33     QIStyledItemDelegate(QObject *pParent) : QStyledItemDelegate(pParent) {}
     39    QIStyledItemDelegate(QObject *pParent)
     40        : QStyledItemDelegate(pParent)
     41        , m_fWatchForEditorEnterKeyTriggering(false)
     42    {}
     43
     44    /** Defines whether QIStyledItemDelegate should watch for the created editor's Enter/Return key triggering. */
     45    void setWatchForEditorEnterKeyTriggering(bool fWatch) { m_fWatchForEditorEnterKeyTriggering = fWatch; }
    3446
    3547private:
     
    3749    /** Returns the widget used to edit the item specified by @a index for editing.
    3850      * The @a pParent widget and style @a option are used to control how the editor widget appears.
    39       * Besides Qt description copy-pasted above we are installing the hook to redirect editor's sigCommitData signal. */
     51      * Besides that, we are installing the hooks to redirect editor's sigCommitData and sigEnterKeyTriggered signals. */
    4052    QWidget* createEditor(QWidget *pParent, const QStyleOptionViewItem &option, const QModelIndex &index) const
    4153    {
    4254        /* Call to base-class to get actual editor created: */
    4355        QWidget *pEditor = QStyledItemDelegate::createEditor(pParent, option, index);
    44         /* All the stuff we actually need from QIStyledItemDelegate is to redirect this one signal: */
     56        /* All the stuff we actually need from QIStyledItemDelegate is to redirect these signals: */
    4557        connect(pEditor, SIGNAL(sigCommitData(QWidget*)), this, SIGNAL(commitData(QWidget*)));
     58        if (m_fWatchForEditorEnterKeyTriggering)
     59            connect(pEditor, SIGNAL(sigEnterKeyTriggered()), this, SIGNAL(sigEditorEnterKeyTriggered()));
    4660        /* Return actual editor: */
    4761        return pEditor;
    4862    }
     63
     64    /** Holds whether QIStyledItemDelegate should watch
     65      * for the created editor's Enter/Return key triggering. */
     66    bool m_fWatchForEditorEnterKeyTriggering;
    4967};
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