summaryrefslogtreecommitdiff
path: root/extensions
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2018-10-06 21:13:17 +0100
committerCaolán McNamara <caolanm@redhat.com>2018-10-07 19:44:31 +0200
commit52f3046842ccb2a81e8eef6c744330567512e55b (patch)
tree13acf3c651362ebadd635d60e26477e0c8f02003 /extensions
parent6846f2f204dbaaf9f32c2f717eb39d3a01711087 (diff)
weld ListSelectionDialog
Change-Id: Id2aaec88bd864167e0815ddb675c27b10331247f Reviewed-on: https://gerrit.libreoffice.org/61482 Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'extensions')
-rw-r--r--extensions/source/propctrlr/formcomponenthandler.cxx6
-rw-r--r--extensions/source/propctrlr/listselectiondlg.cxx60
-rw-r--r--extensions/source/propctrlr/listselectiondlg.hxx22
-rw-r--r--extensions/uiconfig/spropctrlr/ui/listselectdialog.ui50
4 files changed, 79 insertions, 59 deletions
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<VclFrame>("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 <vcl/dialog.hxx>
-#include <vcl/layout.hxx>
-#include <vcl/lstbox.hxx>
+#include <vcl/weld.hxx>
#include <com/sun/star/beans/XPropertySet.hpp>
namespace pcr
{
- class ListSelectionDialog : public ModalDialog
+ class ListSelectionDialog : public weld::GenericDialogController
{
private:
- VclPtr<ListBox> m_pEntries;
-
- css::uno::Reference< css::beans::XPropertySet >
- m_xListBox;
- OUString m_sPropertyName;
+ css::uno::Reference<css::beans::XPropertySet> m_xListBox;
+ OUString m_sPropertyName;
+ std::unique_ptr<weld::Frame> m_xFrame;
+ std::unique_ptr<weld::TreeView> 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 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.18.3 -->
+<!-- Generated with glade 3.22.1 -->
<interface domain="pcr">
<requires lib="gtk+" version="3.18"/>
+ <object class="GtkListStore" id="liststore2">
+ <columns>
+ <!-- column-name text -->
+ <column type="gchararray"/>
+ <!-- column-name id -->
+ <column type="gchararray"/>
+ </columns>
+ </object>
<object class="GtkDialog" id="ListSelectDialog">
<property name="can_focus">False</property>
<property name="border_width">6</property>
+ <property name="modal">True</property>
+ <property name="default_width">0</property>
+ <property name="default_height">0</property>
<property name="type_hint">normal</property>
+ <child>
+ <placeholder/>
+ </child>
<child internal-child="vbox">
<object class="GtkBox" id="dialog-vbox1">
<property name="can_focus">False</property>
@@ -85,11 +99,37 @@
<property name="top_padding">6</property>
<property name="left_padding">12</property>
<child>
- <object class="GtkTreeView" id="treeview:border">
+ <object class="GtkScrolledWindow">
<property name="visible">True</property>
- <property name="can_focus">True</property>
- <child internal-child="selection">
- <object class="GtkTreeSelection" id="treeview-selection2"/>
+ <property name="can_focus">False</property>
+ <property name="hexpand">True</property>
+ <property name="vexpand">True</property>
+ <property name="shadow_type">in</property>
+ <child>
+ <object class="GtkTreeView" id="treeview">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="hexpand">True</property>
+ <property name="vexpand">True</property>
+ <property name="model">liststore2</property>
+ <property name="headers_visible">False</property>
+ <property name="headers_clickable">False</property>
+ <property name="search_column">0</property>
+ <property name="show_expanders">False</property>
+ <child internal-child="selection">
+ <object class="GtkTreeSelection" id="treeview-selection2"/>
+ </child>
+ <child>
+ <object class="GtkTreeViewColumn" id="treeviewcolumn2">
+ <child>
+ <object class="GtkCellRendererText" id="cellrenderertext2"/>
+ <attributes>
+ <attribute name="text">0</attribute>
+ </attributes>
+ </child>
+ </object>
+ </child>
+ </object>
</child>
</object>
</child>