X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/f37ecd6ecfab9bc1d2929504b4f6e4363f8137b9..39f89141b06c:/src/panels/folders/folderspanel.cpp diff --git a/src/panels/folders/folderspanel.cpp b/src/panels/folders/folderspanel.cpp index 72d9a0952..fae7ca6a1 100644 --- a/src/panels/folders/folderspanel.cpp +++ b/src/panels/folders/folderspanel.cpp @@ -19,15 +19,9 @@ #include "folderspanel.h" -#include "dolphinmodel.h" -#include "dolphinsortfilterproxymodel.h" -#include "dolphinview.h" #include "settings/dolphinsettings.h" #include "dolphin_folderspanelsettings.h" #include "dolphin_generalsettings.h" -#include "draganddrophelper.h" -#include "folderexpander.h" -#include "renamedialog.h" #include "paneltreeview.h" #include "treeviewcontextmenu.h" @@ -44,6 +38,13 @@ #include #include +#include +#include +#include +#include +#include +#include + FoldersPanel::FoldersPanel(QWidget* parent) : Panel(parent), m_setLeafVisible(false), @@ -94,31 +95,28 @@ void FoldersPanel::rename(const KFileItem& item) const QModelIndex proxyIndex = m_proxyModel->mapFromSource(dirIndex); m_treeView->edit(proxyIndex); } else { - KFileItemList items; - items.append(item); - RenameDialog dialog(this, items); - if (dialog.exec() == QDialog::Accepted) { - const QString& newName = dialog.newName(); - if (!newName.isEmpty()) { - KUrl newUrl = item.url(); - newUrl.setFileName(newName); - KonqOperations::rename(this, item.url(), newUrl); - } - } + RenameDialog* dialog = new RenameDialog(this, KFileItemList() << item); + dialog->setAttribute(Qt::WA_DeleteOnClose); + dialog->show(); + dialog->raise(); + dialog->activateWindow(); } } -void FoldersPanel::setUrl(const KUrl& url) +bool FoldersPanel::urlChanged() { - if (!url.isValid() || (url == Panel::url())) { - return; + if (!url().isValid() || url().protocol().contains("search")) { + // Skip results shown by a search, as possible identical + // directory names are useless without parent-path information. + return false; } - Panel::setUrl(url); if (m_dirLister != 0) { m_setLeafVisible = true; - loadTree(url); + loadTree(url()); } + + return true; } void FoldersPanel::showEvent(QShowEvent* event) @@ -184,13 +182,23 @@ void FoldersPanel::contextMenuEvent(QContextMenuEvent* event) if (index.isValid()) { const QModelIndex dolphinModelIndex = m_proxyModel->mapToSource(index); item = m_dolphinModel->itemForIndex(dolphinModelIndex); - emit changeSelection(KFileItemList()); } TreeViewContextMenu contextMenu(this, item); contextMenu.open(); } +void FoldersPanel::keyPressEvent(QKeyEvent* event) +{ + const int key = event->key(); + if ((key == Qt::Key_Enter) || (key == Qt::Key_Return)) { + event->accept(); + updateActiveView(m_treeView->currentIndex()); + } else { + Panel::keyPressEvent(event); + } +} + void FoldersPanel::updateActiveView(const QModelIndex& index) { const QModelIndex dirIndex = m_proxyModel->mapToSource(index);