From e0218ed419378d3c31978bb6765f41e09371dc4f Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Thu, 26 Sep 2019 11:58:15 +0100 Subject: weld ORelationDialog and DlgQryJoin MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I15c0745d387e491dd05e14949d744d0a27a8dd49 Reviewed-on: https://gerrit.libreoffice.org/79600 Tested-by: Jenkins Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara --- dbaccess/source/ui/control/RelationControl.cxx | 147 +++++++++++---------- dbaccess/source/ui/dlg/RelationDlg.cxx | 92 ++++++------- dbaccess/source/ui/inc/RelationControl.hxx | 17 +-- dbaccess/source/ui/inc/RelationDlg.hxx | 42 +++--- dbaccess/source/ui/querydesign/QueryTableView.cxx | 6 +- dbaccess/source/ui/querydesign/querydlg.cxx | 130 +++++++++--------- dbaccess/source/ui/querydesign/querydlg.hxx | 29 ++-- .../source/ui/relationdesign/RelationTableView.cxx | 12 +- 8 files changed, 220 insertions(+), 255 deletions(-) (limited to 'dbaccess/source/ui') diff --git a/dbaccess/source/ui/control/RelationControl.cxx b/dbaccess/source/ui/control/RelationControl.cxx index a9ae4dff51b0..959aee714949 100644 --- a/dbaccess/source/ui/control/RelationControl.cxx +++ b/dbaccess/source/ui/control/RelationControl.cxx @@ -22,14 +22,15 @@ #include #include #include -#include +#include #include #include #include +#include +#include #include -#include #include -#include +#include #include #include #include @@ -75,7 +76,7 @@ namespace dbaui */ sal_uInt16 getColumnIdent( sal_uInt16 _nColId ) const; public: - explicit ORelationControl(vcl::Window *pParent); + explicit ORelationControl(css::uno::Reference& rParent); void SetController(OTableListBoxControl* pController) { m_pBoxControl = pController; @@ -125,8 +126,8 @@ namespace dbaui }; // class ORelationControl - ORelationControl::ORelationControl(vcl::Window *pParent) - : EditBrowseBox(pParent, + ORelationControl::ORelationControl(css::uno::Reference& rParent) + : EditBrowseBox(VCLUnoHelper::GetWindow(rParent), EditBrowseBoxFlags::SMART_TAB_TRAVEL | EditBrowseBoxFlags::NO_HANDLE_COLUMN_CONTENT, WB_TABSTOP | WB_BORDER, BrowserMode::AUTOSIZE_LASTCOL) @@ -135,8 +136,6 @@ namespace dbaui { } - VCL_BUILDER_FACTORY(ORelationControl) - void ORelationControl::Init(const TTableConnectionData::value_type& _pConnData) { @@ -435,28 +434,35 @@ namespace dbaui } // class OTableListBoxControl - OTableListBoxControl::OTableListBoxControl(VclBuilderContainer* _pParent, + OTableListBoxControl::OTableListBoxControl(weld::Builder* _pParent, const OJoinTableView::OTableWindowMap* _pTableMap, IRelationControlInterface* _pParentDialog) - : m_pTableMap(_pTableMap) + : m_xLeftTable(_pParent->weld_combo_box("table1")) + , m_xRightTable(_pParent->weld_combo_box("table2")) + , m_xTable(_pParent->weld_container("relations")) + , m_xTableCtrlParent(m_xTable->CreateChildFrame()) + , m_xRC_Tables(VclPtr::Create(m_xTableCtrlParent)) + , m_pTableMap(_pTableMap) , m_pParentDialog(_pParentDialog) { - _pParent->get(m_pLeftTable, "table1"); - _pParent->get(m_pRightTable, "table2"); + Size aPrefSize = m_xRC_Tables->GetOptimalSize(); + m_xTable->set_size_request(aPrefSize.Width(), aPrefSize.Height()); - _pParent->get(m_pRC_Tables, "relations"); - m_pRC_Tables->SetController(this); - m_pRC_Tables->Init(); + m_xRC_Tables->SetController(this); + m_xRC_Tables->Init(); lateUIInit(); - Link aLink(LINK(this, OTableListBoxControl, OnTableChanged)); - m_pLeftTable->SetSelectHdl(aLink); - m_pRightTable->SetSelectHdl(aLink); + Link aLink(LINK(this, OTableListBoxControl, OnTableChanged)); + m_xLeftTable->connect_changed(aLink); + m_xRightTable->connect_changed(aLink); } OTableListBoxControl::~OTableListBoxControl() { + m_xRC_Tables.disposeAndClear(); + m_xTableCtrlParent->dispose(); + m_xTableCtrlParent.clear(); } void OTableListBoxControl::fillListBoxes() @@ -468,8 +474,8 @@ namespace dbaui // Collect the names of all TabWins for (auto const& elem : *m_pTableMap) { - m_pLeftTable->InsertEntry(elem.first); - m_pRightTable->InsertEntry(elem.first); + m_xLeftTable->append_text(elem.first); + m_xRightTable->append_text(elem.first); if (!pInitialLeft) { @@ -490,46 +496,46 @@ namespace dbaui } // The corresponding Defs for my Controls - m_pRC_Tables->setWindowTables(pInitialLeft,pInitialRight); + m_xRC_Tables->setWindowTables(pInitialLeft,pInitialRight); // The table selected in a ComboBox must not be available in the other if ( m_pTableMap->size() > 2 ) { - m_pLeftTable->RemoveEntry(m_strCurrentRight); - m_pRightTable->RemoveEntry(m_strCurrentLeft); + m_xLeftTable->remove_text(m_strCurrentRight); + m_xRightTable->remove_text(m_strCurrentLeft); } // Select the first one on the left side and on the right side, // select the second one - m_pLeftTable->SelectEntry(m_strCurrentLeft); - m_pRightTable->SelectEntry(m_strCurrentRight); + m_xLeftTable->set_active_text(m_strCurrentLeft); + m_xRightTable->set_active_text(m_strCurrentRight); - m_pLeftTable->GrabFocus(); + m_xLeftTable->grab_focus(); } - IMPL_LINK( OTableListBoxControl, OnTableChanged, ListBox&, rListBox, void ) + IMPL_LINK(OTableListBoxControl, OnTableChanged, weld::ComboBox&, rListBox, void) { - OUString strSelected(rListBox.GetSelectedEntry()); + OUString strSelected(rListBox.get_active_text()); OTableWindow* pLeft = nullptr; OTableWindow* pRight = nullptr; // Special treatment: If there are only two tables, we need to switch the other one too when changing in a LB if ( m_pTableMap->size() == 2 ) { - ListBox* pOther; - if (&rListBox == m_pLeftTable) - pOther = m_pRightTable; + weld::ComboBox* pOther; + if (&rListBox == m_xLeftTable.get()) + pOther = m_xRightTable.get(); else - pOther = m_pLeftTable; - pOther->SelectEntryPos(1 - pOther->GetSelectedEntryPos()); + pOther = m_xLeftTable.get(); + pOther->set_active(1 - pOther->get_active()); OJoinTableView::OTableWindowMap::const_iterator aIter = m_pTableMap->begin(); OTableWindow* pFirst = aIter->second; ++aIter; OTableWindow* pSecond = aIter->second; - if ( m_pLeftTable->GetSelectedEntry() == pFirst->GetName() ) + if (m_xLeftTable->get_active_text() == pFirst->GetName()) { pLeft = pFirst; pRight = pSecond; @@ -549,42 +555,42 @@ namespace dbaui pLoop = aFind->second; OSL_ENSURE(pLoop != nullptr, "ORelationDialog::OnTableChanged: invalid ListBox entry!"); // We need to find strSelect, because we filled the ListBoxes with the table names with which we compare now - if (&rListBox == m_pLeftTable) + if (&rListBox == m_xLeftTable.get()) { // Insert the previously selected Entry on the left side on the right side - m_pRightTable->InsertEntry(m_strCurrentLeft); + m_xRightTable->append_text(m_strCurrentLeft); // Remove the currently selected Entry - m_pRightTable->RemoveEntry(strSelected); + m_xRightTable->remove_text(strSelected); m_strCurrentLeft = strSelected; pLeft = pLoop; - OJoinTableView::OTableWindowMap::const_iterator aIter = m_pTableMap->find(m_pRightTable->GetSelectedEntry()); + OJoinTableView::OTableWindowMap::const_iterator aIter = m_pTableMap->find(m_xRightTable->get_active_text()); OSL_ENSURE( aIter != m_pTableMap->end(), "Invalid name"); if ( aIter != m_pTableMap->end() ) pRight = aIter->second; - m_pLeftTable->GrabFocus(); + m_xLeftTable->grab_focus(); } else { // Insert the previously selected Entry on the right side on the left side - m_pLeftTable->InsertEntry(m_strCurrentRight); + m_xLeftTable->append_text(m_strCurrentRight); // Remove the currently selected Entry - m_pLeftTable->RemoveEntry(strSelected); + m_xLeftTable->remove_text(strSelected); m_strCurrentRight = strSelected; pRight = pLoop; - OJoinTableView::OTableWindowMap::const_iterator aIter = m_pTableMap->find(m_pLeftTable->GetSelectedEntry()); + OJoinTableView::OTableWindowMap::const_iterator aIter = m_pTableMap->find(m_xLeftTable->get_active_text()); OSL_ENSURE( aIter != m_pTableMap->end(), "Invalid name"); if ( aIter != m_pTableMap->end() ) pLeft = aIter->second; } } - rListBox.GrabFocus(); + rListBox.grab_focus(); - m_pRC_Tables->setWindowTables(pLeft,pRight); + m_xRC_Tables->setWindowTables(pLeft,pRight); NotifyCellChange(); } @@ -592,7 +598,7 @@ namespace dbaui void OTableListBoxControl::NotifyCellChange() { // Enable/disable the OK button, depending on having a valid situation - TTableConnectionData::value_type pConnData = m_pRC_Tables->getData(); + TTableConnectionData::value_type pConnData = m_xRC_Tables->getData(); const OConnectionLineDataVec& rLines = pConnData->GetConnLineDataList(); bool bValid = !rLines.empty(); if (bValid) @@ -606,86 +612,83 @@ namespace dbaui } m_pParentDialog->setValid(bValid); - m_pRC_Tables->DeactivateCell(); - for (auto const& elem : m_pRC_Tables->m_ops) + m_xRC_Tables->DeactivateCell(); + for (auto const& elem : m_xRC_Tables->m_ops) { switch(elem.first) { case ORelationControl::DELETE: - m_pRC_Tables->RowRemoved(elem.second.first, elem.second.second - elem.second.first); + m_xRC_Tables->RowRemoved(elem.second.first, elem.second.second - elem.second.first); break; case ORelationControl::INSERT: - m_pRC_Tables->RowInserted(elem.second.first, elem.second.second - elem.second.first); + m_xRC_Tables->RowInserted(elem.second.first, elem.second.second - elem.second.first); break; case ORelationControl::MODIFY: for(OConnectionLineDataVec::size_type j = elem.second.first; j < elem.second.second; ++j) - m_pRC_Tables->RowModified(j); + m_xRC_Tables->RowModified(j); break; } } - m_pRC_Tables->ActivateCell(); - m_pRC_Tables->m_ops.clear(); + m_xRC_Tables->ActivateCell(); + m_xRC_Tables->m_ops.clear(); } - static void fillEntryAndDisable(ListBox& _rListBox,const OUString& _sEntry) + static void fillEntryAndDisable(weld::ComboBox& _rListBox,const OUString& _sEntry) { - _rListBox.InsertEntry(_sEntry); - _rListBox.SelectEntryPos(0); - _rListBox.Disable(); + _rListBox.append_text(_sEntry); + _rListBox.set_active(0); + _rListBox.set_sensitive(false); } void OTableListBoxControl::fillAndDisable(const TTableConnectionData::value_type& _pConnectionData) { - fillEntryAndDisable(*m_pLeftTable, _pConnectionData->getReferencingTable()->GetWinName()); - fillEntryAndDisable(*m_pRightTable, _pConnectionData->getReferencedTable()->GetWinName()); + fillEntryAndDisable(*m_xLeftTable, _pConnectionData->getReferencingTable()->GetWinName()); + fillEntryAndDisable(*m_xRightTable, _pConnectionData->getReferencedTable()->GetWinName()); } void OTableListBoxControl::Init(const TTableConnectionData::value_type& _pConnData) { - m_pRC_Tables->Init(_pConnData); + m_xRC_Tables->Init(_pConnData); } void OTableListBoxControl::lateUIInit() { - m_pRC_Tables->Show(); + m_xRC_Tables->Show(); lateInit(); } void OTableListBoxControl::lateInit() { - m_pRC_Tables->lateInit(); + m_xRC_Tables->lateInit(); } void OTableListBoxControl::Disable() { - m_pLeftTable->Disable(); - m_pRightTable->Disable(); - m_pRC_Tables->Disable(); + m_xLeftTable->set_sensitive(false); + m_xRightTable->set_sensitive(false); + m_xRC_Tables->Disable(); } void OTableListBoxControl::Invalidate() { - m_pLeftTable->Invalidate(); - m_pRightTable->Invalidate(); - m_pRC_Tables->Invalidate(); + m_xRC_Tables->Invalidate(); } void OTableListBoxControl::SaveModified() { - m_pRC_Tables->SaveModified(); + m_xRC_Tables->SaveModified(); } TTableWindowData::value_type const & OTableListBoxControl::getReferencingTable() const { - return m_pRC_Tables->getData()->getReferencingTable(); + return m_xRC_Tables->getData()->getReferencingTable(); } void OTableListBoxControl::enableRelation(bool _bEnable) { if ( !_bEnable ) - m_pRC_Tables->PostUserEvent(LINK(m_pRC_Tables, ORelationControl, AsynchDeactivate)); - m_pRC_Tables->Enable(_bEnable); - + m_xRC_Tables->PostUserEvent(LINK(m_xRC_Tables, ORelationControl, AsynchDeactivate)); + m_xRC_Tables->Enable(_bEnable); } } diff --git a/dbaccess/source/ui/dlg/RelationDlg.cxx b/dbaccess/source/ui/dlg/RelationDlg.cxx index 19cb52e7276c..0a9146174b6a 100644 --- a/dbaccess/source/ui/dlg/RelationDlg.cxx +++ b/dbaccess/source/ui/dlg/RelationDlg.cxx @@ -49,29 +49,29 @@ using namespace ::dbtools; ORelationDialog::ORelationDialog( OJoinTableView* pParent, const TTableConnectionData::value_type& pConnectionData, bool bAllowTableSelect ) - : ModalDialog(pParent, "RelationDialog", - "dbaccess/ui/relationdialog.ui") + : GenericDialogController(pParent->GetFrameWeld(), + "dbaccess/ui/relationdialog.ui", "RelationDialog") + , m_pParent(pParent) , m_pOrigConnData(pConnectionData) , m_bTriedOneUpdate(false) + , m_xRB_NoCascUpd(m_xBuilder->weld_radio_button("addaction")) + , m_xRB_CascUpd(m_xBuilder->weld_radio_button("addcascade")) + , m_xRB_CascUpdNull(m_xBuilder->weld_radio_button("addnull")) + , m_xRB_CascUpdDefault(m_xBuilder->weld_radio_button("adddefault")) + , m_xRB_NoCascDel(m_xBuilder->weld_radio_button("delaction")) + , m_xRB_CascDel(m_xBuilder->weld_radio_button("delcascade")) + , m_xRB_CascDelNull(m_xBuilder->weld_radio_button("delnull")) + , m_xRB_CascDelDefault(m_xBuilder->weld_radio_button("deldefault")) + , m_xPB_OK(m_xBuilder->weld_button("ok")) { - get(m_pRB_NoCascUpd, "addaction"); - get(m_pRB_CascUpd, "addcascade"); - get(m_pRB_CascUpdNull, "addnull"); - get(m_pRB_CascUpdDefault, "adddefault"); - get(m_pRB_NoCascDel, "delaction"); - get(m_pRB_CascDel, "delcascade"); - get(m_pRB_CascDelNull, "delnull"); - get(m_pRB_CascDelDefault, "deldefault"); - get(m_pPB_OK, "ok"); - // Copy connection m_pConnData.reset( pConnectionData->NewInstance() ); m_pConnData->CopyFrom( *pConnectionData ); Init(m_pConnData); - m_xTableControl.reset( new OTableListBoxControl(this, &pParent->GetTabWinMap(), this) ); + m_xTableControl.reset(new OTableListBoxControl(m_xBuilder.get(), &pParent->GetTabWinMap(), this)); - m_pPB_OK->SetClickHdl( LINK(this, ORelationDialog, OKClickHdl) ); + m_xPB_OK->connect_clicked(LINK(this, ORelationDialog, OKClickHdl)); m_xTableControl->Init( m_pConnData ); if ( bAllowTableSelect ) @@ -86,24 +86,8 @@ ORelationDialog::ORelationDialog( OJoinTableView* pParent, ORelationDialog::~ORelationDialog() { - disposeOnce(); } -void ORelationDialog::dispose() -{ - m_pRB_NoCascUpd.clear(); - m_pRB_CascUpd.clear(); - m_pRB_CascUpdNull.clear(); - m_pRB_CascUpdDefault.clear(); - m_pRB_NoCascDel.clear(); - m_pRB_CascDel.clear(); - m_pRB_CascDelNull.clear(); - m_pRB_CascDelDefault.clear(); - m_pPB_OK.clear(); - ModalDialog::dispose(); -} - - void ORelationDialog::Init(const TTableConnectionData::value_type& _pConnectionData) { ORelationTableConnectionData* pConnData = static_cast(_pConnectionData.get()); @@ -112,18 +96,18 @@ void ORelationDialog::Init(const TTableConnectionData::value_type& _pConnectionD { case KeyRule::NO_ACTION: case KeyRule::RESTRICT: - m_pRB_NoCascUpd->Check(); + m_xRB_NoCascUpd->set_active(true); break; case KeyRule::CASCADE: - m_pRB_CascUpd->Check(); + m_xRB_CascUpd->set_active(true); break; case KeyRule::SET_NULL: - m_pRB_CascUpdNull->Check(); + m_xRB_CascUpdNull->set_active(true); break; case KeyRule::SET_DEFAULT: - m_pRB_CascUpdDefault->Check(); + m_xRB_CascUpdDefault->set_active(true); break; } @@ -132,35 +116,35 @@ void ORelationDialog::Init(const TTableConnectionData::value_type& _pConnectionD { case KeyRule::NO_ACTION: case KeyRule::RESTRICT: - m_pRB_NoCascDel->Check(); + m_xRB_NoCascDel->set_active(true); break; case KeyRule::CASCADE: - m_pRB_CascDel->Check(); + m_xRB_CascDel->set_active(true); break; case KeyRule::SET_NULL: - m_pRB_CascDelNull->Check(); + m_xRB_CascDelNull->set_active(true); break; case KeyRule::SET_DEFAULT: - m_pRB_CascDelDefault->Check(); + m_xRB_CascDelDefault->set_active(true); break; } } -IMPL_LINK_NOARG( ORelationDialog, OKClickHdl, Button*, void ) +IMPL_LINK_NOARG(ORelationDialog, OKClickHdl, weld::Button&, void) { // Read out RadioButtons sal_uInt16 nAttrib = 0; // Delete Rules - if( m_pRB_NoCascDel->IsChecked() ) + if( m_xRB_NoCascDel->get_active() ) nAttrib |= KeyRule::NO_ACTION; - if( m_pRB_CascDel->IsChecked() ) + if( m_xRB_CascDel->get_active() ) nAttrib |= KeyRule::CASCADE; - if( m_pRB_CascDelNull->IsChecked() ) + if( m_xRB_CascDelNull->get_active() ) nAttrib |= KeyRule::SET_NULL; - if( m_pRB_CascDelDefault->IsChecked() ) + if( m_xRB_CascDelDefault->get_active() ) nAttrib |= KeyRule::SET_DEFAULT; ORelationTableConnectionData* pConnData = static_cast(m_pConnData.get()); @@ -168,13 +152,13 @@ IMPL_LINK_NOARG( ORelationDialog, OKClickHdl, Button*, void ) // Update Rules nAttrib = 0; - if( m_pRB_NoCascUpd->IsChecked() ) + if( m_xRB_NoCascUpd->get_active() ) nAttrib |= KeyRule::NO_ACTION; - if( m_pRB_CascUpd->IsChecked() ) + if( m_xRB_CascUpd->get_active() ) nAttrib |= KeyRule::CASCADE; - if( m_pRB_CascUpdNull->IsChecked() ) + if( m_xRB_CascUpdNull->get_active() ) nAttrib |= KeyRule::SET_NULL; - if( m_pRB_CascUpdDefault->IsChecked() ) + if( m_xRB_CascUpdDefault->get_active() ) nAttrib |= KeyRule::SET_DEFAULT; pConnData->SetUpdateRules( nAttrib ); @@ -192,15 +176,15 @@ IMPL_LINK_NOARG( ORelationDialog, OKClickHdl, Button*, void ) if ( *pConnData == *pOrigConnData || pConnData->Update()) { m_pOrigConnData->CopyFrom( *m_pConnData ); - EndDialog( RET_OK ); + m_xDialog->response(RET_OK); return; } } catch( const SQLException& ) { - ::dbtools::showError( SQLExceptionInfo( ::cppu::getCaughtException() ), - VCLUnoHelper::GetInterface(this), - static_cast(GetParent())->getDesignView()->getController().getORB()); + ::dbtools::showError(SQLExceptionInfo(::cppu::getCaughtException()), + m_xDialog->GetXWindow(), + m_pParent->getDesignView()->getController().getORB()); } catch( const Exception& ) { @@ -217,9 +201,9 @@ IMPL_LINK_NOARG( ORelationDialog, OKClickHdl, Button*, void ) m_xTableControl->lateInit(); } -short ORelationDialog::Execute() +short ORelationDialog::run() { - short nResult = ModalDialog::Execute(); + short nResult = GenericDialogController::run(); if ((nResult != RET_OK) && m_bTriedOneUpdate) return RET_NO; @@ -228,7 +212,7 @@ short ORelationDialog::Execute() void ORelationDialog::setValid(bool _bValid) { - m_pPB_OK->Enable(_bValid); + m_xPB_OK->set_sensitive(_bValid); } void ORelationDialog::notifyConnectionChange() diff --git a/dbaccess/source/ui/inc/RelationControl.hxx b/dbaccess/source/ui/inc/RelationControl.hxx index 1a9e359f1689..a2d3a0e35d93 100644 --- a/dbaccess/source/ui/inc/RelationControl.hxx +++ b/dbaccess/source/ui/inc/RelationControl.hxx @@ -19,9 +19,7 @@ #ifndef INCLUDED_DBACCESS_SOURCE_UI_INC_RELATIONCONTROL_HXX #define INCLUDED_DBACCESS_SOURCE_UI_INC_RELATIONCONTROL_HXX -#include -#include -#include +#include #include "JoinTableView.hxx" namespace dbaui @@ -32,16 +30,19 @@ namespace dbaui class OTableListBoxControl final { - VclPtr m_pLeftTable; - VclPtr m_pRightTable; - VclPtr m_pRC_Tables; + std::unique_ptr m_xLeftTable; + std::unique_ptr m_xRightTable; + std::unique_ptr m_xTable; + css::uno::Reference m_xTableCtrlParent; + VclPtr m_xRC_Tables; + const OJoinTableView::OTableWindowMap* m_pTableMap; IRelationControlInterface* m_pParentDialog; OUString m_strCurrentLeft; OUString m_strCurrentRight; - DECL_LINK( OnTableChanged, ListBox&, void ); + DECL_LINK( OnTableChanged, weld::ComboBox&, void ); public: - OTableListBoxControl(VclBuilderContainer* _pParent, + OTableListBoxControl(weld::Builder* _pParent, const OJoinTableView::OTableWindowMap* _pTableMap, IRelationControlInterface* _pParentDialog); ~OTableListBoxControl(); diff --git a/dbaccess/source/ui/inc/RelationDlg.hxx b/dbaccess/source/ui/inc/RelationDlg.hxx index 72c91215dca4..e3fe49f1335c 100644 --- a/dbaccess/source/ui/inc/RelationDlg.hxx +++ b/dbaccess/source/ui/inc/RelationDlg.hxx @@ -20,9 +20,7 @@ #define INCLUDED_DBACCESS_SOURCE_UI_INC_RELATIONDLG_HXX #include -#include -#include -#include +#include #include "JoinTableView.hxx" #include "RelControliFace.hxx" #include "RelationControl.hxx" @@ -30,35 +28,33 @@ namespace dbaui { class OJoinTableView; - class ORelationDialog final : public ModalDialog - ,public IRelationControlInterface + class ORelationDialog final : public weld::GenericDialogController + , public IRelationControlInterface { - std::unique_ptr m_xTableControl; - - VclPtr m_pRB_NoCascUpd; - VclPtr m_pRB_CascUpd; - VclPtr m_pRB_CascUpdNull; - VclPtr m_pRB_CascUpdDefault; - VclPtr m_pRB_NoCascDel; - VclPtr m_pRB_CascDel; - VclPtr m_pRB_CascDelNull; - VclPtr m_pRB_CascDelDefault; + VclPtr m_pParent; + TTableConnectionData::value_type m_pConnData; + TTableConnectionData::value_type m_pOrigConnData; + bool m_bTriedOneUpdate; - VclPtr m_pPB_OK; + std::unique_ptr m_xRB_NoCascUpd; + std::unique_ptr m_xRB_CascUpd; + std::unique_ptr m_xRB_CascUpdNull; + std::unique_ptr m_xRB_CascUpdDefault; + std::unique_ptr m_xRB_NoCascDel; + std::unique_ptr m_xRB_CascDel; + std::unique_ptr m_xRB_CascDelNull; + std::unique_ptr m_xRB_CascDelDefault; + std::unique_ptr m_xPB_OK; - TTableConnectionData::value_type m_pConnData; - TTableConnectionData::value_type m_pOrigConnData; - - bool m_bTriedOneUpdate; + std::unique_ptr m_xTableControl; public: ORelationDialog(OJoinTableView* pParent, const TTableConnectionData::value_type& pConnectionData, bool bAllowTableSelect = false ); virtual ~ORelationDialog() override; - virtual void dispose() override; - virtual short Execute() override; + virtual short run() override; /** setValid set the valid inside, can be used for OK buttons @param _bValid true when the using control allows an update @@ -72,7 +68,7 @@ namespace dbaui private: void Init(const TTableConnectionData::value_type& _pConnectionData); - DECL_LINK( OKClickHdl, Button*, void ); + DECL_LINK(OKClickHdl, weld::Button&, void); }; } #endif // INCLUDED_DBACCESS_SOURCE_UI_INC_RELATIONDLG_HXX diff --git a/dbaccess/source/ui/querydesign/QueryTableView.cxx b/dbaccess/source/ui/querydesign/QueryTableView.cxx index f6123e2b9676..61042d620c02 100644 --- a/dbaccess/source/ui/querydesign/QueryTableView.cxx +++ b/dbaccess/source/ui/querydesign/QueryTableView.cxx @@ -84,11 +84,11 @@ namespace { OQueryTableConnectionData* pData = static_cast< OQueryTableConnectionData*>(_pConnectionData.get()); - ScopedVclPtrInstance< DlgQryJoin > aDlg(_pView,_pConnectionData,&_pView->GetTabWinMap(),_pView->getDesignView()->getController().getConnection(),_bSelectableTables); - bool bOk = aDlg->Execute() == RET_OK; + DlgQryJoin aDlg(_pView,_pConnectionData,&_pView->GetTabWinMap(),_pView->getDesignView()->getController().getConnection(),_bSelectableTables); + bool bOk = aDlg.run() == RET_OK; if( bOk ) { - pData->SetJoinType(aDlg->GetJoinType()); + pData->SetJoinType(aDlg.GetJoinType()); _pView->getDesignView()->getController().setModified(true); } diff --git a/dbaccess/source/ui/querydesign/querydlg.cxx b/dbaccess/source/ui/querydesign/querydlg.cxx index 0370e6b0f38c..55e3e49a49b6 100644 --- a/dbaccess/source/ui/querydesign/querydlg.cxx +++ b/dbaccess/source/ui/querydesign/querydlg.cxx @@ -41,47 +41,46 @@ using namespace ::com::sun::star::uno; using namespace ::com::sun::star::container; using namespace ::com::sun::star::sdbc; -DlgQryJoin::DlgQryJoin( OQueryTableView * pParent, +DlgQryJoin::DlgQryJoin(OQueryTableView* pParent, const TTableConnectionData::value_type& _pData, const OJoinTableView::OTableWindowMap* _pTableMap, const Reference< XConnection >& _xConnection, bool _bAllowTableSelect) - : ModalDialog( pParent, "JoinDialog", "dbaccess/ui/joindialog.ui" ) + : GenericDialogController(pParent->GetFrameWeld(), "dbaccess/ui/joindialog.ui", "JoinDialog") , eJoinType(static_cast(_pData.get())->GetJoinType()) , m_pOrigConnData(_pData) , m_xConnection(_xConnection) + , m_xML_HelpText(m_xBuilder->weld_label("helptext")) + , m_xPB_OK(m_xBuilder->weld_button("ok")) + , m_xLB_JoinType(m_xBuilder->weld_combo_box("type")) + , m_xCBNatural(m_xBuilder->weld_check_button("natural")) { - get(m_pML_HelpText, "helptext"); - Size aSize(LogicToPixel(Size(179, 49), MapMode(MapUnit::MapAppFont))); + Size aSize(m_xML_HelpText->get_approximate_digit_width() * 44, + m_xML_HelpText->get_text_height() * 6); //alternatively loop through the STR_QUERY_* strings with their STR_JOIN_TYPE_HINT //suffix to find the longest entry at runtime - m_pML_HelpText->set_height_request(aSize.Height()); - m_pML_HelpText->set_width_request(aSize.Width()); - get(m_pLB_JoinType, "type"); - get(m_pCBNatural, "natural"); - get(m_pPB_OK, "ok"); + m_xML_HelpText->set_size_request(aSize.Width(), aSize.Height()); - m_pML_HelpText->SetControlBackground( GetSettings().GetStyleSettings().GetFaceColor() ); // Copy connection m_pConnData.reset(_pData->NewInstance()); m_pConnData->CopyFrom(*_pData); - m_pTableControl.reset(new OTableListBoxControl(this, _pTableMap, this)); + m_xTableControl.reset(new OTableListBoxControl(m_xBuilder.get(), _pTableMap, this)); - m_pCBNatural->Check(static_cast(m_pConnData.get())->isNatural()); + m_xCBNatural->set_active(static_cast(m_pConnData.get())->isNatural()); if( _bAllowTableSelect ) { - m_pTableControl->Init( m_pConnData ); - m_pTableControl->fillListBoxes(); + m_xTableControl->Init( m_pConnData ); + m_xTableControl->fillListBoxes(); } else { - m_pTableControl->fillAndDisable(m_pConnData); - m_pTableControl->Init( m_pConnData ); + m_xTableControl->fillAndDisable(m_pConnData); + m_xTableControl->Init( m_pConnData ); } - m_pTableControl->lateUIInit(); + m_xTableControl->lateUIInit(); bool bSupportFullJoin = false; Reference xMeta; @@ -106,66 +105,55 @@ DlgQryJoin::DlgQryJoin( OQueryTableView * pParent, setJoinType(eJoinType); - m_pPB_OK->SetClickHdl( LINK(this, DlgQryJoin, OKClickHdl) ); + m_xPB_OK->connect_clicked(LINK(this, DlgQryJoin, OKClickHdl)); - m_pLB_JoinType->SetSelectHdl(LINK(this,DlgQryJoin,LBChangeHdl)); - m_pCBNatural->SetToggleHdl(LINK(this,DlgQryJoin,NaturalToggleHdl)); + m_xLB_JoinType->connect_changed(LINK(this,DlgQryJoin,LBChangeHdl)); + m_xCBNatural->connect_toggled(LINK(this,DlgQryJoin,NaturalToggleHdl)); if ( pParent->getDesignView()->getController().isReadOnly() ) { - m_pLB_JoinType->Disable(); - m_pCBNatural->Disable(); - m_pTableControl->Disable(); + m_xLB_JoinType->set_sensitive(false); + m_xCBNatural->set_sensitive(false); + m_xTableControl->Disable(); } else { - for (sal_Int32 i = 0; i < m_pLB_JoinType->GetEntryCount();) + for (sal_Int32 i = 0; i < m_xLB_JoinType->get_count();) { - const sal_IntPtr nJoinTyp = reinterpret_cast(m_pLB_JoinType->GetEntryData(i)); + const sal_IntPtr nJoinTyp = m_xLB_JoinType->get_id(i).toInt32(); if ( !bSupportFullJoin && nJoinTyp == ID_FULL_JOIN ) - m_pLB_JoinType->RemoveEntry(i); + m_xLB_JoinType->remove(i); else if ( !bSupportOuterJoin && (nJoinTyp == ID_LEFT_JOIN || nJoinTyp == ID_RIGHT_JOIN) ) - m_pLB_JoinType->RemoveEntry(i); + m_xLB_JoinType->remove(i); else ++i; } - m_pTableControl->NotifyCellChange(); - m_pTableControl->enableRelation(!static_cast(m_pConnData.get())->isNatural() && eJoinType != CROSS_JOIN ); + m_xTableControl->NotifyCellChange(); + m_xTableControl->enableRelation(!static_cast(m_pConnData.get())->isNatural() && eJoinType != CROSS_JOIN ); } } DlgQryJoin::~DlgQryJoin() { - disposeOnce(); } -void DlgQryJoin::dispose() +IMPL_LINK_NOARG( DlgQryJoin, LBChangeHdl, weld::ComboBox&, void ) { - m_pTableControl.reset(); - m_pML_HelpText.clear(); - m_pPB_OK.clear(); - m_pLB_JoinType.clear(); - m_pCBNatural.clear(); - ModalDialog::dispose(); -} - -IMPL_LINK_NOARG( DlgQryJoin, LBChangeHdl, ListBox&, void ) -{ - if (m_pLB_JoinType->GetSelectedEntryPos() == m_pLB_JoinType->GetSavedValue() ) + if (!m_xLB_JoinType->get_value_changed_from_saved()) return; - m_pLB_JoinType->SaveValue(); - m_pML_HelpText->SetText(OUString()); + m_xLB_JoinType->save_value(); + m_xML_HelpText->set_label(OUString()); - m_pTableControl->enableRelation(true); + m_xTableControl->enableRelation(true); OUString sFirstWinName = m_pConnData->getReferencingTable()->GetWinName(); OUString sSecondWinName = m_pConnData->getReferencedTable()->GetWinName(); const EJoinType eOldJoinType = eJoinType; const char* pResId = nullptr; - const sal_Int32 nPos = m_pLB_JoinType->GetSelectedEntryPos(); - const sal_IntPtr nJoinType = reinterpret_cast(m_pLB_JoinType->GetEntryData(nPos)); + const sal_Int32 nPos = m_xLB_JoinType->get_active(); + const sal_IntPtr nJoinType = m_xLB_JoinType->get_id(nPos).toInt32(); bool bAddHint = true; switch ( nJoinType ) { @@ -198,16 +186,16 @@ IMPL_LINK_NOARG( DlgQryJoin, LBChangeHdl, ListBox&, void ) eJoinType = CROSS_JOIN; m_pConnData->ResetConnLines(); - m_pTableControl->lateInit(); - m_pCBNatural->Check(false); - m_pTableControl->enableRelation(false); + m_xTableControl->lateInit(); + m_xCBNatural->set_active(false); + m_xTableControl->enableRelation(false); m_pConnData->AppendConnLine("",""); - m_pPB_OK->Enable(); + m_xPB_OK->set_sensitive(true); } break; } - m_pCBNatural->Enable(eJoinType != CROSS_JOIN); + m_xCBNatural->set_sensitive(eJoinType != CROSS_JOIN); if ( eJoinType != eOldJoinType && eOldJoinType == CROSS_JOIN ) { @@ -215,11 +203,11 @@ IMPL_LINK_NOARG( DlgQryJoin, LBChangeHdl, ListBox&, void ) } if ( eJoinType != CROSS_JOIN ) { - m_pTableControl->NotifyCellChange(); - NaturalToggleHdl(*m_pCBNatural); + m_xTableControl->NotifyCellChange(); + NaturalToggleHdl(*m_xCBNatural); } - m_pTableControl->Invalidate(); + m_xTableControl->Invalidate(); OUString sHelpText = DBA_RES(pResId); if( nPos ) @@ -233,22 +221,22 @@ IMPL_LINK_NOARG( DlgQryJoin, LBChangeHdl, ListBox&, void ) sHelpText += DBA_RES( STR_JOIN_TYPE_HINT ); } - m_pML_HelpText->SetText( sHelpText ); + m_xML_HelpText->set_label( sHelpText ); } -IMPL_LINK_NOARG( DlgQryJoin, OKClickHdl, Button*, void ) +IMPL_LINK_NOARG(DlgQryJoin, OKClickHdl, weld::Button&, void) { m_pConnData->Update(); m_pOrigConnData->CopyFrom( *m_pConnData ); - EndDialog(RET_OK); + m_xDialog->response(RET_OK); } -IMPL_LINK_NOARG( DlgQryJoin, NaturalToggleHdl, CheckBox&, void ) +IMPL_LINK_NOARG(DlgQryJoin, NaturalToggleHdl, weld::ToggleButton&, void) { - bool bChecked = m_pCBNatural->IsChecked(); + bool bChecked = m_xCBNatural->get_active(); static_cast(m_pConnData.get())->setNatural(bChecked); - m_pTableControl->enableRelation(!bChecked); + m_xTableControl->enableRelation(!bChecked); if ( bChecked ) { m_pConnData->ResetConnLines(); @@ -268,27 +256,27 @@ IMPL_LINK_NOARG( DlgQryJoin, NaturalToggleHdl, CheckBox&, void ) { DBG_UNHANDLED_EXCEPTION("dbaccess"); } - m_pTableControl->NotifyCellChange(); - m_pTableControl->Invalidate(); + m_xTableControl->NotifyCellChange(); + m_xTableControl->Invalidate(); } } void DlgQryJoin::setValid(bool _bValid) { - m_pPB_OK->Enable(_bValid || eJoinType == CROSS_JOIN ); + m_xPB_OK->set_sensitive(_bValid || eJoinType == CROSS_JOIN ); } void DlgQryJoin::notifyConnectionChange( ) { setJoinType( static_cast(m_pConnData.get())->GetJoinType() ); - m_pCBNatural->Check(static_cast(m_pConnData.get())->isNatural()); - NaturalToggleHdl(*m_pCBNatural); + m_xCBNatural->set_active(static_cast(m_pConnData.get())->isNatural()); + NaturalToggleHdl(*m_xCBNatural); } void DlgQryJoin::setJoinType(EJoinType _eNewJoinType) { eJoinType = _eNewJoinType; - m_pCBNatural->Enable(eJoinType != CROSS_JOIN); + m_xCBNatural->set_sensitive(eJoinType != CROSS_JOIN); sal_IntPtr nJoinType = 0; switch ( eJoinType ) @@ -311,17 +299,17 @@ void DlgQryJoin::setJoinType(EJoinType _eNewJoinType) break; } - const sal_Int32 nCount = m_pLB_JoinType->GetEntryCount(); + const sal_Int32 nCount = m_xLB_JoinType->get_count(); for (sal_Int32 i = 0; i < nCount; ++i) { - if ( nJoinType == reinterpret_cast(m_pLB_JoinType->GetEntryData(i)) ) + if (nJoinType == m_xLB_JoinType->get_id(i).toInt32()) { - m_pLB_JoinType->SelectEntryPos(i); + m_xLB_JoinType->set_active(i); break; } } - LBChangeHdl(*m_pLB_JoinType); + LBChangeHdl(*m_xLB_JoinType); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/dbaccess/source/ui/querydesign/querydlg.hxx b/dbaccess/source/ui/querydesign/querydlg.hxx index 08b037a440cd..3304a50ed50b 100644 --- a/dbaccess/source/ui/querydesign/querydlg.hxx +++ b/dbaccess/source/ui/querydesign/querydlg.hxx @@ -18,12 +18,8 @@ */ #ifndef INCLUDED_DBACCESS_SOURCE_UI_QUERYDESIGN_QUERYDLG_HXX #define INCLUDED_DBACCESS_SOURCE_UI_QUERYDESIGN_QUERYDLG_HXX -#include -#include - -#include -#include +#include #include @@ -35,25 +31,23 @@ namespace dbaui { class OTableListBoxControl; class OQueryTableView; - class DlgQryJoin final : public ModalDialog - ,public IRelationControlInterface + class DlgQryJoin final : public weld::GenericDialogController + , public IRelationControlInterface { - VclPtr m_pML_HelpText; - VclPtr m_pPB_OK; - VclPtr m_pLB_JoinType; - VclPtr m_pCBNatural; - - std::unique_ptr m_pTableControl; - EJoinType eJoinType; TTableConnectionData::value_type m_pConnData; // contains left and right table TTableConnectionData::value_type m_pOrigConnData; css::uno::Reference< css::sdbc::XConnection > m_xConnection; + std::unique_ptr m_xML_HelpText; + std::unique_ptr m_xPB_OK; + std::unique_ptr m_xLB_JoinType; + std::unique_ptr m_xCBNatural; + std::unique_ptr m_xTableControl; - DECL_LINK( OKClickHdl, Button*, void ); - DECL_LINK( LBChangeHdl, ListBox&, void ); - DECL_LINK( NaturalToggleHdl, CheckBox&, void ); + DECL_LINK(OKClickHdl, weld::Button&, void); + DECL_LINK(LBChangeHdl, weld::ComboBox&, void); + DECL_LINK(NaturalToggleHdl, weld::ToggleButton&, void); /** setJoinType enables and set the new join type @param _eNewJoinType the new jointype @@ -66,7 +60,6 @@ namespace dbaui const css::uno::Reference< css::sdbc::XConnection >& _xConnection, bool _bAllowTableSelect); virtual ~DlgQryJoin() override; - virtual void dispose() override; EJoinType GetJoinType() const { return eJoinType; }; /** setValid set the valid inside, can be used for OK buttons diff --git a/dbaccess/source/ui/relationdesign/RelationTableView.cxx b/dbaccess/source/ui/relationdesign/RelationTableView.cxx index 30f349a4e68e..484194df9d38 100644 --- a/dbaccess/source/ui/relationdesign/RelationTableView.cxx +++ b/dbaccess/source/ui/relationdesign/RelationTableView.cxx @@ -220,8 +220,8 @@ void ORelationTableView::AddConnection(const OJoinExchangeData& jxdSource, const void ORelationTableView::ConnDoubleClicked(VclPtr& rConnection) { - ScopedVclPtrInstance< ORelationDialog > aRelDlg( this, rConnection->GetData() ); - switch (aRelDlg->Execute()) + ORelationDialog aRelDlg(this, rConnection->GetData()); + switch (aRelDlg.run()) { case RET_OK: // successfully updated @@ -248,9 +248,9 @@ void ORelationTableView::AddNewRelation() { TTableConnectionData::value_type pNewConnData( new ORelationTableConnectionData() ); - ScopedVclPtrInstance< ORelationDialog > aRelDlg(this, pNewConnData, true); + ORelationDialog aRelDlg(this, pNewConnData, true); - bool bSuccess = (aRelDlg->Execute() == RET_OK); + bool bSuccess = (aRelDlg.run() == RET_OK); if (bSuccess) { // already updated by the dialog @@ -362,8 +362,8 @@ void ORelationTableView::lookForUiActivities() } if(m_pCurrentlyTabConnData) { - ScopedVclPtrInstance< ORelationDialog > aRelDlg( this, m_pCurrentlyTabConnData ); - if (aRelDlg->Execute() == RET_OK) + ORelationDialog aRelDlg(this, m_pCurrentlyTabConnData); + if (aRelDlg.run() == RET_OK) { // already updated by the dialog addConnection( VclPtr::Create( this, m_pCurrentlyTabConnData ) ); -- cgit v1.2.3