Changeset View
Changeset View
Standalone View
Standalone View
src/kitemviews/kitemlistcontroller.cpp
Show First 20 Lines • Show All 55 Lines • ▼ Show 20 Line(s) | 41 | KItemListController::KItemListController(KItemModelBase* model, KItemListView* view, QObject* parent) : | |||
---|---|---|---|---|---|
56 | m_oldSelection(), | 56 | m_oldSelection(), | ||
57 | m_keyboardAnchorIndex(-1), | 57 | m_keyboardAnchorIndex(-1), | ||
58 | m_keyboardAnchorPos(0) | 58 | m_keyboardAnchorPos(0) | ||
59 | { | 59 | { | ||
60 | connect(m_keyboardManager, &KItemListKeyboardSearchManager::changeCurrentItem, | 60 | connect(m_keyboardManager, &KItemListKeyboardSearchManager::changeCurrentItem, | ||
61 | this, &KItemListController::slotChangeCurrentItem); | 61 | this, &KItemListController::slotChangeCurrentItem); | ||
62 | connect(m_selectionManager, &KItemListSelectionManager::currentChanged, | 62 | connect(m_selectionManager, &KItemListSelectionManager::currentChanged, | ||
63 | m_keyboardManager, &KItemListKeyboardSearchManager::slotCurrentChanged); | 63 | m_keyboardManager, &KItemListKeyboardSearchManager::slotCurrentChanged); | ||
64 | connect(m_selectionManager, &KItemListSelectionManager::selectionChanged, | ||||
65 | m_keyboardManager, &KItemListKeyboardSearchManager::slotSelectionChanged); | ||||
64 | 66 | | |||
65 | m_autoActivationTimer = new QTimer(this); | 67 | m_autoActivationTimer = new QTimer(this); | ||
66 | m_autoActivationTimer->setSingleShot(true); | 68 | m_autoActivationTimer->setSingleShot(true); | ||
67 | m_autoActivationTimer->setInterval(-1); | 69 | m_autoActivationTimer->setInterval(-1); | ||
68 | connect(m_autoActivationTimer, &QTimer::timeout, this, &KItemListController::slotAutoActivationTimeout); | 70 | connect(m_autoActivationTimer, &QTimer::timeout, this, &KItemListController::slotAutoActivationTimeout); | ||
69 | 71 | | |||
70 | setModel(model); | 72 | setModel(model); | ||
71 | setView(view); | 73 | setView(view); | ||
▲ Show 20 Lines • Show All 395 Lines • ▼ Show 20 Line(s) | 216 | { | |||
467 | return true; | 469 | return true; | ||
468 | } | 470 | } | ||
469 | 471 | | |||
470 | void KItemListController::slotChangeCurrentItem(const QString& text, bool searchFromNextItem) | 472 | void KItemListController::slotChangeCurrentItem(const QString& text, bool searchFromNextItem) | ||
471 | { | 473 | { | ||
472 | if (!m_model || m_model->count() == 0) { | 474 | if (!m_model || m_model->count() == 0) { | ||
473 | return; | 475 | return; | ||
474 | } | 476 | } | ||
475 | const int currentIndex = m_selectionManager->currentItem(); | | |||
476 | int index; | 477 | int index; | ||
477 | if (searchFromNextItem) { | 478 | if (searchFromNextItem) { | ||
479 | const int currentIndex = m_selectionManager->currentItem(); | ||||
478 | index = m_model->indexForKeyboardSearch(text, (currentIndex + 1) % m_model->count()); | 480 | index = m_model->indexForKeyboardSearch(text, (currentIndex + 1) % m_model->count()); | ||
479 | } else { | 481 | } else { | ||
480 | index = m_model->indexForKeyboardSearch(text, currentIndex); | 482 | index = m_model->indexForKeyboardSearch(text, 0); | ||
481 | } | 483 | } | ||
482 | if (index >= 0) { | 484 | if (index >= 0) { | ||
483 | m_selectionManager->setCurrentItem(index); | 485 | m_selectionManager->setCurrentItem(index); | ||
484 | 486 | | |||
485 | if (m_selectionBehavior != NoSelection) { | 487 | if (m_selectionBehavior != NoSelection) { | ||
486 | m_selectionManager->clearSelection(); | 488 | m_selectionManager->replaceSelection(index); | ||
487 | m_selectionManager->setSelected(index, 1); | | |||
488 | m_selectionManager->beginAnchoredSelection(index); | 489 | m_selectionManager->beginAnchoredSelection(index); | ||
489 | } | 490 | } | ||
490 | 491 | | |||
491 | m_view->scrollToItem(index); | 492 | m_view->scrollToItem(index); | ||
492 | } | 493 | } | ||
493 | } | 494 | } | ||
494 | 495 | | |||
495 | void KItemListController::slotAutoActivationTimeout() | 496 | void KItemListController::slotAutoActivationTimeout() | ||
▲ Show 20 Lines • Show All 860 Lines • Show Last 20 Lines |