sw/inc/strings.hrc | 1 sw/source/ui/dbui/addresslistdialog.cxx | 31 ++++++++++++++++++++++++++ sw/source/ui/dbui/addresslistdialog.hxx | 2 + sw/uiconfig/swriter/ui/selectaddressdialog.ui | 23 +++++++++++++++---- 4 files changed, 52 insertions(+), 5 deletions(-)
New commits: commit 007fd868e398f51363a24aa24c244cb8096e0579 Author: Gabor Kelemen <kelemen.gab...@nisz.hu> AuthorDate: Wed Jul 24 01:22:47 2019 +0200 Commit: László Németh <nem...@numbertext.org> CommitDate: Mon Aug 5 10:38:56 2019 +0200 tdf#113699 Add Remove button to Select Address List dialog of MM Wizard To make it easier to remove no longer needed data base connections But only enable it when the list has items to remove Change-Id: I288ec2e4d95ea570c2b42e0024c8e9bb4207b397 Reviewed-on: https://gerrit.libreoffice.org/76209 Tested-by: Jenkins Reviewed-by: Heiko Tietze <heiko.tie...@documentfoundation.org> Tested-by: Heiko Tietze <heiko.tie...@documentfoundation.org> diff --git a/sw/inc/strings.hrc b/sw/inc/strings.hrc index 660b87da3111..1164c8daeb16 100644 --- a/sw/inc/strings.hrc +++ b/sw/inc/strings.hrc @@ -807,6 +807,7 @@ #define ST_SALUTATIONELEMENT NC_("ST_SALUTATIONELEMENT", "Salutation elements") #define ST_MATCHESTO NC_("ST_MATCHESTO", "Matches to field:") #define ST_PREVIEW NC_("ST_PREVIEW", "Preview") +#define ST_DELETE_CONFIRM NC_("ST_DELETE_CONFIRM", "Do you want to delete this registered data source?") #define STR_NOTASSIGNED NC_("STR_NOTASSIGNED", " not yet matched ") #define STR_FILTER_ALL NC_("STR_FILTER_ALL", "All files") diff --git a/sw/source/ui/dbui/addresslistdialog.cxx b/sw/source/ui/dbui/addresslistdialog.cxx index f1d0f49a555d..12818a36e2a5 100644 --- a/sw/source/ui/dbui/addresslistdialog.cxx +++ b/sw/source/ui/dbui/addresslistdialog.cxx @@ -52,6 +52,7 @@ #include <unotools/pathoptions.hxx> #include <svl/urihelper.hxx> #include <dbui.hrc> +#include <strings.hrc> #include <view.hxx> #include <unomid.h> @@ -126,6 +127,7 @@ SwAddressListDialog::SwAddressListDialog(SwMailMergeAddressBlockPage* pParent) , m_xConnecting(m_xBuilder->weld_label("connecting")) , m_xListLB(m_xBuilder->weld_tree_view("sources")) , m_xLoadListPB(m_xBuilder->weld_button("add")) + , m_xRemovePB(m_xBuilder->weld_button("remove")) , m_xCreateListPB(m_xBuilder->weld_button("create")) , m_xFilterPB(m_xBuilder->weld_button("filter")) , m_xEditPB(m_xBuilder->weld_button("edit")) @@ -141,6 +143,7 @@ SwAddressListDialog::SwAddressListDialog(SwMailMergeAddressBlockPage* pParent) m_xDescriptionFI->set_label(sTemp); m_xFilterPB->connect_clicked( LINK( this, SwAddressListDialog, FilterHdl_Impl )); m_xLoadListPB->connect_clicked( LINK( this, SwAddressListDialog, LoadHdl_Impl )); + m_xRemovePB->connect_clicked( LINK(this, SwAddressListDialog, RemoveHdl_Impl )); m_xCreateListPB->connect_clicked( LINK( this, SwAddressListDialog,CreateHdl_Impl )); m_xEditPB->connect_clicked(LINK( this, SwAddressListDialog, EditHdl_Impl)); m_xTablePB->connect_clicked(LINK( this, SwAddressListDialog, TableSelectHdl_Impl)); @@ -207,6 +210,7 @@ SwAddressListDialog::SwAddressListDialog(SwMailMergeAddressBlockPage* pParent) m_xOK->set_sensitive(m_xListLB->n_children() > 0 && bEnableOK); m_xEditPB->set_sensitive(bEnableEdit); + m_xRemovePB->set_sensitive(m_xListLB->n_children() > 0); m_xListLB->connect_changed(LINK(this, SwAddressListDialog, ListBoxSelectHdl_Impl)); TableSelectHdl(nullptr); } @@ -282,9 +286,35 @@ IMPL_LINK_NOARG(SwAddressListDialog, LoadHdl_Impl, weld::Button&, void) m_xListLB->set_id(*m_xIter, OUString::number(reinterpret_cast<sal_Int64>(pUserData))); m_xListLB->select(*m_xIter); ListBoxSelectHdl_Impl(*m_xListLB); + m_xRemovePB->set_sensitive(true); } } +IMPL_LINK_NOARG(SwAddressListDialog, RemoveHdl_Impl, weld::Button&, void) +{ + int nEntry = m_xListLB->get_selected_index(); + if (nEntry != -1) + { + std::unique_ptr<weld::MessageDialog> xQuery(Application::CreateMessageDialog(getDialog(), + VclMessageType::Question, VclButtonsType::YesNo, SwResId(ST_DELETE_CONFIRM))); + if (xQuery->run() == RET_YES) + { // Remove data source connection + SwDBManager::RevokeDataSource(m_xListLB->get_selected_text()); + // Remove item from the list + m_xListLB->remove(nEntry); + // If this was the last item, disable the Remove & Edit buttons and enable Create + if (m_xListLB->n_children() < 1 ) + { + m_xRemovePB->set_sensitive(false); + m_xEditPB->set_sensitive(false); + m_xCreateListPB->set_sensitive(true); + } + } + } + + +} + IMPL_LINK_NOARG(SwAddressListDialog, CreateHdl_Impl, weld::Button&, void) { SwCreateAddressListDialog aDlg(m_xDialog.get(), /*sInputURL*/OUString(), m_xAddressPage->GetWizard()->GetConfigItem()); @@ -351,6 +381,7 @@ IMPL_LINK_NOARG(SwAddressListDialog, CreateHdl_Impl, weld::Button&, void) m_xListLB->select(*m_xIter); ListBoxSelectHdl_Impl(*m_xListLB); m_xCreateListPB->set_sensitive(false); + m_xRemovePB->set_sensitive(true); } catch (const Exception&) { diff --git a/sw/source/ui/dbui/addresslistdialog.hxx b/sw/source/ui/dbui/addresslistdialog.hxx index aba1d8db8104..167cf6ad638a 100644 --- a/sw/source/ui/dbui/addresslistdialog.hxx +++ b/sw/source/ui/dbui/addresslistdialog.hxx @@ -59,6 +59,7 @@ class SwAddressListDialog : public SfxDialogController std::unique_ptr<weld::Label> m_xConnecting; std::unique_ptr<weld::TreeView> m_xListLB; std::unique_ptr<weld::Button> m_xLoadListPB; + std::unique_ptr<weld::Button> m_xRemovePB; std::unique_ptr<weld::Button> m_xCreateListPB; std::unique_ptr<weld::Button> m_xFilterPB; std::unique_ptr<weld::Button> m_xEditPB; @@ -71,6 +72,7 @@ class SwAddressListDialog : public SfxDialogController DECL_LINK(FilterHdl_Impl, weld::Button&, void); DECL_LINK(LoadHdl_Impl, weld::Button&, void); DECL_LINK(CreateHdl_Impl, weld::Button&, void); + DECL_LINK(RemoveHdl_Impl, weld::Button&, void); DECL_LINK(ListBoxSelectHdl_Impl, weld::TreeView&, void); DECL_LINK(EditHdl_Impl, weld::Button&, void); DECL_LINK(TableSelectHdl_Impl, weld::Button&, void); diff --git a/sw/uiconfig/swriter/ui/selectaddressdialog.ui b/sw/uiconfig/swriter/ui/selectaddressdialog.ui index fee262987398..e8151459c9c6 100644 --- a/sw/uiconfig/swriter/ui/selectaddressdialog.ui +++ b/sw/uiconfig/swriter/ui/selectaddressdialog.ui @@ -132,7 +132,6 @@ <property name="orientation">vertical</property> <property name="spacing">6</property> <property name="homogeneous">True</property> - <property name="layout_style">start</property> <child> <object class="GtkButton" id="add"> <property name="label" translatable="yes" context="selectaddressdialog|add">_Add...</property> @@ -148,6 +147,20 @@ </packing> </child> <child> + <object class="GtkButton" id="remove"> + <property name="label" translatable="yes" context="selectaddressdialog|remove">_Remove</property> + <property name="visible">True</property> + <property name="can_focus">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> + <child> <object class="GtkButton" id="create"> <property name="label" translatable="yes" context="selectaddressdialog|create">_Create...</property> <property name="visible">True</property> @@ -158,7 +171,7 @@ <packing> <property name="expand">False</property> <property name="fill">True</property> - <property name="position">1</property> + <property name="position">2</property> </packing> </child> <child> @@ -172,7 +185,7 @@ <packing> <property name="expand">False</property> <property name="fill">True</property> - <property name="position">2</property> + <property name="position">3</property> </packing> </child> <child> @@ -186,7 +199,7 @@ <packing> <property name="expand">False</property> <property name="fill">True</property> - <property name="position">3</property> + <property name="position">4</property> </packing> </child> <child> @@ -200,7 +213,7 @@ <packing> <property name="expand">False</property> <property name="fill">True</property> - <property name="position">4</property> + <property name="position">5</property> </packing> </child> </object> _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits