Ignore:
Timestamp:
Feb 11, 2010, 11:19:06 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.6.1 sources.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

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

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information ([email protected])
     4** All rights reserved.
     5** Contact: Nokia Corporation ([email protected])
    56**
    67** This file is part of the QtGui module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you
     37** @nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    7676
    7777    \ingroup model-view
    78     \mainclass
     78
    7979*/
    8080
     
    578578        return;
    579579
    580     //layoutAboutToBeChanged and layoutChanged will be called by sortChildren 
     580    //layoutAboutToBeChanged and layoutChanged will be called by sortChildren
    581581    rootItem->sortChildren(column, order, true);
    582582}
     
    623623        lit = sortedInsertionIterator(lit, lst.end(), order, item);
    624624        int newRow = qMax(lit - lst.begin(), 0);
     625
     626
     627
     628
    625629        lit = lst.insert(lit, item);
    626630        if (newRow != oldRow) {
     
    854858        for (int c = 0; c < colCount; ++c) {
    855859            QModelIndex from = createIndex(oldRow, c, item);
    856             if (static_cast<QAbstractItemModelPrivate *>(d_ptr)->persistent.indexes.contains(from)) {
     860            if (static_cast<QAbstractItemModelPrivate *>(d_ptr)->persistent.indexes.contains(from)) {
    857861                QModelIndex to = createIndex(r, c, item);
    858862                fromList << from;
     
    15771581        return;
    15781582
    1579     view->viewport()->update( view->d_func()->itemDecorationRect(view->d_func()->index(this)));
     1583    view->);
    15801584}
    15811585
     
    17691773        if (children.count() && (itemFlags & Qt::ItemIsTristate))
    17701774            return childrenCheckState(column);
     1775
    17711776   default:
    17721777        if (column >= 0 && column < values.size()) {
     
    17881793{
    17891794    int column = view ? view->sortColumn() : 0;
    1790     return text(column) < other.text(column);
     1795    const QVariant v1 = data(column, Qt::DisplayRole);
     1796    const QVariant v2 = other.data(column, Qt::DisplayRole);
     1797    return QAbstractItemModelPrivate::variantLessThan(v1, v2);
    17911798}
    17921799
     
    18281835    out << values << d->display;
    18291836}
     1837
    18301838
    18311839/*!
     
    18631871    return *this;
    18641872}
    1865 
    1866 #endif // QT_NO_DATASTREAM
    18671873
    18681874/*!
     
    20722078{
    20732079    QTreeModel *model = (q->view ? qobject_cast<QTreeModel*>(q->view->model()) : 0);
     2080
     2081
    20742082    model->sortItems(&q->children, column, order);
    20752083    if (climb) {
    20762084        QList<QTreeWidgetItem*>::iterator it = q->children.begin();
    20772085        for (; it != q->children.end(); ++it) {
    2078             //here we call the private object's method to avoid emitting 
     2086            //here we call the private object's method to avoid emitting
    20792087            //the layoutAboutToBeChanged and layoutChanged signals
    20802088            (*it)->d->sortChildren(column, order, climb);
     
    22782286void QTreeWidgetPrivate::_q_sort()
    22792287{
    2280     Q_Q(QTreeWidget);
    22812288    if (sortingEnabled) {
    2282         int column = q->header()->sortIndicatorSection();
    2283         Qt::SortOrder order = q->header()->sortIndicatorOrder();
    2284         model()->sort(column, order);
     2289        int column = ->sortIndicatorSection();
     2290        Qt::SortOrder order = ->sortIndicatorOrder();
     2291        odel()->sort(column, order);
    22852292    }
    22862293}
     
    22912298    QModelIndexList indices = selected.indexes();
    22922299    int i;
    2293     QTreeModel *m = model();
     2300    QTreeModel *m = odel();
    22942301    for (i = 0; i < indices.count(); ++i) {
    22952302        QTreeWidgetItem *item = m->item(indices.at(i));
     
    23092316                                        const QModelIndex &bottomRight)
    23102317{
    2311     Q_Q(QTreeWidget);
    23122318    if (sortingEnabled && topLeft.isValid() && bottomRight.isValid()
    2313         && !model()->sortPendingTimer.isActive()) {
    2314         int column = q->header()->sortIndicatorSection();
     2319        && !odel()->sortPendingTimer.isActive()) {
     2320        int column = ->sortIndicatorSection();
    23152321        if (column >= topLeft.column() && column <= bottomRight.column()) {
    2316             Qt::SortOrder order = q->header()->sortIndicatorOrder();
    2317             model()->ensureSorted(column, order, topLeft.row(),
     2322            Qt::SortOrder order = ->sortIndicatorOrder();
     2323            odel()->ensureSorted(column, order, topLeft.row(),
    23182324                                  bottomRight.row(), topLeft.parent());
    23192325        }
     
    23282334
    23292335  \ingroup model-view
    2330   \mainclass
     2336
    23312337
    23322338  The QTreeWidget class is a convenience class that provides a standard
     
    24372443    expandAll() is invoked.
    24382444
    2439     \sa isItemExpanded(), itemCollapsed(), expandItem()
     2445    \sa Expanded(), itemCollapsed(), expandItem()
    24402446*/
    24412447
     
    24492455    collapseAll() is invoked.
    24502456
    2451     \sa isItemExpanded(), itemExpanded(), collapseItem()
     2457    \sa Expanded(), itemExpanded(), collapseItem()
    24522458*/
    24532459
     
    25432549{
    25442550    Q_D(const QTreeWidget);
    2545     return d->model()->columnCount();
     2551    return d->model->columnCount();
    25462552}
    25472553
     
    25552561    if (columns < 0)
    25562562        return;
    2557     d->model()->setColumnCount(columns);
     2563    d->odel()->setColumnCount(columns);
    25582564}
    25592565
     
    25722578{
    25732579    Q_D(const QTreeWidget);
    2574     return d->model()->rootItem;
     2580    return d->odel()->rootItem;
    25752581}
    25762582
     
    25852591{
    25862592    Q_D(const QTreeWidget);
    2587     return d->model()->rootItem->child(index);
     2593    return d->odel()->rootItem->child(index);
    25882594}
    25892595
     
    26002606{
    26012607    Q_D(const QTreeWidget);
    2602     return d->model()->rootItem->childCount();
     2608    return d->odel()->rootItem->childCount();
    26032609}
    26042610
     
    26142620{
    26152621    Q_D(QTreeWidget);
    2616     d->model()->rootItem->insertChild(index, item);
     2622    d->odel()->rootItem->insertChild(index, item);
    26172623}
    26182624
     
    26392645{
    26402646    Q_D(QTreeWidget);
    2641     return d->model()->rootItem->takeChild(index);
     2647    return d->odel()->rootItem->takeChild(index);
    26422648}
    26432649
     
    26482654{
    26492655    Q_D(QTreeWidget);
    2650     d->model()->executePendingSort();
    2651     return d->model()->rootItem->children.indexOf(item);
     2656    d->odel()->executePendingSort();
     2657    return d->odel()->rootItem->children.indexOf(item);
    26522658}
    26532659
     
    26612667{
    26622668    Q_D(const QTreeWidget);
    2663     d->model()->executePendingSort();
    2664     return d->model()->rootItem->children.indexOf(item);
     2669    d->odel()->executePendingSort();
     2670    return d->odel()->rootItem->children.indexOf(item);
    26652671}
    26662672
     
    26772683{
    26782684    Q_D(QTreeWidget);
    2679     d->model()->rootItem->insertChildren(index, items);
     2685    d->odel()->rootItem->insertChildren(index, items);
    26802686}
    26812687
     
    26992705{
    27002706    Q_D(const QTreeWidget);
    2701     return d->model()->headerItem;
     2707    return d->odel()->headerItem;
    27022708}
    27032709
     
    27202726    int oldCount = columnCount();
    27212727    if (oldCount < item->columnCount())
    2722          d->model()->beginInsertColumns(QModelIndex(), oldCount, item->columnCount());
     2728         d->odel()->beginInsertColumns(QModelIndex(), oldCount, item->columnCount());
    27232729    else
    2724          d->model()->beginRemoveColumns(QModelIndex(), item->columnCount(), oldCount);
    2725     delete d->model()->headerItem;
    2726     d->model()->headerItem = item;
     2730         d->odel()->beginRemoveColumns(QModelIndex(), item->columnCount(), oldCount);
     2731    delete d->odel()->headerItem;
     2732    d->odel()->headerItem = item;
    27272733    if (oldCount < item->columnCount())
    2728         d->model()->endInsertColumns();
     2734        d->odel()->endInsertColumns();
    27292735    else
    2730         d->model()->endRemoveColumns();
    2731     d->model()->headerDataChanged(Qt::Horizontal, 0, oldCount);
     2736        d->odel()->endRemoveColumns();
     2737    d->odel()->headerDataChanged(Qt::Horizontal, 0, oldCount);
    27322738}
    27332739
     
    27462752    if (columnCount() < labels.count())
    27472753        setColumnCount(labels.count());
    2748     QTreeModel *model = d->model();
    2749     QTreeWidgetItem *item = model->headerItem;
     2754    QTreeWidgetItem *item = d->treeModel()->headerItem;
    27502755    for (int i = 0; i < labels.count(); ++i)
    27512756        item->setText(i, labels.at(i));
     
    27842789  Sets the current \a item in the tree widget.
    27852790
    2786   Depending on the current selection mode, the item may also be selected.
     2791  Unless the selection mode is \l{QAbstractItemView::}{NoSelection},
     2792  the item is also be selected.
    27872793
    27882794  \sa currentItem(), currentItemChanged()
     
    28462852{
    28472853    Q_D(const QTreeWidget);
    2848     return visualRect(d->index(item));
     2854    //the visual rect for an item is across all columns. So we need to determine
     2855        //what is the first and last column and get their visual index rects
     2856    QModelIndex base = d->index(item);
     2857    const int firstVisiblesection = header()->logicalIndexAt(- header()->offset());
     2858    const int lastVisibleSection = header()->logicalIndexAt(header()->length() - header()->offset() - 1);
     2859    QModelIndex first = base.sibling(base.row(), header()->logicalIndex(firstVisiblesection));
     2860    QModelIndex last = base.sibling(base.row(), header()->logicalIndex(lastVisibleSection));
     2861    return visualRect(first) | visualRect(last);
    28492862}
    28502863
     
    28752888    Q_D(QTreeWidget);
    28762889    header()->setSortIndicator(column, order);
    2877     d->model()->sort(column, order);
     2890    d->model->sort(column, order);
    28782891}
    28792892
     
    30423055{
    30433056    Q_D(const QTreeWidget);
    3044     QModelIndexList indexes = d->model()->match(model()->index(0, column, QModelIndex()),
     3057    QModelIndexList indexes = d->model->match(model()->index(0, column, QModelIndex()),
    30453058                                                Qt::DisplayRole, text, -1, flags);
    30463059    QList<QTreeWidgetItem*> items;
     
    30603073{
    30613074    Q_D(const QTreeWidget);
    3062     if (item == d->model()->headerItem)
     3075    if (item == d->odel()->headerItem)
    30633076        return header()->isHidden();
    30643077    if (d->hiddenIndexes.isEmpty())
    30653078        return false;
    3066     QTreeModel::SkipSorting skipSorting(d->model());
     3079    QTreeModel::SkipSorting skipSorting(d->odel());
    30673080    return d->isRowHidden(d->index(item));
    30683081}
     
    30803093{
    30813094    Q_D(QTreeWidget);
    3082     if (item == d->model()->headerItem) {
     3095    if (item == d->odel()->headerItem) {
    30833096        header()->setHidden(hide);
    30843097    } else {
     
    31003113{
    31013114    Q_D(const QTreeWidget);
    3102     QTreeModel::SkipSorting skipSorting(d->model());
     3115    QTreeModel::SkipSorting skipSorting(d->odel());
    31033116    return isExpanded(d->index(item));
    31043117}
     
    31103123    \sa expandItem(), collapseItem(), itemExpanded()
    31113124
    3112   \obsolete
    3113 
    3114   This function is deprecated. Use \l{QTreeWidgetItem::setExpanded()} instead.
     3125  \obsolete
     3126
     3127  This function is deprecated. Use \l{QTreeWidgetItem::setExpanded()} instead.
    31153128*/
    31163129void QTreeWidget::setItemExpanded(const QTreeWidgetItem *item, bool expand)
    31173130{
    31183131    Q_D(QTreeWidget);
    3119     QTreeModel::SkipSorting skipSorting(d->model());
     3132    QTreeModel::SkipSorting skipSorting(d->odel());
    31203133    setExpanded(d->index(item), expand);
    31213134}
     
    31323145{
    31333146    Q_D(const QTreeWidget);
    3134     if (item == d->model()->headerItem)
     3147    if (item == d->odel()->headerItem)
    31353148        return false; // We can't set the header items to spanning
    31363149    const QModelIndex index = d->index(item);
     
    31493162{
    31503163    Q_D(QTreeWidget);
    3151     if (item == d->model()->headerItem)
     3164    if (item == d->odel()->headerItem)
    31523165        return; // We can't set header items to spanning
    31533166    const QModelIndex index = d->index(item);
     
    31633176{
    31643177    Q_D(const QTreeWidget);
    3165     if (item == d->model()->headerItem)
     3178    if (item == d->odel()->headerItem)
    31663179        return 0;
    31673180    const QModelIndex index = d->index(item);
     
    31783191{
    31793192    Q_D(const QTreeWidget);
    3180     if (item == d->model()->headerItem)
     3193    if (item == d->odel()->headerItem)
    31813194        return 0;
    31823195    const QModelIndex index = d->index(item);
     
    32183231{
    32193232    Q_D(QTreeWidget);
    3220     QTreeModel::SkipSorting skipSorting(d->model());
     3233    QTreeModel::SkipSorting skipSorting(d->odel());
    32213234    expand(d->index(item));
    32223235}
     
    32313244{
    32323245    Q_D(QTreeWidget);
    3233     QTreeModel::SkipSorting skipSorting(d->model());
     3246    QTreeModel::SkipSorting skipSorting(d->odel());
    32343247    collapse(d->index(item));
    32353248}
     
    32483261    Q_D(QTreeWidget);
    32493262    selectionModel()->clear();
    3250     d->model()->clear();
     3263    d->odel()->clear();
    32513264}
    32523265
     
    32733286{
    32743287    Q_D(const QTreeWidget);
    3275     if (d->model()->cachedIndexes.isEmpty()) {
     3288    if (d->odel()->cachedIndexes.isEmpty()) {
    32763289        QList<QModelIndex> indexes;
    32773290        for (int i = 0; i < items.count(); ++i) {
     
    32813294            }
    32823295        }
    3283         return model()->QAbstractItemModel::mimeData(indexes);
    3284     }
    3285     return d->model()->internalMimeData();
     3296        return ->QAbstractItemModel::mimeData(indexes);
     3297    }
     3298    return d->odel()->internalMimeData();
    32863299}
    32873300
     
    34273440    Q_D(QTreeWidget);
    34283441    if (e->type() == QEvent::Polish)
    3429         d->model()->executePendingSort();
     3442        d->odel()->executePendingSort();
    34303443    return QTreeView::event(e);
    34313444}
Note: See TracChangeset for help on using the changeset viewer.