Ignore:
Timestamp:
Aug 2, 2010, 9:27:30 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

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

Location:
trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk

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

    r651 r769  
    15411541        d->doDelayedItemsLayout(); // the size of the items will change
    15421542        break;
     1543#ifdef QT_SOFTKEYS_ENABLED
     1544    case QEvent::LanguageChange:
     1545        d->doneSoftKey->setText(QSoftKeyManager::standardSoftKeyText(QSoftKeyManager::DoneSoftKey));
     1546        break;
     1547#endif
    15431548    default:
    15441549        break;
     
    17811786        if (edited)
    17821787            return;
    1783         if (style()->styleHint(QStyle::SH_ItemView_ActivateItemOnSingleClick, 0, this))
     1788        QStyleOptionViewItemV4 option = d->viewOptionsV4();
     1789        if (d->pressedAlreadySelected)
     1790            option.state |= QStyle::State_Selected;
     1791        if (style()->styleHint(QStyle::SH_ItemView_ActivateItemOnSingleClick, &option, this))
    17841792            emit activated(index);
    17851793    }
     
    21152123    QAbstractScrollArea::focusOutEvent(event);
    21162124    d->viewport->update();
     2125
     2126#ifdef QT_SOFTKEYS_ENABLED
     2127    if(!hasEditFocus())
     2128        removeAction(d->doneSoftKey);
     2129#endif
    21172130}
    21182131
     
    21402153                setEditFocus(true);
    21412154#ifdef QT_SOFTKEYS_ENABLED
    2142                 addAction(d->doneSoftKey);
     2155                // If we can't keypad navigate to any direction, there is no sense to add
     2156                // "Done" softkey, since it basically does nothing when there is
     2157                // only one widget in screen
     2158                if(QWidgetPrivate::canKeypadNavigate(Qt::Horizontal)
     2159                        || QWidgetPrivate::canKeypadNavigate(Qt::Vertical))
     2160                    addAction(d->doneSoftKey);
    21432161#endif
    21442162                return;
     
    21562174        }
    21572175        return;
     2176    case Qt::Key_Down:
     2177    case Qt::Key_Up:
     2178        // Let's ignore vertical navigation events, only if there is no other widget
     2179        // what can take the focus in vertical direction. This means widget can handle navigation events
     2180        // even the widget don't have edit focus, and there is no other widget in requested direction.
     2181        if(QApplication::keypadNavigationEnabled() && !hasEditFocus()
     2182                && QWidgetPrivate::canKeypadNavigate(Qt::Vertical)) {
     2183            event->ignore();
     2184            return;
     2185        }
     2186        break;
     2187    case Qt::Key_Left:
     2188    case Qt::Key_Right:
     2189        // Similar logic as in up and down events
     2190        if(QApplication::keypadNavigationEnabled() && !hasEditFocus()
     2191                && (QWidgetPrivate::canKeypadNavigate(Qt::Horizontal) || QWidgetPrivate::inTabWidget(this))) {
     2192            event->ignore();
     2193            return;
     2194        }
     2195        break;
    21582196    default:
    21592197        if (QApplication::keypadNavigationEnabled() && !hasEditFocus()) {
     
    22412279    case Qt::Key_Up:
    22422280#ifdef QT_KEYPAD_NAVIGATION
    2243         if (QApplication::keypadNavigationEnabled()) {
     2281        if (QApplication::keypadNavigationEnabled() && QWidgetPrivate::canKeypadNavigate(Qt::Vertical)) {
    22442282            event->accept(); // don't change focus
    22452283            break;
     
    22492287    case Qt::Key_Right:
    22502288#ifdef QT_KEYPAD_NAVIGATION
    2251         if (QApplication::navigationMode() == Qt::NavigationModeKeypadDirectional) {
    2252             event->accept(); // don't change horizontal focus in directional mode
     2289        if (QApplication::navigationMode() == Qt::NavigationModeKeypadDirectional
     2290                && (QWidgetPrivate::canKeypadNavigate(Qt::Horizontal)
     2291                || (QWidgetPrivate::inTabWidget(this) && d->model->columnCount(d->root) > 1))) {
     2292            event->accept(); // don't change focus
    22532293            break;
    22542294        }
     
    25322572    QList<QEditorInfo>::iterator it = d->editors.begin();
    25332573    QWidgetList editorsToRelease;
     2574    QWidgetList editorsToHide;
    25342575    while (it != d->editors.end()) {
    25352576        QModelIndex index = it->index;
     
    25432584                    delegate->updateEditorGeometry(editor, option, index);
    25442585            } else {
    2545                 editor->hide();
     2586                editorsToHide << editor;
    25462587            }
    25472588            ++it;
     
    25522593    }
    25532594
    2554     //we release the editor outside of the loop because it might change the focus and try
     2595    //we hide and release the editor outside of the loop because it might change the focus and try
    25552596    //to change the d->editors list.
     2597    for (int i = 0; i < editorsToHide.count(); ++i) {
     2598        editorsToHide.at(i)->hide();
     2599    }
    25562600    for (int i = 0; i < editorsToRelease.count(); ++i) {
    25572601        d->releaseEditor(editorsToRelease.at(i));
     
    30103054        return;
    30113055    if (QWidget *oldWidget = indexWidget(index)) {
     3056        d->persistent.remove(oldWidget);
    30123057        d->removeEditor(oldWidget);
    30133058        oldWidget->deleteLater();
  • trunk/src/gui/itemviews/qabstractproxymodel.cpp

    r651 r769  
    128128        d->model = QAbstractItemModelPrivate::staticEmptyModel();
    129129    }
     130    d->roleNames = d->model->roleNames();
    130131}
    131132
  • trunk/src/gui/itemviews/qfileiconprovider.cpp

    r651 r769  
    6969#ifndef SHGFI_ADDOVERLAYS
    7070#  define SHGFI_ADDOVERLAYS 0x000000020
     71#  define SHGFI_OVERLAYINDEX 0x000000040
    7172#endif
    7273
     
    254255#ifndef Q_OS_WINCE
    255256    val = SHGetFileInfo((const wchar_t *)QDir::toNativeSeparators(fileInfo.filePath()).utf16(), 0, &info,
    256                         sizeof(SHFILEINFO), SHGFI_ICON|SHGFI_SMALLICON|SHGFI_SYSICONINDEX|SHGFI_ADDOVERLAYS);
     257                        sizeof(SHFILEINFO), SHGFI_ICON|SHGFI_SMALLICON|SHGFI_SYSICONINDEX|SHGFI_ADDOVERLAYS|SHGFI_OVERLAYINDEX);
    257258#else
    258259    val = SHGetFileInfo((const wchar_t *)QDir::toNativeSeparators(fileInfo.filePath()).utf16(), 0, &info,
    259260                        sizeof(SHFILEINFO), SHGFI_SMALLICON|SHGFI_SYSICONINDEX);
    260261#endif
    261     if (val) {
     262
     263    // Even if GetFileInfo returns a valid result, hIcon can be empty in some cases
     264    if (val && info.hIcon) {
    262265        if (fileInfo.isDir() && !fileInfo.isRoot()) {
    263266            //using the unique icon index provided by windows save us from duplicate keys
     
    293296#ifndef Q_OS_WINCE
    294297    val = SHGetFileInfo((const wchar_t *)QDir::toNativeSeparators(fileInfo.filePath()).utf16(), 0, &info,
    295                         sizeof(SHFILEINFO), SHGFI_ICON|SHGFI_LARGEICON|SHGFI_SYSICONINDEX|SHGFI_ADDOVERLAYS);
     298                        sizeof(SHFILEINFO), SHGFI_ICON|SHGFI_LARGEICON|SHGFI_SYSICONINDEX|SHGFI_ADDOVERLAYS|SHGFI_OVERLAYINDEX);
    296299#else
    297300    val = SHGetFileInfo((const wchar_t *)QDir::toNativeSeparators(fileInfo.filePath()).utf16(), 0, &info,
    298301                        sizeof(SHFILEINFO), SHGFI_LARGEICON|SHGFI_SYSICONINDEX);
    299302#endif
    300     if (val) {
     303    if (val && info.hIcon) {
    301304        if (fileInfo.isDir() && !fileInfo.isRoot()) {
    302305            //using the unique icon index provided by windows save us from duplicate keys
  • trunk/src/gui/itemviews/qitemdelegate.cpp

    r651 r769  
    10341034    }
    10351035
    1036     return QString::fromUtf16(ptr, int(&arr[sizeof(arr) / sizeof(ushort)] - ptr));
     1036    return QString((const QChar *)ptr, int(&arr[sizeof(arr) / sizeof(ushort)] - ptr));
    10371037}
    10381038
     
    12981298    }
    12991299
    1300     Qt::CheckState state;
    1301     if ( flags & Qt::ItemIsTristate ) {
    1302         state = static_cast<Qt::CheckState>( (value.toInt() + 1) % 3 );
    1303     } else {
    1304         state = (static_cast<Qt::CheckState>(value.toInt()) == Qt::Checked
     1300    Qt::CheckState state = (static_cast<Qt::CheckState>(value.toInt()) == Qt::Checked
    13051301                            ? Qt::Unchecked : Qt::Checked);
    1306     }
    1307 
    13081302    return model->setData(index, state, Qt::CheckStateRole);
    13091303}
  • trunk/src/gui/itemviews/qlistview.cpp

    r651 r769  
    21612161        if (flowPositions.isEmpty())
    21622162            return;
    2163         const int max = flowPositions.count() - 1;
     2163        const int max = scrollValueMap.count() - 1;
    21642164        if (vertical && flow() == QListView::TopToBottom && dy != 0) {
    21652165            int currentValue = qBound(0, verticalValue, max);
  • trunk/src/gui/itemviews/qstyleditemdelegate.cpp

    r651 r769  
    748748    }
    749749
    750     Qt::CheckState state;
    751     if ( flags & Qt::ItemIsTristate ) {
    752         state = static_cast<Qt::CheckState>( (value.toInt() + 1) % 3 );
    753     } else {
    754         state = (static_cast<Qt::CheckState>(value.toInt()) == Qt::Checked
     750    Qt::CheckState state = (static_cast<Qt::CheckState>(value.toInt()) == Qt::Checked
    755751                            ? Qt::Unchecked : Qt::Checked);
    756     }
    757752    return model->setData(index, state, Qt::CheckStateRole);
    758753}
  • trunk/src/gui/itemviews/qtableview.cpp

    r651 r769  
    115115    } else if (old_height > span->height()) {
    116116        //remove the span from all the subspans lists that intersect the columns not covered anymore
    117         Index::iterator it_y = index.lowerBound(-span->bottom());
    118         if (it_y == index.end())
    119             it_y = index.find(-span->top());    // This is the only span remaining and we are deleting it.
     117        Index::iterator it_y = index.lowerBound(-qMax(span->bottom(), span->top())); //qMax usefull if height is 0
    120118        Q_ASSERT(it_y != index.end()); //it_y must exist since the span is in the list
    121119        while (-it_y.key() <= span->top() + old_height -1) {
    122120            if (-it_y.key() > span->bottom()) {
    123                 (*it_y).remove(-span->left());
     121                int removed = (*it_y).remove(-span->left());
     122                Q_ASSERT(removed == 1); Q_UNUSED(removed);
    124123                if (it_y->isEmpty()) {
    125                     it_y = index.erase(it_y) - 1;
     124                    it_y = index.erase(it_y);
    126125                }
    127126            }
     
    19091908        }
    19101909    } else { // nothing moved
     1910        const int gridAdjust = showGrid() ? 1 : 0;
    19111911        for (int i = 0; i < selection.count(); ++i) {
    19121912            QItemSelectionRange range = selection.at(i);
     
    19171917            const int rtop = rowViewportPosition(range.top());
    19181918            const int rbottom = rowViewportPosition(range.bottom()) + rowHeight(range.bottom());
    1919             const int rleft = columnViewportPosition(range.left());
    1920             const int rright = columnViewportPosition(range.right()) + columnWidth(range.right());
    1921             selectionRegion += QRect(QPoint(rleft, rtop), QPoint(rright, rbottom));
     1919            int rleft;
     1920            int rright;
     1921            if (isLeftToRight()) {
     1922                rleft = columnViewportPosition(range.left());
     1923                rright = columnViewportPosition(range.right()) + columnWidth(range.right());
     1924            } else {
     1925                rleft = columnViewportPosition(range.right());
     1926                rright = columnViewportPosition(range.left()) + columnWidth(range.left());
     1927            }
     1928            selectionRegion += QRect(QPoint(rleft, rtop), QPoint(rright - 1 - gridAdjust, rbottom - 1 - gridAdjust));
    19221929            if (d->hasSpans()) {
    19231930                foreach (QSpanCollection::Span *s,
     
    25472554    if (!d->isIndexValid(index)
    25482555        || (d->model->parent(index) != d->root)
    2549         || isIndexHidden(index))
     2556        || isRowHidden(index.row()) || isColumnHidden(index.column()))
    25502557        return;
    25512558
  • trunk/src/gui/itemviews/qtreeview.cpp

    r651 r769  
    24752475        QVector<QTreeViewItem> insertedItems(delta);
    24762476        for (int i = 0; i < delta; ++i) {
    2477             insertedItems[i].index = d->model->index(i + start, 0, parent);
    2478             insertedItems[i].level = childLevel;
    2479             insertedItems[i].hasChildren = d->hasVisibleChildren(insertedItems[i].index);
    2480             insertedItems[i].hasMoreSiblings = !((i == delta - 1) && (parentRowCount == end +1));
     2477            QTreeViewItem &item = insertedItems[i];
     2478            item.index = d->model->index(i + start, 0, parent);
     2479            item.level = childLevel;
     2480            item.hasChildren = d->hasVisibleChildren(item.index);
     2481            item.hasMoreSiblings = !((i == delta - 1) && (parentRowCount == end +1));
    24812482        }
    24822483        if (d->viewItems.isEmpty())
     
    37703771            viewItems[previousSibiling].hasMoreSiblings = false;
    37713772
    3772 
    3773         updateChildCount(parentItem, -removedCount);
    3774         if (parentItem != -1 && viewItems.at(parentItem).total == 0)
    3775             viewItems[parentItem].hasChildren = false; //every children have been removed;
     3773        if (parentItem != -1) {
     3774            if (viewItems.at(parentItem).expanded) {
     3775                updateChildCount(parentItem, -removedCount);
     3776                if (viewItems.at(parentItem).total == 0)
     3777                    viewItems[parentItem].hasChildren = false; //every children have been removed;
     3778            } else if (viewItems[parentItem].hasChildren && !hasVisibleChildren(parent)) {
     3779                viewItems[parentItem].hasChildren = false;
     3780            }
     3781        }
    37763782        if (after) {
    37773783            q->updateGeometries();
Note: See TracChangeset for help on using the changeset viewer.