From 1485acc3e86bf6c7e32672c6d36d86e3eb5ddc9e Mon Sep 17 00:00:00 2001 From: Palenik Mihály Date: Wed, 4 Feb 2015 18:27:35 +0100 Subject: Implement search funtion in Expert Configuration dialog. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I5a594b3d6ef84b022ce4a92a865beba735d47113 Reviewed-on: https://gerrit.libreoffice.org/14322 Tested-by: Jenkins Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara --- cui/source/options/optaboutconfig.cxx | 79 +++++++++++- cui/source/options/optaboutconfig.hxx | 8 ++ cui/uiconfig/ui/aboutconfigdialog.ui | 236 ++++++++++++++++++++-------------- 3 files changed, 226 insertions(+), 97 deletions(-) diff --git a/cui/source/options/optaboutconfig.cxx b/cui/source/options/optaboutconfig.cxx index 87321458fff1..3b2b0f9113fc 100644 --- a/cui/source/options/optaboutconfig.cxx +++ b/cui/source/options/optaboutconfig.cxx @@ -24,6 +24,9 @@ #include #include #include +#include +#include +#include #include #include @@ -124,9 +127,10 @@ CuiAboutConfigTabPage::CuiAboutConfigTabPage( vcl::Window* pParent/*, const SfxI m_pPrefCtrl( get("preferences") ), m_pResetBtn( get("reset") ), m_pEditBtn( get("edit") ), + m_pSearchBtn( get("searchButton") ), + m_pSearchEdit( get("searchEntry") ), m_vectorOfModified(), - m_pPrefBox( new SvSimpleTable(*m_pPrefCtrl, - WB_SCROLL | WB_HSCROLL | WB_VSCROLL ) ) + m_pPrefBox( new SvSimpleTable(*m_pPrefCtrl, WB_SCROLL | WB_HSCROLL | WB_VSCROLL ) ) { Size aControlSize(LogicToPixel(Size(385, 230), MAP_APPFONT)); m_pPrefCtrl->set_width_request(aControlSize.Width()); @@ -135,6 +139,7 @@ CuiAboutConfigTabPage::CuiAboutConfigTabPage( vcl::Window* pParent/*, const SfxI m_pEditBtn->SetClickHdl( LINK( this, CuiAboutConfigTabPage, StandardHdl_Impl ) ); m_pResetBtn->SetClickHdl( LINK( this, CuiAboutConfigTabPage, ResetBtnHdl_Impl ) ); m_pPrefBox->SetDoubleClickHdl( LINK(this, CuiAboutConfigTabPage, StandardHdl_Impl) ); + m_pSearchBtn->SetClickHdl( LINK(this, CuiAboutConfigTabPage, SearchHdl_Impl) ); m_pPrefBox->InsertHeaderEntry(get("preference")->GetText()); m_pPrefBox->InsertHeaderEntry(get("property")->GetText()); @@ -150,6 +155,11 @@ CuiAboutConfigTabPage::CuiAboutConfigTabPage( vcl::Window* pParent/*, const SfxI aTabs[3] = aTabs[2] + fWidth * 20; aTabs[4] = aTabs[3] + fWidth * 8; + m_options.algorithmType = util::SearchAlgorithms_ABSOLUTE; + m_options.transliterateFlags |= i18n::TransliterationModules_IGNORE_CASE; + m_options.searchFlag |= (util::SearchFlags::REG_NOT_BEGINOFLINE | + util::SearchFlags::REG_NOT_ENDOFLINE); + m_pPrefBox->SetTabs(aTabs, MAP_PIXEL); m_pPrefBox->SetAlternatingRowColors( true ); } @@ -165,6 +175,10 @@ void CuiAboutConfigTabPage::InsertEntry(const OUString& rProp, const OUString& r pEntry->AddItem( new SvLBoxString( pEntry, 0, rValue)); m_pPrefBox->Insert( pEntry ); + + SvTreeListEntry* pEntryClone = new SvTreeListEntry; + pEntryClone->Clone( pEntry ); + m_prefBoxEntries.push_back( pEntryClone ); } void CuiAboutConfigTabPage::Reset() @@ -654,6 +668,15 @@ IMPL_LINK_NOARG( CuiAboutConfigTabPage, StandardHdl_Impl ) //update listbox value. m_pPrefBox->SetEntryText( sDialogValue, pEntry, 3 ); + //update m_prefBoxEntries + SvTreeListEntries::iterator it = std::find_if(m_prefBoxEntries.begin(), m_prefBoxEntries.end(), + [sPropertyPath, sPropertyName](SvTreeListEntry &entry) -> bool + { + return static_cast< SvLBoxString* >( entry.GetItem(1) )->GetText().equals( sPropertyPath ) && + static_cast< SvLBoxString* >( entry.GetItem(2) )->GetText().equals( sPropertyName ); + } + ); + it->ReplaceItem( new SvLBoxString( &(*it), 0, sDialogValue ), 4 ); } catch( uno::Exception& ) { @@ -662,4 +685,56 @@ IMPL_LINK_NOARG( CuiAboutConfigTabPage, StandardHdl_Impl ) return 0; } +IMPL_LINK_NOARG( CuiAboutConfigTabPage, SearchHdl_Impl) +{ + m_pPrefBox->Clear(); + m_pPrefBox->SetUpdateMode( false ); + + SvSortMode sortMode = m_pPrefBox->GetModel()->GetSortMode(); + sal_uInt16 sortedCol = m_pPrefBox->GetSortedCol(); + + if( sortMode != SortNone ) + m_pPrefBox->SortByCol( 0xFFFF ); + + if( m_pSearchEdit->GetText().isEmpty() ) + { + for( auto it = m_prefBoxEntries.begin(); it != m_prefBoxEntries.end(); ++it ) + { + SvTreeListEntry* pEntry = new SvTreeListEntry; + pEntry->Clone( &(*it) ) ; + m_pPrefBox->Insert( pEntry ); + } + } + else + { + m_options.searchString = m_pSearchEdit->GetText(); + utl::TextSearch textSearch( m_options ); + + for(auto it = m_prefBoxEntries.begin(); it != m_prefBoxEntries.end(); ++it) + { + sal_Int32 endPos, startPos = 0; + + for(size_t i = 1; i < it->ItemCount(); ++i) + { + OUString scrTxt = static_cast< SvLBoxString* >( it->GetItem(i) )->GetText(); + endPos = scrTxt.getLength(); + if( textSearch.SearchForward( scrTxt, &startPos, &endPos ) ) + { + SvTreeListEntry* pEntry = new SvTreeListEntry; + pEntry->Clone( &(*it) ) ; + m_pPrefBox->Insert( pEntry ); + break; + } + } + } + } + + if( sortMode != SortNone ) + m_pPrefBox->SortByCol(sortedCol, sortMode == SortAscending); + + m_pPrefBox->SetUpdateMode( true ); + + return 0; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cui/source/options/optaboutconfig.hxx b/cui/source/options/optaboutconfig.hxx index 4714cb2e01e5..dc19e4ae6539 100644 --- a/cui/source/options/optaboutconfig.hxx +++ b/cui/source/options/optaboutconfig.hxx @@ -12,6 +12,7 @@ #include #include +#include #include #include @@ -45,15 +46,22 @@ private: SvSimpleTableContainer* m_pPrefCtrl; PushButton* m_pResetBtn; PushButton* m_pEditBtn; + PushButton* m_pSearchBtn; + Edit* m_pSearchEdit; std::vector< boost::shared_ptr< Prop_Impl > > m_vectorOfModified; boost::scoped_ptr< SvSimpleTable > m_pPrefBox; + //for search + ::com::sun::star::util::SearchOptions m_options; + SvTreeListEntries m_prefBoxEntries; + void AddToModifiedVector( const boost::shared_ptr< Prop_Impl >& rProp ); std::vector< OUString > commaStringToSequence( const OUString& rCommaSepString ); DECL_LINK( StandardHdl_Impl, void * ); DECL_LINK( ResetBtnHdl_Impl, void * ); + DECL_LINK( SearchHdl_Impl, void* ); public: CuiAboutConfigTabPage(vcl::Window* pParent); diff --git a/cui/uiconfig/ui/aboutconfigdialog.ui b/cui/uiconfig/ui/aboutconfigdialog.ui index 6a5afd8485d6..3773c500e6d4 100644 --- a/cui/uiconfig/ui/aboutconfigdialog.ui +++ b/cui/uiconfig/ui/aboutconfigdialog.ui @@ -1,8 +1,8 @@ - + - + False 6 @@ -14,89 +14,6 @@ False vertical 12 - - - False - end - - - Edit - True - True - True - - - False - True - 1 - - - - - Reset - True - True - True - - - False - True - 2 - - - - - gtk-ok - True - True - True - True - True - True - - - False - True - 3 - - - - - gtk-cancel - True - True - True - True - - - False - True - 4 - - - - - gtk-help - True - True - True - True - - - False - True - 5 - True - - - - - False - True - end - 0 - - True @@ -108,6 +25,46 @@ True False vertical + 6 + + + True + False + 6 + + + True + True + + + True + True + 0 + + + + + _Search + True + True + True + True + True + True + + + False + True + 1 + + + + + False + True + 0 + + False @@ -125,6 +82,8 @@ 0 0 + 1 + 1 @@ -138,6 +97,8 @@ 1 0 + 1 + 1 @@ -149,6 +110,8 @@ 2 0 + 1 + 1 @@ -160,29 +123,31 @@ 3 0 + 1 + 1 False True - 0 + 1 - True - True - True - True - - - - + True + True + True + True + + + + True True - 1 + 2 @@ -194,6 +159,87 @@ 1 + + + False + end + + + Edit + True + True + True + + + False + True + 1 + + + + + Reset + True + True + True + + + False + True + 2 + + + + + gtk-ok + True + True + True + True + + + False + True + 3 + + + + + gtk-cancel + True + True + True + True + + + False + True + 4 + + + + + gtk-help + True + True + True + True + + + False + True + 5 + True + + + + + False + True + end + 2 + + -- cgit