+ QItemSelectionModel* selectionModel = itemView()->selectionModel();
+ const QAbstractItemModel* itemModel = selectionModel->model();
+
+ const QModelIndex topLeft = itemModel->index(0, 0);
+ const QModelIndex bottomRight = itemModel->index(itemModel->rowCount() - 1,
+ itemModel->columnCount() - 1);
+
+ QItemSelection selection(topLeft, bottomRight);
+ selectionModel->select(selection, QItemSelectionModel::Toggle);
+}
+
+bool DolphinView::hasSelection() const
+{
+ return itemView()->selectionModel()->hasSelection();
+}
+
+void DolphinView::clearSelection()
+{
+ itemView()->selectionModel()->clear();
+}
+
+QList<KFileItem> DolphinView::selectedItems() const
+{
+ const QAbstractItemView* view = itemView();
+
+ // Our view has a selection, we will map them back to the DolphinModel
+ // and then fill the KFileItemList.
+ Q_ASSERT((view != 0) && (view->selectionModel() != 0));
+
+ const QItemSelection selection = m_proxyModel->mapSelectionToSource(view->selectionModel()->selection());
+ QList<KFileItem> itemList;
+
+ const QModelIndexList indexList = selection.indexes();
+ foreach (QModelIndex index, indexList) {
+ KFileItem item = m_dolphinModel->itemForIndex(index);
+ if (!item.isNull()) {
+ itemList.append(item);
+ }
+ }
+
+ return itemList;
+}
+
+KUrl::List DolphinView::selectedUrls() const
+{
+ KUrl::List urls;
+ const QList<KFileItem> list = selectedItems();
+ for ( QList<KFileItem>::const_iterator it = list.begin(), end = list.end();
+ it != end; ++it ) {
+ urls.append((*it).url());
+ }
+ return urls;