comparison demos/browser/searchlineedit.d @ 73:7bfd46c330dc

more porting
author mandel
date Fri, 22 May 2009 10:59:00 +0000
parents b149ef2cb18b
children 37caa90ce503
comparison
equal deleted inserted replaced
72:b149ef2cb18b 73:7bfd46c330dc
39 ** 39 **
40 ****************************************************************************/ 40 ****************************************************************************/
41 41
42 module searchlineedit; 42 module searchlineedit;
43 43
44
44 import urllineedit; 45 import urllineedit;
45 46
46 import qt.gui.QLineEdit; 47 import qt.gui.QLineEdit;
47 import qt.gui.QAbstractButton; 48 import qt.gui.QAbstractButton;
48 import qt.gui.QPainter; 49 import qt.gui.QPainter;
49 import qt.gui.QMouseEvent; 50 import qt.gui.QMouseEvent;
50 import qt.gui.QMenu; 51 import qt.gui.QMenu;
51 import qt.gui.QStyle; 52 import qt.gui.QStyle;
52 import qt.gui.QStyleOptionFrameV2; 53 import qt.gui.QStyleOptionFrameV2;
53 54
55
54 /* 56 /*
55 QT_BEGIN_NAMESPACE 57 Clear button on the right hand side of the search widget.
56 class QMenu; 58 Hidden by default
57 QT_END_NAMESPACE 59 "A circle with an X in it"
58
59 class SearchButton;
60 */ 60 */
61
62 /*
63 Clear button on the right hand side of the search widget.
64 Hidden by default
65 "A circle with an X in it"
66 */
67 class ClearButton : public QAbstractButton 61 class ClearButton : public QAbstractButton
68 { 62 {
69 public: 63 public:
70 64
71 this(QWidget parent = null) 65 this(QWidget parent = null)
106 100
107 /* 101 /*
108 Search icon on the left hand side of the search widget 102 Search icon on the left hand side of the search widget
109 When a menu is set a down arrow appears 103 When a menu is set a down arrow appears
110 */ 104 */
111 class SearchButton : public QAbstractButton { 105 class SearchButton : public QAbstractButton
112 106 {
113 public: 107 public:
114 108
115 SearchButton(QWidget parent = null) 109 SearchButton(QWidget parent = null)
116 { 110 {
117 super(parent); 111 super(parent);
158 } 152 }
159 153
160 QMenu m_menu; 154 QMenu m_menu;
161 155
162 protected: 156 protected:
157
163 void mousePressEvent(QMouseEvent event) 158 void mousePressEvent(QMouseEvent event)
164 { 159 {
165 if (m_menu && event.button() == Qt.LeftButton) { 160 if (m_menu && event.button() == Qt.LeftButton) {
166 QWidget p = parentWidget(); 161 QWidget p = parentWidget();
167 if (p) { 162 if (p) {
174 } 169 }
175 } 170 }
176 171
177 class SearchLineEdit : public ExLineEdit 172 class SearchLineEdit : public ExLineEdit
178 { 173 {
179 //Q_PROPERTY(QString inactiveText READ inactiveText WRITE setInactiveText)
180
181 mixin Signal!("textChanged", QString &text); 174 mixin Signal!("textChanged", QString &text);
182 175
183 public: 176 public:
184 /* 177
185 SearchLineEdit is an enhanced QLineEdit 178 /*
186 - A Search icon on the left with optional menu 179 SearchLineEdit is an enhanced QLineEdit
187 - When there is no text and doesn't have focus an "inactive text" is displayed 180 - A Search icon on the left with optional menu
188 - When there is text a clear button is displayed on the right hand side 181 - When there is no text and doesn't have focus an "inactive text" is displayed
189 */ 182 - When there is text a clear button is displayed on the right hand side
183 */
190 this(QWidget parent = null) : ExLineEdit(parent) 184 this(QWidget parent = null) : ExLineEdit(parent)
191 { 185 {
192 m_searchButton = new SearchButton(this); 186 m_searchButton = new SearchButton(this);
193 lineEdit.textChanged.connect(&this.textChanged); 187 lineEdit.textChanged.connect(&this.textChanged);
194 setLeftWidget(m_searchButton); 188 setLeftWidget(m_searchButton);
225 m_searchButton.m_menu = menu; 219 m_searchButton.m_menu = menu;
226 updateGeometries(); 220 updateGeometries();
227 } 221 }
228 222
229 protected: 223 protected:
224
230 void resizeEvent(QResizeEvent event) 225 void resizeEvent(QResizeEvent event)
231 { 226 {
232 updateGeometries(); 227 updateGeometries();
233 ExLineEdit.resizeEvent(event); 228 ExLineEdit.resizeEvent(event);
234 } 229 }