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

weld DBChangeDialog_Impl

Change-Id: I8d5330f07e4c76c6cdf51a878949bcac9ad3e92e
Reviewed-on: https://gerrit.libreoffice.org/67915
Tested-by: Jenkins
Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst 81c9c3f2
...@@ -448,41 +448,35 @@ IMPL_LINK_NOARG(MappingDialog_Impl, OkHdl, Button*, void) ...@@ -448,41 +448,35 @@ IMPL_LINK_NOARG(MappingDialog_Impl, OkHdl, Button*, void)
EndDialog(bModified ? RET_OK : RET_CANCEL); EndDialog(bModified ? RET_OK : RET_CANCEL);
} }
class DBChangeDialog_Impl : public ModalDialog class DBChangeDialog_Impl : public weld::GenericDialogController
{ {
VclPtr<ListBox> m_pSelectionLB; DBChangeDialogConfig_Impl aConfig;
DBChangeDialogConfig_Impl aConfig;
BibDataManager* pDatMan; BibDataManager* pDatMan;
DECL_LINK(DoubleClickHdl, ListBox&, void); std::unique_ptr<weld::TreeView> m_xSelectionLB;
DECL_LINK(DoubleClickHdl, weld::TreeView&, void);
public: public:
DBChangeDialog_Impl(vcl::Window* pParent, BibDataManager* pMan ); DBChangeDialog_Impl(weld::Window* pParent, BibDataManager* pMan);
virtual ~DBChangeDialog_Impl() override;
virtual void dispose() override;
OUString GetCurrentURL()const; OUString GetCurrentURL()const;
}; };
DBChangeDialog_Impl::DBChangeDialog_Impl(vcl::Window* pParent, BibDataManager* pMan ) DBChangeDialog_Impl::DBChangeDialog_Impl(weld::Window* pParent, BibDataManager* pMan )
: ModalDialog(pParent, "ChooseDataSourceDialog", : GenericDialogController(pParent, "modules/sbibliography/ui/choosedatasourcedialog.ui", "ChooseDataSourceDialog")
"modules/sbibliography/ui/choosedatasourcedialog.ui") , pDatMan(pMan)
, , m_xSelectionLB(m_xBuilder->weld_tree_view("treeview"))
pDatMan(pMan)
{ {
get(m_pSelectionLB, "treeview"); m_xSelectionLB->set_size_request(-1, m_xSelectionLB->get_height_rows(6));
m_pSelectionLB->set_height_request(m_pSelectionLB->GetTextHeight() * 6); m_xSelectionLB->connect_row_activated(LINK(this, DBChangeDialog_Impl, DoubleClickHdl));
m_xSelectionLB->make_sorted();
m_pSelectionLB->SetStyle(m_pSelectionLB->GetStyle() | WB_SORT);
m_pSelectionLB->SetDoubleClickHdl( LINK(this, DBChangeDialog_Impl, DoubleClickHdl));
try try
{ {
OUString sActiveSource = pDatMan->getActiveDataSource(); OUString sActiveSource = pDatMan->getActiveDataSource();
for (const OUString& rSourceName : aConfig.GetDataSourceNames()) for (const OUString& rSourceName : aConfig.GetDataSourceNames())
m_pSelectionLB->InsertEntry(rSourceName); m_xSelectionLB->append_text(rSourceName);
m_xSelectionLB->select_text(sActiveSource);
m_pSelectionLB->SelectEntry(sActiveSource);
} }
catch (const Exception& e) catch (const Exception& e)
{ {
...@@ -492,25 +486,14 @@ DBChangeDialog_Impl::DBChangeDialog_Impl(vcl::Window* pParent, BibDataManager* p ...@@ -492,25 +486,14 @@ DBChangeDialog_Impl::DBChangeDialog_Impl(vcl::Window* pParent, BibDataManager* p
} }
} }
IMPL_LINK_NOARG(DBChangeDialog_Impl, DoubleClickHdl, ListBox&, void) IMPL_LINK_NOARG(DBChangeDialog_Impl, DoubleClickHdl, weld::TreeView&, void)
{
EndDialog(RET_OK);
}
DBChangeDialog_Impl::~DBChangeDialog_Impl()
{ {
disposeOnce(); m_xDialog->response(RET_OK);
}
void DBChangeDialog_Impl::dispose()
{
m_pSelectionLB.clear();
ModalDialog::dispose();
} }
OUString DBChangeDialog_Impl::GetCurrentURL()const OUString DBChangeDialog_Impl::GetCurrentURL()const
{ {
return m_pSelectionLB->GetSelectedEntry(); return m_xSelectionLB->get_selected_text();
} }
// XDispatchProvider // XDispatchProvider
...@@ -1483,13 +1466,13 @@ void BibDataManager::CreateMappingDialog(vcl::Window* pParent) ...@@ -1483,13 +1466,13 @@ void BibDataManager::CreateMappingDialog(vcl::Window* pParent)
} }
} }
OUString BibDataManager::CreateDBChangeDialog(vcl::Window* pParent) OUString BibDataManager::CreateDBChangeDialog(weld::Window* pParent)
{ {
OUString uRet; OUString uRet;
VclPtrInstance< DBChangeDialog_Impl > pDlg(pParent, this ); DBChangeDialog_Impl aDlg(pParent, this);
if(RET_OK == pDlg->Execute()) if (aDlg.run() == RET_OK)
{ {
OUString sNewURL = pDlg->GetCurrentURL(); OUString sNewURL = aDlg.GetCurrentURL();
if(sNewURL != getActiveDataSource()) if(sNewURL != getActiveDataSource())
{ {
uRet = sNewURL; uRet = sNewURL;
......
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
#include <vcl/vclptr.hxx> #include <vcl/vclptr.hxx>
namespace vcl { class Window; } namespace vcl { class Window; }
namespace weld { class Window; }
namespace bib namespace bib
{ {
...@@ -157,7 +157,7 @@ public: ...@@ -157,7 +157,7 @@ public:
bool bForceListBox); bool bForceListBox);
void CreateMappingDialog(vcl::Window* pParent); void CreateMappingDialog(vcl::Window* pParent);
OUString CreateDBChangeDialog(vcl::Window* pParent); OUString CreateDBChangeDialog(weld::Window* pParent);
void DispatchDBChangeDialog(); void DispatchDBChangeDialog();
......
...@@ -385,7 +385,7 @@ void BibFrameController_Impl::dispatch(const util::URL& _rURL, const uno::Sequen ...@@ -385,7 +385,7 @@ void BibFrameController_Impl::dispatch(const util::URL& _rURL, const uno::Sequen
} }
else if(aCommand == "Bib/sdbsource") else if(aCommand == "Bib/sdbsource")
{ {
OUString aURL = m_xDatMan->CreateDBChangeDialog(pParent); OUString aURL = m_xDatMan->CreateDBChangeDialog(pParent ? pParent->GetFrameWeld() : nullptr);
if(!aURL.isEmpty()) if(!aURL.isEmpty())
{ {
try try
......
...@@ -373,7 +373,8 @@ void BibToolBar::Click() ...@@ -373,7 +373,8 @@ void BibToolBar::Click()
{ {
if(pDatMan) if(pDatMan)
{ {
OUString sNew = pDatMan->CreateDBChangeDialog(GetParent()); vcl::Window* pWin = GetParent();
OUString sNew = pDatMan->CreateDBChangeDialog(pWin ? pWin->GetFrameWeld() : nullptr);
if(!sNew.isEmpty()) if(!sNew.isEmpty())
pDatMan->setActiveDataSource(sNew); pDatMan->setActiveDataSource(sNew);
} }
......
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.16.1 --> <!-- Generated with glade 3.22.1 -->
<interface domain="pcr"> <interface domain="pcr">
<requires lib="gtk+" version="3.18"/> <requires lib="gtk+" version="3.18"/>
<object class="GtkTreeStore" id="liststore2">
<columns>
<!-- column-name text -->
<column type="gchararray"/>
<!-- column-name id -->
<column type="gchararray"/>
</columns>
</object>
<object class="GtkDialog" id="ChooseDataSourceDialog"> <object class="GtkDialog" id="ChooseDataSourceDialog">
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="border_width">6</property> <property name="border_width">6</property>
<property name="title" translatable="yes" context="choosedatasourcedialog|ChooseDataSourceDialog">Choose Data Source</property> <property name="title" translatable="yes" context="choosedatasourcedialog|ChooseDataSourceDialog">Choose Data Source</property>
<property name="modal">True</property>
<property name="default_width">0</property>
<property name="default_height">0</property>
<property name="type_hint">dialog</property> <property name="type_hint">dialog</property>
<child>
<placeholder/>
</child>
<child internal-child="vbox"> <child internal-child="vbox">
<object class="GtkBox" id="dialog-vbox1"> <object class="GtkBox" id="dialog-vbox1">
<property name="can_focus">False</property> <property name="can_focus">False</property>
...@@ -71,14 +85,39 @@ ...@@ -71,14 +85,39 @@
<property name="top_padding">6</property> <property name="top_padding">6</property>
<property name="left_padding">12</property> <property name="left_padding">12</property>
<child> <child>
<object class="GtkTreeView" id="treeview:border"> <object class="GtkScrolledWindow">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="hexpand">True</property> <property name="hexpand">True</property>
<property name="vexpand">True</property> <property name="vexpand">True</property>
<property name="show_expanders">False</property> <property name="shadow_type">in</property>
<child internal-child="selection"> <child>
<object class="GtkTreeSelection" id="treeview-selection1"/> <object class="GtkTreeView" id="treeview">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="model">liststore2</property>
<property name="headers_visible">False</property>
<property name="search_column">1</property>
<property name="show_expanders">False</property>
<child internal-child="selection">
<object class="GtkTreeSelection" id="Macro Library List-selection2"/>
</child>
<child>
<object class="GtkTreeViewColumn" id="treeviewcolumn5">
<property name="resizable">True</property>
<property name="spacing">6</property>
<child>
<object class="GtkCellRendererText" id="cellrenderer4"/>
<attributes>
<attribute name="text">0</attribute>
</attributes>
</child>
</object>
</child>
</object>
</child> </child>
</object> </object>
</child> </child>
......
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