Kaydet (Commit) f6eee4f7 authored tarafından Caolán McNamara's avatar Caolán McNamara

weld QueryPropertiesDialog

Change-Id: Id523fdb25a24e2ef205bd24e594c8e01772d7a58
Reviewed-on: https://gerrit.libreoffice.org/61406
Tested-by: Jenkins
Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst faf6b466
......@@ -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
......
......@@ -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
......
......@@ -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: */
......@@ -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 );
}
......
<?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>
......@@ -80,31 +82,16 @@
<property name="vexpand">True</property>
<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>
......
......@@ -126,10 +126,6 @@
</properties>
</glade-widget-class>
<glade-widget-class title="Limit ListBox" name="dbulo-LimitBox"
generic-name="LimitBox" parent="GtkComboBox"
icon-name="widget-gtk-combobox"/>
<glade-widget-class title="OSQL NameComboBox" name="dbulo-OSQLNameComboBox"
generic-name="OSQLNameComboBox" parent="GtkComboBox"
icon-name="widget-gtk-combobox"/>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment