src/gui/itemviews/qitemselectionmodel.cpp
changeset 3 41300fa6a67c
parent 0 1918ee327afb
child 4 3b1da2848fc7
equal deleted inserted replaced
2:56cd8111b7f7 3:41300fa6a67c
   597         if (it->topLeft().parent() != parent) {  // Check parents until reaching root or contained in range
   597         if (it->topLeft().parent() != parent) {  // Check parents until reaching root or contained in range
   598             QModelIndex itParent = it->topLeft().parent();
   598             QModelIndex itParent = it->topLeft().parent();
   599             while (itParent.isValid() && itParent.parent() != parent)
   599             while (itParent.isValid() && itParent.parent() != parent)
   600                 itParent = itParent.parent();
   600                 itParent = itParent.parent();
   601 
   601 
   602             if (parent.isValid() && start <= itParent.row() && itParent.row() <= end) {
   602             if (itParent.isValid() && start <= itParent.row() && itParent.row() <= end) {
   603                 deselected.append(*it);
   603                 deselected.append(*it);
   604                 it = ranges.erase(it);
   604                 it = ranges.erase(it);
   605             } else {
   605             } else {
   606                 ++it;
   606                 ++it;
   607             }
   607             }
   728 void QItemSelectionModelPrivate::_q_layoutAboutToBeChanged()
   728 void QItemSelectionModelPrivate::_q_layoutAboutToBeChanged()
   729 {
   729 {
   730     savedPersistentIndexes.clear();
   730     savedPersistentIndexes.clear();
   731     savedPersistentCurrentIndexes.clear();
   731     savedPersistentCurrentIndexes.clear();
   732 
   732 
   733     // special case for when all indexes are selected
   733     // optimisation for when all indexes are selected
       
   734     // (only if there is lots of items (1000) because this is not entirely correct)
   734     if (ranges.isEmpty() && currentSelection.count() == 1) {
   735     if (ranges.isEmpty() && currentSelection.count() == 1) {
   735         QItemSelectionRange range = currentSelection.first();
   736         QItemSelectionRange range = currentSelection.first();
   736         QModelIndex parent = range.parent();
   737         QModelIndex parent = range.parent();
   737         tableRowCount = model->rowCount(parent);
   738         tableRowCount = model->rowCount(parent);
   738         tableColCount = model->columnCount(parent);
   739         tableColCount = model->columnCount(parent);
   739         if (tableRowCount * tableColCount > 100
   740         if (tableRowCount * tableColCount > 1000
   740             && range.top() == 0
   741             && range.top() == 0
   741             && range.left() == 0
   742             && range.left() == 0
   742             && range.bottom() == tableRowCount - 1
   743             && range.bottom() == tableRowCount - 1
   743             && range.right() == tableColCount - 1) {
   744             && range.right() == tableColCount - 1) {
   744             tableSelected = true;
   745             tableSelected = true;
  1585                 ++s;
  1586                 ++s;
  1586             }
  1587             }
  1587         }
  1588         }
  1588     }
  1589     }
  1589 
  1590 
  1590     emit selectionChanged(selected, deselected);
  1591     if (!selected.isEmpty() || !deselected.isEmpty())
       
  1592         emit selectionChanged(selected, deselected);
  1591 }
  1593 }
  1592 
  1594 
  1593 #ifndef QT_NO_DEBUG_STREAM
  1595 #ifndef QT_NO_DEBUG_STREAM
  1594 QDebug operator<<(QDebug dbg, const QItemSelectionRange &range)
  1596 QDebug operator<<(QDebug dbg, const QItemSelectionRange &range)
  1595 {
  1597 {