diff options
author | Palenik Mihály <palenik.mihaly@gmail.com> | 2015-02-04 18:27:35 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2015-02-05 10:54:49 +0000 |
commit | 1485acc3e86bf6c7e32672c6d36d86e3eb5ddc9e (patch) | |
tree | c64f5182f7cc27017f9e1c4580c1da9a71a90ab1 /cui | |
parent | 47230a036fe35b9a7a7c0609232849fcbb51efcc (diff) |
Implement search funtion in Expert Configuration dialog.
Change-Id: I5a594b3d6ef84b022ce4a92a865beba735d47113
Reviewed-on: https://gerrit.libreoffice.org/14322
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'cui')
-rw-r--r-- | cui/source/options/optaboutconfig.cxx | 79 | ||||
-rw-r--r-- | cui/source/options/optaboutconfig.hxx | 8 | ||||
-rw-r--r-- | 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 <com/sun/star/container/XHierarchicalName.hpp> #include <com/sun/star/container/XHierarchicalNameAccess.hpp> #include <com/sun/star/util/XChangesBatch.hpp> +#include <com/sun/star/i18n/TransliterationModules.hpp> +#include <com/sun/star/util/SearchFlags.hpp> +#include <unotools/textsearch.hxx> #include <vector> #include <boost/shared_ptr.hpp> @@ -124,9 +127,10 @@ CuiAboutConfigTabPage::CuiAboutConfigTabPage( vcl::Window* pParent/*, const SfxI m_pPrefCtrl( get<SvSimpleTableContainer>("preferences") ), m_pResetBtn( get<PushButton>("reset") ), m_pEditBtn( get<PushButton>("edit") ), + m_pSearchBtn( get<PushButton>("searchButton") ), + m_pSearchEdit( get<Edit>("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<FixedText>("preference")->GetText()); m_pPrefBox->InsertHeaderEntry(get<FixedText>("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 <com/sun/star/container/XNameAccess.hpp> #include <com/sun/star/beans/NamedValue.hpp> +#include <com/sun/star/util/SearchOptions.hpp> #include <sfx2/tabdlg.hxx> #include <svtools/simptabl.hxx> @@ -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 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.18.3 --> +<!-- Generated with glade 3.16.1 --> <interface> <requires lib="gtk+" version="3.0"/> - <requires lib="LibreOffice" version="1.0"/> + <!-- interface-requires LibreOffice 1.0 --> <object class="GtkDialog" id="AboutConfig"> <property name="can_focus">False</property> <property name="border_width">6</property> @@ -14,89 +14,6 @@ <property name="can_focus">False</property> <property name="orientation">vertical</property> <property name="spacing">12</property> - <child internal-child="action_area"> - <object class="GtkButtonBox" id="dialog-action_area1"> - <property name="can_focus">False</property> - <property name="layout_style">end</property> - <child> - <object class="GtkButton" id="edit"> - <property name="label" translatable="yes">Edit</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">True</property> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">1</property> - </packing> - </child> - <child> - <object class="GtkButton" id="reset"> - <property name="label" translatable="yes">Reset</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">True</property> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">2</property> - </packing> - </child> - <child> - <object class="GtkButton" id="ok"> - <property name="label">gtk-ok</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="can_default">True</property> - <property name="has_default">True</property> - <property name="receives_default">True</property> - <property name="use_stock">True</property> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">3</property> - </packing> - </child> - <child> - <object class="GtkButton" id="cancel"> - <property name="label">gtk-cancel</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">True</property> - <property name="use_stock">True</property> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">4</property> - </packing> - </child> - <child> - <object class="GtkButton" id="help"> - <property name="label">gtk-help</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">True</property> - <property name="use_stock">True</property> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">5</property> - <property name="secondary">True</property> - </packing> - </child> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="pack_type">end</property> - <property name="position">0</property> - </packing> - </child> <child> <object class="GtkAlignment" id="alignment1"> <property name="visible">True</property> @@ -108,6 +25,46 @@ <property name="visible">True</property> <property name="can_focus">False</property> <property name="orientation">vertical</property> + <property name="spacing">6</property> + <child> + <object class="GtkBox" id="box2"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="spacing">6</property> + <child> + <object class="GtkEntry" id="searchEntry"> + <property name="visible">True</property> + <property name="can_focus">True</property> + </object> + <packing> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkButton" id="searchButton"> + <property name="label" translatable="yes">_Search</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="can_default">True</property> + <property name="has_default">True</property> + <property name="receives_default">True</property> + <property name="use_underline">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> <child> <object class="GtkGrid" id="grid1"> <property name="can_focus">False</property> @@ -125,6 +82,8 @@ <packing> <property name="left_attach">0</property> <property name="top_attach">0</property> + <property name="width">1</property> + <property name="height">1</property> </packing> </child> <child> @@ -138,6 +97,8 @@ <packing> <property name="left_attach">1</property> <property name="top_attach">0</property> + <property name="width">1</property> + <property name="height">1</property> </packing> </child> <child> @@ -149,6 +110,8 @@ <packing> <property name="left_attach">2</property> <property name="top_attach">0</property> + <property name="width">1</property> + <property name="height">1</property> </packing> </child> <child> @@ -160,29 +123,31 @@ <packing> <property name="left_attach">3</property> <property name="top_attach">0</property> + <property name="width">1</property> + <property name="height">1</property> </packing> </child> </object> <packing> <property name="expand">False</property> <property name="fill">True</property> - <property name="position">0</property> + <property name="position">1</property> </packing> </child> <child> <object class="svtlo-SvSimpleTableContainer" id="preferences"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="hexpand">True</property> - <property name="vexpand">True</property> - <child internal-child="selection"> - <object class="GtkTreeSelection" id="Simple Table Container-selection"/> - </child> - </object> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> + <child internal-child="selection"> + <object class="GtkTreeSelection" id="Simple Table Container-selection"/> + </child> + </object> <packing> <property name="expand">True</property> <property name="fill">True</property> - <property name="position">1</property> + <property name="position">2</property> </packing> </child> </object> @@ -194,6 +159,87 @@ <property name="position">1</property> </packing> </child> + <child internal-child="action_area"> + <object class="GtkButtonBox" id="dialog-action_area1"> + <property name="can_focus">False</property> + <property name="layout_style">end</property> + <child> + <object class="GtkButton" id="edit"> + <property name="label" translatable="yes">Edit</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + <child> + <object class="GtkButton" id="reset"> + <property name="label" translatable="yes">Reset</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">2</property> + </packing> + </child> + <child> + <object class="GtkButton" id="ok"> + <property name="label">gtk-ok</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="use_stock">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">3</property> + </packing> + </child> + <child> + <object class="GtkButton" id="cancel"> + <property name="label">gtk-cancel</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="use_stock">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">4</property> + </packing> + </child> + <child> + <object class="GtkButton" id="help"> + <property name="label">gtk-help</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="use_stock">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">5</property> + <property name="secondary">True</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="pack_type">end</property> + <property name="position">2</property> + </packing> + </child> </object> </child> <action-widgets> |