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

weld ODbaseDetailsPage

Change-Id: Ia0d953ee2d4a4f35ba6f59bb6bd6b1a04ed25f63
Reviewed-on: https://gerrit.libreoffice.org/62284
Tested-by: Jenkins
Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst 9dc5234d
......@@ -84,6 +84,46 @@ namespace dbaui
return bChangedSomething;
}
DBCharSetListBox::DBCharSetListBox(std::unique_ptr<weld::ComboBox> xControl)
: m_xControl(std::move(xControl))
{
for (auto const& charset : m_aCharSets)
{
m_xControl->append_text(charset.getDisplayName());
}
}
void DBCharSetListBox::SelectEntryByIanaName( const OUString& _rIanaName )
{
OCharsetDisplay::const_iterator aFind = m_aCharSets.findIanaName( _rIanaName );
if (aFind == m_aCharSets.end())
{
OSL_FAIL( "CharSetListBox::SelectEntryByIanaName: unknown charset falling back to system language!" );
aFind = m_aCharSets.findEncoding( RTL_TEXTENCODING_DONTKNOW );
}
if (aFind == m_aCharSets.end())
m_xControl->set_active(-1);
else
m_xControl->set_active_text((*aFind).getDisplayName());
}
bool DBCharSetListBox::StoreSelectedCharSet( SfxItemSet& _rSet, const sal_uInt16 _nItemId )
{
bool bChangedSomething = false;
if (m_xControl->get_value_changed_from_saved())
{
OCharsetDisplay::const_iterator aFind = m_aCharSets.findDisplayName(m_xControl->get_active_text());
OSL_ENSURE( aFind != m_aCharSets.end(), "CharSetListBox::StoreSelectedCharSet: could not translate the selected character set!" );
if ( aFind != m_aCharSets.end() )
{
_rSet.Put( SfxStringItem( _nItemId, (*aFind).getIanaName() ) );
bChangedSomething = true;
}
}
return bChangedSomething;
}
} // namespace dbaui
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -183,16 +183,15 @@ namespace dbaui
}
// ODbaseDetailsPage
ODbaseDetailsPage::ODbaseDetailsPage( vcl::Window* pParent, const SfxItemSet& _rCoreAttrs )
:OCommonBehaviourTabPage(pParent, "DbasePage", "dbaccess/ui/dbasepage.ui", _rCoreAttrs, OCommonBehaviourTabPageFlags::UseCharset)
ODbaseDetailsPage::ODbaseDetailsPage(TabPageParent pParent, const SfxItemSet& _rCoreAttrs)
: DBOCommonBehaviourTabPage(pParent, "dbaccess/ui/dbasepage.ui", "DbasePage",
_rCoreAttrs, OCommonBehaviourTabPageFlags::UseCharset)
, m_xShowDeleted(m_xBuilder->weld_check_button("showDelRowsCheckbutton"))
, m_xFT_Message(m_xBuilder->weld_label("specMessageLabel"))
, m_xIndexes(m_xBuilder->weld_button("indiciesButton"))
{
get(m_pShowDeleted, "showDelRowsCheckbutton");
get(m_pFT_Message, "specMessageLabel");
get(m_pIndexes, "indiciesButton");
set_height_request(300);
m_pIndexes->SetClickHdl(LINK(this, ODbaseDetailsPage, OnButtonClicked));
m_pShowDeleted->SetClickHdl(LINK(this, ODbaseDetailsPage, OnButtonClicked));
m_xIndexes->connect_clicked(LINK(this, ODbaseDetailsPage, OnButtonClicked));
m_xShowDeleted->connect_clicked(LINK(this, ODbaseDetailsPage, OnButtonClicked));
}
ODbaseDetailsPage::~ODbaseDetailsPage()
......@@ -200,17 +199,119 @@ namespace dbaui
disposeOnce();
}
void ODbaseDetailsPage::dispose()
DBOCommonBehaviourTabPage::DBOCommonBehaviourTabPage(TabPageParent pParent,
const OUString& rUIXMLDescription, const OString& rId, const SfxItemSet& rCoreAttrs,
OCommonBehaviourTabPageFlags nControlFlags)
: OGenericAdministrationPage(pParent, rUIXMLDescription, rId, rCoreAttrs)
, m_nControlFlags(nControlFlags)
{
m_pShowDeleted.clear();
m_pFT_Message.clear();
m_pIndexes.clear();
OCommonBehaviourTabPage::dispose();
if (m_nControlFlags & OCommonBehaviourTabPageFlags::UseOptions)
{
m_xOptionsLabel = m_xBuilder->weld_label("optionslabel");
m_xOptionsLabel->show();
m_xOptions = m_xBuilder->weld_entry("options");
m_xOptions->show();
m_xOptions->connect_changed(LINK(this,OGenericAdministrationPage,OnControlEntryModifyHdl));
}
if (m_nControlFlags & OCommonBehaviourTabPageFlags::UseCharset)
{
m_xDataConvertLabel = m_xBuilder->weld_label("charsetheader");
m_xDataConvertLabel->show();
m_xCharsetLabel = m_xBuilder->weld_label("charsetlabel");
m_xCharsetLabel->show();
m_xCharset.reset(new DBCharSetListBox(m_xBuilder->weld_combo_box("charset")));
m_xCharset->show();
m_xCharset->connect_changed(LINK(this, DBOCommonBehaviourTabPage, CharsetSelectHdl));
}
}
IMPL_LINK_NOARG(DBOCommonBehaviourTabPage, CharsetSelectHdl, weld::ComboBox&, void)
{
callModifiedHdl();
}
DBOCommonBehaviourTabPage::~DBOCommonBehaviourTabPage()
{
disposeOnce();
}
void DBOCommonBehaviourTabPage::dispose()
{
m_xCharset.reset();
OGenericAdministrationPage::dispose();
}
void DBOCommonBehaviourTabPage::fillWindows(std::vector< std::unique_ptr<ISaveValueWrapper> >& _rControlList)
{
if (m_nControlFlags & OCommonBehaviourTabPageFlags::UseOptions)
{
_rControlList.emplace_back(new ODisableWidgetWrapper<weld::Label>(m_xOptionsLabel.get()));
}
if (m_nControlFlags & OCommonBehaviourTabPageFlags::UseCharset)
{
_rControlList.emplace_back(new ODisableWidgetWrapper<weld::Label>(m_xCharsetLabel.get()));
}
}
void DBOCommonBehaviourTabPage::fillControls(std::vector< std::unique_ptr<ISaveValueWrapper> >& _rControlList)
{
if (m_nControlFlags & OCommonBehaviourTabPageFlags::UseOptions)
_rControlList.emplace_back(new OSaveValueWidgetWrapper<weld::Entry>(m_xOptions.get()));
if (m_nControlFlags & OCommonBehaviourTabPageFlags::UseCharset)
_rControlList.emplace_back(new OSaveValueWidgetWrapper<weld::ComboBox>(m_xCharset->get_widget()));
}
void DBOCommonBehaviourTabPage::implInitControls(const SfxItemSet& _rSet, bool _bSaveValue)
{
// check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
bool bValid, bReadonly;
getFlags(_rSet, bValid, bReadonly);
// collect the items
const SfxStringItem* pOptionsItem = _rSet.GetItem<SfxStringItem>(DSID_ADDITIONALOPTIONS);
const SfxStringItem* pCharsetItem = _rSet.GetItem<SfxStringItem>(DSID_CHARSET);
// forward the values to the controls
if (bValid)
{
if (m_nControlFlags & OCommonBehaviourTabPageFlags::UseOptions)
{
m_xOptions->set_text(pOptionsItem->GetValue());
m_xOptions->save_value();
}
if (m_nControlFlags & OCommonBehaviourTabPageFlags::UseCharset)
{
m_xCharset->SelectEntryByIanaName( pCharsetItem->GetValue() );
}
}
OGenericAdministrationPage::implInitControls(_rSet, _bSaveValue);
}
VclPtr<SfxTabPage> ODriversSettings::CreateDbase( TabPageParent pParent, const SfxItemSet* _rAttrSet )
bool DBOCommonBehaviourTabPage::FillItemSet(SfxItemSet* _rSet)
{
return VclPtr<ODbaseDetailsPage>::Create( pParent.pParent, *_rAttrSet );
bool bChangedSomething = false;
if (m_nControlFlags & OCommonBehaviourTabPageFlags::UseOptions)
{
fillString(*_rSet,m_xOptions.get(),DSID_ADDITIONALOPTIONS,bChangedSomething);
}
if (m_nControlFlags & OCommonBehaviourTabPageFlags::UseCharset)
{
if ( m_xCharset->StoreSelectedCharSet( *_rSet, DSID_CHARSET ) )
bChangedSomething = true;
}
return bChangedSomething;
}
VclPtr<SfxTabPage> ODriversSettings::CreateDbase(TabPageParent pParent, const SfxItemSet* _rAttrSet)
{
return VclPtr<ODbaseDetailsPage>::Create(pParent, *_rAttrSet);
}
void ODbaseDetailsPage::implInitControls(const SfxItemSet& _rSet, bool _bSaveValue)
......@@ -231,31 +332,31 @@ namespace dbaui
if ( bValid )
{
m_pShowDeleted->Check( pDeletedItem->GetValue() );
m_pFT_Message->Show(m_pShowDeleted->IsChecked());
m_xShowDeleted->set_active(pDeletedItem->GetValue());
m_xFT_Message->show(m_xShowDeleted->get_active());
}
OCommonBehaviourTabPage::implInitControls(_rSet, _bSaveValue);
DBOCommonBehaviourTabPage::implInitControls(_rSet, _bSaveValue);
}
bool ODbaseDetailsPage::FillItemSet( SfxItemSet* _rSet )
{
bool bChangedSomething = OCommonBehaviourTabPage::FillItemSet(_rSet);
bool bChangedSomething = DBOCommonBehaviourTabPage::FillItemSet(_rSet);
fillBool(*_rSet,m_pShowDeleted,DSID_SHOWDELETEDROWS,bChangedSomething);
fillBool(*_rSet, m_xShowDeleted.get(), DSID_SHOWDELETEDROWS, false, bChangedSomething);
return bChangedSomething;
}
IMPL_LINK( ODbaseDetailsPage, OnButtonClicked, Button*, pButton, void )
IMPL_LINK(ODbaseDetailsPage, OnButtonClicked, weld::Button&, rButton, void)
{
if (m_pIndexes == pButton)
if (m_xIndexes.get() == &rButton)
{
ODbaseIndexDialog aIndexDialog(GetDialogFrameWeld(), m_sDsn);
aIndexDialog.run();
}
else
{
m_pFT_Message->Show(m_pShowDeleted->IsChecked());
m_xFT_Message->show(m_xShowDeleted->get_active());
// it was one of the checkboxes -> we count as modified from now on
callModifiedHdl();
}
......
......@@ -90,27 +90,67 @@ namespace dbaui
DECL_LINK(CharsetSelectHdl, ListBox&, void);
};
class DBOCommonBehaviourTabPage : public OGenericAdministrationPage
{
protected:
OCommonBehaviourTabPageFlags m_nControlFlags;
std::unique_ptr<weld::Label> m_xOptionsLabel;
std::unique_ptr<weld::Entry> m_xOptions;
std::unique_ptr<weld::Label> m_xDataConvertLabel;
std::unique_ptr<weld::Label> m_xCharsetLabel;
std::unique_ptr<DBCharSetListBox> m_xCharset;
std::unique_ptr<weld::CheckButton> m_xAutoRetrievingEnabled;
std::unique_ptr<weld::Label> m_xAutoIncrementLabel;
std::unique_ptr<weld::Entry> m_xAutoIncrement;
std::unique_ptr<weld::Label> m_xAutoRetrievingLabel;
std::unique_ptr<weld::Entry> m_xAutoRetrieving;
public:
virtual bool FillItemSet (SfxItemSet* _rCoreAttrs) override;
DBOCommonBehaviourTabPage(TabPageParent pParent, const OUString& rUIXMLDescription, const OString& rId, const SfxItemSet& _rCoreAttrs, OCommonBehaviourTabPageFlags nControlFlags);
protected:
virtual ~DBOCommonBehaviourTabPage() override;
virtual void dispose() override;
// subclasses must override this, but it isn't pure virtual
virtual void implInitControls(const SfxItemSet& _rSet, bool _bSaveValue) override;
// <method>OGenericAdministrationPage::fillControls</method>
virtual void fillControls(std::vector< std::unique_ptr<ISaveValueWrapper> >& _rControlList) override;
// <method>OGenericAdministrationPage::fillWindows</method>
virtual void fillWindows(std::vector< std::unique_ptr<ISaveValueWrapper> >& _rControlList) override;
private:
DECL_LINK(CharsetSelectHdl, weld::ComboBox&, void);
};
// ODbaseDetailsPage
class ODbaseDetailsPage : public OCommonBehaviourTabPage
class ODbaseDetailsPage : public DBOCommonBehaviourTabPage
{
public:
virtual bool FillItemSet ( SfxItemSet* _rCoreAttrs ) override;
ODbaseDetailsPage(vcl::Window* pParent, const SfxItemSet& _rCoreAttrs);
ODbaseDetailsPage(TabPageParent pParent, const SfxItemSet& _rCoreAttrs);
virtual ~ODbaseDetailsPage() override;
virtual void dispose() override;
private:
VclPtr<CheckBox> m_pShowDeleted;
VclPtr<FixedText> m_pFT_Message;
VclPtr<PushButton> m_pIndexes;
OUString m_sDsn;
std::unique_ptr<weld::CheckButton> m_xShowDeleted;
std::unique_ptr<weld::Label> m_xFT_Message;
std::unique_ptr<weld::Button> m_xIndexes;
protected:
virtual void implInitControls(const SfxItemSet& _rSet, bool _bSaveValue) override;
private:
DECL_LINK( OnButtonClicked, Button *, void );
DECL_LINK(OnButtonClicked, weld::Button&, void);
};
// OAdoDetailsPage
......
......@@ -23,6 +23,7 @@
#include "charsets.hxx"
#include <vcl/lstbox.hxx>
#include <vcl/weld.hxx>
class SfxItemSet;
......@@ -42,6 +43,24 @@ namespace dbaui
OCharsetDisplay m_aCharSets;
};
// CharSetListBox
class DBCharSetListBox
{
public:
DBCharSetListBox(std::unique_ptr<weld::ComboBox> xControl);
void SelectEntryByIanaName( const OUString& _rIanaName );
bool StoreSelectedCharSet( SfxItemSet& _rSet, const sal_uInt16 _nItemId );
weld::ComboBox* get_widget() { return m_xControl.get(); }
void connect_changed(const Link<weld::ComboBox&, void>& rLink) { m_xControl->connect_changed(rLink); }
void show() { m_xControl->show(); }
private:
OCharsetDisplay m_aCharSets;
std::unique_ptr<weld::ComboBox> m_xControl;
};
} // namespace dbaui
#endif // INCLUDED_DBACCESS_SOURCE_UI_INC_CHARSETLISTBOX_HXX
......
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.18.3 -->
<!-- Generated with glade 3.22.1 -->
<interface domain="dba">
<requires lib="gtk+" version="3.18"/>
<requires lib="LibreOffice" version="1.0"/>
<object class="GtkBox" id="DbasePage">
<property name="visible">True</property>
<property name="can_focus">False</property>
......@@ -46,7 +45,7 @@
</packing>
</child>
<child>
<object class="dbulo-CharSetListBox" id="charset">
<object class="GtkComboBoxText" id="charset">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
......@@ -119,10 +118,11 @@
<object class="GtkLabel" id="specMessageLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes" context="dbasepage|specMessageLabel">Note: When deleted, and thus inactive, records are displayed, you will not be able to delete records from the data source.</property>
<property name="wrap">True</property>
<property name="width_chars">60</property>
<property name="max_width_chars">60</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="expand">False</property>
......
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