1 /**************************************************************************** 2 ** 3 ** DQt - D bindings for the Qt Toolkit 4 ** 5 ** GNU Lesser General Public License Usage 6 ** This file may be used under the terms of the GNU Lesser 7 ** General Public License version 3 as published by the Free Software 8 ** Foundation and appearing in the file LICENSE.LGPL3 included in the 9 ** packaging of this file. Please review the following information to 10 ** ensure the GNU Lesser General Public License version 3 requirements 11 ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. 12 ** 13 ****************************************************************************/ 14 module qt.widgets.abstractitemdelegate; 15 extern(C++): 16 17 import qt.config; 18 import qt.core.abstractitemmodel; 19 import qt.core.coreevent; 20 import qt.core.namespace; 21 import qt.core.object; 22 import qt.core.size; 23 import qt.core.string; 24 import qt.core.vector; 25 import qt.gui.event; 26 import qt.gui.fontmetrics; 27 import qt.gui.painter; 28 import qt.helpers; 29 import qt.widgets.abstractitemview; 30 import qt.widgets.styleoption; 31 import qt.widgets.widget; 32 33 /+ QT_REQUIRE_CONFIG(itemviews); 34 35 36 class QPainter; 37 class QModelIndex; 38 class QAbstractItemModel; 39 class QAbstractItemView; 40 class QHelpEvent; +/ 41 extern(C++, class) struct QAbstractItemDelegatePrivate; 42 43 class /+ Q_WIDGETS_EXPORT +/ QAbstractItemDelegate : QObject 44 { 45 mixin(Q_OBJECT); 46 47 public: 48 49 enum EndEditHint { 50 NoHint, 51 EditNextItem, 52 EditPreviousItem, 53 SubmitModelCache, 54 RevertModelCache 55 } 56 57 /+ explicit +/this(QObject parent = null); 58 /+ virtual +/~this(); 59 60 // painting 61 /+ virtual +/ abstract void paint(QPainter* painter, 62 ref const(QStyleOptionViewItem) option, 63 ref const(QModelIndex) index) const; 64 65 /+ virtual +/ abstract QSize sizeHint(ref const(QStyleOptionViewItem) option, 66 ref const(QModelIndex) index) const; 67 68 // editing 69 /+ virtual +/ QWidget createEditor(QWidget parent, 70 ref const(QStyleOptionViewItem) option, 71 ref const(QModelIndex) index) const; 72 73 /+ virtual +/ void destroyEditor(QWidget editor, ref const(QModelIndex) index) const; 74 75 /+ virtual +/ void setEditorData(QWidget editor, ref const(QModelIndex) index) const; 76 77 /+ virtual +/ void setModelData(QWidget editor, 78 QAbstractItemModel model, 79 ref const(QModelIndex) index) const; 80 81 /+ virtual +/ void updateEditorGeometry(QWidget editor, 82 ref const(QStyleOptionViewItem) option, 83 ref const(QModelIndex) index) const; 84 85 // for non-widget editors 86 /+ virtual +/ bool editorEvent(QEvent event, 87 QAbstractItemModel model, 88 ref const(QStyleOptionViewItem) option, 89 ref const(QModelIndex) index); 90 91 /+ #if QT_DEPRECATED_SINCE(5, 13) +/ 92 /+ QT_DEPRECATED_X("Use QFontMetrics::elidedText() instead") +/ 93 static QString elidedText(ref const(QFontMetrics) fontMetrics, int width, 94 /+ Qt:: +/qt.core.namespace.TextElideMode mode, ref const(QString) text); 95 /+ #endif +/ 96 97 /+ virtual +/ bool helpEvent(QHelpEvent event, 98 QAbstractItemView view, 99 ref const(QStyleOptionViewItem) option, 100 ref const(QModelIndex) index); 101 102 /+ virtual +/ QVector!(int) paintingRoles() const; 103 104 /+ Q_SIGNALS +/public: 105 @QSignal final void commitData(QWidget editor); 106 @QSignal final void closeEditor(QWidget editor, QAbstractItemDelegate.EndEditHint hint = EndEditHint.NoHint); 107 @QSignal final void sizeHintChanged(ref const(QModelIndex) ); 108 109 protected: 110 this(ref QObjectPrivate , QObject parent = null); 111 private: 112 /+ Q_DECLARE_PRIVATE(QAbstractItemDelegate) +/ 113 /+ Q_DISABLE_COPY(QAbstractItemDelegate) +/ 114 /+ Q_PRIVATE_SLOT(d_func(), void _q_commitDataAndCloseEditor(QWidget*)) +/ 115 } 116