X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/4bccabca1bd705f24a35ed1ea31fc6d185c2b442..a0d3cf4aa8ffa76ed22a67efa4ea156eb2ef9f68:/src/dolphincontroller.cpp diff --git a/src/dolphincontroller.cpp b/src/dolphincontroller.cpp index 89d6509ca..caa0aa74f 100644 --- a/src/dolphincontroller.cpp +++ b/src/dolphincontroller.cpp @@ -171,15 +171,34 @@ void DolphinController::handleKeyPressEvent(QKeyEvent* event) const QItemSelectionModel* selModel = m_itemView->selectionModel(); const QModelIndex currentIndex = selModel->currentIndex(); const bool trigger = currentIndex.isValid() - && ((event->key() == Qt::Key_Return) - || (event->key() == Qt::Key_Enter)) + && ((event->key() == Qt::Key_Return) || (event->key() == Qt::Key_Enter)) && !selModel->selectedIndexes().isEmpty(); - if (trigger) { - const QModelIndexList indexList = selModel->selectedIndexes(); - foreach (const QModelIndex& index, indexList) { + if (!trigger) { + return; + } + + // Emit the signal itemTriggered() for all selected files. + // Several selected directories are opened in separate tabs, + // one selected directory will get opened in the view. + QModelIndexList dirQueue; + const QModelIndexList indexList = selModel->selectedIndexes(); + foreach (const QModelIndex& index, indexList) { + if (itemForIndex(index).isDir()) { + dirQueue << index; + } else { emit itemTriggered(itemForIndex(index)); } } + + if (dirQueue.length() == 1) { + // open directory in the view + emit itemTriggered(itemForIndex(dirQueue[0])); + } else { + // open directories in separate tabs + foreach(const QModelIndex& dir, dirQueue) { + emit tabRequested(itemForIndex(dir).url()); + } + } } void DolphinController::replaceUrlByClipboard() @@ -255,11 +274,6 @@ void DolphinController::emitViewportEntered() emit viewportEntered(); } -void DolphinController::emitSelectionChanged() -{ - emit selectionChanged(); -} - void DolphinController::updateMouseButtonState() { m_mouseButtons = QApplication::mouseButtons();