From f6eee4f7966e09be82b51554ead4c4aac8c47457 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Fri, 5 Oct 2018 10:02:42 +0100 Subject: weld QueryPropertiesDialog MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Id523fdb25a24e2ef205bd24e594c8e01772d7a58 Reviewed-on: https://gerrit.libreoffice.org/61406 Tested-by: Jenkins Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara --- dbaccess/source/ui/dlg/QueryPropertiesDialog.cxx | 55 ++++++++++++++-------- dbaccess/source/ui/inc/QueryPropertiesDialog.hxx | 34 +++++-------- dbaccess/source/ui/querydesign/LimitBox.cxx | 2 - dbaccess/source/ui/querydesign/querycontroller.cxx | 9 ++-- dbaccess/uiconfig/ui/querypropertiesdialog.ui | 49 +++++++++---------- 5 files changed, 76 insertions(+), 73 deletions(-) (limited to 'dbaccess') diff --git a/dbaccess/source/ui/dlg/QueryPropertiesDialog.cxx b/dbaccess/source/ui/dlg/QueryPropertiesDialog.cxx index 6b5ffe5dc08f..41ed0e867c4b 100644 --- a/dbaccess/source/ui/dlg/QueryPropertiesDialog.cxx +++ b/dbaccess/source/ui/dlg/QueryPropertiesDialog.cxx @@ -8,37 +8,54 @@ */ #include +#include +#include + +#define ALL_STRING DBA_RES(STR_QUERY_LIMIT_ALL) +#define ALL_INT -1 namespace dbaui { QueryPropertiesDialog::QueryPropertiesDialog( - vcl::Window* pParent, const bool bDistinct, const sal_Int64 nLimit ) - : ModalDialog(pParent, "QueryPropertiesDialog", "dbaccess/ui/querypropertiesdialog.ui") - , m_pRB_Distinct( nullptr ) - , m_pRB_NonDistinct( nullptr ) - , m_pLB_Limit( nullptr ) + weld::Window* pParent, const bool bDistinct, const sal_Int64 nLimit ) + : GenericDialogController(pParent, "dbaccess/ui/querypropertiesdialog.ui", "QueryPropertiesDialog") + , m_xRB_Distinct(m_xBuilder->weld_radio_button("distinct")) + , m_xRB_NonDistinct(m_xBuilder->weld_radio_button("nondistinct")) + , m_xLB_Limit(m_xBuilder->weld_combo_box("limitbox")) { - get( m_pRB_Distinct, "distinct" ); - get( m_pRB_NonDistinct, "nondistinct" ); - get( m_pLB_Limit, "limitbox" ); - - m_pRB_Distinct->Check( bDistinct ); - m_pRB_NonDistinct->Check( !bDistinct ); - m_pLB_Limit->SetValue( nLimit ); + m_xRB_Distinct->set_active(bDistinct); + m_xRB_NonDistinct->set_active(!bDistinct); + + m_xLB_Limit->append(OUString::number(ALL_INT), ALL_STRING); + /// Default values + sal_Int64 const aDefLimitAry[] = + { + 5, + 10, + 20, + 50 + }; + for (auto a : aDefLimitAry) + m_xLB_Limit->append(OUString::number(a), OUString::number(a)); + OUString sInitial = OUString::number(nLimit); + auto nPos = m_xLB_Limit->find_id(sInitial); + if (nPos != -1) + m_xLB_Limit->set_active(nPos); + else + m_xLB_Limit->set_entry_text(OUString::number(nLimit)); } -QueryPropertiesDialog::~QueryPropertiesDialog() +sal_Int64 QueryPropertiesDialog::getLimit() const { - disposeOnce(); + OUString sSelectedId = m_xLB_Limit->get_active_id(); + if (!sSelectedId.isEmpty()) + return sSelectedId.toInt64(); + return m_xLB_Limit->get_active_text().toInt64(); } -void QueryPropertiesDialog::dispose() +QueryPropertiesDialog::~QueryPropertiesDialog() { - m_pRB_Distinct.clear(); - m_pRB_NonDistinct.clear(); - m_pLB_Limit.clear(); - ModalDialog::dispose(); } } ///dbaui namespace diff --git a/dbaccess/source/ui/inc/QueryPropertiesDialog.hxx b/dbaccess/source/ui/inc/QueryPropertiesDialog.hxx index 1f1107fe7af2..fde2e8ff9475 100644 --- a/dbaccess/source/ui/inc/QueryPropertiesDialog.hxx +++ b/dbaccess/source/ui/inc/QueryPropertiesDialog.hxx @@ -10,8 +10,7 @@ #ifndef INCLUDED_DBACCESS_SOURCE_UI_INC_QUERYPROPERTIESDIALOG_HXX #define INCLUDED_DBACCESS_SOURCE_UI_INC_QUERYPROPERTIESDIALOG_HXX -#include -#include +#include #include #include "LimitBox.hxx" @@ -22,39 +21,28 @@ namespace dbaui * Dialog to set such properties of a query as distinct values and limit * It can be opened form Edit menu in Query Design View */ -class QueryPropertiesDialog : public ModalDialog +class QueryPropertiesDialog : public weld::GenericDialogController { public: QueryPropertiesDialog( - vcl::Window* pParent, const bool bDistinct, const sal_Int64 nLimit ); + weld::Window* pParent, const bool bDistinct, const sal_Int64 nLimit ); virtual ~QueryPropertiesDialog() override; - virtual void dispose() override; - bool getDistinct() const; + bool getDistinct() const + { + return m_xRB_Distinct->get_active(); + } + sal_Int64 getLimit() const; private: - VclPtr m_pRB_Distinct; - VclPtr m_pRB_NonDistinct; - - VclPtr m_pLB_Limit; - + std::unique_ptr m_xRB_Distinct; + std::unique_ptr m_xRB_NonDistinct; + std::unique_ptr m_xLB_Limit; }; - -inline bool QueryPropertiesDialog::getDistinct() const -{ - return m_pRB_Distinct->IsChecked(); -} - -inline sal_Int64 QueryPropertiesDialog::getLimit() const -{ - return m_pLB_Limit->GetValue(); -} - - } ///dbaui namespace #endif /// INCLUDED_DBACCESS_SOURCE_UI_INC_QUERYPROPERTIESDIALOG_HXX diff --git a/dbaccess/source/ui/querydesign/LimitBox.cxx b/dbaccess/source/ui/querydesign/LimitBox.cxx index 4944f3d30541..6ac017172a07 100644 --- a/dbaccess/source/ui/querydesign/LimitBox.cxx +++ b/dbaccess/source/ui/querydesign/LimitBox.cxx @@ -106,8 +106,6 @@ void LimitBox::LoadDefaultLimits() } } -VCL_BUILDER_FACTORY_ARGS( LimitBox, WB_DROPDOWN | WB_VSCROLL ) - } ///dbaui namespace /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/dbaccess/source/ui/querydesign/querycontroller.cxx b/dbaccess/source/ui/querydesign/querycontroller.cxx index f7659b211088..7026e023ef87 100644 --- a/dbaccess/source/ui/querydesign/querycontroller.cxx +++ b/dbaccess/source/ui/querydesign/querycontroller.cxx @@ -1067,13 +1067,12 @@ void OQueryController::loadViewSettings( const ::comphelper::NamedValueCollectio void OQueryController::execute_QueryPropDlg() { - ScopedVclPtrInstance aQueryPropDlg( - getContainer(), m_bDistinct, m_nLimit ); + QueryPropertiesDialog aQueryPropDlg(getContainer()->GetFrameWeld(), m_bDistinct, m_nLimit); - if( aQueryPropDlg->Execute() == RET_OK ) + if (aQueryPropDlg.run() == RET_OK) { - m_bDistinct = aQueryPropDlg->getDistinct(); - m_nLimit = aQueryPropDlg->getLimit(); + m_bDistinct = aQueryPropDlg.getDistinct(); + m_nLimit = aQueryPropDlg.getLimit(); InvalidateFeature( SID_QUERY_DISTINCT_VALUES ); InvalidateFeature( SID_QUERY_LIMIT, nullptr, true ); } diff --git a/dbaccess/uiconfig/ui/querypropertiesdialog.ui b/dbaccess/uiconfig/ui/querypropertiesdialog.ui index 49dc0467c990..a89852d93573 100644 --- a/dbaccess/uiconfig/ui/querypropertiesdialog.ui +++ b/dbaccess/uiconfig/ui/querypropertiesdialog.ui @@ -1,8 +1,7 @@ - + - False 6 @@ -10,6 +9,9 @@ False True dialog + + + False @@ -80,31 +82,16 @@ True 6 12 - - - True - False - True - - - 1 - 1 - 1 - 1 - - True False - 1 Limit: + 1 0 1 - 1 - 1 @@ -120,8 +107,8 @@ False True 0 + True True - nondistinct False @@ -150,22 +137,36 @@ 1 0 - 1 - 1 True False - 1 Distinct values: + 1 0 0 - 1 - 1 + + + + + True + False + True + True + + + True + True + + + + + 1 + 1 -- cgit