Skip to content
  • Eike Ziller's avatar
    Locator: Fix diverse issues with drawing highlighted text · 3841d2fc
    Eike Ziller authored
    
    
    To draw the result items with highlighted parts, we split the text to
    draw into "before highlight", "highlight" and "after highlight", and
    painted them separately. This had several issues:
    
    It breaks the text layout. Characters within a text are often started at
    subpixels, which was not so visible in the static search results, but
    lead to ugly artifacts while typing in Locator (enter a search term, and
    then continue adding characters that still match the first found item,
    and watch the effect in the "after highlight" part).
    
    It needs a lot of custom painting code. Properly supporting text elide
    modes is hard, scaling to more than one highlight as well. Reusing parts
    of the QItemDelegate base functions also has its issues, e.g. that
    clipping doesn't work well.
    
    Instead, QItemDelegate::drawDisplay should make it possible to set
    format ranges for the text it draws. This patch copies part of
    QItemDelegate to be able to add this parameter. Unfortunately Qt
    currently has a bug (QTBUG-62019) that character backgrounds are not
    painted far enough (1 pixel to the right has the wrong background), which
    looks very ugly in selected items in the search results. So we use the
    new delegate only for Locator for now, to be used later for the search
    results too, when that bug is fixed.
    
    Task-number: QTCREATORBUG-18532
    Change-Id: Idf59b2c2bcfa6b188a810f7a3128a81e7e6fffb1
    Reviewed-by: default avatarAndré Hartmann <aha_1980@gmx.de>
    Reviewed-by: default avatarOrgad Shaneh <orgads@gmail.com>
    Reviewed-by: default avatarDavid Schulz <david.schulz@qt.io>
    3841d2fc