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
This commit is contained in:
@@ -476,10 +476,6 @@ class CodeCompleteListBox: public ListBox
|
||||
{
|
||||
friend class CodeCompleteWindow;
|
||||
private:
|
||||
std::vector< OUString > aEntryVect;
|
||||
/* vector to hold all entries for showing/hiding
|
||||
* when typing a letter/word
|
||||
* */
|
||||
OUStringBuffer aFuncBuffer;
|
||||
/* a buffer to build up function name when typing
|
||||
* a function name, used for showing/hiding listbox values
|
||||
|
@@ -2431,6 +2431,10 @@ long CodeCompleteListBox::PreNotify( NotifyEvent& rNEvt )
|
||||
pCodeCompleteWindow->pParent->GetEditView()->DeleteSelected();
|
||||
SetVisibleEntries();
|
||||
}
|
||||
else
|
||||
{
|
||||
pCodeCompleteWindow->ClearAndHide();
|
||||
}
|
||||
return 0;
|
||||
case KEY_RETURN:
|
||||
InsertSelectedEntry();
|
||||
@@ -2443,12 +2447,13 @@ long CodeCompleteListBox::PreNotify( NotifyEvent& rNEvt )
|
||||
|
||||
void CodeCompleteListBox::SetVisibleEntries()
|
||||
{
|
||||
Clear();
|
||||
for( unsigned int j=0; j < aEntryVect.size(); ++j )
|
||||
for(sal_uInt16 i=0; i< GetEntryCount(); ++i)
|
||||
{
|
||||
if( aEntryVect[j].startsWithIgnoreAsciiCase(aFuncBuffer.toString()) )
|
||||
OUString sEntry = (OUString) GetEntry(i);
|
||||
if( sEntry.startsWithIgnoreAsciiCase( aFuncBuffer.toString() ) )
|
||||
{
|
||||
InsertEntry(aEntryVect[j]);
|
||||
SelectEntry(sEntry);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2467,18 +2472,17 @@ void CodeCompleteWindow::InitListBox()
|
||||
pListBox->SetSizePixel( Size(150,150) ); //default, this will adopt the line length
|
||||
pListBox->Show();
|
||||
pListBox->GrabFocus();
|
||||
pListBox->EnableQuickSelection( false );
|
||||
}
|
||||
|
||||
void CodeCompleteWindow::InsertEntry( const OUString& aStr )
|
||||
{
|
||||
pListBox->InsertEntry( aStr );
|
||||
pListBox->aEntryVect.push_back( aStr );
|
||||
}
|
||||
|
||||
void CodeCompleteWindow::ClearListBox()
|
||||
{
|
||||
pListBox->Clear();
|
||||
pListBox->aEntryVect.clear();
|
||||
pListBox->aFuncBuffer.makeStringAndClear();
|
||||
}
|
||||
|
||||
|
@@ -41,8 +41,9 @@ CodeCompleteOptionsDlg::CodeCompleteOptionsDlg( Window* pWindow )
|
||||
pCancelBtn->SetClickHdl( LINK( this, CodeCompleteOptionsDlg, CancelHdl ) );
|
||||
|
||||
pCodeCompleteChk->Check( CodeCompleteOptions::IsCodeCompleteOn() );
|
||||
pAutocloseProcChk->Check( CodeCompleteOptions::IsProcedureAutoCompleteOn() );
|
||||
//pAutocloseProcChk->Check( CodeCompleteOptions::IsProcedureAutoCompleteOn() );
|
||||
|
||||
pAutocloseProcChk->Enable( false );
|
||||
pAutocloseBracesChk->Enable( false );
|
||||
pAutocloseQuotesChk->Enable( false );
|
||||
}
|
||||
@@ -54,7 +55,7 @@ CodeCompleteOptionsDlg::~CodeCompleteOptionsDlg()
|
||||
IMPL_LINK_NOARG(CodeCompleteOptionsDlg, OkHdl)
|
||||
{
|
||||
CodeCompleteOptions::SetCodeCompleteOn( pCodeCompleteChk->IsChecked() );
|
||||
CodeCompleteOptions::SetProcedureAutoCompleteOn( pCodeCompleteChk->IsChecked() );
|
||||
//CodeCompleteOptions::SetProcedureAutoCompleteOn( pCodeCompleteChk->IsChecked() );
|
||||
Close();
|
||||
return 0;
|
||||
}
|
||||
|
@@ -125,11 +125,8 @@ OUString CodeCompleteDataCache::GetVarType( const OUString& sVarName )
|
||||
for( CodeCompleteVarScopes::const_iterator aIt = aVarScopes.begin(); aIt != aVarScopes.end(); ++aIt )
|
||||
{
|
||||
CodeCompleteVarTypes aTypes = aIt->second;
|
||||
for( CodeCompleteVarTypes::const_iterator aOtherIt = aTypes.begin(); aOtherIt != aTypes.end(); ++aOtherIt )
|
||||
{
|
||||
if( aOtherIt->first == sVarName )
|
||||
return aOtherIt->second;
|
||||
}
|
||||
if( aTypes[sVarName] != OUString("") )
|
||||
return aTypes[sVarName];
|
||||
}
|
||||
//not a local, search global scope
|
||||
for( CodeCompleteVarTypes::const_iterator aIt = aGlobalVars.begin(); aIt != aGlobalVars.end(); ++aIt )
|
||||
|
@@ -230,6 +230,8 @@ public:
|
||||
void setMaxWidthChars(sal_Int32 nWidth);
|
||||
|
||||
virtual bool set_property(const OString &rKey, const OString &rValue);
|
||||
|
||||
void EnableQuickSelection( const bool& b );
|
||||
};
|
||||
|
||||
// ----------------
|
||||
|
@@ -75,9 +75,11 @@ namespace vcl
|
||||
|
||||
bool HandleKeyEvent( const KeyEvent& _rKEvt );
|
||||
void Reset();
|
||||
void SetEnabled( const bool& b );
|
||||
|
||||
private:
|
||||
::std::auto_ptr< QuickSelectionEngine_Data > m_pData;
|
||||
bool bEnabled;
|
||||
|
||||
private:
|
||||
QuickSelectionEngine(); // never implemented
|
||||
|
@@ -382,6 +382,7 @@ public:
|
||||
|
||||
bool GetEdgeBlending() const { return mbEdgeBlending; }
|
||||
void SetEdgeBlending(bool bNew) { mbEdgeBlending = bNew; }
|
||||
void EnableQuickSelection( const bool& b );
|
||||
|
||||
protected:
|
||||
// ISearchableStringList
|
||||
|
@@ -666,6 +666,10 @@ struct ImplEntryMetrics
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
void ImplListBoxWindow::EnableQuickSelection( const bool& b )
|
||||
{
|
||||
maQuickSelectionEngine.SetEnabled( b );
|
||||
}
|
||||
|
||||
void ImplListBoxWindow::ImplUpdateEntryMetrics( ImplEntryType& rEntry )
|
||||
{
|
||||
|
@@ -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 )
|
||||
{
|
||||
|
@@ -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
|
||||
{
|
||||
}
|
||||
|
||||
void QuickSelectionEngine::SetEnabled( const bool& b )
|
||||
{
|
||||
bEnabled = b;
|
||||
}
|
||||
|
||||
bool QuickSelectionEngine::HandleKeyEvent( const KeyEvent& _keyEvent )
|
||||
{
|
||||
sal_Unicode c = _keyEvent.GetCharCode();
|
||||
|
||||
if ( ( c >= 32 ) && ( c != 127 ) && !_keyEvent.GetKeyCode().IsMod2() )
|
||||
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 ( ( c >= 32 ) && ( c != 127 ) && !_keyEvent.GetKeyCode().IsMod2() )
|
||||
{
|
||||
// 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 );
|
||||
}
|
||||
m_pData->sCurrentSearchString += c;
|
||||
OSL_TRACE( "QuickSelectionEngine::HandleKeyEvent: searching for %s", OUStringToOString(m_pData->sCurrentSearchString, RTL_TEXTENCODING_UTF8).getStr() );
|
||||
|
||||
if ( pMatchingEntry )
|
||||
{
|
||||
m_pData->rEntryList.SelectEntry( pMatchingEntry );
|
||||
m_pData->aSearchTimeout.Start();
|
||||
}
|
||||
else
|
||||
{
|
||||
lcl_reset( *m_pData );
|
||||
}
|
||||
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();
|
||||
}
|
||||
|
||||
return true;
|
||||
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 false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void QuickSelectionEngine::Reset()
|
||||
{
|
||||
lcl_reset( *m_pData );
|
||||
if( bEnabled )
|
||||
lcl_reset( *m_pData );
|
||||
}
|
||||
|
||||
} // namespace vcl
|
||||
|
Reference in New Issue
Block a user