From: Peter Penz Date: Sun, 9 Sep 2007 18:54:32 +0000 (+0000) Subject: check whether the current index is valid and whether no other items are selected X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/commitdiff_plain/ea270709c1ed77978d0b88016ab490fe67b73c56 check whether the current index is valid and whether no other items are selected svn path=/trunk/KDE/kdebase/apps/; revision=710361 --- diff --git a/src/dolphindetailsview.cpp b/src/dolphindetailsview.cpp index dfd7018bb..d7c8c5ab1 100644 --- a/src/dolphindetailsview.cpp +++ b/src/dolphindetailsview.cpp @@ -278,8 +278,14 @@ void DolphinDetailsView::paintEvent(QPaintEvent* event) void DolphinDetailsView::keyPressEvent(QKeyEvent* event) { QTreeView::keyPressEvent(event); - if (event->key() == Qt::Key_Return) { - m_controller->triggerItem(selectionModel()->currentIndex()); + + const QItemSelectionModel* selModel = selectionModel(); + const QModelIndex currentIndex = selModel->currentIndex(); + const bool triggerItem = currentIndex.isValid() + && (event->key() == Qt::Key_Return) + && (selModel->selectedIndexes().count() <= 1); + if (triggerItem) { + m_controller->triggerItem(currentIndex); } } diff --git a/src/dolphiniconsview.cpp b/src/dolphiniconsview.cpp index ed2332c05..d287318d0 100644 --- a/src/dolphiniconsview.cpp +++ b/src/dolphiniconsview.cpp @@ -209,8 +209,14 @@ void DolphinIconsView::paintEvent(QPaintEvent* event) void DolphinIconsView::keyPressEvent(QKeyEvent* event) { KCategorizedView::keyPressEvent(event); - if (event->key() == Qt::Key_Return) { - m_controller->triggerItem(selectionModel()->currentIndex()); + + const QItemSelectionModel* selModel = selectionModel(); + const QModelIndex currentIndex = selModel->currentIndex(); + const bool triggerItem = currentIndex.isValid() + && (event->key() == Qt::Key_Return) + && (selModel->selectedIndexes().count() <= 1); + if (triggerItem) { + m_controller->triggerItem(currentIndex); } }