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

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Sun Sep 22 16:06:15 UTC 2019


 dbaccess/source/ui/control/TableGrantCtrl.cxx |    4 -
 dbaccess/source/ui/dlg/UserAdmin.cxx          |   90 ++++++++++++--------------
 dbaccess/source/ui/dlg/UserAdmin.hxx          |   21 +++---
 dbaccess/source/ui/inc/TableGrantCtrl.hxx     |    3 
 dbaccess/uiconfig/ui/useradminpage.ui         |   17 +++-
 5 files changed, 70 insertions(+), 65 deletions(-)

New commits:
commit b27327cf7c77a79e045321f8464a674c8ce658d0
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Sat Sep 21 20:37:33 2019 +0100
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Sun Sep 22 18:05:33 2019 +0200

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

diff --git a/dbaccess/source/ui/control/TableGrantCtrl.cxx b/dbaccess/source/ui/control/TableGrantCtrl.cxx
index 7983d64b3c09..8ed237c98341 100644
--- a/dbaccess/source/ui/control/TableGrantCtrl.cxx
+++ b/dbaccess/source/ui/control/TableGrantCtrl.cxx
@@ -49,8 +49,8 @@ const sal_uInt16 COL_DROP       = 8;
 
 
 // OTableGrantControl
-OTableGrantControl::OTableGrantControl( vcl::Window* pParent, WinBits nBits)
-    :EditBrowseBox( pParent, EditBrowseBoxFlags::SMART_TAB_TRAVEL | EditBrowseBoxFlags::NO_HANDLE_COLUMN_CONTENT, nBits )
+OTableGrantControl::OTableGrantControl(const css::uno::Reference<css::awt::XWindow> &rParent)
+    :EditBrowseBox(VCLUnoHelper::GetWindow(rParent), EditBrowseBoxFlags::SMART_TAB_TRAVEL | EditBrowseBoxFlags::NO_HANDLE_COLUMN_CONTENT, WB_TABSTOP)
     ,m_pCheckCell( nullptr )
     ,m_pEdit( nullptr )
     ,m_nDataPos( 0 )
diff --git a/dbaccess/source/ui/dlg/UserAdmin.cxx b/dbaccess/source/ui/dlg/UserAdmin.cxx
index e6cd0dc6d078..42910b575573 100644
--- a/dbaccess/source/ui/dlg/UserAdmin.cxx
+++ b/dbaccess/source/ui/dlg/UserAdmin.cxx
@@ -108,25 +108,22 @@ IMPL_LINK(OPasswordDialog, ModifiedHdl, weld::Entry&, rEdit, void)
 }
 
 // OUserAdmin
-OUserAdmin::OUserAdmin(vcl::Window* pParent,const SfxItemSet& _rAttrSet)
-    : OGenericAdministrationPage( pParent, "UserAdminPage", "dbaccess/ui/useradminpage.ui", _rAttrSet)
-    , m_pUSER(nullptr)
-    , m_pNEWUSER(nullptr)
-    , m_pCHANGEPWD(nullptr)
-    , m_pDELETEUSER(nullptr)
-    ,m_TableCtrl(VclPtr<OTableGrantControl>::Create(get<VclAlignment>("table"), WB_TABSTOP))
+OUserAdmin::OUserAdmin(TabPageParent pParent,const SfxItemSet& _rAttrSet)
+    : OGenericAdministrationPage(pParent, "dbaccess/ui/useradminpage.ui", "UserAdminPage", _rAttrSet)
+    , m_xUSER(m_xBuilder->weld_combo_box("user"))
+    , m_xNEWUSER(m_xBuilder->weld_button("add"))
+    , m_xCHANGEPWD(m_xBuilder->weld_button("changepass"))
+    , m_xDELETEUSER(m_xBuilder->weld_button("delete"))
+    , m_xTable(m_xBuilder->weld_container("table"))
+    , m_xTableCtrlParent(m_xTable->CreateChildFrame())
+    , m_xTableCtrl(VclPtr<OTableGrantControl>::Create(m_xTableCtrlParent))
 {
-    m_TableCtrl->Show();
-    get(m_pUSER, "user");
-    get(m_pNEWUSER, "add");
-    get(m_pCHANGEPWD, "changepass");
-    get(m_pDELETEUSER, "delete");
+    m_xTableCtrl->Show();
 
-    m_pUSER->SetSelectHdl(LINK(this, OUserAdmin, ListDblClickHdl));
-
-    m_pNEWUSER->SetClickHdl(LINK(this, OUserAdmin, UserHdl));
-    m_pCHANGEPWD->SetClickHdl(LINK(this, OUserAdmin, UserHdl));
-    m_pDELETEUSER->SetClickHdl(LINK(this, OUserAdmin, UserHdl));
+    m_xUSER->connect_changed(LINK(this, OUserAdmin, ListDblClickHdl));
+    m_xNEWUSER->connect_clicked(LINK(this, OUserAdmin, UserHdl));
+    m_xCHANGEPWD->connect_clicked(LINK(this, OUserAdmin, UserHdl));
+    m_xDELETEUSER->connect_clicked(LINK(this, OUserAdmin, UserHdl));
 }
 
 OUserAdmin::~OUserAdmin()
@@ -137,11 +134,9 @@ OUserAdmin::~OUserAdmin()
 void OUserAdmin::dispose()
 {
     m_xConnection = nullptr;
-    m_TableCtrl.disposeAndClear();
-    m_pUSER.clear();
-    m_pNEWUSER.clear();
-    m_pCHANGEPWD.clear();
-    m_pDELETEUSER.clear();
+    m_xTableCtrl.disposeAndClear();
+    m_xTableCtrlParent->dispose();
+    m_xTableCtrlParent.clear();
     OGenericAdministrationPage::dispose();
 }
 
@@ -149,7 +144,7 @@ void OUserAdmin::FillUserNames()
 {
     if(m_xConnection.is())
     {
-        m_pUSER->Clear();
+        m_xUSER->clear();
 
         Reference<XDatabaseMetaData> xMetaData = m_xConnection->getMetaData();
 
@@ -160,50 +155,49 @@ void OUserAdmin::FillUserNames()
             // first we need the users
             if ( m_xUsers.is() )
             {
-                m_pUSER->Clear();
+                m_xUSER->clear();
 
                 m_aUserNames = m_xUsers->getElementNames();
                 const OUString* pBegin = m_aUserNames.getConstArray();
                 const OUString* pEnd   = pBegin + m_aUserNames.getLength();
                 for(;pBegin != pEnd;++pBegin)
-                    m_pUSER->InsertEntry(*pBegin);
+                    m_xUSER->append_text(*pBegin);
 
-                m_pUSER->SelectEntryPos(0);
+                m_xUSER->set_active(0);
                 if(m_xUsers->hasByName(m_UserName))
                 {
                     Reference<XAuthorizable> xAuth;
                     m_xUsers->getByName(m_UserName) >>= xAuth;
-                    m_TableCtrl->setGrantUser(xAuth);
+                    m_xTableCtrl->setGrantUser(xAuth);
                 }
 
-                m_TableCtrl->setUserName(GetUser());
-                m_TableCtrl->Init();
+                m_xTableCtrl->setUserName(GetUser());
+                m_xTableCtrl->Init();
             }
         }
     }
 
     Reference<XAppend> xAppend(m_xUsers,UNO_QUERY);
-    m_pNEWUSER->Enable(xAppend.is());
+    m_xNEWUSER->set_sensitive(xAppend.is());
     Reference<XDrop> xDrop(m_xUsers,UNO_QUERY);
-    m_pDELETEUSER->Enable(xDrop.is());
-
-    m_pCHANGEPWD->Enable(m_xUsers.is());
-    m_TableCtrl->Enable(m_xUsers.is());
+    m_xDELETEUSER->set_sensitive(xDrop.is());
 
+    m_xCHANGEPWD->set_sensitive(m_xUsers.is());
+    m_xTableCtrl->Enable(m_xUsers.is());
 }
 
 VclPtr<SfxTabPage> OUserAdmin::Create( TabPageParent pParent, const SfxItemSet* _rAttrSet )
 {
-    return VclPtr<OUserAdmin>::Create( pParent.pParent, *_rAttrSet );
+    return VclPtr<OUserAdmin>::Create( pParent, *_rAttrSet );
 }
 
-IMPL_LINK( OUserAdmin, UserHdl, Button *, pButton, void )
+IMPL_LINK(OUserAdmin, UserHdl, weld::Button&, rButton, void)
 {
     try
     {
-        if(pButton == m_pNEWUSER)
+        if (&rButton == m_xNEWUSER.get())
         {
-            SfxPasswordDialog aPwdDlg(GetFrameWeld());
+            SfxPasswordDialog aPwdDlg(GetDialogFrameWeld());
             aPwdDlg.ShowExtras(SfxShowExtras::ALL);
             if (aPwdDlg.run())
             {
@@ -219,7 +213,7 @@ IMPL_LINK( OUserAdmin, UserHdl, Button *, pButton, void )
                 }
             }
         }
-        else if(pButton == m_pCHANGEPWD)
+        else if (&rButton == m_xCHANGEPWD.get())
         {
             OUString sName = GetUser();
 
@@ -249,7 +243,7 @@ IMPL_LINK( OUserAdmin, UserHdl, Button *, pButton, void )
                 Reference<XDrop> xDrop(m_xUsers,UNO_QUERY);
                 if(xDrop.is())
                 {
-                    std::unique_ptr<weld::MessageDialog> xQry(Application::CreateMessageDialog(GetFrameWeld(),
+                    std::unique_ptr<weld::MessageDialog> xQry(Application::CreateMessageDialog(GetDialogFrameWeld(),
                                                               VclMessageType::Question, VclButtonsType::YesNo,
                                                               DBA_RES(STR_QUERY_USERADMIN_DELETE_USER)));
                     if (xQry->run() == RET_YES)
@@ -268,17 +262,17 @@ IMPL_LINK( OUserAdmin, UserHdl, Button *, pButton, void )
     }
 }
 
-IMPL_LINK_NOARG( OUserAdmin, ListDblClickHdl, ListBox&, void )
+IMPL_LINK_NOARG(OUserAdmin, ListDblClickHdl, weld::ComboBox&, void)
 {
-    m_TableCtrl->setUserName(GetUser());
-    m_TableCtrl->UpdateTables();
-    m_TableCtrl->DeactivateCell();
-    m_TableCtrl->ActivateCell(m_TableCtrl->GetCurRow(),m_TableCtrl->GetCurColumnId());
+    m_xTableCtrl->setUserName(GetUser());
+    m_xTableCtrl->UpdateTables();
+    m_xTableCtrl->DeactivateCell();
+    m_xTableCtrl->ActivateCell(m_xTableCtrl->GetCurRow(),m_xTableCtrl->GetCurColumnId());
 }
 
 OUString OUserAdmin::GetUser() const
 {
-    return m_pUSER->GetSelectedEntry();
+    return m_xUSER->get_active_text();
 }
 
 void OUserAdmin::fillControls(std::vector< std::unique_ptr<ISaveValueWrapper> >& /*_rControlList*/)
@@ -291,7 +285,7 @@ void OUserAdmin::fillWindows(std::vector< std::unique_ptr<ISaveValueWrapper> >&
 
 void OUserAdmin::implInitControls(const SfxItemSet& _rSet, bool _bSaveValue)
 {
-    m_TableCtrl->setComponentContext(m_xORB);
+    m_xTableCtrl->setComponentContext(m_xORB);
     try
     {
         if ( !m_xConnection.is() && m_pAdminDialog )
@@ -310,7 +304,7 @@ void OUserAdmin::implInitControls(const SfxItemSet& _rSet, bool _bSaveValue)
             }
             if ( xUsersSup.is() )
             {
-                m_TableCtrl->setTablesSupplier(xTablesSup);
+                m_xTableCtrl->setTablesSupplier(xTablesSup);
                 m_xUsers = xUsersSup->getUsers();
             }
         }
diff --git a/dbaccess/source/ui/dlg/UserAdmin.hxx b/dbaccess/source/ui/dlg/UserAdmin.hxx
index f0d105646539..bfcf77ea8af4 100644
--- a/dbaccess/source/ui/dlg/UserAdmin.hxx
+++ b/dbaccess/source/ui/dlg/UserAdmin.hxx
@@ -38,11 +38,13 @@ namespace dbaui
 class OUserAdmin final : public OGenericAdministrationPage
 {
     friend class VclPtr<OUserAdmin>;
-    VclPtr<ListBox>             m_pUSER;
-    VclPtr<PushButton>          m_pNEWUSER;
-    VclPtr<PushButton>          m_pCHANGEPWD;
-    VclPtr<PushButton>          m_pDELETEUSER;
-    VclPtr<OTableGrantControl>  m_TableCtrl; // show the grant rights of one user
+    std::unique_ptr<weld::ComboBox> m_xUSER;
+    std::unique_ptr<weld::Button> m_xNEWUSER;
+    std::unique_ptr<weld::Button> m_xCHANGEPWD;
+    std::unique_ptr<weld::Button> m_xDELETEUSER;
+    std::unique_ptr<weld::Container> m_xTable;
+    css::uno::Reference<css::awt::XWindow> m_xTableCtrlParent;
+    VclPtr<OTableGrantControl> m_xTableCtrl; // show the grant rights of one user
 
     css::uno::Reference< css::sdbc::XConnection>          m_xConnection;
     css::uno::Reference< css::container::XNameAccess >    m_xUsers;
@@ -51,14 +53,14 @@ class OUserAdmin final : public OGenericAdministrationPage
     OUString            m_UserName;
 
     // methods
-    DECL_LINK( ListDblClickHdl, ListBox&, void );
-    DECL_LINK( UserHdl,   Button *, void );
+    DECL_LINK(ListDblClickHdl, weld::ComboBox&, void);
+    DECL_LINK(UserHdl, weld::Button&, void);
 
     void        FillUserNames();
 
-    OUserAdmin( vcl::Window* pParent, const SfxItemSet& _rCoreAttrs);
+    OUserAdmin(TabPageParent pParent, const SfxItemSet& _rCoreAttrs);
 public:
-    static  VclPtr<SfxTabPage> Create( TabPageParent pParent, const SfxItemSet* _rAttrSet );
+    static  VclPtr<SfxTabPage> Create(TabPageParent pParent, const SfxItemSet* _rAttrSet);
 
     virtual ~OUserAdmin() override;
     virtual void dispose() override;
@@ -73,6 +75,7 @@ public:
     // <method>OGenericAdministrationPage::fillWindows</method>
     virtual void fillWindows(std::vector< std::unique_ptr<ISaveValueWrapper> >& _rControlList) override;
 };
+
 }
 #endif // INCLUDED_DBACCESS_SOURCE_UI_DLG_USERADMIN_HXX
 
diff --git a/dbaccess/source/ui/inc/TableGrantCtrl.hxx b/dbaccess/source/ui/inc/TableGrantCtrl.hxx
index f21421ed28d9..7286bd27db5d 100644
--- a/dbaccess/source/ui/inc/TableGrantCtrl.hxx
+++ b/dbaccess/source/ui/inc/TableGrantCtrl.hxx
@@ -24,6 +24,7 @@
 #include <map>
 
 #include <svtools/editbrowsebox.hxx>
+#include <com/sun/star/awt/XWindow.hpp>
 #include <com/sun/star/sdbcx/XTablesSupplier.hpp>
 #include <com/sun/star/sdbcx/XAuthorizable.hpp>
 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
@@ -57,7 +58,7 @@ class OTableGrantControl : public ::svt::EditBrowseBox
     ImplSVEvent *               m_nDeactivateEvent;
 
 public:
-    OTableGrantControl( vcl::Window* pParent, WinBits nBits);
+    OTableGrantControl(const css::uno::Reference<css::awt::XWindow> &rParent);
     virtual ~OTableGrantControl() override;
     virtual void dispose() override;
     void UpdateTables();
diff --git a/dbaccess/uiconfig/ui/useradminpage.ui b/dbaccess/uiconfig/ui/useradminpage.ui
index 35d351eff938..71addc1e6f28 100644
--- a/dbaccess/uiconfig/ui/useradminpage.ui
+++ b/dbaccess/uiconfig/ui/useradminpage.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="dba">
   <requires lib="gtk+" version="3.18"/>
   <object class="GtkBox" id="UserAdminPage">
@@ -43,9 +43,9 @@
                         <property name="can_focus">False</property>
                         <property name="halign">start</property>
                         <property name="hexpand">True</property>
-                        <property name="xalign">0</property>
                         <property name="label" translatable="yes" context="useradminpage|label3">Us_er:</property>
                         <property name="use_underline">True</property>
+                        <property name="xalign">0</property>
                       </object>
                       <packing>
                         <property name="expand">False</property>
@@ -54,7 +54,7 @@
                       </packing>
                     </child>
                     <child>
-                      <object class="GtkComboBox" id="user">
+                      <object class="GtkComboBoxText" id="user">
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
                         <property name="hexpand">True</property>
@@ -157,7 +157,7 @@
         <property name="label_xalign">0</property>
         <property name="shadow_type">none</property>
         <child>
-          <object class="GtkAlignment" id="table">
+          <object class="GtkAlignment" id="alignment">
             <property name="height_request">150</property>
             <property name="visible">True</property>
             <property name="can_focus">False</property>
@@ -166,7 +166,14 @@
             <property name="top_padding">6</property>
             <property name="left_padding">12</property>
             <child>
-              <placeholder/>
+              <object class="GtkBox" id="table">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="orientation">vertical</property>
+                <child>
+                  <placeholder/>
+                </child>
+              </object>
             </child>
           </object>
         </child>


More information about the Libreoffice-commits mailing list