diff options
author | Qt Continuous Integration System <qt-info@nokia.com> | 2010-04-14 08:38:42 (GMT) |
---|---|---|
committer | Qt Continuous Integration System <qt-info@nokia.com> | 2010-04-14 08:38:42 (GMT) |
commit | b371999d3e9c207047be6afda89d008b6cf04763 (patch) | |
tree | 7e2da63139dfc732edcfac73f13ee2b4d998d540 /src/gui/itemviews | |
parent | 4af9cc043370846c52ec21cf874696ee650394c1 (diff) | |
parent | 0711bb704ef5cdd20d5079418c256e3502258613 (diff) | |
download | Qt-b371999d3e9c207047be6afda89d008b6cf04763.zip Qt-b371999d3e9c207047be6afda89d008b6cf04763.tar.gz Qt-b371999d3e9c207047be6afda89d008b6cf04763.tar.bz2 |
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-2 into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-2: (55 commits)
Revert "Removed double setting of _WIN32_WINNT"
Revert "removed a few warnings on wince builds"
removed a few warnings on wince builds
Removed double setting of _WIN32_WINNT
QTreeView: remove dead code.
doc: Clarify effect of QFont::NoFontMerging
Revert "Implement heightForWidth support for QTabWidget and QStackedLayout."
build fix for S60
Improve handling of QAction in soft key manager
Remove useless assert
qdrawhelper: fix optim in 2245641ba
QSlider and StyleSheet: fix one pixel error while drawing the SliderAddPage
accelerate QWindowsPipeWriter for bigger chunks of data
Fix antialiasing with transformed text in OpenGL2 paint engine
Fix flattening of largely scaled, thin, dashed beziers.
Increased the precision used to flatten beziers
Fix QT_NO_MOVIE
Fix compile error with QT_NO_ACTION in QtGui
Fix QT_NO_COMPLETER
Fix QT_NO_FSCOMPLETER
...
Diffstat (limited to 'src/gui/itemviews')
-rw-r--r-- | src/gui/itemviews/qitemselectionmodel.cpp | 21 | ||||
-rw-r--r-- | src/gui/itemviews/qitemselectionmodel.h | 2 | ||||
-rw-r--r-- | src/gui/itemviews/qtableview.cpp | 4 | ||||
-rw-r--r-- | src/gui/itemviews/qtreeview.cpp | 23 | ||||
-rw-r--r-- | src/gui/itemviews/qtreeview_p.h | 1 | ||||
-rw-r--r-- | src/gui/itemviews/qtreewidget.cpp | 6 |
6 files changed, 35 insertions, 22 deletions
diff --git a/src/gui/itemviews/qitemselectionmodel.cpp b/src/gui/itemviews/qitemselectionmodel.cpp index d6e68f6..f848321 100644 --- a/src/gui/itemviews/qitemselectionmodel.cpp +++ b/src/gui/itemviews/qitemselectionmodel.cpp @@ -292,6 +292,27 @@ static void indexesFromRange(const QItemSelectionRange &range, QModelIndexList & } /*! + Returns true if the selection range contains no selectable item + \since 4.7 +*/ + +bool QItemSelectionRange::isEmpty() const +{ + if (!isValid() || !model()) + return true; + + for (int column = left(); column <= right(); ++column) { + for (int row = top(); row <= bottom(); ++row) { + QModelIndex index = model()->index(row, column, parent()); + Qt::ItemFlags flags = model()->flags(index); + if ((flags & Qt::ItemIsSelectable) && (flags & Qt::ItemIsEnabled)) + return false; + } + } + return true; +} + +/*! Returns the list of model index items stored in the selection. */ diff --git a/src/gui/itemviews/qitemselectionmodel.h b/src/gui/itemviews/qitemselectionmodel.h index 9980d0f..436514f 100644 --- a/src/gui/itemviews/qitemselectionmodel.h +++ b/src/gui/itemviews/qitemselectionmodel.h @@ -108,6 +108,8 @@ public: && top() <= bottom() && left() <= right()); } + bool isEmpty() const; + QModelIndexList indexes() const; private: diff --git a/src/gui/itemviews/qtableview.cpp b/src/gui/itemviews/qtableview.cpp index 31be224..80334a6 100644 --- a/src/gui/itemviews/qtableview.cpp +++ b/src/gui/itemviews/qtableview.cpp @@ -1846,7 +1846,9 @@ void QTableView::setSelection(const QRect &rect, QItemSelectionModel::SelectionF selection.append(QItemSelectionRange(topLeft, bottomRight)); } } else { // nothing moved - selection.append(QItemSelectionRange(tl, br)); + QItemSelectionRange range(tl, br); + if (!range.isEmpty()) + selection.append(range); } d->selectionModel->select(selection, command); diff --git a/src/gui/itemviews/qtreeview.cpp b/src/gui/itemviews/qtreeview.cpp index d934683..b797776 100644 --- a/src/gui/itemviews/qtreeview.cpp +++ b/src/gui/itemviews/qtreeview.cpp @@ -3194,12 +3194,16 @@ void QTreeViewPrivate::layout(int i, bool recursiveExpanding, bool afterIsUninit int QTreeViewPrivate::pageUp(int i) const { int index = itemAtCoordinate(coordinateForItem(i) - viewport->height()); + while (isItemHiddenOrDisabled(index)) + index--; return index == -1 ? 0 : index; } int QTreeViewPrivate::pageDown(int i) const { int index = itemAtCoordinate(coordinateForItem(i) + viewport->height()); + while (isItemHiddenOrDisabled(index)) + index++; return index == -1 ? viewItems.count() - 1 : index; } @@ -3424,25 +3428,6 @@ int QTreeViewPrivate::columnAt(int x) const return header->logicalIndexAt(x); } -void QTreeViewPrivate::relayout(const QModelIndex &parent) -{ - Q_Q(QTreeView); - // do a local relayout of the items - if (parent.isValid()) { - int parentViewIndex = viewIndex(parent); - if (parentViewIndex > -1 && viewItems.at(parentViewIndex).expanded) { - collapse(parentViewIndex, false); // remove the current layout - expand(parentViewIndex, false); // do the relayout - q->updateGeometries(); - viewport->update(); - } - } else { - viewItems.clear(); - q->doItemsLayout(); - } -} - - void QTreeViewPrivate::updateScrollBars() { Q_Q(QTreeView); diff --git a/src/gui/itemviews/qtreeview_p.h b/src/gui/itemviews/qtreeview_p.h index 261af31..cbbfd0e 100644 --- a/src/gui/itemviews/qtreeview_p.h +++ b/src/gui/itemviews/qtreeview_p.h @@ -150,7 +150,6 @@ public: int columnAt(int x) const; bool hasVisibleChildren( const QModelIndex& parent) const; - void relayout(const QModelIndex &parent); bool expandOrCollapseItemAtPos(const QPoint &pos); void updateScrollBars(); diff --git a/src/gui/itemviews/qtreewidget.cpp b/src/gui/itemviews/qtreewidget.cpp index 19ed10b..4c80325 100644 --- a/src/gui/itemviews/qtreewidget.cpp +++ b/src/gui/itemviews/qtreewidget.cpp @@ -3039,10 +3039,14 @@ QList<QTreeWidgetItem*> QTreeWidget::selectedItems() const Q_D(const QTreeWidget); QModelIndexList indexes = selectionModel()->selectedIndexes(); QList<QTreeWidgetItem*> items; + items.reserve(indexes.count()); + QSet<QTreeWidgetItem *> seen; + seen.reserve(indexes.count()); for (int i = 0; i < indexes.count(); ++i) { QTreeWidgetItem *item = d->item(indexes.at(i)); - if (isItemHidden(item) || items.contains(item)) // ### slow, optimize later + if (isItemHidden(item) || seen.contains(item)) continue; + seen.insert(item); items.append(item); } return items; |