Changeset View
Changeset View
Standalone View
Standalone View
src/kitemviews/kitemlistcontroller.cpp
| Show First 20 Lines • Show All 256 Lines • ▼ Show 20 Line(s) | 251 | if (m_view->scrollOrientation() == Qt::Horizontal) { | |||
|---|---|---|---|---|---|
| 257 | default: break; | 257 | default: break; | ||
| 258 | } | 258 | } | ||
| 259 | } | 259 | } | ||
| 260 | 260 | | |||
| 261 | const bool selectSingleItem = m_selectionBehavior != NoSelection && | 261 | const bool selectSingleItem = m_selectionBehavior != NoSelection && | ||
| 262 | itemCount == 1 && | 262 | itemCount == 1 && | ||
| 263 | (key == Qt::Key_Home || key == Qt::Key_End || | 263 | (key == Qt::Key_Home || key == Qt::Key_End || | ||
| 264 | key == Qt::Key_Up || key == Qt::Key_Down || | 264 | key == Qt::Key_Up || key == Qt::Key_Down || | ||
| 265 | key == Qt::Key_Left || key == Qt::Key_Right); | 265 | key == Qt::Key_Left || key == Qt::Key_Right|| | ||
| 266 | key == Qt::Key::Key_J || key == Qt::Key::Key_K); | ||||
| 266 | if (selectSingleItem) { | 267 | if (selectSingleItem) { | ||
| 267 | const int current = m_selectionManager->currentItem(); | 268 | const int current = m_selectionManager->currentItem(); | ||
| 268 | m_selectionManager->setSelected(current); | 269 | m_selectionManager->setSelected(current); | ||
| 269 | return true; | 270 | return true; | ||
| 270 | } | 271 | } | ||
| 271 | 272 | | |||
| 272 | switch (key) { | 273 | switch (key) { | ||
| 273 | case Qt::Key_Home: | 274 | case Qt::Key_Home: | ||
| Show All 27 Lines | |||||
| 301 | case Qt::Key_Right: | 302 | case Qt::Key_Right: | ||
| 302 | if (index < itemCount - 1) { | 303 | if (index < itemCount - 1) { | ||
| 303 | ++index; | 304 | ++index; | ||
| 304 | m_keyboardAnchorIndex = index; | 305 | m_keyboardAnchorIndex = index; | ||
| 305 | m_keyboardAnchorPos = keyboardAnchorPos(index); | 306 | m_keyboardAnchorPos = keyboardAnchorPos(index); | ||
| 306 | } | 307 | } | ||
| 307 | break; | 308 | break; | ||
| 308 | 309 | | |||
| 310 | case Qt::Key::Key_K: | ||||
| 309 | case Qt::Key_Up: | 311 | case Qt::Key_Up: | ||
| 310 | updateKeyboardAnchor(); | 312 | updateKeyboardAnchor(); | ||
| 311 | index = previousRowIndex(index); | 313 | index = previousRowIndex(index); | ||
| 312 | break; | 314 | break; | ||
| 313 | 315 | | |||
| 316 | case Qt::Key::Key_J: | ||||
| 314 | case Qt::Key_Down: | 317 | case Qt::Key_Down: | ||
| 315 | updateKeyboardAnchor(); | 318 | updateKeyboardAnchor(); | ||
| 316 | index = nextRowIndex(index); | 319 | index = nextRowIndex(index); | ||
| 317 | break; | 320 | break; | ||
| 318 | 321 | | |||
| 322 | case Qt::Key::Key_Plus: | ||||
| 323 | updateKeyboardAnchor(); | ||||
| 324 | m_selectionManager->setSelected(index, 1, KItemListSelectionManager::SelectionMode::Select); | ||||
| 325 | break; | ||||
| 326 | | ||||
| 327 | case Qt::Key::Key_Minus: | ||||
| 328 | case Qt::Key::Key_Underscore: | ||||
| 329 | updateKeyboardAnchor(); | ||||
| 330 | m_selectionManager->setSelected(index, 1, KItemListSelectionManager::SelectionMode::Deselect); | ||||
| 331 | break; | ||||
| 332 | | ||||
| 319 | case Qt::Key_PageUp: | 333 | case Qt::Key_PageUp: | ||
| 320 | if (m_view->scrollOrientation() == Qt::Horizontal) { | 334 | if (m_view->scrollOrientation() == Qt::Horizontal) { | ||
| 321 | // The new current index should correspond to the first item in the current column. | 335 | // The new current index should correspond to the first item in the current column. | ||
| 322 | int newIndex = qMax(index - 1, 0); | 336 | int newIndex = qMax(index - 1, 0); | ||
| 323 | while (newIndex != index && m_view->itemRect(newIndex).topLeft().y() < m_view->itemRect(index).topLeft().y()) { | 337 | while (newIndex != index && m_view->itemRect(newIndex).topLeft().y() < m_view->itemRect(index).topLeft().y()) { | ||
| 324 | index = newIndex; | 338 | index = newIndex; | ||
| 325 | newIndex = qMax(index - 1, 0); | 339 | newIndex = qMax(index - 1, 0); | ||
| 326 | } | 340 | } | ||
| Show All 40 Lines | 371 | } else { | |||
| 367 | do { | 381 | do { | ||
| 368 | index = newIndex; | 382 | index = newIndex; | ||
| 369 | updateKeyboardAnchor(); | 383 | updateKeyboardAnchor(); | ||
| 370 | newIndex = nextRowIndex(index); | 384 | newIndex = nextRowIndex(index); | ||
| 371 | } while (m_view->itemRect(newIndex).bottomLeft().y() < targetY && newIndex != index); | 385 | } while (m_view->itemRect(newIndex).bottomLeft().y() < targetY && newIndex != index); | ||
| 372 | } | 386 | } | ||
| 373 | break; | 387 | break; | ||
| 374 | 388 | | |||
| 389 | case Qt::Key::Key_L: | ||||
| 375 | case Qt::Key_Enter: | 390 | case Qt::Key_Enter: | ||
| 376 | case Qt::Key_Return: { | 391 | case Qt::Key_Return: { | ||
| 377 | const KItemSet selectedItems = m_selectionManager->selectedItems(); | 392 | const KItemSet selectedItems = m_selectionManager->selectedItems(); | ||
| 378 | if (selectedItems.count() >= 2) { | 393 | if (selectedItems.count() >= 2) { | ||
| 379 | emit itemsActivated(selectedItems); | 394 | emit itemsActivated(selectedItems); | ||
| 380 | } else if (selectedItems.count() == 1) { | 395 | } else if (selectedItems.count() == 1) { | ||
| 381 | emit itemActivated(selectedItems.first()); | 396 | emit itemActivated(selectedItems.first()); | ||
| 382 | } else { | 397 | } else { | ||
| ▲ Show 20 Lines • Show All 972 Lines • Show Last 20 Lines | |||||