Ignore:
Timestamp:
May 5, 2011, 5:36:53 AM (14 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.7.2 sources from branches/vendor/nokia/qt.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/gui/itemviews/qabstractitemview.cpp

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    105105        currentIndexSet(false),
    106106        wrapItemText(false),
    107         delayedPendingLayout(false)
    108 {
     107        delayedPendingLayout(true),
     108        moveCursorUpdatedView(false)
     109{
     110    keyboardInputTime.invalidate();
    109111}
    110112
     
    131133
    132134    viewport->setBackgroundRole(QPalette::Base);
    133 
    134     doDelayedItemsLayout();
    135135
    136136    q->setAttribute(Qt::WA_InputMethodEnabled);
     
    596596QAbstractItemView::~QAbstractItemView()
    597597{
     598    Q_D(QAbstractItemView);
     599    // stop these timers here before ~QObject
     600    d->delayedReset.stop();
     601    d->updateTimer.stop();
     602    d->delayedEditing.stop();
     603    d->delayedAutoScroll.stop();
     604    d->autoScrollTimer.stop();
     605    d->delayedLayout.stop();
     606    d->fetchMoreTimer.stop();
    598607}
    599608
     
    680689        connect(d->model, SIGNAL(layoutChanged()), this, SLOT(_q_layoutChanged()));
    681690    }
    682     setSelectionModel(new QItemSelectionModel(d->model, this));
     691
     692    QItemSelectionModel *selection_model = new QItemSelectionModel(d->model, this);
     693    connect(d->model, SIGNAL(destroyed()), selection_model, SLOT(deleteLater()));
     694    setSelectionModel(selection_model);
     695
    683696    reset(); // kill editors, set new root and do layout
    684697}
     
    824837
    825838    \note If a delegate has been assigned to both a row and a column, the row
    826     delegate (i.e., this delegate) will take presedence and manage the
     839    delegate (i.e., this delegate) will take precedence and manage the
    827840    intersecting cell index.
    828841
     
    882895
    883896    \note If a delegate has been assigned to both a row and a column, the row
    884     delegate will take presedence and manage the intersecting cell index.
     897    delegate will take precedence and manage the intersecting cell index.
    885898
    886899    \warning You should not share the same instance of a delegate between views.
     
    11631176    \brief how the view scrolls its contents in the vertical direction
    11641177
    1165     This property controlls how the view scroll its contents vertically.
     1178    This property controls how the view scroll its contents vertically.
    11661179    Scrolling can be done either per pixel or per item.
    11671180*/
     
    11891202    \brief how the view scrolls its contents in the horizontal direction
    11901203
    1191     This property controlls how the view scroll its contents horizontally.
     1204    This property controls how the view scroll its contents horizontally.
    11921205    Scrolling can be done either per pixel or per item.
    11931206*/
     
    12721285    \brief the size of the area when auto scrolling is triggered
    12731286
    1274     This property controlls the size of the area at the edge of the viewport that
     1287    This property controls the size of the area at the edge of the viewport that
    12751288    triggers autoscrolling. The default value is 16 pixels.
    12761289*/
     
    13601373    Note that the model used needs to provide support for drag and drop operations.
    13611374
    1362     \sa setDragDropMode() {Using Drag and Drop with Item Views}
     1375    \sa setDragDropMode() {Using drag and drop with item views}
    13631376*/
    13641377
     
    20942107        d->autoScroll = false;
    20952108        QModelIndex index = moveCursor(MoveNext, Qt::NoModifier); // first visible index
    2096         if (index.isValid() && d->isIndexEnabled(index))
     2109        if (index.isValid() && d->isIndexEnabled(index) && event->reason() != Qt::MouseFocusReason)
    20972110            selectionModel()->setCurrentIndex(index, QItemSelectionModel::NoUpdate);
    20982111        d->autoScroll = autoScroll;
     
    22142227
    22152228    QPersistentModelIndex newCurrent;
     2229    d->moveCursorUpdatedView = false;
    22162230    switch (event->key()) {
    22172231    case Qt::Key_Down:
     
    22662280                d->selectionModel->setCurrentIndex(newCurrent, command);
    22672281                d->pressedPosition = visualRect(newCurrent).center() + d->offset();
    2268                 // We copy the same behaviour as for mousePressEvent().
    2269                 QRect rect(d->pressedPosition - d->offset(), QSize(1, 1));
    2270                 setSelection(rect, command);
     2282                if (newCurrent.isValid()) {
     2283                    // We copy the same behaviour as for mousePressEvent().
     2284                    QRect rect(d->pressedPosition - d->offset(), QSize(1, 1));
     2285                    setSelection(rect, command);
     2286                }
    22712287            }
     2288            event->accept();
    22722289            return;
    22732290        }
     
    23012318    case Qt::Key_Shift:
    23022319    case Qt::Key_Control:
     2320    case Qt::Key_Delete:
     2321    case Qt::Key_Backspace:
    23032322        event->ignore();
    23042323        break;
     
    23652384        break; }
    23662385    }
     2386    if (d->moveCursorUpdatedView)
     2387        event->accept();
    23672388}
    23682389
     
    28412862    QModelIndex start = currentIndex().isValid() ? currentIndex()
    28422863                        : d->model->index(0, 0, d->root);
    2843     QTime now(QTime::currentTime());
    28442864    bool skipRow = false;
    2845     if (search.isEmpty()
    2846         || (d->keyboardInputTime.msecsTo(now) > QApplication::keyboardInputInterval())) {
     2865    bool keyboardTimeWasValid = d->keyboardInputTime.isValid();
     2866    qint64 keyboardInputTimeElapsed = d->keyboardInputTime.restart();
     2867    if (search.isEmpty() || !keyboardTimeWasValid
     2868        || keyboardInputTimeElapsed > QApplication::keyboardInputInterval()) {
    28472869        d->keyboardInput = search;
    28482870        skipRow = currentIndex().isValid(); //if it is not valid we should really start at QModelIndex(0,0)
     
    28502872        d->keyboardInput += search;
    28512873    }
    2852     d->keyboardInputTime = now;
    28532874
    28542875    // special case for searches with same key like 'aaaaa'
Note: See TracChangeset for help on using the changeset viewer.