diff options
author | Caolán McNamara <caolanm@redhat.com> | 2018-10-11 12:05:58 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2018-10-11 15:17:36 +0200 |
commit | f1f0045c74c930c02592db7dd6d7b782729f9ee9 (patch) | |
tree | bd21b0a3c43b158da0fa49ad56c701e30c123449 /dbaccess/source | |
parent | 282e49b2f7bb3d6993cd2151064d6b2eddfe940b (diff) |
weld OParameterDialog
Change-Id: I46b38a4adb4e1e825918029c7b4aba1d267a6e62
Reviewed-on: https://gerrit.libreoffice.org/61665
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'dbaccess/source')
-rw-r--r-- | dbaccess/source/ui/dlg/paramdialog.cxx | 150 | ||||
-rw-r--r-- | dbaccess/source/ui/inc/paramdialog.hxx | 38 | ||||
-rw-r--r-- | dbaccess/source/ui/uno/dbinteraction.cxx | 6 |
3 files changed, 76 insertions, 118 deletions
diff --git a/dbaccess/source/ui/dlg/paramdialog.cxx b/dbaccess/source/ui/dlg/paramdialog.cxx index 425c9e0936df..370c733eafb7 100644 --- a/dbaccess/source/ui/dlg/paramdialog.cxx +++ b/dbaccess/source/ui/dlg/paramdialog.cxx @@ -49,21 +49,20 @@ namespace dbaui OParameterDialog::OParameterDialog( - vcl::Window* pParent, const Reference< XIndexAccess > & rParamContainer, + weld::Window* pParent, const Reference< XIndexAccess > & rParamContainer, const Reference< XConnection > & _rxConnection, const Reference< XComponentContext >& rxContext) - :ModalDialog( pParent, "Parameters", "dbaccess/ui/parametersdialog.ui") - ,m_nCurrentlySelected(LISTBOX_ENTRY_NOTFOUND) - ,m_xConnection(_rxConnection) - ,m_aPredicateInput( rxContext, _rxConnection, getParseContext() ) - ,m_bNeedErrorOnCurrent(true) + : GenericDialogController(pParent, "dbaccess/ui/parametersdialog.ui", "Parameters") + , m_nCurrentlySelected(-1) + , m_xConnection(_rxConnection) + , m_aPredicateInput( rxContext, _rxConnection, getParseContext() ) + , m_bNeedErrorOnCurrent(true) + , m_xAllParams(m_xBuilder->weld_tree_view("allParamTreeview")) + , m_xParam(m_xBuilder->weld_entry("paramEntry")) + , m_xTravelNext(m_xBuilder->weld_button("next")) + , m_xOKBtn(m_xBuilder->weld_button("ok")) + , m_xCancelBtn(m_xBuilder->weld_button("cancel")) { - get(m_pAllParams, "allParamTreeview"); - get(m_pParam, "paramEntry"); - get(m_pTravelNext, "next"); - get(m_pOKBtn, "ok"); - get(m_pCancelBtn, "cancel"); - - set_height_request(200); + m_xAllParams->set_size_request(-1, m_xAllParams->get_height_rows(10)); if (rxContext.is()) m_xFormatter.set( NumberFormatter::create( rxContext ), UNO_QUERY_THROW); @@ -91,7 +90,7 @@ namespace dbaui if(!xParamAsSet.is()) continue; pValues->Name = ::comphelper::getString(xParamAsSet->getPropertyValue(PROPERTY_NAME)); - m_pAllParams->InsertEntry(pValues->Name); + m_xAllParams->append_text(pValues->Name); m_aVisitedParams.push_back(VisitFlags::NONE); // not visited, not dirty @@ -111,58 +110,47 @@ namespace dbaui OParameterDialog::~OParameterDialog() { - disposeOnce(); - } - - void OParameterDialog::dispose() - { if (m_aResetVisitFlag.IsActive()) m_aResetVisitFlag.Stop(); - m_pAllParams.clear(); - m_pParam.clear(); - m_pTravelNext.clear(); - m_pOKBtn.clear(); - m_pCancelBtn.clear(); - ModalDialog::dispose(); } void OParameterDialog::Construct() { - m_pAllParams->SetSelectHdl(LINK(this, OParameterDialog, OnEntryListBoxSelected)); - m_pParam->SetLoseFocusHdl(LINK(this, OParameterDialog, OnValueLoseFocusHdl)); - m_pParam->SetModifyHdl(LINK(this, OParameterDialog, OnValueModified)); - m_pTravelNext->SetClickHdl(LINK(this, OParameterDialog, OnButtonClicked)); - m_pOKBtn->SetClickHdl(LINK(this, OParameterDialog, OnButtonClicked)); - m_pCancelBtn->SetClickHdl(LINK(this, OParameterDialog, OnButtonClicked)); - - if (m_pAllParams->GetEntryCount()) + m_xAllParams->connect_changed(LINK(this, OParameterDialog, OnEntryListBoxSelected)); + m_xParam->connect_focus_out(LINK(this, OParameterDialog, OnValueLoseFocusHdl)); + m_xParam->connect_changed(LINK(this, OParameterDialog, OnValueModified)); + m_xTravelNext->connect_clicked(LINK(this, OParameterDialog, OnButtonClicked)); + m_xOKBtn->connect_clicked(LINK(this, OParameterDialog, OnButtonClicked)); + m_xCancelBtn->connect_clicked(LINK(this, OParameterDialog, OnButtonClicked)); + + if (m_xAllParams->n_children()) { - m_pAllParams->SelectEntryPos(0); + m_xAllParams->select(0); OnEntrySelected(); - if (m_pAllParams->GetEntryCount() == 1) + if (m_xAllParams->n_children() == 1) { - m_pTravelNext->Enable(false); + m_xTravelNext->set_sensitive(false); } - if (m_pAllParams->GetEntryCount() > 1) + if (m_xAllParams->n_children() > 1) { - m_pOKBtn->SetStyle(m_pOKBtn->GetStyle() & ~WB_DEFBUTTON); - m_pTravelNext->SetStyle(m_pTravelNext->GetStyle() | WB_DEFBUTTON); + m_xOKBtn->set_has_default(false); + m_xTravelNext->set_has_default(true); } } - m_pParam->GrabFocus(); + m_xParam->grab_focus(); } - IMPL_LINK_NOARG(OParameterDialog, OnValueLoseFocusHdl, Control&, void) + IMPL_LINK_NOARG(OParameterDialog, OnValueLoseFocusHdl, weld::Widget&, void) { OnValueLoseFocus(); } bool OParameterDialog::OnValueLoseFocus() { - if (m_nCurrentlySelected != LISTBOX_ENTRY_NOTFOUND) + if (m_nCurrentlySelected != -1) { if ( !( m_aVisitedParams[ m_nCurrentlySelected ] & VisitFlags::Dirty ) ) // nothing to do, the value isn't dirty @@ -175,13 +163,13 @@ namespace dbaui { if (m_xConnection.is() && m_xFormatter.is()) { - OUString sParamValue( m_pParam->GetText() ); + OUString sParamValue(m_xParam->get_text()); bool bValid = m_aPredicateInput.normalizePredicateString( sParamValue, xParamAsSet ); - m_pParam->SetText( sParamValue ); + m_xParam->set_text(sParamValue); if ( bValid ) { // with this the value isn't dirty anymore - if (m_nCurrentlySelected != LISTBOX_ENTRY_NOTFOUND) + if (m_nCurrentlySelected != -1) m_aVisitedParams[m_nCurrentlySelected] &= ~VisitFlags::Dirty; } else @@ -205,7 +193,7 @@ namespace dbaui VclMessageType::Warning, VclButtonsType::Ok, sMessage)); xDialog->run(); - m_pParam->GrabFocus(); + m_xParam->grab_focus(); return true; } } @@ -214,17 +202,16 @@ namespace dbaui return false; } - IMPL_LINK(OParameterDialog, OnButtonClicked, Button*, pButton, void) + IMPL_LINK(OParameterDialog, OnButtonClicked, weld::Button&, rButton, void) { - if (m_pCancelBtn == pButton) + if (m_xCancelBtn.get() == &rButton) { // no interpreting of the given values anymore .... - m_pParam->SetLoseFocusHdl(Link<Control&,void>()); // no direct call from the control anymore ... + m_xParam->connect_focus_out(Link<weld::Widget&, void>()); // no direct call from the control anymore ... m_bNeedErrorOnCurrent = false; // in case of any indirect calls -> no error message - m_pCancelBtn->SetClickHdl(Link<Button*,void>()); - m_pCancelBtn->Click(); + m_xDialog->response(RET_CANCEL); } - else if (m_pOKBtn == pButton) + else if (m_xOKBtn.get() == &rButton) { // transfer the current values into the Any if (OnEntrySelected()) @@ -258,15 +245,13 @@ namespace dbaui } } - // to close the dialog (which is more code than a simple EndDialog) - m_pOKBtn->SetClickHdl(Link<Button*,void>()); - m_pOKBtn->Click(); + m_xDialog->response(RET_OK); } - else if (m_pTravelNext == pButton) + else if (m_xTravelNext.get() == &rButton) { - if (sal_Int32 nCount = m_pAllParams->GetEntryCount()) + if (sal_Int32 nCount = m_xAllParams->n_children()) { - sal_Int32 nCurrent = m_pAllParams->GetSelectedEntryPos(); + sal_Int32 nCurrent = m_xAllParams->get_selected_index(); OSL_ENSURE(static_cast<size_t>(nCount) == m_aVisitedParams.size(), "OParameterDialog::OnButtonClicked : inconsistent lists !"); // search the next entry in list we haven't visited yet @@ -278,7 +263,7 @@ namespace dbaui // there is no such "not visited yet" entry -> simply take the next one nNext = (nCurrent + 1) % nCount; - m_pAllParams->SelectEntryPos(nNext); + m_xAllParams->select(nNext); OnEntrySelected(); m_bNeedErrorOnCurrent = true; // we're are out of the complex web :) of direct and indirect calls to OnValueLoseFocus now, @@ -288,7 +273,7 @@ namespace dbaui } } - IMPL_LINK_NOARG(OParameterDialog, OnEntryListBoxSelected, ListBox&, void) + IMPL_LINK_NOARG(OParameterDialog, OnEntryListBoxSelected, weld::TreeView&, void) { OnEntrySelected(); } @@ -301,23 +286,23 @@ namespace dbaui m_aResetVisitFlag.Stop(); } // save the old values - if (m_nCurrentlySelected != LISTBOX_ENTRY_NOTFOUND) + if (m_nCurrentlySelected != -1) { // do the transformation of the current text if (OnValueLoseFocus()) { // there was an error interpreting the text - m_pAllParams->SelectEntryPos(m_nCurrentlySelected); + m_xAllParams->select(m_nCurrentlySelected); return true; } - m_aFinalValues[m_nCurrentlySelected].Value <<= m_pParam->GetText(); + m_aFinalValues[m_nCurrentlySelected].Value <<= m_xParam->get_text(); } // initialize the controls with the new values - sal_Int32 nSelected = m_pAllParams->GetSelectedEntryPos(); - OSL_ENSURE(nSelected != LISTBOX_ENTRY_NOTFOUND, "OParameterDialog::OnEntrySelected : no current entry !"); + sal_Int32 nSelected = m_xAllParams->get_selected_index(); + OSL_ENSURE(nSelected != -1, "OParameterDialog::OnEntrySelected : no current entry !"); - m_pParam->SetText(::comphelper::getString(m_aFinalValues[nSelected].Value)); + m_xParam->set_text(::comphelper::getString(m_aFinalValues[nSelected].Value)); m_nCurrentlySelected = nSelected; // with this the value isn't dirty @@ -332,7 +317,7 @@ namespace dbaui IMPL_LINK_NOARG(OParameterDialog, OnVisitedTimeout, Timer*, void) { - OSL_ENSURE(m_nCurrentlySelected != LISTBOX_ENTRY_NOTFOUND, "OParameterDialog::OnVisitedTimeout : invalid call !"); + OSL_ENSURE(m_nCurrentlySelected != -1, "OParameterDialog::OnVisitedTimeout : invalid call !"); // mark the currently selected entry as visited OSL_ENSURE(static_cast<size_t>(m_nCurrentlySelected) < m_aVisitedParams.size(), "OParameterDialog::OnVisitedTimeout : invalid entry !"); @@ -348,35 +333,16 @@ namespace dbaui break; } } - if (!bVisited) - { // yes, there isn't another one -> change the "default button" - m_pTravelNext->SetStyle(m_pTravelNext->GetStyle() & ~WB_DEFBUTTON); - m_pOKBtn->SetStyle(m_pOKBtn->GetStyle() | WB_DEFBUTTON); - - // set to focus to one of the buttons temporary (with this their "default"-state is really updated) - vcl::Window* pOldFocus = Application::GetFocusWindow(); - // if the old focus window is the value edit do some preparations ... - Selection aSel; - if (pOldFocus == m_pParam) - { - m_pParam->SetLoseFocusHdl(Link<Control&,void>()); - aSel = m_pParam->GetSelection(); - } - m_pTravelNext->GrabFocus(); - if (pOldFocus) - pOldFocus->GrabFocus(); - - // restore the settings for the value edit - if (pOldFocus == m_pParam) - { - m_pParam->SetLoseFocusHdl(LINK(this, OParameterDialog, OnValueLoseFocusHdl)); - m_pParam->SetSelection(aSel); - } + if (!bVisited) + { + // yes, there isn't another one -> change the "default button" + m_xTravelNext->set_has_default(false); + m_xOKBtn->set_has_default(true); } } - IMPL_LINK_NOARG(OParameterDialog, OnValueModified, Edit&, void) + IMPL_LINK_NOARG(OParameterDialog, OnValueModified, weld::Entry&, void) { // mark the currently selected entry as dirty OSL_ENSURE(static_cast<size_t>(m_nCurrentlySelected) < m_aVisitedParams.size(), "OParameterDialog::OnValueModified : invalid entry !"); diff --git a/dbaccess/source/ui/inc/paramdialog.hxx b/dbaccess/source/ui/inc/paramdialog.hxx index dfe396321a41..c962802e47f0 100644 --- a/dbaccess/source/ui/inc/paramdialog.hxx +++ b/dbaccess/source/ui/inc/paramdialog.hxx @@ -22,12 +22,7 @@ #include "commontypes.hxx" -#include <vcl/dialog.hxx> -#include <vcl/button.hxx> -#include <vcl/fixed.hxx> -#include <vcl/edit.hxx> -#include <vcl/group.hxx> -#include <vcl/lstbox.hxx> +#include <vcl/weld.hxx> #include <com/sun/star/util/XNumberFormatter.hpp> #include <com/sun/star/container/XIndexAccess.hpp> @@ -52,22 +47,13 @@ namespace o3tl { template<> struct typed_flags<VisitFlags> : is_typed_flags<VisitFlags, 0x03> {}; } - namespace dbaui { - // OParameterDialog class OParameterDialog final - :public ModalDialog - ,public ::svxform::OParseContextClient + : public weld::GenericDialogController + , public ::svxform::OParseContextClient { - // the controls - VclPtr<ListBox> m_pAllParams; - VclPtr<Edit> m_pParam; - VclPtr<PushButton> m_pTravelNext; - VclPtr<OKButton> m_pOKBtn; - VclPtr<CancelButton> m_pCancelBtn; - sal_Int32 m_nCurrentlySelected; css::uno::Reference< css::container::XIndexAccess > @@ -88,13 +74,19 @@ namespace dbaui css::uno::Sequence< css::beans::PropertyValue > m_aFinalValues; /// the final values as entered by the user + // the controls + std::unique_ptr<weld::TreeView> m_xAllParams; + std::unique_ptr<weld::Entry> m_xParam; + std::unique_ptr<weld::Button> m_xTravelNext; + std::unique_ptr<weld::Button> m_xOKBtn; + std::unique_ptr<weld::Button> m_xCancelBtn; + public: - OParameterDialog(vcl::Window* _pParent, + OParameterDialog(weld::Window* _pParent, const css::uno::Reference< css::container::XIndexAccess > & _rParamContainer, const css::uno::Reference< css::sdbc::XConnection > & _rxConnection, const css::uno::Reference< css::uno::XComponentContext >& rxContext); virtual ~OParameterDialog() override; - virtual void dispose() override; const css::uno::Sequence< css::beans::PropertyValue >& getValues() const { return m_aFinalValues; } @@ -103,10 +95,10 @@ namespace dbaui void Construct(); DECL_LINK(OnVisitedTimeout, Timer*, void); - DECL_LINK(OnValueModified, Edit&, void); - DECL_LINK(OnEntryListBoxSelected, ListBox&, void); - DECL_LINK(OnButtonClicked, Button*, void); - DECL_LINK(OnValueLoseFocusHdl, Control&, void); + DECL_LINK(OnValueModified, weld::Entry&, void); + DECL_LINK(OnEntryListBoxSelected, weld::TreeView&, void); + DECL_LINK(OnButtonClicked, weld::Button&, void); + DECL_LINK(OnValueLoseFocusHdl, weld::Widget&, void); bool OnValueLoseFocus(); bool OnEntrySelected(); }; diff --git a/dbaccess/source/ui/uno/dbinteraction.cxx b/dbaccess/source/ui/uno/dbinteraction.cxx index b8c6ad061e18..e3e3173238e9 100644 --- a/dbaccess/source/ui/uno/dbinteraction.cxx +++ b/dbaccess/source/ui/uno/dbinteraction.cxx @@ -132,8 +132,8 @@ namespace dbaui xParamCallback.set(_rContinuations[nParamPos], UNO_QUERY); OSL_ENSURE(xParamCallback.is(), "BasicInteractionHandler::implHandle(ParametersRequest): can't set the parameters without an appropriate interaction handler!s"); - ScopedVclPtrInstance< OParameterDialog > aDlg(VCLUnoHelper::GetWindow(m_xParentWindow), _rParamRequest.Parameters, _rParamRequest.Connection, m_xContext); - sal_Int16 nResult = aDlg->Execute(); + OParameterDialog aDlg(Application::GetFrameWeld(m_xParentWindow), _rParamRequest.Parameters, _rParamRequest.Connection, m_xContext); + sal_Int16 nResult = aDlg.run(); try { switch (nResult) @@ -141,7 +141,7 @@ namespace dbaui case RET_OK: if (xParamCallback.is()) { - xParamCallback->setParameters(aDlg->getValues()); + xParamCallback->setParameters(aDlg.getValues()); xParamCallback->select(); } break; |