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

weld ScSelEntryDlg

Change-Id: I1bc78b61a50f909ceb4c79e9dc9425306d41e617
Reviewed-on: https://gerrit.libreoffice.org/54534Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst 74c8bc3c
......@@ -450,8 +450,7 @@ public:
virtual VclPtr<AbstractScInsertTableDlg> CreateScInsertTableDlg(weld::Window* pParent, ScViewData& rViewData,
SCTAB nTabCount, bool bFromFile) = 0;
virtual VclPtr<AbstractScSelEntryDlg > CreateScSelEntryDlg ( vcl::Window* pParent,
const std::vector<OUString> &rEntryList ) = 0;
virtual VclPtr<AbstractScSelEntryDlg > CreateScSelEntryDlg(weld::Window* pParent, const std::vector<OUString> &rEntryList) = 0;
virtual VclPtr<AbstractScLinkedAreaDlg> CreateScLinkedAreaDlg(weld::Window* pParent) = 0;
virtual VclPtr<AbstractScMetricInputDlg> CreateScMetricInputDlg(weld::Window* pParent,
......
......@@ -129,7 +129,10 @@ short AbstractScInsertTableDlg_Impl::Execute()
return m_xDlg->execute();
}
IMPL_ABSTDLG_BASE(AbstractScSelEntryDlg_Impl);
short AbstractScSelEntryDlg_Impl::Execute()
{
return m_xDlg->run();
}
short AbstractScMetricInputDlg_Impl::Execute()
{
......@@ -443,7 +446,7 @@ const OUString* AbstractScInsertTableDlg_Impl::GetNextTable( sal_uInt16* pN )
OUString AbstractScSelEntryDlg_Impl::GetSelectedEntry() const
{
return pDlg->GetSelectedEntry();
return m_xDlg->GetSelectedEntry();
}
void AbstractScLinkedAreaDlg_Impl::InitFromOldLink( const OUString& rFile, const OUString& rFilter,
......@@ -777,11 +780,10 @@ VclPtr<AbstractScInsertTableDlg> ScAbstractDialogFactory_Impl::CreateScInsertTab
return VclPtr<AbstractScInsertTableDlg_Impl>::Create(new ScInsertTableDlg(pParent, rViewData,nTabCount, bFromFile));
}
VclPtr<AbstractScSelEntryDlg> ScAbstractDialogFactory_Impl::CreateScSelEntryDlg ( vcl::Window* pParent,
const std::vector<OUString> &rEntryList )
VclPtr<AbstractScSelEntryDlg> ScAbstractDialogFactory_Impl::CreateScSelEntryDlg(weld::Window* pParent,
const std::vector<OUString> &rEntryList)
{
VclPtr<ScSelEntryDlg> pDlg = VclPtr<ScSelEntryDlg>::Create( pParent, rEntryList );
return VclPtr<AbstractScSelEntryDlg_Impl>::Create( pDlg );
return VclPtr<AbstractScSelEntryDlg_Impl>::Create(new ScSelEntryDlg(pParent, rEntryList));
}
VclPtr<AbstractScLinkedAreaDlg> ScAbstractDialogFactory_Impl::CreateScLinkedAreaDlg(weld::Window* pParent)
......
......@@ -288,7 +288,13 @@ public:
class AbstractScSelEntryDlg_Impl : public AbstractScSelEntryDlg
{
DECL_ABSTDLG_BASE( AbstractScSelEntryDlg_Impl, ScSelEntryDlg )
std::unique_ptr<ScSelEntryDlg> m_xDlg;
public:
explicit AbstractScSelEntryDlg_Impl(ScSelEntryDlg* p)
: m_xDlg(p)
{
}
virtual short Execute() override;
virtual OUString GetSelectedEntry() const override;
};
......@@ -535,8 +541,7 @@ public:
virtual VclPtr<AbstractScInsertTableDlg> CreateScInsertTableDlg(weld::Window* pParent, ScViewData& rViewData,
SCTAB nTabCount, bool bFromFile) override;
virtual VclPtr<AbstractScSelEntryDlg> CreateScSelEntryDlg ( vcl::Window* pParent,
const std::vector<OUString> &rEntryList ) override;
virtual VclPtr<AbstractScSelEntryDlg> CreateScSelEntryDlg(weld::Window* pParent, const std::vector<OUString> &rEntryList) override;
virtual VclPtr<AbstractScLinkedAreaDlg> CreateScLinkedAreaDlg(weld::Window* pParent) override;
......
......@@ -20,24 +20,18 @@
#ifndef INCLUDED_SC_SOURCE_UI_INC_LBSELDLG_HXX
#define INCLUDED_SC_SOURCE_UI_INC_LBSELDLG_HXX
#include <vcl/fixed.hxx>
#include <vcl/lstbox.hxx>
#include <vcl/weld.hxx>
#include <vcl/button.hxx>
#include <vcl/dialog.hxx>
class ScSelEntryDlg : public ModalDialog
class ScSelEntryDlg : public weld::GenericDialogController
{
private:
VclPtr<ListBox> m_pLb;
std::unique_ptr<weld::TreeView> m_xLb;
DECL_LINK( DblClkHdl, ListBox&, void );
DECL_LINK(DblClkHdl, weld::TreeView&, void);
public:
ScSelEntryDlg(vcl::Window* pParent, const std::vector<OUString> &rEntryList);
ScSelEntryDlg(weld::Window* pParent, const std::vector<OUString> &rEntryList);
virtual ~ScSelEntryDlg() override;
virtual void dispose() override;
OUString GetSelectedEntry() const;
};
......
......@@ -21,42 +21,34 @@
#include <lbseldlg.hxx>
ScSelEntryDlg::ScSelEntryDlg(vcl::Window* pParent, const std::vector<OUString> &rEntryList)
: ModalDialog(pParent, "SelectRangeDialog", "modules/scalc/ui/selectrange.ui")
ScSelEntryDlg::ScSelEntryDlg(weld::Window* pParent, const std::vector<OUString> &rEntryList)
: GenericDialogController(pParent, "modules/scalc/ui/selectrange.ui", "SelectRangeDialog")
, m_xLb(m_xBuilder->weld_tree_view("treeview"))
{
get(m_pLb, "treeview");
m_pLb->SetDropDownLineCount(8);
m_pLb->set_width_request(m_pLb->approximate_char_width() * 32);
m_pLb->SetDoubleClickHdl( LINK( this, ScSelEntryDlg, DblClkHdl ) );
m_xLb->set_size_request(m_xLb->get_approximate_digit_width() * 32,
m_xLb->get_height_rows(8));
m_xLb->connect_row_activated(LINK(this, ScSelEntryDlg, DblClkHdl));
std::vector<OUString>::const_iterator pIter;
for ( pIter = rEntryList.begin(); pIter != rEntryList.end(); ++pIter )
m_pLb->InsertEntry(*pIter);
for (pIter = rEntryList.begin(); pIter != rEntryList.end(); ++pIter)
m_xLb->append_text(*pIter);
if ( m_pLb->GetEntryCount() > 0 )
m_pLb->SelectEntryPos( 0 );
if (m_xLb->n_children() > 0)
m_xLb->select(0);
}
ScSelEntryDlg::~ScSelEntryDlg()
{
disposeOnce();
}
void ScSelEntryDlg::dispose()
{
m_pLb.clear();
ModalDialog::dispose();
}
OUString ScSelEntryDlg::GetSelectedEntry() const
{
return m_pLb->GetSelectedEntry();
return m_xLb->get_selected_text();
}
IMPL_LINK_NOARG(ScSelEntryDlg, DblClkHdl, ListBox&, void)
IMPL_LINK_NOARG(ScSelEntryDlg, DblClkHdl, weld::TreeView&, void)
{
EndDialog( RET_OK );
m_xDialog->response(RET_OK);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -740,8 +740,7 @@ void ScCellShell::ExecuteDB( SfxRequest& rReq )
ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
OSL_ENSURE(pFact, "ScAbstractFactory create fail!");
ScopedVclPtr<AbstractScSelEntryDlg> pDlg(pFact->CreateScSelEntryDlg( pTabViewShell->GetDialogParent(),
aList ));
ScopedVclPtr<AbstractScSelEntryDlg> pDlg(pFact->CreateScSelEntryDlg(pTabViewShell->GetFrameWeld(), aList));
OSL_ENSURE(pDlg, "Dialog create fail!");
if ( pDlg->Execute() == RET_OK )
{
......
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.22.1 -->
<interface domain="sc">
<!-- interface-requires gtk+ 3.0 -->
<requires lib="gtk+" version="3.0"/>
<object class="GtkListStore" id="liststore1">
<columns>
<!-- column-name text -->
<column type="gchararray"/>
<!-- column-name id -->
<column type="gchararray"/>
</columns>
</object>
<object class="GtkDialog" id="SelectRangeDialog">
<property name="can_focus">False</property>
<property name="border_width">6</property>
<property name="title" translatable="yes" context="selectrange|SelectRangeDialog">Select Database Range</property>
<property name="modal">True</property>
<property name="default_width">0</property>
<property name="default_height">0</property>
<property name="type_hint">dialog</property>
<child>
<placeholder/>
</child>
<child internal-child="vbox">
<object class="GtkBox" id="SelectRange">
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">12</property>
<child internal-child="action_area">
<object class="GtkButtonBox" id="dialog-action_area1">
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="layout_style">start</property>
<property name="layout_style">end</property>
<child>
<object class="GtkButton" id="ok">
<property name="label">gtk-ok</property>
......@@ -57,6 +72,7 @@
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
<property name="secondary">True</property>
</packing>
</child>
</object>
......@@ -84,7 +100,7 @@
<property name="top_padding">6</property>
<property name="left_padding">12</property>
<child>
<object class="GtkScrolledWindow" id="scrolledwindow1">
<object class="GtkScrolledWindow">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
......@@ -94,6 +110,26 @@
<object class="GtkTreeView" id="treeview">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="model">liststore1</property>
<property name="headers_visible">False</property>
<property name="headers_clickable">False</property>
<property name="search_column">0</property>
<property name="show_expanders">False</property>
<child internal-child="selection">
<object class="GtkTreeSelection" id="treeview-selection1"/>
</child>
<child>
<object class="GtkTreeViewColumn" id="treeviewcolumn1">
<child>
<object class="GtkCellRendererText" id="cellrenderertext1"/>
<attributes>
<attribute name="text">0</attribute>
</attributes>
</child>
</object>
</child>
</object>
</child>
</object>
......
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