diff options
author | Caolán McNamara <caolanm@redhat.com> | 2018-10-05 10:02:42 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2018-10-05 12:20:47 +0200 |
commit | f6eee4f7966e09be82b51554ead4c4aac8c47457 (patch) | |
tree | c47b06cb3c2e9f99ec3fda35738d80a1a62d9bfc /dbaccess | |
parent | faf6b466ab510ccee540953eebb790b6a57386e6 (diff) |
weld QueryPropertiesDialog
Change-Id: Id523fdb25a24e2ef205bd24e594c8e01772d7a58
Reviewed-on: https://gerrit.libreoffice.org/61406
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'dbaccess')
-rw-r--r-- | dbaccess/source/ui/dlg/QueryPropertiesDialog.cxx | 55 | ||||
-rw-r--r-- | dbaccess/source/ui/inc/QueryPropertiesDialog.hxx | 34 | ||||
-rw-r--r-- | dbaccess/source/ui/querydesign/LimitBox.cxx | 2 | ||||
-rw-r--r-- | dbaccess/source/ui/querydesign/querycontroller.cxx | 9 | ||||
-rw-r--r-- | dbaccess/uiconfig/ui/querypropertiesdialog.ui | 49 |
5 files changed, 76 insertions, 73 deletions
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 <QueryPropertiesDialog.hxx> +#include <strings.hrc> +#include <core_resource.hxx> + +#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 <vcl/dialog.hxx> -#include <vcl/button.hxx> +#include <vcl/weld.hxx> #include <rtl/ustring.hxx> #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<RadioButton> m_pRB_Distinct; - VclPtr<RadioButton> m_pRB_NonDistinct; - - VclPtr<LimitBox> m_pLB_Limit; - + std::unique_ptr<weld::RadioButton> m_xRB_Distinct; + std::unique_ptr<weld::RadioButton> m_xRB_NonDistinct; + std::unique_ptr<weld::ComboBox> 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<QueryPropertiesDialog> 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 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.16.1 --> +<!-- Generated with glade 3.22.1 --> <interface domain="dba"> <requires lib="gtk+" version="3.18"/> - <!-- interface-requires LibreOffice 1.0 --> <object class="GtkDialog" id="QueryPropertiesDialog"> <property name="can_focus">False</property> <property name="border_width">6</property> @@ -10,6 +9,9 @@ <property name="resizable">False</property> <property name="modal">True</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> @@ -81,30 +83,15 @@ <property name="row_spacing">6</property> <property name="column_spacing">12</property> <child> - <object class="dbulo-LimitBox" id="limitbox"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="hexpand">True</property> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">1</property> - <property name="width">1</property> - <property name="height">1</property> - </packing> - </child> - <child> <object class="GtkLabel" id="limit-label"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="xalign">1</property> <property name="label" translatable="yes" context="querypropertiesdialog|limit-label">Limit:</property> + <property name="xalign">1</property> </object> <packing> <property name="left_attach">0</property> <property name="top_attach">1</property> - <property name="width">1</property> - <property name="height">1</property> </packing> </child> <child> @@ -120,8 +107,8 @@ <property name="receives_default">False</property> <property name="use_underline">True</property> <property name="xalign">0</property> + <property name="active">True</property> <property name="draw_indicator">True</property> - <property name="group">nondistinct</property> </object> <packing> <property name="expand">False</property> @@ -150,22 +137,36 @@ <packing> <property name="left_attach">1</property> <property name="top_attach">0</property> - <property name="width">1</property> - <property name="height">1</property> </packing> </child> <child> <object class="GtkLabel" id="distinctvalues"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="xalign">1</property> <property name="label" translatable="yes" context="querypropertiesdialog|distinctvalues">Distinct values:</property> + <property name="xalign">1</property> </object> <packing> <property name="left_attach">0</property> <property name="top_attach">0</property> - <property name="width">1</property> - <property name="height">1</property> + </packing> + </child> + <child> + <object class="GtkComboBoxText" id="limitbox"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="hexpand">True</property> + <property name="has_entry">True</property> + <child internal-child="entry"> + <object class="GtkEntry"> + <property name="can_focus">True</property> + <property name="activates_default">True</property> + </object> + </child> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">1</property> </packing> </child> </object> |