[Libreoffice-commits] core.git: Branch 'libreoffice-4-0' - sfx2/inc sfx2/source
Rafael Dominguez
venccsralph at gmail.com
Mon Apr 8 00:39:41 PDT 2013
sfx2/inc/sfx2/thumbnailview.hxx | 2
sfx2/source/control/templateabstractview.cxx | 2
sfx2/source/control/templatelocalview.cxx | 2
sfx2/source/control/templatesearchview.cxx | 2
sfx2/source/control/thumbnailview.cxx | 105 ++++++++++++++-------------
5 files changed, 63 insertions(+), 50 deletions(-)
New commits:
commit 397ebc0260ec6285e5965af26630610e71b5c3fc
Author: Rafael Dominguez <venccsralph at gmail.com>
Date: Sat Mar 30 17:26:03 2013 -0430
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: I408785507ef94908d31e4373b407e9d443f72895
Reviewed-on: https://gerrit.libreoffice.org/3259
Reviewed-by: Miklos Vajna <vmiklos at suse.cz>
Tested-by: Miklos Vajna <vmiklos at suse.cz>
diff --git a/sfx2/inc/sfx2/thumbnailview.hxx b/sfx2/inc/sfx2/thumbnailview.hxx
index 2310060..6d9f30e 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 5c0b563..e28d2e8 100644
--- a/sfx2/source/control/templateabstractview.cxx
+++ b/sfx2/source/control/templateabstractview.cxx
@@ -161,7 +161,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 7ac7b69..6dd82df 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 eaec8dc..c24c567 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 6c64662..725520c 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;
@@ -221,12 +229,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();
@@ -304,59 +310,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
{
@@ -374,7 +356,10 @@ void ThumbnailView::CalculateItemPositions ()
maItemStateHdl.Call(pItem);
}
+
}
+
+ ++nCurCount;
}
// arrange ScrollBar, set values and show it
@@ -870,9 +855,7 @@ void ThumbnailView::updateItems (const std::vector<ThumbnailViewItem*> &items)
mItemList = items;
- CalculateItemPositions();
-
- Invalidate();
+ filterItems(maFilterFunc);
}
size_t ThumbnailView::GetItemPos( sal_uInt16 nItemId ) const
@@ -1070,6 +1053,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();
More information about the Libreoffice-commits
mailing list