diff options
author | Qt Continuous Integration System <qt-info@nokia.com> | 2010-05-25 11:42:10 (GMT) |
---|---|---|
committer | Qt Continuous Integration System <qt-info@nokia.com> | 2010-05-25 11:42:10 (GMT) |
commit | 3985150b2a3f30e3676c82412446aa2735d42b34 (patch) | |
tree | 4cfddea1ba11e314dceb26f646938db4efa55b9a | |
parent | 3ab0ecc3459ae80e038e311a053ce780dcdcd7cf (diff) | |
parent | 07f4d8b7cc658609ef7b0a08adb9ed637b13a958 (diff) | |
download | Qt-3985150b2a3f30e3676c82412446aa2735d42b34.zip Qt-3985150b2a3f30e3676c82412446aa2735d42b34.tar.gz Qt-3985150b2a3f30e3676c82412446aa2735d42b34.tar.bz2 |
Merge branch 'master' of scm.dev.nokia.troll.no:qt/oslo-staging-2 into master-integration
* 'master' of scm.dev.nokia.troll.no:qt/oslo-staging-2:
Use binarysort to find items.
QComboBox: Fix documentation and make auto-test pass.
-rw-r--r-- | src/gui/text/qtextengine.cpp | 19 | ||||
-rw-r--r-- | src/gui/text/qtextlayout.cpp | 24 | ||||
-rw-r--r-- | src/gui/widgets/qcombobox.cpp | 2 | ||||
-rw-r--r-- | tests/auto/qcombobox/tst_qcombobox.cpp | 6 |
4 files changed, 34 insertions, 17 deletions
diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp index d34553f..dc099fc 100644 --- a/src/gui/text/qtextengine.cpp +++ b/src/gui/text/qtextengine.cpp @@ -1518,14 +1518,19 @@ void QTextEngine::itemize() const int QTextEngine::findItem(int strPos) const { itemize(); - - // ##### use binary search - int item; - for (item = layoutData->items.size()-1; item > 0; --item) { - if (layoutData->items[item].position <= strPos) - break; + int left = 0; + int right = layoutData->items.size()-1; + while(left <= right) { + int middle = ((right-left)/2)+left; + if (strPos > layoutData->items[middle].position) + left = middle+1; + else if(strPos < layoutData->items[middle].position) + right = middle-1; + else { + return middle; + } } - return item; + return right; } QFixed QTextEngine::width(int from, int len) const diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp index ce7915d..94d9d67 100644 --- a/src/gui/text/qtextlayout.cpp +++ b/src/gui/text/qtextlayout.cpp @@ -1208,7 +1208,7 @@ void QTextLayout::draw(QPainter *p, const QPointF &pos, const QVector<FormatRang bool hasText = (selection.format.foreground().style() != Qt::NoBrush); bool hasBackground= (selection.format.background().style() != Qt::NoBrush); - + if (hasBackground) { selection.format.setProperty(ObjectSelectionBrush, selection.format.property(QTextFormat::BackgroundBrush)); // don't just clear the property, set an empty brush that overrides a potential @@ -1715,7 +1715,7 @@ namespace { }; inline bool LineBreakHelper::checkFullOtherwiseExtend(QScriptLine &line) -{ +{ LB_DEBUG("possible break width %f, spacew=%f", tmpData.textWidth.toReal(), spaceData.textWidth.toReal()); QFixed newWidth = calculateNewWidth(line); @@ -1781,13 +1781,23 @@ void QTextLine::layout_helper(int maxGlyphs) bool breakany = (wrapMode == QTextOption::WrapAnywhere); lbh.manualWrap = (wrapMode == QTextOption::ManualWrap || wrapMode == QTextOption::NoWrap); - // #### binary search! int item = -1; - int newItem; - for (newItem = eng->layoutData->items.size()-1; newItem > 0; --newItem) { - if (eng->layoutData->items[newItem].position <= line.from) + int newItem = -1; + int left = 0; + int right = eng->layoutData->items.size()-1; + while(left <= right) { + int middle = ((right-left)/2)+left; + if (line.from > eng->layoutData->items[middle].position) + left = middle+1; + else if(line.from < eng->layoutData->items[middle].position) + right = middle-1; + else { + newItem = middle; break; + } } + if (newItem == -1) + newItem = right; LB_DEBUG("from: %d: item=%d, total %d, width available %f", line.from, newItem, eng->layoutData->items.size(), line.width.toReal()); @@ -1939,7 +1949,7 @@ void QTextLine::layout_helper(int maxGlyphs) } LB_DEBUG("reached end of line"); lbh.checkFullOtherwiseExtend(line); -found: +found: if (lbh.rightBearing > 0) // If right bearing has not yet been adjusted lbh.adjustRightBearing(); line.textAdvance = line.textWidth; diff --git a/src/gui/widgets/qcombobox.cpp b/src/gui/widgets/qcombobox.cpp index 1504066..6cf24a6 100644 --- a/src/gui/widgets/qcombobox.cpp +++ b/src/gui/widgets/qcombobox.cpp @@ -1293,7 +1293,7 @@ QComboBox::~QComboBox() By default, this property has a value of 10. \note This property is ignored for non-editable comboboxes in styles that returns - false for QStyle::SH_ComboBox_Popup such as the Mac style or the Gtk+ Style. + true for QStyle::SH_ComboBox_Popup such as the Mac style or the Gtk+ Style. */ int QComboBox::maxVisibleItems() const { diff --git a/tests/auto/qcombobox/tst_qcombobox.cpp b/tests/auto/qcombobox/tst_qcombobox.cpp index 1fcea9e..aa821c2 100644 --- a/tests/auto/qcombobox/tst_qcombobox.cpp +++ b/tests/auto/qcombobox/tst_qcombobox.cpp @@ -2553,9 +2553,11 @@ void tst_QComboBox::maxVisibleItems() QAbstractItemView *v = comboBox.view(); int itemHeight = v->visualRect(v->model()->index(0,0)).height(); - if (v->style()->styleHint(QStyle::SH_ComboBox_Popup)) + QListView *lv = qobject_cast<QListView*>(v); + if (lv) + itemHeight += lv->spacing(); + if (!v->style()->styleHint(QStyle::SH_ComboBox_Popup)) QCOMPARE(v->viewport()->height(), itemHeight * comboBox.maxVisibleItems()); - // QCombobox without a popup does not work, see QTBUG-760 } |