[Libreoffice-commits] core.git: sw/source sw/uiconfig

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Thu Oct 4 14:40:36 UTC 2018


 sw/source/ui/dbui/createaddresslistdialog.cxx     |    9 -
 sw/source/ui/dbui/customizeaddresslistdialog.cxx  |  142 +++++++++-------------
 sw/source/ui/dbui/customizeaddresslistdialog.hxx  |   34 ++---
 sw/uiconfig/swriter/ui/customizeaddrlistdialog.ui |   49 ++++++-
 4 files changed, 126 insertions(+), 108 deletions(-)

New commits:
commit be7ab624c1d56fc4f169e4c7d379e376653165ab
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Thu Oct 4 11:02:57 2018 +0100
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Thu Oct 4 16:40:06 2018 +0200

    weld SwCreateAddressListDialog
    
    Change-Id: I9b8fa8ff001f82904db2478a6c88419294df2855
    Reviewed-on: https://gerrit.libreoffice.org/61364
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

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
diff --git a/sw/uiconfig/swriter/ui/customizeaddrlistdialog.ui b/sw/uiconfig/swriter/ui/customizeaddrlistdialog.ui
index e21e7c0ed77e..e4dda172e8fd 100644
--- a/sw/uiconfig/swriter/ui/customizeaddrlistdialog.ui
+++ b/sw/uiconfig/swriter/ui/customizeaddrlistdialog.ui
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.18.3 -->
+<!-- Generated with glade 3.22.1 -->
 <interface domain="sw">
   <requires lib="gtk+" version="3.18"/>
   <object class="GtkImage" id="image1">
@@ -12,12 +12,26 @@
     <property name="can_focus">False</property>
     <property name="stock">gtk-go-down</property>
   </object>
+  <object class="GtkListStore" id="liststore2">
+    <columns>
+      <!-- column-name text -->
+      <column type="gchararray"/>
+      <!-- column-name id -->
+      <column type="gchararray"/>
+    </columns>
+  </object>
   <object class="GtkDialog" id="CustomizeAddrListDialog">
     <property name="can_focus">False</property>
     <property name="border_width">6</property>
     <property name="title" translatable="yes" context="customizeaddrlistdialog|CustomizeAddrListDialog">Customize Address List</property>
     <property name="resizable">False</property>
+    <property name="modal">True</property>
+    <property name="default_width">0</property>
+    <property name="default_height">0</property>
     <property name="type_hint">dialog</property>
+    <child>
+      <placeholder/>
+    </child>
     <child internal-child="vbox">
       <object class="GtkBox" id="dialog-vbox1">
         <property name="can_focus">False</property>
@@ -154,10 +168,10 @@
                   <object class="GtkLabel" id="label1">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
-                    <property name="xalign">0</property>
                     <property name="label" translatable="yes" context="customizeaddrlistdialog|label1">A_ddress list elements:</property>
                     <property name="use_underline">True</property>
-                    <property name="mnemonic_widget">treeview:border</property>
+                    <property name="mnemonic_widget">treeview</property>
+                    <property name="xalign">0</property>
                   </object>
                   <packing>
                     <property name="left_attach">0</property>
@@ -165,13 +179,36 @@
                   </packing>
                 </child>
                 <child>
-                  <object class="GtkTreeView" id="treeview:border">
+                  <object class="GtkScrolledWindow">
                     <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="treeview-selection1"/>
+                    <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="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>
                   <packing>


More information about the Libreoffice-commits mailing list