+void DolphinView::slotRequestUrlChange(const KUrl& url)
+{
+ emit requestUrlChange(url);
+ m_controller->setUrl(url);
+}
+
+void DolphinView::slotDirListerCompleted()
+{
+ if (!m_expanderActive) {
+ slotLoadingCompleted();
+ }
+
+ if (!m_newFileNames.isEmpty()) {
+ // select all newly added items created by a paste operation or
+ // a drag & drop operation
+ const int rowCount = m_viewAccessor.proxyModel()->rowCount();
+ QItemSelection selection;
+ for (int row = 0; row < rowCount; ++row) {
+ const QModelIndex proxyIndex = m_viewAccessor.proxyModel()->index(row, 0);
+ const QModelIndex dirIndex = m_viewAccessor.proxyModel()->mapToSource(proxyIndex);
+ const KUrl url = m_viewAccessor.dirModel()->itemForIndex(dirIndex).url();
+ if (m_newFileNames.contains(url.fileName())) {
+ selection.merge(QItemSelection(proxyIndex, proxyIndex), QItemSelectionModel::Select);
+ }
+ }
+ m_viewAccessor.itemView()->selectionModel()->select(selection, QItemSelectionModel::Select);
+
+ m_newFileNames.clear();
+ }
+}
+
+void DolphinView::slotLoadingCompleted()
+{
+ m_expanderActive = false;
+ m_loadingDirectory = false;
+
+ if (!m_activeItemUrl.isEmpty()) {
+ // assure that the current item remains visible
+ const QModelIndex dirIndex = m_viewAccessor.dirModel()->indexForUrl(m_activeItemUrl);
+ if (dirIndex.isValid()) {
+ const QModelIndex proxyIndex = m_viewAccessor.proxyModel()->mapFromSource(dirIndex);
+ QAbstractItemView* view = m_viewAccessor.itemView();
+ const bool clearSelection = !hasSelection();
+ view->setCurrentIndex(proxyIndex);
+ if (clearSelection) {
+ view->clearSelection();
+ }
+ m_activeItemUrl.clear();
+ }
+ }
+
+ if (!m_selectedItems.isEmpty()) {
+ const KUrl& baseUrl = url();
+ KUrl url;
+ QItemSelection newSelection;
+ foreach(const KFileItem& item, m_selectedItems) {
+ url = item.url().upUrl();
+ if (baseUrl.equals(url, KUrl::CompareWithoutTrailingSlash)) {
+ QModelIndex index = m_viewAccessor.proxyModel()->mapFromSource(m_viewAccessor.dirModel()->indexForItem(item));
+ newSelection.select(index, index);
+ }
+ }
+ m_viewAccessor.itemView()->selectionModel()->select(newSelection,
+ QItemSelectionModel::ClearAndSelect
+ | QItemSelectionModel::Current);
+ m_selectedItems.clear();
+ }
+
+ // Restore the contents position. This has to be done using a Qt::QueuedConnection
+ // because the view might not be in its final state yet.
+ QMetaObject::invokeMethod(this, "restoreContentsPosition", Qt::QueuedConnection);
+}
+
+void DolphinView::slotRefreshItems()
+{
+ if (m_assureVisibleCurrentIndex) {
+ m_assureVisibleCurrentIndex = false;
+ m_viewAccessor.itemView()->scrollTo(m_viewAccessor.itemView()->currentIndex());
+ }
+}
+