124 Q_Q(QLineEdit); |
124 Q_Q(QLineEdit); |
125 q->setEditFocus(e); |
125 q->setEditFocus(e); |
126 } |
126 } |
127 #endif |
127 #endif |
128 |
128 |
|
129 void QLineEditPrivate::_q_selectionChanged() |
|
130 { |
|
131 Q_Q(QLineEdit); |
|
132 if (control->preeditAreaText().isEmpty()) { |
|
133 QStyleOptionFrameV2 opt; |
|
134 q->initStyleOption(&opt); |
|
135 bool showCursor = control->hasSelectedText() ? |
|
136 q->style()->styleHint(QStyle::SH_BlinkCursorWhenTextSelected, &opt, q): |
|
137 true; |
|
138 setCursorVisible(showCursor); |
|
139 } |
|
140 |
|
141 emit q->selectionChanged(); |
|
142 } |
|
143 |
129 void QLineEditPrivate::init(const QString& txt) |
144 void QLineEditPrivate::init(const QString& txt) |
130 { |
145 { |
131 Q_Q(QLineEdit); |
146 Q_Q(QLineEdit); |
132 control = new QLineControl(txt); |
147 control = new QLineControl(txt); |
133 control->setFont(q->font()); |
148 control->setFont(q->font()); |
134 QObject::connect(control, SIGNAL(textChanged(const QString &)), |
149 QObject::connect(control, SIGNAL(textChanged(QString)), |
135 q, SIGNAL(textChanged(const QString &))); |
150 q, SIGNAL(textChanged(QString))); |
136 QObject::connect(control, SIGNAL(textEdited(const QString &)), |
151 QObject::connect(control, SIGNAL(textEdited(QString)), |
137 q, SLOT(_q_textEdited(const QString &))); |
152 q, SLOT(_q_textEdited(QString))); |
138 QObject::connect(control, SIGNAL(cursorPositionChanged(int, int)), |
153 QObject::connect(control, SIGNAL(cursorPositionChanged(int,int)), |
139 q, SLOT(_q_cursorPositionChanged(int, int))); |
154 q, SLOT(_q_cursorPositionChanged(int,int))); |
140 QObject::connect(control, SIGNAL(selectionChanged()), |
155 QObject::connect(control, SIGNAL(selectionChanged()), |
141 q, SIGNAL(selectionChanged())); |
156 q, SLOT(_q_selectionChanged())); |
142 QObject::connect(control, SIGNAL(accepted()), |
157 QObject::connect(control, SIGNAL(accepted()), |
143 q, SIGNAL(returnPressed())); |
158 q, SIGNAL(returnPressed())); |
144 QObject::connect(control, SIGNAL(editingFinished()), |
159 QObject::connect(control, SIGNAL(editingFinished()), |
145 q, SIGNAL(editingFinished())); |
160 q, SIGNAL(editingFinished())); |
146 #ifdef QT_KEYPAD_NAVIGATION |
161 #ifdef QT_KEYPAD_NAVIGATION |
147 QObject::connect(control, SIGNAL(editFocusChange(bool)), |
162 QObject::connect(control, SIGNAL(editFocusChange(bool)), |
148 q, SLOT(_q_editFocusChange(bool))); |
163 q, SLOT(_q_editFocusChange(bool))); |
149 #endif |
164 #endif |
150 QObject::connect(control, SIGNAL(cursorPositionChanged(int, int)), |
165 QObject::connect(control, SIGNAL(cursorPositionChanged(int,int)), |
|
166 q, SLOT(updateMicroFocus())); |
|
167 |
|
168 QObject::connect(control, SIGNAL(textChanged(const QString &)), |
151 q, SLOT(updateMicroFocus())); |
169 q, SLOT(updateMicroFocus())); |
152 |
170 |
153 // for now, going completely overboard with updates. |
171 // for now, going completely overboard with updates. |
154 QObject::connect(control, SIGNAL(selectionChanged()), |
172 QObject::connect(control, SIGNAL(selectionChanged()), |
155 q, SLOT(update())); |
173 q, SLOT(update())); |
156 |
174 |
157 QObject::connect(control, SIGNAL(displayTextChanged(const QString &)), |
175 QObject::connect(control, SIGNAL(displayTextChanged(QString)), |
158 q, SLOT(update())); |
176 q, SLOT(update())); |
159 |
177 |
160 QObject::connect(control, SIGNAL(updateNeeded(const QRect &)), |
178 QObject::connect(control, SIGNAL(updateNeeded(QRect)), |
161 q, SLOT(update())); |
179 q, SLOT(update())); |
162 |
180 |
163 QStyleOptionFrameV2 opt; |
181 QStyleOptionFrameV2 opt; |
164 q->initStyleOption(&opt); |
182 q->initStyleOption(&opt); |
165 control->setPasswordCharacter(q->style()->styleHint(QStyle::SH_LineEdit_PasswordCharacter, &opt, q)); |
183 control->setPasswordCharacter(q->style()->styleHint(QStyle::SH_LineEdit_PasswordCharacter, &opt, q)); |