equal
deleted
inserted
replaced
1 /**************************************************************************** |
1 /**************************************************************************** |
2 ** |
2 ** |
3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). |
3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
4 ** All rights reserved. |
4 ** All rights reserved. |
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
6 ** |
6 ** |
7 ** This file is part of the QtGui module of the Qt Toolkit. |
7 ** This file is part of the QtGui module of the Qt Toolkit. |
8 ** |
8 ** |
176 |
176 |
177 This signal is emitted when the item specified by \a index is collapsed. |
177 This signal is emitted when the item specified by \a index is collapsed. |
178 */ |
178 */ |
179 |
179 |
180 /*! |
180 /*! |
181 Constructs a table view with a \a parent to represent a model's |
181 Constructs a tree view with a \a parent to represent a model's |
182 data. Use setModel() to set the model. |
182 data. Use setModel() to set the model. |
183 |
183 |
184 \sa QAbstractItemModel |
184 \sa QAbstractItemModel |
185 */ |
185 */ |
186 QTreeView::QTreeView(QWidget *parent) |
186 QTreeView::QTreeView(QWidget *parent) |
1237 newRect.setLeft(newRect.left() - d->indent); |
1237 newRect.setLeft(newRect.left() - d->indent); |
1238 //we need to paint the whole items (including the decoration) so that when the user |
1238 //we need to paint the whole items (including the decoration) so that when the user |
1239 //moves the mouse over those elements they are updated |
1239 //moves the mouse over those elements they are updated |
1240 viewport()->update(oldRect); |
1240 viewport()->update(oldRect); |
1241 viewport()->update(newRect); |
1241 viewport()->update(newRect); |
1242 } |
|
1243 } |
|
1244 if (selectionBehavior() == QAbstractItemView::SelectRows) { |
|
1245 QModelIndex newHoverIndex = indexAt(he->pos()); |
|
1246 if (d->hover != newHoverIndex) { |
|
1247 QRect oldHoverRect = visualRect(d->hover); |
|
1248 QRect newHoverRect = visualRect(newHoverIndex); |
|
1249 viewport()->update(QRect(0, newHoverRect.y(), viewport()->width(), newHoverRect.height())); |
|
1250 viewport()->update(QRect(0, oldHoverRect.y(), viewport()->width(), oldHoverRect.height())); |
|
1251 } |
1242 } |
1252 } |
1243 } |
1253 break; } |
1244 break; } |
1254 default: |
1245 default: |
1255 break; |
1246 break; |
2642 Q_D(QTreeView); |
2633 Q_D(QTreeView); |
2643 if (!selectionModel()) |
2634 if (!selectionModel()) |
2644 return; |
2635 return; |
2645 SelectionMode mode = d->selectionMode; |
2636 SelectionMode mode = d->selectionMode; |
2646 d->executePostedLayout(); //make sure we lay out the items |
2637 d->executePostedLayout(); //make sure we lay out the items |
2647 if (mode != SingleSelection && !d->viewItems.isEmpty()) |
2638 if (mode != SingleSelection && !d->viewItems.isEmpty()) { |
2648 d->select(d->viewItems.first().index, d->viewItems.last().index, |
2639 const QModelIndex &idx = d->viewItems.last().index; |
|
2640 QModelIndex lastItemIndex = idx.sibling(idx.row(), d->model->columnCount(idx.parent()) - 1); |
|
2641 d->select(d->viewItems.first().index, lastItemIndex, |
2649 QItemSelectionModel::ClearAndSelect |
2642 QItemSelectionModel::ClearAndSelect |
2650 |QItemSelectionModel::Rows); |
2643 |QItemSelectionModel::Rows); |
|
2644 } |
2651 } |
2645 } |
2652 |
2646 |
2653 /*! |
2647 /*! |
2654 \since 4.2 |
2648 \since 4.2 |
2655 Expands all expandable items. |
2649 Expands all expandable items. |
3062 |
3056 |
3063 QPixmap QTreeViewPrivate::renderTreeToPixmapForAnimation(const QRect &rect) const |
3057 QPixmap QTreeViewPrivate::renderTreeToPixmapForAnimation(const QRect &rect) const |
3064 { |
3058 { |
3065 Q_Q(const QTreeView); |
3059 Q_Q(const QTreeView); |
3066 QPixmap pixmap(rect.size()); |
3060 QPixmap pixmap(rect.size()); |
|
3061 if (rect.size().isEmpty()) |
|
3062 return pixmap; |
3067 pixmap.fill(Qt::transparent); //the base might not be opaque, and we don't want uninitialized pixels. |
3063 pixmap.fill(Qt::transparent); //the base might not be opaque, and we don't want uninitialized pixels. |
3068 QPainter painter(&pixmap); |
3064 QPainter painter(&pixmap); |
3069 painter.fillRect(QRect(QPoint(0,0), rect.size()), q->palette().base()); |
3065 painter.fillRect(QRect(QPoint(0,0), rect.size()), q->palette().base()); |
3070 painter.translate(0, -rect.top()); |
3066 painter.translate(0, -rect.top()); |
3071 q->drawTree(&painter, QRegion(rect)); |
3067 q->drawTree(&painter, QRegion(rect)); |