diff --git a/dbaccess/source/ui/browser/dbtreemodel.cxx b/dbaccess/source/ui/browser/dbtreemodel.cxx index ef56aa9834d1..3edb5f936518 100644 --- a/dbaccess/source/ui/browser/dbtreemodel.cxx +++ b/dbaccess/source/ui/browser/dbtreemodel.cxx @@ -4,9 +4,9 @@ * * $RCSfile: dbtreemodel.cxx,v $ * - * $Revision: 1.16 $ + * $Revision: 1.17 $ * - * last change: $Author: obo $ $Date: 2006-09-17 06:57:19 $ + * last change: $Author: kz $ $Date: 2006-10-05 13:01:33 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -63,30 +63,4 @@ namespace dbaui { DBG_DTOR(DBTreeListUserData,NULL); } - - //------------------------------------------------------------------------ - sal_uInt16 DBTreeListModel::getImageResId(SbaTableQueryBrowser::EntryType _eType, - sal_Bool _bHiContrast) - { - switch (_eType) - { - case SbaTableQueryBrowser::etTable: - return _bHiContrast ? TABLE_TREE_ICON_SCH : TABLE_TREE_ICON; - case SbaTableQueryBrowser::etView: - return _bHiContrast ? VIEW_TREE_ICON_SCH : VIEW_TREE_ICON; - case SbaTableQueryBrowser::etQuery: - return _bHiContrast ? QUERY_TREE_ICON_SCH : QUERY_TREE_ICON; - case SbaTableQueryBrowser::etDatasource: - return _bHiContrast ? IMG_DATABASE_SCH : IMG_DATABASE; - case SbaTableQueryBrowser::etQueryContainer: - return _bHiContrast ? QUERYFOLDER_TREE_ICON_SCH : QUERYFOLDER_TREE_ICON; - case SbaTableQueryBrowser::etTableContainer: - return _bHiContrast ? TABLEFOLDER_TREE_ICON_SCH : TABLEFOLDER_TREE_ICON; - case SbaTableQueryBrowser::etUnknown: - break; - } - OSL_ENSURE(sal_False, "DBTreeListModel::getImageResId: invalid entry type!"); - return 0; - } - } diff --git a/dbaccess/source/ui/browser/dsEntriesNoExp.cxx b/dbaccess/source/ui/browser/dsEntriesNoExp.cxx index efc4bcc1c53e..2dba3fbdb055 100644 --- a/dbaccess/source/ui/browser/dsEntriesNoExp.cxx +++ b/dbaccess/source/ui/browser/dsEntriesNoExp.cxx @@ -4,9 +4,9 @@ * * $RCSfile: dsEntriesNoExp.cxx,v $ * - * $Revision: 1.16 $ + * $Revision: 1.17 $ * - * last change: $Author: obo $ $Date: 2006-09-17 06:57:47 $ + * last change: $Author: kz $ $Date: 2006-10-05 13:02:00 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -45,6 +45,9 @@ #ifndef _DBAUI_LISTVIEWITEMS_HXX_ #include "listviewitems.hxx" #endif +#ifndef DBACCESS_IMAGEPROVIDER_HXX +#include "imageprovider.hxx" +#endif #ifndef _TOOLS_DEBUG_HXX #include #endif @@ -76,7 +79,7 @@ SbaTableQueryBrowser::EntryType SbaTableQueryBrowser::getChildType( SvLBoxEntry* switch (getEntryType(_pEntry)) { case etTableContainer: - return etTable; + return etTableOrView; case etQueryContainer: return etQuery; default: @@ -118,7 +121,7 @@ SbaTableQueryBrowser::EntryType SbaTableQueryBrowser::getEntryType( SvLBoxEntry* return etQueryContainer; if (pTables == pEntryParent) - return etTable; + return etTableOrView; if (pQueries == pEntryParent) return etQuery; @@ -196,39 +199,78 @@ String SbaTableQueryBrowser::getURL() const { return String(); } + +// ----------------------------------------------------------------------------- +sal_Int32 SbaTableQueryBrowser::getDatabaseObjectType( EntryType _eType ) +{ + switch ( _eType ) + { + case etQuery: + case etQueryContainer: + return DatabaseObject::QUERY; + case etTableOrView: + case etTableContainer: + return DatabaseObject::TABLE; + default: + break; + } + OSL_ENSURE( false, "SbaTableQueryBrowser::getDatabaseObjectType: folder types and 'Unknown' not allowed here!" ); + return DatabaseObject::TABLE; +} + // ----------------------------------------------------------------------------- void SbaTableQueryBrowser::notifyHiContrastChanged() { if ( m_pTreeView ) { - sal_Bool bHiContrast = isHiContrast(); - - if ( m_bHiContrast != bHiContrast ) + // change all bitmap entries + SvLBoxEntry* pEntryLoop = m_pTreeModel->First(); + while ( pEntryLoop ) { - m_bHiContrast = bHiContrast; - // change all bitmap entries - SvLBoxEntry* pEntryLoop = m_pTreeModel->First(); - while ( pEntryLoop ) + DBTreeListModel::DBTreeListUserData* pData = static_cast(pEntryLoop->GetUserData()); + if ( !pData ) { - DBTreeListModel::DBTreeListUserData* pData = static_cast(pEntryLoop->GetUserData()); - if ( pData ) - { - ModuleRes aResId(DBTreeListModel::getImageResId(pData->eType,isHiContrast())); - Image aImage(aResId); - USHORT nCount = pEntryLoop->ItemCount(); - for (USHORT i=0;iGetItem(i); - if ( pItem && pItem->IsA() == SV_ITEM_ID_LBOXCONTEXTBMP) - { - static_cast(pItem)->SetBitmap1( aImage ); - static_cast(pItem)->SetBitmap2( aImage ); - break; - } - } - } pEntryLoop = m_pTreeModel->Next(pEntryLoop); + continue; } + + // the connection to which this entry belongs, if any + ::std::auto_ptr< ImageProvider > pImageProvider( getImageProviderFor( pEntryLoop ) ); + + // the images for this entry + Image aImage, aImageHC; + bool bIsFolder = !isObject( pData->eType ); + if ( bIsFolder ) + { + sal_Int32 nObjectType( getDatabaseObjectType( pData->eType ) ); + aImage = pImageProvider->getFolderImage( nObjectType, false ); + aImageHC = pImageProvider->getFolderImage( nObjectType, true ); + } + else + { + sal_Int32 nObjectType( getDatabaseObjectType( pData->eType ) ); + aImage = pImageProvider->getImage( GetEntryText( pEntryLoop ), nObjectType, false ); + aImageHC = pImageProvider->getImage( GetEntryText( pEntryLoop ), nObjectType, true ); + } + + // find the proper item, and set its icons + USHORT nCount = pEntryLoop->ItemCount(); + for (USHORT i=0;iGetItem(i); + if ( !pItem || ( pItem->IsA() != SV_ITEM_ID_LBOXCONTEXTBMP ) ) + continue; + + SvLBoxContextBmp* pContextBitmapItem = static_cast< SvLBoxContextBmp* >( pItem ); + + pContextBitmapItem->SetBitmap1( aImage, BMP_COLOR_NORMAL ); + pContextBitmapItem->SetBitmap2( aImage, BMP_COLOR_NORMAL ); + pContextBitmapItem->SetBitmap1( aImageHC, BMP_COLOR_HIGHCONTRAST ); + pContextBitmapItem->SetBitmap2( aImageHC, BMP_COLOR_HIGHCONTRAST ); + break; + } + + pEntryLoop = m_pTreeModel->Next(pEntryLoop); } } }