summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGergo Mocsi <gmocsi91@gmail.com>2013-07-25 16:15:27 +0200
committerGergo Mocsi <gmocsi91@gmail.com>2013-07-25 16:15:27 +0200
commit890e3da2594c60914982b0a51b3672a960da23cd (patch)
treec4141eb9ad6bf50e128a8b834a14d5220a479e4c
parentac87d08754d19ed68103449b128d5dbae21ee68e (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
-rw-r--r--basctl/source/basicide/baside2.hxx4
-rw-r--r--basctl/source/basicide/baside2b.cxx16
-rw-r--r--basctl/source/basicide/codecompleteoptionsdlg.cxx5
-rw-r--r--basic/source/classes/codecompletecache.cxx7
-rw-r--r--include/vcl/lstbox.hxx2
-rw-r--r--include/vcl/quickselectionengine.hxx2
-rw-r--r--vcl/inc/ilstbox.hxx1
-rw-r--r--vcl/source/control/ilstbox.cxx4
-rw-r--r--vcl/source/control/lstbox.cxx4
-rw-r--r--vcl/source/control/quickselectionengine.cxx92
10 files changed, 81 insertions, 56 deletions
diff --git a/basctl/source/basicide/baside2.hxx b/basctl/source/basicide/baside2.hxx
index 8737091ce614..42904b2478a9 100644
--- a/basctl/source/basicide/baside2.hxx
+++ b/basctl/source/basicide/baside2.hxx
@@ -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
diff --git a/basctl/source/basicide/baside2b.cxx b/basctl/source/basicide/baside2b.cxx
index ac1f0c959bee..e6aa0b913fd9 100644
--- a/basctl/source/basicide/baside2b.cxx
+++ b/basctl/source/basicide/baside2b.cxx
@@ -2425,6 +2425,10 @@ long CodeCompleteListBox::PreNotify( NotifyEvent& rNEvt )
pCodeCompleteWindow->pParent->GetEditView()->DeleteSelected();
SetVisibleEntries();
}
+ else
+ {
+ pCodeCompleteWindow->ClearAndHide();
+ }
return 0;
case KEY_RETURN:
InsertSelectedEntry();
@@ -2437,12 +2441,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;
}
}
}
@@ -2461,18 +2466,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();
}
diff --git a/basctl/source/basicide/codecompleteoptionsdlg.cxx b/basctl/source/basicide/codecompleteoptionsdlg.cxx
index 96d1ca732f73..6dcde740f214 100644
--- a/basctl/source/basicide/codecompleteoptionsdlg.cxx
+++ b/basctl/source/basicide/codecompleteoptionsdlg.cxx
@@ -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;
}
diff --git a/basic/source/classes/codecompletecache.cxx b/basic/source/classes/codecompletecache.cxx
index cb5d4dbff4f7..952e4ee7538a 100644
--- a/basic/source/classes/codecompletecache.cxx
+++ b/basic/source/classes/codecompletecache.cxx
@@ -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 )
diff --git a/include/vcl/lstbox.hxx b/include/vcl/lstbox.hxx
index 61f8b24b5f0d..6f19cd5b872e 100644
--- a/include/vcl/lstbox.hxx
+++ b/include/vcl/lstbox.hxx
@@ -231,6 +231,8 @@ public:
void setMaxWidthChars(sal_Int32 nWidth);
virtual bool set_property(const OString &rKey, const OString &rValue);
+
+ void EnableQuickSelection( const bool& b );
};
// ----------------
diff --git a/include/vcl/quickselectionengine.hxx b/include/vcl/quickselectionengine.hxx
index 631f0c40aa95..c5a1f7297090 100644
--- a/include/vcl/quickselectionengine.hxx
+++ b/include/vcl/quickselectionengine.hxx
@@ -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
diff --git a/vcl/inc/ilstbox.hxx b/vcl/inc/ilstbox.hxx
index 8962c1d79ee0..75dcd1cc48c4 100644
--- a/vcl/inc/ilstbox.hxx
+++ b/vcl/inc/ilstbox.hxx
@@ -382,6 +382,7 @@ public:
bool GetEdgeBlending() const { return mbEdgeBlending; }
void SetEdgeBlending(bool bNew) { mbEdgeBlending = bNew; }
+ void EnableQuickSelection( const bool& b );
protected:
// ISearchableStringList
diff --git a/vcl/source/control/ilstbox.cxx b/vcl/source/control/ilstbox.cxx
index b15bfc3b37fe..685319a3e7bc 100644
--- a/vcl/source/control/ilstbox.cxx
+++ b/vcl/source/control/ilstbox.cxx
@@ -669,6 +669,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 31dfde2ac5e7..eca99ea7c9ea 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 2f379661dd79..464b4d54df7c 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,55 +105,68 @@ 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 += 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 );
+ 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 ( 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;
}
-
- 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