diff options
Diffstat (limited to 'src/gui/itemviews/qtreewidget.cpp')
-rw-r--r-- | src/gui/itemviews/qtreewidget.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
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; |