Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-33954

Extreme delay after selecting all items of a model with a large subtree and changing the sort order in ItemView (Headerview repaint)

    XMLWordPrintable

    Details

    • Commits:
      9c774b7621fdc99c03fad1b424b09b82057dc748 (dev, 17.7.2014, 5.4)

      Description

      To reproduce:
      1. Add big amount (2000) of items to itemview
      2. Select All
      3. Change column sorting order pressing from header section
      4. Try to resize column from header section
      -> column is resized but with extreme long delay

      Reason for the delay is investigated to the next lines:

      /src/gui/itemviews/qitemselectionmodel.cpp
      bool QItemSelectionModel::isColumnSelected(int column, const QModelIndex &parent) const
      {
      . . .
          // add ranges and currentSelection and check through them all
          QList<QItemSelectionRange>::const_iterator it;
          QList<QItemSelectionRange> joined = d->ranges;
          if (d->currentSelection.count())
              joined += d->currentSelection;
          int rowCount = d->model->rowCount(parent);
          for (int row = 0; row < rowCount; ++row) {
               for (it = joined.constBegin(); it != joined.constEnd(); ++it) {
                   if ((*it).contains(row, column, parent)) {
                       Qt::ItemFlags flags = d->model->index(row, column, parent).flags();
                       if ((flags & Qt::ItemIsSelectable) && (flags & Qt::ItemIsEnabled)) {
                           row = qMax(row, (*it).bottom());
                           break;
                       }
                   }
               }
               if (it == joined.constEnd())
                   return false;
          }
        return rowCount > 0; // no rows means no selected items
      }
      

      Replacing above loop with the following code boosts up issue to invisible. But don't know side-effects if joined/range items are not checked.

          for (int row = 0; row < rowCount; ++row) {
              Qt::ItemFlags flags = d->model->index(row, column, parent).flags();
              if ((flags & Qt::ItemIsSelectable) && !(flags & Qt::ItemIsEnabled)) {
                  return false;
              }
          }
      

      Attached treewidgetdelay.zip contains full small application to reproduce the issue.

        Attachments

        1. treewidgetdelay.zip
          2 kB
        2. qtbug33954.zip
          2 kB
        3. qtbug33954_diag5.diff
          11 kB
        4. qtbug33954_20items_log.txt
          203 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

            Assignee:
            kleint Friedemann Kleint
            Reporter:
            qtcomsupport Qt Support
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Gerrit Reviews

                There are no open Gerrit changes