diff options
author | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com> | 2010-04-12 12:23:40 (GMT) |
---|---|---|
committer | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com> | 2010-04-12 12:23:40 (GMT) |
commit | 0f790634c57400f4ddffd36f5e3443c712d1a1c3 (patch) | |
tree | 2b9f01a1798c5700f3c82e72a3db97dac6a625d5 /src/gui/itemviews | |
parent | 67e8e5baeec38d592596f259894e6dda420728ea (diff) | |
parent | 119d7dddc8da189ccd1cbc55ed3292f311c30e0c (diff) | |
download | Qt-0f790634c57400f4ddffd36f5e3443c712d1a1c3.zip Qt-0f790634c57400f4ddffd36f5e3443c712d1a1c3.tar.gz Qt-0f790634c57400f4ddffd36f5e3443c712d1a1c3.tar.bz2 |
Merge branch '4.7' of git@scm.dev.nokia.troll.no:qt/oslo-staging-2 into 4.7
Diffstat (limited to 'src/gui/itemviews')
-rw-r--r-- | src/gui/itemviews/qfileiconprovider.cpp | 6 | ||||
-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 | 4 | ||||
-rw-r--r-- | src/gui/itemviews/qtreewidget.cpp | 6 |
6 files changed, 39 insertions, 4 deletions
diff --git a/src/gui/itemviews/qfileiconprovider.cpp b/src/gui/itemviews/qfileiconprovider.cpp index f321ab3..5dbd1f0 100644 --- a/src/gui/itemviews/qfileiconprovider.cpp +++ b/src/gui/itemviews/qfileiconprovider.cpp @@ -254,7 +254,9 @@ QIcon QFileIconProviderPrivate::getWinIcon(const QFileInfo &fileInfo) const val = SHGetFileInfo((const wchar_t *)QDir::toNativeSeparators(fileInfo.filePath()).utf16(), 0, &info, sizeof(SHFILEINFO), SHGFI_SMALLICON|SHGFI_SYSICONINDEX); #endif - if (val) { + + // Even if GetFileInfo returns a valid result, hIcon can be empty in some cases + if (val && info.hIcon) { if (fileInfo.isDir() && !fileInfo.isRoot()) { //using the unique icon index provided by windows save us from duplicate keys key = QString::fromLatin1("qt_dir_%1").arg(info.iIcon); @@ -293,7 +295,7 @@ QIcon QFileIconProviderPrivate::getWinIcon(const QFileInfo &fileInfo) const val = SHGetFileInfo((const wchar_t *)QDir::toNativeSeparators(fileInfo.filePath()).utf16(), 0, &info, sizeof(SHFILEINFO), SHGFI_LARGEICON|SHGFI_SYSICONINDEX); #endif - if (val) { + if (val && info.hIcon) { if (fileInfo.isDir() && !fileInfo.isRoot()) { //using the unique icon index provided by windows save us from duplicate keys key = QString::fromLatin1("qt_dir_%1").arg(info.iIcon); 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 43445b4..f49f273 100644 --- a/src/gui/itemviews/qtableview.cpp +++ b/src/gui/itemviews/qtableview.cpp @@ -1847,7 +1847,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..c3ff2bd 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; } 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; |