diff options
author | Rafael Dominguez <venccsralph@gmail.com> | 2013-03-30 17:26:03 -0430 |
---|---|---|
committer | Rafael Dominguez <venccsralph@gmail.com> | 2013-04-05 21:23:10 -0430 |
commit | 86ba7698e6a117967daec23f9580469943f8afda (patch) | |
tree | 101672231940893abf4c3545e50620ca83a33555 /sfx2/source/control | |
parent | 4e4119b2d338b607adff338be01d33d62f3e45f4 (diff) |
Avoid generating filter list several times.
- Only generate the list after applying a new filter function.
- Append item directly to the filtered list if its allowed when appending
a new item to the thumbnailview.
Change-Id: I804533e2a1751abb0cbc3082093aef2cb9093fb0
Diffstat (limited to 'sfx2/source/control')
-rw-r--r-- | sfx2/source/control/templateabstractview.cxx | 2 | ||||
-rw-r--r-- | sfx2/source/control/templatelocalview.cxx | 2 | ||||
-rw-r--r-- | sfx2/source/control/templatesearchview.cxx | 2 | ||||
-rw-r--r-- | sfx2/source/control/thumbnailview.cxx | 105 |
4 files changed, 61 insertions, 50 deletions
diff --git a/sfx2/source/control/templateabstractview.cxx b/sfx2/source/control/templateabstractview.cxx index aae6328c1969..69be29dbc251 100644 --- a/sfx2/source/control/templateabstractview.cxx +++ b/sfx2/source/control/templateabstractview.cxx @@ -162,7 +162,7 @@ void TemplateAbstractView::insertItem(const TemplateItemProperties &rTemplate) pChild->setSelectClickHdl(LINK(this,ThumbnailView,OnItemSelected)); - mItemList.push_back(pChild); + AppendItem(pChild); CalculateItemPositions(); Invalidate(); diff --git a/sfx2/source/control/templatelocalview.cxx b/sfx2/source/control/templatelocalview.cxx index 1f867eaf07b9..9ceb12809e15 100644 --- a/sfx2/source/control/templatelocalview.cxx +++ b/sfx2/source/control/templatelocalview.cxx @@ -262,7 +262,7 @@ sal_uInt16 TemplateLocalView::createRegion(const OUString &rName) pItem->maTitle = aRegionName; pItem->setSelectClickHdl(LINK(this,ThumbnailView,OnItemSelected)); - mItemList.push_back(pItem); + AppendItem(pItem); CalculateItemPositions(); Invalidate(); diff --git a/sfx2/source/control/templatesearchview.cxx b/sfx2/source/control/templatesearchview.cxx index eaec8dc1bf76..c24c567b6946 100644 --- a/sfx2/source/control/templatesearchview.cxx +++ b/sfx2/source/control/templatesearchview.cxx @@ -36,7 +36,7 @@ void TemplateSearchView::AppendItem(sal_uInt16 nAssocItemId, sal_uInt16 nRegionI pItem->setPath(rPath); pItem->setSelectClickHdl(LINK(this,ThumbnailView,OnItemSelected)); - mItemList.push_back(pItem); + ThumbnailView::AppendItem(pItem); CalculateItemPositions(); } diff --git a/sfx2/source/control/thumbnailview.cxx b/sfx2/source/control/thumbnailview.cxx index 488a50d6d824..92030781bbfa 100644 --- a/sfx2/source/control/thumbnailview.cxx +++ b/sfx2/source/control/thumbnailview.cxx @@ -81,6 +81,14 @@ ThumbnailView::~ThumbnailView() ImplDeleteItems(); } +void ThumbnailView::AppendItem(ThumbnailViewItem *pItem) +{ + if (maFilterFunc(pItem)) + mFilteredItemList.push_back(pItem); + + mItemList.push_back(pItem); +} + void ThumbnailView::ImplInit() { mpScrBar = NULL; @@ -220,12 +228,10 @@ void ThumbnailView::CalculateItemPositions () return; Size aWinSize = GetOutputSizePixel(); - size_t nItemCount = mItemList.size(); + size_t nItemCount = mFilteredItemList.size(); WinBits nStyle = GetStyle(); ScrollBar* pDelScrBar = NULL; - mFilteredItemList.clear(); - // consider the scrolling if ( nStyle & WB_VSCROLL ) ImplInitScrollBar(); @@ -300,59 +306,35 @@ void ThumbnailView::CalculateItemPositions () size_t nCurCount = 0; for ( size_t i = 0; i < nItemCount; i++ ) { - ThumbnailViewItem *const pItem = mItemList[i]; + ThumbnailViewItem *const pItem = mFilteredItemList[i]; - if (maFilterFunc(pItem)) + if ((nCurCount >= nFirstItem) && (nCurCount < nLastItem)) { - mFilteredItemList.push_back(pItem); - if ((nCurCount >= nFirstItem) && (nCurCount < nLastItem)) + if( !pItem->isVisible()) { - if( !pItem->isVisible()) + if ( ImplHasAccessibleListeners() ) { - if ( ImplHasAccessibleListeners() ) - { - ::com::sun::star::uno::Any aOldAny, aNewAny; - - aNewAny <<= pItem->GetAccessible( mbIsTransientChildrenDisabled ); - ImplFireAccessibleEvent( ::com::sun::star::accessibility::AccessibleEventId::CHILD, aOldAny, aNewAny ); - } - - pItem->show(true); + ::com::sun::star::uno::Any aOldAny, aNewAny; - maItemStateHdl.Call(pItem); + aNewAny <<= pItem->GetAccessible( mbIsTransientChildrenDisabled ); + ImplFireAccessibleEvent( ::com::sun::star::accessibility::AccessibleEventId::CHILD, aOldAny, aNewAny ); } - pItem->setDrawArea(Rectangle( Point(x,y), Size(mnItemWidth, mnItemHeight) )); - pItem->calculateItemsPosition(mnThumbnailHeight,mnDisplayHeight,mnItemPadding,mpItemAttrs->nMaxTextLenght,mpItemAttrs); + pItem->show(true); - if ( !((nCurCount+1) % mnCols) ) - { - x = nStartX; - y += mnItemHeight+nVItemSpace; - } - else - x += mnItemWidth+nHItemSpace; + maItemStateHdl.Call(pItem); } - else - { - if( pItem->isVisible()) - { - if ( ImplHasAccessibleListeners() ) - { - ::com::sun::star::uno::Any aOldAny, aNewAny; - aOldAny <<= pItem->GetAccessible( mbIsTransientChildrenDisabled ); - ImplFireAccessibleEvent( ::com::sun::star::accessibility::AccessibleEventId::CHILD, aOldAny, aNewAny ); - } - - pItem->show(false); - - maItemStateHdl.Call(pItem); - } + pItem->setDrawArea(Rectangle( Point(x,y), Size(mnItemWidth, mnItemHeight) )); + pItem->calculateItemsPosition(mnThumbnailHeight,mnDisplayHeight,mnItemPadding,mpItemAttrs->nMaxTextLenght,mpItemAttrs); + if ( !((nCurCount+1) % mnCols) ) + { + x = nStartX; + y += mnItemHeight+nVItemSpace; } - - ++nCurCount; + else + x += mnItemWidth+nHItemSpace; } else { @@ -370,7 +352,10 @@ void ThumbnailView::CalculateItemPositions () maItemStateHdl.Call(pItem); } + } + + ++nCurCount; } // arrange ScrollBar, set values and show it @@ -866,9 +851,7 @@ void ThumbnailView::updateItems (const std::vector<ThumbnailViewItem*> &items) mItemList = items; - CalculateItemPositions(); - - Invalidate(); + filterItems(maFilterFunc); } size_t ThumbnailView::GetItemPos( sal_uInt16 nItemId ) const @@ -1048,6 +1031,34 @@ void ThumbnailView::filterItems (const boost::function<bool (const ThumbnailView { mnFirstLine = 0; // start at the top of the list instead of the current position maFilterFunc = func; + mFilteredItemList.clear(); + + for (size_t i = 0, n = mItemList.size(); i < n; ++i) + { + ThumbnailViewItem *const pItem = mItemList[i]; + + if (maFilterFunc(pItem)) + { + mFilteredItemList.push_back(pItem); + } + else + { + if( pItem->isVisible()) + { + if ( ImplHasAccessibleListeners() ) + { + ::com::sun::star::uno::Any aOldAny, aNewAny; + + aOldAny <<= pItem->GetAccessible( mbIsTransientChildrenDisabled ); + ImplFireAccessibleEvent( ::com::sun::star::accessibility::AccessibleEventId::CHILD, aOldAny, aNewAny ); + } + + pItem->show(false); + + maItemStateHdl.Call(pItem); + } + } + } CalculateItemPositions(); |