X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/dcbf1a11783d47e7e4fa30d488ac93a8bc547e71..4a5218b3671cfa637d66bc21c231d5d97670a3fc:/src/dolphincontroller.cpp diff --git a/src/dolphincontroller.cpp b/src/dolphincontroller.cpp index fe8c426f3..820d34a06 100644 --- a/src/dolphincontroller.cpp +++ b/src/dolphincontroller.cpp @@ -26,10 +26,11 @@ #include #include +Qt::MouseButtons DolphinController::m_mouseButtons = Qt::NoButton; + DolphinController::DolphinController(DolphinView* dolphinView) : QObject(dolphinView), m_zoomLevel(0), - m_mouseButtons(Qt::NoButton), m_url(), m_dolphinView(dolphinView), m_itemView(0) @@ -59,7 +60,7 @@ void DolphinController::setItemView(QAbstractItemView* view) if (m_itemView != 0) { m_zoomLevel = ZoomLevelInfo::zoomLevelForIconSize(m_itemView->iconSize()); - + // TODO: this is a workaround until Qt-issue 176832 has been fixed connect(m_itemView, SIGNAL(pressed(const QModelIndex&)), this, SLOT(updateMouseButtonState())); @@ -128,13 +129,36 @@ 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) - && (selModel->selectedIndexes().count() > 0); - if (trigger) { - const QModelIndexList indexList = selModel->selectedIndexes(); - foreach (const QModelIndex& index, indexList) { - triggerItem(index); + + if (currentIndex.isValid() && selModel->selectedIndexes().count() > 0) { + const int key = event->key(); + + if ((key == Qt::Key_Return) || (key == Qt::Key_Enter) || (key == Qt::Key_Right)) { + + const QModelIndexList indexList = selModel->selectedIndexes(); + const bool isColumnView = m_dolphinView->mode() == m_dolphinView->ColumnView; + + if (key == Qt::Key_Right) { + if (isColumnView) { + // If it is the right arrow key and in the column view-only. + KFileItem curFileItem; + foreach(const QModelIndex& index, indexList) { + curFileItem = itemForIndex(index); + if (!curFileItem.isFile()) { + /* We want + * to make sure that the selected item + * is only a folder. If we did not have this check, it would be possible to use + * the right arrow to open a file when in the column view */ + emit itemTriggered(curFileItem); + } + } + } + } else { + //Else it is Return or Enter keypress, so it is okay to perform the action of triggering, on files also. + foreach(const QModelIndex& index, indexList) { + emit itemTriggered(itemForIndex(index)); + } + } } } } @@ -178,9 +202,6 @@ void DolphinController::triggerItem(const QModelIndex& index) m_itemView->clearSelection(); emit itemEntered(KFileItem()); } - m_mouseButtons = Qt::NoButton; - } else if (m_mouseButtons & Qt::RightButton) { - m_mouseButtons = Qt::NoButton; } } @@ -194,9 +215,6 @@ void DolphinController::requestTab(const QModelIndex& index) if (validRequest) { emit tabRequested(item.url()); } - m_mouseButtons = Qt::NoButton; - } else if (m_mouseButtons & Qt::RightButton) { - m_mouseButtons = Qt::NoButton; } }