+ }
+ }
+ updateSelections();
+}
+
+void DolphinColumnView::updateSelections()
+{
+ ColumnWidget* previousWidget = 0;
+ foreach (QObject* object, viewport()->children()) {
+ if (object->inherits("QListView")) {
+ ColumnWidget* widget = static_cast<ColumnWidget*>(object);
+ if (previousWidget != 0) {
+ const QAbstractProxyModel* proxyModel = static_cast<const QAbstractProxyModel*>(model());
+ const KDirModel* dirModel = static_cast<const KDirModel*>(proxyModel->sourceModel());
+ const QModelIndex dirIndex = dirModel->indexForUrl(widget->url());
+ const QModelIndex proxyIndex = proxyModel->mapFromSource(dirIndex);
+
+ QItemSelectionModel* selModel = previousWidget->selectionModel();
+ const QItemSelection selection = selModel->selection();
+ const bool isIndexSelected = selModel->isSelected(proxyIndex);
+
+ const bool clearSelection = !previousWidget->isActive() &&
+ ((selection.count() > 1) || !isIndexSelected);
+ if (clearSelection) {
+ selModel->clear();
+ }
+ if (!isIndexSelected) {
+ selModel->select(proxyIndex, QItemSelectionModel::Select);
+ }
+ }
+
+ previousWidget = widget;
+ }