From 52f3046842ccb2a81e8eef6c744330567512e55b Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Sat, 6 Oct 2018 21:13:17 +0100 Subject: weld ListSelectionDialog MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Id2aaec88bd864167e0815ddb675c27b10331247f Reviewed-on: https://gerrit.libreoffice.org/61482 Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara --- .../source/propctrlr/formcomponenthandler.cxx | 6 +-- extensions/source/propctrlr/listselectiondlg.cxx | 60 +++++++++------------- extensions/source/propctrlr/listselectiondlg.hxx | 22 +++----- .../uiconfig/spropctrlr/ui/listselectdialog.ui | 50 ++++++++++++++++-- 4 files changed, 79 insertions(+), 59 deletions(-) (limited to 'extensions') diff --git a/extensions/source/propctrlr/formcomponenthandler.cxx b/extensions/source/propctrlr/formcomponenthandler.cxx index 5baaa7b5bbdd..f5b565884e1f 100644 --- a/extensions/source/propctrlr/formcomponenthandler.cxx +++ b/extensions/source/propctrlr/formcomponenthandler.cxx @@ -2520,18 +2520,16 @@ namespace pcr } } - bool FormComponentPropertyHandler::impl_dialogListSelection_nothrow( const OUString& _rProperty, ::osl::ClearableMutexGuard& _rClearBeforeDialog ) const { OSL_PRECOND( m_pInfoService.get(), "FormComponentPropertyHandler::impl_dialogListSelection_nothrow: no property meta data!" ); OUString sPropertyUIName( m_pInfoService->getPropertyTranslation( m_pInfoService->getPropertyId( _rProperty ) ) ); - ScopedVclPtrInstance< ListSelectionDialog > aDialog( impl_getDefaultDialogParent_nothrow(), m_xComponent, _rProperty, sPropertyUIName ); + ListSelectionDialog aDialog(impl_getDefaultDialogFrame_nothrow(), m_xComponent, _rProperty, sPropertyUIName); _rClearBeforeDialog.clear(); - return ( RET_OK == aDialog->Execute() ); + return ( RET_OK == aDialog.execute() ); } - bool FormComponentPropertyHandler::impl_dialogFilterOrSort_nothrow( bool _bFilter, OUString& _out_rSelectedClause, ::osl::ClearableMutexGuard& _rClearBeforeDialog ) const { OSL_PRECOND( Reference< XRowSet >( m_xComponent, UNO_QUERY ).is(), diff --git a/extensions/source/propctrlr/listselectiondlg.cxx b/extensions/source/propctrlr/listselectiondlg.cxx index a3f1d79d8b56..0e8becb48f9d 100644 --- a/extensions/source/propctrlr/listselectiondlg.cxx +++ b/extensions/source/propctrlr/listselectiondlg.cxx @@ -29,39 +29,31 @@ namespace pcr using namespace ::com::sun::star::uno; using namespace ::com::sun::star::beans; - ListSelectionDialog::ListSelectionDialog(vcl::Window* _pParent, const Reference< XPropertySet >& _rxListBox, + ListSelectionDialog::ListSelectionDialog(weld::Window* pParent, const Reference< XPropertySet >& _rxListBox, const OUString& _rPropertyName, const OUString& _rPropertyUIName) - : ModalDialog( _pParent, "ListSelectDialog", "modules/spropctrlr/ui/listselectdialog.ui" ) - ,m_xListBox ( _rxListBox ) - ,m_sPropertyName( _rPropertyName ) + : GenericDialogController(pParent, "modules/spropctrlr/ui/listselectdialog.ui", "ListSelectDialog") + , m_xListBox ( _rxListBox ) + , m_sPropertyName( _rPropertyName ) + , m_xFrame(m_xBuilder->weld_frame("frame")) + , m_xEntries(m_xBuilder->weld_tree_view("treeview")) { OSL_PRECOND( m_xListBox.is(), "ListSelectionDialog::ListSelectionDialog: invalid list box!" ); - get(m_pEntries, "treeview"); - Size aSize(LogicToPixel(Size(85, 97), MapMode(MapUnit::MapAppFont))); - m_pEntries->set_width_request(aSize.Width()); - m_pEntries->set_height_request(aSize.Height()); + m_xEntries->set_size_request(m_xEntries->get_approximate_digit_width() * 40, m_xEntries->get_height_rows(9)); - SetText(_rPropertyUIName); - get("frame")->set_label(_rPropertyUIName); + m_xDialog->set_title(_rPropertyUIName); + m_xFrame->set_label(_rPropertyUIName); initialize( ); } ListSelectionDialog::~ListSelectionDialog() { - disposeOnce(); } - void ListSelectionDialog::dispose() + short ListSelectionDialog::execute() { - m_pEntries.clear(); - ModalDialog::dispose(); - } - - short ListSelectionDialog::Execute() - { - short nResult = ModalDialog::Execute(); + short nResult = m_xDialog->run(); if ( RET_OK == nResult ) commitSelection(); @@ -75,14 +67,12 @@ namespace pcr if ( !m_xListBox.is() ) return; - m_pEntries->SetStyle( GetStyle() | WB_SIMPLEMODE ); - try { // initialize the multi-selection flag bool bMultiSelection = false; OSL_VERIFY( m_xListBox->getPropertyValue( PROPERTY_MULTISELECTION ) >>= bMultiSelection ); - m_pEntries->EnableMultiSelection( bMultiSelection ); + m_xEntries->set_selection_mode(bMultiSelection); // fill the list box with all entries Sequence< OUString > aListEntries; @@ -100,7 +90,6 @@ namespace pcr } } - void ListSelectionDialog::commitSelection() { if ( !m_xListBox.is() ) @@ -119,29 +108,28 @@ namespace pcr } } - void ListSelectionDialog::fillEntryList( const Sequence< OUString >& _rListEntries ) { - m_pEntries->Clear(); - for ( auto const & entry : _rListEntries ) - m_pEntries->InsertEntry( entry ); + m_xEntries->freeze(); + m_xEntries->clear(); + for (auto const & entry : _rListEntries) + m_xEntries->append_text(entry); + m_xEntries->thaw(); } - void ListSelectionDialog::collectSelection( std::vector< sal_Int16 >& /* [out] */ _rSelection ) { - const sal_Int32 nSelectedCount = m_pEntries->GetSelectedEntryCount( ); - _rSelection.resize( nSelectedCount ); - for ( sal_Int32 selected = 0; selected < nSelectedCount; ++selected ) - _rSelection[selected] = static_cast< sal_Int16 >( m_pEntries->GetSelectedEntryPos( selected ) ); + auto aSelection = m_xEntries->get_selected_rows(); + _rSelection.resize(aSelection.size()); + for (auto row : aSelection) + _rSelection.push_back(row); } - void ListSelectionDialog::selectEntries( const Sequence< sal_Int16 >& /* [in ] */ _rSelection ) { - m_pEntries->SetNoSelection(); - for ( auto const & selection : _rSelection ) - m_pEntries->SelectEntryPos( selection ); + m_xEntries->unselect_all(); + for (auto const & selection : _rSelection) + m_xEntries->select(selection); } diff --git a/extensions/source/propctrlr/listselectiondlg.hxx b/extensions/source/propctrlr/listselectiondlg.hxx index 1d2d9b08b0cb..e8b493132998 100644 --- a/extensions/source/propctrlr/listselectiondlg.hxx +++ b/extensions/source/propctrlr/listselectiondlg.hxx @@ -20,35 +20,30 @@ #ifndef INCLUDED_EXTENSIONS_SOURCE_PROPCTRLR_LISTSELECTIONDLG_HXX #define INCLUDED_EXTENSIONS_SOURCE_PROPCTRLR_LISTSELECTIONDLG_HXX -#include -#include -#include +#include #include namespace pcr { - class ListSelectionDialog : public ModalDialog + class ListSelectionDialog : public weld::GenericDialogController { private: - VclPtr m_pEntries; - - css::uno::Reference< css::beans::XPropertySet > - m_xListBox; - OUString m_sPropertyName; + css::uno::Reference m_xListBox; + OUString m_sPropertyName; + std::unique_ptr m_xFrame; + std::unique_ptr m_xEntries; public: ListSelectionDialog( - vcl::Window* _pParent, + weld::Window* _pParent, const css::uno::Reference< css::beans::XPropertySet >& _rxListBox, const OUString& _rPropertyName, const OUString& _rPropertyUIName ); virtual ~ListSelectionDialog() override; - virtual void dispose() override; - // Dialog overridables - virtual short Execute() override; + short execute(); private: void initialize( ); @@ -60,7 +55,6 @@ namespace pcr void collectSelection( std::vector< sal_Int16 >& /* [out] */ _rSelection ); }; - } // namespacepcr diff --git a/extensions/uiconfig/spropctrlr/ui/listselectdialog.ui b/extensions/uiconfig/spropctrlr/ui/listselectdialog.ui index 28683b62addd..19a3740fca47 100644 --- a/extensions/uiconfig/spropctrlr/ui/listselectdialog.ui +++ b/extensions/uiconfig/spropctrlr/ui/listselectdialog.ui @@ -1,11 +1,25 @@ - + + + + + + + + + False 6 + True + 0 + 0 normal + + + False @@ -85,11 +99,37 @@ 6 12 - + True - True - - + False + True + True + in + + + True + True + True + True + liststore2 + False + False + 0 + False + + + + + + + + + 0 + + + + + -- cgit