1 module custom_type; 2 3 import dqml; 4 5 @QtProperty!string("text", "text", "setText", "textChanged") 6 @QtProperty!int("indentation", "indentation", "setIndentation", "indentationChanged") 7 class CustomType : QObject 8 { 9 mixin Q_OBJECT; 10 11 public: 12 this(QObject parent = null) 13 { 14 super(); 15 _indentation = 0; 16 } 17 18 this(CustomType other) 19 { 20 _text = other._text; 21 _indentation = other._indentation; 22 } 23 24 @QtSlot() 25 string text() 26 { 27 return _text; 28 } 29 30 @QtSlot() 31 void setText(string value) 32 { 33 if (_text != value) 34 { 35 _text = value; 36 textChanged(text); 37 } 38 } 39 40 @QtSignal() 41 public void textChanged(string); 42 43 @QtSlot() 44 int indentation() 45 { 46 return _indentation; 47 } 48 49 @QtSlot() 50 void setIndentation(int value) 51 { 52 if (_indentation != value) 53 { 54 _indentation = value; 55 indentationChanged(indentation); 56 } 57 } 58 59 @QtSignal() 60 public void indentationChanged(int); 61 62 private: 63 string _text; 64 int _indentation; 65 }