- Timestamp:
- Oct 6, 2016 12:22:33 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/extensions/QIStyledItemDelegate.h
r62493 r64161 16 16 */ 17 17 18 #if def VBOX_WITH_PRECOMPILED_HEADERS19 # include <precomp.h>20 #else /* !VBOX_WITH_PRECOMPILED_HEADERS */ 18 #ifndef ___QIStyledItemDelegate_h___ 19 #define ___QIStyledItemDelegate_h___ 20 21 21 /* Qt includes: */ 22 22 # include <QStyledItemDelegate> 23 #endif /* !VBOX_WITH_PRECOMPILED_HEADERS */24 23 25 /** Own QStyledItemDelegate implementation. */ 24 25 /** QStyledItemDelegate subclass extending standard functionality. */ 26 26 class QIStyledItemDelegate : public QStyledItemDelegate 27 27 { … … 30 30 signals: 31 31 32 /** Notifies listeners about 33 * created editor's Enter/Return key triggering. */ 32 /** Notifies listeners about editor's Enter key triggering. */ 34 33 void sigEditorEnterKeyTriggered(); 35 34 36 35 public: 37 36 38 /** Construct or. */37 /** Constructs delegate passing @a pParent to the base-class. */ 39 38 QIStyledItemDelegate(QObject *pParent) 40 39 : QStyledItemDelegate(pParent) … … 42 41 {} 43 42 44 /** Defines whether QIStyledItemDelegate should watch for the created editor's Enter/Returnkey triggering. */43 /** Defines whether delegate should watch for the editor's Enter key triggering. */ 45 44 void setWatchForEditorEnterKeyTriggering(bool fWatch) { m_fWatchForEditorEnterKeyTriggering = fWatch; } 46 45 47 46 private: 48 47 49 /** Returns the widget used to edit the item specified by @a index for editing. 50 * The @a pParent widget and style @a option are used to control how the editor widget appears. 51 * Besides that, we are installing the hooks to redirect editor's sigCommitData and sigEnterKeyTriggered signals. */ 48 /** Returns the widget used to edit the item specified by @a index. 49 * The @a pParent widget and style @a option are used to control how the editor widget appears. */ 52 50 QWidget* createEditor(QWidget *pParent, const QStyleOptionViewItem &option, const QModelIndex &index) const 53 51 { 54 52 /* Call to base-class to get actual editor created: */ 55 53 QWidget *pEditor = QStyledItemDelegate::createEditor(pParent, option, index); 56 /* All the stuff we actually need from QIStyledItemDelegate is to redirect these signals: */ 54 57 55 connect(pEditor, SIGNAL(sigCommitData(QWidget*)), this, SIGNAL(commitData(QWidget*))); 56 57 /* Watch for editor Enter key triggering, redirect to listeners: */ 58 58 if (m_fWatchForEditorEnterKeyTriggering) 59 59 connect(pEditor, SIGNAL(sigEnterKeyTriggered()), this, SIGNAL(sigEditorEnterKeyTriggered())); 60 60 61 /* Return actual editor: */ 61 62 return pEditor; 62 63 } 63 64 64 /** Holds whether QIStyledItemDelegate should watch 65 * for the created editor's Enter/Return key triggering. */ 65 /** Holds whether delegate should watch for the editor's Enter key triggering. */ 66 66 bool m_fWatchForEditorEnterKeyTriggering; 67 67 }; 68 69 #endif /* !___QIStyledItemDelegate_h___ */ 70
Note:
See TracChangeset
for help on using the changeset viewer.