summaryrefslogtreecommitdiff
path: root/sw/source
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2018-10-04 11:02:57 +0100
committerCaolán McNamara <caolanm@redhat.com>2018-10-04 16:40:06 +0200
commitbe7ab624c1d56fc4f169e4c7d379e376653165ab (patch)
treea1573d48a32d09289f652ec6dcc12c6ac2a01562 /sw/source
parentc3c88d6bbe4109fcf1a6d53e947faec775c96e42 (diff)
weld SwCreateAddressListDialog
Change-Id: I9b8fa8ff001f82904db2478a6c88419294df2855 Reviewed-on: https://gerrit.libreoffice.org/61364 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sw/source')
-rw-r--r--sw/source/ui/dbui/createaddresslistdialog.cxx9
-rw-r--r--sw/source/ui/dbui/customizeaddresslistdialog.cxx142
-rw-r--r--sw/source/ui/dbui/customizeaddresslistdialog.hxx34
3 files changed, 83 insertions, 102 deletions
diff --git a/sw/source/ui/dbui/createaddresslistdialog.cxx b/sw/source/ui/dbui/createaddresslistdialog.cxx
index 6c227ea5273c..736c9adc0321 100644
--- a/sw/source/ui/dbui/createaddresslistdialog.cxx
+++ b/sw/source/ui/dbui/createaddresslistdialog.cxx
@@ -564,16 +564,15 @@ IMPL_LINK_NOARG(SwCreateAddressListDialog, FindHdl_Impl, Button*, void)
m_xFindDlg->show(!m_xFindDlg->get_visible());
}
-IMPL_LINK(SwCreateAddressListDialog, CustomizeHdl_Impl, Button*, pButton, void)
+IMPL_LINK_NOARG(SwCreateAddressListDialog, CustomizeHdl_Impl, Button*, void)
{
- VclPtrInstance< SwCustomizeAddressListDialog > pDlg(pButton, *m_pCSVData);
- if(RET_OK == pDlg->Execute())
+ SwCustomizeAddressListDialog aDlg(GetFrameWeld(), *m_pCSVData);
+ if (aDlg.run() == RET_OK)
{
- m_pCSVData = pDlg->ReleaseNewData();
+ m_pCSVData = aDlg.ReleaseNewData();
m_pAddressControl->SetData(*m_pCSVData);
m_pAddressControl->SetCurrentDataSet(m_pAddressControl->GetCurrentDataSet());
}
- pDlg.reset();
//update find dialog
if (m_xFindDlg)
diff --git a/sw/source/ui/dbui/customizeaddresslistdialog.cxx b/sw/source/ui/dbui/customizeaddresslistdialog.cxx
index 3c466a415487..ee0ad8e15c0e 100644
--- a/sw/source/ui/dbui/customizeaddresslistdialog.cxx
+++ b/sw/source/ui/dbui/customizeaddresslistdialog.cxx
@@ -24,75 +24,62 @@
#include <dbui.hrc>
SwCustomizeAddressListDialog::SwCustomizeAddressListDialog(
- vcl::Window* pParent, const SwCSVData& rOldData)
- : SfxModalDialog(pParent, "CustomizeAddrListDialog",
- "modules/swriter/ui/customizeaddrlistdialog.ui")
- , m_pNewData( new SwCSVData(rOldData))
+ weld::Window* pParent, const SwCSVData& rOldData)
+ : SfxDialogController(pParent, "modules/swriter/ui/customizeaddrlistdialog.ui",
+ "CustomizeAddrListDialog")
+ , m_xNewData(new SwCSVData(rOldData))
+ , m_xFieldsLB(m_xBuilder->weld_tree_view("treeview"))
+ , m_xAddPB(m_xBuilder->weld_button("add"))
+ , m_xDeletePB(m_xBuilder->weld_button("delete"))
+ , m_xRenamePB(m_xBuilder->weld_button("rename"))
+ , m_xUpPB(m_xBuilder->weld_button("up"))
+ , m_xDownPB(m_xBuilder->weld_button("down"))
{
- get(m_pFieldsLB, "treeview");
- m_pFieldsLB->SetDropDownLineCount(14);
- get(m_pAddPB, "add");
- get(m_pDeletePB, "delete");
- get(m_pRenamePB, "rename");
- get(m_pUpPB, "up");
- get(m_pDownPB, "down");
-
- m_pFieldsLB->SetSelectHdl(LINK(this, SwCustomizeAddressListDialog, ListBoxSelectHdl_Impl));
- Link<Button*,void> aAddRenameLk = LINK(this, SwCustomizeAddressListDialog, AddRenameHdl_Impl );
- m_pAddPB->SetClickHdl(aAddRenameLk);
- m_pRenamePB->SetClickHdl(aAddRenameLk);
- m_pDeletePB->SetClickHdl(LINK(this, SwCustomizeAddressListDialog, DeleteHdl_Impl ));
- Link<Button*,void> aUpDownLk = LINK(this, SwCustomizeAddressListDialog, UpDownHdl_Impl);
- m_pUpPB->SetClickHdl(aUpDownLk);
- m_pDownPB->SetClickHdl(aUpDownLk);
+ m_xFieldsLB->set_size_request(-1, m_xFieldsLB->get_height_rows(14));
+
+ m_xFieldsLB->connect_changed(LINK(this, SwCustomizeAddressListDialog, ListBoxSelectHdl_Impl));
+ Link<weld::Button&,void> aAddRenameLk = LINK(this, SwCustomizeAddressListDialog, AddRenameHdl_Impl );
+ m_xAddPB->connect_clicked(aAddRenameLk);
+ m_xRenamePB->connect_clicked(aAddRenameLk);
+ m_xDeletePB->connect_clicked(LINK(this, SwCustomizeAddressListDialog, DeleteHdl_Impl ));
+ Link<weld::Button&,void> aUpDownLk = LINK(this, SwCustomizeAddressListDialog, UpDownHdl_Impl);
+ m_xUpPB->connect_clicked(aUpDownLk);
+ m_xDownPB->connect_clicked(aUpDownLk);
std::vector< OUString >::iterator aHeaderIter;
- for(aHeaderIter = m_pNewData->aDBColumnHeaders.begin();
- aHeaderIter != m_pNewData->aDBColumnHeaders.end(); ++aHeaderIter)
- m_pFieldsLB->InsertEntry(*aHeaderIter);
+ for(aHeaderIter = m_xNewData->aDBColumnHeaders.begin();
+ aHeaderIter != m_xNewData->aDBColumnHeaders.end(); ++aHeaderIter)
+ m_xFieldsLB->append_text(*aHeaderIter);
- m_pFieldsLB->SelectEntryPos(0);
+ m_xFieldsLB->select(0);
UpdateButtons();
}
SwCustomizeAddressListDialog::~SwCustomizeAddressListDialog()
{
- disposeOnce();
-}
-
-void SwCustomizeAddressListDialog::dispose()
-{
- m_pFieldsLB.clear();
- m_pAddPB.clear();
- m_pDeletePB.clear();
- m_pRenamePB.clear();
- m_pUpPB.clear();
- m_pDownPB.clear();
- SfxModalDialog::dispose();
}
-
-IMPL_LINK_NOARG(SwCustomizeAddressListDialog, ListBoxSelectHdl_Impl, ListBox&, void)
+IMPL_LINK_NOARG(SwCustomizeAddressListDialog, ListBoxSelectHdl_Impl, weld::TreeView&, void)
{
UpdateButtons();
}
-IMPL_LINK(SwCustomizeAddressListDialog, AddRenameHdl_Impl, Button*, pButton, void)
+IMPL_LINK(SwCustomizeAddressListDialog, AddRenameHdl_Impl, weld::Button&, rButton, void)
{
- bool bRename = pButton == m_pRenamePB;
- sal_Int32 nPos = m_pFieldsLB->GetSelectedEntryPos();
- if(nPos == LISTBOX_ENTRY_NOTFOUND)
+ bool bRename = &rButton == m_xRenamePB.get();
+ auto nPos = m_xFieldsLB->get_selected_index();
+ if (nPos == -1)
nPos = 0;
std::unique_ptr<SwAddRenameEntryDialog> xDlg;
if (bRename)
- xDlg.reset(new SwRenameEntryDialog(GetFrameWeld(), m_pNewData->aDBColumnHeaders));
+ xDlg.reset(new SwRenameEntryDialog(m_xDialog.get(), m_xNewData->aDBColumnHeaders));
else
- xDlg.reset(new SwAddEntryDialog(GetFrameWeld(), m_pNewData->aDBColumnHeaders));
+ xDlg.reset(new SwAddEntryDialog(m_xDialog.get(), m_xNewData->aDBColumnHeaders));
if (bRename)
{
- OUString aTemp = m_pFieldsLB->GetEntry(nPos);
+ OUString aTemp = m_xFieldsLB->get_text(nPos);
xDlg->SetFieldName(aTemp);
}
if (xDlg->run() == RET_OK)
@@ -100,62 +87,62 @@ IMPL_LINK(SwCustomizeAddressListDialog, AddRenameHdl_Impl, Button*, pButton, voi
OUString sNew = xDlg->GetFieldName();
if(bRename)
{
- m_pNewData->aDBColumnHeaders[nPos] = sNew;
- m_pFieldsLB->RemoveEntry(nPos);
+ m_xNewData->aDBColumnHeaders[nPos] = sNew;
+ m_xFieldsLB->remove(nPos);
}
else
{
- if ( m_pFieldsLB->GetSelectedEntryPos() != LISTBOX_ENTRY_NOTFOUND )
+ if (m_xFieldsLB->get_selected_index() != -1)
++nPos; // append the new entry behind the selected
//add the new column
- m_pNewData->aDBColumnHeaders.insert(m_pNewData->aDBColumnHeaders.begin() + nPos, sNew);
+ m_xNewData->aDBColumnHeaders.insert(m_xNewData->aDBColumnHeaders.begin() + nPos, sNew);
//add a new entry into all data arrays
std::vector< std::vector< OUString > >::iterator aDataIter;
- for( aDataIter = m_pNewData->aDBData.begin(); aDataIter != m_pNewData->aDBData.end(); ++aDataIter)
+ for( aDataIter = m_xNewData->aDBData.begin(); aDataIter != m_xNewData->aDBData.end(); ++aDataIter)
aDataIter->insert(aDataIter->begin() + nPos, OUString());
}
- m_pFieldsLB->InsertEntry(sNew, nPos);
- m_pFieldsLB->SelectEntryPos(nPos);
+ m_xFieldsLB->insert_text(sNew, nPos);
+ m_xFieldsLB->select(nPos);
}
UpdateButtons();
}
-IMPL_LINK_NOARG(SwCustomizeAddressListDialog, DeleteHdl_Impl, Button*, void)
+IMPL_LINK_NOARG(SwCustomizeAddressListDialog, DeleteHdl_Impl, weld::Button&, void)
{
- sal_Int32 nPos = m_pFieldsLB->GetSelectedEntryPos();
- m_pFieldsLB->RemoveEntry(m_pFieldsLB->GetSelectedEntryPos());
- m_pFieldsLB->SelectEntryPos(nPos > m_pFieldsLB->GetEntryCount() - 1 ? nPos - 1 : nPos);
+ auto nPos = m_xFieldsLB->get_selected_index();
+ m_xFieldsLB->remove(nPos);
+ m_xFieldsLB->select(nPos > m_xFieldsLB->n_children() - 1 ? nPos - 1 : nPos);
//remove the column
- m_pNewData->aDBColumnHeaders.erase(m_pNewData->aDBColumnHeaders.begin() + nPos);
+ m_xNewData->aDBColumnHeaders.erase(m_xNewData->aDBColumnHeaders.begin() + nPos);
//remove the data
std::vector< std::vector< OUString > >::iterator aDataIter;
- for( aDataIter = m_pNewData->aDBData.begin(); aDataIter != m_pNewData->aDBData.end(); ++aDataIter)
+ for( aDataIter = m_xNewData->aDBData.begin(); aDataIter != m_xNewData->aDBData.end(); ++aDataIter)
aDataIter->erase(aDataIter->begin() + nPos);
UpdateButtons();
}
-IMPL_LINK(SwCustomizeAddressListDialog, UpDownHdl_Impl, Button*, pButton, void)
+IMPL_LINK(SwCustomizeAddressListDialog, UpDownHdl_Impl, weld::Button&, rButton, void)
{
- sal_Int32 nPos;
- sal_Int32 nOldPos = nPos = m_pFieldsLB->GetSelectedEntryPos();
- OUString aTemp = m_pFieldsLB->GetEntry(nPos);
- m_pFieldsLB->RemoveEntry( nPos );
- if(pButton == m_pUpPB)
+ auto nPos = m_xFieldsLB->get_selected_index();
+ auto nOldPos = nPos;
+ OUString aTemp = m_xFieldsLB->get_text(nPos);
+ m_xFieldsLB->remove(nPos);
+ if (&rButton == m_xUpPB.get())
--nPos;
else
++nPos;
- m_pFieldsLB->InsertEntry(aTemp, nPos);
- m_pFieldsLB->SelectEntryPos(nPos);
- //align m_pNewData
- OUString sHeader = m_pNewData->aDBColumnHeaders[nOldPos];
- m_pNewData->aDBColumnHeaders.erase(m_pNewData->aDBColumnHeaders.begin() + nOldPos);
- m_pNewData->aDBColumnHeaders.insert(m_pNewData->aDBColumnHeaders.begin() + nPos, sHeader);
+ m_xFieldsLB->insert_text(aTemp, nPos);
+ m_xFieldsLB->select(nPos);
+ //align m_xNewData
+ OUString sHeader = m_xNewData->aDBColumnHeaders[nOldPos];
+ m_xNewData->aDBColumnHeaders.erase(m_xNewData->aDBColumnHeaders.begin() + nOldPos);
+ m_xNewData->aDBColumnHeaders.insert(m_xNewData->aDBColumnHeaders.begin() + nPos, sHeader);
std::vector< std::vector< OUString > >::iterator aDataIter;
- for( aDataIter = m_pNewData->aDBData.begin(); aDataIter != m_pNewData->aDBData.end(); ++aDataIter)
+ for( aDataIter = m_xNewData->aDBData.begin(); aDataIter != m_xNewData->aDBData.end(); ++aDataIter)
{
OUString sData = (*aDataIter)[nOldPos];
aDataIter->erase(aDataIter->begin() + nOldPos);
@@ -167,15 +154,14 @@ IMPL_LINK(SwCustomizeAddressListDialog, UpDownHdl_Impl, Button*, pButton, void)
void SwCustomizeAddressListDialog::UpdateButtons()
{
- sal_Int32 nPos = m_pFieldsLB->GetSelectedEntryPos();
- sal_Int32 nEntries = m_pFieldsLB->GetEntryCount();
- m_pUpPB->Enable(nPos > 0 && nEntries > 0);
- m_pDownPB->Enable(nPos < nEntries -1);
- m_pDeletePB->Enable(nEntries > 0);
- m_pRenamePB->Enable(nEntries > 0);
+ auto nPos = m_xFieldsLB->get_selected_index();
+ auto nEntries = m_xFieldsLB->n_children();
+ m_xUpPB->set_sensitive(nPos > 0 && nEntries > 0);
+ m_xDownPB->set_sensitive(nPos < nEntries -1);
+ m_xDeletePB->set_sensitive(nEntries > 0);
+ m_xRenamePB->set_sensitive(nEntries > 0);
}
-
SwAddRenameEntryDialog::SwAddRenameEntryDialog(
weld::Window* pParent, const OUString& rUIXMLDescription, const OString& rID,
const std::vector< OUString >& rCSVHeader)
diff --git a/sw/source/ui/dbui/customizeaddresslistdialog.hxx b/sw/source/ui/dbui/customizeaddresslistdialog.hxx
index e5e2fdb4fae8..7df623622550 100644
--- a/sw/source/ui/dbui/customizeaddresslistdialog.hxx
+++ b/sw/source/ui/dbui/customizeaddresslistdialog.hxx
@@ -26,31 +26,27 @@
struct SwCSVData;
-class SwCustomizeAddressListDialog : public SfxModalDialog
+class SwCustomizeAddressListDialog : public SfxDialogController
{
- VclPtr<ListBox> m_pFieldsLB;
-
- VclPtr<PushButton> m_pAddPB;
- VclPtr<PushButton> m_pDeletePB;
- VclPtr<PushButton> m_pRenamePB;
-
- VclPtr<PushButton> m_pUpPB;
- VclPtr<PushButton> m_pDownPB;
-
- std::unique_ptr<SwCSVData> m_pNewData;
-
- DECL_LINK(AddRenameHdl_Impl, Button*, void);
- DECL_LINK(DeleteHdl_Impl, Button*, void);
- DECL_LINK(UpDownHdl_Impl, Button*, void);
- DECL_LINK(ListBoxSelectHdl_Impl, ListBox&, void);
+ std::unique_ptr<SwCSVData> m_xNewData;
+ std::unique_ptr<weld::TreeView> m_xFieldsLB;
+ std::unique_ptr<weld::Button> m_xAddPB;
+ std::unique_ptr<weld::Button> m_xDeletePB;
+ std::unique_ptr<weld::Button> m_xRenamePB;
+ std::unique_ptr<weld::Button> m_xUpPB;
+ std::unique_ptr<weld::Button> m_xDownPB;
+
+ DECL_LINK(AddRenameHdl_Impl, weld::Button&, void);
+ DECL_LINK(DeleteHdl_Impl, weld::Button&, void);
+ DECL_LINK(UpDownHdl_Impl, weld::Button&, void);
+ DECL_LINK(ListBoxSelectHdl_Impl, weld::TreeView&, void);
void UpdateButtons();
public:
- SwCustomizeAddressListDialog(vcl::Window* pParent, const SwCSVData& rOldData);
+ SwCustomizeAddressListDialog(weld::Window* pParent, const SwCSVData& rOldData);
virtual ~SwCustomizeAddressListDialog() override;
- virtual void dispose() override;
- std::unique_ptr<SwCSVData> ReleaseNewData() { return std::move(m_pNewData);}
+ std::unique_ptr<SwCSVData> ReleaseNewData() { return std::move(m_xNewData);}
};
class SwAddRenameEntryDialog : public SfxDialogController