Changeset 55134 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Apr 8, 2015 1:34:11 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/extensions/QIStyledItemDelegate.h
r53295 r55134 28 28 Q_OBJECT; 29 29 30 signals: 31 32 /** Notifies listeners about 33 * created editor's Enter/Return key triggering. */ 34 void sigEditorEnterKeyTriggered(); 35 30 36 public: 31 37 32 38 /** 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; } 34 46 35 47 private: … … 37 49 /** Returns the widget used to edit the item specified by @a index for editing. 38 50 * 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. */ 40 52 QWidget* createEditor(QWidget *pParent, const QStyleOptionViewItem &option, const QModelIndex &index) const 41 53 { 42 54 /* Call to base-class to get actual editor created: */ 43 55 QWidget *pEditor = QStyledItemDelegate::createEditor(pParent, option, index); 44 /* All the stuff we actually need from QIStyledItemDelegate is to redirect th is one signal: */56 /* All the stuff we actually need from QIStyledItemDelegate is to redirect these signals: */ 45 57 connect(pEditor, SIGNAL(sigCommitData(QWidget*)), this, SIGNAL(commitData(QWidget*))); 58 if (m_fWatchForEditorEnterKeyTriggering) 59 connect(pEditor, SIGNAL(sigEnterKeyTriggered()), this, SIGNAL(sigEditorEnterKeyTriggered())); 46 60 /* Return actual editor: */ 47 61 return pEditor; 48 62 } 63 64 /** Holds whether QIStyledItemDelegate should watch 65 * for the created editor's Enter/Return key triggering. */ 66 bool m_fWatchForEditorEnterKeyTriggering; 49 67 };
Note:
See TracChangeset
for help on using the changeset viewer.