diff options
author | Caolán McNamara <caolanm@redhat.com> | 2019-04-06 19:47:52 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2019-04-08 09:53:27 +0200 |
commit | c5edb541337054412fb1d5037de6c50397ab053f (patch) | |
tree | 8064eb993eecd6aff518c89bda99ad9513c86f0b /dbaccess | |
parent | 93cc8d83cd1f814e8b1df03de2e3c25efa4a9d16 (diff) |
weld OAddTableDlg
Change-Id: Id0c94d3ab1a19a1bb47ba1d47caa95110dab3836
Reviewed-on: https://gerrit.libreoffice.org/70353
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'dbaccess')
-rw-r--r-- | dbaccess/source/ui/control/tabletree.cxx | 54 | ||||
-rw-r--r-- | dbaccess/source/ui/dlg/adtabdlg.cxx | 212 | ||||
-rw-r--r-- | dbaccess/source/ui/dlg/tablespage.cxx | 15 | ||||
-rw-r--r-- | dbaccess/source/ui/dlg/tablespage.hxx | 2 | ||||
-rw-r--r-- | dbaccess/source/ui/inc/JoinController.hxx | 7 | ||||
-rw-r--r-- | dbaccess/source/ui/inc/adtabdlg.hxx | 39 | ||||
-rw-r--r-- | dbaccess/source/ui/inc/tabletree.hxx | 5 | ||||
-rw-r--r-- | dbaccess/source/ui/querydesign/JoinController.cxx | 53 | ||||
-rw-r--r-- | dbaccess/source/ui/querydesign/QueryViewSwitch.cxx | 8 | ||||
-rw-r--r-- | dbaccess/uiconfig/ui/tablesfilterdialog.ui | 8 | ||||
-rw-r--r-- | dbaccess/uiconfig/ui/tablesjoindialog.ui | 109 |
11 files changed, 306 insertions, 206 deletions
diff --git a/dbaccess/source/ui/control/tabletree.cxx b/dbaccess/source/ui/control/tabletree.cxx index b89fa02bbe60..9a4add20afaa 100644 --- a/dbaccess/source/ui/control/tabletree.cxx +++ b/dbaccess/source/ui/control/tabletree.cxx @@ -78,13 +78,12 @@ TableTreeListBox::TableTreeListBox(std::unique_ptr<weld::TreeView> xTreeView) : m_xImageProvider(new ImageProvider) , m_bVirtualRoot(false) , m_bNoEmptyFolders(false) + , m_bShowToggles(true) + , m_nTextColumn(1) , m_xTreeView(std::move(xTreeView)) { - m_xTreeView->make_sorted(); } -VCL_BUILDER_FACTORY_CONSTRUCTOR(OTableTreeListBox, 0) - void OTableTreeListBox::implSetDefaultImages() { SetDefaultExpandedEntryBmp( ImageProvider::getFolderImage( DatabaseObject::TABLE ) ); @@ -383,12 +382,19 @@ void OTableTreeListBox::UpdateTableList( const Reference< XConnection >& _rxConn } } +void TableTreeListBox::DisableCheckButtons() +{ + m_bShowToggles = false; + m_nTextColumn = 0; +} + void TableTreeListBox::UpdateTableList( const Reference< XConnection >& _rxConnection, const TNames& _rTables ) { implOnNewConnection( _rxConnection ); // throw away all the old stuff m_xTreeView->clear(); + m_xTreeView->make_unsorted(); try { @@ -408,8 +414,9 @@ void TableTreeListBox::UpdateTableList( const Reference< XConnection >& _rxConne std::unique_ptr<weld::TreeIter> xRet(m_xTreeView->make_iterator()); m_xTreeView->insert(nullptr, -1, nullptr, &sId, nullptr, nullptr, nullptr, false, xRet.get()); m_xTreeView->set_image(*xRet, sImageId, -1); - m_xTreeView->set_toggle(*xRet, TRISTATE_FALSE, 0); - m_xTreeView->set_text(*xRet, sRootEntryText, 1); + if (m_bShowToggles) + m_xTreeView->set_toggle(*xRet, TRISTATE_FALSE, 0); + m_xTreeView->set_text(*xRet, sRootEntryText, m_nTextColumn); } if ( _rTables.empty() ) @@ -456,8 +463,9 @@ void TableTreeListBox::UpdateTableList( const Reference< XConnection >& _rxConne OUString sId(OUString::number(nFolderType)); m_xTreeView->insert(xRootEntry.get(), -1, nullptr, &sId, nullptr, nullptr, nullptr, false, xRet.get()); m_xTreeView->set_image(*xRet, sImageId, -1); - m_xTreeView->set_toggle(*xRet, TRISTATE_FALSE, 0); - m_xTreeView->set_text(*xRet, folderName, 1); + if (m_bShowToggles) + m_xTreeView->set_toggle(*xRet, TRISTATE_FALSE, 0); + m_xTreeView->set_text(*xRet, folderName, m_nTextColumn); } } } @@ -467,6 +475,8 @@ void TableTreeListBox::UpdateTableList( const Reference< XConnection >& _rxConne { DBG_UNHANDLED_EXCEPTION("dbaccess"); } + + m_xTreeView->make_sorted(); } bool OTableTreeListBox::isWildcardChecked(SvTreeListEntry* _pEntry) @@ -482,8 +492,7 @@ bool OTableTreeListBox::isWildcardChecked(SvTreeListEntry* _pEntry) bool TableTreeListBox::isWildcardChecked(weld::TreeIter& rEntry) { -// return m_xTreeView->get_text_emphasis(rEntry, 2); - return m_xTreeView->get_text_emphasis(rEntry, 1); + return m_xTreeView->get_text_emphasis(rEntry, m_nTextColumn); } void OTableTreeListBox::checkWildcard(SvTreeListEntry* _pEntry) @@ -494,6 +503,8 @@ void OTableTreeListBox::checkWildcard(SvTreeListEntry* _pEntry) void TableTreeListBox::checkWildcard(weld::TreeIter& rEntry) { + if (!m_bShowToggles) + return; m_xTreeView->set_toggle(rEntry, TRISTATE_TRUE, 0); checkedButton_noBroadcast(rEntry); } @@ -528,6 +539,8 @@ void OTableTreeListBox::checkedButton_noBroadcast(SvTreeListEntry* _pEntry) void TableTreeListBox::checkedButton_noBroadcast(weld::TreeIter& rEntry) { + if (!m_bShowToggles) + return; TriState eState = m_xTreeView->get_toggle(rEntry, 0); OSL_ENSURE(TRISTATE_INDET != eState, "OTableTreeListBox::CheckButtonHdl: user action which lead to TRISTATE?"); @@ -618,7 +631,7 @@ void TableTreeListBox::implEmphasize(weld::TreeIter& rEntry, bool _bChecked, boo || bAllObjectsEntryAffected // or it is the "all objects" entry ) { - m_xTreeView->set_text_emphasis(rEntry, _bChecked, 1); + m_xTreeView->set_text_emphasis(rEntry, _bChecked, m_nTextColumn); } if (_bUpdateDescendants) @@ -756,8 +769,9 @@ void TableTreeListBox::implAddEntry( OUString sImageId = ImageProvider::getFolderImageId(DatabaseObject::TABLE); m_xTreeView->insert(xParentEntry.get(), -1, nullptr, &sId, nullptr, nullptr, nullptr, false, xFolder.get()); m_xTreeView->set_image(*xFolder, sImageId, -1); - m_xTreeView->set_toggle(*xFolder, TRISTATE_FALSE, 0); - m_xTreeView->set_text(*xFolder, rFirstName, 1); + if (m_bShowToggles) + m_xTreeView->set_toggle(*xFolder, TRISTATE_FALSE, 0); + m_xTreeView->set_text(*xFolder, rFirstName, m_nTextColumn); } xParentEntry = std::move(xFolder); } @@ -772,8 +786,9 @@ void TableTreeListBox::implAddEntry( OUString sImageId = ImageProvider::getFolderImageId(DatabaseObject::TABLE); m_xTreeView->insert(xParentEntry.get(), -1, nullptr, &sId, nullptr, nullptr, nullptr, false, xFolder.get()); m_xTreeView->set_image(*xFolder, sImageId, -1); - m_xTreeView->set_toggle(*xFolder, TRISTATE_FALSE, 0); - m_xTreeView->set_text(*xFolder, rSecondName, 1); + if (m_bShowToggles) + m_xTreeView->set_toggle(*xFolder, TRISTATE_FALSE, 0); + m_xTreeView->set_text(*xFolder, rSecondName, m_nTextColumn); } xParentEntry = std::move(xFolder); } @@ -791,8 +806,9 @@ void TableTreeListBox::implAddEntry( OUString sImageId(m_xImageProvider->getImageId(_rTableName, DatabaseObject::TABLE)); m_xTreeView->set_image(*xEntry, sImageId, -1); } - m_xTreeView->set_toggle(*xEntry, TRISTATE_FALSE, 0); - m_xTreeView->set_text(*xEntry, sName, 1); + if (m_bShowToggles) + m_xTreeView->set_toggle(*xEntry, TRISTATE_FALSE, 0); + m_xTreeView->set_text(*xEntry, sName, m_nTextColumn); } } @@ -964,6 +980,9 @@ std::unique_ptr<weld::TreeIter> TableTreeListBox::GetEntryPosByName(const OUStri void TableTreeListBox::CheckButtons() { + if (!m_bShowToggles) + return; + auto xEntry(m_xTreeView->make_iterator()); if (!m_xTreeView->get_iter_first(*xEntry)) return; @@ -976,6 +995,9 @@ void TableTreeListBox::CheckButtons() TriState TableTreeListBox::implDetermineState(weld::TreeIter& rEntry) { + if (!m_bShowToggles) + return TRISTATE_FALSE; + TriState eState = m_xTreeView->get_toggle(rEntry, 0); if (!m_xTreeView->iter_has_child(rEntry)) // nothing to do in this bottom-up routine if there are no children ... diff --git a/dbaccess/source/ui/dlg/adtabdlg.cxx b/dbaccess/source/ui/dlg/adtabdlg.cxx index 5f7da6a57965..1a1d1035a6c7 100644 --- a/dbaccess/source/ui/dlg/adtabdlg.cxx +++ b/dbaccess/source/ui/dlg/adtabdlg.cxx @@ -58,14 +58,14 @@ class TableListFacade : public ::cppu::BaseMutex , public TableObjectListFacade , public ::comphelper::OContainerListener { - OTableTreeListBox& m_rTableList; + TableTreeListBox& m_rTableList; Reference< XConnection > m_xConnection; ::rtl::Reference< comphelper::OContainerListenerAdapter> m_pContainerListener; bool m_bAllowViews; public: - TableListFacade( OTableTreeListBox& _rTableList, const Reference< XConnection >& _rxConnection ) + TableListFacade( TableTreeListBox& _rTableList, const Reference< XConnection >& _rxConnection ) : ::comphelper::OContainerListener(m_aMutex) ,m_rTableList( _rTableList ) ,m_xConnection( _rxConnection ) @@ -92,20 +92,29 @@ TableListFacade::~TableListFacade() OUString TableListFacade::getSelectedName( OUString& _out_rAliasName ) const { - SvTreeListEntry* pEntry = m_rTableList.FirstSelected(); - if ( !pEntry ) + weld::TreeView& rTableList = m_rTableList.GetWidget(); + std::unique_ptr<weld::TreeIter> xEntry(rTableList.make_iterator()); + + if (!rTableList.get_selected(xEntry.get())) return OUString(); OUString aCatalog, aSchema, aTableName; - SvTreeListEntry* pSchema = m_rTableList.GetParent(pEntry); - if(pSchema && pSchema != m_rTableList.getAllObjectsEntry()) + std::unique_ptr<weld::TreeIter> xSchema(rTableList.make_iterator(xEntry.get())); + if (rTableList.iter_parent(*xSchema)) { - SvTreeListEntry* pCatalog = m_rTableList.GetParent(pSchema); - if(pCatalog && pCatalog != m_rTableList.getAllObjectsEntry()) - aCatalog = m_rTableList.GetEntryText(pCatalog); - aSchema = m_rTableList.GetEntryText(pSchema); + auto xAll = m_rTableList.getAllObjectsEntry(); + if (!xAll || !xSchema->equal(*xAll)) + { + std::unique_ptr<weld::TreeIter> xCatalog(rTableList.make_iterator(xSchema.get())); + if (rTableList.iter_parent(*xCatalog)) + { + if (!xAll || !xCatalog->equal(*xAll)) + aCatalog = rTableList.get_text(*xCatalog); + } + aSchema = rTableList.get_text(*xSchema); + } } - aTableName = m_rTableList.GetEntryText(pEntry); + aTableName = rTableList.get_text(*xEntry); OUString aComposedName; try @@ -149,7 +158,8 @@ void TableListFacade::_elementReplaced( const container::ContainerEvent& /*_rEve void TableListFacade::updateTableObjectList( bool _bAllowViews ) { m_bAllowViews = _bAllowViews; - m_rTableList.Clear(); + weld::TreeView& rTableList = m_rTableList.GetWidget(); + rTableList.clear(); try { Reference< XTablesSupplier > xTableSupp( m_xConnection, UNO_QUERY_THROW ); @@ -198,14 +208,16 @@ void TableListFacade::updateTableObjectList( bool _bAllowViews ) } m_rTableList.UpdateTableList( m_xConnection, sTables, sViews ); - SvTreeListEntry* pEntry = m_rTableList.First(); - while( pEntry && m_rTableList.GetModel()->HasChildren( pEntry ) ) + + std::unique_ptr<weld::TreeIter> xEntry(rTableList.make_iterator()); + bool bEntry = rTableList.get_iter_first(*xEntry); + while (bEntry && rTableList.iter_has_child(*xEntry)) { - m_rTableList.Expand( pEntry ); - pEntry = m_rTableList.Next( pEntry ); + rTableList.expand_row(*xEntry); + bEntry = rTableList.iter_next(*xEntry); } - if ( pEntry ) - m_rTableList.Select(pEntry); + if (bEntry) + rTableList.select(*xEntry); } catch( const Exception& ) { @@ -215,21 +227,23 @@ void TableListFacade::updateTableObjectList( bool _bAllowViews ) bool TableListFacade::isLeafSelected() const { - SvTreeListEntry* pEntry = m_rTableList.FirstSelected(); - return pEntry && !m_rTableList.GetModel()->HasChildren( pEntry ); + weld::TreeView& rTableList = m_rTableList.GetWidget(); + std::unique_ptr<weld::TreeIter> xEntry(rTableList.make_iterator()); + const bool bEntry = rTableList.get_selected(xEntry.get()); + return bEntry && !rTableList.iter_has_child(*xEntry); } class QueryListFacade : public ::cppu::BaseMutex , public TableObjectListFacade , public ::comphelper::OContainerListener { - SvTreeListBox& m_rQueryList; + weld::TreeView& m_rQueryList; Reference< XConnection > m_xConnection; ::rtl::Reference< comphelper::OContainerListenerAdapter> m_pContainerListener; public: - QueryListFacade( SvTreeListBox& _rQueryList, const Reference< XConnection >& _rxConnection ) + QueryListFacade( weld::TreeView& _rQueryList, const Reference< XConnection >& _rxConnection ) : ::comphelper::OContainerListener(m_aMutex) ,m_rQueryList( _rQueryList ) ,m_xConnection( _rxConnection ) @@ -257,7 +271,10 @@ void QueryListFacade::_elementInserted( const container::ContainerEvent& _rEvent { OUString sName; if ( _rEvent.Accessor >>= sName ) - m_rQueryList.InsertEntry( sName ); + { + OUString aQueryImage(ImageProvider::getDefaultImageResourceID(css::sdb::application::DatabaseObject::QUERY)); + m_rQueryList.append("", sName, aQueryImage); + } } void QueryListFacade::_elementRemoved( const container::ContainerEvent& /*_rEvent*/ ) @@ -271,14 +288,10 @@ void QueryListFacade::_elementReplaced( const container::ContainerEvent& /*_rEve void QueryListFacade::updateTableObjectList( bool /*_bAllowViews*/ ) { - m_rQueryList.Clear(); + m_rQueryList.clear(); try { - ImageProvider aImageProvider( m_xConnection ); - Image aQueryImage( ImageProvider::getDefaultImage( css::sdb::application::DatabaseObject::QUERY ) ); - - m_rQueryList.SetDefaultExpandedEntryBmp( aQueryImage ); - m_rQueryList.SetDefaultCollapsedEntryBmp( aQueryImage ); + OUString aQueryImage(ImageProvider::getDefaultImageResourceID(css::sdb::application::DatabaseObject::QUERY)); Reference< XQueriesSupplier > xSuppQueries( m_xConnection, UNO_QUERY_THROW ); Reference< XNameAccess > xQueries( xSuppQueries->getQueries(), UNO_QUERY_THROW ); @@ -290,7 +303,7 @@ void QueryListFacade::updateTableObjectList( bool /*_bAllowViews*/ ) Sequence< OUString > aQueryNames = xQueries->getElementNames(); for ( auto const & name : aQueryNames ) - m_rQueryList.InsertEntry( name ); + m_rQueryList.append("", name, aQueryImage); } catch( const Exception& ) { @@ -301,80 +314,63 @@ void QueryListFacade::updateTableObjectList( bool /*_bAllowViews*/ ) OUString QueryListFacade::getSelectedName( OUString& _out_rAliasName ) const { OUString sSelected; - SvTreeListEntry* pEntry = m_rQueryList.FirstSelected(); - if ( pEntry ) - sSelected = _out_rAliasName = m_rQueryList.GetEntryText( pEntry ); + std::unique_ptr<weld::TreeIter> xEntry(m_rQueryList.make_iterator()); + const bool bEntry = m_rQueryList.get_selected(xEntry.get()); + if (bEntry) + sSelected = _out_rAliasName = m_rQueryList.get_text(*xEntry); return sSelected; } bool QueryListFacade::isLeafSelected() const { - SvTreeListEntry* pEntry = m_rQueryList.FirstSelected(); - return pEntry && !m_rQueryList.GetModel()->HasChildren( pEntry ); + std::unique_ptr<weld::TreeIter> xEntry(m_rQueryList.make_iterator()); + const bool bEntry = m_rQueryList.get_selected(xEntry.get()); + return bEntry && !m_rQueryList.iter_has_child(*xEntry); + } -OAddTableDlg::OAddTableDlg( vcl::Window* pParent, IAddTableDialogContext& _rContext ) - : ModelessDialog(pParent, "TablesJoinDialog", "dbaccess/ui/tablesjoindialog.ui") +OAddTableDlg::OAddTableDlg(weld::Window* pParent, IAddTableDialogContext& _rContext) + : GenericDialogController(pParent, "dbaccess/ui/tablesjoindialog.ui", "TablesJoinDialog") , m_rContext(_rContext) + , m_xCaseTables(m_xBuilder->weld_radio_button("tables")) + , m_xCaseQueries(m_xBuilder->weld_radio_button("queries")) + , m_xTableList(new TableTreeListBox(m_xBuilder->weld_tree_view("tablelist"))) + , m_xQueryList(m_xBuilder->weld_tree_view("querylist")) + , m_xAddButton(m_xBuilder->weld_button("add")) + , m_xCloseButton(m_xBuilder->weld_button("close")) { - get(m_pCaseTables, "tables"); - get(m_pCaseQueries, "queries"); - - get(m_pTableList, "tablelist"); - get(m_pQueryList, "querylist"); - Size aSize(LogicToPixel(Size(106 , 122), MapMode(MapUnit::MapAppFont))); - m_pTableList->set_height_request(aSize.Height()); - m_pTableList->set_width_request(aSize.Width()); - get(m_pQueryList, "querylist"); - m_pQueryList->set_height_request(aSize.Height()); - m_pQueryList->set_width_request(aSize.Width()); - - get(m_pAddButton, "add"); - get(m_pCloseButton, "close"); - - m_pCaseTables->SetClickHdl( LINK( this, OAddTableDlg, OnTypeSelected ) ); - m_pCaseQueries->SetClickHdl( LINK( this, OAddTableDlg, OnTypeSelected ) ); - m_pAddButton->SetClickHdl( LINK( this, OAddTableDlg, AddClickHdl ) ); - m_pCloseButton->SetClickHdl( LINK( this, OAddTableDlg, CloseClickHdl ) ); - m_pTableList->SetDoubleClickHdl( LINK( this, OAddTableDlg, TableListDoubleClickHdl ) ); - m_pTableList->SetSelectHdl( LINK( this, OAddTableDlg, TableListSelectHdl ) ); - m_pQueryList->SetDoubleClickHdl( LINK( this, OAddTableDlg, TableListDoubleClickHdl ) ); - m_pQueryList->SetSelectHdl( LINK( this, OAddTableDlg, TableListSelectHdl ) ); - - m_pTableList->EnableInplaceEditing( false ); - m_pTableList->SetStyle(m_pTableList->GetStyle() | WB_BORDER | WB_HASLINES |WB_HASBUTTONS | WB_HASBUTTONSATROOT | WB_HASLINESATROOT | WB_SORT | WB_HSCROLL ); - m_pTableList->EnableCheckButton( nullptr ); // do not show any buttons - m_pTableList->SetSelectionMode( SelectionMode::Single ); - m_pTableList->notifyHiContrastChanged(); - m_pTableList->suppressEmptyFolders(); - - m_pQueryList->EnableInplaceEditing( false ); - m_pQueryList->SetSelectionMode( SelectionMode::Single ); + weld::TreeView& rTableList = m_xTableList->GetWidget(); + Size aSize(rTableList.get_approximate_digit_width() * 23, + rTableList.get_height_rows(15)); + rTableList.set_size_request(aSize.Width(), aSize.Height()); + m_xQueryList->set_size_request(aSize.Width(), aSize.Height()); + + m_xCaseTables->connect_clicked( LINK( this, OAddTableDlg, OnTypeSelected ) ); + m_xCaseQueries->connect_clicked( LINK( this, OAddTableDlg, OnTypeSelected ) ); + m_xAddButton->connect_clicked( LINK( this, OAddTableDlg, AddClickHdl ) ); + m_xCloseButton->connect_clicked( LINK( this, OAddTableDlg, CloseClickHdl ) ); + rTableList.connect_row_activated( LINK( this, OAddTableDlg, TableListDoubleClickHdl ) ); + rTableList.connect_changed( LINK( this, OAddTableDlg, TableListSelectHdl ) ); + m_xQueryList->connect_row_activated( LINK( this, OAddTableDlg, TableListDoubleClickHdl ) ); + m_xQueryList->connect_changed( LINK( this, OAddTableDlg, TableListSelectHdl ) ); + + rTableList.set_selection_mode(SelectionMode::Single); + m_xTableList->DisableCheckButtons(); // do not show any buttons + m_xTableList->SuppressEmptyFolders(); + + m_xQueryList->set_selection_mode(SelectionMode::Single); if ( !m_rContext.allowQueries() ) { - m_pCaseTables->Hide(); - m_pCaseQueries->Hide(); + m_xCaseTables->hide(); + m_xCaseQueries->hide(); } - SetText( getDialogTitleForContext( m_rContext ) ); + m_xDialog->set_title(getDialogTitleForContext(m_rContext)); } OAddTableDlg::~OAddTableDlg() { - disposeOnce(); -} - -void OAddTableDlg::dispose() -{ - m_rContext.onWindowClosing( this ); - m_pCaseTables.clear(); - m_pCaseQueries.clear(); - m_pTableList.clear(); - m_pQueryList.clear(); - m_pAddButton.clear(); - m_pCloseButton.clear(); - ModelessDialog::dispose(); } void OAddTableDlg::impl_switchTo( ObjectList _eList ) @@ -382,17 +378,17 @@ void OAddTableDlg::impl_switchTo( ObjectList _eList ) switch ( _eList ) { case Tables: - m_pTableList->Show(); m_pCaseTables->Check(); - m_pQueryList->Show( false ); m_pCaseQueries->Check( false ); - m_xCurrentList.reset( new TableListFacade( *m_pTableList, m_rContext.getConnection() ) ); - m_pTableList->GrabFocus(); + m_xTableList->GetWidget().show(); m_xCaseTables->set_active(true); + m_xQueryList->hide(); m_xCaseQueries->set_active(false); + m_xCurrentList.reset( new TableListFacade( *m_xTableList, m_rContext.getConnection() ) ); + m_xTableList->GetWidget().grab_focus(); break; case Queries: - m_pTableList->Show( false ); m_pCaseTables->Check( false ); - m_pQueryList->Show(); m_pCaseQueries->Check(); - m_xCurrentList.reset( new QueryListFacade( *m_pQueryList, m_rContext.getConnection() ) ); - m_pQueryList->GrabFocus(); + m_xTableList->GetWidget().hide(); m_xCaseTables->set_active(false); + m_xQueryList->show(); m_xCaseQueries->set_active(true); + m_xCurrentList.reset( new QueryListFacade( *m_xQueryList, m_rContext.getConnection() ) ); + m_xQueryList->grab_focus(); break; } m_xCurrentList->updateTableObjectList( m_rContext.allowViews() ); @@ -406,12 +402,12 @@ void OAddTableDlg::Update() m_xCurrentList->updateTableObjectList( m_rContext.allowViews() ); } -IMPL_LINK_NOARG( OAddTableDlg, AddClickHdl, Button*, void ) +IMPL_LINK_NOARG( OAddTableDlg, AddClickHdl, weld::Button&, void ) { - TableListDoubleClickHdl(nullptr); + TableListDoubleClickHdl(m_xTableList->GetWidget()); } -IMPL_LINK_NOARG( OAddTableDlg, TableListDoubleClickHdl, SvTreeListBox*, bool ) +IMPL_LINK_NOARG(OAddTableDlg, TableListDoubleClickHdl, weld::TreeView&, void) { if ( impl_isAddAllowed() ) { @@ -423,35 +419,31 @@ IMPL_LINK_NOARG( OAddTableDlg, TableListDoubleClickHdl, SvTreeListBox*, bool ) m_rContext.addTableWindow( sSelectedName, sAliasName ); } if ( !impl_isAddAllowed() ) - Close(); - return true; // handled + m_xDialog->response(RET_CLOSE); } - - return false; // not handled } -IMPL_LINK_NOARG( OAddTableDlg, TableListSelectHdl, SvTreeListBox*, void ) +IMPL_LINK_NOARG( OAddTableDlg, TableListSelectHdl, weld::TreeView&, void ) { - m_pAddButton->Enable( m_xCurrentList->isLeafSelected() ); + m_xAddButton->set_sensitive( m_xCurrentList->isLeafSelected() ); } -IMPL_LINK_NOARG( OAddTableDlg, CloseClickHdl, Button*, void ) +IMPL_LINK_NOARG( OAddTableDlg, CloseClickHdl, weld::Button&, void ) { - Close(); + m_xDialog->response(RET_CLOSE); } -IMPL_LINK_NOARG( OAddTableDlg, OnTypeSelected, Button*, void ) +IMPL_LINK_NOARG( OAddTableDlg, OnTypeSelected, weld::Button&, void ) { - if ( m_pCaseTables->IsChecked() ) + if ( m_xCaseTables->get_active() ) impl_switchTo( Tables ); else impl_switchTo( Queries ); } -bool OAddTableDlg::Close() +void OAddTableDlg::OnClose() { - m_rContext.onWindowClosing( this ); - return ModelessDialog::Close(); + m_rContext.onWindowClosing(); } bool OAddTableDlg::impl_isAddAllowed() diff --git a/dbaccess/source/ui/dlg/tablespage.cxx b/dbaccess/source/ui/dlg/tablespage.cxx index 7ceacdc70d14..b6666ead4f3e 100644 --- a/dbaccess/source/ui/dlg/tablespage.cxx +++ b/dbaccess/source/ui/dlg/tablespage.cxx @@ -210,20 +210,6 @@ namespace dbaui } } - if (!m_xCollator.is()) - { - // the collator for the string compares - try - { - m_xCollator = Collator::create(m_xORB); - m_xCollator->loadDefaultCollator(Application::GetSettings().GetLanguageTag().getLocale(), 0); - } - catch(const Exception&) - { - DBG_UNHANDLED_EXCEPTION("dbaccess"); - } - } - // fill the table list with this connection information SQLExceptionInfo aErrorInfo; // the current DSN @@ -234,7 +220,6 @@ namespace dbaui try { weld::WaitObject aWaitCursor(GetDialogFrameWeld()); - m_xTablesList->GetWidget().set_sort_order(false); Reference<XPropertySet> xProp = m_pTablesDlg->getCurrentDataSource(); OSL_ENSURE(xProp.is(),"No data source set!"); diff --git a/dbaccess/source/ui/dlg/tablespage.hxx b/dbaccess/source/ui/dlg/tablespage.hxx index 9d92a8407b80..ff21538554b3 100644 --- a/dbaccess/source/ui/dlg/tablespage.hxx +++ b/dbaccess/source/ui/dlg/tablespage.hxx @@ -40,8 +40,6 @@ namespace dbaui css::uno::Reference< css::sdbc::XConnection > m_xCurrentConnection; /// valid as long as the page is active - css::uno::Reference< css::i18n::XCollator > - m_xCollator; OTableSubscriptionDialog* m_pTablesDlg; std::unique_ptr<weld::Widget> m_xTables; diff --git a/dbaccess/source/ui/inc/JoinController.hxx b/dbaccess/source/ui/inc/JoinController.hxx index 538cf192f7a6..733e46d7dd67 100644 --- a/dbaccess/source/ui/inc/JoinController.hxx +++ b/dbaccess/source/ui/inc/JoinController.hxx @@ -48,7 +48,7 @@ namespace dbaui ::dbtools::SQLExceptionInfo m_aExceptionInfo; - VclPtr<OAddTableDlg> m_pAddTableDialog; + std::shared_ptr<OAddTableDlg> m_xAddTableDialog; std::unique_ptr< AddTableDialogContext > m_pDialogContext; Point m_aMinimumTableViewSize; @@ -82,7 +82,7 @@ namespace dbaui // attribute access TTableWindowData& getTableWindowData() { return m_vTableData; } TTableConnectionData& getTableConnectionData() { return m_vTableConnectionData;} - OAddTableDlg* getAddTableDialog()const { return m_pAddTableDialog; } + OAddTableDlg* getAddTableDialog()const { return m_xAddTableDialog.get(); } // OSingleDocumentController overridables virtual void reconnect( bool _bUI ) override; @@ -139,6 +139,9 @@ namespace dbaui return aInfo; } + // show the dialog + void runDialogAsync(); + protected: TTableWindowData::value_type createTableWindowData(const OUString& _sComposedName,const OUString& _sTableName,const OUString& _sWindowName); // ask the user if the design should be saved when it is modified diff --git a/dbaccess/source/ui/inc/adtabdlg.hxx b/dbaccess/source/ui/inc/adtabdlg.hxx index f4710a55142a..4c7589c72de3 100644 --- a/dbaccess/source/ui/inc/adtabdlg.hxx +++ b/dbaccess/source/ui/inc/adtabdlg.hxx @@ -49,47 +49,44 @@ namespace dbaui virtual bool allowQueries() const = 0; virtual bool allowAddition() const = 0; virtual void addTableWindow( const OUString& _rQualifiedTableName, const OUString& _rAliasName ) = 0; - virtual void onWindowClosing( const vcl::Window* _pWindow ) = 0; + virtual void onWindowClosing() = 0; protected: ~IAddTableDialogContext() {} }; - class OAddTableDlg : public ModelessDialog + class OAddTableDlg : public weld::GenericDialogController { - VclPtr<RadioButton> m_pCaseTables; - VclPtr<RadioButton> m_pCaseQueries; - - VclPtr<OTableTreeListBox> m_pTableList; - VclPtr<SvTreeListBox> m_pQueryList; + IAddTableDialogContext& m_rContext; std::unique_ptr< TableObjectListFacade > m_xCurrentList; - VclPtr<PushButton> m_pAddButton; - VclPtr<PushButton> m_pCloseButton; + std::unique_ptr<weld::RadioButton> m_xCaseTables; + std::unique_ptr<weld::RadioButton> m_xCaseQueries; - IAddTableDialogContext& m_rContext; + std::unique_ptr<TableTreeListBox> m_xTableList; + std::unique_ptr<weld::TreeView> m_xQueryList; - DECL_LINK( AddClickHdl, Button*, void ); - DECL_LINK( CloseClickHdl, Button*, void); - DECL_LINK( TableListDoubleClickHdl, SvTreeListBox*, bool ); - DECL_LINK( TableListSelectHdl, SvTreeListBox*, void ); - DECL_LINK( OnTypeSelected, Button*, void ); + std::unique_ptr<weld::Button> m_xAddButton; + std::unique_ptr<weld::Button> m_xCloseButton; + + DECL_LINK( AddClickHdl, weld::Button&, void ); + DECL_LINK( CloseClickHdl, weld::Button&, void); + DECL_LINK( TableListDoubleClickHdl, weld::TreeView&, void ); + DECL_LINK( TableListSelectHdl, weld::TreeView&, void ); + DECL_LINK( OnTypeSelected, weld::Button&, void ); public: - OAddTableDlg( - vcl::Window* _pParent, - IAddTableDialogContext& _rContext ); + OAddTableDlg(weld::Window* _pParent, + IAddTableDialogContext& _rContext); virtual ~OAddTableDlg() override; - virtual void dispose() override; void Update(); + void OnClose(); static OUString getDialogTitleForContext( IAddTableDialogContext const & _rContext ); private: - virtual bool Close() override; - bool impl_isAddAllowed(); enum ObjectList diff --git a/dbaccess/source/ui/inc/tabletree.hxx b/dbaccess/source/ui/inc/tabletree.hxx index e5f9e32a5e21..27eedbda7575 100644 --- a/dbaccess/source/ui/inc/tabletree.hxx +++ b/dbaccess/source/ui/inc/tabletree.hxx @@ -167,6 +167,8 @@ class TableTreeListBox m_xImageProvider; // provider for our images bool m_bVirtualRoot; // should the first entry be visible bool m_bNoEmptyFolders; // should empty catalogs/schematas be prevented from being displayed? + bool m_bShowToggles; // show toggle buttons + int m_nTextColumn; // column text is in, depends on if toggles are shown std::unique_ptr<weld::TreeView> m_xTreeView; public: @@ -179,7 +181,8 @@ public: typedef std::pair< OUString, bool > TTableViewName; typedef std::vector< TTableViewName > TNames; - void suppressEmptyFolders() { m_bNoEmptyFolders = true; } + void SuppressEmptyFolders() { m_bNoEmptyFolders = true; } + void DisableCheckButtons(); /** determines whether the given entry denotes a tables folder */ diff --git a/dbaccess/source/ui/querydesign/JoinController.cxx b/dbaccess/source/ui/querydesign/JoinController.cxx index e89dace04e84..eae59834ce58 100644 --- a/dbaccess/source/ui/querydesign/JoinController.cxx +++ b/dbaccess/source/ui/querydesign/JoinController.cxx @@ -86,7 +86,7 @@ public: virtual bool allowQueries() const override; virtual bool allowAddition() const override; virtual void addTableWindow( const OUString& _rQualifiedTableName, const OUString& _rAliasName ) override; - virtual void onWindowClosing( const vcl::Window* _pWindow ) override; + virtual void onWindowClosing() override; private: OJoinTableView* getTableView() const; @@ -117,14 +117,10 @@ void AddTableDialogContext::addTableWindow( const OUString& _rQualifiedTableName getTableView()->AddTabWin( _rQualifiedTableName, _rAliasName, true ); } -void AddTableDialogContext::onWindowClosing( const vcl::Window* _pWindow ) +void AddTableDialogContext::onWindowClosing() { - if ( !m_rController.getView() ) + if (!m_rController.getView()) return; - - ::dbaui::notifySystemWindow( - m_rController.getView(), const_cast< vcl::Window* >( _pWindow ), ::comphelper::mem_fun( &TaskPaneList::RemoveWindow ) ); - m_rController.InvalidateFeature( ID_BROWSER_ADDTABLE ); m_rController.getView()->GrabFocus(); } @@ -139,8 +135,7 @@ OJoinTableView* AddTableDialogContext::getTableView() const // OJoinController OJoinController::OJoinController(const Reference< XComponentContext >& _rM) - :OJoinController_BASE(_rM) - ,m_pAddTableDialog(nullptr) + : OJoinController_BASE(_rM) { } @@ -155,7 +150,11 @@ OJoinDesignView* OJoinController::getJoinView() void OJoinController::disposing() { - m_pAddTableDialog.disposeAndClear(); + if (m_xAddTableDialog) + { + m_xAddTableDialog->response(RET_CLOSE); + m_xAddTableDialog.reset(); + } OJoinController_BASE::disposing(); @@ -168,8 +167,8 @@ void OJoinController::disposing() void OJoinController::reconnect( bool _bUI ) { OJoinController_BASE::reconnect( _bUI ); - if ( isConnected() && m_pAddTableDialog ) - m_pAddTableDialog->Update(); + if ( isConnected() && m_xAddTableDialog ) + m_xAddTableDialog->Update(); } void OJoinController::impl_onModifyChanged() @@ -207,7 +206,7 @@ FeatureState OJoinController::GetState(sal_uInt16 _nId) const case ID_BROWSER_ADDTABLE: aReturn.bEnabled = ( getView() != nullptr ) && const_cast< OJoinController* >( this )->getJoinView()->getTableView()->IsAddAllowed(); - aReturn.bChecked = aReturn.bEnabled && m_pAddTableDialog != nullptr && m_pAddTableDialog->IsVisible() ; + aReturn.bChecked = aReturn.bEnabled && m_xAddTableDialog; if ( aReturn.bEnabled ) aReturn.sTitle = OAddTableDlg::getDialogTitleForContext( impl_getDialogContext() ); break; @@ -253,22 +252,14 @@ void OJoinController::Execute(sal_uInt16 _nId, const Sequence< PropertyValue >& InvalidateAll(); return; case ID_BROWSER_ADDTABLE: - if ( !m_pAddTableDialog ) - m_pAddTableDialog = VclPtr<OAddTableDlg>::Create( getView(), impl_getDialogContext() ); - - if ( m_pAddTableDialog->IsVisible() ) + if (m_xAddTableDialog) { - m_pAddTableDialog->Show( false ); + m_xAddTableDialog->response(RET_CLOSE); getView()->GrabFocus(); } else { - { - WaitObject aWaitCursor( getView() ); - m_pAddTableDialog->Update(); - } - m_pAddTableDialog->Show(); - ::dbaui::notifySystemWindow(getView(),m_pAddTableDialog,::comphelper::mem_fun(&TaskPaneList::AddWindow)); + runDialogAsync(); } break; default: @@ -277,6 +268,20 @@ void OJoinController::Execute(sal_uInt16 _nId, const Sequence< PropertyValue >& InvalidateFeature(_nId); } +void OJoinController::runDialogAsync() +{ + assert(!m_xAddTableDialog); + m_xAddTableDialog.reset(new OAddTableDlg(getFrameWeld(), impl_getDialogContext())); + { + weld::WaitObject aWaitCursor(getFrameWeld()); + m_xAddTableDialog->Update(); + } + weld::DialogController::runAsync(m_xAddTableDialog, [this](sal_Int32 /*nResult*/){ + m_xAddTableDialog->OnClose(); + m_xAddTableDialog.reset(); + }); +} + void OJoinController::SaveTabWinsPosSize( OJoinTableView::OTableWindowMap* pTabWinList, long nOffsetX, long nOffsetY ) { // Deletion and recreation of the old implementation with the current model is not correct anymore: diff --git a/dbaccess/source/ui/querydesign/QueryViewSwitch.cxx b/dbaccess/source/ui/querydesign/QueryViewSwitch.cxx index 8d26b499de0f..c9c59eae908c 100644 --- a/dbaccess/source/ui/querydesign/QueryViewSwitch.cxx +++ b/dbaccess/source/ui/querydesign/QueryViewSwitch.cxx @@ -149,9 +149,9 @@ void OQueryViewSwitch::impl_forceSQLView() OAddTableDlg* pAddTabDialog( getAddTableDialog() ); // hide the "Add Table" dialog - m_bAddTableDialogWasVisible = pAddTabDialog && pAddTabDialog->IsVisible(); - if ( m_bAddTableDialogWasVisible ) - pAddTabDialog->Hide(); + m_bAddTableDialogWasVisible = pAddTabDialog != nullptr; + if (m_bAddTableDialogWasVisible) + pAddTabDialog->response(RET_CLOSE); // tell the views they're in/active m_pDesignView->stopTimer(); @@ -226,7 +226,7 @@ bool OQueryViewSwitch::impl_postViewSwitch( const bool i_bGraphicalDesign, const OAddTableDlg* pAddTabDialog( getAddTableDialog() ); if ( pAddTabDialog ) if ( i_bGraphicalDesign && m_bAddTableDialogWasVisible ) - pAddTabDialog->Show(); + m_pDesignView->getController().runDialogAsync(); GrabFocus(); } diff --git a/dbaccess/uiconfig/ui/tablesfilterdialog.ui b/dbaccess/uiconfig/ui/tablesfilterdialog.ui index 6069415d6fae..f0f4a9dec946 100644 --- a/dbaccess/uiconfig/ui/tablesfilterdialog.ui +++ b/dbaccess/uiconfig/ui/tablesfilterdialog.ui @@ -1,5 +1,5 @@ <?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"/> <object class="GtkDialog" id="TablesFilterDialog"> @@ -7,7 +7,13 @@ <property name="border_width">6</property> <property name="title" translatable="yes" context="tablesfilterdialog|TablesFilterDialog">Tables Filter</property> <property name="resizable">False</property> + <property name="modal">True</property> + <property name="default_width">0</property> + <property name="default_height">0</property> <property name="type_hint">dialog</property> + <child> + <placeholder/> + </child> <child internal-child="vbox"> <object class="GtkBox" id="dialog-vbox1"> <property name="can_focus">False</property> diff --git a/dbaccess/uiconfig/ui/tablesjoindialog.ui b/dbaccess/uiconfig/ui/tablesjoindialog.ui index f776fcb92f50..37d26ac840a9 100644 --- a/dbaccess/uiconfig/ui/tablesjoindialog.ui +++ b/dbaccess/uiconfig/ui/tablesjoindialog.ui @@ -1,13 +1,37 @@ <?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="GtkTreeStore" id="liststore1"> + <columns> + <!-- column-name expander --> + <column type="GdkPixbuf"/> + <!-- column-name text --> + <column type="gchararray"/> + <!-- column-name id --> + <column type="gchararray"/> + </columns> + </object> + <object class="GtkTreeStore" id="liststore2"> + <columns> + <!-- column-name expander --> + <column type="GdkPixbuf"/> + <!-- column-name text --> + <column type="gchararray"/> + <!-- column-name id --> + <column type="gchararray"/> + </columns> + </object> <object class="GtkDialog" id="TablesJoinDialog"> <property name="can_focus">False</property> <property name="border_width">6</property> <property name="resizable">False</property> + <property name="default_width">0</property> + <property name="default_height">0</property> <property name="type_hint">dialog</property> + <child> + <placeholder/> + </child> <child internal-child="vbox"> <object class="GtkBox" id="dialog-vbox1"> <property name="can_focus">False</property> @@ -87,7 +111,6 @@ <property name="xalign">0</property> <property name="active">True</property> <property name="draw_indicator">True</property> - <property name="group">queries</property> </object> <packing> <property name="left_attach">0</property> @@ -101,7 +124,7 @@ <property name="can_focus">True</property> <property name="receives_default">False</property> <property name="use_underline">True</property> - <property name="xalign">0.0099999997764825821</property> + <property name="xalign">0</property> <property name="draw_indicator">True</property> <property name="group">tables</property> </object> @@ -111,13 +134,46 @@ </packing> </child> <child> - <object class="dbulo-OTableTreeListBox" id="tablelist:border"> + <object class="GtkScrolledWindow"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="hexpand">True</property> <property name="vexpand">True</property> - <child internal-child="selection"> - <object class="GtkTreeSelection" id="OTableTreeListBox-selection3"/> + <property name="shadow_type">in</property> + <child> + <object class="GtkTreeView" id="tablelist"> + <property name="width_request">-1</property> + <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> + <property name="enable_tree_lines">True</property> + <child internal-child="selection"> + <object class="GtkTreeSelection" id="Macro Library List-selection2"/> + </child> + <child> + <object class="GtkTreeViewColumn" id="treeviewcolumn8"> + <property name="spacing">6</property> + <child> + <object class="GtkCellRendererPixbuf" id="cellrenderertext5"/> + <attributes> + <attribute name="pixbuf">0</attribute> + </attributes> + </child> + <child> + <object class="GtkCellRendererText" id="cellrenderertext6"/> + <attributes> + <attribute name="text">1</attribute> + </attributes> + </child> + </object> + </child> + </object> </child> </object> <packing> @@ -148,13 +204,46 @@ </packing> </child> <child> - <object class="vcllo-SvTreeListBox" id="querylist:border"> + <object class="GtkScrolledWindow"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="hexpand">True</property> <property name="vexpand">True</property> - <child internal-child="selection"> - <object class="GtkTreeSelection" id="Tree List-selection3"/> + <property name="shadow_type">in</property> + <child> + <object class="GtkTreeView" id="querylist"> + <property name="width_request">-1</property> + <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">liststore1</property> + <property name="headers_visible">False</property> + <property name="search_column">1</property> + <property name="show_expanders">False</property> + <property name="enable_tree_lines">True</property> + <child internal-child="selection"> + <object class="GtkTreeSelection" id="Macro Library List-selection3"/> + </child> + <child> + <object class="GtkTreeViewColumn" id="treeviewcolumn18"> + <property name="spacing">6</property> + <child> + <object class="GtkCellRendererPixbuf" id="cellrenderertext15"/> + <attributes> + <attribute name="pixbuf">0</attribute> + </attributes> + </child> + <child> + <object class="GtkCellRendererText" id="cellrenderertext16"/> + <attributes> + <attribute name="text">1</attribute> + </attributes> + </child> + </object> + </child> + </object> </child> </object> <packing> |