X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/e1c74b05fdae664aa9211cba3afb7993b51ec23b..7eeb8dba6aeba09aa3dfa7fa5f0b00840d4d8317:/src/dolphincontroller.cpp diff --git a/src/dolphincontroller.cpp b/src/dolphincontroller.cpp index 47c661e83..b61c126b5 100644 --- a/src/dolphincontroller.cpp +++ b/src/dolphincontroller.cpp @@ -34,7 +34,8 @@ DolphinController::DolphinController(DolphinView* dolphinView) : m_nameFilter(), m_url(), m_dolphinView(dolphinView), - m_itemView(0) + m_itemView(0), + m_versionControlActions() { } @@ -46,10 +47,16 @@ void DolphinController::setUrl(const KUrl& url) { if (m_url != url) { m_url = url; + emit cancelPreviews(); emit urlChanged(url); } } +void DolphinController::redirectToUrl(const KUrl& url) +{ + m_url = url; +} + void DolphinController::setItemView(QAbstractItemView* view) { if (m_itemView != 0) { @@ -68,13 +75,6 @@ void DolphinController::setItemView(QAbstractItemView* view) } } -void DolphinController::triggerUrlChangeRequest(const KUrl& url) -{ - if (m_url != url) { - emit requestUrlChange(url); - } -} - void DolphinController::triggerContextMenuRequest(const QPoint& pos, const QList& customActions) { @@ -143,6 +143,20 @@ void DolphinController::setZoomLevel(int level) } } +void DolphinController::setVersionControlActions(QList actions) +{ + m_versionControlActions = actions; +} + +QList DolphinController::versionControlActions(const KFileItemList& items) +{ + emit requestVersionControlActions(items); + // All view implementations are connected with the signal requestVersionControlActions() + // (see ViewExtensionFactory) and will invoke DolphinController::setVersionControlActions(), + // so that the context dependent actions can be returned. + return m_versionControlActions; +} + void DolphinController::handleKeyPressEvent(QKeyEvent* event) { Q_ASSERT(m_itemView != 0); @@ -150,15 +164,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()