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