diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-07-03 10:19:21 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-07-03 11:19:00 +0200 |
commit | 79cb267812f0c22919fddc4d60d381fa649f8d05 (patch) | |
tree | dc93ce86f276270fa45c7eb310b3b35c9975cfd9 /dbaccess/source | |
parent | e119194aeec907f3d02cb914e5afde5ac763df7c (diff) |
no need to switch models in the SvTreeListBox
since we're replacing it completely anyhow.
which means we can remove DisconnectFromModel
Change-Id: I2f31d93eb95a641f3364d715111e70817c7e5087
Reviewed-on: https://gerrit.libreoffice.org/56849
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'dbaccess/source')
-rw-r--r-- | dbaccess/source/ui/browser/dbtreeview.cxx | 20 | ||||
-rw-r--r-- | dbaccess/source/ui/browser/dbtreeview.hxx | 2 | ||||
-rw-r--r-- | dbaccess/source/ui/browser/dsEntriesNoExp.cxx | 11 | ||||
-rw-r--r-- | dbaccess/source/ui/browser/dsbrowserDnD.cxx | 7 | ||||
-rw-r--r-- | dbaccess/source/ui/browser/unodatbr.cxx | 54 | ||||
-rw-r--r-- | dbaccess/source/ui/inc/unodatbr.hxx | 3 |
6 files changed, 41 insertions, 56 deletions
diff --git a/dbaccess/source/ui/browser/dbtreeview.cxx b/dbaccess/source/ui/browser/dbtreeview.cxx index 75efb9995aa5..38e94cbcf199 100644 --- a/dbaccess/source/ui/browser/dbtreeview.cxx +++ b/dbaccess/source/ui/browser/dbtreeview.cxx @@ -50,18 +50,15 @@ DBTreeView::~DBTreeView() void DBTreeView::dispose() { - if (m_pTreeListBox) - { - if (m_pTreeListBox->GetModel()) - { - m_pTreeListBox->GetModel()->RemoveView(m_pTreeListBox); - m_pTreeListBox->DisconnectFromModel(); - } - } m_pTreeListBox.disposeAndClear(); vcl::Window::dispose(); } +SvTreeList* DBTreeView::GetTreeModel() +{ + return m_pTreeListBox->GetModel(); +} + void DBTreeView::SetPreExpandHandler(const Link<SvTreeListEntry*,bool>& _rHdl) { m_pTreeListBox->SetPreExpandHandler(_rHdl); @@ -78,13 +75,6 @@ void DBTreeView::Resize() m_pTreeListBox->SetPosSizePixel(Point(0,0),GetOutputSizePixel()); } -void DBTreeView::setModel(SvTreeList* _pTreeModel) -{ - if (_pTreeModel) - _pTreeModel->InsertView(m_pTreeListBox); - m_pTreeListBox->SetModel(_pTreeModel); -} - void DBTreeView::setSelChangeHdl( const Link<LinkParamNone*,void>& _rHdl ) { m_pTreeListBox->SetSelChangeHdl( _rHdl ); diff --git a/dbaccess/source/ui/browser/dbtreeview.hxx b/dbaccess/source/ui/browser/dbtreeview.hxx index 40994107f3d9..6ff5959e9ae5 100644 --- a/dbaccess/source/ui/browser/dbtreeview.hxx +++ b/dbaccess/source/ui/browser/dbtreeview.hxx @@ -52,7 +52,7 @@ namespace dbaui void setCopyHandler(const Link<LinkParamNone*,void>& _rHdl); - void setModel(SvTreeList* _pTreeModel); + SvTreeList* GetTreeModel(); void setSelChangeHdl(const Link<LinkParamNone*,void>& _rHdl); DBTreeListBox& getListBox() const { return *m_pTreeListBox; } diff --git a/dbaccess/source/ui/browser/dsEntriesNoExp.cxx b/dbaccess/source/ui/browser/dsEntriesNoExp.cxx index e5944d1969a0..1dd3a0991fb9 100644 --- a/dbaccess/source/ui/browser/dsEntriesNoExp.cxx +++ b/dbaccess/source/ui/browser/dsEntriesNoExp.cxx @@ -109,7 +109,7 @@ void SbaTableQueryBrowser::select(SvTreeListEntry* _pEntry, bool _bSelect) if (pTextItem) { static_cast<OBoldListboxString*>(pTextItem)->emphasize(_bSelect); - m_pTreeModel->InvalidateEntry(_pEntry); + m_pTreeView->GetTreeModel()->InvalidateEntry(_pEntry); } else { OSL_FAIL("SbaTableQueryBrowser::select: invalid entry!"); @@ -121,7 +121,7 @@ void SbaTableQueryBrowser::selectPath(SvTreeListEntry* _pEntry, bool _bSelect) while (_pEntry) { select(_pEntry, _bSelect); - _pEntry = m_pTreeModel->GetParent(_pEntry); + _pEntry = m_pTreeView->GetTreeModel()->GetParent(_pEntry); } } @@ -197,14 +197,15 @@ void SbaTableQueryBrowser::notifyHiContrastChanged() { if ( m_pTreeView ) { + auto pTreeModel = m_pTreeView->GetTreeModel(); // change all bitmap entries - SvTreeListEntry* pEntryLoop = m_pTreeModel->First(); + SvTreeListEntry* pEntryLoop = pTreeModel->First(); while ( pEntryLoop ) { DBTreeListUserData* pData = static_cast<DBTreeListUserData*>(pEntryLoop->GetUserData()); if ( !pData ) { - pEntryLoop = m_pTreeModel->Next(pEntryLoop); + pEntryLoop = pTreeModel->Next(pEntryLoop); continue; } @@ -245,7 +246,7 @@ void SbaTableQueryBrowser::notifyHiContrastChanged() break; } - pEntryLoop = m_pTreeModel->Next(pEntryLoop); + pEntryLoop = pTreeModel->Next(pEntryLoop); } } } diff --git a/dbaccess/source/ui/browser/dsbrowserDnD.cxx b/dbaccess/source/ui/browser/dsbrowserDnD.cxx index dc34baf2443e..8ec849dac474 100644 --- a/dbaccess/source/ui/browser/dsbrowserDnD.cxx +++ b/dbaccess/source/ui/browser/dsbrowserDnD.cxx @@ -233,10 +233,11 @@ namespace dbaui } void SbaTableQueryBrowser::clearTreeModel() { - if (m_pTreeModel) + if (m_pTreeView) { + auto pTreeModel = m_pTreeView->GetTreeModel(); // clear the user data of the tree model - SvTreeListEntry* pEntryLoop = m_pTreeModel->First(); + SvTreeListEntry* pEntryLoop = pTreeModel->First(); while (pEntryLoop) { DBTreeListUserData* pData = static_cast<DBTreeListUserData*>(pEntryLoop->GetUserData()); @@ -256,7 +257,7 @@ namespace dbaui delete pData; } - pEntryLoop = m_pTreeModel->Next(pEntryLoop); + pEntryLoop = pTreeModel->Next(pEntryLoop); } } m_pCurrentlyDisplayed = nullptr; diff --git a/dbaccess/source/ui/browser/unodatbr.cxx b/dbaccess/source/ui/browser/unodatbr.cxx index 44fcb8688a07..6eb0557ceed3 100644 --- a/dbaccess/source/ui/browser/unodatbr.cxx +++ b/dbaccess/source/ui/browser/unodatbr.cxx @@ -213,7 +213,6 @@ SbaTableQueryBrowser::SbaTableQueryBrowser(const Reference< XComponentContext >& ,m_aTableCopyHelper(this) ,m_pTreeView(nullptr) ,m_pSplitter(nullptr) - ,m_pTreeModel(nullptr) ,m_pCurrentlyDisplayed(nullptr) ,m_nAsyncDrop(nullptr) ,m_bQueryEscapeProcessing( false ) @@ -286,16 +285,12 @@ void SAL_CALL SbaTableQueryBrowser::disposing() m_aSelectionListeners.disposeAndClear(aEvt); m_aContextMenuInterceptors.disposeAndClear(aEvt); - // reset the content's tree view: it holds a reference to our model which is to be deleted immediately, - // and it will live longer than we do. if (getBrowserView()) - getBrowserView()->setTreeView(nullptr); - - clearTreeModel(); - // clear the tree model { - std::unique_ptr<SvTreeList> aTemp(m_pTreeModel); - m_pTreeModel = nullptr; + // Need to do some cleaup of the data pointed to the tree view entries before we remove the treeview + clearTreeModel(); + m_pTreeView = nullptr; + getBrowserView()->setTreeView(nullptr); } // remove ourself as status listener @@ -364,10 +359,9 @@ bool SbaTableQueryBrowser::Construct(vcl::Window* pParent) getBrowserView()->setTreeView(m_pTreeView); // fill view with data - m_pTreeModel = new SvTreeList; - m_pTreeModel->SetSortMode(SortAscending); - m_pTreeModel->SetCompareHdl(LINK(this, SbaTableQueryBrowser, OnTreeEntryCompare)); - m_pTreeView->setModel(m_pTreeModel); + auto pTreeModel = m_pTreeView->GetTreeModel(); + pTreeModel->SetSortMode(SortAscending); + pTreeModel->SetCompareHdl(LINK(this, SbaTableQueryBrowser, OnTreeEntryCompare)); m_pTreeView->setSelChangeHdl( LINK( this, SbaTableQueryBrowser, OnSelectionChange ) ); // TODO @@ -2455,7 +2449,7 @@ SvTreeListEntry* SbaTableQueryBrowser::implGetConnectionEntry(SvTreeListEntry* _ DBTreeListUserData* pEntryData = static_cast< DBTreeListUserData* >( pCurrentEntry->GetUserData() ); while(pEntryData->eType != etDatasource ) { - pCurrentEntry = m_pTreeModel->GetParent(pCurrentEntry); + pCurrentEntry = m_pTreeView->GetTreeModel()->GetParent(pCurrentEntry); pEntryData = static_cast< DBTreeListUserData* >( pCurrentEntry->GetUserData() ); } return pCurrentEntry; @@ -2477,11 +2471,11 @@ bool SbaTableQueryBrowser::implSelect( SvTreeListEntry* _pEntry ) return false; } - OSL_ENSURE(m_pTreeModel->HasParent(_pEntry), "SbaTableQueryBrowser::implSelect: invalid entry (1)!"); - OSL_ENSURE(m_pTreeModel->HasParent(m_pTreeModel->GetParent(_pEntry)), "SbaTableQueryBrowser::implSelect: invalid entry (2)!"); + OSL_ENSURE(m_pTreeView->GetTreeModel()->HasParent(_pEntry), "SbaTableQueryBrowser::implSelect: invalid entry (1)!"); + OSL_ENSURE(m_pTreeView->GetTreeModel()->HasParent(m_pTreeView->GetTreeModel()->GetParent(_pEntry)), "SbaTableQueryBrowser::implSelect: invalid entry (2)!"); // get the entry for the tables or queries - SvTreeListEntry* pContainer = m_pTreeModel->GetParent(_pEntry); + SvTreeListEntry* pContainer = m_pTreeView->GetTreeModel()->GetParent(_pEntry); DBTreeListUserData* pContainerData = static_cast<DBTreeListUserData*>(pContainer->GetUserData()); // get the entry for the datasource @@ -2506,13 +2500,13 @@ bool SbaTableQueryBrowser::implSelect( SvTreeListEntry* _pEntry ) if ( etQueryContainer == pContainerData->eType ) { SvTreeListEntry* pTemp = pContainer; - while( m_pTreeModel->GetParent(pTemp) != pConnection ) + while( m_pTreeView->GetTreeModel()->GetParent(pTemp) != pConnection ) { sNameBuffer.insert(0,'/'); pString = static_cast<SvLBoxString*>(pTemp->GetFirstItem(SvLBoxItemType::String)); OSL_ENSURE(pString,"There must be a string item!"); sNameBuffer.insert(0,pString->GetText()); - pTemp = m_pTreeModel->GetParent(pTemp); + pTemp = m_pTreeView->GetTreeModel()->GetParent(pTemp); } } OUString aName = sNameBuffer.makeStringAndClear(); @@ -2773,12 +2767,12 @@ void SAL_CALL SbaTableQueryBrowser::elementRemoved( const ContainerEvent& _rEven pTemp->SetUserData(nullptr); delete pData; // the data could be null because we have a table which isn't correct - m_pTreeModel->Remove(pTemp); + m_pTreeView->GetTreeModel()->Remove(pTemp); } else { // remove the entry from the model - SvTreeListEntry* pChild = m_pTreeModel->FirstChild(pContainer); + SvTreeListEntry* pChild = m_pTreeView->GetTreeModel()->FirstChild(pContainer); while(pChild) { if (m_pTreeView->getListBox().GetEntryText(pChild) == aName) @@ -2786,7 +2780,7 @@ void SAL_CALL SbaTableQueryBrowser::elementRemoved( const ContainerEvent& _rEven DBTreeListUserData* pData = static_cast<DBTreeListUserData*>(pChild->GetUserData()); pChild->SetUserData(nullptr); delete pData; - m_pTreeModel->Remove(pChild); + m_pTreeView->GetTreeModel()->Remove(pChild); break; } pChild = pChild->NextSibling(); @@ -2834,7 +2828,7 @@ void SAL_CALL SbaTableQueryBrowser::elementReplaced( const ContainerEvent& _rEve else { // find the entry for this name - SvTreeListEntry* pChild = m_pTreeModel->FirstChild(pContainer); + SvTreeListEntry* pChild = m_pTreeView->GetTreeModel()->FirstChild(pContainer); while(pChild) { if (m_pTreeView->getListBox().GetEntryText(pChild) == aName) @@ -2921,9 +2915,9 @@ void SbaTableQueryBrowser::closeConnection(SvTreeListEntry* _pDSEntry, bool _bDi unloadAndCleanup(_bDisposeConnection); // collapse the query/table container - for (SvTreeListEntry* pContainers = m_pTreeModel->FirstChild(_pDSEntry); pContainers; pContainers = pContainers->NextSibling()) + for (SvTreeListEntry* pContainers = m_pTreeView->GetTreeModel()->FirstChild(_pDSEntry); pContainers; pContainers = pContainers->NextSibling()) { - SvTreeListEntry* pElements = m_pTreeModel->FirstChild(pContainers); + SvTreeListEntry* pElements = m_pTreeView->GetTreeModel()->FirstChild(pContainers); if ( pElements ) m_pTreeView->getListBox().Collapse(pContainers); m_pTreeView->getListBox().EnableExpandHandler(pContainers); @@ -2935,7 +2929,7 @@ void SbaTableQueryBrowser::closeConnection(SvTreeListEntry* _pDSEntry, bool _bDi DBTreeListUserData* pData = static_cast<DBTreeListUserData*>(pRemove->GetUserData()); pRemove->SetUserData(nullptr); delete pData; - m_pTreeModel->Remove(pRemove); + m_pTreeView->GetTreeModel()->Remove(pRemove); } } // collapse the entry itself @@ -3273,7 +3267,7 @@ bool SbaTableQueryBrowser::getExistentConnectionFor( SvTreeListEntry* _pAnyEntry bool SbaTableQueryBrowser::impl_isDataSourceEntry( SvTreeListEntry* _pEntry ) const { - return m_pTreeModel->GetRootLevelParent( _pEntry ) == _pEntry; + return m_pTreeView->GetTreeModel()->GetRootLevelParent( _pEntry ) == _pEntry; } bool SbaTableQueryBrowser::ensureConnection( SvTreeListEntry* _pDSEntry, void* pDSData, SharedConnection& _rConnection ) @@ -3596,7 +3590,7 @@ OUString SbaTableQueryBrowser::getPrivateTitle() const OUString sTitle; if ( m_pCurrentlyDisplayed ) { - SvTreeListEntry* pContainer = m_pTreeModel->GetParent(m_pCurrentlyDisplayed); + SvTreeListEntry* pContainer = m_pTreeView->GetTreeModel()->GetParent(m_pCurrentlyDisplayed); // get the entry for the datasource SvTreeListEntry* pConnection = implGetConnectionEntry(pContainer); OUString sName = m_pTreeView->getListBox().GetEntryText(m_pCurrentlyDisplayed); @@ -3721,7 +3715,7 @@ void SbaTableQueryBrowser::impl_cleanupDataSourceEntry( const OUString& _rDataSo // delete any user data of the child entries of the to-be-removed entry std::pair<SvTreeListEntries::const_iterator, SvTreeListEntries::const_iterator> aIters = - m_pTreeModel->GetChildIterators(pDataSourceEntry); + m_pTreeView->GetTreeModel()->GetChildIterators(pDataSourceEntry); SvTreeListEntries::const_iterator it = aIters.first, itEnd = aIters.second; @@ -3737,7 +3731,7 @@ void SbaTableQueryBrowser::impl_cleanupDataSourceEntry( const OUString& _rDataSo DBTreeListUserData* pData = static_cast< DBTreeListUserData* >( pDataSourceEntry->GetUserData() ); pDataSourceEntry->SetUserData( nullptr ); delete pData; - m_pTreeModel->Remove( pDataSourceEntry ); + m_pTreeView->GetTreeModel()->Remove( pDataSourceEntry ); } void SAL_CALL SbaTableQueryBrowser::revokedDatabaseLocation( const DatabaseRegistrationEvent& Event ) diff --git a/dbaccess/source/ui/inc/unodatbr.hxx b/dbaccess/source/ui/inc/unodatbr.hxx index 49ee4e3b513e..1e4417c5df47 100644 --- a/dbaccess/source/ui/inc/unodatbr.hxx +++ b/dbaccess/source/ui/inc/unodatbr.hxx @@ -99,9 +99,8 @@ namespace dbaui OUString m_sQueryCommand; // the command of the query currently loaded (if any) //OUString m_sToBeLoaded; // contains the element name which should be loaded if any - VclPtr<DBTreeView> m_pTreeView; + VclPtr<DBTreeView> m_pTreeView; // contains the datasources of the registry VclPtr<Splitter> m_pSplitter; - SvTreeList* m_pTreeModel; // contains the datasources of the registry SvTreeListEntry* m_pCurrentlyDisplayed; ImplSVEvent * m_nAsyncDrop; |