diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-02-08 11:55:18 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-02-11 07:00:35 +0100 |
commit | 7df04009b98165f89c89f1e506ebafd2fecc8f5a (patch) | |
tree | 5629b360bd669d458dcfa0e3da7e7ce44c194363 /dbaccess | |
parent | eb5e2dea18835df78872a8b0e3446e604f749645 (diff) |
remove ControlDependencyManager
and just use our normal handlers, instead of this weird magic
Change-Id: I8245787bec2a755ce6aba31ed681577771537ca1
Reviewed-on: https://gerrit.libreoffice.org/67534
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'dbaccess')
-rw-r--r-- | dbaccess/source/ui/dlg/admincontrols.cxx | 132 | ||||
-rw-r--r-- | dbaccess/source/ui/dlg/admincontrols.hxx | 6 | ||||
-rw-r--r-- | dbaccess/source/ui/dlg/advancedsettings.hxx | 2 | ||||
-rw-r--r-- | dbaccess/source/ui/dlg/detailpages.hxx | 1 | ||||
-rw-r--r-- | dbaccess/source/ui/dlg/generalpage.cxx | 30 | ||||
-rw-r--r-- | dbaccess/source/ui/dlg/generalpage.hxx | 4 |
6 files changed, 53 insertions, 122 deletions
diff --git a/dbaccess/source/ui/dlg/admincontrols.cxx b/dbaccess/source/ui/dlg/admincontrols.cxx index 22303969b09a..517852513d51 100644 --- a/dbaccess/source/ui/dlg/admincontrols.cxx +++ b/dbaccess/source/ui/dlg/admincontrols.cxx @@ -28,101 +28,6 @@ namespace dbaui { - // TextResetOperatorEventFilter - class TextResetOperatorEventFilter : public ::svt::IWindowEventFilter - { - public: - TextResetOperatorEventFilter() - { - } - - // IWindowEventFilter - virtual bool payAttentionTo( const VclWindowEvent& _rEvent ) const override - { - return ( _rEvent.GetId() == VclEventId::WindowEnabled ) - || ( _rEvent.GetId() == VclEventId::WindowDisabled ) - || ( _rEvent.GetId() == VclEventId::EditModify ); - } - }; - - // TextResetOperator - class TextResetOperator :public ::svt::IWindowOperator - { - public: - explicit TextResetOperator( const OUString& _rDisabledText ) - :m_sDisabledText( _rDisabledText ) - { - } - - // IWindowOperator - virtual void operateOn( const VclWindowEvent& _rTrigger, vcl::Window& _rOperateOn ) const override; - - private: - const OUString m_sDisabledText; - OUString m_sUserText; - }; - - void TextResetOperator::operateOn( const VclWindowEvent& _rTrigger, vcl::Window& _rOperateOn ) const - { - OSL_ENSURE( _rTrigger.GetWindow() == &_rOperateOn, "TextResetOperator::operateOn: you're misusing this implementation!" ); - - switch ( _rTrigger.GetId() ) - { - case VclEventId::NONE: - // initial call - const_cast< TextResetOperator* >( this )->m_sUserText = _rTrigger.GetWindow()->GetText(); - break; - - case VclEventId::EditModify: - if ( _rTrigger.GetWindow()->IsEnabled() ) - const_cast< TextResetOperator* >( this )->m_sUserText = _rTrigger.GetWindow()->GetText(); - break; - - case VclEventId::WindowEnabled: - _rOperateOn.SetText( m_sUserText ); - break; - - case VclEventId::WindowDisabled: - _rOperateOn.SetText( m_sDisabledText ); - break; - - default: - OSL_FAIL( "TextResetOperator::operateOn: unexpected event ID!" ); - // all those IDs should have been filtered out by payAttentionTo - break; - } - } - - // TextResetOperatorController - class TextResetOperatorController_Base - { - protected: - explicit TextResetOperatorController_Base( const OUString& _rDisabledText ) - :m_pEventFilter( new TextResetOperatorEventFilter ) - ,m_pOperator( new TextResetOperator( _rDisabledText ) ) - { - } - - const ::svt::PWindowEventFilter& getEventFilter() const { return m_pEventFilter; } - const ::svt::PWindowOperator& getOperator() const { return m_pOperator; } - - private: - ::svt::PWindowEventFilter m_pEventFilter; - ::svt::PWindowOperator m_pOperator; - }; - - class TextResetOperatorController :public TextResetOperatorController_Base - ,public ::svt::DialogController - { - public: - TextResetOperatorController( vcl::Window& _rObservee, const OUString& _rDisabledText ) - :TextResetOperatorController_Base( _rDisabledText ) - ,::svt::DialogController( _rObservee, getEventFilter(), getOperator() ) - { - addDependentWindow( _rObservee ); - } - }; - // MySQLNativeSettings MySQLNativeSettings::MySQLNativeSettings( vcl::Window& _rParent, const Link<void*,void>& _rControlModificationLink ) :TabPage( &_rParent, "MysqlNativeSettings", "dbaccess/ui/mysqlnativesettings.ui" ), @@ -142,6 +47,8 @@ namespace dbaui get(m_pSocket, "socket"); get(m_pNamedPipe, "namedpipe"); + m_pHostName->SetText("localhost"); + m_pDatabaseName->SetModifyHdl( LINK(this, MySQLNativeSettings, EditModifyHdl) ); m_pHostName->SetModifyHdl( LINK(this, MySQLNativeSettings, EditModifyHdl) ); m_pPort->SetModifyHdl( LINK(this, MySQLNativeSettings, EditModifyHdl) ); @@ -149,14 +56,7 @@ namespace dbaui m_pNamedPipe->SetModifyHdl( LINK(this, MySQLNativeSettings, EditModifyHdl) ); m_pSocketRadio->SetToggleHdl( LINK(this, MySQLNativeSettings, RadioToggleHdl) ); m_pNamedPipeRadio->SetToggleHdl( LINK(this, MySQLNativeSettings, RadioToggleHdl) ); - - m_aControlDependencies.enableOnRadioCheck( *m_pHostPortRadio, *m_pHostNameLabel, *m_pHostName, *m_pPortLabel, *m_pPort, *m_pDefaultPort ); - m_aControlDependencies.enableOnRadioCheck( *m_pSocketRadio, *m_pSocket ); - m_aControlDependencies.enableOnRadioCheck( *m_pNamedPipeRadio, *m_pNamedPipe ); - - m_aControlDependencies.addController( std::shared_ptr<svt::DialogController>( - new TextResetOperatorController( *m_pHostName, "localhost" ) - ) ); + m_pHostPortRadio->SetToggleHdl( LINK(this, MySQLNativeSettings, RadioToggleHdl) ); // sockets are available on Unix systems only, named pipes only on Windows #ifdef UNX @@ -170,12 +70,36 @@ namespace dbaui IMPL_LINK(MySQLNativeSettings, RadioToggleHdl, RadioButton&, rRadioButton, void) { - m_aControlModificationLink.Call(&rRadioButton); + if (&rRadioButton == &*m_pSocketRadio || &rRadioButton == &*m_pNamedPipeRadio) + m_aControlModificationLink.Call(&rRadioButton); + bool bSelected = rRadioButton.IsChecked(); + if (&rRadioButton == &*m_pHostPortRadio) + { + m_pHostNameLabel->Enable(bSelected); + m_pHostName->Enable(bSelected); + m_pPortLabel->Enable(bSelected); + m_pPort->Enable(bSelected); + m_pDefaultPort->Enable(bSelected); + if (bSelected) + m_pHostName->SetText(m_sHostNameUserText); + else + m_pHostName->SetText("localhost"); + } + else if (&rRadioButton == &*m_pSocketRadio) + m_pSocket->Enable(bSelected); + else if (&rRadioButton == &*m_pNamedPipeRadio) + m_pNamedPipe->Enable(bSelected); } IMPL_LINK(MySQLNativeSettings, EditModifyHdl, Edit&, rEdit, void) { m_aControlModificationLink.Call(&rEdit); + + if (&rEdit == m_pHostName.get()) + { + if (m_pHostName->IsEnabled()) + m_sHostNameUserText = m_pHostName->GetText(); + } } MySQLNativeSettings::~MySQLNativeSettings() diff --git a/dbaccess/source/ui/dlg/admincontrols.hxx b/dbaccess/source/ui/dlg/admincontrols.hxx index de6aed4fdc9e..71366a09266f 100644 --- a/dbaccess/source/ui/dlg/admincontrols.hxx +++ b/dbaccess/source/ui/dlg/admincontrols.hxx @@ -26,8 +26,6 @@ #include <vcl/field.hxx> #include <vcl/fixed.hxx> -#include <svtools/dialogcontrolling.hxx> - namespace dbaui { @@ -48,8 +46,8 @@ namespace dbaui VclPtr<Edit> m_pSocket; VclPtr<Edit> m_pNamedPipe; Link<void*,void> m_aControlModificationLink; - ::svt::ControlDependencyManager - m_aControlDependencies; + OUString m_sHostNameUserText; + DECL_LINK(RadioToggleHdl, RadioButton&, void); DECL_LINK(EditModifyHdl, Edit&, void); diff --git a/dbaccess/source/ui/dlg/advancedsettings.hxx b/dbaccess/source/ui/dlg/advancedsettings.hxx index a285c733a2f0..a523e8e8d4ee 100644 --- a/dbaccess/source/ui/dlg/advancedsettings.hxx +++ b/dbaccess/source/ui/dlg/advancedsettings.hxx @@ -23,8 +23,6 @@ #include "adminpages.hxx" #include <dsmeta.hxx> -#include <svtools/dialogcontrolling.hxx> - #include <vcl/field.hxx> #include <vector> diff --git a/dbaccess/source/ui/dlg/detailpages.hxx b/dbaccess/source/ui/dlg/detailpages.hxx index 6e50f67d59b5..47ba2089850a 100644 --- a/dbaccess/source/ui/dlg/detailpages.hxx +++ b/dbaccess/source/ui/dlg/detailpages.hxx @@ -30,7 +30,6 @@ #include "TextConnectionHelper.hxx" #include "admincontrols.hxx" -#include <svtools/dialogcontrolling.hxx> #include <o3tl/typed_flags_set.hxx> enum class OCommonBehaviourTabPageFlags { diff --git a/dbaccess/source/ui/dlg/generalpage.cxx b/dbaccess/source/ui/dlg/generalpage.cxx index 9f1c2c6f58a6..ba609c6a89b4 100644 --- a/dbaccess/source/ui/dlg/generalpage.cxx +++ b/dbaccess/source/ui/dlg/generalpage.cxx @@ -577,12 +577,6 @@ namespace dbaui m_pFT_DocListLabel->Enable( false ); m_pLB_DocumentList->Enable( false ); } - else - { - m_aControlDependencies.enableOnRadioCheck( *m_pRB_CreateDatabase, *m_pEmbeddedDBType, *m_pFT_EmbeddedDBLabel ); - m_aControlDependencies.enableOnRadioCheck( *m_pRB_ConnectDatabase, *m_pDatasourceType ); - m_aControlDependencies.enableOnRadioCheck( *m_pRB_OpenExistingDatabase, *m_pPB_OpenDatabase, *m_pFT_DocListLabel, *m_pLB_DocumentList ); - } m_pLB_DocumentList->SetDropDownLineCount( 20 ); if ( m_pLB_DocumentList->GetEntryCount() ) @@ -675,12 +669,34 @@ namespace dbaui m_aCreationModeHandler.Call( *this ); OnEmbeddedDBTypeSelected( *m_pEmbeddedDBType ); + + bool bValid, bReadonly; + getFlags( GetItemSet(), bValid, bReadonly ); + if ( bValid && !bReadonly ) + { + m_pEmbeddedDBType->Enable(m_pRB_CreateDatabase->IsChecked()); + m_pFT_EmbeddedDBLabel->Enable(m_pRB_CreateDatabase->IsChecked()); + } } - IMPL_LINK_NOARG( OGeneralPageWizard, OnSetupModeSelected, Button*, void ) + IMPL_LINK( OGeneralPageWizard, OnSetupModeSelected, Button*, pButton, void ) { m_aCreationModeHandler.Call( *this ); OnDatasourceTypeSelected(*m_pDatasourceType); + + bool bValid, bReadonly; + getFlags( GetItemSet(), bValid, bReadonly ); + if ( bValid && !bReadonly ) + { + if (pButton == m_pRB_ConnectDatabase.get()) + m_pDatasourceType->Enable(m_pRB_ConnectDatabase->IsChecked()); + else if (pButton == m_pRB_OpenExistingDatabase.get()) + { + m_pPB_OpenDatabase->Enable(m_pRB_OpenExistingDatabase->IsChecked()); + m_pFT_DocListLabel->Enable(m_pRB_OpenExistingDatabase->IsChecked()); + m_pLB_DocumentList->Enable(m_pRB_OpenExistingDatabase->IsChecked()); + } + } } IMPL_LINK_NOARG( OGeneralPageWizard, OnDocumentSelected, ListBox&, void ) diff --git a/dbaccess/source/ui/dlg/generalpage.hxx b/dbaccess/source/ui/dlg/generalpage.hxx index 711913410e91..eb4ec41af21a 100644 --- a/dbaccess/source/ui/dlg/generalpage.hxx +++ b/dbaccess/source/ui/dlg/generalpage.hxx @@ -25,7 +25,6 @@ #include <vcl/fixed.hxx> #include <vcl/lstbox.hxx> #include <vcl/edit.hxx> -#include <svtools/dialogcontrolling.hxx> namespace dbaui { @@ -157,9 +156,6 @@ namespace dbaui Link<OGeneralPageWizard&,void> m_aDocumentSelectionHandler; /// to be called when a document in the RecentDoc list is selected Link<OGeneralPageWizard&,void> m_aChooseDocumentHandler; /// to be called when a recent document has been definitely chosen - ::svt::ControlDependencyManager - m_aControlDependencies; - bool m_bInitEmbeddedDBList : 1; void insertEmbeddedDBTypeEntryData( const OUString& _sType, const OUString& sDisplayName ); |