Hi,
I have submitted a patch for review:
https://gerrit.libreoffice.org/3259
To pull it, you can do:
git pull ssh://gerrit.libreoffice.org:29418/core refs/changes/59/3259/1
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
---
M sfx2/inc/sfx2/thumbnailview.hxx
M sfx2/source/control/templateabstractview.cxx
M sfx2/source/control/templatelocalview.cxx
M sfx2/source/control/templatesearchview.cxx
M sfx2/source/control/thumbnailview.cxx
5 files changed, 65 insertions(+), 52 deletions(-)
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 @@
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 @@
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 @@
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 @@
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 @@
ImplDeleteItems();
}
+void ThumbnailView::AppendItem(ThumbnailViewItem *pItem)
+{
+ if (maFilterFunc(pItem))
+ mFilteredItemList.push_back(pItem);
+
+ mItemList.push_back(pItem);
+}
+
void ThumbnailView::ImplInit()
{
mpScrBar = NULL;
@@ -221,11 +229,9 @@
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 )
@@ -304,59 +310,35 @@
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;
+ ::com::sun::star::uno::Any aOldAny, aNewAny;
- aNewAny <<= pItem->GetAccessible( mbIsTransientChildrenDisabled );
- ImplFireAccessibleEvent(
::com::sun::star::accessibility::AccessibleEventId::CHILD, aOldAny, aNewAny );
- }
-
- pItem->show(true);
-
- 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);
+ }
+
+ 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;
}
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);
- }
-
- }
-
- ++nCurCount;
+ x += mnItemWidth+nHItemSpace;
}
else
{
@@ -374,7 +356,10 @@
maItemStateHdl.Call(pItem);
}
+
}
+
+ ++nCurCount;
}
// arrange ScrollBar, set values and show it
@@ -870,9 +855,7 @@
mItemList = items;
- CalculateItemPositions();
-
- Invalidate();
+ filterItems(maFilterFunc);
}
size_t ThumbnailView::GetItemPos( sal_uInt16 nItemId ) const
@@ -1070,6 +1053,34 @@
{
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();
--
To view, visit https://gerrit.libreoffice.org/3259
To unsubscribe, visit https://gerrit.libreoffice.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I408785507ef94908d31e4373b407e9d443f72895
Gerrit-PatchSet: 1
Gerrit-Project: core
Gerrit-Branch: libreoffice-4-0
Gerrit-Owner: Rafael Dominguez <venccsralph@gmail.com>
Context
- [PATCH libreoffice-4-0] Avoid generating filter list several times. · Rafael Dominguez (via Code Review)
Privacy Policy |
Impressum (Legal Info) |
Copyright information: Unless otherwise specified, all text and images
on this website are licensed under the
Creative Commons Attribution-Share Alike 3.0 License.
This does not include the source code of LibreOffice, which is
licensed under the Mozilla Public License (
MPLv2).
"LibreOffice" and "The Document Foundation" are
registered trademarks of their corresponding registered owners or are
in actual use as trademarks in one or more countries. Their respective
logos and icons are also subject to international copyright laws. Use
thereof is explained in our
trademark policy.