diff options
author | Gergo Mocsi <gmocsi91@gmail.com> | 2013-07-25 16:15:27 +0200 |
---|---|---|
committer | Gergo Mocsi <gmocsi91@gmail.com> | 2013-09-02 18:16:49 +0200 |
commit | d5aa9c3b23f6c9b5ff0b6af11ff6d6827c5f24bd (patch) | |
tree | 7459b7b96eb233133c18f3fa53d2c76cff6aba68 /vcl/source | |
parent | 59520bd3f1cd619cfe02ea1d6c8d8888413fd9af (diff) |
GSOC work, disable QuickSelectionEngine+ListBox navigation modification
Added a function to disable QuickSelectionEngine in ListBox, beacuse it's not needed.
ListBox navigation changed: it is not hiding/showing entries, instead of it, jumps to the longest match without filtering.
Arrow behavior remains the same.
Change-Id: I8982c280f20929c74f9630cbaa95010820d2e234
Diffstat (limited to 'vcl/source')
-rw-r--r-- | vcl/source/control/ilstbox.cxx | 4 | ||||
-rw-r--r-- | vcl/source/control/lstbox.cxx | 4 | ||||
-rw-r--r-- | vcl/source/control/quickselectionengine.cxx | 77 |
3 files changed, 61 insertions, 24 deletions
diff --git a/vcl/source/control/ilstbox.cxx b/vcl/source/control/ilstbox.cxx index 03da1f7a754c..a5bc8bfd80ec 100644 --- a/vcl/source/control/ilstbox.cxx +++ b/vcl/source/control/ilstbox.cxx @@ -666,6 +666,10 @@ struct ImplEntryMetrics }; // ----------------------------------------------------------------------- +void ImplListBoxWindow::EnableQuickSelection( const bool& b ) +{ + maQuickSelectionEngine.SetEnabled( b ); +} void ImplListBoxWindow::ImplUpdateEntryMetrics( ImplEntryType& rEntry ) { diff --git a/vcl/source/control/lstbox.cxx b/vcl/source/control/lstbox.cxx index 1a95d2a5726c..175e86d62135 100644 --- a/vcl/source/control/lstbox.cxx +++ b/vcl/source/control/lstbox.cxx @@ -38,6 +38,10 @@ #include <com/sun/star/datatransfer/dnd/XDropTarget.hpp> +void ListBox::EnableQuickSelection( const bool& b ) +{ + mpImplLB->GetMainWindow()->EnableQuickSelection(b); +} ListBox::ListBox( WindowType nType ) : Control( nType ) { diff --git a/vcl/source/control/quickselectionengine.cxx b/vcl/source/control/quickselectionengine.cxx index 5ee2cfaf2981..f265bf400e9c 100644 --- a/vcl/source/control/quickselectionengine.cxx +++ b/vcl/source/control/quickselectionengine.cxx @@ -96,7 +96,8 @@ namespace vcl } QuickSelectionEngine::QuickSelectionEngine( ISearchableStringList& _entryList ) - :m_pData( new QuickSelectionEngine_Data( _entryList ) ) + :m_pData( new QuickSelectionEngine_Data( _entryList ) ), + bEnabled( true ) { } @@ -104,11 +105,14 @@ namespace vcl { } - bool QuickSelectionEngine::HandleKeyEvent( const KeyEvent& _keyEvent ) + void QuickSelectionEngine::SetEnabled( const bool& b ) { - sal_Unicode c = _keyEvent.GetCharCode(); + bEnabled = b; + } - if ( ( c >= 32 ) && ( c != 127 ) && !_keyEvent.GetKeyCode().IsMod2() ) + bool QuickSelectionEngine::HandleKeyEvent( const KeyEvent& _keyEvent ) + { + if( bEnabled ) { m_pData->sCurrentSearchString += OUString(c); OSL_TRACE( "QuickSelectionEngine::HandleKeyEvent: searching for %s", OUStringToOString(m_pData->sCurrentSearchString, RTL_TEXTENCODING_UTF8).getStr() ); @@ -125,34 +129,59 @@ namespace vcl } OUString aSearchTemp( m_pData->sCurrentSearchString ); + sal_Unicode c = _keyEvent.GetCharCode(); - StringEntryIdentifier pMatchingEntry = findMatchingEntry( aSearchTemp, *m_pData ); - OSL_TRACE( "QuickSelectionEngine::HandleKeyEvent: found %p", pMatchingEntry ); - if ( !pMatchingEntry && (aSearchTemp.getLength() > 1) && !!m_pData->aSingleSearchChar ) - { - // if there's only one letter in the search string, use a different search mode - aSearchTemp = OUString(*m_pData->aSingleSearchChar); - pMatchingEntry = findMatchingEntry( aSearchTemp, *m_pData ); - } - - if ( pMatchingEntry ) - { - m_pData->rEntryList.SelectEntry( pMatchingEntry ); - m_pData->aSearchTimeout.Start(); - } - else + if ( ( c >= 32 ) && ( c != 127 ) && !_keyEvent.GetKeyCode().IsMod2() ) { - lcl_reset( *m_pData ); + m_pData->sCurrentSearchString += c; + OSL_TRACE( "QuickSelectionEngine::HandleKeyEvent: searching for %s", OUStringToOString(m_pData->sCurrentSearchString, RTL_TEXTENCODING_UTF8).getStr() ); + + if ( m_pData->sCurrentSearchString.Len() == 1 ) + { // first character in the search -> remmeber + m_pData->aSingleSearchChar.reset( c ); + } + else if ( m_pData->sCurrentSearchString.Len() > 1 ) + { + if ( !!m_pData->aSingleSearchChar && ( *m_pData->aSingleSearchChar != c ) ) + // we already have a "single char", but the current one is different -> reset + m_pData->aSingleSearchChar.reset(); + } + + OUString aSearchTemp( m_pData->sCurrentSearchString ); + + StringEntryIdentifier pMatchingEntry = findMatchingEntry( aSearchTemp, *m_pData ); + OSL_TRACE( "QuickSelectionEngine::HandleKeyEvent: found %p", pMatchingEntry ); + if ( !pMatchingEntry && (aSearchTemp.getLength() > 1) && !!m_pData->aSingleSearchChar ) + { + // if there's only one letter in the search string, use a different search mode + aSearchTemp = OUString(*m_pData->aSingleSearchChar); + pMatchingEntry = findMatchingEntry( aSearchTemp, *m_pData ); + } + + if ( pMatchingEntry ) + { + m_pData->rEntryList.SelectEntry( pMatchingEntry ); + m_pData->aSearchTimeout.Start(); + } + else + { + lcl_reset( *m_pData ); + } + + return true; } - - return true; + return false; + } + else + { + return false; } - return false; } void QuickSelectionEngine::Reset() { - lcl_reset( *m_pData ); + if( bEnabled ) + lcl_reset( *m_pData ); } } // namespace vcl |