summaryrefslogtreecommitdiff
path: root/dbaccess/source
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2018-10-23 21:09:47 +0100
committerCaolán McNamara <caolanm@redhat.com>2018-10-24 17:07:39 +0200
commitfad334d72d9f49906322bd1bc3769ce6f565c3b5 (patch)
tree14e878bc705a09bc8e287187d741475b0a662d60 /dbaccess/source
parent9dc5234d36ebcafca36aece80b6a9b59da287cda (diff)
weld ODbaseDetailsPage
Change-Id: Ia0d953ee2d4a4f35ba6f59bb6bd6b1a04ed25f63 Reviewed-on: https://gerrit.libreoffice.org/62284 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'dbaccess/source')
-rw-r--r--dbaccess/source/ui/control/charsetlistbox.cxx40
-rw-r--r--dbaccess/source/ui/dlg/detailpages.cxx149
-rw-r--r--dbaccess/source/ui/dlg/detailpages.hxx56
-rw-r--r--dbaccess/source/ui/inc/charsetlistbox.hxx19
4 files changed, 232 insertions, 32 deletions
diff --git a/dbaccess/source/ui/control/charsetlistbox.cxx b/dbaccess/source/ui/control/charsetlistbox.cxx
index 7cc4b15a9212..9ea9f7f70c65 100644
--- a/dbaccess/source/ui/control/charsetlistbox.cxx
+++ b/dbaccess/source/ui/control/charsetlistbox.cxx
@@ -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: */
diff --git a/dbaccess/source/ui/dlg/detailpages.cxx b/dbaccess/source/ui/dlg/detailpages.cxx
index 332f0ab2f5ac..6c9c8e6d10ff 100644
--- a/dbaccess/source/ui/dlg/detailpages.cxx
+++ b/dbaccess/source/ui/dlg/detailpages.cxx
@@ -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();
}
diff --git a/dbaccess/source/ui/dlg/detailpages.hxx b/dbaccess/source/ui/dlg/detailpages.hxx
index 4d008efbede1..a998a4dbd696 100644
--- a/dbaccess/source/ui/dlg/detailpages.hxx
+++ b/dbaccess/source/ui/dlg/detailpages.hxx
@@ -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
diff --git a/dbaccess/source/ui/inc/charsetlistbox.hxx b/dbaccess/source/ui/inc/charsetlistbox.hxx
index 5a965f2fc205..b97145e862b9 100644
--- a/dbaccess/source/ui/inc/charsetlistbox.hxx
+++ b/dbaccess/source/ui/inc/charsetlistbox.hxx
@@ -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