equal
deleted
inserted
replaced
192 QString text = index.data(Qt::DisplayRole).toString(); |
192 QString text = index.data(Qt::DisplayRole).toString(); |
193 QFont font(option.font); |
193 QFont font(option.font); |
194 // font.setFamily(text); |
194 // font.setFamily(text); |
195 font.setPointSize(QFontInfo(font).pointSize() * 3/2); |
195 font.setPointSize(QFontInfo(font).pointSize() * 3/2); |
196 QFontMetrics fontMetrics(font); |
196 QFontMetrics fontMetrics(font); |
197 return QSize(fontMetrics.width(text), fontMetrics.lineSpacing()); |
197 return QSize(fontMetrics.width(text), fontMetrics.height()); |
198 } |
198 } |
199 |
199 |
200 |
200 |
201 class QFontComboBoxPrivate : public QComboBoxPrivate |
201 class QFontComboBoxPrivate : public QComboBoxPrivate |
202 { |
202 { |
245 if (list.at(i) == fi.family() || list.at(i).startsWith(fi.family() + QLatin1String(" ["))) |
245 if (list.at(i) == fi.family() || list.at(i).startsWith(fi.family() + QLatin1String(" ["))) |
246 offset = result.count() - 1; |
246 offset = result.count() - 1; |
247 } |
247 } |
248 list = result; |
248 list = result; |
249 |
249 |
|
250 //we need to block the signals so that the model doesn't emit reset |
|
251 //this prevents the current index from changing |
|
252 //it will be updated just after this |
|
253 ///TODO: we should finda way to avoid blocking signals and have a real update of the model |
|
254 const bool old = m->blockSignals(true); |
250 m->setStringList(list); |
255 m->setStringList(list); |
|
256 m->blockSignals(old); |
|
257 |
251 if (list.isEmpty()) { |
258 if (list.isEmpty()) { |
252 if (currentFont != QFont()) { |
259 if (currentFont != QFont()) { |
253 currentFont = QFont(); |
260 currentFont = QFont(); |
254 emit q->currentFontChanged(currentFont); |
261 emit q->currentFontChanged(currentFont); |
255 } |
262 } |
260 |
267 |
261 |
268 |
262 void QFontComboBoxPrivate::_q_currentChanged(const QString &text) |
269 void QFontComboBoxPrivate::_q_currentChanged(const QString &text) |
263 { |
270 { |
264 Q_Q(QFontComboBox); |
271 Q_Q(QFontComboBox); |
265 QFont newFont(text); |
272 if (currentFont.family() != text) { |
266 if (currentFont.family() != newFont.family()) { |
273 currentFont.setFamily(text); |
267 currentFont = newFont; |
|
268 emit q->currentFontChanged(currentFont); |
274 emit q->currentFontChanged(currentFont); |
269 } |
275 } |
270 } |
276 } |
271 |
277 |
272 /*! |
278 /*! |
418 void QFontComboBox::setCurrentFont(const QFont &font) |
424 void QFontComboBox::setCurrentFont(const QFont &font) |
419 { |
425 { |
420 Q_D(QFontComboBox); |
426 Q_D(QFontComboBox); |
421 if (font != d->currentFont) { |
427 if (font != d->currentFont) { |
422 d->currentFont = font; |
428 d->currentFont = font; |
423 emit currentFontChanged(d->currentFont); |
|
424 d->_q_updateModel(); |
429 d->_q_updateModel(); |
|
430 if (d->currentFont == font) { //else the signal has already be emitted by _q_updateModel |
|
431 emit currentFontChanged(d->currentFont); |
|
432 } |
425 } |
433 } |
426 } |
434 } |
427 |
435 |
428 /*! |
436 /*! |
429 \fn QFontComboBox::currentFontChanged(const QFont &font) |
437 \fn QFontComboBox::currentFontChanged(const QFont &font) |