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 | |
parent | Dont show import action while in save mode. (diff) | |
download | core-86ba7698e6a117967daec23f9580469943f8afda.tar.gz core-86ba7698e6a117967daec23f9580469943f8afda.zip |
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
-rw-r--r-- | sfx2/inc/sfx2/thumbnailview.hxx | 2 | ||||
-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 |
5 files changed, 63 insertions, 50 deletions
diff --git a/sfx2/inc/sfx2/thumbnailview.hxx b/sfx2/inc/sfx2/thumbnailview.hxx index 5287605b7f4c..dbab91cdd079 100644 --- a/sfx2/inc/sfx2/thumbnailview.hxx +++ b/sfx2/inc/sfx2/thumbnailview.hxx @@ -179,6 +179,8 @@ public: virtual ~ThumbnailView (); + void AppendItem (ThumbnailViewItem *pItem); + void RemoveItem( sal_uInt16 nItemId ); void Clear(); 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(); |