+ emit requestItemInfo(KFileItem());
+}
+
+void DolphinView::slotDeleteFileFinished(KJob* job)
+{
+ if (job->error() == 0) {
+ emit operationCompletedMessage(i18nc("@info:status", "Delete operation completed."));
+ } else if (job->error() != KIO::ERR_USER_CANCELED) {
+ emit errorMessage(job->errorString());
+ }
+}
+
+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;
+
+ 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());
+ }
+}
+
+void DolphinView::loadDirectory(const KUrl& url, bool reload)
+{
+ if (!url.isValid()) {
+ const QString location(url.pathOrUrl());
+ if (location.isEmpty()) {
+ emit errorMessage(i18nc("@info:status", "The location is empty."));
+ } else {
+ emit errorMessage(i18nc("@info:status", "The location '%1' is invalid.", location));
+ }
+ return;
+ }
+
+ KDirLister* dirLister = m_viewAccessor.dirLister();
+ dirLister->openUrl(url, reload ? KDirLister::Reload : KDirLister::NoFlags);